Package com.cburch.logisim.comp

Examples of com.cburch.logisim.comp.ComponentFactory


    boolean changed = false;
    for (Map.Entry<Integer,Tool> entry : map.entrySet()) {
      Integer key = entry.getKey();
      Tool tool = entry.getValue();
      if (tool instanceof AddTool) {
        ComponentFactory factory = ((AddTool) tool).getFactory();
        if (toolMap.containsKey(factory)) {
          changed = true;
          Tool newTool = toolMap.get(factory);
          if (newTool == null) {
            map.remove(key);
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

    // next "if" suggested roughly by Kevin Walsh of Cornell to take care of
    // repaint problems on OpenJDK under Ubuntu
    int x = lastX;
    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

      if (shouldSnap) Canvas.snapToGrid(e);
      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(Strings.getter("exclusiveError"));
        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

  }

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

    toolMap = new HashMap<Tool,Tool>();
    for (Tool oldTool : old.getTools()) {
      Tool newTool = base.getTool(oldTool.getName());
      toolMap.put(oldTool, newTool);
      if (oldTool instanceof AddTool) {
        ComponentFactory oldFactory = ((AddTool) oldTool).getFactory();
        if (newTool != null && newTool instanceof AddTool) {
          ComponentFactory newFactory = ((AddTool) newTool).getFactory();
          componentMap.put(oldFactory, newFactory);
        } else {
          componentMap.put(oldFactory, null);
        }
      }
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.