示例#1
0
 @Override
 public int hitByPoint(JEnvironment env, JRequest req, Point2D point) {
   if (isLocked() || !isVisible()) return JRequest.HIT_NON;
   Shape s = getShape();
   if (s.contains(point)) {
     req.hitObjects.add(this);
     return (req.hitResult = JRequest.HIT_OBJECT);
   }
   double radius = JEnvironment.PATH_SELECTOR_SIZE / 2 / env.getToScreenRatio();
   Rectangle2D.Double sr = new Rectangle2D.Double(0, 0, radius * 2, radius * 2);
   PathIterator path = s.getPathIterator(null);
   double[] coords = new double[6];
   while (!path.isDone()) {
     int type = path.currentSegment(coords);
     if (type == path.SEG_LINETO || type == path.SEG_MOVETO) {
       sr.x = coords[0] - radius;
       sr.y = coords[1] - radius;
       if (sr.contains(point)) {
         req.hitObjects.add(this);
         return (req.hitResult = JRequest.HIT_OBJECT);
       }
     }
     path.next();
   }
   return JRequest.HIT_NON;
 }
示例#2
0
 @Override
 public UndoableEdit updateTransform(JEnvironment env) {
   JDocumentViewer viewer = getDocument().getViewer();
   JRequest req = viewer.getCurrentRequest();
   CompoundEdit cEdit = new CompoundEdit();
   if (req.isAltDown
       && req.getSelectionMode() == req.GROUP_MODE
       && addingTransform.getType() == AffineTransform.TYPE_TRANSLATION) {
     cEdit.addEdit(new JDuplicateObjectEdit(viewer, this));
   }
   cEdit.addEdit(new JTransformImageObjectEdit(viewer, this, addingTransform));
   addingTransform = null;
   cEdit.end();
   return cEdit;
 }