Package com.cburch.logisim.data

Examples of com.cburch.logisim.data.Bounds


  public Bounds getBounds() {
    return bounds;
  }

  public Bounds getBounds(Graphics g) {
    Bounds ret = bounds;
    InstanceTextField field = textField;
    if (field != null) ret = ret.add(field.getBounds(g));
    return ret;
  }
View Full Code Here


    painter.setInstance(this);
    factory.paintInstance(painter);
  }

  public void expose(ComponentDrawContext context) {
    Bounds b = bounds;
    context.getDestination().repaint(b.getX(), b.getY(), b.getWidth(), b.getHeight());
  }
View Full Code Here

  public void draw(Graphics g) {
    if (field.getFont() != null) g.setFont(field.getFont());

    // draw boundary
    Bounds bds = getBounds(g);
    g.setColor(Color.white);
    g.fillRect(bds.getX(), bds.getY(),
        bds.getWidth(), bds.getHeight());
    g.setColor(Color.black);
    g.drawRect(bds.getX(), bds.getY(),
        bds.getWidth(), bds.getHeight());

    // draw text
    int x = field.getX();
    int y = field.getY();
    FontMetrics fm = g.getFontMetrics();
View Full Code Here

      ++pos;
    }
  }

  private void moveCaret(int x, int y) {
    Bounds bds = getBounds(g);
    FontMetrics fm = g.getFontMetrics();
    x -= bds.getX();
    int last = 0;
    for (int i = 0; i < curText.length(); i++) {
      int cur = fm.stringWidth(curText.substring(0, i + 1));
      if (x <= (last + cur) / 2) {
        pos = i;
View Full Code Here

 
  private boolean mouseDown;

  @Override
  public Bounds getBounds(InstancePainter painter) {
    Bounds bds = painter.getInstance().getBounds();
    int cx = bds.getX() + bds.getWidth() / 2;
    int cy = bds.getY() + bds.getHeight() / 2;
    return Bounds.create(cx - 5, cy - 5, 15, 15);
  }
View Full Code Here

 
  @Override
  public void paint(InstancePainter painter) {
    if (painter.getDestination() instanceof Canvas
        && painter.getData() instanceof CircuitState) {
      Bounds bds = painter.getInstance().getBounds();
      int cx = bds.getX() + bds.getWidth() / 2;
      int cy = bds.getY() + bds.getHeight() / 2;
 
      int tx = cx + 3;
      int ty = cy + 3;
      int[] xp = { tx - 1, cx + 8, cx + 10, tx + 1 };
      int[] yp = { ty + 1, cy + 10, cy + 8, ty - 1 };
View Full Code Here

      }
    }
  }
 
  private boolean isWithin(InstanceState state, MouseEvent e) {
    Bounds bds = state.getInstance().getBounds();
    int cx = bds.getX() + bds.getWidth() / 2;
    int cy = bds.getY() + bds.getHeight() / 2;
    int dx = e.getX() - cx;
    int dy = e.getY() - cy;
    return dx * dx + dy * dy <= 60;
  }
View Full Code Here

  }

  private void exposeHaloedComponent(Graphics g) {
    Component c = haloedComponent;
    if (c == null) return;
    Bounds bds = c.getBounds(g).expand(7);
    int w = bds.getWidth();
    int h = bds.getHeight();
    double a = Canvas.SQRT_2 * w;
    double b = Canvas.SQRT_2 * h;
    canvas.repaint((int) Math.round(bds.getX() + w/2.0 - a/2.0),
      (int) Math.round(bds.getY() + h/2.0 - b/2.0),
      (int) Math.round(a), (int) Math.round(b));
  }
View Full Code Here

    boolean showHalo = AppPreferences.ATTRIBUTE_HALO.getBoolean();
    if (showHalo && haloedComponent != null && haloedCircuit == circ
        && !hidden.contains(haloedComponent)) {
      GraphicsUtil.switchToWidth(g, 3);
      g.setColor(Canvas.HALO_COLOR);
      Bounds bds = haloedComponent.getBounds(g).expand(5);
      int w = bds.getWidth();
      int h = bds.getHeight();
      double a = Canvas.SQRT_2 * w;
      double b = Canvas.SQRT_2 * h;
      g.drawOval((int) Math.round(bds.getX() + w/2.0 - a/2.0),
        (int) Math.round(bds.getY() + h/2.0 - b/2.0),
        (int) Math.round(a), (int) Math.round(b));
      GraphicsUtil.switchToWidth(g, 1);
      g.setColor(Color.BLACK);
    }

View Full Code Here

  // helper methods
  //
  public void drawBounds(Component comp) {
    GraphicsUtil.switchToWidth(g, 2);
    g.setColor(Color.BLACK);
    Bounds bds = comp.getBounds();
    g.drawRect(bds.getX(), bds.getY(),
        bds.getWidth(), bds.getHeight());
    GraphicsUtil.switchToWidth(g, 1);
  }
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.