21990c88d1359fb82ad304ccf98cde5378ce8e76
1 /**********************************************************************
2 * Copyright (c) 2005, 2013 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 if (getStartLifeline() == null) {
32 return super.getX() + super.getWidth() - 16;
39 return super.getY() + 3;
43 public int getWidth() {
48 protected void drawMessage(IGC context
) {
49 // temporary store the coordinates to avoid more methods calls
52 int width
= super.getWidth();
53 int height
= getHeight();
55 // UML2 found message (always drawn from left to right)
56 if (getStartLifeline() == null && getEndLifeline() != null) {
57 // Draw the message label above the message and centered
58 // The label is truncated if it cannot fit between the two message end
59 // 2*Metrics.MESSAGES_NAME_SPACING = space above the label + space below the label
60 context
.drawTextTruncatedCentred(getName(), x
, y
- Metrics
.getMessageFontHeigth() - 2 * Metrics
.MESSAGES_NAME_SPACING
, width
, 2 * Metrics
.MESSAGES_NAME_SPACING
+ Metrics
.getMessageFontHeigth(), !isSelected());
62 int currentStyle
= context
.getLineStyle();
63 context
.setLineStyle(context
.getLineSolidStyle());
64 // Draw the message main line
65 context
.drawRectangle(x
+ width
- 5, y
, x
+ width
- 6, y
+ height
);
66 context
.drawRectangle(x
+ width
- 10, y
, x
+ width
- 11, y
+ height
);
67 context
.drawRectangle(x
+ width
- 15, y
, x
+ width
- 16, y
+ height
);
68 context
.setLineStyle(currentStyle
);
70 IColor storedColor
= context
.getBackground();
71 context
.setBackground(context
.getForeground());
72 context
.fillRectangle(x
+ width
- 5, y
, x
+ width
- 6, y
+ height
);
73 context
.fillRectangle(x
+ width
- 10, y
, x
+ width
- 11, y
+ height
);
74 context
.fillRectangle(x
+ width
- 15, y
, x
+ width
- 16, y
+ height
);
75 context
.setBackground(storedColor
);
77 // UML2 lost message (always drawn from left to right)
78 else if (getEndLifeline() == null && getStartLifeline() != null) {
79 // Draw the message label above the message and centered
80 // The label is truncated if it cannot fit between the two message end
81 // 2*Metrics.MESSAGES_NAME_SPACING = space above the label + space below the label
82 context
.drawTextTruncatedCentred(getName(), x
, y
- Metrics
.getMessageFontHeigth() - 2 * Metrics
.MESSAGES_NAME_SPACING
, width
, 2 * Metrics
.MESSAGES_NAME_SPACING
+ Metrics
.getMessageFontHeigth(), !isSelected());
84 int currentStyle
= context
.getLineStyle();
85 context
.setLineStyle(context
.getLineSolidStyle());
86 // Draw the message main line
87 context
.drawRectangle(x
+ 5, y
, 1, 1);
88 context
.drawRectangle(x
+ 10, y
, 1, 1);
89 context
.drawRectangle(x
+ 15, y
, 1, 1);
91 context
.setLineStyle(currentStyle
);
93 IColor storedColor
= context
.getBackground();
94 context
.setBackground(context
.getForeground());
95 context
.fillRectangle(x
+ 5, y
, 1, 1);
96 context
.fillRectangle(x
+ 10, y
, 1, 1);
97 context
.fillRectangle(x
+ 15, y
, 1, 1);
99 context
.setBackground(storedColor
);
107 public void draw(IGC context
) {
112 ISDPreferences pref
= SDViewPref
.getInstance();
114 // Draw it selected?*/
118 * Draw it twice First time, bigger inverting selection colors Second time, regular drawing using selection
119 * colors This create the highlight effect
121 context
.setForeground(pref
.getBackGroundColorSelection());
122 context
.setLineWidth(Metrics
.SELECTION_LINE_WIDTH
);
123 drawMessage(context
);
124 context
.setBackground(pref
.getBackGroundColorSelection());
125 context
.setForeground(pref
.getForeGroundColorSelection());
126 // Second drawing is done after the else
128 context
.setBackground(pref
.getBackGroundColor(ISDPreferences
.PREF_ASYNC_MESS
));
129 context
.setForeground(pref
.getForeGroundColor(ISDPreferences
.PREF_ASYNC_MESS
));
132 context
.setDrawTextWithFocusStyle(true);
134 context
.setLineWidth(Metrics
.NORMAL_LINE_WIDTH
);
135 drawMessage(context
);
136 context
.setLineWidth(Metrics
.NORMAL_LINE_WIDTH
);
138 context
.setDrawTextWithFocusStyle(false);
This page took 0.033495 seconds and 4 git commands to generate.