//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Subtracts the shape of the specified <code>Area</code> from the * shape of this <code>Area</code>. * The resulting shape of this <code>Area</code> will include * areas that were contained only in this <code>Area</code> * and not in the specified <code>Area</code>. * <pre> * // Example: * Area a1 = new Area([triangle 0,0 => 8,0 => 0,8]); * Area a2 = new Area([triangle 0,0 => 8,0 => 8,8]); * a1.subtract(a2); * * a1(before) - a2 = a1(after) * * ################ ################ * ############## ############## ## * ############ ############ #### * ########## ########## ###### * ######## ######## ######## * ###### ###### ###### * #### #### #### * ## ## ## * </pre> * @param rhs the <code>Area</code> to be subtracted from the * current shape * @throws NullPointerException if <code>rhs</code> is null */ public void Subtract(Area rhs) { _curves = new AreaOp.SubOp().Calculate(_curves, rhs._curves); InvalidateBounds(); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Sets the shape of this <code>Area</code> to the intersection of * its current shape and the shape of the specified <code>Area</code>. * The resulting shape of this <code>Area</code> will include * only areas that were contained in both this <code>Area</code> * and also in the specified <code>Area</code>. * <pre> * // Example: * Area a1 = new Area([triangle 0,0 => 8,0 => 0,8]); * Area a2 = new Area([triangle 0,0 => 8,0 => 8,8]); * a1.intersect(a2); * * a1(before) intersect a2 = a1(after) * * ################ ################ ################ * ############## ############## ############ * ############ ############ ######## * ########## ########## #### * ######## ######## * ###### ###### * #### #### * ## ## * </pre> * @param rhs the <code>Area</code> to be intersected with this * <code>Area</code> * @throws NullPointerException if <code>rhs</code> is null */ public void Intersect(Area rhs) { _curves = new AreaOp.IntOp().Calculate(_curves, rhs._curves); InvalidateBounds(); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Sets the shape of this <code>Area</code> to be the combined area * of its current shape and the shape of the specified <code>Area</code>, * minus their intersection. * The resulting shape of this <code>Area</code> will include * only areas that were contained in either this <code>Area</code> * or in the specified <code>Area</code>, but not in both. * <pre> * // Example: * Area a1 = new Area([triangle 0,0 => 8,0 => 0,8]); * Area a2 = new Area([triangle 0,0 => 8,0 => 8,8]); * a1.exclusiveOr(a2); * * a1(before) xor a2 = a1(after) * * ################ ################ * ############## ############## ## ## * ############ ############ #### #### * ########## ########## ###### ###### * ######## ######## ################ * ###### ###### ###### ###### * #### #### #### #### * ## ## ## ## * </pre> * @param rhs the <code>Area</code> to be exclusive ORed with this * <code>Area</code>. * @throws NullPointerException if <code>rhs</code> is null */ public void ExclusiveOr(Area rhs) { _curves = new AreaOp.XorOp().Calculate(_curves, rhs._curves); InvalidateBounds(); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Tests whether the geometries of the two <code>Area</code> objects * are equal. * This method will return false if the argument is null. * @param other the <code>Area</code> to be compared to this * <code>Area</code> * @return <code>true</code> if the two geometries are equal; * <code>false</code> otherwise. */ public bool Equals(Area other) { // REMIND: A *much* simpler operation should be possible... // Should be able to do a curve-wise comparison since all Areas // should evaluate their curves in the same top-down order. if (other == this) { return true; } if (other == null) { return false; } ArrayList c = new AreaOp.XorOp().Calculate(_curves, other._curves); return c.Count == 0; }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Creates a new <code>Area</code> object that contains the same * geometry as this <code>Area</code> transformed by the specified * <code>AffineTransform</code>. This <code>Area</code> object * is unchanged. * @param t the specified <code>AffineTransform</code> used to transform * the new <code>Area</code> * @throws NullPointerException if <code>t</code> is null * @return a new <code>Area</code> object representing the transformed * geometry. */ public Area CreateTransformedArea(AffineTransform t) { Area a = new Area(this); a.Transform(t); return a; }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Adds the shape of the specified <code>Area</code> to the * shape of this <code>Area</code>. * The resulting shape of this <code>Area</code> will include * the union of both shapes, or all areas that were contained * in either this or the specified <code>Area</code>. * <pre> * // Example: * Area a1 = new Area([triangle 0,0 => 8,0 => 0,8]); * Area a2 = new Area([triangle 0,0 => 8,0 => 8,8]); * a1.add(a2); * * a1(before) + a2 = a1(after) * * ################ ################ ################ * ############## ############## ################ * ############ ############ ################ * ########## ########## ################ * ######## ######## ################ * ###### ###### ###### ###### * #### #### #### #### * ## ## ## ## * </pre> * @param rhs the <code>Area</code> to be added to the * current shape * @throws NullPointerException if <code>rhs</code> is null */ public void Add(Area rhs) { _curves = new AreaOp.AddOp().Calculate(_curves, rhs._curves); InvalidateBounds(); }