Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java @ 1738:6cdc7a77d3d4
Apply theme attributes to axis annotation.
flys-artifacts/trunk@3028 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 19 Oct 2011 11:39:46 +0000 |
parents | f708120cb7bc |
children | 27b8836abec9 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java Wed Oct 19 11:00:13 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java Wed Oct 19 11:39:46 2011 +0000 @@ -4,9 +4,14 @@ import java.util.Iterator; +import org.w3c.dom.Document; + import java.awt.Shape; import java.awt.geom.Rectangle2D; import java.awt.geom.Line2D; +import java.awt.Color; +import java.awt.Font; +import java.awt.BasicStroke; import org.jfree.chart.annotations.XYTextAnnotation; import org.jfree.chart.axis.ValueAxis; @@ -25,6 +30,7 @@ import org.jfree.ui.RectangleEdge; import org.jfree.ui.TextAnchor; +import de.intevation.flys.utils.ThemeUtil; /** * Custom Annotations class that is drawn only if no collisions with other @@ -49,6 +55,12 @@ /** The 1-dimensional position of this annotation. */ protected float pos; + /** Theme attributes. */ + protected Color textColor; + protected Color lineColor; + protected Font font; + protected int lineWidth; + /** * Trivial constructor. @@ -277,12 +289,14 @@ } // Always draw the small line at axis. + setOutlineStroke(new BasicStroke((float) lineWidth)); g2.setStroke(getOutlineStroke()); - g2.setPaint(getPaint()); + g2.setPaint(lineColor); drawAxisMark(g2, dataArea, domainAxis, rangeAxis, domainEdge, rangeEdge, orientation); - g2.setFont(getFont()); + g2.setPaint(textColor); + g2.setFont(font); Shape hotspot = TextUtilities.calculateRotatedStringBounds( getText(), g2, anchorX, anchorY, getTextAnchor(), getRotationAngle(), getRotationAnchor()); @@ -306,7 +320,6 @@ g2.setPaint(getBackgroundPaint()); g2.fill(hotspot); } - g2.setPaint(getPaint()); TextUtilities.drawRotatedString(getText(), g2, anchorX, anchorY, getTextAnchor(), getRotationAngle(), getRotationAnchor()); // Draw outline. @@ -319,5 +332,13 @@ // Add info that we have drawn this Annotation. addEntity(info, hotspot, rendererIndex, getToolTipText(), getURL()); } + + + public void applyTheme(Document theme) { + lineWidth = ThemeUtil.parseLineWidth(theme); + lineColor = ThemeUtil.parseLineColorField(theme); + textColor = ThemeUtil.parseTextColor(theme); + font = ThemeUtil.parseTextFont(theme); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :