tmf/lttng: Remove unneeded (non-Javadoc) comments
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / core / Stop.java
CommitLineData
73005152 1/**********************************************************************
11252342 2 * Copyright (c) 2005, 2013 IBM Corporation, Ericsson
73005152
BH
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
c8422608
AM
7 *
8 * Contributors:
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
73005152 11 **********************************************************************/
c8422608 12
73005152
BH
13package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
14
15import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
df0b8ff4 16import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
3145ec83 17import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref;
73005152
BH
18
19/**
df0b8ff4
BH
20 * <p>
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.
24 * </p>
c8422608 25 *
df0b8ff4 26 * @version 1.0
73005152 27 * @author sveyrier
73005152
BH
28 */
29public class Stop extends GraphNode {
30
df0b8ff4
BH
31 // ------------------------------------------------------------------------
32 // Constants
33 // ------------------------------------------------------------------------
73005152
BH
34 /**
35 * The graphNode ID
36 */
37 public static final String STOP = "STOP"; //$NON-NLS-1$
c8422608 38
df0b8ff4
BH
39 // ------------------------------------------------------------------------
40 // Attributes
41 // ------------------------------------------------------------------------
42 /**
43 * The owning lifeline on which the stop appears
44 */
eb63f5ff 45 protected Lifeline fLifeline = null;
73005152
BH
46 /**
47 * This basically represents the time when the stop occurs on the owning Lifeline
c8422608 48 *
73005152
BH
49 * @see Lifeline Lifeline for more event occurence details
50 */
eb63f5ff 51 protected int fEventOccurrence = 0;
73005152 52
df0b8ff4
BH
53 // ------------------------------------------------------------------------
54 // Methods
55 // ------------------------------------------------------------------------
56
73005152
BH
57 @Override
58 public int getX() {
eb63f5ff 59 if (fLifeline == null) {
73005152 60 return 0;
df0b8ff4 61 }
eb63f5ff 62 return fLifeline.getX() + Metrics.getLifelineWidth() / 2 - Metrics.STOP_WIDTH / 2;
73005152
BH
63 }
64
65 @Override
66 public int getY() {
eb63f5ff 67 if (fLifeline == null) {
73005152 68 return 0;
df0b8ff4 69 }
eb63f5ff 70 return fLifeline.getY() + fLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fEventOccurrence - Metrics.STOP_WIDTH / 2;
73005152
BH
71 }
72
73 @Override
74 public int getWidth() {
eb63f5ff 75 if (fLifeline == null) {
73005152 76 return 0;
df0b8ff4 77 }
73005152
BH
78 return Metrics.STOP_WIDTH;
79 }
80
81 @Override
82 public int getHeight() {
eb63f5ff 83 if (fLifeline == null) {
73005152 84 return 0;
df0b8ff4 85 }
73005152
BH
86 return Metrics.STOP_WIDTH;
87 }
88
89 /**
90 * Set the lifeline on which the stop must be draw
c8422608 91 *
73005152
BH
92 * @param theLifeline The the stop owing lifeline
93 */
94 public void setLifeline(Lifeline theLifeline) {
eb63f5ff 95 fLifeline = theLifeline;
73005152
BH
96 }
97
98 /**
99 * Set the event occurrence when this stop appears
c8422608 100 *
73005152
BH
101 * @param occurrence the eventOccurence to assign to the stop
102 */
103 public void setEventOccurrence(int occurrence) {
eb63f5ff 104 fEventOccurrence = occurrence;
73005152
BH
105 }
106
107 @Override
108 public void draw(IGC context) {
3145ec83
BH
109
110 ISDPreferences pref = SDViewPref.getInstance();
111
73005152 112 // Set the appropriate color depending if the graph node if selected or not
eb63f5ff 113 if (fLifeline.isSelected()) {
3145ec83 114 context.setForeground(pref.getBackGroundColorSelection());
73005152
BH
115 context.setLineWidth(Metrics.SELECTION_LINE_WIDTH);
116 int lastWidth = context.getLineWidth();
117 context.setLineWidth(9);
118 // Draw a cross on the lifeline
119 context.drawLine(getX(), getY(), getX() + getWidth(), getY() + getHeight());
120 context.drawLine(getX() + getWidth(), getY(), getX(), getY() + getHeight());
121 // restore the context
122 context.setLineWidth(lastWidth);
3145ec83
BH
123 context.setBackground(pref.getBackGroundColorSelection());
124 context.setForeground(pref.getForeGroundColorSelection());
73005152 125 } else {
3145ec83
BH
126 context.setBackground(pref.getBackGroundColor(ISDPreferences.PREF_LIFELINE));
127 context.setForeground(pref.getForeGroundColor(ISDPreferences.PREF_LIFELINE));
73005152
BH
128 }
129 int lastWidth = context.getLineWidth();
130 context.setLineWidth(3);
131 // Draw a cross on the lifeline
132 context.drawLine(getX(), getY(), getX() + getWidth(), getY() + getHeight());
133 context.drawLine(getX() + getWidth(), getY(), getX(), getY() + getHeight());
134 // restore the context
135 context.setLineWidth(lastWidth);
136 }
137
73005152
BH
138 @Override
139 public String getArrayId() {
140 return STOP;
141 }
142
73005152
BH
143 @Override
144 public boolean contains(int x, int y) {
73005152
BH
145 return false;
146 }
147}
This page took 0.564964 seconds and 5 git commands to generate.