Package com.googlecode.jumpnevolve.math

Examples of com.googlecode.jumpnevolve.math.Rectangle


   * {@link com.googlecode.jumpnevolve.math.Rectangle#doesCollide(com.googlecode.jumpnevolve.math.Shape)}
   * .
   */
  @Test
  public void testDoesCollide() {
    Rectangle rect = new Rectangle(55.0f, -20.0f, 356.0f, 23.0f);
    assertThat(rect.doesCollide(rect), is(true));
    assertThat(rect.doesCollide(rect.getBestCircle()), is(true));
    assertThat(rect.doesCollide(rect.getBoundingCircle()), is(true));
    assertThat(rect.doesCollide(new Circle(4000.0f, 4000.0f, 2.0f)),
        is(false));
    assertThat(rect.doesCollide(new Circle(0.0f, 0.0f, 60.0f)), is(true));
  }
View Full Code Here


  public void testDoesCollide() {
    Circle circle = new Circle(0.4f, 0.99f, 29.0f);
    assertThat(circle.doesCollide(circle), is(true));
    assertThat(circle.doesCollide(circle.getBoundingRect()), is(true));
    assertThat(
        circle.doesCollide(new Rectangle(26.0f, 0.0f, 80.0f, 21.0f)),
        is(true));
    assertThat(circle.doesCollide(new Circle(30.0f, 30.0f, 0.1f)),
        is(false));
    assertThat(circle.doesCollide(new Rectangle(999.0f, 999.0f, 0.1f,
        1000.0f)), is(false));
  }
View Full Code Here

   * {@link com.googlecode.jumpnevolve.math.Circle#getBoundingRect()}.
   */
  @Test
  public void testGetBoundingRectangle() {
    assertThat(new Circle(0.0f, 0.0f, 20.0f).getBoundingRect(),
        is(new Rectangle(-20.0f, -20.0f, 40.0f, 40.f)));
  }
View Full Code Here

   *            Grafikkontext
   * @param circle
   *            Kreis
   */
  public static void draw(Graphics g, Circle circle) {
    Rectangle rect = circle.getBoundingRect();
    g.drawOval(rect.x, rect.y, rect.width, rect.height);
  }
View Full Code Here

      drawScaled(g, (Rectangle) shape, zoom);
    }
  }

  public static void drawScaled(Graphics g, Rectangle rect, float zoom) {
    Rectangle rect2 = new Rectangle(rect.getCenter(), new Vector(rect.width
        / 2.0f * zoom, rect.height / 2.0f * zoom));
    draw(g, rect2);
  }
View Full Code Here

   *            dargestellt werden soll
   */
  public InterfaceButton(InterfaceFunction function, String iconPath) {
    super(function);
    this.icon = iconPath;
    this.shape = new Rectangle(Vector.ZERO, BUTTON_DIMENSION,
        BUTTON_DIMENSION);
  }
View Full Code Here

  }

  public InterfaceButton(InterfaceFunction function, int key, String iconPath) {
    super(function, key);
    this.icon = iconPath;
    this.shape = new Rectangle(Vector.ZERO, BUTTON_DIMENSION,
        BUTTON_DIMENSION);
  }
View Full Code Here

  public void draw(Graphics g) {
    if (Font == null) {
      Font = g.getFont();
      setTextHeight(Font.getLineHeight());
    }
    if (this.shape.equals(new Rectangle(Vector.ZERO, 1, 1))) {
      int width = Font.getWidth(this.buttonText);
      int height = Font.getHeight(this.buttonText);
      this.shape = new Rectangle(Vector.ZERO, width, height);
    }
    Vector pos = this.getCenterVector();
    this.shape = (Rectangle) this.shape.modifyCenter(pos);
    Color c = g.getColor();
    switch (this.getStatus()) {
View Full Code Here

    if (font == null) {
      float width = this.getContent().length() * 10;
      if (width < 50) {
        width = 50;
      }
      return new Rectangle(Vector.ZERO, width, 20);
    } else {
      return new Rectangle(Vector.ZERO,
          font.getWidth(this.getContent() + 10), font.getLineHeight());
    }
  }
View Full Code Here

  @Override
  public void draw(Graphics g) {
    if (font == null) {
      font = g.getFont();
    }
    Rectangle rect = (Rectangle) this.getNeededSize();
    Vector center = this.getCenterVector();

    GraphicUtils.fill(g, rect.modifyCenter(center), Color.blue);

    Vector pos = this.parent.getPositionFor(this);
    GraphicUtils.drawString(g, pos.add(2, 0), this.content1);

    float xModifier = g.getFont().getWidth(this.content1);
View Full Code Here

TOP

Related Classes of com.googlecode.jumpnevolve.math.Rectangle

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.