Revision: 7647
Author: victormote
Date: 2006-06-16 08:49:09 -0700 (Fri, 16 Jun 2006)
ViewCVS: http://svn.sourceforge.net/foray/?rev=7647&view=rev
Log Message:
-----------
Make DtColor constructor private, and use static factory methods instead. We will eventually try to prevent creation of duplicate Color and DtColor instances.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Border.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Color.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyParser.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtColor.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Border.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Border.java 2006-06-16 15:23:58 UTC (rev 7646)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Border.java 2006-06-16 15:49:09 UTC (rev 7647)
@@ -114,7 +114,7 @@
Color color = DtColor.mapNameToColorRGB(token);
if (color != null) {
return new BorderColor(Constants.FOPROP_BORDER_COLOR,
- new DtColor(color));
+ DtColor.makeColorDT(color));
}
// Now try using the standard parse
PropertyValue pv = standardParse(propertyList, token, false, false);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Color.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Color.java 2006-06-16 15:23:58 UTC (rev 7646)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Color.java 2006-06-16 15:49:09 UTC (rev 7647)
@@ -62,7 +62,7 @@
String value) throws PropertyException {
java.awt.Color color = DtColor.mapNameToColorRGB(value);
if (color != null) {
- return new DtColor(color);
+ return DtColor.makeColorDT(color);
}
PropertyValue pv = checkKeywords(value);
if (pv != null) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyParser.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyParser.java 2006-06-16 15:23:58 UTC (rev 7646)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyParser.java 2006-06-16 15:49:09 UTC (rev 7647)
@@ -243,7 +243,7 @@
} catch (PropertyException e) {
throw new PropertyException(e.getMessage());
}
- prop = new DtColor(color);
+ prop = DtColor.makeColorDT(color);
break;
case TOK_FUNCTION_LPAR: {
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 15:23:58 UTC (rev 7646)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtColor.java 2006-06-16 15:49:09 UTC (rev 7647)
@@ -353,10 +353,10 @@
private Color value;
/**
- * Constructor.
- * @param color The Color instance that is the value for this property.
+ * Private Constructor. Use one of the following static methods instead:
+ * {@link #makeColorDT(String)}.
*/
- public DtColor(Color color) {
+ private DtColor(Color color) {
this.value = color;
}
@@ -372,13 +372,14 @@
}
/**
- * Factory method which converts a String input into a ColorDT instance.
- * @param input The String to be converted into a ColorDT instance.
+ * Factory method which converts a named color into a ColorDT instance.
+ * @param input The named color (for example, "blue" or "teal") to be
+ * converted.
* @return A ColorDT instance, or null if input is not valid.
*/
public static DtColor makeColorDT(String input) {
/*
- * Look for named colors first. Note: This scheme is not strictly
+ * Note: This scheme is not strictly
* conformant to the XSL-FO 1.0 Standard, which lists only 16 named
* colors, the same that are in CSS. The list used in our search has
* many more than that. Not sure whether this is a bonus or a problem
@@ -391,6 +392,10 @@
return null;
}
+ public static DtColor makeColorDT(Color color) {
+ return new DtColor(color);
+ }
+
public static Color 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.
|