Package com.cburch.logisim.data

Examples of com.cburch.logisim.data.Location


  public Bounds getOffsetBounds() {
    InstanceComponent c = comp;
    if (c == null) {
      return factory.getOffsetBounds(attrs);
    } else {
      Location loc = c.getLocation();
      return c.getBounds().translate(-loc.getX(), -loc.getY());
    }
  }
View Full Code Here


      Circuit circ = canvas.getCircuit();
      if (!canvas.getProject().getLogisimFile().contains(circ)) return;
      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);
     
View Full Code Here

    Port[] ports = new Port[portLocs.size()];
    Instance[] pins = new Instance[portLocs.size()];
    int i = -1;
    for (Map.Entry<Location, Instance> portLoc : portLocs.entrySet()) {
      i++;
      Location loc = portLoc.getKey();
      Instance pin = portLoc.getValue();
      String type = Pin.FACTORY.isInputPin(pin) ? Port.INPUT : Port.OUTPUT;
      BitWidth width = pin.getAttributeValue(StdAttr.WIDTH);
      ports[i] = new Port(loc.getX(), loc.getY(), type, width);
      pins[i] = pin;
     
      String label = pin.getAttributeValue(StdAttr.LABEL);
      if (label != null && label.length() > 0) {
        ports[i].setToolTip(StringUtil.constantGetter(label));
View Full Code Here

 
  private void paintBase(InstancePainter painter, Graphics g) {
    CircuitAttributes attrs = (CircuitAttributes) painter.getAttributeSet();
    Direction facing = attrs.getFacing();
    Direction defaultFacing = source.getAppearance().getFacing();
    Location loc = painter.getLocation();
    g.translate(loc.getX(), loc.getY());
    source.getAppearance().paintSubcircuit(g, facing);
    drawCircuitLabel(painter, getOffsetBounds(attrs), facing, defaultFacing);
    g.translate(-loc.getX(), -loc.getY());
    painter.drawLabel();
  }
View Full Code Here

  @Override
  public void mousePressed(Canvas canvas, Graphics g, MouseEvent e) {
    int x = e.getX();
    int y = e.getY();
    Location pt = Location.create(x, y);

    JPopupMenu menu;
    Project proj = canvas.getProject();
    Selection sel = proj.getSelection();
    Collection<Component> in_sel = sel.getComponentsContaining(pt, g);
View Full Code Here

    int axis = baseWidth / 2 + (negateOutput ? 10 : 0);
    int perp = 0;
    if (AppPreferences.GATE_SHAPE.get().equals(AppPreferences.SHAPE_RECTANGULAR)) {
      perp += 6;
    }
    Location loc = instance.getLocation();
    int cx;
    int cy;
    if (facing == Direction.NORTH) {
      cx = loc.getX() + perp;
      cy = loc.getY() + axis;
    } else if (facing == Direction.SOUTH) {
      cx = loc.getX() - perp;
      cy = loc.getY() - axis;
    } else if (facing == Direction.WEST) {
      cx = loc.getX() + axis;
      cy = loc.getY() - perp;
    } else {
      cx = loc.getX() - axis;
      cy = loc.getY() + perp;
    }
    instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT, cx, cy,
        TextField.H_CENTER, TextField.V_CENTER);
  }
View Full Code Here

    int inputs = attrs.inputs;

    Port[] ports = new Port[inputs + 1];
    ports[0] = new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH);
    for (int i = 0; i < inputs; i++) {
      Location offs = getInputOffset(attrs, i);
      ports[i + 1] = new Port(offs.getX(), offs.getY(), Port.INPUT, StdAttr.WIDTH);
    }
    instance.setPorts(ports);
  }
View Full Code Here

      CanvasObject add = commit(canvas);
      canvas.toolGestureComplete(this, add);
      return;
    }

    Location loc = Location.create(mx, my);
    ArrayList<Location> locs = locations;
    if (!active) { locs.clear(); locs.add(loc); }
    locs.add(loc);

    mouseDown = true;
View Full Code Here

    if (active) {
      updateMouse(canvas, e.getX(), e.getY(), e.getModifiersEx());
      mouseDown = false;
      int size = locations.size();
      if (size >= 3) {
        Location first = locations.get(0);
        Location last = locations.get(size - 1);
        if (first.manhattanDistanceTo(last) <= CLOSE_TOLERANCE) {
          locations.remove(size - 1);
          CanvasObject add = commit(canvas);
          canvas.toolGestureComplete(this, add);
        }
View Full Code Here

  private void updateMouse(Canvas canvas, int mx, int my, int mods) {
    lastMouseX = mx;
    lastMouseY = my;
    if (active) {
      int index = locations.size() - 1;
      Location last = locations.get(index);
      Location newLast;
      if ((mods & MouseEvent.SHIFT_DOWN_MASK) != 0 && index > 0) {
        Location nextLast = locations.get(index - 1);
        newLast = LineUtil.snapTo8Cardinals(nextLast, mx, my);
      } else {
        newLast = Location.create(mx, my);
      }
      if ((mods & MouseEvent.CTRL_DOWN_MASK) != 0) {
View Full Code Here

TOP

Related Classes of com.cburch.logisim.data.Location

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.