Package net.sf.arianne.marboard.server.entity.shape

Source Code of net.sf.arianne.marboard.server.entity.shape.Rectangle

package net.sf.arianne.marboard.server.entity.shape;

import marauroa.common.game.RPClass;
import marauroa.common.game.RPObject;
import marauroa.common.game.Definition.Type;

/**
* represents a rectangle
*
* @author madmetzger, hendrik
*/
public class Rectangle extends Shape {

  /**
   * creates a new Rectangle
   *
   * @param object RPObject to use as default
   */
  public Rectangle(RPObject object) {
    super(object);
  }

  /**
   * creates a new rectangle
   *
   * @param color color
   * @param fillColor color used to fill the rectangle
   * @param thickness thickness
   * @param x x
   * @param y y
   * @param x2 x-coordinate of second point
   * @param y2 y-coordinate of second point
   */
  public Rectangle(int color, int fillColor, int thickness, int x, int y, int x2, int y2) {
    setRPClass("rectangle");
    put("color", color);
    put("fill_color", fillColor);
    put("thickness", thickness);

    // (x, y) needs to be the upper left corner, because swing does not draw the rectangle otherwise
    put("x", Math.min(x, x2));
    put("y", Math.min(y, y2));
    put("x2", Math.max(x, x2));
    put("y2", Math.max(y, y2));
  }
 
  /**
   * creates a new rectangle
   * @param color color
   * @param fillColor color used to fill the rectangle
   * @param thickness thickness
   * @param x x
   * @param y y
   * @param z z-index
   * @param x2 x-coordinate of second point
   * @param y2 y-coordinate of second point
   */
  public Rectangle(int color, int fillColor, int thickness, int x, int y, int z, int x2, int y2) {
    this(color, fillColor, thickness, x, y, x2, y2);
    put("z", z);
  }

  /**
   * generates the class definition for marauroa.
   */
  public static void generateRPClass() {
    final RPClass shape = new RPClass("rectangle");
    shape.isA("filled_shape");
    shape.addAttribute("x2", Type.INT);
    shape.addAttribute("y2", Type.INT);
  }
 
}
TOP

Related Classes of net.sf.arianne.marboard.server.entity.shape.Rectangle

TOP
Copyright © 2018 www.massapi.com. 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.