java.lang.Object
sofia.graphics.ShapeFilter<ShapeType extends sofia.graphics.Shape>
A chainable filter that lets you search for shapes in a field based on a set of criteria.
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
ShapeFilter(ShapeFilter<? super ShapeType> previous, String descriptionOfConstraint)
Create a new Filter object.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ShapeSet<ShapeType>
|
all()
Returns the set of all shapes matched by this filter.
| ||||||||||
ShapeType
|
back()
Gets the shape that is farthest in the background that matches this
filter.
| ||||||||||
int
|
count()
Gets the number of shapes matched by this filter.
| ||||||||||
String
|
description()
Get a human-readable description of this filter.
| ||||||||||
boolean
|
equals(Object other)
Determine whether this object is equal to the another.
| ||||||||||
boolean
|
exist()
Returns true if any shapes were matched by this filter.
| ||||||||||
ShapeType
|
front()
Gets the shape that is farthest in the foreground that matches this
filter.
| ||||||||||
int
|
hashCode()
| ||||||||||
ShapeFilter<ShapeType>
|
intersecting(RectF bounds)
Restrict this filter to only match shapes that intersect the specified
rectangle.
| ||||||||||
ShapeFilter<ShapeType>
|
intersecting(float left, float top, float right, float bottom)
Restrict this filter to only match shapes that intersect the specified
rectangle.
| ||||||||||
boolean
|
isEmpty()
Returns true if no shapes were matched by this filter.
| ||||||||||
Iterator<ShapeType>
|
iterator()
Gets an iterator over all shapes matched by this filter.
| ||||||||||
ShapeFilter<ShapeType>
|
locatedAt(PointF point)
Restrict this filter to only match shapes that occupy the specified
point.
| ||||||||||
ShapeFilter<ShapeType>
|
locatedAt(float x, float y)
Restrict this filter to only match shapes that occupy the specified
point.
| ||||||||||
ShapeFilter<ShapeType>
|
locatedWithin(PointF point, float radius)
Restrict this filter to only match shapes that are located within the
specified radius of a point.
| ||||||||||
ShapeFilter<ShapeType>
|
locatedWithin(float x, float y, float radius)
Restrict this filter to only match shapes that are located within the
specified radius of a point.
| ||||||||||
ShapeSet<ShapeType>
|
remove()
Removes all of the shapes matched by this filter from the field they are
in, and returns the set of those shapes.
| ||||||||||
String
|
toString()
Get a human-readable description of this filter.
| ||||||||||
ShapeFilter<ShapeType>
|
withAngularVelocity(Predicate<Number> predicate)
Restrict this filter to only match shapes that are currently in motion
with a linear velocity whose magnitude satisfies the specified predicate
(less than, greater than, etc.).
| ||||||||||
ShapeFilter<ShapeType>
|
withAwake(boolean awake)
Restrict this filter to only match shapes with the specified awake
state.
| ||||||||||
<ConstrainedShapeType extends ShapeType extends Shape>
ShapeFilter<ConstrainedShapeType>
|
withClass(Class<? extends ConstrainedShapeType> theClass)
Restrict this filter to only match shapes whose classes are the same as,
or subclasses of, the specified class.
| ||||||||||
<ConstrainedShapeType extends ShapeType extends Shape>
ShapeFilter<ConstrainedShapeType>
|
withClass(Predicate<Class<? extends ConstrainedShapeType>> predicate)
Restrict this filter to only match shapes whose classes match the
specified predicate (such as
equalTo(Object) or
extending(Class) ). | ||||||||||
ShapeFilter<ShapeType>
|
withColor(Color color)
Restrict this filter to only match shapes with the specified color.
| ||||||||||
ShapeFilter<ShapeType>
|
withLinearVelocity(Predicate<Number> predicate)
Restrict this filter to only match shapes that are currently in motion
with a linear velocity whose magnitude satisfies the specified predicate
(less than, greater than, etc.).
| ||||||||||
ShapeFilter<ShapeType>
|
withSensor(boolean sensor)
Restrict this filter to only match shapes with the specified sensor
property.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
final
boolean
|
accept(ShapeType object)
TODO: document.
| ||||||||||
void
|
addDescriptionOfConstraint(StringBuilder result)
Get a human-readable description of this filter.
| ||||||||||
World
|
b2World()
Gets the JBox2D world where this filter will be executed.
| ||||||||||
String
|
describe(ShapeType object)
Get a description of the specified object, suitable for use in
a diagnostic message.
| ||||||||||
String
|
description(boolean plural)
Get a human-readable description of this filter.
| ||||||||||
final
void
|
filter()
TODO: document.
| ||||||||||
String
|
filteredObjectDescription()
Get a human-readable name for the type of objects to which this filter
applies.
| ||||||||||
String
|
filteredObjectsDescription()
Get the plural form of
filteredObjectDescription() . | ||||||||||
ShapeFilter<? super ShapeType>
|
previousFilter()
TODO: document.
| ||||||||||
RectF
|
queryBounds()
Gets a bounding box that indicates which subregion of the world should
be queried by the filter, or null to query the entire world.
| ||||||||||
abstract
boolean
|
thisFilterAccepts(ShapeType object)
TODO: document.
| ||||||||||
RectF
|
thisQueryBounds()
Gets a bounding box that indicates which subregion of the world should
be queried by the filter, or null to query the entire world.
|
Methods inherited from
class
java.lang.Object
| |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Object
|
clone()
| ||||||||||
boolean
|
equals(Object arg0)
| ||||||||||
void
|
finalize()
| ||||||||||
final
Class<?>
|
getClass()
| ||||||||||
int
|
hashCode()
| ||||||||||
final
void
|
notify()
| ||||||||||
final
void
|
notifyAll()
| ||||||||||
String
|
toString()
| ||||||||||
final
void
|
wait()
| ||||||||||
final
void
|
wait(long arg0, int arg1)
| ||||||||||
final
void
|
wait(long arg0)
|
Methods inherited from
interface
java.lang.Iterable
| |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract
Iterator<T>
|
iterator()
|
Create a new Filter object.
Gets the shape that is farthest in the background that matches this filter. This is the shape that has the lowest z-index, or if multiple shapes have the same z-index, the one that was added least recently to its field.
the bottom-most shape in the set, or null if the filter matched no shapes
Gets the number of shapes matched by this filter.
the number of shapes matched by this filter
Get a human-readable description of this filter.
A human-readable description of this filter.
Determine whether this object is equal to the another.
True if this object is equal to the other.
Returns true if any shapes were matched by this filter. This is the
opposite of isEmpty()
.
true if any shapes were matched by this filter, or false if no shapes were matched
Gets the shape that is farthest in the foreground that matches this filter. This is the shape that has the highest z-index, or if multiple shapes have the same z-index, the one that was added most recently to its field.
the frontmost shape in the set, or null if the filter matched no shapes
Restrict this filter to only match shapes that intersect the specified rectangle.
a new filter with the given restriction
Restrict this filter to only match shapes that intersect the specified rectangle.
a new filter with the given restriction
Returns true if no shapes were matched by this filter. This is the
opposite of exist()
.
true if no shapes were matched by this filter
Restrict this filter to only match shapes that occupy the specified point.
a new filter with the given restriction
Restrict this filter to only match shapes that occupy the specified point.
a new filter with the given restriction
Restrict this filter to only match shapes that are located within the specified radius of a point.
a new filter with the given restriction
Restrict this filter to only match shapes that are located within the specified radius of a point.
a new filter with the given restriction
Removes all of the shapes matched by this filter from the field they are in, and returns the set of those shapes.
a ShapeSet
containing the shapes that were matched and
removed
Get a human-readable description of this filter.
A human-readable description of this filter.
Restrict this filter to only match shapes that are currently in motion with a linear velocity whose magnitude satisfies the specified predicate (less than, greater than, etc.).
a new filter with the given restriction
Restrict this filter to only match shapes with the specified awake state.
a new filter with the given restriction
Restrict this filter to only match shapes whose classes are the same as,
or subclasses of, the specified class. This is equivalent to calling
withClass(Predicate.extending(theClass))
. If you need to write
a filter that only matches the class of the shape
exactly and excludes subclasses, then you must call the
predicate version of this method directly:
withClass(Predicate.equalTo(theClass))
.
a new filter with the given restriction
Restrict this filter to only match shapes whose classes match the
specified predicate (such as equalTo(Object)
or
extending(Class)
).
a new filter with the given restriction
Restrict this filter to only match shapes with the specified color.
Color
of shapes to be matcheda new filter with the given restriction
Restrict this filter to only match shapes that are currently in motion with a linear velocity whose magnitude satisfies the specified predicate (less than, greater than, etc.).
a new filter with the given restriction
Restrict this filter to only match shapes with the specified sensor property.
a new filter with the given restriction
TODO: document.
TODO: describe
Get a human-readable description of this filter.
Gets the JBox2D world where this filter will be executed. The default behavior of this method is to ask the previous filter for its world,
Get a description of the specified object, suitable for use in
a diagnostic message. The default implementation just uses
toString()
on the object.
a description of the object.
Get a human-readable description of this filter.
A human-readable description of this filter.
TODO: document.
Get a human-readable name for the type of objects to which this filter applies. The result should be in the singular form.
A human-readable version of the FilteredObjectType.
Get the plural form of filteredObjectDescription()
.
A human-readable version of the plural form of FilteredObjectType.
Gets a bounding box that indicates which subregion of the world should be queried by the filter, or null to query the entire world.
the bounding box where the query should be executed
TODO: document.
TODO: describe
Gets a bounding box that indicates which subregion of the world should be queried by the filter, or null to query the entire world.
the bounding box where the query should be executed