Package com.cburch.logisim.data

Examples of com.cburch.logisim.data.Location


    }

    int[] lengths = new int[inputs];
    INPUT_LENGTHS.put(key, lengths);
    int width = mainHeight;
    Location loc0 = OrGate.FACTORY.getInputOffset(attrs, 0);
    Location locn = OrGate.FACTORY.getInputOffset(attrs, inputs - 1);
    int totalHeight = 10 + loc0.manhattanDistanceTo(locn);
    if (totalHeight < width) totalHeight = width;
   
    GeneralPath path = computeShield(width, totalHeight);
    for (int i = 0; i < inputs; i++) {
      Location loci = OrGate.FACTORY.getInputOffset(attrs, i);
      Point2D p = new Point2D.Float(loci.getX() + 1, loci.getY());
      int iters = 0;
      while (path.contains(p) && iters < 15) {
        iters++;
        p.setLocation(p.getX() + 1, p.getY());
      }
View Full Code Here


    painter.drawPort(IN1);
    painter.drawPort(OUT);
    painter.drawPort(C_IN,  "c in",  Direction.NORTH);
    painter.drawPort(C_OUT, "c out", Direction.SOUTH);

    Location loc = painter.getLocation();
    int x = loc.getX();
    int y = loc.getY();
    GraphicsUtil.switchToWidth(g, 2);
    g.setColor(Color.BLACK);
    g.drawLine(x - 15, y, x - 5, y);
    g.drawLine(x - 10, y - 5, x - 10, y + 5);
    GraphicsUtil.switchToWidth(g, 1);
View Full Code Here

  private boolean isButton1(MouseEvent e) {
    return (e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0;
  }
 
  private void handlePopupTrigger(MouseEvent e) {
    Location loc = Location.create(e.getX(), e.getY());
    List<CanvasObject> objects = canvas.getModel().getObjectsFromTop();
    CanvasObject clicked = null;
    for (CanvasObject o : objects) {
      if (o.contains(loc, false)) {
        clicked = o;
View Full Code Here

    boolean enable = instance.getAttributeValue(Plexers.ATTR_ENABLE).booleanValue();
   
    int selMult = selectLoc == Plexers.SELECT_BOTTOM_LEFT ? 1 : -1;
    int inputs = 1 << select.getWidth();
    Port[] ps = new Port[inputs + (enable ? 3 : 2)];
    Location sel;
    if (inputs == 2) {
      Location end0;
      Location end1;
      if (dir == Direction.WEST) {
        end0 = Location.create(30, -10);
        end1 = Location.create(3010);
        sel = Location.create(20, selMult * 20);
      } else if (dir == Direction.NORTH) {
        end0 = Location.create(-10, 30);
        end1 = Location.create( 10, 30);
        sel = Location.create(selMult * -2020);
      } else if (dir == Direction.SOUTH) {
        end0 = Location.create(-10, -30);
        end1 = Location.create( 10, -30);
        sel = Location.create(selMult * -20, -20);
      } else {
        end0 = Location.create(-30, -10);
        end1 = Location.create(-3010);
        sel = Location.create(-20, selMult * 20);
      }
      ps[0] = new Port(end0.getX(), end0.getY(), Port.INPUT,  data.getWidth());
      ps[1] = new Port(end1.getX(), end1.getY(), Port.INPUT,  data.getWidth());
    } else {
      int dx = -(inputs / 2) * 10;
      int ddx = 10;
      int dy = -(inputs / 2) * 10;
      int ddy = 10;
      if (dir == Direction.WEST) {
        dx = 40; ddx = 0;
        sel = Location.create(20, selMult * (dy + 10 * inputs));
      } else if (dir == Direction.NORTH) {
        dy = 40; ddy = 0;
        sel = Location.create(selMult * dx, 20);
      } else if (dir == Direction.SOUTH) {
        dy = -40; ddy = 0;
        sel = Location.create(selMult * dx, -20);
      } else {
        dx = -40; ddx = 0;
        sel = Location.create(-20, selMult * (dy + 10 * inputs));
      }
      for (int i = 0; i < inputs; i++) {
        ps[i] = new Port(dx, dy, Port.INPUT, data.getWidth());
        dx += ddx;
        dy += ddy;
      }
    }
    Location en = sel.translate(dir, 10);
    ps[inputs] = new Port(sel.getX(), sel.getY(), Port.INPUT, select.getWidth());
    if (enable) {
      ps[inputs + 1] = new Port(en.getX(), en.getY(), Port.INPUT, BitWidth.ONE);
    }
    ps[ps.length - 1] = new Port(0, 0, Port.OUTPUT, data.getWidth());

    for (int i = 0; i < inputs; i++) {
      ps[i].setToolTip(Strings.getter("multiplexerInTip", "" + i));
View Full Code Here

    Object selectLoc = painter.getAttributeValue(Plexers.ATTR_SELECT_LOC);
    int selMult = selectLoc == Plexers.SELECT_BOTTOM_LEFT ? 1 : -1;
    int dx = vertical ? 0 : -selMult;
    int dy = vertical ? selMult : 0;
    if (inputs == 2) { // draw select wire
      Location pt = painter.getInstance().getPortLocation(inputs);
      if (painter.getShowState()) {
        g.setColor(painter.getPort(inputs).getColor());
      }
      g.drawLine(pt.getX() - 2 * dx, pt.getY() - 2 * dy,
          pt.getX(), pt.getY());
    }
    if (enable) {
      Location en = painter.getInstance().getPortLocation(inputs + 1);
      if (painter.getShowState()) {
        g.setColor(painter.getPort(inputs + 1).getColor());
      }
      int len = inputs == 2 ? 6 : 4;
      g.drawLine(en.getX() - len * dx, en.getY() - len * dy,
          en.getX(), en.getY());
    }
    GraphicsUtil.switchToWidth(g, 1);
   
    // draw a circle indicating where the select input is located
    Multiplexer.drawSelectCircle(g, bds, painter.getInstance().getPortLocation(inputs));
View Full Code Here

    painter.drawPorts();
  }
 
  static void drawSelectCircle(Graphics g, Bounds bds, Location loc) {
    int locDelta = Math.max(bds.getHeight(), bds.getWidth()) <= 50 ? 8 : 6;
    Location circLoc;
    if (bds.getHeight() >= bds.getWidth()) { // vertically oriented
      if (loc.getY() < bds.getY() + bds.getHeight() / 2) { // at top
        circLoc = loc.translate(0, locDelta);
      } else { // at bottom
        circLoc = loc.translate(0, -locDelta);
      }
    } else {
      if (loc.getX() < bds.getX() + bds.getWidth() / 2) { // at left
        circLoc = loc.translate(locDelta, 0);
      } else { // at right
        circLoc = loc.translate(-locDelta, 0);
      }
    }
    g.setColor(Color.LIGHT_GRAY);
    g.fillOval(circLoc.getX() - 3, circLoc.getY() - 3, 6, 6);
  }
View Full Code Here

    g.drawRoundRect(-30, -10, 30, 30, 8, 8);
  }

  @Override
  public void paintInstance(InstancePainter painter) {
    Location loc = painter.getLocation();
    int x = loc.getX();
    int y = loc.getY();
   
    Graphics g = painter.getGraphics();
    g.drawRoundRect(x - 30, y - 10, 30, 30, 8, 8);
    g.drawRoundRect(x - 28, y - 8, 26, 26, 4, 4);
    drawBall(g, x - 15, y + 5, painter.getAttributeValue(Io.ATTR_COLOR),
View Full Code Here

    painter.drawPort(IN1);
    painter.drawPort(OUT);
    painter.drawPort(UPPER, Strings.get("dividerUpperInput"),  Direction.NORTH);
    painter.drawPort(REM, Strings.get("dividerRemainderOutput"), Direction.SOUTH);

    Location loc = painter.getLocation();
    int x = loc.getX();
    int y = loc.getY();
    GraphicsUtil.switchToWidth(g, 2);
    g.setColor(Color.BLACK);
    g.fillOval(x - 12, y - 7, 4, 4);
    g.drawLine(x - 15, y, x - 5, y);
    g.fillOval(x - 12, y + 3, 4, 4);
View Full Code Here

      updateState(state, 0, 0);
    }
   
    @Override
    public void mouseDragged(InstanceState state, MouseEvent e) {
      Location loc = state.getInstance().getLocation();
      int cx = loc.getX() - 15;
      int cy = loc.getY() + 5;
      updateState(state, e.getX() - cx, e.getY() - cy);
    }
View Full Code Here

    Set<CanvasObject> selected = selection.getSelected();
    int action = curAction;
    curAction = IDLE;
   
    if (!dragEffective) {
      Location loc = dragEnd;
      CanvasObject o = getObjectAt(model, loc.getX(), loc.getY(), false);
      if (o != null) {
        Handle han = o.canDeleteHandle(loc);
        if (han != null) {
          selection.setHandleSelected(han);
        } else {
          han = o.canInsertHandle(loc);
          if (han != null) {
            selection.setHandleSelected(han);
          }
        }
      }
    }
   
    Location start = dragStart;
    int x1 = e.getX();
    int y1 = e.getY();
    switch (action) {
    case MOVE_ALL:
      Location moveDelta = selection.getMovingDelta();
      if (dragEffective && !moveDelta.equals(Location.create(0, 0))) {
        canvas.doAction(new ModelTranslateAction(model, selected,
            moveDelta.getX(), moveDelta.getY()));
      }
      break;
    case MOVE_HANDLE:
      HandleGesture gesture = curGesture;
      curGesture = null;
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.