Java Doc and API clean up of TMF UML Sequence diagram framework
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / core / EllipsisMessage.java
1 /**********************************************************************
2 * Copyright (c) 2005, 2008 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
4 *
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
9 *
10 * Contributors:
11 * IBM - Initial API and implementation
12 * Bernd Hufmann - Updated for TMF
13 **********************************************************************/
14 package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
15
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;
19
20 /**
21 * Class to draw Ellipsis Message.
22 *
23 * @version 1.0
24 * @author sveyrier
25 *
26 */
27 public class EllipsisMessage extends AsyncMessage implements ITimeRange {
28
29 /*
30 * (non-Javadoc)
31 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#getX()
32 */
33 @Override
34 public int getX() {
35 if (startLifeline == null) {
36 return super.getX() + super.getWidth() - 16;
37 }
38 return super.getX();
39 }
40
41 /*
42 * (non-Javadoc)
43 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#getY()
44 */
45 @Override
46 public int getY() {
47 return super.getY() + 3;
48 }
49
50 /*
51 * (non-Javadoc)
52 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#getWidth()
53 */
54 @Override
55 public int getWidth() {
56 return 16;
57 }
58
59 /*
60 * (non-Javadoc)
61 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#drawMessage(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
62 */
63 @Override
64 protected void drawMessage(IGC context) {
65 // temporary store the coordinates to avoid more methods calls
66 int x = super.getX();
67 int y = getY();
68 int width = super.getWidth();
69 int height = getHeight();
70
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());
77
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);
85
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);
92 }
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());
99
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);
106
107 context.setLineStyle(currentStyle);
108
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);
114
115 context.setBackground(storedColor);
116
117 } else {
118 super.draw(context);
119 }
120 }
121
122 /*
123 * (non-Javadoc)
124 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
125 */
126 @Override
127 public void draw(IGC context) {
128 if (!isVisible()) {
129 return;
130 }
131 // Draw it selected?*/
132 if (isSelected()) {
133 /*
134 * Draw it twice First time, bigger inverting selection colors Second time, regular drawing using selection
135 * colors This create the highlight effect
136 */
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
143 } else {
144 context.setBackground(Frame.getUserPref().getBackGroundColor(ISDPreferences.PREF_ASYNC_MESS));
145 context.setForeground(Frame.getUserPref().getForeGroundColor(ISDPreferences.PREF_ASYNC_MESS));
146 }
147 if (hasFocus()) {
148 context.setDrawTextWithFocusStyle(true);
149 }
150 context.setLineWidth(Metrics.NORMAL_LINE_WIDTH);
151 drawMessage(context);
152 context.setLineWidth(Metrics.NORMAL_LINE_WIDTH);
153 if (hasFocus()) {
154 context.setDrawTextWithFocusStyle(false);
155 }
156 }
157 }
This page took 0.033798 seconds and 5 git commands to generate.