tmf: API clean-up of sequence diagram framework
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / core / BaseMessage.java
index 195289b833df61aad92c9cbb21a915c6cebb29ad..b35340b6ce7e0c5a3ec6ba0d0f277e395064a7a2 100755 (executable)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2005, 2012 IBM Corporation, Ericsson
+ * Copyright (c) 2005, 2013 IBM Corporation, Ericsson
  * All rights reserved.   This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -38,33 +38,26 @@ public abstract class BaseMessage extends GraphNode {
     /**
      * The lifeline which send the message
      */
-    protected Lifeline fStartLifeline = null;
+    private Lifeline fStartLifeline = null;
     /**
      * The lifeline which receive the message
      */
-    protected Lifeline fEndLifeline = null;
+    private Lifeline fEndLifeline = null;
     /**
      * The visiblitiy flag.
      */
-    protected boolean fVisible = true;
+    private boolean fVisible = true;
 
     // ------------------------------------------------------------------------
     // Methods
     // ------------------------------------------------------------------------
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getX()
-     */
+
     @Override
     public int getX() {
         // returns the exact x coordinate
         return getX(false);
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getY()
-     */
     @Override
     public int getY() {
         /*
@@ -76,40 +69,32 @@ public abstract class BaseMessage extends GraphNode {
             /*
              * Regular message, both ends are attached to a lifeline
              */
-            return fEndLifeline.getY() + fEndLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fEndEventOccurrence;
+            return fEndLifeline.getY() + fEndLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * getEndOccurrence();
 
         }
         /*
          * UML2 lost message kind
          */
         if (fStartLifeline != null) {
-            return fStartLifeline.getY() + fStartLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fEndEventOccurrence;
+            return fStartLifeline.getY() + fStartLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * getEndOccurrence();
         }
 
         /*
          * UML2 found message kind
          */
         if (fEndLifeline != null) {
-            return fEndLifeline.getY() + fEndLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fEndEventOccurrence;
+            return fEndLifeline.getY() + fEndLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * getEndOccurrence();
         }
         // return 0 by default
         return 0;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getWidth()
-     */
     @Override
     public int getWidth() {
         // Returns the exact width
         return getWidth(false);
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getHeight()
-     */
     @Override
     public int getHeight() {
         return 0;
@@ -153,7 +138,7 @@ public abstract class BaseMessage extends GraphNode {
             activationWidth = -activationWidth;
         }
 
-        if (isMessageStartInActivation(fEndEventOccurrence)) {
+        if (isMessageStartInActivation(getEndOccurrence())) {
             x = x + activationWidth;
         }
 
@@ -201,21 +186,17 @@ public abstract class BaseMessage extends GraphNode {
             activationWidth = -activationWidth;
         }
 
-        if (isMessageStartInActivation(fEndEventOccurrence)) {
+        if (isMessageStartInActivation(getEndOccurrence())) {
             width = width - activationWidth;
         }
 
-        if (isMessageEndInActivation(fEndEventOccurrence)) {
+        if (isMessageEndInActivation(getEndOccurrence())) {
             width = width - activationWidth;
         }
 
         return width;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#isVisible(int, int, int, int)
-     */
     @Override
     public boolean isVisible(int x, int y, int width, int height) {
         // ***Common*** syncMessages visibility
@@ -293,7 +274,7 @@ public abstract class BaseMessage extends GraphNode {
      * @see Lifeline Lifeline for more event occurence details
      */
     protected void setEventOccurrence(int occurrence) {
-        fEndEventOccurrence = occurrence;
+        setEndOccurrence(occurrence);
     }
 
     /**
@@ -303,7 +284,7 @@ public abstract class BaseMessage extends GraphNode {
      * @see Lifeline Lifeline for more event occurence details
      */
     public int getEventOccurrence() {
-        return fEndEventOccurrence;
+        return getEndOccurrence();
     }
 
     /**
@@ -325,7 +306,7 @@ public abstract class BaseMessage extends GraphNode {
             int thisY = getY();
             for (int i = 0; i < fStartLifeline.getExecutions().size(); i++) {
                 BasicExecutionOccurrence toDraw = (BasicExecutionOccurrence) fStartLifeline.getExecutions().get(i);
-                if ((event >= toDraw.fStartEventOccurrence) && (event <= toDraw.fEndEventOccurrence)) {
+                if ((event >= toDraw.getStartOccurrence()) && (event <= toDraw.getEndOccurrence())) {
                     inActivation = true;
                 }
                 // if we are outside the visible area we stop right now
@@ -355,7 +336,7 @@ public abstract class BaseMessage extends GraphNode {
             // for drawing speed reason with only search on the visivle subset
             for (int i = 0; i < fEndLifeline.getExecutions().size(); i++) {
                 BasicExecutionOccurrence toDraw = (BasicExecutionOccurrence) fEndLifeline.getExecutions().get(i);
-                if ((event >= toDraw.fStartEventOccurrence) && (event <= toDraw.fEndEventOccurrence)) {
+                if ((event >= toDraw.getStartOccurrence()) && (event <= toDraw.getEndOccurrence())) {
                     inActivation = true;
                 }
                 // if we are outside the visible area we stop right now
@@ -368,10 +349,6 @@ public abstract class BaseMessage extends GraphNode {
         return inActivation;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#contains(int, int)
-     */
     @Override
     public boolean contains(int xValue, int yValue) {
         int x = getX();
@@ -430,8 +407,10 @@ public abstract class BaseMessage extends GraphNode {
      * @param context A graphical context to draw in.
      */
     protected void drawMessage(IGC context) {
-        int fX, fY, fW, fH;
-        fX = fY = fW = fH = 0;
+        int fX = 0;
+        int fY = 0;
+        int fW = 0;
+        int fH = 0;
 
         // temporary store the coordinates to avoid more methods calls
         int x = getX();
@@ -448,7 +427,7 @@ public abstract class BaseMessage extends GraphNode {
             // The label is truncated if it cannot fit between the two message end
             // 2*Metrics.MESSAGES_NAME_SPACING = space above the label + space below the label
             IColor temp = context.getForeground();
-            context.setForeground(pref.getFontColor(fPrefId));
+            context.setForeground(pref.getFontColor(getColorPrefId()));
             context.drawTextTruncatedCentred(getName(), x, y - Metrics.getMessageFontHeigth() - 2 * Metrics.MESSAGES_NAME_SPACING, width, 2 * Metrics.MESSAGES_NAME_SPACING + Metrics.getMessageFontHeigth(), !isSelected());
             context.setForeground(temp);
             int margin = 0;
@@ -492,7 +471,7 @@ public abstract class BaseMessage extends GraphNode {
                 context.fillOval(x + width - ray, y + height - ray, ray * 2, ray * 2);
             }
             context.setBackground(storedColor);
-            context.setForeground(pref.getFontColor(fPrefId));
+            context.setForeground(pref.getFontColor(getColorPrefId()));
             fX = x;
             fY = y - yt.intValue();
             fW = width;
@@ -553,7 +532,7 @@ public abstract class BaseMessage extends GraphNode {
             // 2*Metrics.MESSAGES_NAME_SPACING = space above the label + space below the label
 
             // the space available for the text is sorter if are drawing internal message on the last lifeline
-            context.setForeground(pref.getFontColor(fPrefId));
+            context.setForeground(pref.getFontColor(getColorPrefId()));
             if (fStartLifeline.getIndex() == fStartLifeline.getFrame().getHorizontalIndex()) {
                 context.drawTextTruncated(getName(), x + width + Metrics.INTERNAL_MESSAGE_V_MARGIN / 2, y, Metrics.swimmingLaneWidth() / 2 - Metrics.EXECUTION_OCCURRENCE_WIDTH + -Metrics.INTERNAL_MESSAGE_WIDTH, +Metrics.MESSAGES_NAME_SPACING
                         - Metrics.getMessageFontHeigth(), !isSelected());
@@ -618,7 +597,7 @@ public abstract class BaseMessage extends GraphNode {
             // Draw the message label above the message and centered
             // The label is truncated if it cannot fit between the two message end
             // 2*Metrics.MESSAGES_NAME_SPACING = space above the label + space below the label
-            context.setForeground(pref.getFontColor(fPrefId));
+            context.setForeground(pref.getFontColor(getColorPrefId()));
             if (spaceBTWStartEnd > 0) {
                 context.drawTextTruncatedCentred(getName(), x, y + height / 2 - (2 * Metrics.MESSAGES_NAME_SPACING + Metrics.getMessageFontHeigth()), width, 2 * Metrics.MESSAGES_NAME_SPACING + Metrics.getMessageFontHeigth(), !isSelected());
             } else {
@@ -627,10 +606,6 @@ public abstract class BaseMessage extends GraphNode {
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNodee#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
-     */
     @Override
     public void draw(IGC context) {
         if (!isVisible()) {
@@ -723,24 +698,20 @@ public abstract class BaseMessage extends GraphNode {
         context.drawPolygon(points);
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#drawFocus(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
-     */
     @Override
     public void drawFocus(IGC context) {
 
         ISDPreferences pref = SDViewPref.getInstance();
 
-        if ((fStartLifeline != fEndLifeline) && (fStartEventOccurrence == fEndEventOccurrence)) {
+        if ((fStartLifeline != fEndLifeline) && (getStartOccurrence() == getEndOccurrence())) {
             context.setLineStyle(context.getLineDotStyle());
             context.setLineWidth(Metrics.NORMAL_LINE_WIDTH);
             context.setBackground(pref.getBackGroundColorSelection());
             context.setForeground(pref.getForeGroundColorSelection());
             context.drawFocus(getX(), getY() - 3, getWidth(), getHeight() + 6);
-        } else if ((fStartLifeline == fEndLifeline) && (fStartEventOccurrence == fEndEventOccurrence)) {
+        } else if ((fStartLifeline == fEndLifeline) && (getStartOccurrence() == getEndOccurrence())) {
             context.drawFocus(getX(), getY() - 3, getWidth(), Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT + 6);
-        } else if ((fStartLifeline != fEndLifeline) && (fStartEventOccurrence != fEndEventOccurrence)) {
+        } else if ((fStartLifeline != fEndLifeline) && (getStartOccurrence() != getEndOccurrence())) {
             context.setLineStyle(context.getLineDotStyle());
             context.setLineWidth(Metrics.NORMAL_LINE_WIDTH);
             context.setBackground(pref.getBackGroundColor(ISDPreferences.PREF_LIFELINE_HEADER));
This page took 0.036268 seconds and 5 git commands to generate.