Package com.cburch.logisim.circuit

Examples of com.cburch.logisim.circuit.Circuit$MyComponentListener


  @Override
  public void selectAll() {
    Project proj = frame.getProject();
    Selection sel = frame.getCanvas().getSelection();
    selectSelectTool(proj);
    Circuit circ = proj.getCurrentCircuit();
    sel.addAll(circ.getWires());
    sel.addAll(circ.getNonWires());
    proj.repaintCanvas();
  }
View Full Code Here


    }

    public void actionPerformed(ActionEvent e) {
      Object src = e.getSource();
      if (src == del) {
        Circuit circ = proj.getCurrentCircuit();
        CircuitMutation xn = new CircuitMutation(circ);
        xn.remove(comp);
        proj.doAction(xn.toAction(Strings.getter("removeComponentAction", comp.getFactory().getDisplayGetter())));
      } else if (src == attrs) {
        proj.getFrame().viewComponentAttributes(circ, comp);
View Full Code Here

    }
  }

  private void buildCircuit(XmlReader.CircuitData circData, CircuitMutator mutator) {
    Element elt = circData.circuitElement;
    Circuit dest = circData.circuit;
    Map<Element, Component> knownComponents = circData.knownComponents;
    if (knownComponents == null) knownComponents = Collections.emptyMap();
    try {
      reader.initAttributeSet(circData.circuitElement, dest.getStaticAttributes(), null);
    } catch (XmlReaderException e) {
      reader.addErrors(e, circData.circuit.getName() + ".static");
    }

    for (Element sub_elt : XmlIterator.forChildElements(elt)) {
      String sub_elt_name = sub_elt.getTagName();
      if (sub_elt_name.equals("comp")) {
        try {
          Component comp = knownComponents.get(sub_elt);
          if (comp == null) {
            comp = getComponent(sub_elt, reader);
          }
          mutator.add(dest, comp);
        } catch (XmlReaderException e) {
          reader.addErrors(e, circData.circuit.getName() + "." + toComponentString(sub_elt));
        }
      } else if (sub_elt_name.equals("wire")) {
        try {
          addWire(dest, mutator, sub_elt);
        } catch (XmlReaderException e) {
          reader.addErrors(e, circData.circuit.getName() + "." + toWireString(sub_elt));
        }
      }
    }
   
    List<AbstractCanvasObject> appearance = circData.appearance;
    if (appearance != null && !appearance.isEmpty()) {
      dest.getAppearance().setObjectsForce(appearance);
      dest.getAppearance().setDefaultAppearance(false);
    }
  }
View Full Code Here

    LogisimFile file;
    try {
      file = loader.openLogisimFile(templReader);
    } catch (Throwable t) {
      file = LogisimFile.createNew(loader);
      file.addCircuit(new Circuit("main"));
    } finally {
      try { templReader.close(); } catch (IOException e) { }
    }
    return file;
  }
View Full Code Here

  }
 
  @Override
  protected void paintComponent(Graphics g) {
    if (circuitState != null) {
      Circuit circuit = circuitState.getCircuit();
      Bounds bds = circuit.getBounds(g);
      Dimension size = getSize();
      double scaleX = (double) (size.width - 2 * BORDER) / bds.getWidth();
      double scaleY = (double) (size.height - 2 * BORDER) / bds.getHeight();
      double scale = Math.min(1.0, Math.min(scaleX, scaleY));
     
      Graphics gCopy = g.create();
      int borderX = (int) ((size.width - bds.getWidth() * scale) / 2);
      int borderY = (int) ((size.height - bds.getHeight() * scale) / 2);
      gCopy.translate(borderX, borderY);
      if (scale != 1.0 && g instanceof Graphics2D) {
        ((Graphics2D) gCopy).scale(scale, scale);
      }
      gCopy.translate(-bds.getX(), -bds.getY());
     
      ComponentDrawContext context = new ComponentDrawContext(this, circuit,
          circuitState, g, gCopy);
      context.setShowState(false);
      context.setShowColor(false);
      circuit.draw(context, Collections.<Component>emptySet());
      if (ports != null) {
        gCopy.setColor(AppearancePort.COLOR);
        int width = Math.max(4, (int) ((2 / scale) + 0.5));
        GraphicsUtil.switchToWidth(gCopy, width);
        for (Instance port : ports) {
View Full Code Here

    throw new UnsupportedOperationException("SelectionAttributes.copyInto");
  }

  @Override
  public List<Attribute<?>> getAttributes() {
    Circuit circ = canvas.getCircuit();
    if (selected.isEmpty() && circ != null) {
      return circ.getStaticAttributes().getAttributes();
    } else {
      return attrsView;
    }
  }
View Full Code Here

  }
 
  @Override
  public boolean isReadOnly(Attribute<?> attr) {
    Project proj = canvas.getProject();
    Circuit circ = canvas.getCircuit();
    if (!proj.getLogisimFile().contains(circ)) {
      return true;
    } else if (selected.isEmpty() && circ != null) {
      return circ.getStaticAttributes().isReadOnly(attr);
    } else {
      int i = findIndex(attr);
      boolean[] ro = readOnly;
      return i >= 0 && i < ro.length ? ro[i] : true;
    }
View Full Code Here

    return false;
  }

  @Override
  public <V> V getValue(Attribute<V> attr) {
    Circuit circ = canvas.getCircuit();
    if (selected.isEmpty() && circ != null) {
      return circ.getStaticAttributes().getValue(attr);
    } else {
      int i = findIndex(attr);
      Object[] vs = values;
      @SuppressWarnings("unchecked")
      V ret = (V) (i >= 0 && i < vs.length ? vs[i] : null);
View Full Code Here

    }
  }

  @Override
  public <V> void setValue(Attribute<V> attr, V value) {
    Circuit circ = canvas.getCircuit();
    if (selected.isEmpty() && circ != null) {
      circ.getStaticAttributes().setValue(attr, value);
    } else {
      int i = findIndex(attr);
      Object[] vs = values;
      if (i >= 0 && i < vs.length) {
        vs[i] = value;
View Full Code Here

      if (selected instanceof AddTool) {
        AddTool addTool = (AddTool) selected;
        ComponentFactory source = addTool.getFactory();
        if (source instanceof SubcircuitFactory) {
          SubcircuitFactory circFact = (SubcircuitFactory) source;
          Circuit circ = circFact.getSubcircuit();
          if (proj.getCurrentCircuit() == circ) {
            AttrTableModel m = new AttrTableCircuitModel(proj, circ);
            proj.getFrame().setAttrTableModel(m);
            return;
          }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.circuit.Circuit$MyComponentListener

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.