Commit | Line | Data |
---|---|---|
73005152 BH |
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 $ | |
8 | * | |
9 | * Contributors: | |
10 | * IBM - Initial API and implementation | |
11 | * Bernd Hufmann - Updated for TMF | |
12 | **********************************************************************/ | |
13 | package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core; | |
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 | |
18 | * | |
19 | * @author sveyrier | |
20 | * | |
21 | */ | |
22 | public class Metrics { | |
23 | ||
24 | /** | |
25 | * Space between the Frame and the top of the View This also represent the space between the frame and the bottom of | |
26 | * the View | |
27 | */ | |
28 | public static final int FRAME_H_MARGIN = 10; | |
29 | /** | |
30 | * Space between the Frame and the left of the View This also represent the space between the Frame and the right of | |
31 | * the View | |
32 | */ | |
33 | public static final int FRAME_V_MARGIN = 10; | |
34 | /** | |
35 | * Space between the Lifelines and the right of the Frame | |
36 | */ | |
37 | public static final int LIFELINE_H_MAGIN = 23; | |
38 | ||
39 | /** | |
40 | * Space between the Lifelines and the bottom of the Frame | |
41 | */ | |
42 | public static final int LIFELINE_VB_MAGIN = 20; | |
43 | /** | |
44 | * Space between the Lifelines and the top of the Frame | |
45 | */ | |
46 | public static final int LIFELINE_VT_MAGIN = 30;// 18 | |
47 | /** | |
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 | |
50 | */ | |
51 | public static final int LIFELINE_HEARDER_TEXT_V_MARGIN = 4; | |
52 | /** | |
53 | * Vertical spacing between messages | |
54 | */ | |
55 | protected static final int MESSAGES_SPACING = 30; | |
56 | /** | |
57 | * Vertical spacing between the message and its name | |
58 | */ | |
59 | public static final int MESSAGES_NAME_SPACING = 10; | |
60 | /** | |
61 | * Horizontal spacing between the Frame name and its containing rectangle | |
62 | */ | |
63 | public static final int FRAME_NAME_H_MARGIN = 4; | |
64 | /** | |
65 | * Vertical spacing between the Frame name and its containing rectangle | |
66 | */ | |
67 | public static final int FRAME_NAME_V_MARGIN = 8; | |
68 | /** | |
69 | * Horizontal spacing between the lifeline name and its containing rectangle | |
70 | */ | |
71 | public static final int LIFELINE_NAME_H_MARGIN = 14; | |
72 | /** | |
73 | * Vertical spacing between the lifeline name and its containing rectangle | |
74 | */ | |
75 | public static final int LIFELINE_NAME_V_MARGIN = 20; | |
76 | /** | |
77 | * Space between the rectangles which contain the Lifelines name | |
78 | */ | |
79 | public static final int LIFELINE_SPACING = 45; | |
80 | /** | |
81 | * The circle ray used to draw the circle which compose Found and Lost messages | |
82 | */ | |
83 | public static final int MESSAGE_CIRCLE_RAY = 5; | |
84 | /** | |
85 | * Execution occurrence vertical width | |
86 | */ | |
87 | public static final int EXECUTION_OCCURRENCE_WIDTH = 8; | |
88 | /** | |
89 | * The square width which contains the Stop representation (a cross) | |
90 | */ | |
91 | public static final int STOP_WIDTH = 20; | |
92 | ||
93 | public static final int INTERNAL_MESSAGE_WIDTH = 20; | |
94 | public static final int SYNC_INTERNAL_MESSAGE_HEIGHT = 10; | |
95 | ||
96 | /** | |
97 | * Line width used when drawing selected GraphNode | |
98 | */ | |
99 | public static final int SELECTION_LINE_WIDTH = 5; | |
100 | /** | |
101 | * Line width used when drawing non selected GraphNode | |
102 | */ | |
103 | public static final int NORMAL_LINE_WIDTH = 1; | |
104 | public static final int INTERNAL_MESSAGE_V_MARGIN = 10; | |
105 | ||
106 | /** | |
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 | |
109 | */ | |
110 | public static final int LIFELINE_SIGNIFICANT_HSPACING = 10; | |
111 | /** | |
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 | |
114 | */ | |
115 | public static final int MESSAGE_SIGNIFICANT_VSPACING = 1; | |
116 | ||
117 | // Used for internal syncMessages only | |
118 | public static final int MESSAGE_SELECTION_TOLERANCE = 30; | |
119 | ||
120 | public static final int FOCUS_DRAWING_MARGIN = 10; | |
121 | ||
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; | |
128 | ||
129 | static private int forcedEventSpacing = -1; | |
130 | ||
131 | /** | |
132 | * Set the character height used to draw the lifeline name | |
133 | * | |
134 | * @param height the character height | |
135 | */ | |
136 | static public void setLifelineFontHeight(int height) { | |
137 | lifelineFontHeight = height; | |
138 | } | |
139 | ||
140 | /** | |
141 | * Set the character width used to draw the lifeline name | |
142 | * | |
143 | * @param width the character width | |
144 | */ | |
145 | static public void setLifelineFontWidth(int width) { | |
146 | lifelineFontWidth = width; | |
147 | } | |
148 | ||
149 | /** | |
150 | * Set the character height used to draw the message name | |
151 | * | |
152 | * @param fontHeight the character height | |
153 | */ | |
154 | static public void setMessageFontHeight(int fontHeight) { | |
155 | messageFontHeight = fontHeight; | |
156 | } | |
157 | ||
158 | /** | |
159 | * Returns the character height used to draw the lifeline name | |
160 | * | |
161 | * @return the character height | |
162 | */ | |
163 | static public int getFrameFontHeigth() { | |
164 | return frameFontHeight; | |
165 | } | |
166 | ||
167 | /** | |
168 | * Set the character height used to draw the message name | |
169 | * | |
170 | * @param fontHeight the character height | |
171 | */ | |
172 | static public void setFrameFontHeight(int fontHeight) { | |
173 | frameFontHeight = fontHeight; | |
174 | } | |
175 | ||
176 | /** | |
177 | * Returns the character height used to draw the lifeline name | |
178 | * | |
179 | * @return the character height | |
180 | */ | |
181 | static public int getLifelineHeaderFontHeigth() { | |
182 | return lifelineHeaderFontHeight; | |
183 | } | |
184 | ||
185 | /** | |
186 | * Set the character height used to draw the message name | |
187 | * | |
188 | * @param fontHeight the character height | |
189 | */ | |
190 | static public void setLifelineHeaderFontHeight(int fontHeight) { | |
191 | lifelineHeaderFontHeight = fontHeight; | |
192 | } | |
193 | ||
194 | /** | |
195 | * Returns the character height used to draw the lifeline name | |
196 | * | |
197 | * @return the character height | |
198 | */ | |
199 | static public int getLifelineFontHeigth() { | |
200 | return lifelineFontHeight; | |
201 | } | |
202 | ||
203 | /** | |
204 | * Returns the character height used to draw the message name | |
205 | * | |
206 | * @return the character height | |
207 | */ | |
208 | static public int getMessageFontHeigth() { | |
209 | if (forcedEventSpacing >= 0) | |
210 | return 0; | |
211 | else | |
212 | return messageFontHeight; | |
213 | } | |
214 | ||
215 | /** | |
216 | * This is the vertical space used by a Lifeline (mostly the rectangle which contain its name) | |
217 | * | |
218 | * @return the vertical space used by a Lifeline | |
219 | */ | |
220 | static public int getLifelineWidth() { | |
221 | return lifeLineWidth; | |
222 | } | |
223 | ||
224 | /** | |
225 | * Set the vertical space used by a Lifeline (mostly the rectangle which contain its name) | |
226 | * | |
227 | * @param value the vertical space | |
228 | */ | |
229 | static public void setLifelineWidth(int value) { | |
230 | lifeLineWidth = value; | |
231 | } | |
232 | ||
233 | /** | |
234 | * Returns the swimming lane width | |
235 | * | |
236 | * @return the swimming lane width | |
237 | */ | |
238 | static public int swimmingLaneWidth() { | |
239 | return getLifelineWidth() + LIFELINE_SPACING; | |
240 | } | |
241 | ||
242 | /** | |
243 | * Returns the character width used to draw the Lifelines name | |
244 | * | |
245 | * @return the average character width | |
246 | */ | |
247 | static public int getAverageCharWidth() { | |
248 | return lifelineFontWidth; | |
249 | } | |
250 | ||
251 | static public int getMessagesSpacing() { | |
252 | if (forcedEventSpacing >= 0) | |
253 | return forcedEventSpacing; | |
254 | else | |
255 | return MESSAGES_SPACING; | |
256 | } | |
257 | ||
258 | /** | |
259 | * Sets the forced event spacing value . | |
260 | * | |
261 | * @param eventSpacing | |
262 | */ | |
263 | static public void setForcedEventSpacing(int eventSpacing) { | |
264 | forcedEventSpacing = eventSpacing; | |
265 | } | |
266 | ||
267 | /** | |
268 | * Gets the forced event spacing value. | |
269 | * | |
270 | * @return forcedEventSpacing | |
271 | */ | |
272 | static public int getForcedEventSpacing() { | |
273 | return forcedEventSpacing; | |
274 | } | |
275 | } |