コード例 #1
0
 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);
 }
コード例 #2
0
 @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);
   }
 }
コード例 #3
0
 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);
     }
   }
 }
コード例 #4
0
  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);
  }
コード例 #5
0
ファイル: Canvas.java プロジェクト: r0the/logisim
 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();
   }
 }
コード例 #6
0
ファイル: Canvas.java プロジェクト: r0the/logisim
  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);
    }
  }
コード例 #7
0
 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;
 }
コード例 #8
0
	@Override
	void undoSub(CanvasModel model) {
		model.insertHandle(handle, previous);
	}
コード例 #9
0
	@Override
	void doSub(CanvasModel model) {
		previous = model.deleteHandle(handle);
	}