Package com.cburch.logisim.proj

Examples of com.cburch.logisim.proj.Project


    private class MyListener implements ActionListener, SimulatorListener, ChangeListener {  
        @Override
        public void actionPerformed(ActionEvent e) {
            Object src = e.getSource();
            Project proj = menubar.getProject();
            Simulator sim = proj == null ? null : proj.getSimulator();
            if (src == run || src == LogisimMenuBar.SIMULATE_ENABLE) {
                if (sim != null) {
                    sim.setIsRunning(!sim.isRunning());
                    proj.repaintCanvas();
                }
            } else if (src == reset) {
                if (sim != null) {
                    sim.requestReset();
                }
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);
View Full Code Here

        add(lowerBottom);
        addSeparator();
        add(addCtrl);
        add(remCtrl);

        Project proj = menubar.getProject();
        if (proj != null) {
            proj.addProjectListener(myListener);
            undo.addActionListener(myListener);
      redo.addActionListener( myListener );
        }

        undo.setEnabled(false);
View Full Code Here

        return true;
    }

    @Override
    public void draw(Canvas canvas, ComponentDrawContext context) {
        Project proj = canvas.getProject();
        int dx = curDx;
        int dy = curDy;
        if (state == MOVING) {
            proj.getSelection().drawGhostsShifted(context, dx, dy);

            MoveGesture gesture = moveGesture;
            if (gesture != null && drawConnections && (dx != 0 || dy != 0)) {
                MoveResult result = gesture.findResult(dx, dy);
                if (result != null) {
View Full Code Here

        canvas.requestFocusInWindow();
    }

    @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;
        }

        // The user clicked on the background. This is a rectangular
        // selection (maybe with the shift key down).
        if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) {
            Action act = SelectionActions.dropAll(sel);
            if (act != null) {
                proj.doAction(act);
            }
        }
        setState(proj, RECT_SELECT);
        proj.repaintCanvas();
    }
View Full Code Here

@SuppressWarnings("serial")
class MenuEdit extends Menu {
    private class MyListener implements ProjectListener, ActionListener {
        @Override
        public void projectChanged(ProjectEvent e) {
            Project proj = menubar.getProject();
            Action last = proj == null ? null : proj.getLastAction();
      if( last == null )
      {
        undo.setText( getFromLocale( "editCantUndoItem" ) );
        undo.setEnabled( false );
      }
      else
      {
        undo.setText( getFromLocale( "editUndoItem", last.getName() ) );
        undo.setEnabled( true );
            }

      // If there is a project open...
      if( proj != null )
        // And you CAN redo an undo...
        if( proj.getCanRedo() )
        {
          // Get that action
          Action lastRedo = proj.getLastRedoAction();

          // Set the detailed, localized text

          redo.setText( getFromLocale( "editRedoItem", lastRedo.getName() ) );
         
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.