Spec-Zone .ru
спецификации, руководства, описания, API
001/*
002 * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation.  Oracle designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Oracle in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
022 * or visit www.oracle.com if you need additional information or have any
023 * questions.
024 */
025
026package javafx.geometry;
027
028/**
029 * The base class for objects that are used to describe the bounds of a node or
030 * other scene graph object.
031 */
032public abstract class Bounds {
033    /**
034     * The x coordinate of the upper-left corner of this {@code Bounds}.
035     *
036     * @defaultValue 0.0
037     */
038    public final double getMinX() { return minX; }
039    private double minX;
040
041    /**
042     * The y coordinate of the upper-left corner of this {@code Bounds}.
043     *
044     * @defaultValue 0.0
045     */
046    public final double getMinY() { return minY; }
047    private double minY;
048    /**
049     * The minimum z coordinate of this {@code Bounds}.
050     *
051     * @defaultValue 0.0
052     * @since JavaFX 1.3
053     */
054    public final double getMinZ() { return minZ; }
055    private double minZ;
056    /**
057     * The width of this {@code Bounds}.
058     *
059     * @defaultValue 0.0
060     */
061    public final double getWidth() { return width; }
062    private double width;
063    /**
064     * The height of this {@code Bounds}.
065     *
066     * @defaultValue 0.0
067     */
068    public final double getHeight() { return height; }
069    private double height;
070    /**
071     * The depth of this {@code Bounds}.
072     *
073     * @defaultValue 0.0
074     * @since JavaFX 1.3
075     */
076    public final double getDepth() { return depth; }
077    private double depth;
078    /**
079     * The x coordinate of the lower-right corner of this {@code Bounds}.
080     *
081     * @defaultValue {@code minX + width}
082     */
083    public final double getMaxX() { return maxX; }
084    private double maxX;
085    /**
086     * The y coordinate of the lower-right corner of this {@code Bounds}.
087     *
088     * @defaultValue {@code minY + height}
089     */
090    public final double getMaxY() { return maxY; }
091    private double maxY;
092    /**
093     * The maximum z coordinate of this {@code Bounds}.
094     *
095     * @defaultValue {@code minZ + depth}
096     * @since JavaFX 1.3
097     */
098    public final double getMaxZ() { return maxZ; }
099    private double maxZ;
100
101    /**
102     * Indicates whether any of the dimensions(width, height or depth) of this bounds
103     * is less than zero.
104     * @return true if any of the dimensions(width, height or depth) of this bounds
105     * is less than zero.
106     */
107    public abstract boolean isEmpty();
108
109    /**
110     * Tests if the specified point is inside the boundary of {@code Bounds}.
111     *
112     * @param p the specified point to be tested
113     * @return true if the specified point is inside the boundary of this
114     * {@code Bounds}; false otherwise.
115     */
116    public abstract boolean contains(Point2D p);
117
118    /**
119     * Tests if the specified point is inside the boundary of {@code Bounds}.
120     *
121     * @param p the specified 3D point to be tested
122     * @return true if the specified point is inside the boundary of this
123     * {@code Bounds}; false otherwise.
124     */
125    public abstract boolean contains(Point3D p);
126
127    /**
128     * Tests if the specified {@code (x, y)} coordinates are inside the boundary
129     * of {@code Bounds}.
130     *
131     * @param x the specified x coordinate to be tested
132     * @param y the specified y coordinate to be tested
133     * @return true if the specified {@code (x, y)} coordinates are inside the
134     * boundary of this {@code Bounds}; false otherwise.
135     */
136    public abstract boolean contains(double x, double y);
137
138    /**
139     * Tests if the specified {@code (x, y, z)} coordinates are inside the boundary
140     * of {@code Bounds}.
141     *
142     * @param x the specified x coordinate to be tested
143     * @param y the specified y coordinate to be tested
144     * @return true if the specified {@code (x, y)} coordinates are inside the
145     * boundary of this {@code Bounds}; false otherwise.
146     */
147    public abstract boolean contains(double x, double y, double z);
148
149    /**
150     * Tests if the interior of this {@code Bounds} entirely contains the
151     * specified Bounds, {@code b}.
152     *
153     * @param b The specified Bounds
154     * @return true if the specified Bounds, {@code b}, is inside the
155     * boundary of this {@code Bounds}; false otherwise.
156     */
157    public abstract boolean contains(Bounds b);
158
159    /**
160     * Tests if the interior of this {@code Bounds} entirely contains the
161     * specified rectangular area.
162     *
163     * @param x the x coordinate of the upper-left corner of the specified
164     * rectangular area
165     * @param y the y coordinate of the upper-left corner of the specified
166     * rectangular area
167     * @param w the width of the specified rectangular area
168     * @param h the height of the specified rectangular area
169     * @return true if the interior of this {@code Bounds} entirely contains
170     * the specified rectangular area; false otherwise.
171     */
172    public abstract boolean contains(double x, double y, double w, double h);
173
174    /**
175     * Tests if the interior of this {@code Bounds} entirely contains the
176     * specified rectangular area.
177     *
178     * @param x the x coordinate of the upper-left corner of the specified
179     * rectangular volume
180     * @param y the y coordinate of the upper-left corner of the specified
181     * rectangular volume
182     * @param z the z coordinate of the upper-left corner of the specified
183     * rectangular volume
184     * @param w the width of the specified rectangular volume
185     * @param h the height of the specified rectangular volume
186     * @param d the depth of the specified rectangular volume
187     * @return true if the interior of this {@code Bounds} entirely contains
188     * the specified rectangular area; false otherwise.
189     */
190    public abstract boolean contains(double x, double y, double z,
191            double w, double h, double d);
192
193    /**
194     * Tests if the interior of this {@code Bounds} intersects the interior
195     * of a specified Bounds, {@code b}.
196     *
197     * @param b The specified Bounds
198     * @return true if the interior of this {@code Bounds} and the interior
199     * of the specified Bounds, {@code b}, intersect.
200     */
201    public abstract boolean intersects(Bounds b);
202
203    /**
204     * Tests if the interior of this {@code Bounds} intersects the interior
205     * of a specified rectangular area.
206     *
207     * @param x the x coordinate of the upper-left corner of the specified
208     * rectangular area
209     * @param y the y coordinate of the upper-left corner of the specified
210     * rectangular area
211     * @param w the width of the specified rectangular area
212     * @param h the height of the specified rectangular area
213     * @return true if the interior of this {@code Bounds} and the interior
214     * of the rectangular area intersect.
215     */
216    public abstract boolean intersects(double x, double y, double w, double h);
217
218    /**
219     * Tests if the interior of this {@code Bounds} intersects the interior
220     * of a specified rectangular area.
221     *
222     * @param x the x coordinate of the upper-left corner of the specified
223     * rectangular volume
224     * @param y the y coordinate of the upper-left corner of the specified
225     * rectangular volume
226     * @param z the z coordinate of the upper-left corner of the specified
227     * rectangular volume
228     * @param w the width of the specified rectangular volume
229     * @param h the height of the specified rectangular volume
230     * @param d the depth of the specified rectangular volume
231     * @return true if the interior of this {@code Bounds} and the interior
232     * of the rectangular area intersect.
233     */
234    public abstract boolean intersects(double x, double y, double z,
235            double w, double h, double d);
236
237    /**
238     * Creates a new instance of {@code Bounds} class.
239     * @param minX the X coordinate of the upper-left corner
240     * @param minY the Y coordinate of the upper-left corner
241     * @param minZ the minimum z coordinate of the {@code Bounds}
242     * @param width the width of the {@code Bounds}
243     * @param height the height of the {@code Bounds}
244     * @param depth the depth of the {@code Bounds}
245     */
246    protected Bounds(double minX, double minY, double minZ, double width, double height, double depth) {
247        this.minX = minX;
248        this.minY = minY;
249        this.minZ = minZ;
250        this.width = width;
251        this.height = height;
252        this.depth = depth;
253        this.maxX = minX + width;
254        this.maxY = minY + height;
255        this.maxZ = minZ + depth;
256    }
257}