Mercurial > dive4elements > river
changeset 1751:27b8836abec9
Draw the text background and use orientation attribute.
flys-artifacts/trunk@3053 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 21 Oct 2011 08:21:45 +0000 |
parents | 415ec0223dff |
children | b7b424ae32a8 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java |
diffstat | 2 files changed, 40 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Oct 21 08:19:26 2011 +0000 +++ b/flys-artifacts/ChangeLog Fri Oct 21 08:21:45 2011 +0000 @@ -1,3 +1,8 @@ +2011-10-21 Raimund Renkert <raimund.renkert@intevation.de> + + * src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java: + Draw the text background and use orientation attribute. + 2011-10-21 Raimund Renkert <raimund.renkert@intevation.de> * doc/conf/themes.xml:
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java Fri Oct 21 08:19:26 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java Fri Oct 21 08:21:45 2011 +0000 @@ -60,6 +60,9 @@ protected Color lineColor; protected Font font; protected int lineWidth; + protected String textOrientation = "vertical"; + protected Color textBackground; + protected boolean showBackground; /** @@ -119,8 +122,13 @@ */ public void setStickyAxis(SimpleAxis stickyAxis) { this.stickyAxis = stickyAxis; - if (stickyAxis == SimpleAxis.X_AXIS) { - this.setRotationAngle(270f * (Math.PI / 180f)); + if (stickyAxis == SimpleAxis.X_AXIS){ + float o = 270f; + if(textOrientation.equals("horizontal")) { + o = 0f; + } + logger.debug("orientation: " + o); + this.setRotationAngle(o * (Math.PI / 180f)); this.setRotationAnchor(TextAnchor.CENTER_LEFT); this.setTextAnchor(TextAnchor.CENTER_LEFT); } else { @@ -288,15 +296,9 @@ anchorY = tempAnchor; } - // Always draw the small line at axis. - setOutlineStroke(new BasicStroke((float) lineWidth)); - g2.setStroke(getOutlineStroke()); - g2.setPaint(lineColor); - drawAxisMark(g2, dataArea, domainAxis, rangeAxis, domainEdge, - rangeEdge, orientation); + //Call to apply orientation. + setStickyAxis(stickyAxis); - g2.setPaint(textColor); - g2.setFont(font); Shape hotspot = TextUtilities.calculateRotatedStringBounds( getText(), g2, anchorX, anchorY, getTextAnchor(), getRotationAngle(), getRotationAnchor()); @@ -315,19 +317,30 @@ } } - // Actuall drawing. - if (getBackgroundPaint() != null) { - g2.setPaint(getBackgroundPaint()); + // Draw the background. + if (showBackground) { + g2.setStroke(new BasicStroke ((float) 1)); + g2.setBackground(textBackground); + g2.setPaint(textBackground); + hotspot = TextUtilities.calculateRotatedStringBounds( + getText(), g2, anchorX, anchorY, getTextAnchor(), + getRotationAngle(), getRotationAnchor()); g2.fill(hotspot); + g2.draw(hotspot); } + + // Always draw the small line at axis. + setOutlineStroke(new BasicStroke((float) lineWidth)); + g2.setStroke(getOutlineStroke()); + g2.setPaint(lineColor); + drawAxisMark(g2, dataArea, domainAxis, rangeAxis, domainEdge, + rangeEdge, orientation); + + // Draw the text. + g2.setPaint(textColor); + g2.setFont(font); TextUtilities.drawRotatedString(getText(), g2, anchorX, anchorY, getTextAnchor(), getRotationAngle(), getRotationAnchor()); - // Draw outline. - if (false) { - g2.setStroke(getOutlineStroke()); - g2.setPaint(getOutlinePaint()); - g2.draw(hotspot); - } // Add info that we have drawn this Annotation. addEntity(info, hotspot, rendererIndex, getToolTipText(), getURL()); @@ -339,6 +352,9 @@ lineColor = ThemeUtil.parseLineColorField(theme); textColor = ThemeUtil.parseTextColor(theme); font = ThemeUtil.parseTextFont(theme); + textOrientation = ThemeUtil.parseTextOrientation(theme); + textBackground = ThemeUtil.parseTextBackground(theme); + showBackground = ThemeUtil.parseShowTextBackground(theme); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :