String texturePaintKey = "fill" + fillPaintString + fillPatternString;
if (fillPaintString == null) {
fillPaint = Color.black;
TexturePaint ret = (TexturePaint) renderAttributesCache.get("fill" + fillPaint + fillPatternString);
if (ret != null) {
return ret;
} else {
ret = (TexturePaint) renderAttributesCache.get(texturePaintKey);
if (ret != null) {
return ret;
}
}
}
BufferedImage bi = new BufferedImage(8, 8, BufferedImage.TYPE_INT_ARGB);
Graphics2D big = bi.createGraphics();
big.setColor(new Color(0, true)); // clear
big.fillRect(0, 0, 8, 8);
big.setPaint(fillPaint);
if (fillPatternString.equalsIgnoreCase(LPC_HORIZONTAL_PATTERN)) {
big.draw(new Line2D.Double(0, 0, 7, 0));
big.draw(new Line2D.Double(0, 4, 7, 4));
} else if (fillPatternString.equalsIgnoreCase(LPC_VERTICAL_PATTERN)) {
big.draw(new Line2D.Double(0, 0, 0, 7));
big.draw(new Line2D.Double(4, 0, 4, 7));
} else if (fillPatternString.equalsIgnoreCase(LPC_CROSS_PATTERN)) {
big.draw(new Line2D.Double(0, 0, 7, 0));
big.draw(new Line2D.Double(0, 4, 7, 4));
big.draw(new Line2D.Double(0, 0, 0, 7));
big.draw(new Line2D.Double(4, 0, 4, 7));
} else if (fillPatternString.equalsIgnoreCase(LPC_DIAG_CROSS_PATTERN)) {
big.draw(new Line2D.Double(0, 0, 7, 7));
big.draw(new Line2D.Double(0, 4, 3, 7));
big.draw(new Line2D.Double(4, 0, 7, 3));
big.draw(new Line2D.Double(0, 7, 7, 0));
big.draw(new Line2D.Double(0, 3, 3, 0));
big.draw(new Line2D.Double(4, 7, 7, 4));
} else if (fillPatternString.equalsIgnoreCase(LPC_BACKWARD_DIAG_PATTERN)) {
big.draw(new Line2D.Double(0, 0, 7, 7));
big.draw(new Line2D.Double(0, 4, 3, 7));
big.draw(new Line2D.Double(4, 0, 7, 3));
} else if (fillPatternString.equalsIgnoreCase(LPC_FORWARD_DIAG_PATTERN)) {
big.draw(new Line2D.Double(0, 7, 7, 0));
big.draw(new Line2D.Double(0, 3, 3, 0));
big.draw(new Line2D.Double(4, 7, 7, 4));
} else {
// default to solid
big.fillRect(0, 0, 8, 8);
}
Rectangle r = new Rectangle(0, 0, 8, 8);
TexturePaint texturePaint = new TexturePaint(bi, r);
renderAttributesCache.put(texturePaintKey, texturePaint);
return texturePaint;
}
}