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>
24 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline#setStop(Stop)
28 public class Stop
extends GraphNode
{
31 * The owning lifeline on which the stop appears
33 protected Lifeline lifeline
= null;
38 public static final String STOP
= "STOP"; //$NON-NLS-1$
41 * This basically represents the time when the stop occurs on the owning Lifeline
43 * @see Lifeline Lifeline for more event occurence details
45 protected int eventOccurrence
= 0;
51 return lifeline
.getX() + Metrics
.getLifelineWidth() / 2 - Metrics
.STOP_WIDTH
/ 2;
58 return lifeline
.getY() + lifeline
.getHeight() + (Metrics
.getMessageFontHeigth() + Metrics
.getMessagesSpacing()) * eventOccurrence
- Metrics
.STOP_WIDTH
/ 2;
62 public int getWidth() {
65 return Metrics
.STOP_WIDTH
;
69 public int getHeight() {
72 return Metrics
.STOP_WIDTH
;
76 * Set the lifeline on which the stop must be draw
78 * @param theLifeline The the stop owing lifeline
80 public void setLifeline(Lifeline theLifeline
) {
81 lifeline
= theLifeline
;
85 * Set the event occurrence when this stop appears
87 * @param occurrence the eventOccurence to assign to the stop
89 public void setEventOccurrence(int occurrence
) {
90 eventOccurrence
= occurrence
;
94 public void draw(IGC context
) {
95 // Set the appropriate color depending if the graph node if selected or not
96 if (lifeline
.isSelected()) {
97 context
.setForeground(Frame
.getUserPref().getBackGroundColorSelection());
98 context
.setLineWidth(Metrics
.SELECTION_LINE_WIDTH
);
99 int lastWidth
= context
.getLineWidth();
100 context
.setLineWidth(9);
101 // Draw a cross on the lifeline
102 context
.drawLine(getX(), getY(), getX() + getWidth(), getY() + getHeight());
103 context
.drawLine(getX() + getWidth(), getY(), getX(), getY() + getHeight());
104 // restore the context
105 context
.setLineWidth(lastWidth
);
106 context
.setBackground(Frame
.getUserPref().getBackGroundColorSelection());
107 context
.setForeground(Frame
.getUserPref().getForeGroundColorSelection());
109 context
.setBackground(Frame
.getUserPref().getBackGroundColor(ISDPreferences
.PREF_LIFELINE
));
110 context
.setForeground(Frame
.getUserPref().getForeGroundColor(ISDPreferences
.PREF_LIFELINE
));
112 int lastWidth
= context
.getLineWidth();
113 context
.setLineWidth(3);
114 // Draw a cross on the lifeline
115 context
.drawLine(getX(), getY(), getX() + getWidth(), getY() + getHeight());
116 context
.drawLine(getX() + getWidth(), getY(), getX(), getY() + getHeight());
117 // restore the context
118 context
.setLineWidth(lastWidth
);
123 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getArrayId()
126 public String
getArrayId() {
132 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#contains(int, int)
135 public boolean contains(int x
, int y
) {
136 // TODO Auto-generated method stub
This page took 0.034495 seconds and 6 git commands to generate.