Package com.cburch.logisim.proj

Examples of com.cburch.logisim.proj.Project


  }

  @Override
  public void mouseDragged(Canvas canvas, Graphics g, MouseEvent e) {
    if (state == MOVING) {
      Project proj = canvas.getProject();
      computeDxDy(proj, e, g);
      handleMoveDrag(canvas, curDx, curDy, e.getModifiersEx());
    } else if (state == RECT_SELECT) {
      Project proj = canvas.getProject();
      curDx = e.getX() - start.getX();
      curDy = e.getY() - start.getY();
      proj.repaintCanvas();
    }
  }
View Full Code Here


    }
  }

  @Override
  public void mouseReleased(Canvas canvas, Graphics g, MouseEvent e) {
    Project proj = canvas.getProject();
    if (state == MOVING) {
      setState(proj, IDLE);
      computeDxDy(proj, e, g);
      int dx = curDx;
      int dy = curDy;
      if (dx != 0 || dy != 0) {
        if (!proj.getLogisimFile().contains(canvas.getCircuit())) {
          canvas.setErrorMessage(Strings.getter("cannotModifyError"));
        } else if (proj.getSelection().hasConflictWhenMoved(dx, dy)) {
          canvas.setErrorMessage(Strings.getter("exclusiveError"));
        } else {
          boolean connect = shouldConnect(canvas, e.getModifiersEx());
          drawConnections = false;
          ReplacementMap repl;
          if (connect) {
            MoveGesture gesture = moveGesture;
            if (gesture == null) {
              gesture = new MoveGesture(new MoveRequestHandler(canvas),
                  canvas.getCircuit(), canvas.getSelection().getAnchoredComponents());
            }
            canvas.setErrorMessage(new ComputingMessage(dx, dy), COLOR_COMPUTING);
            MoveResult result = gesture.forceRequest(dx, dy);
            clearCanvasMessage(canvas, dx, dy);
            repl = result.getReplacementMap();
          } else {
            repl = null;
          }
          Selection sel = proj.getSelection();
          proj.doAction(SelectionActions.translate(sel, dx, dy, repl));
        }
      }
      moveGesture = null;
      proj.repaintCanvas();
    } else if (state == RECT_SELECT) {
      Bounds bds = Bounds.create(start).add(start.getX() + curDx,
        start.getY() + curDy);
      Circuit circuit = canvas.getCircuit();
      Selection sel = proj.getSelection();
      Collection<Component> in_sel = sel.getComponentsWithin(bds, g);
      for (Component comp : circuit.getAllWithin(bds, g)) {
        if (!in_sel.contains(comp)) sel.add(comp);
      }
      Action act = SelectionActions.drop(sel, in_sel);
      if (act != null) {
        proj.doAction(act);
      }
      setState(proj, IDLE);
      proj.repaintCanvas();
    }
  }
View Full Code Here

        DialogPanel() {
            List<Project> projects = Projects.getOpenProjects();
            Object[] options = new Object[projects.size()];
            Object initialSelection = null;
            for (int i = 0; i < options.length; i++) {
                Project proj = projects.get(i);
                options[i] = new ProjectItem(proj);
                if (proj == model.getCurrentProject()) {
                    initialSelection = options[i];
                }
            }
View Full Code Here

    }

    private class MyListener implements ActionListener {
        @Override
        public void actionPerformed(ActionEvent event) {
            Project dest = null;
            String name = null;
            boolean twoInputs = false;
            boolean useNands = false;
            boolean replace = false;

            boolean ok = false;
            while (!ok) {
                DialogPanel dlog = new DialogPanel();
                int action = JOptionPane.showConfirmDialog(parent,
                        dlog, getFromLocale("buildDialogTitle"), JOptionPane.OK_CANCEL_OPTION,
                        JOptionPane.QUESTION_MESSAGE);
                if (action != JOptionPane.OK_OPTION) {
                    return;
                }


                ProjectItem projectItem = (ProjectItem) dlog.project.getSelectedItem();
                if (projectItem == null) {
                    JOptionPane.showMessageDialog(parent, getFromLocale("buildNeedProjectError"),
                            getFromLocale("buildDialogErrorTitle"), JOptionPane.ERROR_MESSAGE);
                    continue;
                }
                dest = projectItem.project;

                name = dlog.name.getText().trim();
                if (name.equals("")) {
                    JOptionPane.showMessageDialog(parent, getFromLocale("buildNeedCircuitError"),
                            getFromLocale("buildDialogErrorTitle"), JOptionPane.ERROR_MESSAGE);
                    continue;
                }

                if (dest.getLogisimFile().getCircuit(name) != null) {
                    int choice = JOptionPane.showConfirmDialog(parent,
                            getFromLocale("buildConfirmReplaceMessage", name),
                            getFromLocale("buildConfirmReplaceTitle"), JOptionPane.YES_NO_OPTION);
                    if (choice != JOptionPane.YES_OPTION) {
                        continue;
View Full Code Here

                    if (p != null) {
                        Caret caret = p.getPokeCaret(event);
                        setPokedComponent(circ, c, caret);
                        AttributeSet attrs = c.getAttributeSet();
                        if (attrs != null && attrs.getAttributes().size() > 0) {
                            Project proj = canvas.getProject();
                            proj.getFrame().viewComponentAttributes(circ, c);
                        }
                    }
                }
            }
        }
View Full Code Here

        }

        @Override
        public java.awt.Component getCellEditor(Window source, MemContents value) {
            if (source instanceof Frame) {
                Project proj = ((Frame) source).getProject();
                RomAttributes.register(value, proj);
            }
            ContentsCell ret = new ContentsCell(source, value);
            ret.mouseClicked(null);
            return ret;
View Full Code Here

        public void mouseClicked(MouseEvent e) {
            if (contents == null) {
                return;
            }

            Project proj = source instanceof Frame ? ((Frame) source).getProject() : null;
            HexFrame frame = RomAttributes.getHexFrame(contents, proj);
            frame.setVisible(true);
            frame.toFront();
        }
View Full Code Here

            initValue = data.getContents().get(data.getCursor());
            curValue = initValue;

            Object attrs = state.getInstance().getAttributeSet();
            if (attrs instanceof RomAttributes) {
                Project proj = state.getProject();
                if (proj != null) {
                    ((RomAttributes) attrs).setProject(proj);
                }
            }
        }
View Full Code Here

        // no simulation remaining to perform, so just exit
        if (format == 0) {
            System.exit(0);
        }

        Project proj = new Project(file);
        Circuit circuit = file.getMainCircuit();
        Map<Instance, String> pinNames = Analyze.getPinLabels(circuit);
        ArrayList<Instance> outputPins = new ArrayList<Instance>();
        Instance haltPin = null;
        for (Map.Entry<Instance, String> entry : pinNames.entrySet()) {
View Full Code Here

        }
    }

    private void doPrintFile(File file) {
        if (initialized) {
            Project toPrint = ProjectActions.doOpen(null, null, file);
            Print.doPrint(toPrint);
            toPrint.getFrame().dispose();
        } else {
            filesToPrint.add(file);
        }
    }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.proj.Project

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.