Package com.cburch.logisim.tools

Examples of com.cburch.logisim.tools.Tool


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


  }
 
  @Override
  public boolean isSelected(ToolbarItem item) {
    if (item instanceof ToolItem) {
      Tool tool = ((ToolItem) item).tool;
      return tool == proj.getTool();
    } else {
      return false;
    }
  }
View Full Code Here

  }

  @Override
  public void itemSelected(ToolbarItem item) {
    if (item instanceof ToolItem) {
      Tool tool = ((ToolItem) item).tool;
      proj.setTool(tool);
    }
  }
View Full Code Here

      for (Element sub_elt : XmlIterator.forChildElements(elt, "tool")) {
        if (!sub_elt.hasAttribute("name")) {
          loader.showError(Strings.get("toolNameMissingError"));
        } else {
          String tool_str = sub_elt.getAttribute("name");
          Tool tool = ret.getTool(tool_str);
          if (tool != null) {
            try {
              initAttributeSet(sub_elt, tool.getAttributeSet(), tool);
            } catch (XmlReaderException e) {
              addErrors(e, "lib." + name + "." + tool_str);
            }
          }
        }
View Full Code Here

    }

    private void initMouseMappings(Element elt) {
      MouseMappings map = file.getOptions().getMouseMappings();
      for (Element sub_elt : XmlIterator.forChildElements(elt, "tool")) {
        Tool tool;
        try {
          tool = toTool(sub_elt);
        } catch (XmlReaderException e) {
          addErrors(e, "mapping");
          continue;
        }

        String mods_str = sub_elt.getAttribute("map");
        if (mods_str == null || mods_str.equals("")) {
          loader.showError(Strings.get("mappingMissingError"));
          continue;
        }
        int mods;
        try {
          mods = InputEventUtil.fromString(mods_str);
        } catch (NumberFormatException e) {
          loader.showError(StringUtil.format(
            Strings.get("mappingBadError"), mods_str));
          continue;
        }

        tool = tool.cloneTool();
        try {
          initAttributeSet(sub_elt, tool.getAttributeSet(), tool);
        } catch (XmlReaderException e) {
          addErrors(e, "mapping." + tool.getName());
        }

        map.setToolFor(mods, tool);
      }
    }
View Full Code Here

      ToolbarData toolbar = file.getOptions().getToolbarData();
      for (Element sub_elt : XmlIterator.forChildElements(elt)) {
        if (sub_elt.getTagName().equals("sep")) {
          toolbar.addSeparator();
        } else if (sub_elt.getTagName().equals("tool")) {
          Tool tool;
          try {
            tool = toTool(sub_elt);
          } catch (XmlReaderException e) {
            addErrors(e, "toolbar");
            continue;
          }
          if (tool != null) {
            tool = tool.cloneTool();
            try {
              initAttributeSet(sub_elt, tool.getAttributeSet(), tool);
            } catch (XmlReaderException e) {
              addErrors(e, "toolbar." + tool.getName());
            }
            toolbar.addTool(tool);
          }
        }
      }
View Full Code Here

      Library lib = findLibrary(elt.getAttribute("lib"));
      String name = elt.getAttribute("name");
      if (name == null || name.equals("")) {
        throw new XmlReaderException(Strings.get("toolNameMissing"));
      }
      Tool tool = lib.getTool(name);
      if (tool == null) {
        throw new XmlReaderException(Strings.get("toolNotFound"));
      }
      return tool;
    }
View Full Code Here

        // but it exists there in the 1.4 and 5.0 versions.
        mouseDragged(e);
        return;
      }
     
      Tool tool = getToolFor(e);
      if (tool != null) {
        tool.mouseMoved(Canvas.this, getGraphics(), e);
      }
    }
View Full Code Here

    public void mouseEntered(MouseEvent e) {
      if (drag_tool != null) {
        drag_tool.mouseEntered(Canvas.this, getGraphics(), e);
      } else {
        Tool tool = getToolFor(e);
        if (tool != null) {
          tool.mouseEntered(Canvas.this, getGraphics(), e);
        }
      }
    }
View Full Code Here

  private void drawWithUserState(Graphics base, Graphics g, Project proj) {
    Circuit circ = proj.getCurrentCircuit();
    Selection sel = proj.getSelection();
    Set<Component> hidden;
    Tool dragTool = canvas.getDragTool();
    if (dragTool == null) {
      hidden = NO_COMPONENTS;
    } else {
      hidden = dragTool.getHiddenComponents(canvas);
      if (hidden == null) hidden = NO_COMPONENTS;
    }

    // draw halo around component whose attributes we are viewing
    boolean showHalo = AppPreferences.ATTRIBUTE_HALO.getBoolean();
    if (showHalo && haloedComponent != null && haloedCircuit == circ
        && !hidden.contains(haloedComponent)) {
      GraphicsUtil.switchToWidth(g, 3);
      g.setColor(Canvas.HALO_COLOR);
      Bounds bds = haloedComponent.getBounds(g).expand(5);
      int w = bds.getWidth();
      int h = bds.getHeight();
      double a = Canvas.SQRT_2 * w;
      double b = Canvas.SQRT_2 * h;
      g.drawOval((int) Math.round(bds.getX() + w/2.0 - a/2.0),
        (int) Math.round(bds.getY() + h/2.0 - b/2.0),
        (int) Math.round(a), (int) Math.round(b));
      GraphicsUtil.switchToWidth(g, 1);
      g.setColor(Color.BLACK);
    }

    // draw circuit and selection
    CircuitState circState = proj.getCircuitState();
    boolean printerView = AppPreferences.PRINTER_VIEW.getBoolean();
    ComponentDrawContext context = new ComponentDrawContext(canvas,
        circ, circState, base, g, printerView);
    context.setHighlightedWires(highlightedWires);
    circ.draw(context, hidden);
    sel.draw(context, hidden);

    // draw tool
    Tool tool = dragTool != null ? dragTool : proj.getTool();
    if (tool != null && !canvas.isPopupMenuUp()) {
      Graphics gCopy = g.create();
      context.setGraphics(gCopy);
      tool.draw(canvas, context);
      gCopy.dispose();
    }
  }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.tools.Tool

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.