Package com.cburch.logisim.gui.main

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


        }

        @Override
        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


        }
    }

    @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

                        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);
            }
View Full Code Here

    private void processKeyEvent(Canvas canvas, KeyEvent e, int type) {
        HashMap<Component, KeyConfigurator> handlers = keyHandlers;
        if (handlers == null) {
            handlers = new HashMap<Component, KeyConfigurator>();
            Selection sel = canvas.getSelection();
            for (Component comp : sel.getComponents()) {
                ComponentFactory factory = comp.getFactory();
                AttributeSet attrs = comp.getAttributeSet();
                Object handler = factory.getFeature(KeyConfigurator.class, attrs);
                if (handler != null) {
                    KeyConfigurator base = (KeyConfigurator) handler;
View Full Code Here

        } else {
            dx = Math.max(e.getX() - start.getX(), -bds.getX());
            dy = Math.max(e.getY() - start.getY(), -bds.getY());
        }

        Selection sel = proj.getSelection();
        if (sel.shouldSnap()) {
            dx = Canvas.snapXToGrid(dx);
            dy = Canvas.snapYToGrid(dy);
        }
        curDx = dx;
        curDy = dy;
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.