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/surface/ellipse/Ellipse2D.java
Ellipse2D.java | ||
---|---|---|
25 | 25 |
import java.awt.geom.AffineTransform; |
26 | 26 |
|
27 | 27 |
import org.gvsig.fmap.geom.Geometry; |
28 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
29 |
import org.gvsig.fmap.geom.GeometryManager; |
|
28 | 30 |
import org.gvsig.fmap.geom.jts.primitive.point.Point2D; |
29 | 31 |
import org.gvsig.fmap.geom.jts.util.ArrayListCoordinateSequence; |
30 | 32 |
import org.gvsig.fmap.geom.jts.util.JTSUtils; |
33 |
import org.gvsig.fmap.geom.jts.util.UtilFunctions; |
|
31 | 34 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
32 | 35 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
33 | 36 |
import org.gvsig.fmap.geom.primitive.Ellipse; |
... | ... | |
104 | 107 |
return AffineTransform.getRotateInstance(getAxis1Angle(), this.getAxis1Start().getX(), this.getAxis1Start().getY()); |
105 | 108 |
} |
106 | 109 |
|
110 |
/* (non-Javadoc) |
|
111 |
* @see org.gvsig.fmap.geom.Geometry#offset(double) |
|
112 |
*/ |
|
113 |
public Geometry offset(double distance) throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
114 |
Ellipse clonedEllipse = (Ellipse) this.cloneGeometry(); |
|
115 |
|
|
116 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
117 |
Point center = new Point2D((getAxis1Start().getX()+getAxis1End().getX())/2, |
|
118 |
(getAxis1Start().getY()+getAxis1End().getY())/2); |
|
119 |
double axis1Lenght = getAxis1Start().distance(getAxis1End()); |
|
120 |
|
|
121 |
Point clonedAxis1Start = (Point) getAxis1Start().cloneGeometry(); |
|
122 |
Point clonedAxis1End = (Point) getAxis1End().cloneGeometry(); |
|
123 |
double clonedYDist = this.ydist+distance; |
|
124 |
|
|
125 |
clonedAxis1Start.setX(JTSUtils.straightLineThroughTwoPointsEquation(0, axis1Lenght/2, center.getX(), getAxis1Start().getX(), axis1Lenght/2+distance)); |
|
126 |
clonedAxis1Start.setY(JTSUtils.straightLineThroughTwoPointsEquation(0, axis1Lenght/2, center.getY(), getAxis1Start().getY(), axis1Lenght/2+distance)); |
|
127 |
|
|
128 |
clonedAxis1End.setX(JTSUtils.straightLineThroughTwoPointsEquation(0, axis1Lenght/2, center.getX(), getAxis1End().getX(), axis1Lenght/2+distance)); |
|
129 |
clonedAxis1End.setY(JTSUtils.straightLineThroughTwoPointsEquation(0, axis1Lenght/2, center.getY(), getAxis1End().getY(), axis1Lenght/2+distance)); |
|
130 |
|
|
131 |
clonedEllipse.setPoints(clonedAxis1Start, clonedAxis1End, clonedYDist); |
|
132 |
return clonedEllipse; |
|
133 |
} |
|
107 | 134 |
} |
Also available in: Unified diff