Hi Glen,
I dont know much about the AUTOMATIC colour (Ha! another Aussie with the
right spelling ;-) ) however with regards to the class vs instance issue, I
have the same problems as you suggest. There is no reason why they need to
be classes.
In fact i have attached a patch that does this, although it doesnt fix the
places where it breaks the existing code (except for the Workbook class). I
could create a patch that uses this new scheme if everyone agrees that this
approach is the best way to go.
I think that in the long run when the custom colours are decoded correctly,
the HSSFColor will need to change into something like this patch and provide
a constructor that allows a triplet (R,G,B value) to be passed in. Any
existing methods that return an index (short) to reference a colour whould
then need to return a HSSFColor directly.
I hope that makes sense.
Anyhow if people think that this patch is OK then i will make all of the
necessary example changes so that the code can be built.
Jason
PS Sorry about the size of this email. It is a large patch after all.
Index: jakarta-poi/src/java/org/apache/poi/hssf/model/Workbook.java
===
RCS file:
/home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/model/Workbook.java
,v
retrieving revision 1.13
diff -w -r1.13 Workbook.java
1482,1485c1482,1485
retval.setTopBorderPaletteIdx(HSSFColor.BLACK.index);
retval.setBottomBorderPaletteIdx(HSSFColor.BLACK.index);
retval.setLeftBorderPaletteIdx(HSSFColor.BLACK.index);
retval.setRightBorderPaletteIdx(HSSFColor.BLACK.index);
---
retval.setTopBorderPaletteIdx(HSSFColor.BLACK.getIndex());
retval.setBottomBorderPaletteIdx(HSSFColor.BLACK.getIndex());
retval.setLeftBorderPaletteIdx(HSSFColor.BLACK.getIndex());
retval.setRightBorderPaletteIdx(HSSFColor.BLACK.getIndex());
Index: jakarta-poi/src/java/org/apache/poi/hssf/util/HSSFColor.java
===
RCS file:
/home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/util/HSSFColor.java
,v
retrieving revision 1.5
diff -w -r1.5 HSSFColor.java
75a76,78
private short[] triplet;
private int index;
private String hexString;
77a81,83
public HSSFColor(short[] triplet) {
this(triplet, -1, );
}
79c85
public HSSFColor()
---
private HSSFColor(short[] triplet, int index, String hexString)
80a87,89
this.triplet = triplet;
this.index = index;
this.hexString = hexString;
97,145c106,154
hash.put(new Integer(HSSFColor.BLACK.index), new
HSSFColor.BLACK());
hash.put(new Integer(HSSFColor.BROWN.index), new
HSSFColor.BROWN());
hash.put(new Integer(HSSFColor.OLIVE_GREEN.index),
new HSSFColor.OLIVE_GREEN());
hash.put(new Integer(HSSFColor.DARK_GREEN.index), new
HSSFColor.DARK_GREEN());
hash.put(new Integer(HSSFColor.DARK_TEAL.index), new
HSSFColor.DARK_TEAL());
hash.put(new Integer(HSSFColor.DARK_BLUE.index), new
HSSFColor.DARK_BLUE());
hash.put(new Integer(HSSFColor.INDIGO.index), new
HSSFColor.INDIGO());
hash.put(new Integer(HSSFColor.GREY_80_PERCENT.index),
new HSSFColor.GREY_80_PERCENT());
hash.put(new Integer(HSSFColor.ORANGE.index), new
HSSFColor.ORANGE());
hash.put(new Integer(HSSFColor.DARK_YELLOW.index),
new HSSFColor.DARK_YELLOW());
hash.put(new Integer(HSSFColor.GREEN.index), new
HSSFColor.GREEN());
hash.put(new Integer(HSSFColor.TEAL.index), new HSSFColor.TEAL());
hash.put(new Integer(HSSFColor.BLUE.index), new HSSFColor.BLUE());
hash.put(new Integer(HSSFColor.BLUE_GREY.index), new
HSSFColor.BLUE_GREY());
hash.put(new Integer(HSSFColor.GREY_50_PERCENT.index),
new HSSFColor.GREY_50_PERCENT());
hash.put(new Integer(HSSFColor.RED.index), new HSSFColor.RED());
hash.put(new Integer(HSSFColor.LIGHT_ORANGE.index),
new HSSFColor.LIGHT_ORANGE());
hash.put(new Integer(HSSFColor.LIME.index), new HSSFColor.LIME());
hash.put(new Integer(HSSFColor.SEA_GREEN.index), new
HSSFColor.SEA_GREEN());
hash.put(new Integer(HSSFColor.AQUA.index), new HSSFColor.AQUA());
hash.put(new Integer(HSSFColor.LIGHT_BLUE.index), new
HSSFColor.LIGHT_BLUE());
hash.put(new Integer(HSSFColor.VIOLET.index), new
HSSFColor.VIOLET());
hash.put(new Integer(HSSFColor.GREY_40_PERCENT.index),
new HSSFColor.GREY_40_PERCENT());
hash.put(new Integer(HSSFColor.PINK.index), new HSSFColor.PINK());
hash.put(new Integer(HSSFColor.GOLD.index), new HSSFColor.GOLD());
hash.put(new Integer(HSSFColor.YELLOW.index), new
HSSFColor.YELLOW());
hash.put(new Integer(HSSFColor.BRIGHT_GREEN.index),
new HSSFColor.BRIGHT_GREEN());