1 /**********************************************************************
2 * Copyright (c) 2005, 2008 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * which accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
11 * IBM - Initial API and implementation
12 * Bernd Hufmann - Updated for TMF
13 **********************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
;
16 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.IColor
;
17 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.IGC
;
18 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.ISDPreferences
;
21 * Class to draw Ellipsis Message.
27 public class EllipsisMessage
extends AsyncMessage
implements ITimeRange
{
31 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#getX()
35 if (startLifeline
== null) {
36 return super.getX() + super.getWidth() - 16;
43 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#getY()
47 return super.getY() + 3;
52 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#getWidth()
55 public int getWidth() {
61 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#drawMessage(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
64 protected void drawMessage(IGC context
) {
65 // temporary store the coordinates to avoid more methods calls
68 int width
= super.getWidth();
69 int height
= getHeight();
71 // UML2 found message (always drawn from left to right)
72 if (startLifeline
== null && endLifeline
!= null) {
73 // Draw the message label above the message and centered
74 // The label is truncated if it cannot fit between the two message end
75 // 2*Metrics.MESSAGES_NAME_SPACING = space above the label + space below the label
76 context
.drawTextTruncatedCentred(getName(), x
, y
- Metrics
.getMessageFontHeigth() - 2 * Metrics
.MESSAGES_NAME_SPACING
, width
, 2 * Metrics
.MESSAGES_NAME_SPACING
+ Metrics
.getMessageFontHeigth(), !isSelected());
78 int currentStyle
= context
.getLineStyle();
79 context
.setLineStyle(context
.getLineSolidStyle());
80 // Draw the message main line
81 context
.drawRectangle(x
+ width
- 5, y
, x
+ width
- 6, y
+ height
);
82 context
.drawRectangle(x
+ width
- 10, y
, x
+ width
- 11, y
+ height
);
83 context
.drawRectangle(x
+ width
- 15, y
, x
+ width
- 16, y
+ height
);
84 context
.setLineStyle(currentStyle
);
86 IColor storedColor
= context
.getBackground();
87 context
.setBackground(context
.getForeground());
88 context
.fillRectangle(x
+ width
- 5, y
, x
+ width
- 6, y
+ height
);
89 context
.fillRectangle(x
+ width
- 10, y
, x
+ width
- 11, y
+ height
);
90 context
.fillRectangle(x
+ width
- 15, y
, x
+ width
- 16, y
+ height
);
91 context
.setBackground(storedColor
);
93 // UML2 lost message (always drawn from left to right)
94 else if (endLifeline
== null && startLifeline
!= null) {
95 // Draw the message label above the message and centered
96 // The label is truncated if it cannot fit between the two message end
97 // 2*Metrics.MESSAGES_NAME_SPACING = space above the label + space below the label
98 context
.drawTextTruncatedCentred(getName(), x
, y
- Metrics
.getMessageFontHeigth() - 2 * Metrics
.MESSAGES_NAME_SPACING
, width
, 2 * Metrics
.MESSAGES_NAME_SPACING
+ Metrics
.getMessageFontHeigth(), !isSelected());
100 int currentStyle
= context
.getLineStyle();
101 context
.setLineStyle(context
.getLineSolidStyle());
102 // Draw the message main line
103 context
.drawRectangle(x
+ 5, y
, 1, 1);
104 context
.drawRectangle(x
+ 10, y
, 1, 1);
105 context
.drawRectangle(x
+ 15, y
, 1, 1);
107 context
.setLineStyle(currentStyle
);
109 IColor storedColor
= context
.getBackground();
110 context
.setBackground(context
.getForeground());
111 context
.fillRectangle(x
+ 5, y
, 1, 1);
112 context
.fillRectangle(x
+ 10, y
, 1, 1);
113 context
.fillRectangle(x
+ 15, y
, 1, 1);
115 context
.setBackground(storedColor
);
124 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
127 public void draw(IGC context
) {
131 // Draw it selected?*/
134 * Draw it twice First time, bigger inverting selection colors Second time, regular drawing using selection
135 * colors This create the highlight effect
137 context
.setForeground(Frame
.getUserPref().getBackGroundColorSelection());
138 context
.setLineWidth(Metrics
.SELECTION_LINE_WIDTH
);
139 drawMessage(context
);
140 context
.setBackground(Frame
.getUserPref().getBackGroundColorSelection());
141 context
.setForeground(Frame
.getUserPref().getForeGroundColorSelection());
142 // Second drawing is done after the else
144 context
.setBackground(Frame
.getUserPref().getBackGroundColor(ISDPreferences
.PREF_ASYNC_MESS
));
145 context
.setForeground(Frame
.getUserPref().getForeGroundColor(ISDPreferences
.PREF_ASYNC_MESS
));
148 context
.setDrawTextWithFocusStyle(true);
150 context
.setLineWidth(Metrics
.NORMAL_LINE_WIDTH
);
151 drawMessage(context
);
152 context
.setLineWidth(Metrics
.NORMAL_LINE_WIDTH
);
154 context
.setDrawTextWithFocusStyle(false);
This page took 0.033798 seconds and 5 git commands to generate.