public class FreeformFinSet extends FinSet {
private static final LogHelper log = Application.getLogger();
private static final Translator trans = Application.getTranslator();
-
+
private ArrayList<Coordinate> points = new ArrayList<Coordinate>();
public FreeformFinSet() {
public FreeformFinSet(FinSet finset) {
Coordinate[] finpoints = finset.getFinPoints();
this.copyFrom(finset);
-
+
points.clear();
for (Coordinate c: finpoints) {
points.add(c);
* inserted in its stead.
* <p>
* The specified fin set should not be used after the call!
- *
+ *
* @param finset the fin set to convert.
* @return the new freeform fin set.
*/
/**
* Add a fin point between indices <code>index-1</code> and <code>index</code>.
* The point is placed at the midpoint of the current segment.
- *
+ *
* @param index the fin point before which to add the new point.
*/
public void addPoint(int index) {
* Remove the fin point with the given index. The first and last fin points
* cannot be removed, and will cause an <code>IllegalFinPointException</code>
* if attempted.
- *
+ *
* @param index the fin point index to remove
* @throws IllegalFinPointException if removing would result in invalid fin planform
*/
* Set the point at position <code>i</code> to coordinates (x,y).
* <p>
* Note that this method enforces basic fin shape restrictions (non-negative y,
- * first and last point locations) silently, but throws an
+ * first and last point locations) silently, but throws an
* <code>IllegalFinPointException</code> if the point causes fin segments to
* intersect.
* <p>
* Moving of the first point in the X-axis is allowed, but this actually moves
* all of the other points the corresponding distance back.
- *
+ *
* @param index the point index to modify.
* @param x the x-coordinate.
* @param y the y-coordinate.
return c;
}
- /**
- * Accept a visitor to this FreeformFinSet in the component hierarchy.
- *
- * @param theVisitor the visitor that will be called back with a reference to this FreeformFinSet
- */
- @Override
- public void accept(ComponentVisitor theVisitor) {
- theVisitor.visit(this);
- }
-
- private void validate(ArrayList<Coordinate> points) throws IllegalFinPointException {
- final int n = points.size();
- if (points.get(0).x != 0 || points.get(0).y != 0 ||
- points.get(n - 1).x < 0 || points.get(n - 1).y != 0) {
+ private void validate(ArrayList<Coordinate> pts) throws IllegalFinPointException {
+ final int n = pts.size();
+ if (pts.get(0).x != 0 || pts.get(0).y != 0 ||
+ pts.get(n - 1).x < 0 || pts.get(n - 1).y != 0) {
throw new IllegalFinPointException("Start or end point illegal.");
}
for (int i = 0; i < n - 1; i++) {
for (int j = i + 2; j < n - 1; j++) {
- if (intersects(points.get(i).x, points.get(i).y, points.get(i + 1).x, points.get(i + 1).y,
- points.get(j).x, points.get(j).y, points.get(j + 1).x, points.get(j + 1).y)) {
+ if (intersects(pts.get(i).x, pts.get(i).y, pts.get(i + 1).x, pts.get(i + 1).y,
+ pts.get(j).x, pts.get(j).y, pts.get(j + 1).x, pts.get(j + 1).y)) {
throw new IllegalFinPointException("segments intersect");
}
}
- if (points.get(i).z != 0) {
+ if (pts.get(i).z != 0) {
throw new IllegalFinPointException("z-coordinate not zero");
}
}