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 $
10 * IBM - Initial API and implementation
11 * Bernd Hufmann - Updated for TMF
12 **********************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
;
15 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.IGC
;
16 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.ISDPreferences
;
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>
26 public class Stop
extends GraphNode
{
29 * The owning lifeline on which the stop appears
31 protected Lifeline lifeline
= null;
36 public static final String STOP
= "STOP"; //$NON-NLS-1$
39 * This basically represents the time when the stop occurs on the owning Lifeline
41 * @see Lifeline Lifeline for more event occurence details
43 protected int eventOccurrence
= 0;
49 return lifeline
.getX() + Metrics
.getLifelineWidth() / 2 - Metrics
.STOP_WIDTH
/ 2;
56 return lifeline
.getY() + lifeline
.getHeight() + (Metrics
.getMessageFontHeigth() + Metrics
.getMessagesSpacing()) * eventOccurrence
- Metrics
.STOP_WIDTH
/ 2;
60 public int getWidth() {
63 return Metrics
.STOP_WIDTH
;
67 public int getHeight() {
70 return Metrics
.STOP_WIDTH
;
74 * Set the lifeline on which the stop must be draw
76 * @param theLifeline The the stop owing lifeline
78 public void setLifeline(Lifeline theLifeline
) {
79 lifeline
= theLifeline
;
83 * Set the event occurrence when this stop appears
85 * @param occurrence the eventOccurence to assign to the stop
87 public void setEventOccurrence(int occurrence
) {
88 eventOccurrence
= occurrence
;
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());
107 context
.setBackground(Frame
.getUserPref().getBackGroundColor(ISDPreferences
.PREF_LIFELINE
));
108 context
.setForeground(Frame
.getUserPref().getForeGroundColor(ISDPreferences
.PREF_LIFELINE
));
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
);
121 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getArrayId()
124 public String
getArrayId() {
130 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#contains(int, int)
133 public boolean contains(int x
, int y
) {
134 // TODO Auto-generated method stub
This page took 0.033958 seconds and 6 git commands to generate.