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 / AsyncMessage.java
index 52047a78caeb44ec1f9b2aa10aec56a1fb4d22ea..31867f8be4f789bb2d020789276766bd4934eed4 100755 (executable)
@@ -1,14 +1,15 @@
 /**********************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * 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
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- * IBM - Initial API and implementation
- * Bernd Hufmann - Updated for TMF
+ *     IBM - Initial API and implementation
+ *     Bernd Hufmann - Updated for TMF
  **********************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
 
 import java.util.Comparator;
@@ -66,15 +67,15 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
     /**
      * Flag whether message has time information or not.
      */
-    protected boolean fHasTime = false;
+    private boolean fHasTime = false;
     /**
      * The time when the message begin
      */
-    protected ITmfTimestamp fEndTime = new TmfTimestamp();
+    private ITmfTimestamp fEndTime = new TmfTimestamp();
     /**
      * The time when the message end
      */
-    protected ITmfTimestamp fStartTime = new TmfTimestamp();
+    private ITmfTimestamp fStartTime = new TmfTimestamp();
     /**
      * The associated message.
      */
@@ -87,73 +88,58 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
      * Default constructor
      */
     public AsyncMessage() {
-        fPrefId = ISDPreferences.PREF_ASYNC_MESS;
+        setColorPrefId(ISDPreferences.PREF_ASYNC_MESS);
     }
 
     // ------------------------------------------------------------------------
     // Methods
     // ------------------------------------------------------------------------
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#getX()
-     */
+
     @Override
     public int getX() {
         int x = super.getX(true);
         int activationWidth = Metrics.EXECUTION_OCCURRENCE_WIDTH / 2;
-        if ((fStartLifeline != null) && (fEndLifeline != null) && (fStartLifeline.getX() > fEndLifeline.getX())) {
+        if ((getStartLifeline() != null) && (getEndLifeline() != null) && (getStartLifeline().getX() > getEndLifeline().getX())) {
             activationWidth = -activationWidth;
         }
 
-        if (isMessageStartInActivation(fStartEventOccurrence)) {
+        if (isMessageStartInActivation(getStartOccurrence())) {
             x = x + activationWidth;
         }
         return x;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#getY()
-     */
     @Override
     public int getY() {
-        if ((fStartLifeline != null) && (fEndLifeline != null)) {
-            return fEndLifeline.getY() + fEndLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fStartEventOccurrence;
+        if ((getStartLifeline() != null) && (getEndLifeline() != null)) {
+            return getEndLifeline().getY() + getEndLifeline().getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * getStartOccurrence();
         }
         return super.getY();
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#getWidth()
-     */
     @Override
     public int getWidth() {
         int width = super.getWidth(true);
         int activationWidth = Metrics.EXECUTION_OCCURRENCE_WIDTH / 2;
-        if ((fStartLifeline != null) && (fEndLifeline != null) && (fStartLifeline.getX() > fEndLifeline.getX())) {
+        if ((getStartLifeline() != null) && (getEndLifeline() != null) && (getStartLifeline().getX() > getEndLifeline().getX())) {
             activationWidth = -activationWidth;
         }
 
-        if (isMessageStartInActivation(fStartEventOccurrence)) {
+        if (isMessageStartInActivation(getStartOccurrence())) {
             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.BaseMessage#getHeight()
-     */
     @Override
     public int getHeight() {
-        if ((fStartLifeline != null) && (fEndLifeline != null)) {
-            return (fEndLifeline.getY() + fEndLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fEndEventOccurrence) - getY();
+        if ((getStartLifeline() != null) && (getEndLifeline() != null)) {
+            return (getEndLifeline().getY() + getEndLifeline().getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * getEndOccurrence()) - getY();
         }
         return super.getHeight();
     }
@@ -172,10 +158,11 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
      *
      * @param occurrence the event occurrence to set
      */
+    @Override
     public void setEndOccurrence(int occurrence) {
-        fEndEventOccurrence = occurrence;
+        super.setEndOccurrence(occurrence);
         if (getStartLifeline() == null) {
-            fStartEventOccurrence = occurrence;
+            setStartOccurrence(occurrence);
         }
         informFrame(getEndLifeline(), occurrence);
     }
@@ -199,10 +186,11 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
      *
      * @param occurrence the event occurrence to set
      */
+    @Override
     public void setStartOccurrence(int occurrence) {
-        fStartEventOccurrence = occurrence;
+        super.setStartOccurrence(occurrence);
         if (getEndLifeline() == null) {
-            fEndEventOccurrence = fStartEventOccurrence;
+            setEndOccurrence(getStartOccurrence());
         }
         informFrame(getStartLifeline(), occurrence);
     }
@@ -229,23 +217,15 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
         setEndLifeline(lifeline);
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#setStartLifeline(org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline)
-     */
     @Override
     public void setStartLifeline(Lifeline lifeline) {
         super.setStartLifeline(lifeline);
         setStartOccurrence(getStartLifeline().getEventOccurrence());
         if (getEndLifeline() == null) {
-            fEndEventOccurrence = fStartEventOccurrence;
+            setEndOccurrence(getStartOccurrence());
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#setEndLifeline(org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline)
-     */
     @Override
     public void setEndLifeline(Lifeline lifeline) {
         super.setEndLifeline(lifeline);
@@ -286,14 +266,10 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
         return false;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#contains(int, int)
-     */
     @Override
     public boolean contains(int x, int y) {
         // Is it a self message?
-        if (fStartLifeline == fEndLifeline) {
+        if (getStartLifeline() == getEndLifeline()) {
             return super.contains(x, y);
         }
         if (isNearSegment(getX(), getY(), getX() + getWidth(), getY() + getHeight(), x, y)) {
@@ -319,13 +295,13 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
      * @param context A graphical context to draw in.
      */
     protected void drawAsyncMessage(IGC context) {
-        if (fStartLifeline != null && fEndLifeline != null && fStartLifeline == fEndLifeline && (fStartEventOccurrence != fEndEventOccurrence)) {
+        if (getStartLifeline() != null && getEndLifeline() != null && getStartLifeline() == getEndLifeline() && (getStartOccurrence() != getEndOccurrence())) {
             int x = getX();
             int y = getY();
             int height = getHeight();
             int tempx = 0;
-            boolean startInActivation = isMessageStartInActivation(fStartEventOccurrence);
-            boolean endInActivation = isMessageEndInActivation(fEndEventOccurrence);
+            boolean startInActivation = isMessageStartInActivation(getStartOccurrence());
+            boolean endInActivation = isMessageEndInActivation(getEndOccurrence());
 
             if (endInActivation && !startInActivation) {
                 tempx = Metrics.EXECUTION_OCCURRENCE_WIDTH / 2;
@@ -358,10 +334,6 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
-     */
     @Override
     public void draw(IGC context) {
         if (!isVisible()) {
@@ -371,7 +343,7 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
         ISDPreferences pref = SDViewPref.getInstance();
 
         // Draw it selected?
-        if (isSelected() && (fStartLifeline != null && fEndLifeline != null && fStartLifeline == fEndLifeline && (fStartEventOccurrence != fEndEventOccurrence))) {
+        if (isSelected() && (getStartLifeline() != null && getEndLifeline() != null && getStartLifeline() == getEndLifeline() && (getStartOccurrence() != getEndOccurrence()))) {
             /*
              * Draw it twice First time, bigger inverting selection colors Second time, regular drawing using selection
              * colors This create the highlight effect
@@ -383,8 +355,8 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
             context.setForeground(pref.getForeGroundColorSelection());
             // Second drawing is done after the else
         } else {
-            context.setBackground(pref.getBackGroundColor(fPrefId));
-            context.setForeground(pref.getForeGroundColor(fPrefId));
+            context.setBackground(pref.getBackGroundColor(getColorPrefId()));
+            context.setForeground(pref.getForeGroundColor(getColorPrefId()));
         }
         if (hasFocus()) {
             context.setDrawTextWithFocusStyle(true);
@@ -449,10 +421,14 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
         return fHasTime;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#isVisible(int, int, int, int)
+    /**
+     *  @return message return instance or null
+     *  @since 2.0
      */
+    public AsyncMessageReturn getMessageReturn() {
+        return fMessageReturn;
+    }
+
     @Override
     public boolean isVisible(int x, int y, int width, int height) {
         int toDrawY = getY();
@@ -466,37 +442,21 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
         return super.isVisible(x, y, width, height);
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getComparator()
-     */
     @Override
     public Comparator<GraphNode> getComparator() {
         return new SortAsyncMessageComparator();
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getArrayId()
-     */
     @Override
     public String getArrayId() {
         return ASYNC_MESS_TAG;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getBackComparator()
-     */
     @Override
     public Comparator<GraphNode> getBackComparator() {
         return new SortAsyncForBackward();
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#positiveDistanceToPoint(int, int)
-     */
     @Override
     public boolean positiveDistanceToPoint(int x, int y) {
         int mY = getY();
This page took 0.036921 seconds and 5 git commands to generate.