Search in sources :

Example 6 with Tool

use of com.cburch.logisim.tools.Tool in project logisim-evolution by reds-heig.

the class MouseMappings method copyFrom.

// 
// modification methods
// 
public void copyFrom(MouseMappings other, LogisimFile file) {
    if (this == other)
        return;
    cache_mods = -1;
    this.map.clear();
    for (Integer mods : other.map.keySet()) {
        Tool srcTool = other.map.get(mods);
        Tool dstTool = file.findTool(srcTool);
        if (dstTool != null) {
            dstTool = dstTool.cloneTool();
            AttributeSets.copy(srcTool.getAttributeSet(), dstTool.getAttributeSet());
            this.map.put(mods, dstTool);
        }
    }
    fireMouseMappingsChanged();
}
Also used : SelectTool(com.cburch.logisim.tools.SelectTool) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Example 7 with Tool

use of com.cburch.logisim.tools.Tool in project logisim-evolution by reds-heig.

the class MouseMappings method getToolFor.

public Tool getToolFor(int mods) {
    if (mods == cache_mods) {
        return cache_tool;
    } else {
        Tool ret = map.get(Integer.valueOf(mods));
        cache_mods = mods;
        cache_tool = ret;
        return ret;
    }
}
Also used : SelectTool(com.cburch.logisim.tools.SelectTool) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Example 8 with Tool

use of com.cburch.logisim.tools.Tool in project logisim-evolution by reds-heig.

the class ToolbarData method replaceAll.

// 
// package-protected methods
// 
void replaceAll(Map<Tool, Tool> toolMap) {
    boolean changed = false;
    for (ListIterator<Tool> it = contents.listIterator(); it.hasNext(); ) {
        Object old = it.next();
        if (toolMap.containsKey(old)) {
            changed = true;
            removeAttributeListeners((Tool) old);
            Tool newTool = toolMap.get(old);
            if (newTool == null) {
                it.remove();
            } else {
                Tool addedTool = newTool.cloneTool();
                addAttributeListeners(addedTool);
                LoadedLibrary.copyAttributes(addedTool.getAttributeSet(), ((Tool) old).getAttributeSet());
                it.set(addedTool);
            }
        }
    }
    if (changed)
        fireToolbarChanged();
}
Also used : Tool(com.cburch.logisim.tools.Tool)

Example 9 with Tool

use of com.cburch.logisim.tools.Tool in project logisim-evolution by reds-heig.

the class ToolboxManip method doubleClicked.

public void doubleClicked(ProjectExplorerEvent event) {
    Object clicked = event.getTarget();
    if (clicked instanceof ProjectExplorerToolNode) {
        Tool baseTool = ((ProjectExplorerToolNode) clicked).getValue();
        if (baseTool instanceof AddTool) {
            AddTool tool = (AddTool) baseTool;
            ComponentFactory source = tool.getFactory();
            if (source instanceof SubcircuitFactory) {
                SubcircuitFactory circFact = (SubcircuitFactory) source;
                proj.setCurrentCircuit(circFact.getSubcircuit());
                proj.getFrame().setEditorView(Frame.EDIT_LAYOUT);
                if (lastSelected != null) {
                    proj.setTool(lastSelected);
                } else {
                    Library base = proj.getLogisimFile().getLibrary("Base");
                    if (base != null)
                        proj.setTool(base.getTool("Edit Tool"));
                }
            }
        }
    }
}
Also used : ProjectExplorerToolNode(com.cburch.logisim.gui.generic.ProjectExplorerToolNode) ComponentFactory(com.cburch.logisim.comp.ComponentFactory) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) AddTool(com.cburch.logisim.tools.AddTool) Library(com.cburch.logisim.tools.Library) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Example 10 with Tool

use of com.cburch.logisim.tools.Tool in project logisim-evolution by reds-heig.

the class ToolboxManip method selectionChanged.

public void selectionChanged(ProjectExplorerEvent event) {
    Object selected = event.getTarget();
    if (selected instanceof ProjectExplorerToolNode) {
        Tool tool = ((ProjectExplorerToolNode) selected).getValue();
        if (selected instanceof AddTool) {
            AddTool addTool = (AddTool) tool;
            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;
                }
            }
        }
        // This was causing the selection to lag behind double-clicks,
        // commented-out
        // lastSelected = proj.getTool();
        proj.setTool(tool);
        proj.getFrame().viewAttributes(tool);
    }
}
Also used : ProjectExplorerToolNode(com.cburch.logisim.gui.generic.ProjectExplorerToolNode) ComponentFactory(com.cburch.logisim.comp.ComponentFactory) AttrTableModel(com.cburch.logisim.gui.generic.AttrTableModel) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) Circuit(com.cburch.logisim.circuit.Circuit) AddTool(com.cburch.logisim.tools.AddTool) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Aggregations

Tool (com.cburch.logisim.tools.Tool)28 AddTool (com.cburch.logisim.tools.AddTool)16 ComponentFactory (com.cburch.logisim.comp.ComponentFactory)9 Library (com.cburch.logisim.tools.Library)7 Circuit (com.cburch.logisim.circuit.Circuit)6 SubcircuitFactory (com.cburch.logisim.circuit.SubcircuitFactory)6 ProjectExplorerToolNode (com.cburch.logisim.gui.generic.ProjectExplorerToolNode)4 SelectTool (com.cburch.logisim.tools.SelectTool)4 Component (com.cburch.logisim.comp.Component)3 ArrayList (java.util.ArrayList)3 Element (org.w3c.dom.Element)3 AttributeSet (com.cburch.logisim.data.AttributeSet)2 ProjectExplorerLibraryNode (com.cburch.logisim.gui.generic.ProjectExplorerLibraryNode)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 ToolbarItem (com.cburch.draw.toolbar.ToolbarItem)1 ToolbarSeparator (com.cburch.draw.toolbar.ToolbarSeparator)1 CircuitState (com.cburch.logisim.circuit.CircuitState)1 ComponentDrawContext (com.cburch.logisim.comp.ComponentDrawContext)1