/** * Returns a string representation of this <code>Insets</code> object. * This method is intended to be used only for debugging purposes, and * the content and format of the returned string may vary between * implementations. The returned string may be empty but may not be * <code>null</code>. * * @return a string representation of this <code>Insets</code> object. */ @Override public String toString() { return getClass().getName().substring(getClass().getName().lastIndexOf('.')+1) + "[top=" + getTop() + ",left=" + getLeft() + ",bottom=" + getBottom() + ",right=" + getRight() + "]"; } /**
/** * Subtracts the current insets to the specified Rectangle2D making the * rectangle smaller. * * @param r The Rectangle2D. */ public void subtractTo(Rectangle2D r) { r.setRect( r.getX() + getLeft(), r.getY() + getTop(), r.getWidth() - getLeft() - getRight(), r.getHeight() - getTop() - getBottom() ); } /**
/** * Adds the current insets to the specified Rectangle2D making the * rectangle larger. * * @param r The Rectangle2D. */ public void addTo(Rectangle2D r) { r.setRect( r.getX() - getLeft(), r.getY() - getTop(), r.getWidth() + getLeft() + getRight(), r.getHeight() + getTop() + getBottom() ); } /**
/** * Sets the insets. * * @param i The new insets. */ public void set(Insets2D i) { set(i.getTop(), i.getLeft(), i.getBottom(), i.getRight()); }
/** * Checks whether two insets objects are equal. Two instances * of <code>Insets2DDouble</code> are equal if the four integer values * of the fields <code>top</code>, <code>left</code>, * <code>bottom</code>, and <code>right</code> are all equal. * @return <code>true</code> if the two insets are equal; * otherwise <code>false</code>. * @since JDK1.1 */ @Override public boolean equals(Object obj) { if (obj instanceof Insets2D) { Insets2D that = (Insets2D)obj; return ((getTop() == that.getTop()) && (getLeft() == that.getLeft()) && (getBottom() == that.getBottom()) && (getRight() == that.getRight())); } return false; }
/** * Returns the hash code for this Insets2DDouble. * * @return a hash code for this Insets2DDouble. */ @Override public int hashCode() { double sum1 = getLeft() + getBottom(); double sum2 = getRight() + getTop(); double val1 = sum1 * (sum1 + 1)/2 + getLeft(); double val2 = sum2 * (sum2 + 1)/2 + getTop(); double sum3 = val1 + val2; return java.lang.Float.floatToIntBits((float) (sum3 * (sum3 + 1)/2 + val2)); } /**
/** * Adds the specified insets to the current insets. * * @param top The top insets. * @param left The left insets. * @param bottom The bottom insets. * @param right The right insets. */ public void add(double top, double left, double bottom, double right) { set( getTop() + top, getLeft() + left, getBottom() + bottom, getRight() + right ); } /**
/** * Subtracts the specified insets from the current insets. * * @param top The top insets. * @param left The left insets. * @param bottom The bottom insets. * @param right The right insets. */ public void subtract(double top, double left, double bottom, double right) { set( getTop() - top, getLeft() - left, getBottom() - bottom, getRight() - right ); } /**