Search in sources :

Example 6 with ComponentFactory

use of com.cburch.logisim.comp.ComponentFactory in project logisim-evolution by reds-heig.

the class AddTool method getBounds.

private Bounds getBounds() {
    Bounds ret = bounds;
    if (ret == null) {
        ComponentFactory source = getFactory();
        if (source == null) {
            ret = Bounds.EMPTY_BOUNDS;
        } else {
            AttributeSet base = getBaseAttributes();
            ret = source.getOffsetBounds(base).expand(5);
        }
        bounds = ret;
    }
    return ret;
}
Also used : AttributeSet(com.cburch.logisim.data.AttributeSet) Bounds(com.cburch.logisim.data.Bounds) ComponentFactory(com.cburch.logisim.comp.ComponentFactory)

Example 7 with ComponentFactory

use of com.cburch.logisim.comp.ComponentFactory in project logisim-evolution by reds-heig.

the class AddTool method getFactory.

public ComponentFactory getFactory() {
    ComponentFactory ret = factory;
    if (ret != null || sourceLoadAttempted) {
        return ret;
    } else {
        ret = description.getFactory(descriptionBase);
        if (ret != null) {
            AttributeSet base = getBaseAttributes();
            Boolean value = (Boolean) ret.getFeature(ComponentFactory.SHOULD_SNAP, base);
            shouldSnap = value == null ? true : value.booleanValue();
        }
        factory = ret;
        sourceLoadAttempted = true;
        return ret;
    }
}
Also used : AttributeSet(com.cburch.logisim.data.AttributeSet) ComponentFactory(com.cburch.logisim.comp.ComponentFactory)

Example 8 with ComponentFactory

use of com.cburch.logisim.comp.ComponentFactory in project logisim-evolution by reds-heig.

the class AddTool method getDescription.

@Override
public String getDescription() {
    String ret;
    FactoryDescription desc = description;
    if (desc != null) {
        ret = desc.getToolTip();
    } else {
        ComponentFactory source = getFactory();
        if (source != null) {
            ret = (String) source.getFeature(ComponentFactory.TOOL_TIP, getAttributeSet());
        } else {
            ret = null;
        }
    }
    if (ret == null) {
        ret = StringUtil.format(Strings.get("addToolText"), getDisplayName());
    }
    return ret;
}
Also used : ComponentFactory(com.cburch.logisim.comp.ComponentFactory)

Example 9 with ComponentFactory

use of com.cburch.logisim.comp.ComponentFactory in project logisim-evolution by reds-heig.

the class FactoryAttributes method getBase.

AttributeSet getBase() {
    AttributeSet ret = baseAttrs;
    if (ret == null) {
        ComponentFactory fact = factory;
        if (fact == null) {
            fact = desc.getFactory(descBase);
            factory = fact;
        }
        if (fact == null) {
            ret = AttributeSets.EMPTY;
        } else {
            ret = fact.createAttributeSet();
            ret.addAttributeListener(this);
        }
        baseAttrs = ret;
    }
    return ret;
}
Also used : AttributeSet(com.cburch.logisim.data.AttributeSet) ComponentFactory(com.cburch.logisim.comp.ComponentFactory)

Example 10 with ComponentFactory

use of com.cburch.logisim.comp.ComponentFactory in project logisim-evolution by reds-heig.

the class FileStatistics method doRecursiveCount.

private static Map<ComponentFactory, Count> doRecursiveCount(Circuit circuit, Set<Circuit> include, Map<Circuit, Map<ComponentFactory, Count>> countMap) {
    if (countMap.containsKey(circuit)) {
        return countMap.get(circuit);
    }
    Map<ComponentFactory, Count> counts = doSimpleCount(circuit);
    countMap.put(circuit, counts);
    for (Count count : counts.values()) {
        count.uniqueCount = count.simpleCount;
        count.recursiveCount = count.simpleCount;
    }
    for (Circuit sub : include) {
        SubcircuitFactory subFactory = sub.getSubcircuitFactory();
        if (counts.containsKey(subFactory)) {
            int multiplier = counts.get(subFactory).simpleCount;
            Map<ComponentFactory, Count> subCount;
            subCount = doRecursiveCount(sub, include, countMap);
            for (Count subcount : subCount.values()) {
                ComponentFactory subfactory = subcount.factory;
                Count supercount = counts.get(subfactory);
                if (supercount == null) {
                    supercount = new Count(subfactory);
                    counts.put(subfactory, supercount);
                }
                supercount.recursiveCount += multiplier * subcount.recursiveCount;
            }
        }
    }
    return counts;
}
Also used : ComponentFactory(com.cburch.logisim.comp.ComponentFactory) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) Circuit(com.cburch.logisim.circuit.Circuit)

Aggregations

ComponentFactory (com.cburch.logisim.comp.ComponentFactory)37 AttributeSet (com.cburch.logisim.data.AttributeSet)16 AddTool (com.cburch.logisim.tools.AddTool)9 Tool (com.cburch.logisim.tools.Tool)9 Circuit (com.cburch.logisim.circuit.Circuit)8 SubcircuitFactory (com.cburch.logisim.circuit.SubcircuitFactory)8 Component (com.cburch.logisim.comp.Component)8 Library (com.cburch.logisim.tools.Library)8 ArrayList (java.util.ArrayList)6 Wire (com.cburch.logisim.circuit.Wire)4 Location (com.cburch.logisim.data.Location)4 ProjectExplorerToolNode (com.cburch.logisim.gui.generic.ProjectExplorerToolNode)4 HashSet (java.util.HashSet)4 Attribute (com.cburch.logisim.data.Attribute)3 Bounds (com.cburch.logisim.data.Bounds)3 ToolAttributeAction (com.cburch.logisim.gui.main.ToolAttributeAction)3 Action (com.cburch.logisim.proj.Action)3 HashMap (java.util.HashMap)3 CircuitMutation (com.cburch.logisim.circuit.CircuitMutation)2 Direction (com.cburch.logisim.data.Direction)2