Package com.cburch.logisim.tools

Examples of com.cburch.logisim.tools.Tool


                JComponent comp = (JComponent) ret;
                comp.setToolTipText(null);
            }
            if (value instanceof ProjectExplorerToolNode) {
                ProjectExplorerToolNode toolNode = (ProjectExplorerToolNode) value;
                Tool tool = toolNode.getValue();
                if (ret instanceof JLabel) {
                    ((JLabel) ret).setText(tool.getDisplayName());
                    ((JLabel) ret).setIcon(new ToolIcon(tool));
                    ((JLabel) ret).setToolTipText(tool.getDescription());
                }
            } else if (value instanceof ProjectExplorerLibraryNode) {
                ProjectExplorerLibraryNode libNode = (ProjectExplorerLibraryNode) value;
                Library lib = libNode.getValue();
                if (ret instanceof JLabel) {
View Full Code Here


    private void selectSelectTool(Project proj) {
        for (Library sub : proj.getLogisimFile().getLibraries()) {
            if (sub instanceof Base) {
                Base base = (Base) sub;
                Tool tool = base.getTool("Edit Tool");
                if (tool != null) {
                    proj.setTool(tool);
                }

            }
View Full Code Here

    }

    @Override
    public boolean isSelected(ToolbarItem item) {
        if (item instanceof ToolItem) {
            Tool tool = ((ToolItem) item).tool;
            return tool == proj.getTool();
        } else {
            return false;
        }
    }
View Full Code Here

    }

    @Override
    public void itemSelected(ToolbarItem item) {
        if (item instanceof ToolItem) {
            Tool tool = ((ToolItem) item).tool;
            proj.setTool(tool);
        }
    }
View Full Code Here

    }

    private static boolean doSave(Project proj, File f) {
        Loader loader = proj.getLogisimFile().getLoader();
        Tool oldTool = proj.getTool();
        proj.setTool(null);
        boolean ret = loader.save(proj.getLogisimFile(), f);
        if (ret) {
            AppPreferences.updateRecentFile(f);
            proj.setFileAsClean();
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()) {
            if (value == null || !getOptions().getMouseMappings().containsSelectTool()) {
View Full Code Here

    private void drawWithUserState(Graphics base, Graphics g, Project proj) {
        Circuit circ = proj.getCurrentCircuit();
        Selection sel = proj.getSelection();
        Set<Component> hidden;
        Tool dragTool = canvas.getDragTool();
        if (dragTool == null) {
            hidden = NO_COMPONENTS;
        } else {
            hidden = dragTool.getHiddenComponents(canvas);
            if (hidden == null) {
                hidden = NO_COMPONENTS;
            }

        }

        // draw halo around component whose attributes we are viewing
        boolean showHalo = AppPreferences.ATTRIBUTE_HALO.getBoolean();
        if (showHalo && haloedComponent != null && haloedCircuit == circ
                && !hidden.contains(haloedComponent)) {
            GraphicsUtil.switchToWidth(g, 3);
            g.setColor(Canvas.HALO_COLOR);
            Bounds bds = haloedComponent.getBounds(g).expand(5);
            int w = bds.getWidth();
            int h = bds.getHeight();
            double a = Canvas.SQRT_2 * w;
            double b = Canvas.SQRT_2 * h;
            g.drawOval((int) Math.round(bds.getX() + w/2.0 - a/2.0),
                (int) Math.round(bds.getY() + h/2.0 - b/2.0),
                (int) Math.round(a), (int) Math.round(b));
            GraphicsUtil.switchToWidth(g, 1);
            g.setColor(Color.BLACK);
        }

        // draw circuit and selection
        CircuitState circState = proj.getCircuitState();
        boolean printerView = AppPreferences.PRINTER_VIEW.getBoolean();
        ComponentDrawContext context = new ComponentDrawContext(canvas,
                circ, circState, base, g, printerView);
        context.setHighlightedWires(highlightedWires);
        circ.draw(context, hidden);
        sel.draw(context, hidden);

        // draw tool
        Tool tool = dragTool != null ? dragTool : proj.getTool();
        if (tool != null && !canvas.isPopupMenuUp()) {
            Graphics gCopy = g.create();
            context.setGraphics(gCopy);
            tool.draw(canvas, context);
            gCopy.dispose();
        }
    }
View Full Code Here

    Element fromMouseMappings() {
        Element elt = doc.createElement("mappings");
        MouseMappings map = file.getOptions().getMouseMappings();
        for (Map.Entry<Integer,Tool> entry : map.getMappings().entrySet()) {
            Integer mods = entry.getKey();
            Tool tool = entry.getValue();
            Element toolElt = fromTool(tool);
            String mapValue = InputEventUtil.toString(mods.intValue());
            toolElt.setAttribute("map", mapValue);
            elt.appendChild(toolElt);
        }
View Full Code Here

        this.contents.clear();
        for (Tool srcTool : other.contents) {
            if (srcTool == null) {
                this.addSeparator();
            } else {
                Tool toolCopy = file.findTool(srcTool);
                if (toolCopy != null) {
                    Tool dstTool = toolCopy.cloneTool();
                    AttributeSets.copy(srcTool.getAttributeSet(),
                            dstTool.getAttributeSet());
                    this.addTool(dstTool);
                    addAttributeListeners(toolCopy);
                }
            }
        }
View Full Code Here

        contents.add(pos, null);
        fireToolbarChanged();
    }

    public Object move(int from, int to) {
        Tool moved = contents.remove(from);
        contents.add(to, moved);
        fireToolbarChanged();
        return moved;
    }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.tools.Tool

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.