You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by vi...@apache.org on 2015/10/19 07:59:38 UTC
svn commit: r1709355 [3/4] - in /poi/trunk/src/ooxml:
java/org/apache/poi/xdgf/exceptions/ java/org/apache/poi/xdgf/geom/
java/org/apache/poi/xdgf/usermodel/
java/org/apache/poi/xdgf/usermodel/section/
java/org/apache/poi/xdgf/usermodel/section/geometr...
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/XDGFSection.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/XDGFSection.java?rev=1709355&r1=1709354&r2=1709355&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/XDGFSection.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/XDGFSection.java Mon Oct 19 05:59:37 2015
@@ -31,68 +31,70 @@ import com.microsoft.schemas.office.visi
public abstract class XDGFSection {
- static final ObjectFactory<XDGFSection, SectionType> _sectionTypes;
-
- static {
- _sectionTypes = new ObjectFactory<>();
- try {
- _sectionTypes.put("LineGradient", GenericSection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("FillGradient", GenericSection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("Character", CharacterSection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("Paragraph", GenericSection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("Tabs", GenericSection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("Scratch", GenericSection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("Connection", GenericSection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("ConnectionABCD", GenericSection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("Field", GenericSection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("Control", GenericSection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("Geometry", GeometrySection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("Actions", GenericSection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("Layer", GenericSection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("User", GenericSection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("Property", GenericSection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("Hyperlink", GenericSection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("Reviewer", GenericSection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("Annotation", GenericSection.class, SectionType.class, XDGFSheet.class);
- _sectionTypes.put("ActionTag", GenericSection.class, SectionType.class, XDGFSheet.class);
- } catch (NoSuchMethodException | SecurityException e) {
- throw new POIXMLException("Internal error");
- }
-
- }
-
- public static XDGFSection load(SectionType section, XDGFSheet containingSheet) {
- return _sectionTypes.load(section.getN(), section, containingSheet);
- }
-
-
- protected SectionType _section;
- protected XDGFSheet _containingSheet;
-
- protected Map<String, XDGFCell> _cells = new HashMap<>();
-
-
- public XDGFSection(SectionType section, XDGFSheet containingSheet) {
- _section = section;
- _containingSheet = containingSheet;
-
- // only store cells in the base, not rows -- because rows are handled
- // specially for geometry sections
- for (CellType cell: section.getCellArray()) {
- _cells.put(cell.getN(), new XDGFCell(cell));
- }
- }
-
- @Internal
- public SectionType getXmlObject() {
- return _section;
- }
-
- @Override
- public String toString() {
- return "<Section type=" + _section.getN() + " from " + _containingSheet + ">";
- }
+ static final ObjectFactory<XDGFSection, SectionType> _sectionTypes;
+
+ static {
+ _sectionTypes = new ObjectFactory<XDGFSection, SectionType>();
+ try {
+ _sectionTypes.put("LineGradient", GenericSection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("FillGradient", GenericSection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("Character", CharacterSection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("Paragraph", GenericSection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("Tabs", GenericSection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("Scratch", GenericSection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("Connection", GenericSection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("ConnectionABCD", GenericSection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("Field", GenericSection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("Control", GenericSection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("Geometry", GeometrySection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("Actions", GenericSection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("Layer", GenericSection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("User", GenericSection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("Property", GenericSection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("Hyperlink", GenericSection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("Reviewer", GenericSection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("Annotation", GenericSection.class, SectionType.class, XDGFSheet.class);
+ _sectionTypes.put("ActionTag", GenericSection.class, SectionType.class, XDGFSheet.class);
+ } catch (NoSuchMethodException e) {
+ throw new POIXMLException("Internal error");
+ } catch (SecurityException e) {
+ throw new POIXMLException("Internal error");
+ }
+
+ }
+
+ public static XDGFSection load(SectionType section, XDGFSheet containingSheet) {
+ return _sectionTypes.load(section.getN(), section, containingSheet);
+ }
+
+
+ protected SectionType _section;
+ protected XDGFSheet _containingSheet;
+
+ protected Map<String, XDGFCell> _cells = new HashMap<String, XDGFCell>();
+
+
+ public XDGFSection(SectionType section, XDGFSheet containingSheet) {
+ _section = section;
+ _containingSheet = containingSheet;
+
+ // only store cells in the base, not rows -- because rows are handled
+ // specially for geometry sections
+ for (CellType cell: section.getCellArray()) {
+ _cells.put(cell.getN(), new XDGFCell(cell));
+ }
+ }
+
+ @Internal
+ public SectionType getXmlObject() {
+ return _section;
+ }
+
+ @Override
+ public String toString() {
+ return "<Section type=" + _section.getN() + " from " + _containingSheet + ">";
+ }
+
+ public abstract void setupMaster(XDGFSection section);
- public abstract void setupMaster(XDGFSection section);
-
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/ArcTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/ArcTo.java?rev=1709355&r1=1709354&r2=1709355&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/ArcTo.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/ArcTo.java Mon Oct 19 05:59:37 2015
@@ -30,102 +30,105 @@ import com.microsoft.schemas.office.visi
import com.microsoft.schemas.office.visio.x2012.main.RowType;
public class ArcTo implements GeometryRow {
-
- ArcTo _master = null;
-
- // The x-coordinate of the ending vertex of an arc.
- Double x = null;
-
- // The y-coordinate of the ending vertex of an arc.
- Double y = null;
-
- // The distance from the arc's midpoint to the midpoint of its chord.
- Double a = null;
-
- Boolean deleted = null;
-
- // TODO: support formulas
-
- public ArcTo(RowType row) {
-
- if (row.isSetDel()) deleted = row.getDel();
-
- for (CellType cell: row.getCellArray()) {
- String cellName = cell.getN();
-
- if (cellName.equals("X")) {
- x = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("Y")) {
- y = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("A")) {
- a = XDGFCell.parseDoubleValue(cell);
- } else {
- throw new POIXMLException("Invalid cell '" + cellName + "' in ArcTo row");
- }
- }
- }
-
- public boolean getDel() {
- if (deleted != null)
- return deleted;
-
- if (_master != null)
- return _master.getDel();
-
- return false;
- }
-
- public Double getX() {
- return x == null ? _master.x : x;
- }
-
- public Double getY() {
- return y == null ? _master.y : y;
- }
-
- public Double getA() {
- return a == null ? _master.a : a;
- }
-
- @Override
- public void setupMaster(GeometryRow row) {
- _master = (ArcTo) row;
- }
-
- @Override
- public void addToPath(Path2D.Double path, XDGFShape parent) {
-
- if (getDel()) return;
-
- Point2D last = path.getCurrentPoint();
-
- // intentionally shadowing variables here
- double x = getX();
- double y = getY();
- double a = getA();
-
- if (a == 0) {
- path.lineTo(x, y);
- return;
- }
-
- double x0 = last.getX();
- double y0 = last.getY();
-
- double chordLength = Math.hypot(y - y0, x - x0);
- double radius = (4 * a * a + chordLength * chordLength) / (8 * Math.abs(a));
-
- // center point
- double cx = x0 + (x - x0) / 2.0;
- double cy = y0 + (y - y0) / 2.0;
-
- double rotate = Math.atan2(y - cy, x - cx);
-
- Arc2D arc = new Arc2D.Double(x0, y0 - radius,
- chordLength, 2*radius,
- 180, x0 < x ? 180 : -180,
- Arc2D.OPEN);
-
- path.append(AffineTransform.getRotateInstance(rotate, x0, y0).createTransformedShape(arc), true);
- }
+
+ ArcTo _master = null;
+
+ // The x-coordinate of the ending vertex of an arc.
+ Double x = null;
+
+ // The y-coordinate of the ending vertex of an arc.
+ Double y = null;
+
+ // The distance from the arc's midpoint to the midpoint of its chord.
+ Double a = null;
+
+ Boolean deleted = null;
+
+ // TODO: support formulas
+
+ public ArcTo(RowType row) {
+
+ if (row.isSetDel())
+ deleted = row.getDel();
+
+ for (CellType cell : row.getCellArray()) {
+ String cellName = cell.getN();
+
+ if (cellName.equals("X")) {
+ x = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("Y")) {
+ y = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("A")) {
+ a = XDGFCell.parseDoubleValue(cell);
+ } else {
+ throw new POIXMLException("Invalid cell '" + cellName
+ + "' in ArcTo row");
+ }
+ }
+ }
+
+ public boolean getDel() {
+ if (deleted != null)
+ return deleted;
+
+ if (_master != null)
+ return _master.getDel();
+
+ return false;
+ }
+
+ public Double getX() {
+ return x == null ? _master.x : x;
+ }
+
+ public Double getY() {
+ return y == null ? _master.y : y;
+ }
+
+ public Double getA() {
+ return a == null ? _master.a : a;
+ }
+
+ @Override
+ public void setupMaster(GeometryRow row) {
+ _master = (ArcTo) row;
+ }
+
+ @Override
+ public void addToPath(Path2D.Double path, XDGFShape parent) {
+
+ if (getDel())
+ return;
+
+ Point2D last = path.getCurrentPoint();
+
+ // intentionally shadowing variables here
+ double x = getX();
+ double y = getY();
+ double a = getA();
+
+ if (a == 0) {
+ path.lineTo(x, y);
+ return;
+ }
+
+ double x0 = last.getX();
+ double y0 = last.getY();
+
+ double chordLength = Math.hypot(y - y0, x - x0);
+ double radius = (4 * a * a + chordLength * chordLength)
+ / (8 * Math.abs(a));
+
+ // center point
+ double cx = x0 + (x - x0) / 2.0;
+ double cy = y0 + (y - y0) / 2.0;
+
+ double rotate = Math.atan2(y - cy, x - cx);
+
+ Arc2D arc = new Arc2D.Double(x0, y0 - radius, chordLength, 2 * radius,
+ 180, x0 < x ? 180 : -180, Arc2D.OPEN);
+
+ path.append(AffineTransform.getRotateInstance(rotate, x0, y0)
+ .createTransformedShape(arc), true);
+ }
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/Ellipse.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/Ellipse.java?rev=1709355&r1=1709354&r2=1709355&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/Ellipse.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/Ellipse.java Mon Oct 19 05:59:37 2015
@@ -29,128 +29,132 @@ import com.microsoft.schemas.office.visi
import com.microsoft.schemas.office.visio.x2012.main.RowType;
public class Ellipse implements GeometryRow {
-
- Ellipse _master = null;
-
- // x coordinate of center point
- Double x = null;
- // y coordinate of center point
- Double y = null;
-
- // x coordinate of first point on ellipse
- Double a = null;
- // y coordinate of first point on ellipse
- Double b = null;
-
- // x coordinate of second point on ellipse
- Double c = null;
- // y coordinate of second point on ellipse
- Double d = null;
-
- Boolean deleted = null;
-
- // TODO: support formulas
-
- public Ellipse(RowType row) {
-
- if (row.isSetDel()) deleted = row.getDel();
-
- for (CellType cell: row.getCellArray()) {
- String cellName = cell.getN();
-
- if (cellName.equals("X")) {
- x = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("Y")) {
- y = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("A")) {
- a = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("B")) {
- b = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("C")) {
- c = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("D")) {
- d = XDGFCell.parseDoubleValue(cell);
- } else {
- throw new POIXMLException("Invalid cell '" + cellName + "' in Ellipse row");
- }
- }
- }
-
- public boolean getDel() {
- if (deleted != null)
- return deleted;
-
- if (_master != null)
- return _master.getDel();
-
- return false;
- }
-
- public Double getX() {
- return x == null ? _master.x : x;
- }
-
- public Double getY() {
- return y == null ? _master.y : y;
- }
-
- public Double getA() {
- return a == null ? _master.a : a;
- }
-
- public Double getB() {
- return b == null ? _master.b : b;
- }
-
- public Double getC() {
- return c == null ? _master.c : c;
- }
-
- public Double getD() {
- return d == null ? _master.d : d;
- }
-
- @Override
- public void setupMaster(GeometryRow row) {
- _master = (Ellipse) row;
- }
-
- public Path2D.Double getPath() {
-
- if (getDel()) return null;
-
- // intentionally shadowing variables here
- double cx = getX(); // center
- double cy = getY();
- double a = getA(); // left
- double b = getB();
- double c = getC(); // top
- double d = getD();
-
- // compute radius
- double rx = Math.hypot(a - cx, b - cy);
- double ry = Math.hypot(c - cx, d - cy);
-
- // compute angle of ellipse
- double angle = (2.0*Math.PI + (cy > b ? 1.0 : -1.0) * Math.acos((cx - a) / rx)) % (2.0*Math.PI);
-
- // create ellipse
- Ellipse2D.Double ellipse = new Ellipse2D.Double(cx - rx,
- cy - ry,
- rx*2, ry*2);
-
- // create a path, rotate it about its center
- Path2D.Double path = new Path2D.Double(ellipse);
-
- AffineTransform tr = new AffineTransform();
- tr.rotate(angle, cx, cy);
- path.transform(tr);
-
- return path;
- }
-
- @Override
- public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
- throw new POIXMLException("Ellipse elements cannot be part of a path");
- }
+
+ Ellipse _master = null;
+
+ // x coordinate of center point
+ Double x = null;
+ // y coordinate of center point
+ Double y = null;
+
+ // x coordinate of first point on ellipse
+ Double a = null;
+ // y coordinate of first point on ellipse
+ Double b = null;
+
+ // x coordinate of second point on ellipse
+ Double c = null;
+ // y coordinate of second point on ellipse
+ Double d = null;
+
+ Boolean deleted = null;
+
+ // TODO: support formulas
+
+ public Ellipse(RowType row) {
+
+ if (row.isSetDel())
+ deleted = row.getDel();
+
+ for (CellType cell : row.getCellArray()) {
+ String cellName = cell.getN();
+
+ if (cellName.equals("X")) {
+ x = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("Y")) {
+ y = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("A")) {
+ a = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("B")) {
+ b = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("C")) {
+ c = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("D")) {
+ d = XDGFCell.parseDoubleValue(cell);
+ } else {
+ throw new POIXMLException("Invalid cell '" + cellName
+ + "' in Ellipse row");
+ }
+ }
+ }
+
+ public boolean getDel() {
+ if (deleted != null)
+ return deleted;
+
+ if (_master != null)
+ return _master.getDel();
+
+ return false;
+ }
+
+ public Double getX() {
+ return x == null ? _master.x : x;
+ }
+
+ public Double getY() {
+ return y == null ? _master.y : y;
+ }
+
+ public Double getA() {
+ return a == null ? _master.a : a;
+ }
+
+ public Double getB() {
+ return b == null ? _master.b : b;
+ }
+
+ public Double getC() {
+ return c == null ? _master.c : c;
+ }
+
+ public Double getD() {
+ return d == null ? _master.d : d;
+ }
+
+ @Override
+ public void setupMaster(GeometryRow row) {
+ _master = (Ellipse) row;
+ }
+
+ public Path2D.Double getPath() {
+
+ if (getDel())
+ return null;
+
+ // intentionally shadowing variables here
+ double cx = getX(); // center
+ double cy = getY();
+ double a = getA(); // left
+ double b = getB();
+ double c = getC(); // top
+ double d = getD();
+
+ // compute radius
+ double rx = Math.hypot(a - cx, b - cy);
+ double ry = Math.hypot(c - cx, d - cy);
+
+ // compute angle of ellipse
+ double angle = (2.0 * Math.PI + (cy > b ? 1.0 : -1.0)
+ * Math.acos((cx - a) / rx))
+ % (2.0 * Math.PI);
+
+ // create ellipse
+ Ellipse2D.Double ellipse = new Ellipse2D.Double(cx - rx, cy - ry,
+ rx * 2, ry * 2);
+
+ // create a path, rotate it about its center
+ Path2D.Double path = new Path2D.Double(ellipse);
+
+ AffineTransform tr = new AffineTransform();
+ tr.rotate(angle, cx, cy);
+ path.transform(tr);
+
+ return path;
+ }
+
+ @Override
+ public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+ throw new POIXMLException("Ellipse elements cannot be part of a path");
+ }
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/EllipticalArcTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/EllipticalArcTo.java?rev=1709355&r1=1709354&r2=1709355&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/EllipticalArcTo.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/EllipticalArcTo.java Mon Oct 19 05:59:37 2015
@@ -19,7 +19,6 @@ package org.apache.poi.xdgf.usermodel.se
import java.awt.geom.AffineTransform;
import java.awt.geom.Arc2D;
-import java.awt.geom.Path2D;
import java.awt.geom.Point2D;
import org.apache.poi.POIXMLException;
@@ -30,202 +29,218 @@ import com.microsoft.schemas.office.visi
import com.microsoft.schemas.office.visio.x2012.main.RowType;
public class EllipticalArcTo implements GeometryRow {
-
- EllipticalArcTo _master = null;
-
- // The x-coordinate of the ending vertex on an arc.
- Double x = null;
-
- // The y-coordinate of the ending vertex on an arc.
- Double y = null;
-
- // The x-coordinate of the arc's control point; a point on the arc. The
- // control point is best located about halfway between the beginning and
- // ending vertices of the arc. Otherwise, the arc may grow to an extreme
- // size in order to pass through the control point, with unpredictable
- // results.
- Double a = null;
-
- // The y-coordinate of an arc's control point.
- Double b = null;
-
- // The angle of an arc's major axis relative to the x-axis of its parent shape.
- Double c = null;
-
- // The ratio of an arc's major axis to its minor axis. Despite the usual
- // meaning of these words, the "major" axis does not have to be greater than
- // the "minor" axis, so this ratio does not have to be greater than 1.
- // Setting this cell to a value less than or equal to 0 or greater than 1000
- // can lead to unpredictable results.
- Double d = null;
-
- Boolean deleted = null;
-
- // TODO: support formulas
-
- public EllipticalArcTo(RowType row) {
-
- if (row.isSetDel()) deleted = row.getDel();
-
- for (CellType cell: row.getCellArray()) {
- String cellName = cell.getN();
-
- if (cellName.equals("X")) {
- x = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("Y")) {
- y = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("A")) {
- a = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("B")) {
- b = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("C")) {
- c = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("D")) {
- d = XDGFCell.parseDoubleValue(cell);
- } else {
- throw new POIXMLException("Invalid cell '" + cellName + "' in EllipticalArcTo row");
- }
- }
- }
-
- public boolean getDel() {
- if (deleted != null)
- return deleted;
-
- if (_master != null)
- return _master.getDel();
-
- return false;
- }
-
- public Double getX() {
- return x == null ? _master.x : x;
- }
-
- public Double getY() {
- return y == null ? _master.y : y;
- }
-
- public Double getA() {
- return a == null ? _master.a : a;
- }
-
- public Double getB() {
- return b == null ? _master.b : b;
- }
-
- public Double getC() {
- return c == null ? _master.c : c;
- }
-
- public Double getD() {
- return d == null ? _master.d : d;
- }
-
-
- @Override
- public void setupMaster(GeometryRow row) {
- _master = (EllipticalArcTo) row;
- }
-
- public static int draw = 0;
-
- @Override
- public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
-
- if (getDel()) return;
-
- // intentionally shadowing variables here
- double x = getX();
- double y = getY();
- double a = getA();
- double b = getB();
- double c = getC();
- double d = getD();
-
- createEllipticalArc(x, y, a, b, c, d, path);
- }
-
- public static void createEllipticalArc(double x, double y, double a, double b,
- double c, double d,
- java.awt.geom.Path2D.Double path) {
-
- // Formula for center of ellipse by Junichi Yoda & nashwaan:
- // -> From http://visguy.com/vgforum/index.php?topic=2464.0
- //
- // x1,y1 = start; x2,y2 = end; x3,y3 = control point
- //
- // x0 = ((x1-x2)*(x1+x2)*(y2-y3)-(x2-x3)*(x2+x3)*(y1-y2)+D^2*(y1-y2)*(y2-y3)*(y1-y3))/(2*((x1-x2)*(y2-y3)-(x2-x3)*(y1-y2)))
- // y0 = ((x1-x2)*(x2-x3)*(x1-x3)/D^2+(x2-x3)*(y1-y2)*(y1+y2)-(x1-x2)*(y2-y3)*(y2+y3))/(2*((x2-x3)*(y1-y2)-(x1-x2)*(y2-y3)))
- // radii along axis: a = sqrt{ (x1-x0)^2 + (y1-y0)^2 * D^2 }
- //
-
- Point2D last = path.getCurrentPoint();
- double x0 = last.getX();
- double y0 = last.getY();
-
- // translate all of the points to the same angle as the ellipse
- AffineTransform at = AffineTransform.getRotateInstance(-c);
- double[] pts = new double[]{x0, y0, x, y, a, b};
- at.transform(pts, 0, pts, 0, 3);
-
-
- x0 = pts[0]; y0 = pts[1];
- x = pts[2]; y = pts[3];
- a = pts[4]; b = pts[5];
-
- // nasty math time
-
- double d2 = d*d;
- double cx = ((x0-x)*(x0+x)*(y-b)-(x-a)*(x+a)*(y0-y)+d2*(y0-y)*(y-b)*(y0-b))/(2.0*((x0-x)*(y-b)-(x-a)*(y0-y)));
- double cy = ((x0-x)*(x-a)*(x0-a)/d2+(x-a)*(y0-y)*(y0+y)-(x0-x)*(y-b)*(y+b))/(2.0*((x-a)*(y0-y)-(x0-x)*(y-b)));
-
- // calculate radii of ellipse
- double rx = Math.sqrt(Math.pow(x0-cx, 2) + Math.pow(y0-cy,2) * d2);
- double ry = rx / d;
-
- // Arc2D requires us to draw an arc from one point to another, so we
- // need to calculate the angle of the start point and end point along the ellipse
- // - Derived from parametric form of ellipse: x = h + a*cos(t); y = k + b*sin(t)
-
- double ctrlAngle = Math.toDegrees(Math.atan2((b-cy)/ry, (a-cx)/rx));
- double startAngle = Math.toDegrees(Math.atan2((y0-cy)/ry, (x0-cx)/rx));
- double endAngle = Math.toDegrees(Math.atan2((y-cy)/ry, (x-cx)/rx));
-
- double sweep = computeSweep(startAngle, endAngle, ctrlAngle);
-
- // Now we have enough information to go on. Create the arc.
- Arc2D arc = new Arc2D.Double(cx-rx, cy-ry,
- rx*2, ry*2, -startAngle, sweep, Arc2D.OPEN);
-
- // rotate the arc back to the original coordinate system
- at.setToRotation(c);
- path.append(at.createTransformedShape(arc), false);
- }
-
- protected static double computeSweep(double startAngle, double endAngle, double ctrlAngle) {
- double sweep;
-
- startAngle = (360.0 + startAngle) % 360.0;
- endAngle = (360.0 + endAngle) % 360.0;
- ctrlAngle = (360.0 + ctrlAngle) % 360.0;
-
- // different sweeps depending on where the control point is
-
- if (startAngle < endAngle) {
- if (startAngle < ctrlAngle && ctrlAngle < endAngle) {
- sweep = startAngle - endAngle;
- } else {
- sweep = 360 + (startAngle - endAngle);
- }
- } else {
- if (endAngle < ctrlAngle && ctrlAngle < startAngle) {
- sweep = startAngle - endAngle;
- } else {
- sweep = - (360 - (startAngle - endAngle));
- }
- }
-
- return sweep;
- }
+
+ EllipticalArcTo _master = null;
+
+ // The x-coordinate of the ending vertex on an arc.
+ Double x = null;
+
+ // The y-coordinate of the ending vertex on an arc.
+ Double y = null;
+
+ // The x-coordinate of the arc's control point; a point on the arc. The
+ // control point is best located about halfway between the beginning and
+ // ending vertices of the arc. Otherwise, the arc may grow to an extreme
+ // size in order to pass through the control point, with unpredictable
+ // results.
+ Double a = null;
+
+ // The y-coordinate of an arc's control point.
+ Double b = null;
+
+ // The angle of an arc's major axis relative to the x-axis of its parent
+ // shape.
+ Double c = null;
+
+ // The ratio of an arc's major axis to its minor axis. Despite the usual
+ // meaning of these words, the "major" axis does not have to be greater than
+ // the "minor" axis, so this ratio does not have to be greater than 1.
+ // Setting this cell to a value less than or equal to 0 or greater than 1000
+ // can lead to unpredictable results.
+ Double d = null;
+
+ Boolean deleted = null;
+
+ // TODO: support formulas
+
+ public EllipticalArcTo(RowType row) {
+
+ if (row.isSetDel())
+ deleted = row.getDel();
+
+ for (CellType cell : row.getCellArray()) {
+ String cellName = cell.getN();
+
+ if (cellName.equals("X")) {
+ x = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("Y")) {
+ y = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("A")) {
+ a = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("B")) {
+ b = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("C")) {
+ c = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("D")) {
+ d = XDGFCell.parseDoubleValue(cell);
+ } else {
+ throw new POIXMLException("Invalid cell '" + cellName
+ + "' in EllipticalArcTo row");
+ }
+ }
+ }
+
+ public boolean getDel() {
+ if (deleted != null)
+ return deleted;
+
+ if (_master != null)
+ return _master.getDel();
+
+ return false;
+ }
+
+ public Double getX() {
+ return x == null ? _master.x : x;
+ }
+
+ public Double getY() {
+ return y == null ? _master.y : y;
+ }
+
+ public Double getA() {
+ return a == null ? _master.a : a;
+ }
+
+ public Double getB() {
+ return b == null ? _master.b : b;
+ }
+
+ public Double getC() {
+ return c == null ? _master.c : c;
+ }
+
+ public Double getD() {
+ return d == null ? _master.d : d;
+ }
+
+ @Override
+ public void setupMaster(GeometryRow row) {
+ _master = (EllipticalArcTo) row;
+ }
+
+ public static int draw = 0;
+
+ @Override
+ public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+
+ if (getDel())
+ return;
+
+ // intentionally shadowing variables here
+ double x = getX();
+ double y = getY();
+ double a = getA();
+ double b = getB();
+ double c = getC();
+ double d = getD();
+
+ createEllipticalArc(x, y, a, b, c, d, path);
+ }
+
+ public static void createEllipticalArc(double x, double y, double a,
+ double b, double c, double d, java.awt.geom.Path2D.Double path) {
+
+ // Formula for center of ellipse by Junichi Yoda & nashwaan:
+ // -> From http://visguy.com/vgforum/index.php?topic=2464.0
+ //
+ // x1,y1 = start; x2,y2 = end; x3,y3 = control point
+ //
+ // x0 =
+ // ((x1-x2)*(x1+x2)*(y2-y3)-(x2-x3)*(x2+x3)*(y1-y2)+D^2*(y1-y2)*(y2-y3)*(y1-y3))/(2*((x1-x2)*(y2-y3)-(x2-x3)*(y1-y2)))
+ // y0 =
+ // ((x1-x2)*(x2-x3)*(x1-x3)/D^2+(x2-x3)*(y1-y2)*(y1+y2)-(x1-x2)*(y2-y3)*(y2+y3))/(2*((x2-x3)*(y1-y2)-(x1-x2)*(y2-y3)))
+ // radii along axis: a = sqrt{ (x1-x0)^2 + (y1-y0)^2 * D^2 }
+ //
+
+ Point2D last = path.getCurrentPoint();
+ double x0 = last.getX();
+ double y0 = last.getY();
+
+ // translate all of the points to the same angle as the ellipse
+ AffineTransform at = AffineTransform.getRotateInstance(-c);
+ double[] pts = new double[] { x0, y0, x, y, a, b };
+ at.transform(pts, 0, pts, 0, 3);
+
+ x0 = pts[0];
+ y0 = pts[1];
+ x = pts[2];
+ y = pts[3];
+ a = pts[4];
+ b = pts[5];
+
+ // nasty math time
+
+ double d2 = d * d;
+ double cx = ((x0 - x) * (x0 + x) * (y - b) - (x - a) * (x + a)
+ * (y0 - y) + d2 * (y0 - y) * (y - b) * (y0 - b))
+ / (2.0 * ((x0 - x) * (y - b) - (x - a) * (y0 - y)));
+ double cy = ((x0 - x) * (x - a) * (x0 - a) / d2 + (x - a) * (y0 - y)
+ * (y0 + y) - (x0 - x) * (y - b) * (y + b))
+ / (2.0 * ((x - a) * (y0 - y) - (x0 - x) * (y - b)));
+
+ // calculate radii of ellipse
+ double rx = Math.sqrt(Math.pow(x0 - cx, 2) + Math.pow(y0 - cy, 2) * d2);
+ double ry = rx / d;
+
+ // Arc2D requires us to draw an arc from one point to another, so we
+ // need to calculate the angle of the start point and end point along
+ // the ellipse
+ // - Derived from parametric form of ellipse: x = h + a*cos(t); y = k +
+ // b*sin(t)
+
+ double ctrlAngle = Math.toDegrees(Math.atan2((b - cy) / ry, (a - cx)
+ / rx));
+ double startAngle = Math.toDegrees(Math.atan2((y0 - cy) / ry, (x0 - cx)
+ / rx));
+ double endAngle = Math.toDegrees(Math.atan2((y - cy) / ry, (x - cx)
+ / rx));
+
+ double sweep = computeSweep(startAngle, endAngle, ctrlAngle);
+
+ // Now we have enough information to go on. Create the arc.
+ Arc2D arc = new Arc2D.Double(cx - rx, cy - ry, rx * 2, ry * 2,
+ -startAngle, sweep, Arc2D.OPEN);
+
+ // rotate the arc back to the original coordinate system
+ at.setToRotation(c);
+ path.append(at.createTransformedShape(arc), false);
+ }
+
+ protected static double computeSweep(double startAngle, double endAngle,
+ double ctrlAngle) {
+ double sweep;
+
+ startAngle = (360.0 + startAngle) % 360.0;
+ endAngle = (360.0 + endAngle) % 360.0;
+ ctrlAngle = (360.0 + ctrlAngle) % 360.0;
+
+ // different sweeps depending on where the control point is
+
+ if (startAngle < endAngle) {
+ if (startAngle < ctrlAngle && ctrlAngle < endAngle) {
+ sweep = startAngle - endAngle;
+ } else {
+ sweep = 360 + (startAngle - endAngle);
+ }
+ } else {
+ if (endAngle < ctrlAngle && ctrlAngle < startAngle) {
+ sweep = startAngle - endAngle;
+ } else {
+ sweep = -(360 - (startAngle - endAngle));
+ }
+ }
+
+ return sweep;
+ }
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/GeometryRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/GeometryRow.java?rev=1709355&r1=1709354&r2=1709355&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/GeometryRow.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/GeometryRow.java Mon Oct 19 05:59:37 2015
@@ -21,11 +21,10 @@ import java.awt.geom.Path2D;
import org.apache.poi.xdgf.usermodel.XDGFShape;
-
public interface GeometryRow {
-
- public void setupMaster(GeometryRow row);
- public void addToPath(Path2D.Double path, XDGFShape parent);
-
+ public void setupMaster(GeometryRow row);
+
+ public void addToPath(Path2D.Double path, XDGFShape parent);
+
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/GeometryRowFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/GeometryRowFactory.java?rev=1709355&r1=1709354&r2=1709355&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/GeometryRowFactory.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/GeometryRowFactory.java Mon Oct 19 05:59:37 2015
@@ -24,34 +24,38 @@ import com.microsoft.schemas.office.visi
public class GeometryRowFactory {
- static final ObjectFactory<GeometryRow, RowType> _rowTypes;
-
- static {
- _rowTypes = new ObjectFactory<>();
- try {
- _rowTypes.put("ArcTo", ArcTo.class, RowType.class);
- _rowTypes.put("Ellipse", Ellipse.class, RowType.class);
- _rowTypes.put("EllipticalArcTo", EllipticalArcTo.class, RowType.class);
- _rowTypes.put("InfiniteLine", InfiniteLine.class, RowType.class);
- _rowTypes.put("LineTo", LineTo.class, RowType.class);
- _rowTypes.put("MoveTo", MoveTo.class, RowType.class);
- _rowTypes.put("NURBSTo", NURBSTo.class, RowType.class);
- _rowTypes.put("PolyLineTo", PolyLineTo.class, RowType.class);
- _rowTypes.put("RelCubBezTo", RelCubBezTo.class, RowType.class);
- _rowTypes.put("RelEllipticalArcTo", RelEllipticalArcTo.class, RowType.class);
- _rowTypes.put("RelLineTo", RelLineTo.class, RowType.class);
- _rowTypes.put("RelMoveTo", RelMoveTo.class, RowType.class);
- _rowTypes.put("RelQuadBezTo", RelQuadBezTo.class, RowType.class);
- _rowTypes.put("SplineKnot", SplineKnot.class, RowType.class);
- _rowTypes.put("SplineStart", SplineStart.class, RowType.class);
- } catch (NoSuchMethodException | SecurityException e) {
- throw new POIXMLException("Internal error", e);
- }
-
- }
-
- public static GeometryRow load(RowType row) {
- return _rowTypes.load(row.getT(), row);
- }
-
+ static final ObjectFactory<GeometryRow, RowType> _rowTypes;
+
+ static {
+ _rowTypes = new ObjectFactory<GeometryRow, RowType>();
+ try {
+ _rowTypes.put("ArcTo", ArcTo.class, RowType.class);
+ _rowTypes.put("Ellipse", Ellipse.class, RowType.class);
+ _rowTypes.put("EllipticalArcTo", EllipticalArcTo.class,
+ RowType.class);
+ _rowTypes.put("InfiniteLine", InfiniteLine.class, RowType.class);
+ _rowTypes.put("LineTo", LineTo.class, RowType.class);
+ _rowTypes.put("MoveTo", MoveTo.class, RowType.class);
+ _rowTypes.put("NURBSTo", NURBSTo.class, RowType.class);
+ _rowTypes.put("PolyLineTo", PolyLineTo.class, RowType.class);
+ _rowTypes.put("RelCubBezTo", RelCubBezTo.class, RowType.class);
+ _rowTypes.put("RelEllipticalArcTo", RelEllipticalArcTo.class,
+ RowType.class);
+ _rowTypes.put("RelLineTo", RelLineTo.class, RowType.class);
+ _rowTypes.put("RelMoveTo", RelMoveTo.class, RowType.class);
+ _rowTypes.put("RelQuadBezTo", RelQuadBezTo.class, RowType.class);
+ _rowTypes.put("SplineKnot", SplineKnot.class, RowType.class);
+ _rowTypes.put("SplineStart", SplineStart.class, RowType.class);
+ } catch (NoSuchMethodException e) {
+ throw new POIXMLException("Internal error", e);
+ } catch (SecurityException e) {
+ throw new POIXMLException("Internal error", e);
+ }
+
+ }
+
+ public static GeometryRow load(RowType row) {
+ return _rowTypes.load(row.getT(), row);
+ }
+
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/InfiniteLine.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/InfiniteLine.java?rev=1709355&r1=1709354&r2=1709355&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/InfiniteLine.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/InfiniteLine.java Mon Oct 19 05:59:37 2015
@@ -18,14 +18,9 @@
package org.apache.poi.xdgf.usermodel.section.geometry;
import java.awt.geom.Path2D;
-import java.awt.geom.Point2D;
-import java.awt.geom.Rectangle2D;
import org.apache.poi.POIXMLException;
-import org.apache.poi.xdgf.geom.Dimension2dDouble;
import org.apache.poi.xdgf.usermodel.XDGFCell;
-import org.apache.poi.xdgf.usermodel.XDGFDocument;
-import org.apache.poi.xdgf.usermodel.XDGFPage;
import org.apache.poi.xdgf.usermodel.XDGFShape;
import com.microsoft.schemas.office.visio.x2012.main.CellType;
@@ -35,117 +30,125 @@ import com.microsoft.schemas.office.visi
* Contains the x- and y-coordinates of two points on an infinite line.
*/
public class InfiniteLine implements GeometryRow {
-
- InfiniteLine _master = null;
-
- // An x-coordinate of a point on the infinite line; paired with y-coordinate represented by the Y cell.
- Double x = null;
-
- // A y-coordinate of a point on the infinite line; paired with x-coordinate represented by the X cell.
- Double y = null;
-
- // An x-coordinate of a point on the infinite line; paired with y-coordinate represented by the B cell.
- Double a = null;
-
- // A y-coordinate of a point on an infinite line; paired with x-coordinate represented by the A cell.
- Double b = null;
-
- Boolean deleted = null;
-
- // TODO: support formulas
-
- public InfiniteLine(RowType row) {
-
- if (row.isSetDel()) deleted = row.getDel();
-
- for (CellType cell: row.getCellArray()) {
- String cellName = cell.getN();
-
- if (cellName.equals("X")) {
- x = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("Y")) {
- y = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("A")) {
- a = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("B")) {
- b = XDGFCell.parseDoubleValue(cell);
- } else {
- throw new POIXMLException("Invalid cell '" + cellName + "' in InfiniteLine row");
- }
- }
- }
-
- public boolean getDel() {
- if (deleted != null)
- return deleted;
-
- if (_master != null)
- return _master.getDel();
-
- return false;
- }
-
- public Double getX() {
- return x == null ? _master.x : x;
- }
-
- public Double getY() {
- return y == null ? _master.y : y;
- }
-
- public Double getA() {
- return a == null ? _master.a : a;
- }
-
- public Double getB() {
- return b == null ? _master.b : b;
- }
-
- @Override
- public void setupMaster(GeometryRow row) {
- _master = (InfiniteLine) row;
- }
-
- @Override
- public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
-
- if (getDel()) return;
-
- throw new POIXMLException("InfiniteLine elements cannot be part of a path");
- }
-
- // returns this object as a line that extends between the boundaries of
- // the document
- public Path2D.Double getPath() {
- Path2D.Double path = new Path2D.Double();
-
- // this is a bit of a hack, but it works
- double max_val = 100000;
-
- // compute slope..
- double x0 = getX();
- double y0 = getY();
- double x1 = getA(); // second x
- double y1 = getB(); // second y
-
- if (x0 == x1) {
- path.moveTo(x0, -max_val);
- path.lineTo(x0, max_val);
- } else if (y0 == y1) {
- path.moveTo(-max_val, y0);
- path.lineTo(max_val, y0);
- } else {
-
- // normal case: compute slope/intercept
- double m = (y1 - y0) / (x1 - x0);
- double c = y0 - m*x0;
-
- // y = mx + c
-
- path.moveTo(max_val, m*max_val + c);
- path.lineTo(max_val, (max_val - c)/m);
- }
-
- return path;
- }
+
+ InfiniteLine _master = null;
+
+ // An x-coordinate of a point on the infinite line; paired with y-coordinate
+ // represented by the Y cell.
+ Double x = null;
+
+ // A y-coordinate of a point on the infinite line; paired with x-coordinate
+ // represented by the X cell.
+ Double y = null;
+
+ // An x-coordinate of a point on the infinite line; paired with y-coordinate
+ // represented by the B cell.
+ Double a = null;
+
+ // A y-coordinate of a point on an infinite line; paired with x-coordinate
+ // represented by the A cell.
+ Double b = null;
+
+ Boolean deleted = null;
+
+ // TODO: support formulas
+
+ public InfiniteLine(RowType row) {
+
+ if (row.isSetDel())
+ deleted = row.getDel();
+
+ for (CellType cell : row.getCellArray()) {
+ String cellName = cell.getN();
+
+ if (cellName.equals("X")) {
+ x = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("Y")) {
+ y = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("A")) {
+ a = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("B")) {
+ b = XDGFCell.parseDoubleValue(cell);
+ } else {
+ throw new POIXMLException("Invalid cell '" + cellName
+ + "' in InfiniteLine row");
+ }
+ }
+ }
+
+ public boolean getDel() {
+ if (deleted != null)
+ return deleted;
+
+ if (_master != null)
+ return _master.getDel();
+
+ return false;
+ }
+
+ public Double getX() {
+ return x == null ? _master.x : x;
+ }
+
+ public Double getY() {
+ return y == null ? _master.y : y;
+ }
+
+ public Double getA() {
+ return a == null ? _master.a : a;
+ }
+
+ public Double getB() {
+ return b == null ? _master.b : b;
+ }
+
+ @Override
+ public void setupMaster(GeometryRow row) {
+ _master = (InfiniteLine) row;
+ }
+
+ @Override
+ public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+
+ if (getDel())
+ return;
+
+ throw new POIXMLException(
+ "InfiniteLine elements cannot be part of a path");
+ }
+
+ // returns this object as a line that extends between the boundaries of
+ // the document
+ public Path2D.Double getPath() {
+ Path2D.Double path = new Path2D.Double();
+
+ // this is a bit of a hack, but it works
+ double max_val = 100000;
+
+ // compute slope..
+ double x0 = getX();
+ double y0 = getY();
+ double x1 = getA(); // second x
+ double y1 = getB(); // second y
+
+ if (x0 == x1) {
+ path.moveTo(x0, -max_val);
+ path.lineTo(x0, max_val);
+ } else if (y0 == y1) {
+ path.moveTo(-max_val, y0);
+ path.lineTo(max_val, y0);
+ } else {
+
+ // normal case: compute slope/intercept
+ double m = (y1 - y0) / (x1 - x0);
+ double c = y0 - m * x0;
+
+ // y = mx + c
+
+ path.moveTo(max_val, m * max_val + c);
+ path.lineTo(max_val, (max_val - c) / m);
+ }
+
+ return path;
+ }
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/LineTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/LineTo.java?rev=1709355&r1=1709354&r2=1709355&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/LineTo.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/LineTo.java Mon Oct 19 05:59:37 2015
@@ -26,63 +26,66 @@ import com.microsoft.schemas.office.visi
public class LineTo implements GeometryRow {
- LineTo _master = null;
-
- Double x = null;
- Double y = null;
-
- Boolean deleted = null;
-
- // TODO: support formulas
-
- public LineTo(RowType row) {
-
- if (row.isSetDel()) deleted = row.getDel();
-
- for (CellType cell: row.getCellArray()) {
- String cellName = cell.getN();
-
- if (cellName.equals("X")) {
- x = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("Y")) {
- y = XDGFCell.parseDoubleValue(cell);
- } else {
- throw new POIXMLException("Invalid cell '" + cellName + "' in LineTo row");
- }
- }
- }
-
- @Override
- public String toString() {
- return "LineTo: x=" + getX() + "; y=" + getY();
- }
-
- public boolean getDel() {
- if (deleted != null)
- return deleted;
-
- if (_master != null)
- return _master.getDel();
-
- return false;
- }
-
- public Double getX() {
- return x == null ? _master.x : x;
- }
-
- public Double getY() {
- return y == null ? _master.y : y;
- }
-
- @Override
- public void setupMaster(GeometryRow row) {
- _master = (LineTo) row;
- }
-
- @Override
- public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
- if (getDel()) return;
- path.lineTo(getX(), getY());
- }
+ LineTo _master = null;
+
+ Double x = null;
+ Double y = null;
+
+ Boolean deleted = null;
+
+ // TODO: support formulas
+
+ public LineTo(RowType row) {
+
+ if (row.isSetDel())
+ deleted = row.getDel();
+
+ for (CellType cell : row.getCellArray()) {
+ String cellName = cell.getN();
+
+ if (cellName.equals("X")) {
+ x = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("Y")) {
+ y = XDGFCell.parseDoubleValue(cell);
+ } else {
+ throw new POIXMLException("Invalid cell '" + cellName
+ + "' in LineTo row");
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "LineTo: x=" + getX() + "; y=" + getY();
+ }
+
+ public boolean getDel() {
+ if (deleted != null)
+ return deleted;
+
+ if (_master != null)
+ return _master.getDel();
+
+ return false;
+ }
+
+ public Double getX() {
+ return x == null ? _master.x : x;
+ }
+
+ public Double getY() {
+ return y == null ? _master.y : y;
+ }
+
+ @Override
+ public void setupMaster(GeometryRow row) {
+ _master = (LineTo) row;
+ }
+
+ @Override
+ public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+ if (getDel())
+ return;
+ path.lineTo(getX(), getY());
+ }
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/MoveTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/MoveTo.java?rev=1709355&r1=1709354&r2=1709355&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/MoveTo.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/MoveTo.java Mon Oct 19 05:59:37 2015
@@ -30,64 +30,67 @@ import com.microsoft.schemas.office.visi
* the height and width of the shape.
*/
public class MoveTo implements GeometryRow {
-
- MoveTo _master = null;
-
- Double x = null;
- Double y = null;
-
- Boolean deleted = null;
-
- // TODO: support formulas
-
- public MoveTo(RowType row) {
-
- if (row.isSetDel()) deleted = row.getDel();
-
- for (CellType cell: row.getCellArray()) {
- String cellName = cell.getN();
-
- if (cellName.equals("X")) {
- x = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("Y")) {
- y = XDGFCell.parseDoubleValue(cell);
- } else {
- throw new POIXMLException("Invalid cell '" + cellName + "' in MoveTo row");
- }
- }
- }
-
- @Override
- public String toString() {
- return "MoveTo: x=" + getX() + "; y=" + getY();
- }
-
- public boolean getDel() {
- if (deleted != null)
- return deleted;
-
- if (_master != null)
- return _master.getDel();
-
- return false;
- }
-
- public Double getX() {
- return x == null ? _master.x : x;
- }
-
- public Double getY() {
- return y == null ? _master.y : y;
- }
-
- @Override
- public void setupMaster(GeometryRow row) {
- _master = (MoveTo) row;
- }
-
- @Override
- public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
- if (getDel()) return;
- path.moveTo(getX(), getY());
- }
+
+ MoveTo _master = null;
+
+ Double x = null;
+ Double y = null;
+
+ Boolean deleted = null;
+
+ // TODO: support formulas
+
+ public MoveTo(RowType row) {
+
+ if (row.isSetDel())
+ deleted = row.getDel();
+
+ for (CellType cell : row.getCellArray()) {
+ String cellName = cell.getN();
+
+ if (cellName.equals("X")) {
+ x = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("Y")) {
+ y = XDGFCell.parseDoubleValue(cell);
+ } else {
+ throw new POIXMLException("Invalid cell '" + cellName
+ + "' in MoveTo row");
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "MoveTo: x=" + getX() + "; y=" + getY();
+ }
+
+ public boolean getDel() {
+ if (deleted != null)
+ return deleted;
+
+ if (_master != null)
+ return _master.getDel();
+
+ return false;
+ }
+
+ public Double getX() {
+ return x == null ? _master.x : x;
+ }
+
+ public Double getY() {
+ return y == null ? _master.y : y;
+ }
+
+ @Override
+ public void setupMaster(GeometryRow row) {
+ _master = (MoveTo) row;
+ }
+
+ @Override
+ public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+ if (getDel())
+ return;
+ path.moveTo(getX(), getY());
+ }
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/NURBSTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/NURBSTo.java?rev=1709355&r1=1709354&r2=1709355&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/NURBSTo.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/NURBSTo.java Mon Oct 19 05:59:37 2015
@@ -20,186 +20,192 @@ package org.apache.poi.xdgf.usermodel.se
import java.awt.geom.Point2D;
import org.apache.poi.POIXMLException;
+import org.apache.poi.ss.formula.functions.LookupUtils.ValueVector;
import org.apache.poi.xdgf.geom.SplineRenderer;
import org.apache.poi.xdgf.usermodel.XDGFCell;
import org.apache.poi.xdgf.usermodel.XDGFShape;
-import com.graphbuilder.curve.ControlPath;
-import com.graphbuilder.curve.ShapeMultiPath;
-import com.graphbuilder.curve.ValueVector;
-import com.graphbuilder.geom.PointFactory;
import com.microsoft.schemas.office.visio.x2012.main.CellType;
import com.microsoft.schemas.office.visio.x2012.main.RowType;
public class NURBSTo implements GeometryRow {
-
- NURBSTo _master = null;
-
- // The x-coordinate of the last control point of a NURBS.
- Double x = null;
-
- // The y-coordinate of the last control point of a NURBS.
- Double y = null;
-
- // The second to the last knot of the NURBS.
- Double a = null;
-
- // The last weight of the NURBS.
- Double b = null;
-
- // The first knot of the NURBS.
- Double c = null;
-
- // The first weight of the NURBS.
- Double d = null;
-
- // A NURBS formula.
- String e = null;
-
- Boolean deleted = null;
-
- // TODO: support formulas
-
- public NURBSTo(RowType row) {
-
- if (row.isSetDel()) deleted = row.getDel();
-
- for (CellType cell: row.getCellArray()) {
- String cellName = cell.getN();
-
- if (cellName.equals("X")) {
- x = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("Y")) {
- y = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("A")) {
- a = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("B")) {
- b = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("C")) {
- c = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("D")) {
- d = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("E")) {
- e = cell.getV();
- } else {
- throw new POIXMLException("Invalid cell '" + cellName + "' in NURBS row");
- }
- }
- }
-
- public boolean getDel() {
- if (deleted != null)
- return deleted;
-
- if (_master != null)
- return _master.getDel();
-
- return false;
- }
-
- public Double getX() {
- return x == null ? _master.x : x;
- }
-
- public Double getY() {
- return y == null ? _master.y : y;
- }
-
- public Double getA() {
- return a == null ? _master.a : a;
- }
-
- public Double getB() {
- return b == null ? _master.b : b;
- }
-
- public Double getC() {
- return c == null ? _master.c : c;
- }
-
- public Double getD() {
- return d == null ? _master.d : d;
- }
-
- public String getE() {
- return e == null ? _master.e : e;
- }
-
- @Override
- public void setupMaster(GeometryRow row) {
- _master = (NURBSTo) row;
- }
-
- @Override
- public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
- if (getDel()) return;
-
- Point2D last = path.getCurrentPoint();
-
- // A NURBS formula: knotLast, degree, xType, yType, x1, y1, knot1, weight1, ..
- String formula = getE().trim();
- if (!formula.startsWith("NURBS(") || !formula.endsWith(")"))
- throw new POIXMLException("Invalid NURBS formula: " + formula);
-
- String [] components = formula.substring(6, formula.length()-1).split(",");
-
- if (components.length < 8)
- throw new POIXMLException("Invalid NURBS formula (not enough arguments)");
-
- if ((components.length - 4) % 4 != 0)
- throw new POIXMLException("Invalid NURBS formula -- need 4 + n*4 arguments, got " + components.length);
-
- double lastControlX = getX();
- double lastControlY = getY();
- double secondToLastKnot = getA();
- double lastWeight = getB();
- double firstKnot = getC();
- double firstWeight = getD();
-
- double lastKnot = Double.parseDouble(components[0].trim());
- int degree = Integer.parseInt(components[1].trim());
- int xType = Integer.parseInt(components[2].trim());
- int yType = Integer.parseInt(components[3].trim());
-
- double xScale = 1;
- double yScale = 1;
-
- if (xType == 0)
- xScale = parent.getWidth();
- if (yType == 0)
- yScale = parent.getHeight();
-
- // setup first knots/weights/control point
- ControlPath controlPath = new ControlPath();
- ValueVector knots = new ValueVector();
- ValueVector weights = new ValueVector();
-
- knots.add(firstKnot);
- weights.add(firstWeight);
- controlPath.addPoint(PointFactory.create(last.getX(), last.getY()));
-
- // iterate get knots/weights
- int sets = (components.length - 4) / 4;
- for (int i = 0; i < sets; i++) {
- double x1 = Double.parseDouble(components[4 + i*4 + 0].trim());
- double y1 = Double.parseDouble(components[4 + i*4 + 1].trim());
- double k = Double.parseDouble(components[4 + i*4 + 2].trim());
- double w = Double.parseDouble(components[4 + i*4 + 3].trim());
-
- controlPath.addPoint(PointFactory.create(x1*xScale, y1*yScale));
- knots.add(k);
- weights.add(w);
- }
-
- // last knots/weights/control point
- knots.add(secondToLastKnot);
- knots.add(lastKnot);
-
- weights.add(lastWeight);
-
- controlPath.addPoint(PointFactory.create(lastControlX, lastControlY));
-
- ShapeMultiPath shape = SplineRenderer.createNurbsSpline(controlPath, knots, weights, degree);
- path.append(shape, true);
- }
+
+ NURBSTo _master = null;
+
+ // The x-coordinate of the last control point of a NURBS.
+ Double x = null;
+
+ // The y-coordinate of the last control point of a NURBS.
+ Double y = null;
+
+ // The second to the last knot of the NURBS.
+ Double a = null;
+
+ // The last weight of the NURBS.
+ Double b = null;
+
+ // The first knot of the NURBS.
+ Double c = null;
+
+ // The first weight of the NURBS.
+ Double d = null;
+
+ // A NURBS formula.
+ String e = null;
+
+ Boolean deleted = null;
+
+ // TODO: support formulas
+
+ public NURBSTo(RowType row) {
+
+ if (row.isSetDel())
+ deleted = row.getDel();
+
+ for (CellType cell : row.getCellArray()) {
+ String cellName = cell.getN();
+
+ if (cellName.equals("X")) {
+ x = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("Y")) {
+ y = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("A")) {
+ a = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("B")) {
+ b = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("C")) {
+ c = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("D")) {
+ d = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("E")) {
+ e = cell.getV();
+ } else {
+ throw new POIXMLException("Invalid cell '" + cellName
+ + "' in NURBS row");
+ }
+ }
+ }
+
+ public boolean getDel() {
+ if (deleted != null)
+ return deleted;
+
+ if (_master != null)
+ return _master.getDel();
+
+ return false;
+ }
+
+ public Double getX() {
+ return x == null ? _master.x : x;
+ }
+
+ public Double getY() {
+ return y == null ? _master.y : y;
+ }
+
+ public Double getA() {
+ return a == null ? _master.a : a;
+ }
+
+ public Double getB() {
+ return b == null ? _master.b : b;
+ }
+
+ public Double getC() {
+ return c == null ? _master.c : c;
+ }
+
+ public Double getD() {
+ return d == null ? _master.d : d;
+ }
+
+ public String getE() {
+ return e == null ? _master.e : e;
+ }
+
+ @Override
+ public void setupMaster(GeometryRow row) {
+ _master = (NURBSTo) row;
+ }
+
+ @Override
+ public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+ if (getDel())
+ return;
+
+ Point2D last = path.getCurrentPoint();
+
+ // A NURBS formula: knotLast, degree, xType, yType, x1, y1, knot1,
+ // weight1, ..
+ String formula = getE().trim();
+ if (!formula.startsWith("NURBS(") || !formula.endsWith(")"))
+ throw new POIXMLException("Invalid NURBS formula: " + formula);
+
+ String[] components = formula.substring(6, formula.length() - 1).split(
+ ",");
+
+ if (components.length < 8)
+ throw new POIXMLException(
+ "Invalid NURBS formula (not enough arguments)");
+
+ if ((components.length - 4) % 4 != 0)
+ throw new POIXMLException(
+ "Invalid NURBS formula -- need 4 + n*4 arguments, got "
+ + components.length);
+
+ double lastControlX = getX();
+ double lastControlY = getY();
+ double secondToLastKnot = getA();
+ double lastWeight = getB();
+ double firstKnot = getC();
+ double firstWeight = getD();
+
+ double lastKnot = Double.parseDouble(components[0].trim());
+ int degree = Integer.parseInt(components[1].trim());
+ int xType = Integer.parseInt(components[2].trim());
+ int yType = Integer.parseInt(components[3].trim());
+
+ double xScale = 1;
+ double yScale = 1;
+
+ if (xType == 0)
+ xScale = parent.getWidth();
+ if (yType == 0)
+ yScale = parent.getHeight();
+
+ // setup first knots/weights/control point
+ ControlPath controlPath = new ControlPath();
+ ValueVector knots = new ValueVector();
+ ValueVector weights = new ValueVector();
+
+ knots.add(firstKnot);
+ weights.add(firstWeight);
+ controlPath.addPoint(PointFactory.create(last.getX(), last.getY()));
+
+ // iterate get knots/weights
+ int sets = (components.length - 4) / 4;
+ for (int i = 0; i < sets; i++) {
+ double x1 = Double.parseDouble(components[4 + i * 4 + 0].trim());
+ double y1 = Double.parseDouble(components[4 + i * 4 + 1].trim());
+ double k = Double.parseDouble(components[4 + i * 4 + 2].trim());
+ double w = Double.parseDouble(components[4 + i * 4 + 3].trim());
+
+ controlPath.addPoint(PointFactory.create(x1 * xScale, y1 * yScale));
+ knots.add(k);
+ weights.add(w);
+ }
+
+ // last knots/weights/control point
+ knots.add(secondToLastKnot);
+ knots.add(lastKnot);
+
+ weights.add(lastWeight);
+
+ controlPath.addPoint(PointFactory.create(lastControlX, lastControlY));
+
+ ShapeMultiPath shape = SplineRenderer.createNurbsSpline(controlPath,
+ knots, weights, degree);
+ path.append(shape, true);
+ }
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/PolyLineTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/PolyLineTo.java?rev=1709355&r1=1709354&r2=1709355&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/PolyLineTo.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/PolyLineTo.java Mon Oct 19 05:59:37 2015
@@ -25,71 +25,74 @@ import com.microsoft.schemas.office.visi
import com.microsoft.schemas.office.visio.x2012.main.RowType;
public class PolyLineTo implements GeometryRow {
-
- PolyLineTo _master = null;
-
- // The x-coordinate of the ending vertex of a polyline.
- Double x = null;
-
- // The y-coordinate of the ending vertex of a polyline.
- Double y = null;
-
- // The polyline formula
- String a = null;
-
- Boolean deleted = null;
-
- // TODO: support formulas
-
- public PolyLineTo(RowType row) {
-
- if (row.isSetDel()) deleted = row.getDel();
-
- for (CellType cell: row.getCellArray()) {
- String cellName = cell.getN();
-
- if (cellName.equals("X")) {
- x = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("Y")) {
- y = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("A")) {
- a = cell.getV();
- } else {
- throw new POIXMLException("Invalid cell '" + cellName + "' in ArcTo row");
- }
- }
- }
-
- public boolean getDel() {
- if (deleted != null)
- return deleted;
-
- if (_master != null)
- return _master.getDel();
-
- return false;
- }
-
- public Double getX() {
- return x == null ? _master.x : x;
- }
-
- public Double getY() {
- return y == null ? _master.y : y;
- }
-
- public String getA() {
- return a == null ? _master.a : a;
- }
-
- @Override
- public void setupMaster(GeometryRow row) {
- _master = (PolyLineTo) row;
- }
-
- @Override
- public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
- if (getDel()) return;
- throw new POIXMLException("Polyline support not implemented");
- }
+
+ PolyLineTo _master = null;
+
+ // The x-coordinate of the ending vertex of a polyline.
+ Double x = null;
+
+ // The y-coordinate of the ending vertex of a polyline.
+ Double y = null;
+
+ // The polyline formula
+ String a = null;
+
+ Boolean deleted = null;
+
+ // TODO: support formulas
+
+ public PolyLineTo(RowType row) {
+
+ if (row.isSetDel())
+ deleted = row.getDel();
+
+ for (CellType cell : row.getCellArray()) {
+ String cellName = cell.getN();
+
+ if (cellName.equals("X")) {
+ x = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("Y")) {
+ y = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("A")) {
+ a = cell.getV();
+ } else {
+ throw new POIXMLException("Invalid cell '" + cellName
+ + "' in ArcTo row");
+ }
+ }
+ }
+
+ public boolean getDel() {
+ if (deleted != null)
+ return deleted;
+
+ if (_master != null)
+ return _master.getDel();
+
+ return false;
+ }
+
+ public Double getX() {
+ return x == null ? _master.x : x;
+ }
+
+ public Double getY() {
+ return y == null ? _master.y : y;
+ }
+
+ public String getA() {
+ return a == null ? _master.a : a;
+ }
+
+ @Override
+ public void setupMaster(GeometryRow row) {
+ _master = (PolyLineTo) row;
+ }
+
+ @Override
+ public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+ if (getDel())
+ return;
+ throw new POIXMLException("Polyline support not implemented");
+ }
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelCubBezTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelCubBezTo.java?rev=1709355&r1=1709354&r2=1709355&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelCubBezTo.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelCubBezTo.java Mon Oct 19 05:59:37 2015
@@ -25,103 +25,115 @@ import com.microsoft.schemas.office.visi
import com.microsoft.schemas.office.visio.x2012.main.RowType;
public class RelCubBezTo implements GeometryRow {
-
- RelCubBezTo _master = null;
-
- // The x-coordinate of the ending vertex of a cubic Bézier curve relative to the width of the shape.
- Double x = null;
-
- // The y-coordinate of the ending vertex of a cubic Bézier curve relative to the height of the shape.
- Double y = null;
-
- // The x-coordinate of the curveâs beginning control point relative to the shapeâs width; a point on the arc. The control point is best located between the beginning and ending vertices of the arc.
- Double a = null;
-
- // The y-coordinate of a curveâs beginning control point relative to the shapeâs height.
- Double b = null;
-
- // The x-coordinate of the curveâs ending control point relative to the shapeâs width; a point on the arc. The control point is best located between the beginning control point and ending vertices of the arc.
- Double c = null;
-
- // The y-coordinate of a curve's ending control point relative to the shapeâs height.
- Double d = null;
-
- Boolean deleted = null;
-
- // TODO: support formulas
-
- public RelCubBezTo(RowType row) {
-
- if (row.isSetDel()) deleted = row.getDel();
-
- for (CellType cell: row.getCellArray()) {
- String cellName = cell.getN();
-
- if (cellName.equals("X")) {
- x = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("Y")) {
- y = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("A")) {
- a = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("B")) {
- b = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("C")) {
- c = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("D")) {
- d = XDGFCell.parseDoubleValue(cell);
- } else {
- throw new POIXMLException("Invalid cell '" + cellName + "' in RelCubBezTo row");
- }
- }
- }
-
- public boolean getDel() {
- if (deleted != null)
- return deleted;
-
- if (_master != null)
- return _master.getDel();
-
- return false;
- }
-
- public Double getX() {
- return x == null ? _master.x : x;
- }
-
- public Double getY() {
- return y == null ? _master.y : y;
- }
-
- public Double getA() {
- return a == null ? _master.a : a;
- }
-
- public Double getB() {
- return b == null ? _master.b : b;
- }
-
- public Double getC() {
- return c == null ? _master.c : c;
- }
-
- public Double getD() {
- return d == null ? _master.d : d;
- }
-
- @Override
- public void setupMaster(GeometryRow row) {
- _master = (RelCubBezTo) row;
- }
-
- @Override
- public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
-
- if (getDel()) return;
-
- double w = parent.getWidth();
- double h = parent.getHeight();
-
- path.curveTo(getA()*w, getB()*h, getC()*w, getD()*h, getX()*w, getY()*h);
- }
+
+ RelCubBezTo _master = null;
+
+ // The x-coordinate of the ending vertex of a cubic Bezier curve relative to
+ // the width of the shape.
+ Double x = null;
+
+ // The y-coordinate of the ending vertex of a cubic Bezier curve relative to
+ // the height of the shape.
+ Double y = null;
+
+ // The x-coordinate of the curve's beginning control point relative to the
+ // shape's width; a point on the arc. The control point is best located
+ // between the beginning and ending vertices of the arc.
+ Double a = null;
+
+ // The y-coordinate of a curve's beginning control point relative to the
+ // shape's height.
+ Double b = null;
+
+ // The x-coordinate of the curve's ending control point relative to the
+ // shape's width; a point on the arc. The control point is best located
+ // between the beginning control point and ending vertices of the arc.
+ Double c = null;
+
+ // The y-coordinate of a curve's ending control point relative to the
+ // shape's height.
+ Double d = null;
+
+ Boolean deleted = null;
+
+ // TODO: support formulas
+
+ public RelCubBezTo(RowType row) {
+
+ if (row.isSetDel())
+ deleted = row.getDel();
+
+ for (CellType cell : row.getCellArray()) {
+ String cellName = cell.getN();
+
+ if (cellName.equals("X")) {
+ x = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("Y")) {
+ y = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("A")) {
+ a = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("B")) {
+ b = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("C")) {
+ c = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("D")) {
+ d = XDGFCell.parseDoubleValue(cell);
+ } else {
+ throw new POIXMLException("Invalid cell '" + cellName
+ + "' in RelCubBezTo row");
+ }
+ }
+ }
+
+ public boolean getDel() {
+ if (deleted != null)
+ return deleted;
+
+ if (_master != null)
+ return _master.getDel();
+
+ return false;
+ }
+
+ public Double getX() {
+ return x == null ? _master.x : x;
+ }
+
+ public Double getY() {
+ return y == null ? _master.y : y;
+ }
+
+ public Double getA() {
+ return a == null ? _master.a : a;
+ }
+
+ public Double getB() {
+ return b == null ? _master.b : b;
+ }
+
+ public Double getC() {
+ return c == null ? _master.c : c;
+ }
+
+ public Double getD() {
+ return d == null ? _master.d : d;
+ }
+
+ @Override
+ public void setupMaster(GeometryRow row) {
+ _master = (RelCubBezTo) row;
+ }
+
+ @Override
+ public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+
+ if (getDel())
+ return;
+
+ double w = parent.getWidth();
+ double h = parent.getHeight();
+
+ path.curveTo(getA() * w, getB() * h, getC() * w, getD() * h,
+ getX() * w, getY() * h);
+ }
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelEllipticalArcTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelEllipticalArcTo.java?rev=1709355&r1=1709354&r2=1709355&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelEllipticalArcTo.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelEllipticalArcTo.java Mon Oct 19 05:59:37 2015
@@ -25,117 +25,120 @@ import com.microsoft.schemas.office.visi
import com.microsoft.schemas.office.visio.x2012.main.RowType;
public class RelEllipticalArcTo implements GeometryRow {
-
- RelEllipticalArcTo _master = null;
-
- // The x-coordinate of the ending vertex on an arc relative to the width of
- // the shape.
- Double x = null;
-
- // The y-coordinate of the ending vertex on an arc relative to the height of
- // the shape.
- Double y = null;
-
- // The x-coordinate of the arc's control point relative to the shapeâs
- // width; a point on the arc.
- Double a = null;
-
- // The y-coordinate of an arc's control point relative to the shapeâs width.
- Double b = null;
-
- // The angle of an arc's major axis relative to the x-axis of its parent.
- Double c = null;
-
- // The ratio of an arc's major axis to its minor axis. Despite the usual
- // meaning of these words, the "major" axis does not have to be greater than
- // the "minor" axis, so this ratio does not have to be greater than 1.
- Double d = null;
-
- Boolean deleted = null;
-
- // TODO: support formulas
-
- public RelEllipticalArcTo(RowType row) {
-
- if (row.isSetDel()) deleted = row.getDel();
-
- for (CellType cell: row.getCellArray()) {
- String cellName = cell.getN();
-
- if (cellName.equals("X")) {
- x = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("Y")) {
- y = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("A")) {
- a = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("B")) {
- b = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("C")) {
- c = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("D")) {
- d = XDGFCell.parseDoubleValue(cell);
- } else {
- throw new POIXMLException("Invalid cell '" + cellName + "' in RelEllipticalArcTo row");
- }
- }
- }
-
- public boolean getDel() {
- if (deleted != null)
- return deleted;
-
- if (_master != null)
- return _master.getDel();
-
- return false;
- }
-
- public Double getX() {
- return x == null ? _master.x : x;
- }
-
- public Double getY() {
- return y == null ? _master.y : y;
- }
-
- public Double getA() {
- return a == null ? _master.a : a;
- }
-
- public Double getB() {
- return b == null ? _master.b : b;
- }
-
- public Double getC() {
- return c == null ? _master.c : c;
- }
-
- public Double getD() {
- return d == null ? _master.d : d;
- }
-
- @Override
- public void setupMaster(GeometryRow row) {
- _master = (RelEllipticalArcTo) row;
- }
-
- @Override
- public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
-
- if (getDel()) return;
-
- double w = parent.getWidth();
- double h = parent.getHeight();
-
- // intentionally shadowing variables here
- double x = getX()*w;
- double y = getY()*h;
- double a = getA()*w;
- double b = getB()*h;
- double c = getC();
- double d = getD();
-
- EllipticalArcTo.createEllipticalArc(x, y, a, b, c, d, path);
-
- }
+
+ RelEllipticalArcTo _master = null;
+
+ // The x-coordinate of the ending vertex on an arc relative to the width of
+ // the shape.
+ Double x = null;
+
+ // The y-coordinate of the ending vertex on an arc relative to the height of
+ // the shape.
+ Double y = null;
+
+ // The x-coordinate of the arc's control point relative to the shape's
+ // width; a point on the arc.
+ Double a = null;
+
+ // The y-coordinate of an arc's control point relative to the shape's width.
+ Double b = null;
+
+ // The angle of an arc's major axis relative to the x-axis of its parent.
+ Double c = null;
+
+ // The ratio of an arc's major axis to its minor axis. Despite the usual
+ // meaning of these words, the "major" axis does not have to be greater than
+ // the "minor" axis, so this ratio does not have to be greater than 1.
+ Double d = null;
+
+ Boolean deleted = null;
+
+ // TODO: support formulas
+
+ public RelEllipticalArcTo(RowType row) {
+
+ if (row.isSetDel())
+ deleted = row.getDel();
+
+ for (CellType cell : row.getCellArray()) {
+ String cellName = cell.getN();
+
+ if (cellName.equals("X")) {
+ x = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("Y")) {
+ y = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("A")) {
+ a = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("B")) {
+ b = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("C")) {
+ c = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("D")) {
+ d = XDGFCell.parseDoubleValue(cell);
+ } else {
+ throw new POIXMLException("Invalid cell '" + cellName
+ + "' in RelEllipticalArcTo row");
+ }
+ }
+ }
+
+ public boolean getDel() {
+ if (deleted != null)
+ return deleted;
+
+ if (_master != null)
+ return _master.getDel();
+
+ return false;
+ }
+
+ public Double getX() {
+ return x == null ? _master.x : x;
+ }
+
+ public Double getY() {
+ return y == null ? _master.y : y;
+ }
+
+ public Double getA() {
+ return a == null ? _master.a : a;
+ }
+
+ public Double getB() {
+ return b == null ? _master.b : b;
+ }
+
+ public Double getC() {
+ return c == null ? _master.c : c;
+ }
+
+ public Double getD() {
+ return d == null ? _master.d : d;
+ }
+
+ @Override
+ public void setupMaster(GeometryRow row) {
+ _master = (RelEllipticalArcTo) row;
+ }
+
+ @Override
+ public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+
+ if (getDel())
+ return;
+
+ double w = parent.getWidth();
+ double h = parent.getHeight();
+
+ // intentionally shadowing variables here
+ double x = getX() * w;
+ double y = getY() * h;
+ double a = getA() * w;
+ double b = getB() * h;
+ double c = getC();
+ double d = getD();
+
+ EllipticalArcTo.createEllipticalArc(x, y, a, b, c, d, path);
+
+ }
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelLineTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelLineTo.java?rev=1709355&r1=1709354&r2=1709355&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelLineTo.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelLineTo.java Mon Oct 19 05:59:37 2015
@@ -26,65 +26,67 @@ import com.microsoft.schemas.office.visi
/**
* Contains x-and y-coordinates of the ending vertex of a straight line segment
- * relative to a shapeâs width and height.
+ * relative to a shape's width and height.
*/
public class RelLineTo implements GeometryRow {
-
- RelLineTo _master = null;
-
- Double x = null;
- Double y = null;
-
- Boolean deleted = null;
-
- // TODO: support formulas
-
- public RelLineTo(RowType row) {
-
- if (row.isSetDel()) deleted = row.getDel();
-
- for (CellType cell: row.getCellArray()) {
- String cellName = cell.getN();
-
- if (cellName.equals("X")) {
- x = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("Y")) {
- y = XDGFCell.parseDoubleValue(cell);
- } else {
- throw new POIXMLException("Invalid cell '" + cellName + "' in RelLineTo row");
- }
- }
- }
-
- public boolean getDel() {
- if (deleted != null)
- return deleted;
-
- if (_master != null)
- return _master.getDel();
-
- return false;
- }
-
- public Double getX() {
- return x == null ? _master.x : x;
- }
-
- public Double getY() {
- return y == null ? _master.y : y;
- }
-
- @Override
- public void setupMaster(GeometryRow row) {
- _master = (RelLineTo) row;
- }
-
- @Override
- public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
-
- if (getDel()) return;
-
- path.lineTo(getX()*parent.getWidth(),
- getY()*parent.getHeight());
- }
+
+ RelLineTo _master = null;
+
+ Double x = null;
+ Double y = null;
+
+ Boolean deleted = null;
+
+ // TODO: support formulas
+
+ public RelLineTo(RowType row) {
+
+ if (row.isSetDel())
+ deleted = row.getDel();
+
+ for (CellType cell : row.getCellArray()) {
+ String cellName = cell.getN();
+
+ if (cellName.equals("X")) {
+ x = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("Y")) {
+ y = XDGFCell.parseDoubleValue(cell);
+ } else {
+ throw new POIXMLException("Invalid cell '" + cellName
+ + "' in RelLineTo row");
+ }
+ }
+ }
+
+ public boolean getDel() {
+ if (deleted != null)
+ return deleted;
+
+ if (_master != null)
+ return _master.getDel();
+
+ return false;
+ }
+
+ public Double getX() {
+ return x == null ? _master.x : x;
+ }
+
+ public Double getY() {
+ return y == null ? _master.y : y;
+ }
+
+ @Override
+ public void setupMaster(GeometryRow row) {
+ _master = (RelLineTo) row;
+ }
+
+ @Override
+ public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+
+ if (getDel())
+ return;
+
+ path.lineTo(getX() * parent.getWidth(), getY() * parent.getHeight());
+ }
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelMoveTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelMoveTo.java?rev=1709355&r1=1709354&r2=1709355&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelMoveTo.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelMoveTo.java Mon Oct 19 05:59:37 2015
@@ -25,62 +25,64 @@ import com.microsoft.schemas.office.visi
import com.microsoft.schemas.office.visio.x2012.main.RowType;
public class RelMoveTo implements GeometryRow {
-
- RelMoveTo _master = null;
-
- Double x = null;
- Double y = null;
-
- Boolean deleted = null;
-
- // TODO: support formulas
-
- public RelMoveTo(RowType row) {
-
- if (row.isSetDel()) deleted = row.getDel();
-
- for (CellType cell: row.getCellArray()) {
- String cellName = cell.getN();
-
- if (cellName.equals("X")) {
- x = XDGFCell.parseDoubleValue(cell);
- } else if (cellName.equals("Y")) {
- y = XDGFCell.parseDoubleValue(cell);
- } else {
- throw new POIXMLException("Invalid cell '" + cellName + "' in RelMoveTo row");
- }
- }
- }
-
- public boolean getDel() {
- if (deleted != null)
- return deleted;
-
- if (_master != null)
- return _master.getDel();
-
- return false;
- }
-
- public Double getX() {
- return x == null ? _master.x : x;
- }
-
- public Double getY() {
- return y == null ? _master.y : y;
- }
-
- @Override
- public void setupMaster(GeometryRow row) {
- _master = (RelMoveTo) row;
- }
-
- @Override
- public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
-
- if (getDel()) return;
-
- path.moveTo(getX()*parent.getWidth(),
- getY()*parent.getHeight());
- }
+
+ RelMoveTo _master = null;
+
+ Double x = null;
+ Double y = null;
+
+ Boolean deleted = null;
+
+ // TODO: support formulas
+
+ public RelMoveTo(RowType row) {
+
+ if (row.isSetDel())
+ deleted = row.getDel();
+
+ for (CellType cell : row.getCellArray()) {
+ String cellName = cell.getN();
+
+ if (cellName.equals("X")) {
+ x = XDGFCell.parseDoubleValue(cell);
+ } else if (cellName.equals("Y")) {
+ y = XDGFCell.parseDoubleValue(cell);
+ } else {
+ throw new POIXMLException("Invalid cell '" + cellName
+ + "' in RelMoveTo row");
+ }
+ }
+ }
+
+ public boolean getDel() {
+ if (deleted != null)
+ return deleted;
+
+ if (_master != null)
+ return _master.getDel();
+
+ return false;
+ }
+
+ public Double getX() {
+ return x == null ? _master.x : x;
+ }
+
+ public Double getY() {
+ return y == null ? _master.y : y;
+ }
+
+ @Override
+ public void setupMaster(GeometryRow row) {
+ _master = (RelMoveTo) row;
+ }
+
+ @Override
+ public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+
+ if (getDel())
+ return;
+
+ path.moveTo(getX() * parent.getWidth(), getY() * parent.getHeight());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org