Package com.cburch.logisim.comp

Examples of com.cburch.logisim.comp.ComponentFactory


        Circuit circ = null;

        ToolIcon(Tool tool) {
            this.tool = tool;
            if (tool instanceof AddTool) {
                ComponentFactory fact = ((AddTool) tool).getFactory(false);
                if (fact instanceof SubcircuitFactory) {
                    circ = ((SubcircuitFactory) fact).getSubcircuit();
                }
            }
        }
View Full Code Here


        }
        return ret;
    }

    Element fromComponent(Component comp) {
        ComponentFactory source = comp.getFactory();
        Library lib = findLibrary(source);
        String lib_name;
        if (lib == null) {
            loader.showError(source.getName() + " component not found");
            return null;
        } else if (lib == file) {
            lib_name = null;
        } else {
            lib_name = libs.get(lib);
            if (lib_name == null) {
                loader.showError("unknown library within file");
                return null;
            }
        }

        Element ret = doc.createElement("comp");
        if (lib_name != null) {
            ret.setAttribute("lib", lib_name);
        }

        ret.setAttribute("name", source.getName());
        ret.setAttribute("loc", comp.getLocation().toString());
        addAttributeSetContent(ret, comp.getAttributeSet(), comp.getFactory());
        return ret;
    }
View Full Code Here

        frame.getCanvas().getSelection().addListener(this);
    }

    @Override
    public String getTitle() {
        ComponentFactory wireFactory = null;
        ComponentFactory factory = null;
        int factoryCount = 0;
        int totalCount = 0;
        boolean variousFound = false;

        Selection selection = frame.getCanvas().getSelection();
        for (Component comp : selection.getComponents()) {
            ComponentFactory fact = comp.getFactory();
            if (fact.equals(factory)) {
                factoryCount++;
            } else if (comp instanceof Wire) {
                wireFactory = fact;
                if (factory == null) {
                    factoryCount++;
View Full Code Here

    public ComponentFactory getFactory(boolean forceLoad) {
        return forceLoad ? getFactory() : factory;
    }

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

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

        int y = lastY;
        if (x == INVALID_COORD || y == INVALID_COORD) {
            return;
        }

        ComponentFactory source = getFactory();
        if (source == null) {
            return;
        }

        if (state == SHOW_GHOST) {
            source.drawGhost(context, Color.GRAY, x, y, getBaseAttributes());
        } else if (state == SHOW_ADD) {
            source.drawGhost(context, Color.BLACK, x, y, getBaseAttributes());
        }
    }
View Full Code Here

            moveTo(canvas, g, e.getX(), e.getY());

            Location loc = Location.create(e.getX(), e.getY());
            AttributeSet attrsCopy = (AttributeSet) attrs.clone();
            ComponentFactory source = getFactory();
            if (source == null) {
                return;
            }

            Component c = source.createComponent(loc, attrsCopy);

            if (circ.hasConflict(c)) {
                canvas.setErrorMessage(getFromLocale("exclusiveError"), 0, 0);
                return;
            }
View Full Code Here

    }

    private void processKeyEvent(Canvas canvas, KeyEvent event, int type) {
        KeyConfigurator handler = keyHandler;
        if (!keyHandlerTried) {
            ComponentFactory source = getFactory();
            AttributeSet baseAttrs = getBaseAttributes();
            handler = (KeyConfigurator) source.getFeature(KeyConfigurator.class, baseAttrs);
            keyHandler = handler;
            keyHandlerTried = true;
        }

        if (handler != null) {
View Full Code Here

            }
        }
    }

    private void setFacing(Canvas canvas, Direction facing) {
        ComponentFactory source = getFactory();
        if (source == null) {
            return;
        }

        AttributeSet base = getBaseAttributes();
        Object feature = source.getFeature(ComponentFactory.FACING_ATTRIBUTE_KEY, base);
        @SuppressWarnings("unchecked")
        Attribute<Direction> attr = (Attribute<Direction>) feature;
        if (attr != null) {
            Action act = ToolAttributeAction.create(this, attr, facing);
            canvas.getProject().doAction(act);
View Full Code Here

                icon.paintIcon(c.getDestination(), c.getGraphics(), x + 2, y + 2);
                return;
            }
        }

        ComponentFactory source = getFactory();
        if (source != null) {
            AttributeSet base = getBaseAttributes();
            source.paintIcon(c, x, y, base);
        }
    }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.comp.ComponentFactory

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.