Fix javadoc warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / core / Stop.java
CommitLineData
73005152
BH
1/**********************************************************************
2 * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
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
7 * $Id: Stop.java,v 1.2 2006/09/20 20:56:25 ewchan Exp $
8 *
9 * Contributors:
10 * IBM - Initial API and implementation
11 * Bernd Hufmann - Updated for TMF
12 **********************************************************************/
13package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
14
15import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
16import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
17
18/**
19 * It is the UML2 stop graphical representation in the sequence diagram viewer.<br>
20 * This draw a cross on the lifeline. The stop y coordinate depend on the event occurrence when it appears.<br>
21 * A stop is never drawn it is assigned to a lifeline.<br>
22 * <br>
23 *
73005152 24 * @author sveyrier
73005152
BH
25 */
26public class Stop extends GraphNode {
27
28 /**
29 * The owning lifeline on which the stop appears
30 */
31 protected Lifeline lifeline = null;
32
33 /**
34 * The graphNode ID
35 */
36 public static final String STOP = "STOP"; //$NON-NLS-1$
37
38 /**
39 * This basically represents the time when the stop occurs on the owning Lifeline
40 *
41 * @see Lifeline Lifeline for more event occurence details
42 */
43 protected int eventOccurrence = 0;
44
45 @Override
46 public int getX() {
47 if (lifeline == null)
48 return 0;
49 return lifeline.getX() + Metrics.getLifelineWidth() / 2 - Metrics.STOP_WIDTH / 2;
50 }
51
52 @Override
53 public int getY() {
54 if (lifeline == null)
55 return 0;
56 return lifeline.getY() + lifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * eventOccurrence - Metrics.STOP_WIDTH / 2;
57 }
58
59 @Override
60 public int getWidth() {
61 if (lifeline == null)
62 return 0;
63 return Metrics.STOP_WIDTH;
64 }
65
66 @Override
67 public int getHeight() {
68 if (lifeline == null)
69 return 0;
70 return Metrics.STOP_WIDTH;
71 }
72
73 /**
74 * Set the lifeline on which the stop must be draw
75 *
76 * @param theLifeline The the stop owing lifeline
77 */
78 public void setLifeline(Lifeline theLifeline) {
79 lifeline = theLifeline;
80 }
81
82 /**
83 * Set the event occurrence when this stop appears
84 *
85 * @param occurrence the eventOccurence to assign to the stop
86 */
87 public void setEventOccurrence(int occurrence) {
88 eventOccurrence = occurrence;
89 }
90
91 @Override
92 public void draw(IGC context) {
93 // Set the appropriate color depending if the graph node if selected or not
94 if (lifeline.isSelected()) {
95 context.setForeground(Frame.getUserPref().getBackGroundColorSelection());
96 context.setLineWidth(Metrics.SELECTION_LINE_WIDTH);
97 int lastWidth = context.getLineWidth();
98 context.setLineWidth(9);
99 // Draw a cross on the lifeline
100 context.drawLine(getX(), getY(), getX() + getWidth(), getY() + getHeight());
101 context.drawLine(getX() + getWidth(), getY(), getX(), getY() + getHeight());
102 // restore the context
103 context.setLineWidth(lastWidth);
104 context.setBackground(Frame.getUserPref().getBackGroundColorSelection());
105 context.setForeground(Frame.getUserPref().getForeGroundColorSelection());
106 } else {
107 context.setBackground(Frame.getUserPref().getBackGroundColor(ISDPreferences.PREF_LIFELINE));
108 context.setForeground(Frame.getUserPref().getForeGroundColor(ISDPreferences.PREF_LIFELINE));
109 }
110 int lastWidth = context.getLineWidth();
111 context.setLineWidth(3);
112 // Draw a cross on the lifeline
113 context.drawLine(getX(), getY(), getX() + getWidth(), getY() + getHeight());
114 context.drawLine(getX() + getWidth(), getY(), getX(), getY() + getHeight());
115 // restore the context
116 context.setLineWidth(lastWidth);
117 }
118
119 /*
120 * (non-Javadoc)
121 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getArrayId()
122 */
123 @Override
124 public String getArrayId() {
125 return STOP;
126 }
127
128 /*
129 * (non-Javadoc)
130 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#contains(int, int)
131 */
132 @Override
133 public boolean contains(int x, int y) {
134 // TODO Auto-generated method stub
135 return false;
136 }
137}
This page took 0.030498 seconds and 5 git commands to generate.