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
;
18 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.SDViewPref
;
22 * It is the UML2 stop graphical representation in the sequence diagram viewer.
23 * This draw a cross on the lifeline. The stop y coordinate depend on the event occurrence when it appears.
24 * A stop is never drawn it is assigned to a lifeline.
30 public class Stop
extends GraphNode
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
38 public static final String STOP
= "STOP"; //$NON-NLS-1$
40 // ------------------------------------------------------------------------
42 // ------------------------------------------------------------------------
44 * The owning lifeline on which the stop appears
46 protected Lifeline fLifeline
= null;
48 * This basically represents the time when the stop occurs on the owning Lifeline
50 * @see Lifeline Lifeline for more event occurence details
52 protected int fEventOccurrence
= 0;
54 // ------------------------------------------------------------------------
56 // ------------------------------------------------------------------------
60 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getX()
64 if (fLifeline
== null) {
67 return fLifeline
.getX() + Metrics
.getLifelineWidth() / 2 - Metrics
.STOP_WIDTH
/ 2;
72 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getY()
76 if (fLifeline
== null) {
79 return fLifeline
.getY() + fLifeline
.getHeight() + (Metrics
.getMessageFontHeigth() + Metrics
.getMessagesSpacing()) * fEventOccurrence
- Metrics
.STOP_WIDTH
/ 2;
84 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getWidth()
87 public int getWidth() {
88 if (fLifeline
== null) {
91 return Metrics
.STOP_WIDTH
;
96 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getHeight()
99 public int getHeight() {
100 if (fLifeline
== null) {
103 return Metrics
.STOP_WIDTH
;
107 * Set the lifeline on which the stop must be draw
109 * @param theLifeline The the stop owing lifeline
111 public void setLifeline(Lifeline theLifeline
) {
112 fLifeline
= theLifeline
;
116 * Set the event occurrence when this stop appears
118 * @param occurrence the eventOccurence to assign to the stop
120 public void setEventOccurrence(int occurrence
) {
121 fEventOccurrence
= occurrence
;
126 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
129 public void draw(IGC context
) {
131 ISDPreferences pref
= SDViewPref
.getInstance();
133 // Set the appropriate color depending if the graph node if selected or not
134 if (fLifeline
.isSelected()) {
135 context
.setForeground(pref
.getBackGroundColorSelection());
136 context
.setLineWidth(Metrics
.SELECTION_LINE_WIDTH
);
137 int lastWidth
= context
.getLineWidth();
138 context
.setLineWidth(9);
139 // Draw a cross on the lifeline
140 context
.drawLine(getX(), getY(), getX() + getWidth(), getY() + getHeight());
141 context
.drawLine(getX() + getWidth(), getY(), getX(), getY() + getHeight());
142 // restore the context
143 context
.setLineWidth(lastWidth
);
144 context
.setBackground(pref
.getBackGroundColorSelection());
145 context
.setForeground(pref
.getForeGroundColorSelection());
147 context
.setBackground(pref
.getBackGroundColor(ISDPreferences
.PREF_LIFELINE
));
148 context
.setForeground(pref
.getForeGroundColor(ISDPreferences
.PREF_LIFELINE
));
150 int lastWidth
= context
.getLineWidth();
151 context
.setLineWidth(3);
152 // Draw a cross on the lifeline
153 context
.drawLine(getX(), getY(), getX() + getWidth(), getY() + getHeight());
154 context
.drawLine(getX() + getWidth(), getY(), getX(), getY() + getHeight());
155 // restore the context
156 context
.setLineWidth(lastWidth
);
161 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getArrayId()
164 public String
getArrayId() {
170 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#contains(int, int)
173 public boolean contains(int x
, int y
) {
This page took 0.034293 seconds and 6 git commands to generate.