Skip to content

Commit

Permalink
Move extendLine to LineUtilities class.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfree committed Feb 28, 2014
1 parent 5324db8 commit 73e9a42
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/jfree/chart/plot/RingPlot.java
Expand Up @@ -84,6 +84,7 @@
import org.jfree.chart.text.TextUtilities;
import org.jfree.chart.ui.TextAnchor;
import org.jfree.chart.urls.PieURLGenerator;
import org.jfree.chart.util.LineUtilities;
import org.jfree.chart.util.ParamChecks;
import org.jfree.chart.util.SerialUtilities;
import org.jfree.data.general.PieDataset;
Expand Down Expand Up @@ -627,8 +628,8 @@ dataset, getPieIndex(), section, key, tip,
}
else if (currentPass == 2) {
if (this.separatorsVisible) {
Line2D extendedSeparator = extendLine(separator,
this.innerSeparatorExtension,
Line2D extendedSeparator = LineUtilities.extendLine(
separator, this.innerSeparatorExtension,
this.outerSeparatorExtension);
g2.setStroke(this.separatorStroke);
g2.setPaint(this.separatorPaint);
Expand Down
34 changes: 32 additions & 2 deletions src/main/java/org/jfree/chart/util/LineUtilities.java
Expand Up @@ -2,7 +2,7 @@
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
* (C) Copyright 2000-2014, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
Expand All @@ -27,14 +27,15 @@
* ------------------
* LineUtilities.java
* ------------------
* (C) Copyright 2008, by Object Refinery Limited and Contributors.
* (C) Copyright 2008, 2014, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 05-Nov-2008 : Version 1 (DG);
* 28-Feb-2014 : Added extendLine() (DG);
*
*/

Expand Down Expand Up @@ -139,4 +140,33 @@ else if ((f2 & Rectangle2D.OUT_TOP) == Rectangle2D.OUT_TOP
// returned false from within the while loop above

}

/**
* Creates a new line by extending an existing line.
*
* @param line the line (<code>null</code> not permitted).
* @param startPercent the amount to extend the line at the start point
* end.
* @param endPercent the amount to extend the line at the end point end.
*
* @return A new line.
*
* @since 1.0.18
*/
public static Line2D extendLine(Line2D line, double startPercent,
double endPercent) {
ParamChecks.nullNotPermitted(line, "line");
double x1 = line.getX1();
double x2 = line.getX2();
double deltaX = x2 - x1;
double y1 = line.getY1();
double y2 = line.getY2();
double deltaY = y2 - y1;
x1 = x1 - (startPercent * deltaX);
y1 = y1 - (startPercent * deltaY);
x2 = x2 + (endPercent * deltaX);
y2 = y2 + (endPercent * deltaY);
return new Line2D.Double(x1, y1, x2, y2);
}

}

0 comments on commit 73e9a42

Please sign in to comment.