Improve test cases, speed and accuracy.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / core / EllipsisisMessage.java
CommitLineData
73005152
BH
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 $
8 *
9 * Contributors:
10 * IBM - Initial API and implementation
11 * Bernd Hufmann - Updated for TMF
12 **********************************************************************/
13package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
14
15import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor;
16import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
17import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
18
19public class EllipsisisMessage extends AsyncMessage implements ITimeRange {
20
21 @Override
22 public int getX() {
23 if (startLifeline == null)
24 return super.getX() + super.getWidth() - 16;
25 else
26 return super.getX();
27 }
28
29 @Override
30 public int getY() {
31 return super.getY() + 3;
32 }
33
34 @Override
35 public int getWidth() {
36 return 16;
37 }
38
39 @Override
40 protected void drawMessage(IGC context) {
41 // temporay store the coordinates to avoid more methods calls
42 int x = super.getX();
43 int y = getY();
44 int width = super.getWidth();
45 int height = getHeight();
46
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());
53
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);
61
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);
68 }
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());
75
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);
82
83 context.setLineStyle(currentStyle);
84
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);
90
91 context.setBackground(storedColor);
92
93 } else
94 super.draw(context);
95 }
96
97 @Override
98 public void draw(IGC context) {
99 if (!isVisible())
100 return;
101 // Draw it selected?*/
102 if (isSelected()) {
103 /*
104 * Draw it twice First time, bigger inverting selection colors Second time, regular drawing using selection
105 * colors This create the highlight effect
106 */
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
113 } else {
114 context.setBackground(Frame.getUserPref().getBackGroundColor(ISDPreferences.PREF_ASYNC_MESS));
115 context.setForeground(Frame.getUserPref().getForeGroundColor(ISDPreferences.PREF_ASYNC_MESS));
116 }
117 if (hasFocus()) {
118 context.setDrawTextWithFocusStyle(true);
119 }
120 context.setLineWidth(Metrics.NORMAL_LINE_WIDTH);
121 drawMessage(context);
122 context.setLineWidth(Metrics.NORMAL_LINE_WIDTH);
123 if (hasFocus()) {
124 context.setDrawTextWithFocusStyle(false);
125 }
126 }
127}
This page took 0.02961 seconds and 5 git commands to generate.