comparison flys-artifacts/src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java @ 1759:c51089a84d13

Restored correct drawing behavior for Annotations. flys-artifacts/trunk@3072 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 25 Oct 2011 12:43:58 +0000
parents 8e6615ad60b8
children 59622ba800c8
comparison
equal deleted inserted replaced
1758:1d78039a36e6 1759:c51089a84d13
30 30
31 import de.intevation.flys.utils.ThemeAccess; 31 import de.intevation.flys.utils.ThemeAccess;
32 32
33 /** 33 /**
34 * Custom Annotations class that is drawn only if no collisions with other 34 * Custom Annotations class that is drawn only if no collisions with other
35 * already drawn CustomAnnotations in current plot are found. 35 * already drawn CustomAnnotations in current plot are found. A mark on
36 * the axis is shown in all cases, though.
36 * Draws a given text and a line to it from either axis. 37 * Draws a given text and a line to it from either axis.
37 */ 38 */
38 public class StickyAxisAnnotation extends XYTextAnnotation { 39 public class StickyAxisAnnotation extends XYTextAnnotation {
39 40
40 /** Logger for this class. */ 41 /** Logger for this class. */
214 215
215 // line is clipped to avoid JRE bug 6574155, for more info 216 // line is clipped to avoid JRE bug 6574155, for more info
216 // see JFreeChart bug 2221495 217 // see JFreeChart bug 2221495
217 boolean visible = LineUtilities.clipLine(line, dataArea); 218 boolean visible = LineUtilities.clipLine(line, dataArea);
218 if (visible) { 219 if (visible) {
220 setOutlineStroke(new BasicStroke((float) lineWidth));
221 g2.setStroke(getOutlineStroke());
222 g2.setPaint(lineColor);
219 g2.draw(line); 223 g2.draw(line);
220 } 224 }
221 } 225 }
222 226
223 227
293 anchorY = tempAnchor; 297 anchorY = tempAnchor;
294 } 298 }
295 299
296 //Call to apply orientation. 300 //Call to apply orientation.
297 setStickyAxis(stickyAxis); 301 setStickyAxis(stickyAxis);
302
303 // Always draw the small line at axis.
304 drawAxisMark(g2, dataArea, domainAxis, rangeAxis, domainEdge,
305 rangeEdge, orientation);
298 306
299 Shape hotspot = TextUtilities.calculateRotatedStringBounds( 307 Shape hotspot = TextUtilities.calculateRotatedStringBounds(
300 getText(), g2, anchorX, anchorY, getTextAnchor(), 308 getText(), g2, anchorX, anchorY, getTextAnchor(),
301 getRotationAngle(), getRotationAnchor()); 309 getRotationAngle(), getRotationAnchor());
302 Rectangle2D hotspotBox = hotspot.getBounds2D(); 310 Rectangle2D hotspotBox = hotspot.getBounds2D();
324 getRotationAngle(), getRotationAnchor()); 332 getRotationAngle(), getRotationAnchor());
325 g2.fill(hotspot); 333 g2.fill(hotspot);
326 g2.draw(hotspot); 334 g2.draw(hotspot);
327 } 335 }
328 336
329 // Always draw the small line at axis.
330 setOutlineStroke(new BasicStroke((float) lineWidth));
331 g2.setStroke(getOutlineStroke());
332 g2.setPaint(lineColor);
333 drawAxisMark(g2, dataArea, domainAxis, rangeAxis, domainEdge,
334 rangeEdge, orientation);
335
336 // Draw the text. 337 // Draw the text.
337 g2.setPaint(textColor); 338 g2.setPaint(textColor);
338 g2.setFont(font); 339 g2.setFont(font);
339 TextUtilities.drawRotatedString(getText(), g2, anchorX, anchorY, 340 TextUtilities.drawRotatedString(getText(), g2, anchorX, anchorY,
340 getTextAnchor(), getRotationAngle(), getRotationAnchor()); 341 getTextAnchor(), getRotationAngle(), getRotationAnchor());

http://dive4elements.wald.intevation.org