Package com.cburch.draw.actions

Source Code of com.cburch.draw.actions.ModelAction

/* Copyright (c) 2010, Carl Burch. License information is located in the
* com.cburch.logisim.Main source code and at www.cburch.com/logisim/. */

package com.cburch.draw.actions;

import java.util.Collection;
import java.util.Collections;

import com.cburch.draw.model.CanvasModel;
import com.cburch.draw.model.CanvasObject;
import com.cburch.draw.undo.Action;

public abstract class ModelAction extends Action {
  private CanvasModel model;
 
  public ModelAction(CanvasModel model) {
    this.model = model;
  }
 
  public Collection<CanvasObject> getObjects() {
    return Collections.emptySet();
  }

  @Override
  public abstract String getName();
 
  abstract void doSub(CanvasModel model);
 
  abstract void undoSub(CanvasModel model);

  @Override
  public final void doIt() {
    doSub(model);
  }

  @Override
  public final void undo() {
    undoSub(model);
  }
 
  public CanvasModel getModel() {
    return model;
  }
 
  static String getShapesName(Collection<CanvasObject> coll) {
    if (coll.size() != 1) {
      return Strings.get("shapeMultiple");
    } else {
      CanvasObject shape = coll.iterator().next();
      return shape.getDisplayName();
    }
  }
}
TOP

Related Classes of com.cburch.draw.actions.ModelAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.