Package com.cburch.logisim.tools.key

Examples of com.cburch.logisim.tools.key.KeyConfigurator


  @Override
  public Object getFeature(Object key, AttributeSet attrs) {
    if (key == FACING_ATTRIBUTE_KEY) {
      return StdAttr.FACING;
    } else if (key == KeyConfigurator.class) {
      KeyConfigurator altConfig = ParallelConfigurator.create(
          new BitWidthConfigurator(SplitterAttributes.ATTR_WIDTH),
          new IntegerConfigurator(SplitterAttributes.ATTR_FANOUT,
              1, 32, InputEvent.ALT_DOWN_MASK));
      return JoinedConfigurator.create(
        new IntegerConfigurator(SplitterAttributes.ATTR_FANOUT, 1, 32, 0),
View Full Code Here


  public void keyTyped(Canvas canvas, KeyEvent event) {
    processKeyEvent(canvas, event, KeyConfigurationEvent.KEY_TYPED);
  }
 
  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) {
      AttributeSet baseAttrs = getBaseAttributes();
      KeyConfigurationEvent e = new KeyConfigurationEvent(type, baseAttrs, event, this);
      KeyConfigurationResult r = handler.keyEventReceived(e);
      if (r != null) {
        Action act = ToolAttributeAction.create(r);
        canvas.getProject().doAction(act);
      }
    }
View Full Code Here

      for (Component comp : sel.getComponents()) {
        ComponentFactory factory = comp.getFactory();
        AttributeSet attrs = comp.getAttributeSet();
        Object handler = factory.getFeature(KeyConfigurator.class, attrs);
        if (handler != null) {
          KeyConfigurator base = (KeyConfigurator) handler;
          handlers.put(comp, base.clone());
        }
      }
      keyHandlers = handlers;
    }

    if (!handlers.isEmpty()) {
      boolean consume = false;
      ArrayList<KeyConfigurationResult> results;
      results = new ArrayList<KeyConfigurationResult>();
      for (Map.Entry<Component, KeyConfigurator> entry : handlers.entrySet()) {
        Component comp = entry.getKey();
        KeyConfigurator handler = entry.getValue();
        KeyConfigurationEvent event = new KeyConfigurationEvent(type,
            comp.getAttributeSet(), e, comp);
        KeyConfigurationResult result = handler.keyEventReceived(event);
        consume |= event.isConsumed();
        if (result != null) {
          results.add(result);
        }
      }
View Full Code Here

    @Override
    public Object getFeature(Object key, AttributeSet attrs) {
        if (key == FACING_ATTRIBUTE_KEY) {
            return StdAttr.FACING;
        } else if (key == KeyConfigurator.class) {
            KeyConfigurator altConfig = ParallelConfigurator.create(
                    new BitWidthConfigurator(SplitterAttributes.ATTR_WIDTH),
                    new IntegerConfigurator(SplitterAttributes.ATTR_FANOUT,
                            1, 32, InputEvent.ALT_DOWN_MASK));
            return JoinedConfigurator.create(
                new IntegerConfigurator(SplitterAttributes.ATTR_FANOUT, 1, 32, 0),
View Full Code Here

    public void keyTyped(Canvas canvas, KeyEvent event) {
        processKeyEvent(canvas, event, KeyConfigurationEvent.KEY_TYPED);
    }

    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) {
            AttributeSet baseAttrs = getBaseAttributes();
            KeyConfigurationEvent e = new KeyConfigurationEvent(type, baseAttrs, event, this);
            KeyConfigurationResult r = handler.keyEventReceived(e);
            if (r != null) {
                Action act = ToolAttributeAction.create(r);
                canvas.getProject().doAction(act);
            }
        }
View Full Code Here

            for (Component comp : sel.getComponents()) {
                ComponentFactory factory = comp.getFactory();
                AttributeSet attrs = comp.getAttributeSet();
                Object handler = factory.getFeature(KeyConfigurator.class, attrs);
                if (handler != null) {
                    KeyConfigurator base = (KeyConfigurator) handler;
                    handlers.put(comp, base.clone());
                }
            }
            keyHandlers = handlers;
        }

        if (!handlers.isEmpty()) {
            boolean consume = false;
            ArrayList<KeyConfigurationResult> results;
            results = new ArrayList<KeyConfigurationResult>();
            for (Map.Entry<Component, KeyConfigurator> entry : handlers.entrySet()) {
                Component comp = entry.getKey();
                KeyConfigurator handler = entry.getValue();
                KeyConfigurationEvent event = new KeyConfigurationEvent(type,
                        comp.getAttributeSet(), e, comp);
                KeyConfigurationResult result = handler.keyEventReceived(event);
                consume |= event.isConsumed();
                if (result != null) {
                    results.add(result);
                }
            }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.tools.key.KeyConfigurator

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.