Revision 42441 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/primitive/curve/periellipse/PeriEllipse2D.java
PeriEllipse2D.java | ||
---|---|---|
23 | 23 |
package org.gvsig.fmap.geom.jts.primitive.curve.periellipse; |
24 | 24 |
|
25 | 25 |
import org.gvsig.fmap.geom.Geometry; |
26 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
27 |
import org.gvsig.fmap.geom.GeometryManager; |
|
28 |
import org.gvsig.fmap.geom.jts.primitive.point.Point2D; |
|
26 | 29 |
import org.gvsig.fmap.geom.jts.primitive.surface.ellipse.BaseEllipse2D; |
27 | 30 |
import org.gvsig.fmap.geom.jts.util.ArrayListCoordinateSequence; |
28 | 31 |
import org.gvsig.fmap.geom.jts.util.JTSUtils; |
32 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
33 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
34 |
import org.gvsig.fmap.geom.primitive.Ellipse; |
|
29 | 35 |
import org.gvsig.fmap.geom.primitive.PeriEllipse; |
30 | 36 |
import org.gvsig.fmap.geom.primitive.Point; |
31 | 37 |
|
... | ... | |
75 | 81 |
throw new UnsupportedOperationException(message); |
76 | 82 |
} |
77 | 83 |
|
84 |
|
|
85 |
/* (non-Javadoc) |
|
86 |
* @see org.gvsig.fmap.geom.Geometry#offset(double) |
|
87 |
*/ |
|
88 |
public Geometry offset(double distance) throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
89 |
PeriEllipse clonedEllipse = (PeriEllipse) this.cloneGeometry(); |
|
90 |
|
|
91 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
92 |
Point center = new Point2D((getAxis1Start().getX()+getAxis1End().getX())/2, |
|
93 |
(getAxis1Start().getY()+getAxis1End().getY())/2); |
|
94 |
double axis1Lenght = getAxis1Start().distance(getAxis1End()); |
|
95 |
|
|
96 |
Point clonedAxis1Start = (Point) getAxis1Start().cloneGeometry(); |
|
97 |
Point clonedAxis1End = (Point) getAxis1End().cloneGeometry(); |
|
98 |
double clonedYDist = this.ydist+distance; |
|
99 |
|
|
100 |
clonedAxis1Start.setX(JTSUtils.straightLineThroughTwoPointsEquation(0, axis1Lenght/2, center.getX(), getAxis1Start().getX(), axis1Lenght/2+distance)); |
|
101 |
clonedAxis1Start.setY(JTSUtils.straightLineThroughTwoPointsEquation(0, axis1Lenght/2, center.getY(), getAxis1Start().getY(), axis1Lenght/2+distance)); |
|
102 |
|
|
103 |
clonedAxis1End.setX(JTSUtils.straightLineThroughTwoPointsEquation(0, axis1Lenght/2, center.getX(), getAxis1End().getX(), axis1Lenght/2+distance)); |
|
104 |
clonedAxis1End.setY(JTSUtils.straightLineThroughTwoPointsEquation(0, axis1Lenght/2, center.getY(), getAxis1End().getY(), axis1Lenght/2+distance)); |
|
105 |
|
|
106 |
clonedEllipse.setPoints(clonedAxis1Start, clonedAxis1End, clonedYDist); |
|
107 |
return clonedEllipse; |
|
108 |
} |
|
109 |
|
|
78 | 110 |
} |
Also available in: Unified diff