Mercurial > projects > dwt-addons
annotate dwtx/draw2d/SchemeBorder.d @ 192:c3583c6ec027
Added missing default cases for switch statements
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 03 Nov 2008 22:52:26 +0100 |
parents | 2d6540440fe6 |
children |
rev | line source |
---|---|
98
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1 /******************************************************************************* |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2 * Copyright (c) 2000, 2005 IBM Corporation and others. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3 * All rights reserved. This program and the accompanying materials |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
5 * which accompanies this distribution, and is available at |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
6 * http://www.eclipse.org/legal/epl-v10.html |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
7 * |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
8 * Contributors: |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
9 * IBM Corporation - initial API and implementation |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
10 * Port to the D programming language: |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
11 * Frank Benoit <benoit@tionex.de> |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
12 *******************************************************************************/ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
13 module dwtx.draw2d.SchemeBorder; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
14 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
15 import dwt.dwthelper.utils; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
16 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
17 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
18 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
19 import dwt.graphics.Color; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
20 import dwtx.draw2d.geometry.Insets; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
21 import dwtx.draw2d.geometry.Rectangle; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
22 import dwtx.draw2d.IFigure; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
23 import dwtx.draw2d.Border; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
24 import dwtx.draw2d.Graphics; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
25 import dwtx.draw2d.AbstractBorder; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
26 import dwtx.draw2d.ColorConstants; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
27 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
28 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
29 * SchemeBorder allows the creation of borders based on |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
30 * {@link SchemeBorder.Scheme Schemes}. A <i>Scheme</i> is a class whose only purpose is |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
31 * to carry border specific information. SchemeBorder renders the border based on the |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
32 * information given by the <i>Scheme</i> set to it. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
33 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
34 public class SchemeBorder |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
35 : AbstractBorder |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
36 //, ColorConstants |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
37 { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
38 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
39 /** The {@link SchemeBorder.Scheme} associated with this SchemeBorder **/ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
40 protected Scheme scheme = null; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
41 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
42 /** Arrays of Colors, used for shadow or highlight effects **/ |
103
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
43 private static bool initStaticConsts_done = false; |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
44 private static Color[] |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
45 DARKEST_DARKER_, |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
46 LIGHTER_DARKER_, |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
47 DARKER_LIGHTER_; |
98
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
48 |
103
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
49 protected static Color[] DARKEST_DARKER(){ |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
50 if( !initStaticConsts_done ) initStaticConsts(); |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
51 return DARKEST_DARKER_; |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
52 } |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
53 protected static Color[] LIGHTER_DARKER(){ |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
54 if( !initStaticConsts_done ) initStaticConsts(); |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
55 return LIGHTER_DARKER_; |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
56 } |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
57 protected static Color[] DARKER_LIGHTER(){ |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
58 if( !initStaticConsts_done ) initStaticConsts(); |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
59 return DARKER_LIGHTER_; |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
60 } |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
61 |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
62 |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
63 static void initStaticConsts(){ |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
64 synchronized( SchemeBorder.classinfo ){ |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
65 if( !initStaticConsts_done ) { |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
66 DARKEST_DARKER_ = [ColorConstants.buttonDarkest, ColorConstants.buttonDarker]; |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
67 LIGHTER_DARKER_ = [ColorConstants.buttonLightest, ColorConstants.buttonDarker]; |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
68 DARKER_LIGHTER_ = [ColorConstants.buttonDarker, ColorConstants.buttonLightest]; |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
69 initStaticConsts_done = true; |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
70 } |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
71 } |
98
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
72 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
73 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
74 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
75 * Holds a set of information about a border, which can be changed to create a wide range |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
76 * of schemes. Provides support for border opacity, size, highlight side and shadow side |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
77 * colors. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
78 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
79 public static class Scheme { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
80 private Insets insets; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
81 private bool isOpaque_ = false; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
82 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
83 /** Arrays of Colors, used for highlight and shadow effecsts */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
84 protected Color[] |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
85 highlight, |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
86 shadow; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
87 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
88 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
89 * Constructs a default border Scheme with no border sides. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
90 * @since 2.0 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
91 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
92 protected this() { } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
93 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
94 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
95 * Constructs a border Scheme with the specified highlight and shadow colors. The size |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
96 * of the border depends on the number of colors passed in for each parameter. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
97 * Hightlight colors are used in the top and left sides of the border, and Shadow |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
98 * colors are used in the bottom and right sides of the border. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
99 * |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
100 * @param highlight the hightlight colors |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
101 * @param shadow the shadow colors |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
102 * @since 2.0 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
103 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
104 public this(Color[] highlight, Color[] shadow) { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
105 this.highlight = highlight; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
106 this.shadow = shadow; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
107 init(); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
108 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
109 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
110 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
111 * Constructs a border scheme with the specified colors. The input colors serve as |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
112 * both highlight and shadow colors. The size of the border is the number of colors |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
113 * passed in as input. Hightlight colors are used in the top and left sides of the |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
114 * border, and Shadow colors are used in the bottom and right sides of the border. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
115 * |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
116 * @param colors the colors to be used for the border |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
117 * @since 2.0 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
118 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
119 public this(Color[] colors) { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
120 highlight = shadow = colors; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
121 init(); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
122 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
123 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
124 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
125 * Calculates and returns the Insets for this border Scheme. The calculations depend |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
126 * on the number of colors passed in as input. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
127 * |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
128 * @return the Insets used by this border |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
129 * @since 2.0 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
130 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
131 protected Insets calculateInsets() { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
132 int tl = getHighlight().length; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
133 int br = getShadow().length; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
134 return new Insets(tl, tl, br, br); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
135 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
136 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
137 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
138 * Calculates and retuns the opaque state of this border scheme. Returns |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
139 * <code>false</code> if any of the border colors are <code>null</code>. This is done |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
140 * to prevent the appearance of underlying pixels since the border color is |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
141 * <code>null</code>. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
142 * |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
143 * @return <code>true</code> if this border is opaque |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
144 * @since 2.0 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
145 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
146 protected bool calculateOpaque() { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
147 Color colors [] = getHighlight(); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
148 for (int i = 0; i < colors.length; i++) |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
149 if (colors[i] is null) |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
150 return false; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
151 colors = getShadow(); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
152 for (int i = 0; i < colors.length; i++) |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
153 if (colors[i] is null) |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
154 return false; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
155 return true; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
156 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
157 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
158 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
159 * Returns the highlight colors of this border scheme as an array of Colors. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
160 * |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
161 * @return the highlight colors |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
162 * @since 2.0 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
163 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
164 protected Color[] getHighlight() { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
165 return highlight; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
166 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
167 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
168 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
169 * Returns the Insets required by this Scheme. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
170 * |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
171 * @return the Insets |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
172 * @since 2.0 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
173 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
174 protected Insets getInsets() { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
175 return insets; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
176 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
177 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
178 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
179 * Returns the shadow colors of this border scheme as an array of Colors. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
180 * |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
181 * @return the shadow colors |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
182 * @since 2.0 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
183 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
184 protected Color[] getShadow() { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
185 return shadow; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
186 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
187 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
188 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
189 * Calculates and initializes the properties of this border scheme. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
190 * |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
191 * @since 2.0 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
192 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
193 protected void init() { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
194 insets = calculateInsets(); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
195 isOpaque_ = calculateOpaque(); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
196 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
197 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
198 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
199 * Returns whether this border should be opaque or not. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
200 * |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
201 * @return <code>true</code> if this border is opaque |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
202 * @since 2.0 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
203 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
204 protected bool isOpaque() { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
205 return isOpaque_; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
206 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
207 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
208 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
209 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
210 * Interface which defines some commonly used schemes for the border. These schemes can be |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
211 * given as input to the {@link SchemeBorder SchemeBorder} to generate appropriate borders. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
212 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
213 public struct SCHEMES { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
214 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
215 /** Schemes used for shadow and highlight effects **/ |
103
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
216 private static bool initStaticConsts_done = false; |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
217 private static Scheme |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
218 BUTTON_CONTRAST_, |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
219 BUTTON_RAISED_, |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
220 BUTTON_PRESSED_, |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
221 RAISED_, |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
222 LOWERED_, |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
223 RIDGED_, |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
224 ETCHED_; |
98
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
225 |
103
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
226 public static Scheme BUTTON_CONTRAST(){ |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
227 if( !initStaticConsts_done ) initStaticConsts(); |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
228 return BUTTON_CONTRAST_; |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
229 } |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
230 public static Scheme BUTTON_RAISED(){ |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
231 if( !initStaticConsts_done ) initStaticConsts(); |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
232 return BUTTON_RAISED_; |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
233 } |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
234 public static Scheme BUTTON_PRESSED(){ |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
235 if( !initStaticConsts_done ) initStaticConsts(); |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
236 return BUTTON_PRESSED_; |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
237 } |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
238 public static Scheme RAISED(){ |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
239 if( !initStaticConsts_done ) initStaticConsts(); |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
240 return RAISED_; |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
241 } |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
242 public static Scheme LOWERED(){ |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
243 if( !initStaticConsts_done ) initStaticConsts(); |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
244 return LOWERED_; |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
245 } |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
246 public static Scheme RIDGED(){ |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
247 if( !initStaticConsts_done ) initStaticConsts(); |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
248 return RIDGED_; |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
249 } |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
250 public static Scheme ETCHED(){ |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
251 if( !initStaticConsts_done ) initStaticConsts(); |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
252 return ETCHED_; |
98
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
253 } |
103
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
254 |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
255 |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
256 static void initStaticConsts(){ |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
257 synchronized( SchemeBorder.classinfo ){ |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
258 if( !initStaticConsts_done ) { |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
259 BUTTON_CONTRAST_ = new Scheme( |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
260 [ColorConstants.button, ColorConstants.buttonLightest], |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
261 DARKEST_DARKER |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
262 ); |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
263 BUTTON_RAISED_ = new Scheme( |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
264 [ColorConstants.buttonLightest], |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
265 DARKEST_DARKER |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
266 ); |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
267 BUTTON_PRESSED_ = new Scheme( |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
268 DARKEST_DARKER, |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
269 [ColorConstants.buttonLightest] |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
270 ); |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
271 RAISED_ = new Scheme( |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
272 [ColorConstants.buttonLightest], |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
273 [ColorConstants.buttonDarkest] |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
274 ); |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
275 LOWERED_ = new Scheme( |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
276 [ColorConstants.buttonDarkest], |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
277 [ColorConstants.buttonLightest] |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
278 ); |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
279 RIDGED_ = new Scheme(LIGHTER_DARKER, DARKER_LIGHTER); |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
280 ETCHED_ = new Scheme(DARKER_LIGHTER, LIGHTER_DARKER); |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
281 initStaticConsts_done = true; |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
282 } |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
283 } |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
284 } |
2d6540440fe6
Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents:
98
diff
changeset
|
285 |
98
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
286 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
287 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
288 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
289 * Constructs a default SchemeBorder with no scheme defined. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
290 * @since 2.0 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
291 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
292 protected this() { } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
293 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
294 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
295 * Constructs a SchemeBorder with the Scheme given as input. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
296 * |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
297 * @param scheme the Scheme to be used by this border |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
298 * @since 2.0 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
299 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
300 public this(Scheme scheme) { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
301 setScheme(scheme); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
302 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
303 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
304 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
305 * @see Border#getInsets(IFigure) |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
306 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
307 public Insets getInsets(IFigure figure) { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
308 return getScheme().getInsets(); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
309 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
310 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
311 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
312 * Returns the scheme used by this border. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
313 * |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
314 * @return the Scheme used by this border |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
315 * @since 2.0 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
316 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
317 protected Scheme getScheme() { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
318 return scheme; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
319 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
320 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
321 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
322 * Returns the opaque state of this border. Returns <code>true</code> indicating that this |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
323 * will fill in the area enclosed by the border. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
324 * |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
325 * @see Border#isOpaque() |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
326 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
327 public bool isOpaque() { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
328 return true; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
329 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
330 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
331 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
332 * Sets the Scheme for this border to the Scheme given as input. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
333 * |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
334 * @param scheme the Scheme for this border |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
335 * @since 2.0 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
336 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
337 protected void setScheme(Scheme scheme) { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
338 this.scheme = scheme; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
339 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
340 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
341 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
342 * @see Border#paint(IFigure, Graphics, Insets) |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
343 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
344 public void paint(IFigure figure, Graphics g, Insets insets) { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
345 Color [] tl = scheme.getHighlight(); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
346 Color [] br = scheme.getShadow(); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
347 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
348 paint (g, figure, insets, tl, br); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
349 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
350 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
351 /** |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
352 * Paints the border using the information in the set Scheme and the inputs given. Side |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
353 * widths are determined by the number of colors in the Scheme for each side. |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
354 * |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
355 * @param graphics the graphics object |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
356 * @param fig the figure this border belongs to |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
357 * @param insets the insets |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
358 * @param tl the highlight (top/left) colors |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
359 * @param br the shadow (bottom/right) colors |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
360 */ |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
361 protected void paint(Graphics graphics, IFigure fig, |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
362 Insets insets, Color[] tl, Color[] br) { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
363 graphics.setLineWidth(1); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
364 graphics.setLineStyle(Graphics.LINE_SOLID); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
365 graphics.setXORMode(false); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
366 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
367 Rectangle rect = getPaintRectangle(fig, insets); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
368 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
369 int top = rect.y; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
370 int left = rect.x; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
371 int bottom = rect.bottom() - 1; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
372 int right = rect.right() - 1; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
373 Color color; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
374 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
375 for (int i = 0; i < br.length; i++) { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
376 color = br[i]; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
377 graphics.setForegroundColor(color); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
378 graphics.drawLine(right - i, bottom - i, right - i, top + i); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
379 graphics.drawLine(right - i, bottom - i, left + i, bottom - i); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
380 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
381 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
382 right--; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
383 bottom--; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
384 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
385 for (int i = 0; i < tl.length; i++) { |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
386 color = tl[i]; |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
387 graphics.setForegroundColor(color); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
388 graphics.drawLine(left + i, top + i, right - i, top + i); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
389 graphics.drawLine(left + i, top + i, left + i, bottom - i); |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
390 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
391 } |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
392 |
95307ad235d9
Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
393 } |