/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 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
- * $Id: ExecutionOccurrence.java,v 1.2 2006/09/20 20:56:25 ewchan Exp $
- *
- * Contributors:
- * IBM - Initial API and implementation
- * Bernd Hufmann - Updated for TMF
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ * Bernd Hufmann - Updated for TMF
**********************************************************************/
+
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref;
/**
* ExecutionOccurrence is the UML2 execution occurrence graphical representation. It is a BasicExecutionOccurrence on
- * which you can customize fill and/or
- *
+ * which you can customize fill and/or.
+ *
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline Lifeline for more event occurence details
+ * @version 1.0
* @author sveyrier
- *
+ *
*/
public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITimeRange {
- protected int[] fillRGB;
- protected int[] strokeRGB;
- protected IImage image, ellipsesImage;
-
- protected ITmfTimestamp startTime, endTime;
- protected boolean hasTime;
-
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * Set the red, green and blue value of the optional color to be used for filling the execution occurrence.
+ */
+ protected int[] fFillRGB;
+ /**
+ * Set the red, green and blue value of the optional color to be used for drawing the execution occurrence
+ */
+ protected int[] fStrokeRGB;
+ /**
+ * The occurrence image.
+ */
+ protected IImage fImage;
+ /**
+ * The top ellipses image.
+ */
+ protected IImage fEllipsesImage;
+ /**
+ * The start time stamp.
+ */
+ protected ITmfTimestamp fStartTime;
/**
- * Set the lifeline on which the execution occurrence appears.
- *
- * @param theLifeline - the parent lifeline
+ * The end time stamp;
+ */
+ protected ITmfTimestamp fEndTime;
+ /**
+ * Flag to indicate whether time information is available or not.
+ */
+ protected boolean fHasTimeInfo;
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#setLifeline(org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline)
*/
@Override
public void setLifeline(Lifeline theLifeline) {
super.setLifeline(theLifeline);
- if (lifeline != null && hasTime) {
- lifeline.hasTime = true;
- if (lifeline.getFrame() != null) {
- lifeline.getFrame().setHasTimeInfo(true);
+ if (fLifeline != null && fHasTimeInfo) {
+ fLifeline.fHasTimeInfo = true;
+ if (fLifeline.getFrame() != null) {
+ fLifeline.getFrame().setHasTimeInfo(true);
}
}
}
/**
- * Set the red, green and blue value of the optional color to be used for filling the execution occurrence
- *
- * @param _r
- * @param _g
- * @param _b
- */
- public void setFillColor(int _r, int _g, int _b) {
- fillRGB = new int[3];
- fillRGB[0] = _r;
- fillRGB[1] = _g;
- fillRGB[2] = _b;
+ * Set the red, green and blue value of the optional color to be used for filling the execution occurrence.
+ *
+ * @param red A value for red.
+ * @param green A green value for green.
+ * @param blue A value blue.
+ */
+ public void setFillColor(int red, int green, int blue) {
+ fFillRGB = new int[3];
+ fFillRGB[0] = red;
+ fFillRGB[1] = green;
+ fFillRGB[2] = blue;
}
/**
* Set the red, green and blue value of the optional color to be used for drawing the execution occurrence
- *
- * @param _r
- * @param _g
- * @param _b
- */
- public void setStrokeColor(int _r, int _g, int _b) {
- strokeRGB = new int[3];
- strokeRGB[0] = _r;
- strokeRGB[1] = _g;
- strokeRGB[2] = _b;
+ *
+ * @param red A value for red.
+ * @param green A green value for green.
+ * @param blue A value blue.
+ */
+ public void setStrokeColor(int red, int green, int blue) {
+ fStrokeRGB = new int[3];
+ fStrokeRGB[0] = red;
+ fStrokeRGB[1] = green;
+ fStrokeRGB[2] = blue;
}
- public void setImage(IImage image_) {
- image = image_;
+ /**
+ * Set the corresponding image.
+ *
+ * @param image A image to set.
+ */
+ public void setImage(IImage image) {
+ fImage = image;
}
- public void setTopEllipsesImage(IImage image_) {
- ellipsesImage = image_;
+ /**
+ * Set the top ellipses image.
+ *
+ * @param image A image to set.
+ */
+ public void setTopEllipsesImage(IImage image) {
+ fEllipsesImage = image;
}
/**
- * Set the time when the execution occurrence starts.<br>
- *
+ * Set the time when the execution occurrence starts.
+ *
* @param time the time when the execution occurrence starts
+ * @since 2.0
*/
- public void setStartTime(TmfTimestamp time) {
- startTime = time.clone();
- hasTime = true;
- if (lifeline != null) {
- lifeline.setTimeInfo(true);
+ public void setStartTime(ITmfTimestamp time) {
+ fStartTime = time;
+ fHasTimeInfo = true;
+ if (fLifeline != null) {
+ fLifeline.setTimeInfo(true);
}
}
/**
- * Set the time when the execution occurrence ends.<br>
- *
+ * Set the time when the execution occurrence ends.
+ *
* @param time the time when the execution occurrence ends
+ * @since 2.0
*/
- public void setEndTime(TmfTimestamp time) {
- endTime = time.clone();
- hasTime = true;
- if (lifeline != null) {
- lifeline.setTimeInfo(true);
+ public void setEndTime(ITmfTimestamp time) {
+ fEndTime = time;
+ fHasTimeInfo = true;
+ if (fLifeline != null) {
+ fLifeline.setTimeInfo(true);
}
}
/**
- * Returns the time when the execution occurrence starts
- *
- * @return the time
+ * @since 2.0
*/
@Override
public ITmfTimestamp getStartTime() {
- return startTime;
+ return fStartTime;
}
/**
- * Returns the time when the execution occurrence ends
- *
- * @return the time
+ * @since 2.0
*/
@Override
public ITmfTimestamp getEndTime() {
- return endTime;
+ return fEndTime;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#hasTimeInfo()
+ */
@Override
public boolean hasTimeInfo() {
- return hasTime;
+ return fHasTimeInfo;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
+ */
@Override
public void draw(IGC context) {
super.draw(context);
int y = getY();
int width = getWidth();
int height = getHeight();
- if (image != null) {
- context.drawImage(image, x + width - 4, y + height - 11, 8, 11);
+ if (fImage != null) {
+ context.drawImage(fImage, x + width - 4, y + height - 11, 8, 11);
}
- if (ellipsesImage != null) {
- context.drawImage(ellipsesImage, x + width, y, 40, 10);
+ if (fEllipsesImage != null) {
+ context.drawImage(fEllipsesImage, x + width, y, 40, 10);
}
}
- /**
- * Extension in order to support customized fill colors
- *
- * @param context
- * @return IColor
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#setUnselectedFillColor(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
*/
@Override
protected IColor setUnselectedFillColor(IGC context) {
- if (fillRGB != null) {
- IColor tempFillColor = context.createColor(fillRGB[0], fillRGB[1], fillRGB[2]);
- if (Frame.getUserPref().useGradienColor()) {
+ ISDPreferences pref = SDViewPref.getInstance();
+ if (fFillRGB != null) {
+ IColor tempFillColor = context.createColor(fFillRGB[0], fFillRGB[1], fFillRGB[2]);
+ if (pref.useGradienColor()) {
context.setGradientColor(tempFillColor);
- context.setForeground(Frame.getUserPref().getForeGroundColor(ISDPreferences.PREF_EXEC));
- context.setBackground(Frame.getUserPref().getBackGroundColor(ISDPreferences.PREF_FRAME));
- } else
+ context.setForeground(pref.getForeGroundColor(ISDPreferences.PREF_EXEC));
+ context.setBackground(pref.getBackGroundColor(ISDPreferences.PREF_FRAME));
+ } else {
context.setBackground(tempFillColor);
+ }
return tempFillColor;
- } else {
- return super.setUnselectedFillColor(context);
}
+ return super.setUnselectedFillColor(context);
}
- /**
- * Extension in order to support customized stroke colors
- *
- * @param context
- * @return IColor
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#setUnselectedStrokeColor(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
*/
@Override
protected IColor setUnselectedStrokeColor(IGC context) {
- if (strokeRGB != null) {
- IColor tempStrokeColor = context.createColor(strokeRGB[0], strokeRGB[1], strokeRGB[2]);
+ if (fStrokeRGB != null) {
+ IColor tempStrokeColor = context.createColor(fStrokeRGB[0], fStrokeRGB[1], fStrokeRGB[2]);
context.setForeground(tempStrokeColor);
return tempStrokeColor;
- } else {
- return super.setUnselectedStrokeColor(context);
}
+ return super.setUnselectedStrokeColor(context);
}
}