d0ff801648949de67bcc9dbd41ca6c5496540856
1 /**********************************************************************
2 * Copyright (c) 2005, 2014 IBM Corporation, Ericsson
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
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
11 **********************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.core
;
15 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.drawings
.IGC
;
16 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.preferences
.ISDPreferences
;
17 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.preferences
.SDViewPref
;
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 private 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 private int fEventOccurrence
= 0;
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
59 if (fLifeline
== null) {
62 return fLifeline
.getX() + Metrics
.getLifelineWidth() / 2 - Metrics
.STOP_WIDTH
/ 2;
67 if (fLifeline
== null) {
70 return fLifeline
.getY() + fLifeline
.getHeight() + (Metrics
.getMessageFontHeigth() + Metrics
.getMessagesSpacing()) * fEventOccurrence
- Metrics
.STOP_WIDTH
/ 2;
74 public int getWidth() {
75 if (fLifeline
== null) {
78 return Metrics
.STOP_WIDTH
;
82 public int getHeight() {
83 if (fLifeline
== null) {
86 return Metrics
.STOP_WIDTH
;
90 * Set the lifeline on which the stop must be draw
92 * @param theLifeline The the stop owing lifeline
94 public void setLifeline(Lifeline theLifeline
) {
95 fLifeline
= theLifeline
;
99 * Get the lifeline on which the stop must be draw
101 * @return the the stop owing lifeline
103 public Lifeline
getLifeline() {
108 * Get the event occurrence when this stop appears
110 * @return the eventOccurence to assign to the stop
112 public int getEventOccurrence() {
113 return fEventOccurrence
;
117 * Set the event occurrence when this stop appears
119 * @param occurrence the eventOccurence to assign to the stop
121 public void setEventOccurrence(int occurrence
) {
122 fEventOccurrence
= occurrence
;
126 public void draw(IGC context
) {
128 ISDPreferences pref
= SDViewPref
.getInstance();
130 // Set the appropriate color depending if the graph node if selected or not
131 if (fLifeline
.isSelected()) {
132 context
.setForeground(pref
.getBackGroundColorSelection());
133 context
.setLineWidth(Metrics
.SELECTION_LINE_WIDTH
);
134 int lastWidth
= context
.getLineWidth();
135 context
.setLineWidth(9);
136 // Draw a cross on the lifeline
137 context
.drawLine(getX(), getY(), getX() + getWidth(), getY() + getHeight());
138 context
.drawLine(getX() + getWidth(), getY(), getX(), getY() + getHeight());
139 // restore the context
140 context
.setLineWidth(lastWidth
);
141 context
.setBackground(pref
.getBackGroundColorSelection());
142 context
.setForeground(pref
.getForeGroundColorSelection());
144 context
.setBackground(pref
.getBackGroundColor(ISDPreferences
.PREF_LIFELINE
));
145 context
.setForeground(pref
.getForeGroundColor(ISDPreferences
.PREF_LIFELINE
));
147 int lastWidth
= context
.getLineWidth();
148 context
.setLineWidth(3);
149 // Draw a cross on the lifeline
150 context
.drawLine(getX(), getY(), getX() + getWidth(), getY() + getHeight());
151 context
.drawLine(getX() + getWidth(), getY(), getX(), getY() + getHeight());
152 // restore the context
153 context
.setLineWidth(lastWidth
);
157 public String
getArrayId() {
162 public boolean contains(int x
, int y
) {
This page took 0.047227 seconds and 5 git commands to generate.