AppearanceEditHandler(AppearanceCanvas canvas) { this.canvas = canvas; canvas.getSelection().addSelectionListener(this); CanvasModel model = canvas.getModel(); if (model != null) model.addCanvasModelListener(this); canvas.addPropertyChangeListener(Canvas.MODEL_PROPERTY, this); }
@Override public void setModel(CanvasModel value, ActionDispatcher dispatcher) { CanvasModel oldModel = super.getModel(); if (oldModel != null) { oldModel.removeCanvasModelListener(listener); } super.setModel(value, dispatcher); if (value != null) { value.addCanvasModelListener(listener); } }
public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (prop.equals(Canvas.MODEL_PROPERTY)) { CanvasModel oldModel = (CanvasModel) e.getOldValue(); if (oldModel != null) { oldModel.removeCanvasModelListener(this); } CanvasModel newModel = (CanvasModel) e.getNewValue(); if (newModel != null) { newModel.addCanvasModelListener(this); } } }
public AppearanceCanvas(CanvasTool selectTool) { super(Main.getAppContext()); this.selectTool = selectTool; this.grid = new GridPainter(this); this.listener = new Listener(); this.oldPreferredSize = null; setSelection(new AppearanceSelection()); setTool(selectTool); CanvasModel model = super.getModel(); if (model != null) model.addCanvasModelListener(listener); grid.addPropertyChangeListener(GridPainter.ZOOM_PROPERTY, listener); }
protected void paintForeground(Graphics g) { CanvasModel cModel = this.model; CanvasTool tool = listener.getTool(); if (cModel != null) { Graphics dup = g.create(); cModel.paint(g, selection); dup.dispose(); } if (tool != null) { Graphics dup = g.create(); tool.draw(this, dup); dup.dispose(); } }
public void setModel(CanvasModel value, ActionDispatcher dispatcher) { CanvasModel oldValue = model; if (!oldValue.equals(value)) { if (oldValue != null) { oldValue.removeCanvasModelListener(listener); } model = value; this.dispatcher = dispatcher; if (value != null) { value.addCanvasModelListener(listener); } selection.clearSelected(); repaint(); firePropertyChange(MODEL_PROPERTY, oldValue, value); } }
static int getMaxIndex(CanvasModel model) { List<CanvasObject> objects = model.getObjectsFromBottom(); for (int i = objects.size() - 1; i >= 0; i--) { if (!(objects.get(i) instanceof AppearanceElement)) { return i; } } return -1; }
@Override void undoSub(CanvasModel model) { model.insertHandle(handle, previous); }
@Override void doSub(CanvasModel model) { previous = model.deleteHandle(handle); }