### Eclipse Workspace Patch 1.0
#P org.eclipse.draw2d
Index: src/org/eclipse/draw2d/FanRouter.java
===================================================================
RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/FanRouter.java,v
retrieving revision 1.11
diff -u -r1.11 FanRouter.java
--- src/org/eclipse/draw2d/FanRouter.java 30 Mar 2005 21:27:45 -0000 1.11
+++ src/org/eclipse/draw2d/FanRouter.java 3 May 2010 19:12:49 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,78 +12,82 @@
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.draw2d.geometry.Ray;
+import org.eclipse.draw2d.geometry.PrecisionPoint;
+import org.eclipse.draw2d.geometry.Vector;
/**
- * Automatic router that spreads its {@link Connection Connections} in a fan-like fashion
- * upon collision.
+ * Automatic router that spreads its {@link Connection Connections} in a
+ * fan-like fashion upon collision.
*/
-public class FanRouter
- extends AutomaticRouter
-{
+public class FanRouter extends AutomaticRouter {
-private int separation = 10;
+ private int separation = 10;
-/**
- * Returns the separation in pixels between fanned connections.
- *
- * @return the separation
- * @since 2.0
- */
-public int getSeparation() {
- return separation;
-}
+ /**
+ * Returns the separation in pixels between fanned connections.
+ *
+ * @return the separation
+ * @since 2.0
+ */
+ public int getSeparation() {
+ return separation;
+ }
-/**
- * Modifies a given PointList that collides with some other PointList. The given
- * index indicates that this it the ith PointList in a group of
- * colliding points.
- *
- * @param points the colliding points
- * @param index the index
- */
-protected void handleCollision(PointList points, int index) {
- Point start = points.getFirstPoint();
- Point end = points.getLastPoint();
-
- if (start.equals(end))
- return;
-
- Point midPoint = new Point((end.x + start.x) / 2, (end.y + start.y) / 2);
- int position = end.getPosition(start);
- Ray ray;
- if (position == PositionConstants.SOUTH || position == PositionConstants.EAST)
- ray = new Ray(start, end);
- else
- ray = new Ray(end, start);
- double length = ray.length();
-
- double xSeparation = separation * ray.x / length;
- double ySeparation = separation * ray.y / length;
-
- Point bendPoint;
-
- if (index % 2 == 0) {
- bendPoint = new Point(
- midPoint.x + (index / 2) * (-1 * ySeparation),
- midPoint.y + (index / 2) * xSeparation);
- } else {
- bendPoint = new Point(
- midPoint.x + (index / 2) * ySeparation,
- midPoint.y + (index / 2) * (-1 * xSeparation));
+ /**
+ * Modifies a given PointList that collides with some other PointList. The
+ * given index indicates that this it the ith PointList in
+ * a group of colliding points.
+ *
+ * @param points
+ * the colliding points
+ * @param index
+ * the index
+ */
+ protected void handleCollision(PointList points, int index) {
+ Point start = points.getFirstPoint();
+ Point end = points.getLastPoint();
+
+ if (start.equals(end))
+ return;
+
+ Point midPoint = new Point((end.x + start.x) / 2, (end.y + start.y) / 2);
+ int position = end.getPosition(start);
+ Vector vector;
+ if (position == PositionConstants.SOUTH
+ || position == PositionConstants.EAST)
+ vector = new Vector(new PrecisionPoint(start), new PrecisionPoint(
+ end));
+ else
+ vector = new Vector(new PrecisionPoint(end), new PrecisionPoint(
+ start));
+ double length = vector.getLength();
+
+ double xSeparation = separation * vector.x / length;
+ double ySeparation = separation * vector.y / length;
+
+ Point bendPoint;
+
+ if (index % 2 == 0) {
+ bendPoint = new Point(
+ midPoint.x + (index / 2) * (-1 * ySeparation), midPoint.y
+ + (index / 2) * xSeparation);
+ } else {
+ bendPoint = new Point(midPoint.x + (index / 2) * ySeparation,
+ midPoint.y + (index / 2) * (-1 * xSeparation));
+ }
+ if (!bendPoint.equals(midPoint))
+ points.insertPoint(bendPoint, 1);
}
- if (!bendPoint.equals(midPoint))
- points.insertPoint(bendPoint, 1);
-}
-/**
- * Sets the colliding {@link Connection Connection's} separation in pixels.
- *
- * @param value the separation
- * @since 2.0
- */
-public void setSeparation(int value) {
- separation = value;
-}
+ /**
+ * Sets the colliding {@link Connection Connection's} separation in pixels.
+ *
+ * @param value
+ * the separation
+ * @since 2.0
+ */
+ public void setSeparation(int value) {
+ separation = value;
+ }
-}
+}
\ No newline at end of file
Index: src/org/eclipse/draw2d/ManhattanConnectionRouter.java
===================================================================
RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/ManhattanConnectionRouter.java,v
retrieving revision 1.9
diff -u -r1.9 ManhattanConnectionRouter.java
--- src/org/eclipse/draw2d/ManhattanConnectionRouter.java 30 Mar 2005 21:27:45 -0000 1.9
+++ src/org/eclipse/draw2d/ManhattanConnectionRouter.java 3 May 2010 19:12:49 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,361 +17,365 @@
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.draw2d.geometry.Ray;
+import org.eclipse.draw2d.geometry.PrecisionPoint;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.draw2d.geometry.Vector;
/**
- * Provides a {@link Connection} with an orthogonal route between the Connection's source
- * and target anchors.
+ * Provides a {@link Connection} with an orthogonal route between the
+ * Connection's source and target anchors.
*/
-public final class ManhattanConnectionRouter
- extends AbstractRouter
-{
-
-private Map rowsUsed = new HashMap();
-private Map colsUsed = new HashMap();
-//private Hashtable offsets = new Hashtable(7);
-
-private Map reservedInfo = new HashMap();
-
-private class ReservedInfo {
- public List reservedRows = new ArrayList(2);
- public List reservedCols = new ArrayList(2);
-}
-
-private static Ray UP = new Ray(0, -1),
- DOWN = new Ray(0, 1),
- LEFT = new Ray(-1, 0),
- RIGHT = new Ray(1, 0);
+public final class ManhattanConnectionRouter extends AbstractRouter {
+ private Map rowsUsed = new HashMap();
+ private Map colsUsed = new HashMap();
+ // private Hashtable offsets = new Hashtable(7);
-/**
- * @see ConnectionRouter#invalidate(Connection)
- */
-public void invalidate(Connection connection) {
- removeReservedLines(connection);
-}
+ private Map reservedInfo = new HashMap();
-private int getColumnNear(Connection connection, int r, int n, int x) {
- int min = Math.min(n, x),
- max = Math.max(n, x);
- if (min > r) {
- max = min;
- min = r - (min - r);
- }
- if (max < r) {
- min = max;
- max = r + (r - max);
- }
- int proximity = 0;
- int direction = -1;
- if (r % 2 == 1)
- r--;
- Integer i;
- while (proximity < r) {
- i = new Integer(r + proximity * direction);
- if (!colsUsed.containsKey(i)) {
- colsUsed.put(i, i);
- reserveColumn(connection, i);
- return i.intValue();
- }
- int j = i.intValue();
- if (j <= min)
- return j + 2;
- if (j >= max)
- return j - 2;
- if (direction == 1)
- direction = -1;
- else {
- direction = 1;
- proximity += 2;
- }
+ private class ReservedInfo {
+ public List reservedRows = new ArrayList(2);
+ public List reservedCols = new ArrayList(2);
}
- return r;
-}
-/**
- * Returns the direction the point p is in relation to the given rectangle.
- * Possible values are LEFT (-1,0), RIGHT (1,0), UP (0,-1) and DOWN (0,1).
- *
- * @param r the rectangle
- * @param p the point
- * @return the direction from r to p
- */
-protected Ray getDirection(Rectangle r, Point p) {
- int i, distance = Math.abs(r.x - p.x);
- Ray direction;
-
- direction = LEFT;
+ private static Vector UP = new Vector(0, -1), DOWN = new Vector(0, 1),
+ LEFT = new Vector(-1, 0), RIGHT = new Vector(1, 0);
- i = Math.abs(r.y - p.y);
- if (i <= distance) {
- distance = i;
- direction = UP;
+ /**
+ * @see ConnectionRouter#invalidate(Connection)
+ */
+ public void invalidate(Connection connection) {
+ removeReservedLines(connection);
}
- i = Math.abs(r.bottom() - p.y);
- if (i <= distance) {
- distance = i;
- direction = DOWN;
+ private int getColumnNear(Connection connection, int r, int n, int x) {
+ int min = Math.min(n, x), max = Math.max(n, x);
+ if (min > r) {
+ max = min;
+ min = r - (min - r);
+ }
+ if (max < r) {
+ min = max;
+ max = r + (r - max);
+ }
+ int proximity = 0;
+ int direction = -1;
+ if (r % 2 == 1)
+ r--;
+ Integer i;
+ while (proximity < r) {
+ i = new Integer(r + proximity * direction);
+ if (!colsUsed.containsKey(i)) {
+ colsUsed.put(i, i);
+ reserveColumn(connection, i);
+ return i.intValue();
+ }
+ int j = i.intValue();
+ if (j <= min)
+ return j + 2;
+ if (j >= max)
+ return j - 2;
+ if (direction == 1)
+ direction = -1;
+ else {
+ direction = 1;
+ proximity += 2;
+ }
+ }
+ return r;
}
- i = Math.abs(r.right() - p.x);
- if (i < distance) {
- distance = i;
- direction = RIGHT;
- }
+ /**
+ * Returns the direction the point p is in relation to the given
+ * rectangle. Possible values are LEFT (-1,0), RIGHT (1,0), UP (0,-1) and
+ * DOWN (0,1).
+ *
+ * @param r
+ * the rectangle
+ * @param p
+ * the point
+ * @return the direction from r to p
+ */
+ protected Vector getDirection(Rectangle r, Point p) {
+ int i, distance = Math.abs(r.x - p.x);
+ Vector direction;
+
+ direction = LEFT;
+
+ i = Math.abs(r.y - p.y);
+ if (i <= distance) {
+ distance = i;
+ direction = UP;
+ }
- return direction;
-}
+ i = Math.abs(r.bottom() - p.y);
+ if (i <= distance) {
+ distance = i;
+ direction = DOWN;
+ }
-protected Ray getEndDirection(Connection conn) {
- ConnectionAnchor anchor = conn.getTargetAnchor();
- Point p = getEndPoint(conn);
- Rectangle rect;
- if (anchor.getOwner() == null)
- rect = new Rectangle(p.x - 1, p.y - 1, 2, 2);
- else {
- rect = conn.getTargetAnchor().getOwner().getBounds().getCopy();
- conn.getTargetAnchor().getOwner().translateToAbsolute(rect);
+ i = Math.abs(r.right() - p.x);
+ if (i < distance) {
+ distance = i;
+ direction = RIGHT;
+ }
+
+ return direction;
}
- return getDirection(rect, p);
-}
-protected int getRowNear(Connection connection, int r, int n, int x) {
- int min = Math.min(n, x),
- max = Math.max(n, x);
- if (min > r) {
- max = min;
- min = r - (min - r);
- }
- if (max < r) {
- min = max;
- max = r + (r - max);
- }
-
- int proximity = 0;
- int direction = -1;
- if (r % 2 == 1)
- r--;
- Integer i;
- while (proximity < r) {
- i = new Integer(r + proximity * direction);
- if (!rowsUsed.containsKey(i)) {
- rowsUsed.put(i, i);
- reserveRow(connection, i);
- return i.intValue();
- }
- int j = i.intValue();
- if (j <= min)
- return j + 2;
- if (j >= max)
- return j - 2;
- if (direction == 1)
- direction = -1;
+ protected Vector getEndDirection(Connection conn) {
+ ConnectionAnchor anchor = conn.getTargetAnchor();
+ Point p = getEndPoint(conn);
+ Rectangle rect;
+ if (anchor.getOwner() == null)
+ rect = new Rectangle(p.x - 1, p.y - 1, 2, 2);
else {
- direction = 1;
- proximity += 2;
+ rect = conn.getTargetAnchor().getOwner().getBounds().getCopy();
+ conn.getTargetAnchor().getOwner().translateToAbsolute(rect);
}
+ return getDirection(rect, p);
}
- return r;
-}
-
-protected Ray getStartDirection(Connection conn) {
- ConnectionAnchor anchor = conn.getSourceAnchor();
- Point p = getStartPoint(conn);
- Rectangle rect;
- if (anchor.getOwner() == null)
- rect = new Rectangle(p.x - 1, p.y - 1, 2, 2);
- else {
- rect = conn.getSourceAnchor().getOwner().getBounds().getCopy();
- conn.getSourceAnchor().getOwner().translateToAbsolute(rect);
- }
- return getDirection(rect, p);
-}
-protected void processPositions(Ray start, Ray end, List positions,
- boolean horizontal, Connection conn) {
- removeReservedLines(conn);
-
- int pos[] = new int[positions.size() + 2];
- if (horizontal)
- pos[0] = start.x;
- else
- pos[0] = start.y;
- int i;
- for (i = 0; i < positions.size(); i++) {
- pos[i + 1] = ((Integer)positions.get(i)).intValue();
- }
- if (horizontal == (positions.size() % 2 == 1))
- pos[++i] = end.x;
- else
- pos[++i] = end.y;
-
- PointList points = new PointList();
- points.addPoint(new Point(start.x, start.y));
- Point p;
- int current, prev, min, max;
- boolean adjust;
- for (i = 2; i < pos.length - 1; i++) {
- horizontal = !horizontal;
- prev = pos[i - 1];
- current = pos[i];
+ protected int getRowNear(Connection connection, int r, int n, int x) {
+ int min = Math.min(n, x), max = Math.max(n, x);
+ if (min > r) {
+ max = min;
+ min = r - (min - r);
+ }
+ if (max < r) {
+ min = max;
+ max = r + (r - max);
+ }
- adjust = (i != pos.length - 2);
- if (horizontal) {
- if (adjust) {
- min = pos[i - 2];
- max = pos[i + 2];
- pos[i] = current = getRowNear(conn, current, min, max);
+ int proximity = 0;
+ int direction = -1;
+ if (r % 2 == 1)
+ r--;
+ Integer i;
+ while (proximity < r) {
+ i = new Integer(r + proximity * direction);
+ if (!rowsUsed.containsKey(i)) {
+ rowsUsed.put(i, i);
+ reserveRow(connection, i);
+ return i.intValue();
}
- p = new Point(prev, current);
- } else {
- if (adjust) {
- min = pos[i - 2];
- max = pos[i + 2];
- pos[i] = current = getColumnNear(conn, current, min, max);
+ int j = i.intValue();
+ if (j <= min)
+ return j + 2;
+ if (j >= max)
+ return j - 2;
+ if (direction == 1)
+ direction = -1;
+ else {
+ direction = 1;
+ proximity += 2;
}
- p = new Point(current, prev);
}
- points.addPoint(p);
+ return r;
}
- points.addPoint(new Point(end.x, end.y));
- conn.setPoints(points);
-}
-/**
- * @see ConnectionRouter#remove(Connection)
- */
-public void remove(Connection connection) {
- removeReservedLines(connection);
-}
+ protected Vector getStartDirection(Connection conn) {
+ ConnectionAnchor anchor = conn.getSourceAnchor();
+ Point p = getStartPoint(conn);
+ Rectangle rect;
+ if (anchor.getOwner() == null)
+ rect = new Rectangle(p.x - 1, p.y - 1, 2, 2);
+ else {
+ rect = conn.getSourceAnchor().getOwner().getBounds().getCopy();
+ conn.getSourceAnchor().getOwner().translateToAbsolute(rect);
+ }
+ return getDirection(rect, p);
+ }
-protected void removeReservedLines(Connection connection) {
- ReservedInfo rInfo = (ReservedInfo) reservedInfo.get(connection);
- if (rInfo == null)
- return;
-
- for (int i = 0; i < rInfo.reservedRows.size(); i++) {
- rowsUsed.remove(rInfo.reservedRows.get(i));
+ protected void processPositions(Vector start, Vector end, List positions,
+ boolean horizontal, Connection conn) {
+ removeReservedLines(conn);
+
+ int pos[] = new int[positions.size() + 2];
+ if (horizontal)
+ pos[0] = (int) start.x;
+ else
+ pos[0] = (int) start.y;
+ int i;
+ for (i = 0; i < positions.size(); i++) {
+ pos[i + 1] = ((Integer) positions.get(i)).intValue();
+ }
+ if (horizontal == (positions.size() % 2 == 1))
+ pos[++i] = (int) end.x;
+ else
+ pos[++i] = (int) end.y;
+
+ PointList points = new PointList();
+ points.addPoint(new Point(start.x, start.y));
+ Point p;
+ int current, prev, min, max;
+ boolean adjust;
+ for (i = 2; i < pos.length - 1; i++) {
+ horizontal = !horizontal;
+ prev = pos[i - 1];
+ current = pos[i];
+
+ adjust = (i != pos.length - 2);
+ if (horizontal) {
+ if (adjust) {
+ min = pos[i - 2];
+ max = pos[i + 2];
+ pos[i] = current = getRowNear(conn, current, min, max);
+ }
+ p = new Point(prev, current);
+ } else {
+ if (adjust) {
+ min = pos[i - 2];
+ max = pos[i + 2];
+ pos[i] = current = getColumnNear(conn, current, min, max);
+ }
+ p = new Point(current, prev);
+ }
+ points.addPoint(p);
+ }
+ points.addPoint(new Point(end.x, end.y));
+ conn.setPoints(points);
}
- for (int i = 0; i < rInfo.reservedCols.size(); i++) {
- colsUsed.remove(rInfo.reservedCols.get(i));
+
+ /**
+ * @see ConnectionRouter#remove(Connection)
+ */
+ public void remove(Connection connection) {
+ removeReservedLines(connection);
}
- reservedInfo.remove(connection);
-}
-protected void reserveColumn(Connection connection, Integer column) {
- ReservedInfo info = (ReservedInfo) reservedInfo.get(connection);
- if (info == null) {
- info = new ReservedInfo();
- reservedInfo.put(connection, info);
+ protected void removeReservedLines(Connection connection) {
+ ReservedInfo rInfo = (ReservedInfo) reservedInfo.get(connection);
+ if (rInfo == null)
+ return;
+
+ for (int i = 0; i < rInfo.reservedRows.size(); i++) {
+ rowsUsed.remove(rInfo.reservedRows.get(i));
+ }
+ for (int i = 0; i < rInfo.reservedCols.size(); i++) {
+ colsUsed.remove(rInfo.reservedCols.get(i));
+ }
+ reservedInfo.remove(connection);
}
- info.reservedCols.add(column);
-}
-protected void reserveRow(Connection connection, Integer row) {
- ReservedInfo info = (ReservedInfo) reservedInfo.get(connection);
- if (info == null) {
- info = new ReservedInfo();
- reservedInfo.put(connection, info);
+ protected void reserveColumn(Connection connection, Integer column) {
+ ReservedInfo info = (ReservedInfo) reservedInfo.get(connection);
+ if (info == null) {
+ info = new ReservedInfo();
+ reservedInfo.put(connection, info);
+ }
+ info.reservedCols.add(column);
}
- info.reservedRows.add(row);
-}
-/**
- * @see ConnectionRouter#route(Connection)
- */
-public void route(Connection conn) {
- if ((conn.getSourceAnchor() == null) || (conn.getTargetAnchor() == null))
- return;
- int i;
- Point startPoint = getStartPoint(conn);
- conn.translateToRelative(startPoint);
- Point endPoint = getEndPoint(conn);
- conn.translateToRelative(endPoint);
-
- Ray start = new Ray(startPoint);
- Ray end = new Ray(endPoint);
- Ray average = start.getAveraged(end);
-
- Ray direction = new Ray(start, end);
- Ray startNormal = getStartDirection(conn);
- Ray endNormal = getEndDirection(conn);
-
- List positions = new ArrayList(5);
- boolean horizontal = startNormal.isHorizontal();
- if (horizontal)
- positions.add(new Integer(start.y));
- else
- positions.add(new Integer(start.x));
- horizontal = !horizontal;
-
- if (startNormal.dotProduct(endNormal) == 0) {
- if ((startNormal.dotProduct(direction) >= 0)
- && (endNormal.dotProduct(direction) <= 0)) {
- // 0
- } else {
- // 2
- if (startNormal.dotProduct(direction) < 0)
- i = startNormal.similarity(start.getAdded(startNormal.getScaled(10)));
- else {
- if (horizontal)
- i = average.y;
- else
- i = average.x;
- }
- positions.add(new Integer(i));
- horizontal = !horizontal;
+ protected void reserveRow(Connection connection, Integer row) {
+ ReservedInfo info = (ReservedInfo) reservedInfo.get(connection);
+ if (info == null) {
+ info = new ReservedInfo();
+ reservedInfo.put(connection, info);
+ }
+ info.reservedRows.add(row);
+ }
- if (endNormal.dotProduct(direction) > 0)
- i = endNormal.similarity(end.getAdded(endNormal.getScaled(10)));
- else {
- if (horizontal)
- i = average.y;
- else
- i = average.x;
+ /**
+ * @see ConnectionRouter#route(Connection)
+ */
+ public void route(Connection conn) {
+ if ((conn.getSourceAnchor() == null)
+ || (conn.getTargetAnchor() == null))
+ return;
+ int i;
+ Point startPoint = getStartPoint(conn);
+ conn.translateToRelative(startPoint);
+ Point endPoint = getEndPoint(conn);
+ conn.translateToRelative(endPoint);
+
+ Vector start = new Vector(new PrecisionPoint(startPoint));
+ Vector end = new Vector(new PrecisionPoint(endPoint));
+ Vector average = start.getAveraged(end);
+
+ Vector direction = new Vector(start, end);
+ Vector startNormal = getStartDirection(conn);
+ Vector endNormal = getEndDirection(conn);
+
+ List positions = new ArrayList(5);
+ boolean horizontal = startNormal.isHorizontal();
+ if (horizontal)
+ positions.add(new Integer((int) start.y));
+ else
+ positions.add(new Integer((int) start.x));
+ horizontal = !horizontal;
+
+ if (startNormal.getDotProduct(endNormal) == 0) {
+ if ((startNormal.getDotProduct(direction) >= 0)
+ && (endNormal.getDotProduct(direction) <= 0)) {
+ // 0
+ } else {
+ // 2
+ if (startNormal.getDotProduct(direction) < 0)
+ i = (int) startNormal.getSimilarity(start
+ .getAdded(startNormal.getMultiplied(10)));
+ else {
+ if (horizontal)
+ i = (int) average.y;
+ else
+ i = (int) average.x;
+ }
+ positions.add(new Integer(i));
+ horizontal = !horizontal;
+
+ if (endNormal.getDotProduct(direction) > 0)
+ i = (int) endNormal.getSimilarity(end.getAdded(endNormal
+ .getMultiplied(10)));
+ else {
+ if (horizontal)
+ i = (int) average.y;
+ else
+ i = (int) average.x;
+ }
+ positions.add(new Integer(i));
+ horizontal = !horizontal;
}
- positions.add(new Integer(i));
- horizontal = !horizontal;
- }
- } else {
- if (startNormal.dotProduct(endNormal) > 0) {
- //1
- if (startNormal.dotProduct(direction) >= 0)
- i = startNormal.similarity(start.getAdded(startNormal.getScaled(10)));
- else
- i = endNormal.similarity(end.getAdded(endNormal.getScaled(10)));
- positions.add(new Integer(i));
- horizontal = !horizontal;
} else {
- //3 or 1
- if (startNormal.dotProduct(direction) < 0) {
- i = startNormal.similarity(start.getAdded(startNormal.getScaled(10)));
+ if (startNormal.getDotProduct(endNormal) > 0) {
+ // 1
+ if (startNormal.getDotProduct(direction) >= 0)
+ i = (int) startNormal.getSimilarity(start
+ .getAdded(startNormal.getMultiplied(10)));
+ else
+ i = (int) endNormal.getSimilarity(end.getAdded(endNormal
+ .getMultiplied(10)));
positions.add(new Integer(i));
horizontal = !horizontal;
- }
-
- if (horizontal)
- i = average.y;
- else
- i = average.x;
- positions.add(new Integer(i));
- horizontal = !horizontal;
-
- if (startNormal.dotProduct(direction) < 0) {
- i = endNormal.similarity(end.getAdded(endNormal.getScaled(10)));
+ } else {
+ // 3 or 1
+ if (startNormal.getDotProduct(direction) < 0) {
+ i = (int) startNormal.getSimilarity(start
+ .getAdded(startNormal.getMultiplied(10)));
+ positions.add(new Integer(i));
+ horizontal = !horizontal;
+ }
+
+ if (horizontal)
+ i = (int) average.y;
+ else
+ i = (int) average.x;
positions.add(new Integer(i));
horizontal = !horizontal;
+
+ if (startNormal.getDotProduct(direction) < 0) {
+ i = (int) endNormal.getSimilarity(end.getAdded(endNormal
+ .getMultiplied(10)));
+ positions.add(new Integer(i));
+ horizontal = !horizontal;
+ }
}
}
+ if (horizontal)
+ positions.add(new Integer((int) end.y));
+ else
+ positions.add(new Integer((int) end.x));
+
+ processPositions(start, end, positions, startNormal.x > 0, conn);
}
- if (horizontal)
- positions.add(new Integer(end.y));
- else
- positions.add(new Integer(end.x));
-
- processPositions(start, end, positions, startNormal.isHorizontal(), conn);
-}
}