1 /**********************************************************************
2 * Copyright (c) 2005, 2008, 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: EllipsisisMessage.java,v 1.3 2008/01/24 02:29:19 apnan 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
.IColor
;
16 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.IGC
;
17 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.ISDPreferences
;
19 public class EllipsisisMessage
extends AsyncMessage
implements ITimeRange
{
23 if (startLifeline
== null)
24 return super.getX() + super.getWidth() - 16;
31 return super.getY() + 3;
35 public int getWidth() {
40 protected void drawMessage(IGC context
) {
41 // temporay store the coordinates to avoid more methods calls
44 int width
= super.getWidth();
45 int height
= getHeight();
47 // UML2 found message (always drawn from left to right)
48 if (startLifeline
== null && endLifeline
!= null) {
49 // Draw the message label above the message and centered
50 // The label is truncated if it cannot fit between the two message end
51 // 2*Metrics.MESSAGES_NAME_SPACING = space above the label + space below the label
52 context
.drawTextTruncatedCentred(getName(), x
, y
- Metrics
.getMessageFontHeigth() - 2 * Metrics
.MESSAGES_NAME_SPACING
, width
, 2 * Metrics
.MESSAGES_NAME_SPACING
+ Metrics
.getMessageFontHeigth(), !isSelected());
54 int currentStyle
= context
.getLineStyle();
55 context
.setLineStyle(context
.getLineSolidStyle());
56 // Draw the message main line
57 context
.drawRectangle(x
+ width
- 5, y
, x
+ width
- 6, y
+ height
);
58 context
.drawRectangle(x
+ width
- 10, y
, x
+ width
- 11, y
+ height
);
59 context
.drawRectangle(x
+ width
- 15, y
, x
+ width
- 16, y
+ height
);
60 context
.setLineStyle(currentStyle
);
62 IColor storedColor
= context
.getBackground();
63 context
.setBackground(context
.getForeground());
64 context
.fillRectangle(x
+ width
- 5, y
, x
+ width
- 6, y
+ height
);
65 context
.fillRectangle(x
+ width
- 10, y
, x
+ width
- 11, y
+ height
);
66 context
.fillRectangle(x
+ width
- 15, y
, x
+ width
- 16, y
+ height
);
67 context
.setBackground(storedColor
);
69 // UML2 lost message (always drawn from left to right)
70 else if (endLifeline
== null && startLifeline
!= null) {
71 // Draw the message label above the message and centered
72 // The label is truncated if it cannot fit between the two message end
73 // 2*Metrics.MESSAGES_NAME_SPACING = space above the label + space below the label
74 context
.drawTextTruncatedCentred(getName(), x
, y
- Metrics
.getMessageFontHeigth() - 2 * Metrics
.MESSAGES_NAME_SPACING
, width
, 2 * Metrics
.MESSAGES_NAME_SPACING
+ Metrics
.getMessageFontHeigth(), !isSelected());
76 int currentStyle
= context
.getLineStyle();
77 context
.setLineStyle(context
.getLineSolidStyle());
78 // Draw the message main line
79 context
.drawRectangle(x
+ 5, y
, 1, 1);
80 context
.drawRectangle(x
+ 10, y
, 1, 1);
81 context
.drawRectangle(x
+ 15, y
, 1, 1);
83 context
.setLineStyle(currentStyle
);
85 IColor storedColor
= context
.getBackground();
86 context
.setBackground(context
.getForeground());
87 context
.fillRectangle(x
+ 5, y
, 1, 1);
88 context
.fillRectangle(x
+ 10, y
, 1, 1);
89 context
.fillRectangle(x
+ 15, y
, 1, 1);
91 context
.setBackground(storedColor
);
98 public void draw(IGC context
) {
101 // Draw it selected?*/
104 * Draw it twice First time, bigger inverting selection colors Second time, regular drawing using selection
105 * colors This create the highlight effect
107 context
.setForeground(Frame
.getUserPref().getBackGroundColorSelection());
108 context
.setLineWidth(Metrics
.SELECTION_LINE_WIDTH
);
109 drawMessage(context
);
110 context
.setBackground(Frame
.getUserPref().getBackGroundColorSelection());
111 context
.setForeground(Frame
.getUserPref().getForeGroundColorSelection());
112 // Second drawing is done after the else
114 context
.setBackground(Frame
.getUserPref().getBackGroundColor(ISDPreferences
.PREF_ASYNC_MESS
));
115 context
.setForeground(Frame
.getUserPref().getForeGroundColor(ISDPreferences
.PREF_ASYNC_MESS
));
118 context
.setDrawTextWithFocusStyle(true);
120 context
.setLineWidth(Metrics
.NORMAL_LINE_WIDTH
);
121 drawMessage(context
);
122 context
.setLineWidth(Metrics
.NORMAL_LINE_WIDTH
);
124 context
.setDrawTextWithFocusStyle(false);
This page took 0.032912 seconds and 5 git commands to generate.