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);
  }
Example #5
0
  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);
    }
  }