Esempio n. 1
0
 @Override
 public void mouseReleased(Canvas canvas, MouseEvent e) {
   if (active) {
     updateMouse(canvas, e.getX(), e.getY(), e.getModifiersEx());
     Location start = mouseStart;
     Location end = mouseEnd;
     CanvasObject add = null;
     if (!start.equals(end)) {
       active = false;
       CanvasModel model = canvas.getModel();
       Location[] ends = {start, end};
       List<Location> locs = UnmodifiableList.create(ends);
       add = attrs.applyTo(new Poly(false, locs));
       add.setValue(DrawAttr.PAINT_TYPE, DrawAttr.PAINT_STROKE);
       canvas.doAction(new ModelAddAction(model, add));
       repaintArea(canvas);
     }
     canvas.toolGestureComplete(this, add);
   }
 }
Esempio n. 2
0
 @Override
 public void fillShape(Graphics g, int x, int y, int w, int h) {
   int r = 2 * attrs.getValue(DrawAttr.CORNER_RADIUS).intValue();
   g.fillRoundRect(x, y, w, h, r, r);
 }
Esempio n. 3
0
 @Override
 public CanvasObject createShape(int x, int y, int w, int h) {
   return attrs.applyTo(new RoundRectangle(x, y, w, h));
 }
Esempio n. 4
0
 @Override
 public List<Attribute<?>> getAttributes() {
   return DrawAttr.getRoundRectAttributes(attrs.getValue(DrawAttr.PAINT_TYPE));
 }