Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java @ 2792:fe987587ebc9
Merged revisions 4539-4540,4543,4545-4546 via svnmerge from
file:///home/clients/bsh/bsh-generischer-viewer/Material/SVN/flys-artifacts/trunk
........
r4539 | teichmann | 2012-05-27 20:02:13 +0200 (So, 27 Mai 2012) | 1 line
FixA: Added forgotten csv/report facets/generators to conf.
........
r4540 | teichmann | 2012-05-27 20:11:31 +0200 (So, 27 Mai 2012) | 1 line
FixA: Fixed class cast bug in report facet.
........
r4543 | teichmann | 2012-05-28 20:35:01 +0200 (Mo, 28 Mai 2012) | 1 line
FixA: Added facet to return delta w/t as CSV
........
r4545 | teichmann | 2012-05-28 22:59:27 +0200 (Mo, 28 Mai 2012) | 1 line
FixA: Made Delta W/t calculation finally work
........
r4546 | teichmann | 2012-05-28 23:34:24 +0200 (Mo, 28 Mai 2012) | 1 line
FixA: corrected fitting (Q->W instead W->Q).
........
flys-artifacts/tags/2.7@4547 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 29 May 2012 04:58:29 +0000 |
parents | 5016609663e2 |
children | 703be13ffa74 |
line wrap: on
line source
package de.intevation.flys.jfree; import org.apache.log4j.Logger; /** * Custom Annotations class that is drawn only if no collisions with other * already drawn CustomAnnotations in current plot are found. A mark on * the axis is shown in all cases, though. * Draws a given text and a line to it from either axis. */ public class StickyAxisAnnotation { /** Logger for this class. */ private static Logger logger = Logger.getLogger(StickyAxisAnnotation.class); /** Simplified view on axes. */ public static enum SimpleAxis { X_AXIS, /** Usually "horizontal". */ Y_AXIS /** Usually "vertical". */ } /** The "symbolic" integer representing which axis to stick to. */ protected int axisSymbol; /** Which axis to stick to. */ protected SimpleAxis stickyAxis = SimpleAxis.X_AXIS; /** The 1-dimensional position of this annotation. */ protected float pos; /** * Optional field used when from axis a line should be drawn that * hits a curve or something similar (current scenario: duration curves). * This value is in the "other" dimension than the pos - field. */ protected float hitPoint; /** The text to display at axis. */ String text; /** * Constructor with implicit sticky x-axis. * @param text the text to display. * @param pos the position at which to draw the text and mark. */ public StickyAxisAnnotation(String text, float pos) { this(text, pos, SimpleAxis.X_AXIS); } /** * Constructor with given explicit axis. * @param text the text to display. * @param pos the position at which to draw the text and mark. * @param stickyAxis the axis at which to stick (and to which 'pos' is * relative). * @param lineTo upto where to draw a line (NaN for none). */ public StickyAxisAnnotation(String text, float pos, SimpleAxis stickAxis ) { this(text, pos, stickAxis, 0); } public StickyAxisAnnotation(String text, float pos, SimpleAxis stickAxis, int axisSymbol ) { setStickyAxis(stickAxis); this.text = text; this.pos = pos; this.axisSymbol = axisSymbol; this.hitPoint = Float.NaN; } /** * Sets the "sticky axis" (whether to draw annotations at the * X- or the Y-Axis. * * @param stickyAxis axis to stick to. */ public void setStickyAxis(SimpleAxis stickyAxis) { this.stickyAxis = stickyAxis; } public float getPos() { return this.pos; } public SimpleAxis getStickyAxis() { return this.stickyAxis; } public boolean atX() { return this.getStickyAxis() == SimpleAxis.X_AXIS; } /** Get text to be displayed at axis. */ public String getText() { return this.text; } public int getAxisSymbol() { return this.axisSymbol; } /** Set where to hit a curve (if any). */ public void setHitPoint(float pos) { this.hitPoint = pos; } /** Get where to hit a curve (if any). */ public float getHitPoint() { return this.hitPoint; } /** Set sticky axis to the X axis if it is currently Y, and vice versa. */ public void flipStickyAxis() { if (this.getStickyAxis() == SimpleAxis.X_AXIS) { this.setStickyAxis(SimpleAxis.Y_AXIS); } else { this.setStickyAxis(SimpleAxis.X_AXIS); } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :