From: <mu...@us...> - 2013-12-06 08:37:59
|
Revision: 3071 http://sourceforge.net/p/jfreechart/code/3071 Author: mungady Date: 2013-12-06 08:37:55 +0000 (Fri, 06 Dec 2013) Log Message: ----------- 2013-12-05 David Gilbert <dav...@ob...> Patch from Lukasz Rzeszotarski: * org/jfree/chart/renderer/xy/XYStepAreaRenderer.java (stepPoint): New field, (XYStepAreaRenderer): Initialise stepPoint; (getStepPoint): New method, (setStepPoint): Likewise, (drawItem): Calculate step point, (equals): Add check for stepPoint attribute. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java 2013-11-27 03:26:01 UTC (rev 3070) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java 2013-12-06 08:37:55 UTC (rev 3071) @@ -27,10 +27,11 @@ * ----------------------- * XYStepAreaRenderer.java * ----------------------- - * (C) Copyright 2003-2009, by Matthias Rose and Contributors. + * (C) Copyright 2003-2013, by Matthias Rose and Contributors. * * Original Author: Matthias Rose (based on XYAreaRenderer.java); * Contributor(s): David Gilbert (for Object Refinery Limited); + * Lukasz Rzeszotarski; * * Changes: * -------- @@ -50,6 +51,7 @@ * 04-May-2007 : Set processVisibleItemsOnly flag to false (DG); * 14-May-2008 : Call addEntity() from within drawItem() (DG); * 19-May-2009 : Fixed FindBugs warnings, patch by Michal Wozniak (DG); + * 05-Dec-2013 : Added setStepPoint() method (LR); * */ @@ -65,7 +67,6 @@ import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; -import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; @@ -122,6 +123,14 @@ * area. */ private double rangeBase; + + /** + * The factor (from 0.0 to 1.0) that determines the position of the + * step. + * + * @since 1.0.18. + */ + private double stepPoint; /** * Constructs a new renderer. @@ -150,10 +159,8 @@ * (<code>null</code> permitted). * @param urlGenerator the URL generator (<code>null</code> permitted). */ - public XYStepAreaRenderer(int type, - XYToolTipGenerator toolTipGenerator, - XYURLGenerator urlGenerator) { - + public XYStepAreaRenderer(int type, XYToolTipGenerator toolTipGenerator, + XYURLGenerator urlGenerator) { super(); setBaseToolTipGenerator(toolTipGenerator); setURLGenerator(urlGenerator); @@ -169,6 +176,7 @@ this.shapesVisible = true; } this.showOutline = false; + this.stepPoint = 1.0; } /** @@ -301,6 +309,42 @@ } /** + * Returns the fraction of the domain position between two points on which + * the step is drawn. The default is 1.0d, which means the step is drawn + * at the domain position of the second`point. If the stepPoint is 0.5d the + * step is drawn at half between the two points. + * + * @return The fraction of the domain position between two points where the + * step is drawn. + * + * @see #setStepPoint(double) + * + * @since 1.0.18 + */ + public double getStepPoint() { + return stepPoint; + } + + /** + * Sets the step point and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param stepPoint the step point (in the range 0.0 to 1.0) + * + * @see #getStepPoint() + * + * @since 1.0.18 + */ + public void setStepPoint(double stepPoint) { + if (stepPoint < 0.0d || stepPoint > 1.0d) { + throw new IllegalArgumentException( + "Requires stepPoint in [0.0;1.0]"); + } + this.stepPoint = stepPoint; + fireChangeEvent(); + } + + /** * Initialises the renderer. Here we calculate the Java2D y-coordinate for * zero, since all the bars have their bases fixed at zero. * @@ -326,7 +370,6 @@ } - /** * Draws the visual representation of a single data item. * @@ -424,11 +467,15 @@ } if (transY0 != transY1) { // not just a horizontal bar but need to perform a 'step'. + double transXs = transX0 + (getStepPoint() + * (transX1 - transX0)); if (orientation == PlotOrientation.VERTICAL) { - this.pArea.addPoint((int) transX1, (int) transY0); + this.pArea.addPoint((int) transXs, (int) transY0); + this.pArea.addPoint((int) transXs, (int) transY1); } else if (orientation == PlotOrientation.HORIZONTAL) { - this.pArea.addPoint((int) transY0, (int) transX1); + this.pArea.addPoint((int) transY0, (int) transXs); + this.pArea.addPoint((int) transY1, (int) transXs); } } } @@ -553,6 +600,9 @@ if (this.rangeBase != that.rangeBase) { return false; } + if (this.stepPoint != that.stepPoint) { + return false; + } return super.equals(obj); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |