Revision: 7651
Author: victormote
Date: 2006-06-16 11:37:46 -0700 (Fri, 16 Jun 2006)
ViewCVS: http://svn.sourceforge.net/foray/?rev=7651&view=rev
Log Message:
-----------
Fix ugly static initialization problem.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtColor.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtColor.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtColor.java 2006-06-16 17:36:25 UTC (rev 7650)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtColor.java 2006-06-16 18:37:46 UTC (rev 7651)
@@ -242,7 +242,7 @@
* TODO: Sort this by the numeric color value stored in the java.awt.Color
* so that a binary search can be used.
*/
- private static ArrayList colorsUsed = new ArrayList(20);
+ private static ArrayList colorsUsed;
private Color value;
@@ -311,8 +311,8 @@
* if it has not yet been created.
*/
private static DtColor findColor(Color color) {
- for (int i = 0; i < DtColor.colorsUsed.size(); i++) {
- DtColor usedColor = (DtColor) DtColor.colorsUsed.get(i);
+ for (int i = 0; i < DtColor.getColorsUsed().size(); i++) {
+ DtColor usedColor = (DtColor) DtColor.getColorsUsed().get(i);
if (usedColor.value.equals(color)) {
return usedColor;
}
@@ -332,8 +332,8 @@
*/
private static DtColor findColor(float red, float green, float blue,
float alpha) {
- for (int i = 0; i < DtColor.colorsUsed.size(); i++) {
- DtColor usedColor = (DtColor) DtColor.colorsUsed.get(i);
+ for (int i = 0; i < DtColor.getColorsUsed().size(); i++) {
+ DtColor usedColor = (DtColor) DtColor.getColorsUsed().get(i);
Color colorValue = usedColor.value;
float[] components = colorValue.getRGBComponents(null);
if (components == null
@@ -350,6 +350,14 @@
return null;
}
+ private static ArrayList getColorsUsed() {
+ if (DtColor.colorsUsed == null) {
+ /* For some reason, this won't initialize when declared. */
+ DtColor.colorsUsed = new ArrayList(20);
+ }
+ return DtColor.colorsUsed;
+ }
+
public static DtColor mapNameToColorRGB(String colorName) {
// Do a binary search to find the name in the names list.
int index = Arrays.binarySearch(names, colorName);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|