Package com.cburch.logisim.data

Examples of com.cburch.logisim.data.Location


   
    Graphics g = context.getGraphics();
    GraphicsUtil.switchToWidth(g, 2);
    for (Entry e : data) {
      if (e.state == state) {
        Location p = e.loc;
        g.drawOval(p.getX() - 4, p.getY() - 4, 8, 8);
      } else if (stateMap.containsKey(e.state)) {
        CircuitState substate = stateMap.get(e.state);
        Component subcirc = substate.getSubcircuit();
        Bounds b = subcirc.getBounds();
        g.drawRect(b.getX(), b.getY(), b.getWidth(), b.getHeight());
View Full Code Here


  }
 
  @Override
  public final Location getRandomPoint(Bounds bds, Random rand) {
    if (getPaintType() == DrawAttr.PAINT_STROKE) {
      Location ret = getRandomBoundaryPoint(bds, rand);
      int w = getStrokeWidth();
      if (w > 1) {
        int dx = rand.nextInt(w) - w / 2;
        int dy = rand.nextInt(w) - w / 2;
        ret = ret.translate(dx, dy);
      }
      return ret;
    } else {
      return super.getRandomPoint(bds, rand);
    }
View Full Code Here

      for (int i = 0, n = hs.length; i < n; i++) {
        Handle h = hs[i];
        if (h.equals(g)) {
          int x = h.getX() + gesture.getDeltaX();
          int y = h.getY() + gesture.getDeltaY();
          Location r;
          if (gesture.isShiftDown()) {
            Location prev = hs[(i + n - 1) % n].getLocation();
            Location next = hs[(i + 1) % n].getLocation();
            if (!closed) {
              if (i == 0) prev = null;
              if (i == n - 1) next = null;
            }
            if (prev == null) {
              r = LineUtil.snapTo8Cardinals(next, x, y);
            } else if (next == null) {
              r = LineUtil.snapTo8Cardinals(prev, x, y);
            } else {
              Location to = Location.create(x, y);
              Location a = LineUtil.snapTo8Cardinals(prev, x, y);
              Location b = LineUtil.snapTo8Cardinals(next, x, y);
              int ad = a.manhattanDistanceTo(to);
              int bd = b.manhattanDistanceTo(to);
              r = ad < bd ? a : b;
            }
          } else {
            r = Location.create(x, y);
          }
View Full Code Here

  public Handle canInsertHandle(Location loc) {
    PolyUtil.ClosestResult result = PolyUtil.getClosestPoint(loc, closed,
        handles);
    int thresh = Math.max(Line.ON_LINE_THRESH, getStrokeWidth() / 2);
    if (result.getDistanceSq() < thresh * thresh) {
      Location resLoc = result.getLocation();
      if (result.getPreviousHandle().isAt(resLoc)
          || result.getNextHandle().isAt(resLoc)) {
        return null;
      } else {
        return new Handle(this, result.getLocation());
View Full Code Here

    }
  }
 
  @Override
  public void insertHandle(Handle desired, Handle previous) {
    Location loc = desired.getLocation();
    Handle[] hs = handles;
    Handle prev;
    if (previous == null) {
      PolyUtil.ClosestResult result = PolyUtil.getClosestPoint(loc,
          closed, hs);
View Full Code Here

        + (exceptions.size() == 1 ? "" : " (" + exceptions.size() + ")"));
    for (WidthIncompatibilityData ex : exceptions) {
      // See whether any of the points are on the canvas.
      boolean isWithin = false;
      for (int i = 0; i < ex.size(); i++) {
        Location p = ex.getPoint(i);
        int x = p.getX();
        int y = p.getY();
        if (x >= viewable.x && x < viewable.x + viewable.width
            && y >= viewable.y && y < viewable.y + viewable.height) {
          isWithin = true;
          break;
        }
      }

      // If none are, insert an arrow.
      if (!isWithin) {
        Location p = ex.getPoint(0);
        int x = p.getX();
        int y = p.getY();
        boolean isWest = x < viewable.x;
        boolean isEast = x >= viewable.x + viewable.width;
        boolean isNorth = y < viewable.y;
        boolean isSouth = y >= viewable.y + viewable.height;
View Full Code Here

  @Override
  public String getToolTipText(MouseEvent event) {
    boolean showTips = AppPreferences.COMPONENT_TIPS.getBoolean();
    if (showTips) {
      Canvas.snapToGrid(event);
      Location loc = Location.create(event.getX(), event.getY());
      ComponentUserEvent e = null;
      for (Component comp : getCircuit().getAllContaining(loc)) {
        Object makerObj = comp.getFeature(ToolTipMaker.class);
        if (makerObj != null && makerObj instanceof ToolTipMaker) {
          ToolTipMaker maker = (ToolTipMaker) makerObj;
          if (e == null) {
            e = new ComponentUserEvent(this, loc.getX(), loc.getY());
          }
          String ret = maker.getToolTip(e);
          if (ret != null) {
            unrepairMouseEvent(event);
            return ret;
View Full Code Here

    g.setFont(old);
  }

  @Override
  public void paintInstance(InstancePainter painter) {
    Location loc = painter.getLocation();
    int x = loc.getX();
    int y = loc.getY();
    Graphics g = painter.getGraphics();
    g.translate(x, y);
    g.setColor(Color.BLACK);
    paintGhost(painter);
    g.translate(-x, -y);
View Full Code Here

      dy = Canvas.snapYToGrid(dy);
    }
    Graphics g = context.getGraphics();
    for (Component comp : unionSet) {
      AttributeSet attrs = comp.getAttributeSet();
      Location loc = comp.getLocation();
      int x = loc.getX() + dx;
      int y = loc.getY() + dy;
      context.setGraphics(g.create());
      comp.getFactory().drawGhost(context, Color.gray, x, y, attrs);
      context.getGraphics().dispose();
    }
    context.setGraphics(g);
View Full Code Here

    return c == null ? Location.create(0, 0) : c.getLocation();
  }
 
  public boolean isPortConnected(int index) {
    Circuit circ = context.getCircuit();
    Location loc = comp.getEnd(index).getLocation();
    return circ.isConnected(loc, comp);
  }
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.