Package com.cburch.logisim.data

Examples of com.cburch.logisim.data.Bounds


  public void drawRectangle(Component comp) {
    drawRectangle(comp, "");
  }
 
  public void drawRectangle(Component comp, String label) {
    Bounds bds = comp.getBounds(g);
    drawRectangle(bds.getX(), bds.getY(), bds.getWidth(),
      bds.getHeight(), label);
  }
View Full Code Here


    }
  }
 
  public void drawRectangle(ComponentFactory source, int x, int y,
      AttributeSet attrs, String label) {
    Bounds bds = source.getOffsetBounds(attrs);
    drawRectangle(source, x + bds.getX(), y + bds.getY(), bds.getWidth(),
      bds.getHeight(), label);
  }
View Full Code Here

    g.setColor(curColor);
    GraphicsUtil.switchToWidth(g, 1);
  }

  public void drawHandles(Component comp) {
    Bounds b = comp.getBounds(g);
    int left = b.getX();
    int right = left + b.getWidth();
    int top = b.getY();
    int bot = top + b.getHeight();
    drawHandle(right, top);
    drawHandle(left,  bot);
    drawHandle(right, bot);
    drawHandle(left,  top);
  }
View Full Code Here

  @Override
  public Bounds getBounds() {
    if (bounds == null) {
      Location loc = getLocation();
      Bounds offBounds = getFactory().getOffsetBounds(getAttributeSet());
      bounds = offBounds.translate(loc.getX(), loc.getY());
    }
    return bounds;
  }
View Full Code Here

  //
  // user interface methods
  //
  public void expose(ComponentDrawContext context) {
    Bounds bounds = getBounds();
    java.awt.Component dest = context.getDestination();
    if (bounds != null) {
      dest.repaint(bounds.getX() - 5, bounds.getY() - 5,
        bounds.getWidth() + 10, bounds.getHeight() + 10);
    }
  }
View Full Code Here

  // user interface methods
  //
  public void drawGhost(ComponentDrawContext context, Color color,
        int x, int y, AttributeSet attrs) {
    Graphics g = context.getGraphics();
    Bounds bds = getOffsetBounds(attrs);
    g.setColor(color);
    GraphicsUtil.switchToWidth(g, 2);
    g.drawRect(x + bds.getX(), y + bds.getY(),
      bds.getWidth(), bds.getHeight());
  }
View Full Code Here

  }
 
  public void markComponent(Component comp, int dx, int dy) {
    HashMap<Location,String> avoid = this.avoid;
    boolean translated = dx != 0 || dy != 0;
    Bounds bds = comp.getBounds();
    int x0 = bds.getX() + dx;
    int y0 = bds.getY() + dy;
    int x1 = x0 + bds.getWidth();
    int y1 = y0 + bds.getHeight();
    x0 += 9 - (x0 + 9) % 10;
    y0 += 9 - (y0 + 9) % 10;
    for (int x = x0; x <= x1; x += 10) {
      for (int y = y0; y <= y1; y += 10) {
        Location loc = Location.create(x, y);
View Full Code Here

  //
  // concrete methods not intended to be overridden
  //
  @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

 
  private int computeStage(InstanceState state, MouseEvent e) {
    Integer lenObj = state.getAttributeValue(ShiftRegister.ATTR_LENGTH);
    BitWidth widObj = state.getAttributeValue(StdAttr.WIDTH);
    Boolean loadObj = state.getAttributeValue(ShiftRegister.ATTR_LOAD);
    Bounds bds = state.getInstance().getBounds();

    int y = bds.getY();
    String label = state.getAttributeValue(StdAttr.LABEL);
    if (label == null || label.equals("")) y += bds.getHeight() / 2;
    else y += 3 * bds.getHeight() / 4;
    y = e.getY() - y;
    if (y <= -6 || y >= 8) return -1;
   
    int x = e.getX() - (bds.getX() + 15);
    if (!loadObj.booleanValue() || widObj.getWidth() > 4) return -1;
    if (x < 0 || x >= lenObj.intValue() * 10) return -1;
    return x / 10;
  }
View Full Code Here

  @Override
  public void paint(InstancePainter painter) {
    int loc = this.loc;
    if (loc < 0) return;
    Bounds bds = painter.getInstance().getBounds();
    int x = bds.getX() + 15 + loc * 10;
    int y = bds.getY();
    String label = painter.getAttributeValue(StdAttr.LABEL);
    if (label == null || label.equals("")) y += bds.getHeight() / 2;
    else y += 3 * bds.getHeight() / 4;
    Graphics g = painter.getGraphics();
    g.setColor(Color.RED);
    g.drawRect(x, y - 6, 10, 13);
  }
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.