@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); } }
@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); }
@Override public CanvasObject createShape(int x, int y, int w, int h) { return attrs.applyTo(new RoundRectangle(x, y, w, h)); }
@Override public List<Attribute<?>> getAttributes() { return DrawAttr.getRoundRectAttributes(attrs.getValue(DrawAttr.PAINT_TYPE)); }