1 /**********************************************************************
2 * Copyright (c) 2005, 2012 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
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
;
15 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.IColor
;
16 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.IGC
;
17 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.ISDPreferences
;
18 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.SDViewPref
;
21 * Class to draw Ellipsis Message.
27 public class EllipsisMessage
extends AsyncMessage
{
31 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#getX()
35 if (fStartLifeline
== 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 (fStartLifeline
== null && fEndLifeline
!= 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 (fEndLifeline
== null && fStartLifeline
!= 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
) {
132 ISDPreferences pref
= SDViewPref
.getInstance();
134 // Draw it selected?*/
138 * Draw it twice First time, bigger inverting selection colors Second time, regular drawing using selection
139 * colors This create the highlight effect
141 context
.setForeground(pref
.getBackGroundColorSelection());
142 context
.setLineWidth(Metrics
.SELECTION_LINE_WIDTH
);
143 drawMessage(context
);
144 context
.setBackground(pref
.getBackGroundColorSelection());
145 context
.setForeground(pref
.getForeGroundColorSelection());
146 // Second drawing is done after the else
148 context
.setBackground(pref
.getBackGroundColor(ISDPreferences
.PREF_ASYNC_MESS
));
149 context
.setForeground(pref
.getForeGroundColor(ISDPreferences
.PREF_ASYNC_MESS
));
152 context
.setDrawTextWithFocusStyle(true);
154 context
.setLineWidth(Metrics
.NORMAL_LINE_WIDTH
);
155 drawMessage(context
);
156 context
.setLineWidth(Metrics
.NORMAL_LINE_WIDTH
);
158 context
.setDrawTextWithFocusStyle(false);
This page took 0.033716 seconds and 5 git commands to generate.