Exemple #1
0
 /**
  * Adds a <code>Rectangle2D</code> object to this <code>Rectangle2D</code>. The resulting <code>
  * Rectangle2D</code> is the union of the two <code>Rectangle2D</code> objects.
  *
  * @param r the <code>Rectangle2D</code> to add to this <code>Rectangle2D</code>.
  * @since 1.2
  */
 public void add(Rectangle2D r) {
   double x1 = Math.min(getMinX(), r.getMinX());
   double x2 = Math.max(getMaxX(), r.getMaxX());
   double y1 = Math.min(getMinY(), r.getMinY());
   double y2 = Math.max(getMaxY(), r.getMaxY());
   setRect(x1, y1, x2 - x1, y2 - y1);
 }
Exemple #2
0
 /**
  * Adds a point, specified by the double precision arguments <code>newx</code> and <code>newy
  * </code>, to this <code>Rectangle2D</code>. The resulting <code>Rectangle2D</code> is the
  * smallest <code>Rectangle2D</code> that contains both the original <code>Rectangle2D</code> and
  * the specified point.
  *
  * <p>After adding a point, a call to <code>contains</code> with the added point as an argument
  * does not necessarily return <code>true</code>. The <code>contains</code> method does not return
  * <code>true</code> for points on the right or bottom edges of a rectangle. Therefore, if the
  * added point falls on the left or bottom edge of the enlarged rectangle, <code>contains</code>
  * returns <code>false</code> for that point.
  *
  * @param newx the X coordinate of the new point
  * @param newy the Y coordinate of the new point
  * @since 1.2
  */
 public void add(double newx, double newy) {
   double x1 = Math.min(getMinX(), newx);
   double x2 = Math.max(getMaxX(), newx);
   double y1 = Math.min(getMinY(), newy);
   double y2 = Math.max(getMaxY(), newy);
   setRect(x1, y1, x2 - x1, y2 - y1);
 }
Exemple #3
0
 /**
  * Sets the location and size of the outer bounds of this <code>Rectangle2D</code> to the
  * specified rectangular values.
  *
  * @param x the X coordinate of the upper-left corner of this <code>Rectangle2D</code>
  * @param y the Y coordinate of the upper-left corner of this <code>Rectangle2D</code>
  * @param w the width of this <code>Rectangle2D</code>
  * @param h the height of this <code>Rectangle2D</code>
  * @since 1.2
  */
 public void setFrame(double x, double y, double w, double h) {
   setRect(x, y, w, h);
 }
Exemple #4
0
 /**
  * Sets this <code>Rectangle2D</code> to be the same as the specified <code>Rectangle2D</code>.
  *
  * @param r the specified <code>Rectangle2D</code>
  * @since 1.2
  */
 public void setRect(Rectangle2D r) {
   setRect(r.getX(), r.getY(), r.getWidth(), r.getHeight());
 }