Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ArgoFig |
|
| 1.0;1 |
1 | /* $Id: ArgoFig.java 17753 2010-01-11 19:49:55Z linus $ | |
2 | ******************************************************************************* | |
3 | * Copyright (c) 2010 Contributors - see below | |
4 | * All rights reserved. This program and the accompanying materials | |
5 | * are made available under the terms of the Eclipse Public License v1.0 | |
6 | * which accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Tom Morris | |
11 | * Bob Tarling | |
12 | ******************************************************************************* | |
13 | * | |
14 | * Some portions of this file were previously release using the BSD License: | |
15 | */ | |
16 | // $Id: ArgoFig.java 17753 2010-01-11 19:49:55Z linus $ | |
17 | // Copyright (c) 2007-2009 The Regents of the University of California. All | |
18 | // Rights Reserved. Permission to use, copy, modify, and distribute this | |
19 | // software and its documentation without fee, and without a written | |
20 | // agreement is hereby granted, provided that the above copyright notice | |
21 | // and this paragraph appear in all copies. This software program and | |
22 | // documentation are copyrighted by The Regents of the University of | |
23 | // California. The software program and documentation are supplied "AS | |
24 | // IS", without any accompanying services from The Regents. The Regents | |
25 | // does not warrant that the operation of the program will be | |
26 | // uninterrupted or error-free. The end-user understands that the program | |
27 | // was developed for research purposes and is advised not to rely | |
28 | // exclusively on the program for any reason. IN NO EVENT SHALL THE | |
29 | // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, | |
30 | // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, | |
31 | // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF | |
32 | // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF | |
33 | // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY | |
34 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
35 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE | |
36 | // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF | |
37 | // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, | |
38 | // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
39 | ||
40 | package org.argouml.uml.diagram.ui; | |
41 | ||
42 | import java.awt.Color; | |
43 | ||
44 | import org.argouml.uml.diagram.DiagramSettings; | |
45 | ||
46 | /** | |
47 | * An interface that all ArgoUML Figs are required to implament. It provides a | |
48 | * single place to specify behaviors that we want all Figs to have since we | |
49 | * don't have access to the GEF class hierarchy (and it is made up of concrete | |
50 | * classes instead of interfaces. | |
51 | * | |
52 | * @author Tom Morris <tfmorris@gmail.com> | |
53 | * @since 0.25.4 | |
54 | */ | |
55 | public interface ArgoFig { | |
56 | ||
57 | // TODO: These have been used for most instances of new FigFoo(X0, Y0, ... | |
58 | // but additional work is required to extract the constant from | |
59 | // calculations, etc. | |
60 | ||
61 | /** Default X offset of origin used when building figs */ | |
62 | static final int X0 = 10; | |
63 | ||
64 | /** Default Y offset of origin used when building figs */ | |
65 | static final int Y0 = 10; | |
66 | ||
67 | /** | |
68 | * min. 17, used to calculate y pos of FigText items in a compartment | |
69 | */ | |
70 | public static final int ROWHEIGHT = 17; | |
71 | /** | |
72 | * min. 18, used to calculate y pos of stereotype FigText items | |
73 | * in a compartment | |
74 | */ | |
75 | public static final int STEREOHEIGHT = 18; | |
76 | ||
77 | ||
78 | /** | |
79 | * Enable this flag to switch to the debug default color scheme | |
80 | */ | |
81 | static final boolean DEBUG = false; | |
82 | ||
83 | /** | |
84 | * Default line width in pixels. | |
85 | */ | |
86 | static final int LINE_WIDTH = !DEBUG ? 1 : 20; | |
87 | ||
88 | /** | |
89 | * Default color for lines. This constant is an interim measure before | |
90 | * moving to settable defaults. | |
91 | */ | |
92 | static final Color LINE_COLOR = !DEBUG ? Color.black | |
93 | : new Color(0, 100, 100, 50); // transparent cyan | |
94 | ||
95 | /** | |
96 | * Color for a solid fill. It's probably always going to be the same as | |
97 | * the line color, but we'll identify it separately for flexibility in the | |
98 | * future. | |
99 | */ | |
100 | static final Color SOLID_FILL_COLOR = !DEBUG ? LINE_COLOR : new Color( | |
101 | LINE_COLOR.getRed(), LINE_COLOR.getGreen(), LINE_COLOR.getBlue(), | |
102 | 75); // | |
103 | ||
104 | /** | |
105 | * Default color for filled figures. This is an interim measure before | |
106 | * moving to settable defaults. | |
107 | */ | |
108 | static final Color FILL_COLOR = !DEBUG ? Color.white | |
109 | : new Color(255, 255, 100, 100); // yellow | |
110 | ||
111 | /** | |
112 | * Color for a line which is supposed to blend into the fill. It's the same | |
113 | * color for right now, but we'll keep it separate so we can identify it | |
114 | * easily in the future. | |
115 | */ | |
116 | static final Color INVISIBLE_LINE_COLOR = !DEBUG ? FILL_COLOR : new Color( | |
117 | FILL_COLOR.getRed(), FILL_COLOR.getGreen(), FILL_COLOR.getBlue(), | |
118 | 50); | |
119 | ||
120 | ||
121 | /** | |
122 | * Default color for text. This is an interim measure before moving to | |
123 | * settable defaults. | |
124 | */ | |
125 | static final Color TEXT_COLOR = !DEBUG ? Color.black | |
126 | : new Color(0, 100, 0, 100); // translucent green | |
127 | ||
128 | /** | |
129 | * The color used for things which shouldn't normally be visible, so we can | |
130 | * spot them easily when they are. Completely transparent when we're not | |
131 | * debugging. Historically this was hardwired to either red or cyan. | |
132 | */ | |
133 | static final Color DEBUG_COLOR = new Color(255, 0, 255, !DEBUG ? 0 : 255); | |
134 | ||
135 | /** | |
136 | * Rerender the entire fig. | |
137 | * <p> | |
138 | * This may be an expensive operation for subclasses which are complex, | |
139 | * so should be used sparingly. It is only intended to be used when | |
140 | * some global change to the rendering defaults is made at the ArgoDiagram | |
141 | * level. | |
142 | */ | |
143 | public void renderingChanged(); | |
144 | ||
145 | /** | |
146 | * @return the rendering settings for the Fig | |
147 | */ | |
148 | public DiagramSettings getSettings(); | |
149 | ||
150 | /** | |
151 | * Set the rendering settings to be used for this fig. Currently this | |
152 | * normally will be a diagram-wide or project-wide settings object that is | |
153 | * shared by all Figs. | |
154 | * | |
155 | * @param settings the rendering settings to use | |
156 | */ | |
157 | public void setSettings(DiagramSettings settings); | |
158 | } |