1 /**********************************************************************
2 * Copyright (c) 2005, 2014 IBM Corporation, Ericsson
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
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
11 **********************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.core
;
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
23 public class Metrics
{
24 // ------------------------------------------------------------------------
26 // ------------------------------------------------------------------------
29 * Space between the Frame and the top of the View This also represent the space between the frame and the bottom of
32 public static final int FRAME_H_MARGIN
= 10;
34 * Space between the Frame and the left of the View This also represent the space between the Frame and the right of
37 public static final int FRAME_V_MARGIN
= 10;
39 * Space between the Lifelines and the right of the Frame
41 public static final int LIFELINE_H_MAGIN
= 23;
43 * Space between the Lifelines and the bottom of the Frame
45 public static final int LIFELINE_VB_MAGIN
= 20;
47 * Space between the Lifelines and the top of the Frame
49 public static final int LIFELINE_VT_MAGIN
= 30;// 18
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
54 public static final int LIFELINE_HEARDER_TEXT_V_MARGIN
= 4;
56 * Vertical spacing between messages
58 public static final int MESSAGES_SPACING
= 30;
60 * Vertical spacing between the message and its name
62 public static final int MESSAGES_NAME_SPACING
= 10;
64 * Horizontal spacing between the Frame name and its containing rectangle
66 public static final int FRAME_NAME_H_MARGIN
= 4;
68 * Vertical spacing between the Frame name and its containing rectangle
70 public static final int FRAME_NAME_V_MARGIN
= 8;
72 * Horizontal spacing between the lifeline name and its containing rectangle
74 public static final int LIFELINE_NAME_H_MARGIN
= 14;
76 * Vertical spacing between the lifeline name and its containing rectangle
78 public static final int LIFELINE_NAME_V_MARGIN
= 20;
80 * Space between the rectangles which contain the Lifelines name
82 public static final int LIFELINE_SPACING
= 45;
84 * The circle ray used to draw the circle which compose Found and Lost messages
86 public static final int MESSAGE_CIRCLE_RAY
= 5;
88 * Execution occurrence vertical width
90 public static final int EXECUTION_OCCURRENCE_WIDTH
= 8;
92 * The square width which contains the Stop representation (a cross)
94 public static final int STOP_WIDTH
= 20;
96 * The internal message width.
98 public static final int INTERNAL_MESSAGE_WIDTH
= 20;
100 * The internal sychrounous message height.
102 public static final int SYNC_INTERNAL_MESSAGE_HEIGHT
= 10;
104 * Line width used when drawing selected GraphNode
106 public static final int SELECTION_LINE_WIDTH
= 5;
108 * Line width used when drawing non selected GraphNode
110 public static final int NORMAL_LINE_WIDTH
= 1;
112 * The internal vertical message margin
114 public static final int INTERNAL_MESSAGE_V_MARGIN
= 10;
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
120 public static final int LIFELINE_SIGNIFICANT_HSPACING
= 10;
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
125 public static final int MESSAGE_SIGNIFICANT_VSPACING
= 1;
127 * Message selection tolerance. Used for internal syncMessages only
129 public static final int MESSAGE_SELECTION_TOLERANCE
= 30;
131 * The focus drawing margin.
133 public static final int FOCUS_DRAWING_MARGIN
= 10;
135 // ------------------------------------------------------------------------
137 // ------------------------------------------------------------------------
139 * The lifeline font height
141 private static int fLifelineFontHeight
= 0;
143 * The message font height
145 private static int fMessageFontHeight
= 0;
147 * The frame font height
149 private static int fFrameFontHeight
= 0;
151 * The lifeline header font height
153 private static int fLifelineHeaderFontHeight
= 0;
155 * The lifeline font widht
157 private static int fLifelineFontWidth
= 0;
161 private static int fLifeLineWidth
= 119;
163 * The (forced) event spacing
165 private static int fForcedEventSpacing
= -1;
167 // ------------------------------------------------------------------------
169 // ------------------------------------------------------------------------
173 * Hide private constructor
178 // ------------------------------------------------------------------------
180 // ------------------------------------------------------------------------
183 * Set the character height used to draw the lifeline name
185 * @param height the character height
187 public static void setLifelineFontHeight(int height
) {
188 fLifelineFontHeight
= height
;
192 * Set the character width used to draw the lifeline name
194 * @param width the character width
196 public static void setLifelineFontWidth(int width
) {
197 fLifelineFontWidth
= width
;
201 * Set the character height used to draw the message name
203 * @param fontHeight the character height
205 public static void setMessageFontHeight(int fontHeight
) {
206 fMessageFontHeight
= fontHeight
;
210 * Returns the character height used to draw the lifeline name
212 * @return the character height
214 public static int getFrameFontHeigth() {
215 return fFrameFontHeight
;
219 * Set the character height used to draw the message name
221 * @param fontHeight the character height
223 public static void setFrameFontHeight(int fontHeight
) {
224 fFrameFontHeight
= fontHeight
;
228 * Returns the character height used to draw the lifeline name
230 * @return the character height
232 public static int getLifelineHeaderFontHeigth() {
233 return fLifelineHeaderFontHeight
;
237 * Set the character height used to draw the message name
239 * @param fontHeight the character height
241 public static void setLifelineHeaderFontHeight(int fontHeight
) {
242 fLifelineHeaderFontHeight
= fontHeight
;
246 * Returns the character height used to draw the lifeline name
248 * @return the character height
250 public static int getLifelineFontHeigth() {
251 return fLifelineFontHeight
;
255 * Returns the character height used to draw the message name
257 * @return the character height
259 public static int getMessageFontHeigth() {
260 if (fForcedEventSpacing
>= 0) {
263 return fMessageFontHeight
;
267 * This is the vertical space used by a Lifeline (mostly the rectangle which contain its name)
269 * @return the vertical space used by a Lifeline
271 public static int getLifelineWidth() {
272 return fLifeLineWidth
;
276 * Set the vertical space used by a Lifeline (mostly the rectangle which contain its name)
278 * @param value the vertical space
280 public static void setLifelineWidth(int value
) {
281 fLifeLineWidth
= value
;
285 * Returns the swimming lane width
287 * @return the swimming lane width
289 public static int swimmingLaneWidth() {
290 return getLifelineWidth() + LIFELINE_SPACING
;
294 * Returns the character width used to draw the Lifelines name
296 * @return the average character width
298 public static int getAverageCharWidth() {
299 return fLifelineFontWidth
;
303 * Returns the message spacing.
305 * @return the message spacing
307 public static int getMessagesSpacing() {
308 if (fForcedEventSpacing
>= 0) {
309 return fForcedEventSpacing
;
311 return MESSAGES_SPACING
;
315 * Sets the forced event spacing value .
317 * @param eventSpacing
320 public static void setForcedEventSpacing(int eventSpacing
) {
321 fForcedEventSpacing
= eventSpacing
;
325 * Gets the forced event spacing value.
327 * @return forcedEventSpacing
329 public static int getForcedEventSpacing() {
330 return fForcedEventSpacing
;