Package com.cburch.logisim.data

Examples of com.cburch.logisim.data.Bounds


    Iterator<Component> it = unionSet.iterator();
    if (it.hasNext()) {
      bounds = it.next().getBounds(g);
      while (it.hasNext()) {
        Component comp = it.next();
        Bounds bds = comp.getBounds(g);
        bounds = bounds.add(bds);
      }
    } else {
      bounds = Bounds.EMPTY_BOUNDS;
    }
View Full Code Here


              if (selfConflicts || !components.contains(conflict)) return true;
            }
          }
        }
        Location newLoc = comp.getLocation().translate(dx, dy);
        Bounds newBounds = comp.getBounds().translate(dx, dy);
        for (Component comp2 : circuit.getAllContaining(newLoc)) {
          Bounds bds = comp2.getBounds();
          if (bds.equals(newBounds)) {
            if (selfConflicts || !components.contains(comp2)) return true;
          }
        }
      }
    }
View Full Code Here

  private static Bounds computeBounds(Collection<Component> components) {
    if (components.isEmpty()) {
      return Bounds.EMPTY_BOUNDS;
    } else {
      Iterator<Component> it = components.iterator();
      Bounds ret = it.next().getBounds();
      while (it.hasNext()) {
        Component comp = it.next();
        Bounds bds = comp.getBounds();
        ret = ret.add(bds);
      }
      return ret;
    }
  }
View Full Code Here

 
  private HashMap<Component,Component> copyComponents(Collection<Component> components) {
    // determine translation offset where we can legally place the clipboard
    int dx;
    int dy;
    Bounds bds = computeBounds(components);
    for (int index = 0; ; index++) {
      // compute offset to try: We try points along successively larger
      // squares radiating outward from 0,0
      if (index == 0) {
        dx = 0;
        dy = 0;
      } else {
        int side = 1;
        while (side * side <= index) side += 2;
        int offs = index - (side - 2) * (side - 2);
        dx = side / 2;
        dy = side / 2;
        if (offs < side - 1) { // top edge of square
          dx -= offs;
        } else if (offs < 2 * (side - 1)) { // left edge
          offs -= side - 1;
          dx = -dx;
          dy -= offs;
        } else if (offs < 3 * (side - 1)) { // right edge
          offs -= 2 * (side - 1);
          dx = -dx + offs;
          dy = -dy;
        } else {
          offs -= 3 * (side - 1);
          dy = -dy + offs;
        }
        dx *= 10;
        dy *= 10;
      }
     
      if (bds.getX() + dx >= 0 && bds.getY() + dy >= 0
          && !hasConflictTranslated(components, dx, dy, true)) {
        return copyComponents(components, dx, dy);
      }
    }
  }
View Full Code Here

      } while (usedLocs.contains(loc));
      return loc;
    }
   
    // otherwise place it on the boundary of the bounding rectangle
    Bounds bds = appear.getAbsoluteBounds();
    int x;
    int y;
    int dx = 0;
    int dy = 0;
    if (facing == Direction.EAST) { // on west side by default
      x = bds.getX() - 7;
      y = bds.getY() + 5;
      dy = 10;
    } else if (facing == Direction.WEST) { // on east side by default
      x = bds.getX() + bds.getWidth() - 3;
      y = bds.getY() + 5;
      dy = 10;
    } else if (facing == Direction.SOUTH) { // on north side by default
      x = bds.getX() + 5;
      y = bds.getY() - 7;
      dx = 10;
    } else { // on south side by default
      x = bds.getX() + 5;
      y = bds.getY() + bds.getHeight() - 3;
      dx = 10;
    }
    x = (x + 9) / 10 * 10; // round coordinates up to ensure they're on grid
    y = (y + 9) / 10 * 10;
    Location loc = Location.create(x, y);
View Full Code Here

    SplitterAttributes attrs = (SplitterAttributes) attrsBase;
    int fanout = attrs.fanout;
    SplitterParameters parms = attrs.getParameters();
    int xEnd0 = parms.getEnd0X();
    int yEnd0 = parms.getEnd0Y();
    Bounds bds = Bounds.create(0, 0, 1, 1);
    bds = bds.add(xEnd0, yEnd0);
    bds = bds.add(xEnd0 + (fanout - 1) * parms.getEndToEndDeltaX(),
        yEnd0 + (fanout - 1) * parms.getEndToEndDeltaY());
    return bds;
  }
View Full Code Here

    g.drawLine(e0.getX(), e0.getY(), e1.getX(), e1.getY());
  }
 
  @Override
  public Bounds getBounds() {
    Bounds bds = super.getBounds(RADIUS);
    Location center = getLocation();
    Location end = center.translate(facing, RADIUS + INDICATOR_LENGTH);
    return bds.add(end);
  }
View Full Code Here

  public Bounds getAbsoluteBounds() {
    return getBounds(false);
  }
 
  private Bounds getBounds(boolean relativeToAnchor) {
    Bounds ret = null;
    Location offset = null;
    for (CanvasObject o : getObjectsFromBottom()) {
      if (o instanceof AppearanceElement) {
        Location loc = ((AppearanceElement) o).getLocation();
        if (o instanceof AppearanceAnchor) {
          offset = loc;
        }
        if (ret == null) {
          ret = Bounds.create(loc);
        } else {
          ret = ret.add(loc);
        }
      } else {
        if (ret == null) {
          ret = o.getBounds();
        } else {
          ret = ret.add(o.getBounds());
        }
      }
    }
    if (ret == null) {
      return Bounds.EMPTY_BOUNDS;
    } else if (relativeToAnchor && offset != null) {
      return ret.translate(-offset.getX(), -offset.getY());
    } else {
      return ret;
    }
  }
View Full Code Here

  Bounds getOffsetBounds() {
    return offsetBounds;
  }
 
  boolean setOffsetBounds(Bounds value) {
    Bounds old = offsetBounds;
    boolean same = old == null ? value == null : old.equals(value);
    if (!same) {
      offsetBounds = value;
    }
    return !same;
  }
View Full Code Here

    return new CounterAttributes();
  }
 
  @Override
  protected void configureNewInstance(Instance instance) {
    Bounds bds = instance.getBounds();
    instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT,
        bds.getX() + bds.getWidth() / 2, bds.getY() - 3,
        GraphicsUtil.H_CENTER, GraphicsUtil.V_BASELINE);
  }
View Full Code Here

TOP

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

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.