Package com.cburch.logisim.gui.main

Examples of com.cburch.logisim.gui.main.Selection$MyListener


    int y = e.getY();
    Location pt = Location.create(x, y);

    JPopupMenu menu;
    Project proj = canvas.getProject();
    Selection sel = proj.getSelection();
    Collection<Component> in_sel = sel.getComponentsContaining(pt, g);
    if (!in_sel.isEmpty()) {
      Component comp = in_sel.iterator().next();
      if (sel.getComponents().size() > 1) {
        menu = new MenuSelection(proj);
      } else {
        menu = new MenuComponent(proj,
          canvas.getCircuit(), comp);
        MenuExtender extender = (MenuExtender) comp.getFeature(MenuExtender.class);
View Full Code Here


      add(copy); copy.addActionListener(this);
    }

    public void actionPerformed(ActionEvent e) {
      Object src = e.getSource();
      Selection sel = proj.getSelection();
      if (src == del) {
        proj.doAction(SelectionActions.clear(sel));
      } else if (src == cut) {
        proj.doAction(SelectionActions.cut(sel));
      } else if (src == copy) {
View Full Code Here

    Location oldWireLoc = wireLoc;
    wireLoc = NULL_LOCATION;
    lastX = Integer.MIN_VALUE;
    if (wire) {
      current = wiring;
      Selection sel = canvas.getSelection();
      Circuit circ = canvas.getCircuit();
      Collection<Component> selected = sel.getAnchoredComponents();
      ArrayList<Component> suppress = null;
      for (Wire w : circ.getWires()) {
        if (selected.contains(w)) {
          if (w.contains(oldWireLoc)) {
            if (suppress == null) suppress = new ArrayList<Component>();
            suppress.add(w);
          }
        }
      }
      sel.setSuppressHandles(suppress);
    } else {
      current = select;
    }
    pressX = e.getX();
    pressY = e.getY();
View Full Code Here

  }
 
  private void attemptReface(Canvas canvas, final Direction facing, KeyEvent e) {
    if (e.getModifiersEx() == 0) {
      final Circuit circuit = canvas.getCircuit();
      final Selection sel = canvas.getSelection();
      SetAttributeAction act = new SetAttributeAction(circuit,
          Strings.getter("selectionRefaceAction"));
      for (Component comp : sel.getComponents()) {
        if (!(comp instanceof Wire)) {
          Attribute<Direction> attr = getFacingAttribute(comp);
          if (attr != null) {
            act.set(comp, attr, facing);
          }
View Full Code Here

    ComponentFactory factory = null;
    int factoryCount = 0;
    int totalCount = 0;
    boolean variousFound = false;
   
    Selection selection = frame.getCanvas().getSelection();
    for (Component comp : selection.getComponents()) {
      ComponentFactory fact = comp.getFactory();
      if (fact == factory) {
        factoryCount++;
      } else if (comp instanceof Wire) {
        wireFactory = fact;
View Full Code Here

  }

  @Override
  public void setValueRequested(Attribute<Object> attr, Object value)
      throws AttrTableSetException {
    Selection selection = frame.getCanvas().getSelection();
    Circuit circuit = frame.getCanvas().getCircuit();
    if (selection.isEmpty() && circuit != null) {
      AttrTableCircuitModel circuitModel = new AttrTableCircuitModel(project, circuit);
      circuitModel.setValueRequested(attr, value);
    } else {
      SetAttributeAction act = new SetAttributeAction(circuit,
          Strings.getter("selectionAttributeAction"));
      for (Component comp : selection.getComponents()) {
        if (!(comp instanceof Wire)) {
          act.set(comp, attr, value);
        }
      }
      project.doAction(act);
View Full Code Here

    boolean circuitChanged = old == null || oldCircuit != newCircuit;
    if (circuitChanged) {
      Canvas canvas = frame == null ? null : frame.getCanvas();
      if (canvas != null) {
        if (tool != null) tool.deselect(canvas);
        Selection selection = canvas.getSelection();
        if (selection != null) {
          Action act = SelectionActions.dropAll(selection);
          if (act != null) {
            doAction(act);
          }
View Full Code Here

  public void setTool(Tool value) {
    if (tool == value) return;
    Tool old = tool;
    Canvas canvas = frame.getCanvas();
    if (old != null) old.deselect(canvas);
    Selection selection = canvas.getSelection();
    if (selection != null && !selection.isEmpty()) {
      Circuit circuit = canvas.getCircuit();
      CircuitMutation xn = new CircuitMutation(circuit);
      if (value == null) {
        Action act = SelectionActions.dropAll(selection);
        if (act != null) {
View Full Code Here

    }
  }
 
  @Override
  public void select(Canvas canvas) {
    Selection sel = canvas.getSelection();
    if (!selectionsAdded.contains(sel)) {
      sel.addListener(selListener);
    }
  }
View Full Code Here

  }

  @Override
  public void mousePressed(Canvas canvas, Graphics g, MouseEvent e) {
    Project proj = canvas.getProject();
    Selection sel = proj.getSelection();
    Circuit circuit = canvas.getCircuit();
    start = Location.create(e.getX(), e.getY());
    curDx = 0;
    curDy = 0;
    moveGesture = null;

    // if the user clicks into the selection,
    // selection is being modified
    Collection<Component> in_sel = sel.getComponentsContaining(start, g);
    if (!in_sel.isEmpty()) {
      if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) {
        setState(proj, MOVING);
        proj.repaintCanvas();
        return;
      } else {
        Action act = SelectionActions.drop(sel, in_sel);
        if (act != null) {
          proj.doAction(act);
        }
      }
    }

    // if the user clicks into a component outside selection, user
    // wants to add/reset selection
    Collection<Component> clicked = circuit.getAllContaining(start, g);
    if (!clicked.isEmpty()) {
      if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) {
        if (sel.getComponentsContaining(start).isEmpty()) {
          Action act = SelectionActions.dropAll(sel);
          if (act != null) {
            proj.doAction(act);
          }
        }
      }
      for (Component comp : clicked) {
        if (!in_sel.contains(comp)) {
          sel.add(comp);
        }
      }
      setState(proj, MOVING);
      proj.repaintCanvas();
      return;
View Full Code Here

TOP

Related Classes of com.cburch.logisim.gui.main.Selection$MyListener

Copyright © 2018 www.massapicom. 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.