Package com.cburch.logisim.data

Examples of com.cburch.logisim.data.Location


    repaintArea(canvas, bds);
  }
 
  @Override
  public void mousePressed(Canvas canvas, MouseEvent e) {
    Location loc = Location.create(e.getX(), e.getY());
    Bounds bds = Bounds.create(loc);
    dragStart = loc;
    lastMouseX = loc.getX();
    lastMouseY = loc.getY();
    active = canvas.getModel() != null;
    repaintArea(canvas, bds);
  }
View Full Code Here


    lastMouseX = mx;
    lastMouseY = my;
    if (!active) {
      return Bounds.EMPTY_BOUNDS;
    } else {
      Location start = dragStart;
      int x0 = start.getX();
      int y0 = start.getY();
      int x1 = mx;
      int y1 = my;
      if (x0 == x1 && y0 == y1) {
        return Bounds.EMPTY_BOUNDS;
      }
View Full Code Here

  private void configurePorts(Instance instance) {
    Direction facing = instance.getAttributeValue(StdAttr.FACING);

    Port[] ports = new Port[2];
    ports[0] = new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH);
    Location out = Location.create(0, 0).translate(facing, -20);
    ports[1] = new Port(out.getX(), out.getY(), Port.INPUT, StdAttr.WIDTH);
    instance.setPorts(ports);
  }
View Full Code Here

    Graphics g = painter.getGraphics();
    painter.drawBounds();

    painter.drawPorts();

    Location loc = painter.getLocation();
    int x = loc.getX() - 15;
    int y = loc.getY();
    Object shift = painter.getAttributeValue(ATTR_SHIFT);
    g.setColor(Color.BLACK);
    if (shift == SHIFT_LOGICAL_RIGHT) {
      g.fillRect(x, y - 1, 8, 3);
      drawArrow(g, x + 10, y, -4);
View Full Code Here

    painter.drawLabel();
  }

  private void paintBase(InstancePainter painter) {
    Direction facing = painter.getAttributeValue(StdAttr.FACING);
    Location loc = painter.getLocation();
    int x = loc.getX();
    int y = loc.getY();
    Graphics g = painter.getGraphics();
    g.translate(x, y);
    double rotate = 0.0;
    if (facing != Direction.EAST && g instanceof Graphics2D) {
      rotate = -facing.toRadians();
View Full Code Here

    Text clicked = null;
    boolean found = false;
    int mx = e.getX();
    int my = e.getY();
    Location mloc = Location.create(mx, my);
    for (CanvasObject o : canvas.getModel().getObjectsFromTop()) {
      if (o instanceof Text && o.contains(mloc, true)) {
        clicked = (Text) o;
        found = true;
        break;
View Full Code Here

    painter.drawPort(IN1);
    painter.drawPort(OUT);
    painter.drawPort(B_IN,  "b in",  Direction.NORTH);
    painter.drawPort(B_OUT, "b 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);
    GraphicsUtil.switchToWidth(g, 1);
  }
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 - 5, x - 5, y + 5);
    g.drawLine(x - 15, y + 5, x - 5, y - 5);
    GraphicsUtil.switchToWidth(g, 1);
View Full Code Here

    @Override
    public String getLogName(InstanceState state, Object option) {
      if (option instanceof Integer) {
        String disp = Strings.get("ramComponent");
        Location loc = state.getInstance().getLocation();
        return disp + loc + "[" + option + "]";
      } else {
        return null;
      }
    }
View Full Code Here

      return path;
    }
  }

  static void paintInputLines(InstancePainter painter, AbstractGate factory) {
    Location loc = painter.getLocation();
    boolean printView = painter.isPrintView();
    GateAttributes attrs = (GateAttributes) painter.getAttributeSet();
    Direction facing = attrs.facing;
    int inputs = attrs.inputs;
    int negated = attrs.negated;
   
    int[] lengths = getInputLineLengths(attrs, factory);
    if (painter.getInstance() == null) { // drawing ghost - negation bubbles only
      for (int i = 0; i < inputs; i++) {
        boolean iNegated = ((negated >> i) & 1) == 1;
        if (iNegated) {
          Location offs = factory.getInputOffset(attrs, i);
          Location loci = loc.translate(offs.getX(), offs.getY());
          Location cent = loci.translate(facing, lengths[i] + 5);
          painter.drawDongle(cent.getX(), cent.getY());
        }
      }
    } else {
      Graphics g = painter.getGraphics();
      Color baseColor = g.getColor();
      GraphicsUtil.switchToWidth(g, 3);
      for (int i = 0; i < inputs; i++) {
        Location offs = factory.getInputOffset(attrs, i);
        Location src = loc.translate(offs.getX(), offs.getY());
        int len = lengths[i];
        if (len != 0 && (!printView || painter.isPortConnected(i + 1))) {
          if (painter.getShowState()) {
            Value val = painter.getPort(i + 1);
            g.setColor(val.getColor());
          } else {
            g.setColor(baseColor);
          }
          Location dst = src.translate(facing, len);
          g.drawLine(src.getX(), src.getY(), dst.getX(), dst.getY());
        }
        if (((negated >> i) & 1) == 1) {
          Location cent = src.translate(facing, lengths[i] + 5);
          g.setColor(baseColor);
          painter.drawDongle(cent.getX(), cent.getY());
          GraphicsUtil.switchToWidth(g, 3);
        }
      }
    }
  }
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.