/** * Returns the X coordinate of the center of the framing * rectangle of the <code>Shape</code> in <code>double</code> * precision. * @return the X coordinate of the center of the framing rectangle * of the <code>Shape</code>. * @since 1.2 */ public double getCenterX() { return getX() + getWidth() / 2.0; }
/** * Returns the X coordinate of the center of the framing * rectangle of the <code>Shape</code> in <code>double</code> * precision. * @return the X coordinate of the center of the framing rectangle * of the <code>Shape</code>. * @since 1.2 */ public double getCenterX() { return getX() + getWidth() / 2.0; }
/** * Returns the largest X coordinate of the framing * rectangle of the <code>Shape</code> in <code>double</code> * precision. * * @return the largest X coordinate of the framing * rectangle of the <code>Shape</code>. * @since 1.2 */ public double getMaxX() { return getX() + getWidth(); }
/** * Returns the largest X coordinate of the framing * rectangle of the <code>Shape</code> in <code>double</code> * precision. * * @return the largest X coordinate of the framing * rectangle of the <code>Shape</code>. * @since 1.2 */ public double getMaxX() { return getX() + getWidth(); }
/** * set minimum X * * @param x minimum x */ public void setX(double x) { setRect(x, getY(), getWidth(), getHeight()); }
/** * set Y height * * @param h Y height */ public void setHeight(double h) { setRect(getX(), getY(), getWidth(), h); }
/** * set minimum Y * * @param y minimum y */ public void setY(double y) { setRect(getX(), y, getWidth(), getHeight()); }
/** * set minimum Y * * @param y minimum y */ public void setY(double y) { setRect(getX(), y, getWidth(), getHeight()); }
/** * set Y height * * @param h Y height */ public void setHeight(double h) { setRect(getX(), getY(), getWidth(), h); }
/** * set minimum X * * @param x minimum x */ public void setX(double x) { setRect(x, getY(), getWidth(), getHeight()); }
/** * set minimum Y * * @param y minimum y */ public void setY(double y) { setRect(getX(), y, getWidth(), getHeight()); }
/** * Get the maximum corner of the bounding box. * * @return maximum corner of the bounding box */ public ProjectionPoint getMaxPoint() { return new ProjectionPointImpl(getX() + getWidth(), getY() + getHeight()); }
/** * Get the maximum corner of the bounding box. * * @return maximum corner of the bounding box */ public ProjectionPoint getMaxPoint() { return new ProjectionPointImpl(getX() + getWidth(), getY() + getHeight()); }
public boolean intersects(double x, double y, double w, double h) { if (isEmpty() || w <= 0 || h <= 0) { return false; } double x0 = getX(); double y0 = getY(); return (x + w > x0 && y + h > y0 && x < x0 + getWidth() && y < y0 + getHeight()); }
/** * Get the maximum corner of the bounding box. * * @return maximum corner of the bounding box */ public ProjectionPoint getMaxPoint() { return new ProjectionPointImpl(getX() + getWidth(), getY() + getHeight()); }
/** * Wrtie the object to the output stream * * @param s stream to write * @throws IOException Problem writing to stream */ private void writeObject(ObjectOutputStream s) throws IOException { s.writeDouble(getX()); s.writeDouble(getY()); s.writeDouble(getWidth()); s.writeDouble(getHeight()); } }
/** * Get a String representation of this object. * * @return a String representation of this object. */ public String toString() { return "min: " + Format.d(getX(), 3) + " " + Format.d(getY(), 3) + " size: " + Format.d(getWidth(), 3) + " " + Format.d(getHeight(), 3); }
/** * Get a String representation of this object. * * @return a String representation of this object. */ public String toString() { return "min: " + Format.d(getX(), 3) + " " + Format.d(getY(), 3) + " size: " + Format.d(getWidth(), 3) + " " + Format.d(getHeight(), 3); }
/** * Get a String representation of this object. * * @return a String representation of this object. */ public String toString() { return "min: " + Format.d(getX(), 3) + " " + Format.d(getY(), 3) + " size: " + Format.d(getWidth(), 3) + " " + Format.d(getHeight(), 3); }
private ProjectionRect scaleShiftRect(double scaleFactor, double deltaX, double deltaY) { // quick and dirty method to scale and shift a rectangle, based on projectionRect double centerX = projectionRect.getCenterX(); double centerY = projectionRect.getCenterY(); double width = projectionRect.getWidth(); double height = projectionRect.getHeight(); double testMinX = (centerX + deltaX) - scaleFactor * (width/2); double testMinY = (centerY + deltaY) - scaleFactor * (height/2); return new ProjectionRect(new ProjectionPointImpl(testMinX, testMinY), scaleFactor * width, scaleFactor * height); }