/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 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: BaseMessage.java,v 1.3 2008/01/24 02:28:49 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
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.ISDPreferences;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref;
/**
* The base UML2 syncMessages implementation.<br>
* <br>
*
* @see Lifeline Lifeline for more event occurence details
+ * @version 1.0
* @author sveyrier
*/
public abstract class BaseMessage extends GraphNode {
-
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
/**
* The lifeline which send the message
*/
- protected Lifeline startLifeline = null;
-
+ protected Lifeline fStartLifeline = null;
/**
* The lifeline which receive the message
*/
- protected Lifeline endLifeline = null;
-
- protected boolean visible = true;
-
+ protected Lifeline fEndLifeline = null;
+ /**
+ * The visiblitiy flag.
+ */
+ protected 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() {
/*
* lifeline name getHeight return the height of this rectangle The message y coordinate is then relative to this
* position depending of its eventOccurrence Space between syncMessages is constant
*/
- if ((startLifeline != null) && (endLifeline != null)) {
+ if ((fStartLifeline != null) && (fEndLifeline != null)) {
/*
* Regular message, both ends are attached to a lifeline
*/
- return endLifeline.getY() + endLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * endEventOccurrence;
+ return fEndLifeline.getY() + fEndLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fEndEventOccurrence;
} else {
/*
* UML2 lost message kind
*/
- if (startLifeline != null) {
- return startLifeline.getY() + startLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * endEventOccurrence;
+ if (fStartLifeline != null) {
+ return fStartLifeline.getY() + fStartLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fEndEventOccurrence;
}
/*
* UML2 found message kind
*/
- if (endLifeline != null) {
- return endLifeline.getY() + endLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * endEventOccurrence;
+ if (fEndLifeline != null) {
+ return fEndLifeline.getY() + fEndLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fEndEventOccurrence;
}
}
// 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;
protected int getX(boolean quick) {
int x = 0;
int activationWidth = Metrics.EXECUTION_OCCURRENCE_WIDTH / 2;
- if ((startLifeline != null) && (endLifeline != null)) {
- x = startLifeline.getX() + Metrics.getLifelineWidth() / 2;
+ if ((fStartLifeline != null) && (fEndLifeline != null)) {
+ x = fStartLifeline.getX() + Metrics.getLifelineWidth() / 2;
} else {
- if (startLifeline != null) {
- x = startLifeline.getX() + Metrics.getLifelineWidth() / 2;
+ if (fStartLifeline != null) {
+ x = fStartLifeline.getX() + Metrics.getLifelineWidth() / 2;
}
- if (endLifeline != null) {
- x = endLifeline.getX() - Metrics.LIFELINE_SPACING / 2;
+ if (fEndLifeline != null) {
+ x = fEndLifeline.getX() - Metrics.LIFELINE_SPACING / 2;
}
}
- if (quick)
+ if (quick) {
return x;
+ }
- if ((startLifeline != null) && (endLifeline != null) && (startLifeline.getX() > endLifeline.getX())) {
+ if ((fStartLifeline != null) && (fEndLifeline != null) && (fStartLifeline.getX() > fEndLifeline.getX())) {
activationWidth = -activationWidth;
}
- if (isMessageStartInActivation(endEventOccurrence)) {
+ if (isMessageStartInActivation(fEndEventOccurrence)) {
x = x + activationWidth;
}
protected int getWidth(boolean quick) {
int width = 0;
int activationWidth = Metrics.EXECUTION_OCCURRENCE_WIDTH / 2;
- if ((startLifeline != null) && (endLifeline != null)) {
- if (startLifeline == endLifeline)
+ if ((fStartLifeline != null) && (fEndLifeline != null)) {
+ if (fStartLifeline == fEndLifeline) {
width = Metrics.INTERNAL_MESSAGE_WIDTH + Metrics.EXECUTION_OCCURRENCE_WIDTH;
- else
- width = endLifeline.getX() + Metrics.getLifelineWidth() / 2 - getX(true);
+ } else {
+ width = fEndLifeline.getX() + Metrics.getLifelineWidth() / 2 - getX(true);
+ }
} else {
- if (startLifeline != null) {
+ if (fStartLifeline != null) {
width = Metrics.swimmingLaneWidth() / 2;
}
- if (endLifeline != null) {
+ if (fEndLifeline != null) {
width = Metrics.swimmingLaneWidth() / 2;
}
}
- if (quick)
+ if (quick) {
return width;
+ }
- if ((startLifeline != null) && (endLifeline != null) && (startLifeline.getX() > endLifeline.getX())) {
+ if ((fStartLifeline != null) && (fEndLifeline != null) && (fStartLifeline.getX() > fEndLifeline.getX())) {
activationWidth = -activationWidth;
}
- if (isMessageStartInActivation(endEventOccurrence))
+ if (isMessageStartInActivation(fEndEventOccurrence)) {
width = width - activationWidth;
+ }
- if (isMessageEndInActivation(endEventOccurrence))
+ if (isMessageEndInActivation(fEndEventOccurrence)) {
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
// draw the message only if at least one end is visible
- if (endLifeline != null && (endLifeline.isVisible(x, y, width, height)) || (startLifeline != null && startLifeline.isVisible(x, y, width, height)))
+ if (fEndLifeline != null && (fEndLifeline.isVisible(x, y, width, height)) || (fStartLifeline != null && fStartLifeline.isVisible(x, y, width, height))) {
return true;
+ }
// In this case it can be a message which cross the whole visible area
- else if (endLifeline != null && (!endLifeline.isVisible(x, y, width, height)) && (startLifeline != null && !startLifeline.isVisible(x, y, width, height))) {
- if (endLifeline.getX() > x + width && startLifeline.getX() < x)
+ else if (fEndLifeline != null && (!fEndLifeline.isVisible(x, y, width, height)) && (fStartLifeline != null && !fStartLifeline.isVisible(x, y, width, height))) {
+ if (fEndLifeline.getX() > x + width && fStartLifeline.getX() < x) {
return true;
- else if (startLifeline.getX() > x + width && endLifeline.getX() < x)
+ } else if (fStartLifeline.getX() > x + width && fEndLifeline.getX() < x) {
return true;
+ }
}
return false;
}
+ /**
+ * Sets the visibility value.
+ *
+ * @param value The visibility to set.
+ */
public void setVisible(boolean value) {
- visible = value;
+ fVisible = value;
}
+ /**
+ * @return the visibility value.
+ */
public boolean isVisible() {
- return visible;
+ return fVisible;
}
/**
* @param lifeline - the message sender
*/
public void setStartLifeline(Lifeline lifeline) {
- startLifeline = lifeline;
+ fStartLifeline = lifeline;
}
/**
* @return the message sender
*/
public Lifeline getStartLifeline() {
- return startLifeline;
+ return fStartLifeline;
}
/**
* @return the message receiver
*/
public Lifeline getEndLifeline() {
- return endLifeline;
+ return fEndLifeline;
}
/**
* @param lifeline the message receiver
*/
public void setEndLifeline(Lifeline lifeline) {
- endLifeline = lifeline;
+ fEndLifeline = lifeline;
}
/**
* @see Lifeline Lifeline for more event occurence details
*/
protected void setEventOccurrence(int occurrence) {
- endEventOccurrence = occurrence;
+ fEndEventOccurrence = occurrence;
}
/**
* @see Lifeline Lifeline for more event occurence details
*/
public int getEventOccurrence() {
- return endEventOccurrence;
+ return fEndEventOccurrence;
}
/**
*/
protected boolean isMessageStartInActivation(int event) {
boolean inActivation = false;
- if ((startLifeline != null) && (startLifeline.getExecutions() != null)) {
+ if ((fStartLifeline != null) && (fStartLifeline.getExecutions() != null)) {
// int acIndex=startLifeline.getExecOccurrenceDrawIndex();
// acIndex = first visible execution occurrence
// for drawing speed reason with only search on the visivle subset
int thisY = getY();
- for (int i = 0; i < startLifeline.getExecutions().size(); i++) {
- BasicExecutionOccurrence toDraw = (BasicExecutionOccurrence) startLifeline.getExecutions().get(i);
- if ((event >= toDraw.startEventOccurrence) && (event <= toDraw.endEventOccurrence))
+ for (int i = 0; i < fStartLifeline.getExecutions().size(); i++) {
+ BasicExecutionOccurrence toDraw = (BasicExecutionOccurrence) fStartLifeline.getExecutions().get(i);
+ if ((event >= toDraw.fStartEventOccurrence) && (event <= toDraw.fEndEventOccurrence)) {
inActivation = true;
+ }
// if we are outside the visible area we stop right now
// This works because execution occurrences are ordered along the Y axis
- if (toDraw.getY() > thisY)
+ if (toDraw.getY() > thisY) {
break;
+ }
}
}
return inActivation;
*/
protected boolean isMessageEndInActivation(int event) {
boolean inActivation = false;
- if ((endLifeline != null) && (endLifeline.getExecutions() != null)) {
+ if ((fEndLifeline != null) && (fEndLifeline.getExecutions() != null)) {
// acIndex = first visible execution occurrence
// for drawing speed reason with only search on the visivle subset
- for (int i = 0; i < endLifeline.getExecutions().size(); i++) {
- BasicExecutionOccurrence toDraw = (BasicExecutionOccurrence) endLifeline.getExecutions().get(i);
- if ((event >= toDraw.startEventOccurrence) && (event <= toDraw.endEventOccurrence))
+ for (int i = 0; i < fEndLifeline.getExecutions().size(); i++) {
+ BasicExecutionOccurrence toDraw = (BasicExecutionOccurrence) fEndLifeline.getExecutions().get(i);
+ if ((event >= toDraw.fStartEventOccurrence) && (event <= toDraw.fEndEventOccurrence)) {
inActivation = true;
+ }
// if we are outside the visible area we stop right now
// This works because execution occurrences are ordered along the Y axis
- if (toDraw.getY() > getY())
+ if (toDraw.getY() > getY()) {
break;
+ }
}
}
return inActivation;
}
- /**
- * Returns true if the message or the message label contains the point given in parameter
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#contains(int, int)
*/
@Override
- public boolean contains(int _x, int _y) {
+ public boolean contains(int xValue, int yValue) {
int x = getX();
int y = getY();
int width = getWidth();
int tempHeight = Metrics.MESSAGES_NAME_SPACING + Metrics.getMessageFontHeigth();
// Is it a self message?
- if (startLifeline == endLifeline) {
+ if (fStartLifeline == fEndLifeline) {
/*
* Rectangle.contains(x,y, width, height) does not works with negative height or width We check here if the
* rectangle width is negative.
*/
if (getName().length() * Metrics.getAverageCharWidth() > Metrics.swimmingLaneWidth() - Metrics.EXECUTION_OCCURRENCE_WIDTH / 2 + -Metrics.INTERNAL_MESSAGE_WIDTH) {
- if (Frame.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH + 10, y, Metrics.swimmingLaneWidth() - Metrics.EXECUTION_OCCURRENCE_WIDTH / 2 + -Metrics.INTERNAL_MESSAGE_WIDTH, Metrics.getMessageFontHeigth(), _x, _y))
+ if (Frame.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH + 10, y, Metrics.swimmingLaneWidth() - Metrics.EXECUTION_OCCURRENCE_WIDTH / 2 + -Metrics.INTERNAL_MESSAGE_WIDTH, Metrics.getMessageFontHeigth(), xValue, yValue)) {
return true;
+ }
} else {
- if (Frame.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH + 10, y, getName().length() * Metrics.getAverageCharWidth(), Metrics.getMessageFontHeigth(), _x, _y))
+ if (Frame.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH + 10, y, getName().length() * Metrics.getAverageCharWidth(), Metrics.getMessageFontHeigth(), xValue, yValue)) {
return true;
+ }
}
// Test if the point is in part 1 of the self message
// see: "private void drawMessage (NGC context)" method for self message drawing schema
- if (Frame.contains(x, y - Metrics.MESSAGE_SELECTION_TOLERANCE / 2, Metrics.INTERNAL_MESSAGE_WIDTH / 2, Metrics.MESSAGE_SELECTION_TOLERANCE, _x, _y))
+ if (Frame.contains(x, y - Metrics.MESSAGE_SELECTION_TOLERANCE / 2, Metrics.INTERNAL_MESSAGE_WIDTH / 2, Metrics.MESSAGE_SELECTION_TOLERANCE, xValue, yValue)) {
return true;
+ }
// Test if the point is in part 3 of the self message
- if (Frame.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH - Metrics.MESSAGE_SELECTION_TOLERANCE / 2, y, Metrics.MESSAGE_SELECTION_TOLERANCE, height + Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT, _x, _y))
+ if (Frame.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH - Metrics.MESSAGE_SELECTION_TOLERANCE / 2, y, Metrics.MESSAGE_SELECTION_TOLERANCE, height + Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT, xValue, yValue)) {
return true;
+ }
// Test if the point is in part 5 of the self message
- if (Frame.contains(x, y + height - Metrics.MESSAGE_SELECTION_TOLERANCE / 2 + Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT, Metrics.INTERNAL_MESSAGE_WIDTH / 2, Metrics.MESSAGE_SELECTION_TOLERANCE, _x, _y))
+ if (Frame.contains(x, y + height - Metrics.MESSAGE_SELECTION_TOLERANCE / 2 + Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT, Metrics.INTERNAL_MESSAGE_WIDTH / 2, Metrics.MESSAGE_SELECTION_TOLERANCE, xValue, yValue)) {
return true;
+ }
// false otherwise
return false;
}
- if (Frame.contains(x, y - tempHeight, width, tempHeight, _x, _y))
+ if (Frame.contains(x, y - tempHeight, width, tempHeight, xValue, yValue)) {
return true;
+ }
// false otherwise
return false;
}
+ /**
+ * Method to draw the message using the graphical context.
+ *
+ * @param context A graphical context to draw in.
+ */
protected void drawMessage(IGC context) {
int fX, fY, fW, fH;
fX = fY = fW = fH = 0;
- // temporay store the coordinates to avoid more methods calls
+ // temporary store the coordinates to avoid more methods calls
int x = getX();
int y = getY();
int width = getWidth();
int height = getHeight();
+ ISDPreferences pref = SDViewPref.getInstance();
+
// UML2 found message (always drawn from left to right)
// or UML2 lost message (always drawn from left to right)
- if ((startLifeline == null || endLifeline == null) && startLifeline != endLifeline) {
+ if ((fStartLifeline == null || fEndLifeline == null) && fStartLifeline != fEndLifeline) {
// 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
IColor temp = context.getForeground();
- context.setForeground(Frame.getUserPref().getFontColor(prefId));
+ context.setForeground(pref.getFontColor(fPrefId));
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;
- if (endLifeline == null)
+ if (fEndLifeline == null) {
margin = Metrics.MESSAGE_CIRCLE_RAY;
+ }
// Draw the message main line
context.drawLine(x, y, x + width, y + height);
// Draw the two little lines which make a arrow part of the message
- Double xt = new Double(Math.cos(0.75) * 7);
- Double yt = new Double(Math.sin(0.75) * 7);
+ Double xt = Double.valueOf(Math.cos(0.75) * 7);
+ Double yt = Double.valueOf(Math.sin(0.75) * 7);
if (context.getLineStyle() == context.getLineSolidStyle()) {
IColor backcolor = context.getBackground();
context.setBackground(context.getForeground());
// Draw a circle at the message end (endLifeline side)
int ray = Metrics.MESSAGE_CIRCLE_RAY;
- if (context.getLineWidth() != Metrics.NORMAL_LINE_WIDTH)
+ if (context.getLineWidth() != Metrics.NORMAL_LINE_WIDTH) {
ray = ray + Metrics.SELECTION_LINE_WIDTH - Metrics.NORMAL_LINE_WIDTH;
- if (startLifeline == null)
+ }
+ if (fStartLifeline == null) {
context.fillOval(x - ray, y - ray, ray * 2, ray * 2);
- else
+ } else {
context.fillOval(x + width - ray, y + height - ray, ray * 2, ray * 2);
+ }
context.setBackground(storedColor);
- context.setForeground(Frame.getUserPref().getFontColor(prefId));
+ context.setForeground(pref.getFontColor(fPrefId));
fX = x;
fY = y - yt.intValue();
fW = width;
fH = height + 2 * yt.intValue();
}
// it is self message (always drawn at the left side of the owning lifeLifeline)
- else if (startLifeline != null && endLifeline != null && startLifeline == endLifeline) {
+ else if (fStartLifeline != null && fEndLifeline != null && fStartLifeline == fEndLifeline) {
/*
* Self syncMessages are drawn in 5 parts 1 -----------+ + 2 + | | | 3 | + 5 + 4 -----------+
*/
int tempy = Metrics.INTERNAL_MESSAGE_WIDTH / 2;
- if (Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT <= Metrics.INTERNAL_MESSAGE_WIDTH)
+ if (Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT <= Metrics.INTERNAL_MESSAGE_WIDTH) {
tempy = Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT / 2;
+ }
// Part 1
context.drawLine(x, y, x + Metrics.INTERNAL_MESSAGE_WIDTH / 2, y);
// Part 5
context.drawLine(x, y + height + Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT, x + Metrics.INTERNAL_MESSAGE_WIDTH / 2, y + height + Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT);
- Double xt = new Double(Math.cos(0.75) * 7);
- Double yt = new Double(Math.sin(0.75) * 7);
+ Double xt = Double.valueOf(Math.cos(0.75) * 7);
+ Double yt = Double.valueOf(Math.sin(0.75) * 7);
fX = x;
fY = y;
// 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(Frame.getUserPref().getFontColor(prefId));
- if (startLifeline.getIndex() == startLifeline.getFrame().getHorizontalIndex())
+ context.setForeground(pref.getFontColor(fPrefId));
+ 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());
- else
+ } else {
context.drawTextTruncated(getName(), x + width + Metrics.INTERNAL_MESSAGE_V_MARGIN / 2, y, Metrics.swimmingLaneWidth() - Metrics.EXECUTION_OCCURRENCE_WIDTH + -Metrics.INTERNAL_MESSAGE_WIDTH,
+Metrics.MESSAGES_NAME_SPACING - Metrics.getMessageFontHeigth(), !isSelected());
+ }
}
// it is regular message
- else if (startLifeline != null && endLifeline != null) {
+ else if (fStartLifeline != null && fEndLifeline != null) {
// Draw the message main line
context.drawLine(x, y, x + width, y + height);
- int spaceBTWStartEnd = endLifeline.getX() - startLifeline.getX();
+ int spaceBTWStartEnd = fEndLifeline.getX() - fStartLifeline.getX();
double a = height;
double b = width;
double angle = Math.atan(a / b);
// Compute the coordinates of the two little lines which make the arrow part of the message
int sign = 1;
- if (spaceBTWStartEnd < 0)
+ if (spaceBTWStartEnd < 0) {
sign = -1;
- Double x1 = new Double(sign * Math.cos(angle - 0.75) * 7);
- Double y1 = new Double(sign * Math.sin(angle - 0.75) * 7);
- Double x2 = new Double(sign * Math.cos(angle + 0.75) * 7);
- Double y2 = new Double(sign * Math.sin(angle + 0.75) * 7);
+ }
+ Double x1 = Double.valueOf(sign * Math.cos(angle - 0.75) * 7);
+ Double y1 = Double.valueOf(sign * Math.sin(angle - 0.75) * 7);
+ Double x2 = Double.valueOf(sign * Math.cos(angle + 0.75) * 7);
+ Double y2 = Double.valueOf(sign * Math.sin(angle + 0.75) * 7);
fX = getX();
fY = y + height - y2.intValue();
// 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(Frame.getUserPref().getFontColor(prefId));
- if (spaceBTWStartEnd > 0)
+ context.setForeground(pref.getFontColor(fPrefId));
+ 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
+ } else {
context.drawTextTruncatedCentred(getName(), x + width, y + height / 2 - (2 * Metrics.MESSAGES_NAME_SPACING + Metrics.getMessageFontHeigth()), -width, 2 * Metrics.MESSAGES_NAME_SPACING + +Metrics.getMessageFontHeigth(), !isSelected());
+ }
}
}
-
+
+ /*
+ * (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())
+ if (!isVisible()) {
return;
+ }
+
// Draw it selected?*/
if (isSelected()) {
-
+ ISDPreferences pref = SDViewPref.getInstance();
/*
* Draw it twice First time, bigger inverting selection colors Second time, regular drawing using selection
* colors This create the highlight effect
*/
- context.setForeground(Frame.getUserPref().getBackGroundColorSelection());
+ context.setForeground(pref.getBackGroundColorSelection());
context.setLineWidth(Metrics.SELECTION_LINE_WIDTH);
drawMessage(context);
- context.setBackground(Frame.getUserPref().getBackGroundColorSelection());
- context.setForeground(Frame.getUserPref().getForeGroundColorSelection());
+ context.setBackground(pref.getBackGroundColorSelection());
+ context.setForeground(pref.getForeGroundColorSelection());
// Second drawing is done after
}
context.setLineWidth(Metrics.NORMAL_LINE_WIDTH);
*
* @param message - the message to compare with
* @return true if identical false otherwise
+ *
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#isSameAs(org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode)
*/
@Override
public boolean isSameAs(GraphNode message) {
- if (message == null)
+ if (message == null) {
return false;
- if (!(message instanceof BaseMessage))
+ }
+ if (!(message instanceof BaseMessage)) {
return super.isSameAs(message);
- if (getX() == message.getX() && getY() == message.getY() && getWidth() == message.getWidth() && getHeight() == message.getHeight())
- return true;
- else
- return false;
+ }
+ return ((getX() == message.getX()) && (getY() == message.getY()) && (getWidth() == message.getWidth()) && (getHeight() == message.getHeight()));
}
+ /**
+ * Method drawRot.
+ *
+ * @param x A x coordinate
+ * @param y A y coordinate
+ * @param w A width
+ * @param h A height
+ * @param context A graphical context
+ */
public void drawRot(int x, int y, int w, int h, IGC context) {
double angleA = Math.atan2(getHeight(), getWidth());
double cosA = Math.cos(angleA);
int gx = getX();
int gy = getY();
- h = h / 2;
+ int localHeight = h;
+ localHeight = localHeight / 2;
double cw = Math.sqrt(w * w + getHeight() * getHeight());
int x2 = Math.round((float) (cw * cosA - (y - gy) * sinA));
int y2 = Math.round((float) (cw * sinA + (y - gy) * cosA));
- int x3 = Math.round((float) (cw * cosA - (h) * sinA));
- int y3 = Math.round((float) (cw * sinA + (h) * cosA));
+ int x3 = Math.round((float) (cw * cosA - (localHeight) * sinA));
+ int y3 = Math.round((float) (cw * sinA + (localHeight) * cosA));
- int x4 = Math.round((float) ((x - gx) * cosA - (h) * sinA));
- int y4 = Math.round((float) ((x - gx) * sinA + (h) * cosA));
+ int x4 = Math.round((float) ((x - gx) * cosA - (localHeight) * sinA));
+ int y4 = Math.round((float) ((x - gx) * sinA + (localHeight) * cosA));
int[] points = { x1 + getX(), y1 + getY(), x2 + getX(), y2 + getY(), x3 + getX(), y3 + getY(), x4 + getX(), y4 + getY() };
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) {
- if ((startLifeline != endLifeline) && (startEventOccurrence == endEventOccurrence)) {
+
+ ISDPreferences pref = SDViewPref.getInstance();
+
+ if ((fStartLifeline != fEndLifeline) && (fStartEventOccurrence == fEndEventOccurrence)) {
context.setLineStyle(context.getLineDotStyle());
context.setLineWidth(Metrics.NORMAL_LINE_WIDTH);
- context.setBackground(Frame.getUserPref().getBackGroundColorSelection());
- context.setForeground(Frame.getUserPref().getForeGroundColorSelection());
+ context.setBackground(pref.getBackGroundColorSelection());
+ context.setForeground(pref.getForeGroundColorSelection());
context.drawFocus(getX(), getY() - 3, getWidth(), getHeight() + 6);
- } else if ((startLifeline == endLifeline) && (startEventOccurrence == endEventOccurrence)) {
+ } else if ((fStartLifeline == fEndLifeline) && (fStartEventOccurrence == fEndEventOccurrence)) {
context.drawFocus(getX(), getY() - 3, getWidth(), Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT + 6);
- } else if ((startLifeline != endLifeline) && (startEventOccurrence != endEventOccurrence)) {
+ } else if ((fStartLifeline != fEndLifeline) && (fStartEventOccurrence != fEndEventOccurrence)) {
context.setLineStyle(context.getLineDotStyle());
context.setLineWidth(Metrics.NORMAL_LINE_WIDTH);
- context.setBackground(Frame.getUserPref().getBackGroundColor(ISDPreferences.PREF_LIFELINE_HEADER));
- context.setForeground(Frame.getUserPref().getForeGroundColor(ISDPreferences.PREF_LIFELINE_HEADER));
+ context.setBackground(pref.getBackGroundColor(ISDPreferences.PREF_LIFELINE_HEADER));
+ context.setForeground(pref.getForeGroundColor(ISDPreferences.PREF_LIFELINE_HEADER));
drawRot(getX(), getY() - 5, getWidth(), 10, context);
- } else
+ } else {
super.drawFocus(context);
+ }
}
}