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