Commit | Line | Data |
---|---|---|
73005152 | 1 | /********************************************************************** |
ed902a2b | 2 | * Copyright (c) 2005, 2014 IBM Corporation, Ericsson |
73005152 BH |
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 | |
013a5f1c AM |
7 | * |
8 | * Contributors: | |
c8422608 AM |
9 | * IBM - Initial API and implementation |
10 | * Bernd Hufmann - Updated for TMF | |
73005152 | 11 | **********************************************************************/ |
c8422608 | 12 | |
2bdf0193 | 13 | package org.eclipse.tracecompass.tmf.ui.views.uml2sd.core; |
73005152 BH |
14 | |
15 | /** | |
16 | * This class contains the metrics used to layout a sequence diagram on a view The class method are mostly used in | |
17 | * combination with the preferences | |
013a5f1c AM |
18 | * |
19 | * @version 1.0 | |
73005152 | 20 | * @author sveyrier |
013a5f1c | 21 | * |
73005152 BH |
22 | */ |
23 | public class Metrics { | |
df0b8ff4 BH |
24 | // ------------------------------------------------------------------------ |
25 | // Constants | |
26 | // ------------------------------------------------------------------------ | |
73005152 BH |
27 | |
28 | /** | |
29 | * Space between the Frame and the top of the View This also represent the space between the frame and the bottom of | |
30 | * the View | |
31 | */ | |
32 | public static final int FRAME_H_MARGIN = 10; | |
33 | /** | |
34 | * Space between the Frame and the left of the View This also represent the space between the Frame and the right of | |
35 | * the View | |
36 | */ | |
37 | public static final int FRAME_V_MARGIN = 10; | |
38 | /** | |
39 | * Space between the Lifelines and the right of the Frame | |
40 | */ | |
41 | public static final int LIFELINE_H_MAGIN = 23; | |
73005152 BH |
42 | /** |
43 | * Space between the Lifelines and the bottom of the Frame | |
44 | */ | |
45 | public static final int LIFELINE_VB_MAGIN = 20; | |
46 | /** | |
47 | * Space between the Lifelines and the top of the Frame | |
48 | */ | |
49 | public static final int LIFELINE_VT_MAGIN = 30;// 18 | |
50 | /** | |
51 | * Vertical space between the lifeline name and the rectangle which contains that name This is only for the | |
52 | * "always visible" lifeline name rectangle | |
53 | */ | |
54 | public static final int LIFELINE_HEARDER_TEXT_V_MARGIN = 4; | |
55 | /** | |
56 | * Vertical spacing between messages | |
57 | */ | |
df0b8ff4 | 58 | public static final int MESSAGES_SPACING = 30; |
73005152 BH |
59 | /** |
60 | * Vertical spacing between the message and its name | |
61 | */ | |
62 | public static final int MESSAGES_NAME_SPACING = 10; | |
63 | /** | |
64 | * Horizontal spacing between the Frame name and its containing rectangle | |
65 | */ | |
66 | public static final int FRAME_NAME_H_MARGIN = 4; | |
67 | /** | |
68 | * Vertical spacing between the Frame name and its containing rectangle | |
69 | */ | |
70 | public static final int FRAME_NAME_V_MARGIN = 8; | |
71 | /** | |
72 | * Horizontal spacing between the lifeline name and its containing rectangle | |
73 | */ | |
74 | public static final int LIFELINE_NAME_H_MARGIN = 14; | |
75 | /** | |
76 | * Vertical spacing between the lifeline name and its containing rectangle | |
77 | */ | |
78 | public static final int LIFELINE_NAME_V_MARGIN = 20; | |
79 | /** | |
80 | * Space between the rectangles which contain the Lifelines name | |
81 | */ | |
82 | public static final int LIFELINE_SPACING = 45; | |
83 | /** | |
84 | * The circle ray used to draw the circle which compose Found and Lost messages | |
85 | */ | |
86 | public static final int MESSAGE_CIRCLE_RAY = 5; | |
87 | /** | |
88 | * Execution occurrence vertical width | |
89 | */ | |
90 | public static final int EXECUTION_OCCURRENCE_WIDTH = 8; | |
91 | /** | |
92 | * The square width which contains the Stop representation (a cross) | |
93 | */ | |
94 | public static final int STOP_WIDTH = 20; | |
df0b8ff4 | 95 | /** |
013a5f1c | 96 | * The internal message width. |
df0b8ff4 | 97 | */ |
73005152 | 98 | public static final int INTERNAL_MESSAGE_WIDTH = 20; |
df0b8ff4 BH |
99 | /** |
100 | * The internal sychrounous message height. | |
101 | */ | |
73005152 | 102 | public static final int SYNC_INTERNAL_MESSAGE_HEIGHT = 10; |
73005152 BH |
103 | /** |
104 | * Line width used when drawing selected GraphNode | |
105 | */ | |
106 | public static final int SELECTION_LINE_WIDTH = 5; | |
107 | /** | |
108 | * Line width used when drawing non selected GraphNode | |
109 | */ | |
110 | public static final int NORMAL_LINE_WIDTH = 1; | |
df0b8ff4 BH |
111 | /** |
112 | * The internal vertical message margin | |
113 | */ | |
73005152 BH |
114 | public static final int INTERNAL_MESSAGE_V_MARGIN = 10; |
115 | ||
116 | /** | |
117 | * Used to sample the diagram. When the lifeline spacing is smaller than this constant when zooming out then less | |
118 | * lifelines are displayed to avoid lifelines overlapping and mainly saving some execution time | |
119 | */ | |
120 | public static final int LIFELINE_SIGNIFICANT_HSPACING = 10; | |
121 | /** | |
122 | * Used to sample the diagram. When the message spacing is smaller than this constant when zooming out then less | |
123 | * message are displayed to avoid message overlapping and mainly saving some execution time | |
124 | */ | |
125 | public static final int MESSAGE_SIGNIFICANT_VSPACING = 1; | |
df0b8ff4 BH |
126 | /** |
127 | * Message selection tolerance. Used for internal syncMessages only | |
128 | */ | |
73005152 | 129 | public static final int MESSAGE_SELECTION_TOLERANCE = 30; |
df0b8ff4 BH |
130 | /** |
131 | * The focus drawing margin. | |
132 | */ | |
73005152 | 133 | public static final int FOCUS_DRAWING_MARGIN = 10; |
013a5f1c | 134 | |
df0b8ff4 BH |
135 | // ------------------------------------------------------------------------ |
136 | // Attributes | |
137 | // ------------------------------------------------------------------------ | |
138 | /** | |
139 | * The lifeline font height | |
140 | */ | |
eb63f5ff | 141 | private static int fLifelineFontHeight = 0; |
df0b8ff4 BH |
142 | /** |
143 | * The message font height | |
144 | */ | |
eb63f5ff | 145 | private static int fMessageFontHeight = 0; |
df0b8ff4 BH |
146 | /** |
147 | * The frame font height | |
148 | */ | |
eb63f5ff | 149 | private static int fFrameFontHeight = 0; |
df0b8ff4 BH |
150 | /** |
151 | * The lifeline header font height | |
152 | */ | |
eb63f5ff | 153 | private static int fLifelineHeaderFontHeight = 0; |
df0b8ff4 BH |
154 | /** |
155 | * The lifeline font widht | |
156 | */ | |
eb63f5ff | 157 | private static int fLifelineFontWidth = 0; |
df0b8ff4 BH |
158 | /** |
159 | * The lifeline width | |
160 | */ | |
eb63f5ff | 161 | private static int fLifeLineWidth = 119; |
df0b8ff4 BH |
162 | /** |
163 | * The (forced) event spacing | |
164 | */ | |
eb63f5ff | 165 | private static int fForcedEventSpacing = -1; |
73005152 | 166 | |
3145ec83 BH |
167 | // ------------------------------------------------------------------------ |
168 | // Constructor | |
169 | // ------------------------------------------------------------------------ | |
170 | /** | |
171 | * Constructor | |
013a5f1c | 172 | * |
3145ec83 BH |
173 | * Hide private constructor |
174 | */ | |
175 | private Metrics() { | |
176 | } | |
013a5f1c | 177 | |
df0b8ff4 BH |
178 | // ------------------------------------------------------------------------ |
179 | // Methods | |
180 | // ------------------------------------------------------------------------ | |
73005152 BH |
181 | |
182 | /** | |
183 | * Set the character height used to draw the lifeline name | |
013a5f1c | 184 | * |
73005152 BH |
185 | * @param height the character height |
186 | */ | |
187 | static public void setLifelineFontHeight(int height) { | |
eb63f5ff | 188 | fLifelineFontHeight = height; |
73005152 BH |
189 | } |
190 | ||
191 | /** | |
192 | * Set the character width used to draw the lifeline name | |
013a5f1c | 193 | * |
73005152 BH |
194 | * @param width the character width |
195 | */ | |
196 | static public void setLifelineFontWidth(int width) { | |
eb63f5ff | 197 | fLifelineFontWidth = width; |
73005152 BH |
198 | } |
199 | ||
200 | /** | |
201 | * Set the character height used to draw the message name | |
013a5f1c | 202 | * |
73005152 BH |
203 | * @param fontHeight the character height |
204 | */ | |
205 | static public void setMessageFontHeight(int fontHeight) { | |
eb63f5ff | 206 | fMessageFontHeight = fontHeight; |
73005152 BH |
207 | } |
208 | ||
209 | /** | |
210 | * Returns the character height used to draw the lifeline name | |
013a5f1c | 211 | * |
73005152 BH |
212 | * @return the character height |
213 | */ | |
214 | static public int getFrameFontHeigth() { | |
eb63f5ff | 215 | return fFrameFontHeight; |
73005152 BH |
216 | } |
217 | ||
218 | /** | |
219 | * Set the character height used to draw the message name | |
013a5f1c | 220 | * |
73005152 BH |
221 | * @param fontHeight the character height |
222 | */ | |
223 | static public void setFrameFontHeight(int fontHeight) { | |
eb63f5ff | 224 | fFrameFontHeight = fontHeight; |
73005152 BH |
225 | } |
226 | ||
227 | /** | |
228 | * Returns the character height used to draw the lifeline name | |
013a5f1c | 229 | * |
73005152 BH |
230 | * @return the character height |
231 | */ | |
232 | static public int getLifelineHeaderFontHeigth() { | |
eb63f5ff | 233 | return fLifelineHeaderFontHeight; |
73005152 BH |
234 | } |
235 | ||
236 | /** | |
237 | * Set the character height used to draw the message name | |
013a5f1c | 238 | * |
73005152 BH |
239 | * @param fontHeight the character height |
240 | */ | |
241 | static public void setLifelineHeaderFontHeight(int fontHeight) { | |
eb63f5ff | 242 | fLifelineHeaderFontHeight = fontHeight; |
73005152 BH |
243 | } |
244 | ||
245 | /** | |
246 | * Returns the character height used to draw the lifeline name | |
013a5f1c | 247 | * |
73005152 BH |
248 | * @return the character height |
249 | */ | |
250 | static public int getLifelineFontHeigth() { | |
eb63f5ff | 251 | return fLifelineFontHeight; |
73005152 BH |
252 | } |
253 | ||
254 | /** | |
255 | * Returns the character height used to draw the message name | |
013a5f1c | 256 | * |
73005152 BH |
257 | * @return the character height |
258 | */ | |
259 | static public int getMessageFontHeigth() { | |
eb63f5ff | 260 | if (fForcedEventSpacing >= 0) { |
73005152 | 261 | return 0; |
df0b8ff4 | 262 | } |
eb63f5ff | 263 | return fMessageFontHeight; |
73005152 BH |
264 | } |
265 | ||
266 | /** | |
267 | * This is the vertical space used by a Lifeline (mostly the rectangle which contain its name) | |
013a5f1c | 268 | * |
73005152 BH |
269 | * @return the vertical space used by a Lifeline |
270 | */ | |
271 | static public int getLifelineWidth() { | |
eb63f5ff | 272 | return fLifeLineWidth; |
73005152 BH |
273 | } |
274 | ||
275 | /** | |
276 | * Set the vertical space used by a Lifeline (mostly the rectangle which contain its name) | |
013a5f1c | 277 | * |
73005152 BH |
278 | * @param value the vertical space |
279 | */ | |
280 | static public void setLifelineWidth(int value) { | |
eb63f5ff | 281 | fLifeLineWidth = value; |
73005152 BH |
282 | } |
283 | ||
284 | /** | |
285 | * Returns the swimming lane width | |
013a5f1c | 286 | * |
73005152 BH |
287 | * @return the swimming lane width |
288 | */ | |
289 | static public int swimmingLaneWidth() { | |
290 | return getLifelineWidth() + LIFELINE_SPACING; | |
291 | } | |
292 | ||
293 | /** | |
294 | * Returns the character width used to draw the Lifelines name | |
013a5f1c | 295 | * |
73005152 BH |
296 | * @return the average character width |
297 | */ | |
298 | static public int getAverageCharWidth() { | |
eb63f5ff | 299 | return fLifelineFontWidth; |
73005152 BH |
300 | } |
301 | ||
df0b8ff4 BH |
302 | /** |
303 | * Returns the message spacing. | |
013a5f1c | 304 | * |
df0b8ff4 BH |
305 | * @return the message spacing |
306 | */ | |
73005152 | 307 | static public int getMessagesSpacing() { |
eb63f5ff BH |
308 | if (fForcedEventSpacing >= 0) { |
309 | return fForcedEventSpacing; | |
013a5f1c | 310 | } |
df0b8ff4 | 311 | return MESSAGES_SPACING; |
73005152 BH |
312 | } |
313 | ||
314 | /** | |
315 | * Sets the forced event spacing value . | |
013a5f1c | 316 | * |
73005152 | 317 | * @param eventSpacing |
a55887ca | 318 | * The spacing value |
73005152 BH |
319 | */ |
320 | static public void setForcedEventSpacing(int eventSpacing) { | |
eb63f5ff | 321 | fForcedEventSpacing = eventSpacing; |
73005152 BH |
322 | } |
323 | ||
324 | /** | |
325 | * Gets the forced event spacing value. | |
013a5f1c | 326 | * |
73005152 BH |
327 | * @return forcedEventSpacing |
328 | */ | |
329 | static public int getForcedEventSpacing() { | |
eb63f5ff | 330 | return fForcedEventSpacing; |
73005152 BH |
331 | } |
332 | } |