/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Map is used to represent a map element that is part of an HTML document.
* Once a Map has been created, and any number of areas have been added,
* you can test if a point falls inside the map via the contains method.
*
* @author Scott Violet
*/
/** Name of the Map. */
/** An array of AttributeSets. */
/** An array of RegionContainments, will slowly grow to match the
* length of areaAttributes as needed. */
public Map() {
}
}
/**
* Returns the name of the Map.
*/
return name;
}
/**
* Defines a region of the Map, based on the passed in AttributeSet.
*/
return;
}
if (areaAttributes == null) {
}
}
/**
* Removes the previously created area.
*/
counter--) {
}
}
}
}
}
/**
* Returns the AttributeSets representing the differet areas of the Map.
*/
0;
if (numAttributes != 0) {
return retValue;
}
return null;
}
/**
* Returns the AttributeSet that contains the passed in location,
* <code>x</code>, <code>y</code>. <code>width</code>, <code>height</code>
* gives the size of the region the map is defined over. If a matching
* area is found, the AttribueSet for it is returned.
*/
if (numAttributes > 0) {
}
}
}
}
}
return null;
}
/**
* Creates and returns an instance of RegionContainment that can be
* used to test if a particular point lies inside a region.
*/
shape = "rect";
}
try {
}
}
}
}
} catch (RuntimeException re) {
// Something wrong with attributes.
}
return rc;
}
return null;
}
/**
* Creates and returns an array of integers from the String
* <code>stringCoords</code>. If one of the values represents a
* % the returned value with be negative. If a parse error results
* from trying to parse one of the numbers null is returned.
*/
return null;
}
", \t\n\r");
int numCoords = 0;
while(st.hasMoreElements()) {
int scale;
scale = -1;
}
else {
scale = 1;
}
try {
retValue = new int[4];
}
}
} catch (NumberFormatException nfe) {
return null;
}
}
}
return retValue;
}
/**
* Defines the interface used for to check if a point is inside a
* region.
*/
interface RegionContainment {
/**
* Returns true if the location <code>x</code>, <code>y</code>
* falls inside the region defined in the receiver.
* <code>width</code>, <code>height</code> is the size of
* the enclosing region.
*/
}
/**
* Used to test for containment in a rectangular region.
*/
/** Will be non-null if one of the values is a percent, and any value
* that is non null indicates it is a percent
* (order is x, y, width, height). */
float[] percents;
/** Last value of width passed in. */
int lastWidth;
/** Last value of height passed in. */
int lastHeight;
/** Top left. */
int x0;
int y0;
/** Bottom right. */
int x1;
int y1;
throw new RuntimeException("Unable to parse rectangular area");
}
else {
percents = new float[4];
}
else {
}
}
}
}
}
return contains(x, y);
}
lastHeight = height;
}
}
}
}
}
return contains(x, y);
}
public boolean contains(int x, int y) {
}
}
/**
* Used to test for containment in a polygon region.
*/
/** If any value is a percent there will be an entry here for the
* percent value. Use percentIndex to find out the index for it. */
float[] percentValues;
int[] percentIndexs;
/** Last value of width passed in. */
int lastWidth;
/** Last value of height passed in. */
int lastHeight;
COORDS));
throw new RuntimeException("Unable to parse polygon area");
}
else {
int numPercents = 0;
counter--) {
numPercents++;
}
}
if (numPercents > 0) {
percentIndexs = new int[numPercents];
percentValues = new float[numPercents];
-100.0f;
pCounter++;
}
}
}
else {
}
}
}
}
lastHeight == height)) {
return contains(x, y);
}
// Force the bounding box to be recalced.
lastHeight = height;
counter--) {
// x
}
else {
// y
}
}
return contains(x, y);
}
}
/**
* Used to test for containment in a circular region.
*/
/** X origin of the circle. */
int x;
/** Y origin of the circle. */
int y;
/** Radius of the circle. */
int radiusSquared;
/** Non-null indicates one of the values represents a percent. */
float[] percentValues;
/** Last value of width passed in. */
int lastWidth;
/** Last value of height passed in. */
int lastHeight;
COORDS));
throw new RuntimeException("Unable to parse circular area");
}
x = coords[0];
y = coords[1];
percentValues = new float[3];
-100.0f;
}
else {
}
}
}
else {
}
}
lastHeight != height)) {
lastHeight = height;
}
}
}
}
return (((x - this.x) * (x - this.x) +
(y - this.y) * (y - this.y)) <= radiusSquared);
}
}
/**
* An implementation that will return true if the x, y location is
* inside a rectangle defined by origin 0, 0, and width equal to
* width passed in, and height equal to height passed in.
*/
/** A global shared instance. */
si = new DefaultRegionContainment();
}
return si;
}
}
}
}