1 /**********************************************************************
2 * Copyright (c) 2005, 2006 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * which accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
11 * IBM - Initial API and implementation
12 * Bernd Hufmann - Updated for TMF
13 **********************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
;
16 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.IGC
;
17 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.ISDPreferences
;
21 * It is the UML2 stop graphical representation in the sequence diagram viewer.
22 * This draw a cross on the lifeline. The stop y coordinate depend on the event occurrence when it appears.
23 * A stop is never drawn it is assigned to a lifeline.
29 public class Stop
extends GraphNode
{
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
37 public static final String STOP
= "STOP"; //$NON-NLS-1$
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
43 * The owning lifeline on which the stop appears
45 protected Lifeline fLifeline
= null;
47 * This basically represents the time when the stop occurs on the owning Lifeline
49 * @see Lifeline Lifeline for more event occurence details
51 protected int fEventOccurrence
= 0;
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
59 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getX()
63 if (fLifeline
== null) {
66 return fLifeline
.getX() + Metrics
.getLifelineWidth() / 2 - Metrics
.STOP_WIDTH
/ 2;
71 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getY()
75 if (fLifeline
== null) {
78 return fLifeline
.getY() + fLifeline
.getHeight() + (Metrics
.getMessageFontHeigth() + Metrics
.getMessagesSpacing()) * fEventOccurrence
- Metrics
.STOP_WIDTH
/ 2;
83 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getWidth()
86 public int getWidth() {
87 if (fLifeline
== null) {
90 return Metrics
.STOP_WIDTH
;
95 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getHeight()
98 public int getHeight() {
99 if (fLifeline
== null) {
102 return Metrics
.STOP_WIDTH
;
106 * Set the lifeline on which the stop must be draw
108 * @param theLifeline The the stop owing lifeline
110 public void setLifeline(Lifeline theLifeline
) {
111 fLifeline
= theLifeline
;
115 * Set the event occurrence when this stop appears
117 * @param occurrence the eventOccurence to assign to the stop
119 public void setEventOccurrence(int occurrence
) {
120 fEventOccurrence
= occurrence
;
125 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
128 public void draw(IGC context
) {
129 // Set the appropriate color depending if the graph node if selected or not
130 if (fLifeline
.isSelected()) {
131 context
.setForeground(Frame
.getUserPref().getBackGroundColorSelection());
132 context
.setLineWidth(Metrics
.SELECTION_LINE_WIDTH
);
133 int lastWidth
= context
.getLineWidth();
134 context
.setLineWidth(9);
135 // Draw a cross on the lifeline
136 context
.drawLine(getX(), getY(), getX() + getWidth(), getY() + getHeight());
137 context
.drawLine(getX() + getWidth(), getY(), getX(), getY() + getHeight());
138 // restore the context
139 context
.setLineWidth(lastWidth
);
140 context
.setBackground(Frame
.getUserPref().getBackGroundColorSelection());
141 context
.setForeground(Frame
.getUserPref().getForeGroundColorSelection());
143 context
.setBackground(Frame
.getUserPref().getBackGroundColor(ISDPreferences
.PREF_LIFELINE
));
144 context
.setForeground(Frame
.getUserPref().getForeGroundColor(ISDPreferences
.PREF_LIFELINE
));
146 int lastWidth
= context
.getLineWidth();
147 context
.setLineWidth(3);
148 // Draw a cross on the lifeline
149 context
.drawLine(getX(), getY(), getX() + getWidth(), getY() + getHeight());
150 context
.drawLine(getX() + getWidth(), getY(), getX(), getY() + getHeight());
151 // restore the context
152 context
.setLineWidth(lastWidth
);
157 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getArrayId()
160 public String
getArrayId() {
166 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#contains(int, int)
169 public boolean contains(int x
, int y
) {
This page took 0.033371 seconds and 5 git commands to generate.