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: Metrics.java,v 1.3 2008/01/24 02:28:49 apnan Exp $
10 * IBM - Initial API and implementation
11 * Bernd Hufmann - Updated for TMF
12 **********************************************************************/
13 package org
.eclipse
.linuxtools
.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
22 public class Metrics
{
25 * Space between the Frame and the top of the View This also represent the space between the frame and the bottom of
28 public static final int FRAME_H_MARGIN
= 10;
30 * Space between the Frame and the left of the View This also represent the space between the Frame and the right of
33 public static final int FRAME_V_MARGIN
= 10;
35 * Space between the Lifelines and the right of the Frame
37 public static final int LIFELINE_H_MAGIN
= 23;
40 * Space between the Lifelines and the bottom of the Frame
42 public static final int LIFELINE_VB_MAGIN
= 20;
44 * Space between the Lifelines and the top of the Frame
46 public static final int LIFELINE_VT_MAGIN
= 30;// 18
48 * Vertical space between the lifeline name and the rectangle which contains that name This is only for the
49 * "always visible" lifeline name rectangle
51 public static final int LIFELINE_HEARDER_TEXT_V_MARGIN
= 4;
53 * Vertical spacing between messages
55 protected static final int MESSAGES_SPACING
= 30;
57 * Vertical spacing between the message and its name
59 public static final int MESSAGES_NAME_SPACING
= 10;
61 * Horizontal spacing between the Frame name and its containing rectangle
63 public static final int FRAME_NAME_H_MARGIN
= 4;
65 * Vertical spacing between the Frame name and its containing rectangle
67 public static final int FRAME_NAME_V_MARGIN
= 8;
69 * Horizontal spacing between the lifeline name and its containing rectangle
71 public static final int LIFELINE_NAME_H_MARGIN
= 14;
73 * Vertical spacing between the lifeline name and its containing rectangle
75 public static final int LIFELINE_NAME_V_MARGIN
= 20;
77 * Space between the rectangles which contain the Lifelines name
79 public static final int LIFELINE_SPACING
= 45;
81 * The circle ray used to draw the circle which compose Found and Lost messages
83 public static final int MESSAGE_CIRCLE_RAY
= 5;
85 * Execution occurrence vertical width
87 public static final int EXECUTION_OCCURRENCE_WIDTH
= 8;
89 * The square width which contains the Stop representation (a cross)
91 public static final int STOP_WIDTH
= 20;
93 public static final int INTERNAL_MESSAGE_WIDTH
= 20;
94 public static final int SYNC_INTERNAL_MESSAGE_HEIGHT
= 10;
97 * Line width used when drawing selected GraphNode
99 public static final int SELECTION_LINE_WIDTH
= 5;
101 * Line width used when drawing non selected GraphNode
103 public static final int NORMAL_LINE_WIDTH
= 1;
104 public static final int INTERNAL_MESSAGE_V_MARGIN
= 10;
107 * Used to sample the diagram. When the lifeline spacing is smaller than this constant when zooming out then less
108 * lifelines are displayed to avoid lifelines overlapping and mainly saving some execution time
110 public static final int LIFELINE_SIGNIFICANT_HSPACING
= 10;
112 * Used to sample the diagram. When the message spacing is smaller than this constant when zooming out then less
113 * message are displayed to avoid message overlapping and mainly saving some execution time
115 public static final int MESSAGE_SIGNIFICANT_VSPACING
= 1;
117 // Used for internal syncMessages only
118 public static final int MESSAGE_SELECTION_TOLERANCE
= 30;
120 public static final int FOCUS_DRAWING_MARGIN
= 10;
122 static private int lifelineFontHeight
= 0;
123 static private int messageFontHeight
= 0;
124 static private int frameFontHeight
= 0;
125 static private int lifelineHeaderFontHeight
= 0;
126 static private int lifelineFontWidth
= 0;
127 static private int lifeLineWidth
= 119;
129 static private int forcedEventSpacing
= -1;
132 * Set the character height used to draw the lifeline name
134 * @param height the character height
136 static public void setLifelineFontHeight(int height
) {
137 lifelineFontHeight
= height
;
141 * Set the character width used to draw the lifeline name
143 * @param width the character width
145 static public void setLifelineFontWidth(int width
) {
146 lifelineFontWidth
= width
;
150 * Set the character height used to draw the message name
152 * @param fontHeight the character height
154 static public void setMessageFontHeight(int fontHeight
) {
155 messageFontHeight
= fontHeight
;
159 * Returns the character height used to draw the lifeline name
161 * @return the character height
163 static public int getFrameFontHeigth() {
164 return frameFontHeight
;
168 * Set the character height used to draw the message name
170 * @param fontHeight the character height
172 static public void setFrameFontHeight(int fontHeight
) {
173 frameFontHeight
= fontHeight
;
177 * Returns the character height used to draw the lifeline name
179 * @return the character height
181 static public int getLifelineHeaderFontHeigth() {
182 return lifelineHeaderFontHeight
;
186 * Set the character height used to draw the message name
188 * @param fontHeight the character height
190 static public void setLifelineHeaderFontHeight(int fontHeight
) {
191 lifelineHeaderFontHeight
= fontHeight
;
195 * Returns the character height used to draw the lifeline name
197 * @return the character height
199 static public int getLifelineFontHeigth() {
200 return lifelineFontHeight
;
204 * Returns the character height used to draw the message name
206 * @return the character height
208 static public int getMessageFontHeigth() {
209 if (forcedEventSpacing
>= 0)
212 return messageFontHeight
;
216 * This is the vertical space used by a Lifeline (mostly the rectangle which contain its name)
218 * @return the vertical space used by a Lifeline
220 static public int getLifelineWidth() {
221 return lifeLineWidth
;
225 * Set the vertical space used by a Lifeline (mostly the rectangle which contain its name)
227 * @param value the vertical space
229 static public void setLifelineWidth(int value
) {
230 lifeLineWidth
= value
;
234 * Returns the swimming lane width
236 * @return the swimming lane width
238 static public int swimmingLaneWidth() {
239 return getLifelineWidth() + LIFELINE_SPACING
;
243 * Returns the character width used to draw the Lifelines name
245 * @return the average character width
247 static public int getAverageCharWidth() {
248 return lifelineFontWidth
;
251 static public int getMessagesSpacing() {
252 if (forcedEventSpacing
>= 0)
253 return forcedEventSpacing
;
255 return MESSAGES_SPACING
;
259 * Sets the forced event spacing value .
261 * @param eventSpacing
263 static public void setForcedEventSpacing(int eventSpacing
) {
264 forcedEventSpacing
= eventSpacing
;
268 * Gets the forced event spacing value.
270 * @return forcedEventSpacing
272 static public int getForcedEventSpacing() {
273 return forcedEventSpacing
;