}
public Rectangle2D getTerminalShape() {
- double pickDist = pointerInteractor.getPickDistance();
+ double pickDist = pointerInteractor.getTerminalPickDistance();
return new Rectangle2D.Double(-pickDist - 0.5, -pickDist - 0.5, pickDist * 2 + 1, pickDist * 2 + 1);
}
public Rectangle2D getPickRectangle(double x, double y) {
- double pickDist = pointerInteractor.getPickDistance();
- Rectangle2D controlPickRect = new Rectangle2D.Double(x-pickDist, y-pickDist, pickDist*2+1, pickDist*2+1);
+ double pickDist = pointerInteractor.getTerminalPickDistance();
+ Rectangle2D controlPickRect = new Rectangle2D.Double(x-pickDist, y-pickDist, pickDist*2, pickDist*2);
return controlPickRect;
}
public class PointerInteractor extends AbstractDiagramParticipant {
/**
- * A hint key for terminal pick distance in control pixels.
+ * Hint keys for pick distances in control pixels.
* @see #PICK_DIST
*/
public static final Key KEY_PICK_DISTANCE = new KeyOf(Double.class, "PICK_DISTANCE");
+ public static final Key KEY_TERMINAL_PICK_DISTANCE = new KeyOf(Double.class, "TERMINAL_PICK_DISTANCE");
/**
- * Default terminal pick distance in control pixels.
+ * Default pick distances in control pixels.
* @see #DEFAULT_PICK_DISTANCE
*/
- public static final double PICK_DIST = 10;
+ public static final double PICK_DIST = 5;
+ public static final double TERMINAL_PICK_DIST = 15;
/**
* @see #altToggled(KeyEvent)
return canvasShape;
}
+ /**
+ * @param controlPos
+ * @return <code>null</code> if current canvas transform is not invertible
+ */
+ public Shape getTerminalCanvasPickShape(Point2D controlPos) {
+ AffineTransform inverse = util.getInverseTransform();
+ if (inverse == null)
+ return null;
+
+ double pd = getTerminalPickDistance();
+ Rectangle2D controlPickRect = new Rectangle2D.Double(controlPos.getX()-pd, controlPos.getY()-pd, pd*2, pd*2);
+ Shape canvasShape = GeometryUtils.transformShape(controlPickRect, inverse);
+ return canvasShape;
+ }
+
public List<TerminalInfo> pickTerminals(Point2D controlPos)
{
- Shape canvasPickRect = getCanvasPickShape(controlPos);
+ Shape canvasPickRect = getTerminalCanvasPickShape(controlPos);
if (canvasPickRect == null)
return Collections.emptyList();
return TerminalUtil.pickTerminals(getContext(), diagram, canvasPickRect, true, true);
public TerminalInfo pickTerminal(Point2D controlPos)
{
- Shape canvasPickRect = getCanvasPickShape(controlPos);
+ Shape canvasPickRect = getTerminalCanvasPickShape(controlPos);
if (canvasPickRect == null)
return null;
TerminalInfo ti = TerminalUtil.pickTerminal(getContext(), diagram, canvasPickRect);
return pickDistance == null ? PICK_DIST : Math.max(pickDistance, 0);
}
+ public double getTerminalPickDistance() {
+ Double pickDistance = getHint(KEY_TERMINAL_PICK_DISTANCE);
+ return pickDistance == null ? TERMINAL_PICK_DIST : Math.max(pickDistance, 0);
+ }
+
public PickPolicy getBoxSelectMode() {
return boxSelectMode;
}