# HG changeset patch # User Raimund Renkert # Date 1319185305 0 # Node ID 27b8836abec98965ec3a950db57d4d0613b4b88d # Parent 415ec0223dff55e6d49785dd82bbdff180d457d8 Draw the text background and use orientation attribute. flys-artifacts/trunk@3053 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 415ec0223dff -r 27b8836abec9 flys-artifacts/ChangeLog --- 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 + + * src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java: + Draw the text background and use orientation attribute. + 2011-10-21 Raimund Renkert * doc/conf/themes.xml: diff -r 415ec0223dff -r 27b8836abec9 flys-artifacts/src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java --- 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 :