java.lang.Object
sofia.graphics.ShapeSet<ShapeType extends sofia.graphics.Shape>
A shape field is a shape set that also provides (optional) real-time physics
simulation. By default, a ShapeView
creates an empty
ShapeField
to hold its shapes, but you can also have multiple
shape fields in an application and swap them in and out of the view as
needed (for example, to represent different levels of a game).
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
ShapeField()
Creates a new, empty shape field with no gravity.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean
|
add(Shape shape)
Adds the specified shape to this set if it is not already present.
| ||||||||||
boolean
|
addAll(Collection<? extends Shape> collection)
Adds all of the shapes in the specified collection to this set if
they're not already present.
| ||||||||||
Shape
|
back()
Gets the backmost shape in the shape set.
| ||||||||||
void
|
clear()
Removes all of the shapes from this set.
| ||||||||||
boolean
|
contains(Object object)
Returns true if this set contains the specified shape.
| ||||||||||
boolean
|
containsAll(Collection<?> collection)
Returns true if this set contains all of the shapes of the specified
collection.
| ||||||||||
boolean
|
equals(Object object)
Compares the specified object with this set for equality.
| ||||||||||
Shape
|
front()
Gets the frontmost shape in the shape set.
| ||||||||||
Iterator<Shape>
|
frontToBackIterator()
Access an iterator that traverses the collection from "front" (top) to
"back" (bottom) in terms of drawing order.
| ||||||||||
final
World
|
getB2World()
This method is intended for internal and advanced usage
only.
| ||||||||||
PointF
|
getGravity()
Gets the gravity of the physical world represented by this shape view.
| ||||||||||
ShapeFilter<Shape>
|
getShapes()
Gets a filter that can be used to find shapes that match a certain set of criteria. | ||||||||||
final
ShapeView
|
getView()
| ||||||||||
int
|
hashCode()
Returns the hash code value for this set.
| ||||||||||
boolean
|
isEmpty()
Returns true if this set contains no shapes.
| ||||||||||
Iterator<Shape>
|
iterator()
Returns an iterator over the shapes in this set.
| ||||||||||
boolean
|
remove(Object object)
Removes the specified shape from this set if it is present.
| ||||||||||
boolean
|
removeAll(Collection<?> collection)
Removes from this set all of its shapes that are contained in the
specified collection.
| ||||||||||
boolean
|
retainAll(Collection<?> collection)
Retains only the shapes in this set that are contained in the specified
collection.
| ||||||||||
void
|
setDrawingOrder(ZIndexComparator order)
Change the shape order for this shape set.
| ||||||||||
void
|
setGravity(float xGravity, float yGravity)
Sets the gravity of the physical world represented by this shape view.
| ||||||||||
void
|
setGravity(PointF gravity)
Sets the gravity of the physical world represented by this shape view.
| ||||||||||
int
|
size()
Returns the number of shapes in this set (its cardinality).
| ||||||||||
<T>
T[]
|
toArray(T[] array)
Returns an array containing all of the shapes in this set; the runtime type of the returned array is that of the specified array. | ||||||||||
Shape[]
|
toArray()
Returns an array containing all of the shapes in this set.
|
Methods inherited from
class
sofia.graphics.ShapeSet
| |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean
|
add(ShapeType shape)
Adds the specified shape to this set if it is not already present.
| ||||||||||
boolean
|
addAll(Collection<? extends ShapeType> collection)
Adds all of the shapes in the specified collection to this set if
they're not already present.
| ||||||||||
ShapeType
|
back()
Gets the backmost shape in the shape set.
| ||||||||||
void
|
clear()
Removes all of the shapes from this set.
| ||||||||||
boolean
|
contains(Object object)
Returns true if this set contains the specified shape.
| ||||||||||
boolean
|
containsAll(Collection<?> collection)
Returns true if this set contains all of the shapes of the specified
collection.
| ||||||||||
boolean
|
equals(Object other)
Compares the specified object with this set for equality.
| ||||||||||
ShapeType
|
front()
Gets the frontmost shape in the shape set.
| ||||||||||
Iterator<ShapeType>
|
frontToBackIterator()
Access an iterator that traverses the collection from "front" (top) to
"back" (bottom) in terms of drawing order.
| ||||||||||
ZIndexComparator
|
getDrawingOrder()
Get the shape order for this shape set.
| ||||||||||
int
|
hashCode()
Returns the hash code value for this set.
| ||||||||||
boolean
|
isEmpty()
Returns true if this set contains no shapes.
| ||||||||||
boolean
|
isInFrontOf(Shape left, Shape right)
Returns true if the left shape is drawn in front of (later than) the
shape on the right.
| ||||||||||
Iterator<ShapeType>
|
iterator()
Returns an iterator over the shapes in this set.
| ||||||||||
TreeSet<ShapeType>
|
rawSet()
Gets the
TreeSet underlying this shape set. | ||||||||||
boolean
|
remove(Object object)
Removes the specified shape from this set if it is present.
| ||||||||||
boolean
|
removeAll(Collection<?> collection)
Removes from this set all of its shapes that are contained in the
specified collection.
| ||||||||||
boolean
|
retainAll(Collection<?> collection)
Retains only the shapes in this set that are contained in the specified
collection.
| ||||||||||
void
|
setDrawingOrder(ZIndexComparator order)
Change the shape order for this shape set.
| ||||||||||
int
|
size()
Returns the number of shapes in this set (its cardinality).
| ||||||||||
<T>
T[]
|
toArray(T[] array)
Returns an array containing all of the shapes in this set; the runtime type of the returned array is that of the specified array. | ||||||||||
Shape[]
|
toArray()
Returns an array containing all of the shapes in this set.
|
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()
|
Methods inherited from
interface
java.util.Collection
| |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract
boolean
|
add(E arg0)
| ||||||||||
abstract
boolean
|
addAll(Collection<? extends E> arg0)
| ||||||||||
abstract
void
|
clear()
| ||||||||||
abstract
boolean
|
contains(Object arg0)
| ||||||||||
abstract
boolean
|
containsAll(Collection<?> arg0)
| ||||||||||
abstract
boolean
|
equals(Object arg0)
| ||||||||||
abstract
int
|
hashCode()
| ||||||||||
abstract
boolean
|
isEmpty()
| ||||||||||
abstract
Iterator<E>
|
iterator()
| ||||||||||
abstract
boolean
|
remove(Object arg0)
| ||||||||||
abstract
boolean
|
removeAll(Collection<?> arg0)
| ||||||||||
abstract
boolean
|
retainAll(Collection<?> arg0)
| ||||||||||
abstract
int
|
size()
| ||||||||||
abstract
<T>
T[]
|
toArray(T[] arg0)
| ||||||||||
abstract
Object[]
|
toArray()
|
Methods inherited from
interface
java.util.Set
| |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract
boolean
|
add(E arg0)
| ||||||||||
abstract
boolean
|
addAll(Collection<? extends E> arg0)
| ||||||||||
abstract
void
|
clear()
| ||||||||||
abstract
boolean
|
contains(Object arg0)
| ||||||||||
abstract
boolean
|
containsAll(Collection<?> arg0)
| ||||||||||
abstract
boolean
|
equals(Object arg0)
| ||||||||||
abstract
int
|
hashCode()
| ||||||||||
abstract
boolean
|
isEmpty()
| ||||||||||
abstract
Iterator<E>
|
iterator()
| ||||||||||
abstract
boolean
|
remove(Object arg0)
| ||||||||||
abstract
boolean
|
removeAll(Collection<?> arg0)
| ||||||||||
abstract
boolean
|
retainAll(Collection<?> arg0)
| ||||||||||
abstract
int
|
size()
| ||||||||||
abstract
<T>
T[]
|
toArray(T[] arg0)
| ||||||||||
abstract
Object[]
|
toArray()
|
Creates a new, empty shape field with no gravity.
Adds the specified shape to this set if it is not already present.
true if this set did not already contain the specified shape
Adds all of the shapes in the specified collection to this set if they're not already present.
true if the set changed as a result of this operation
Gets the backmost shape in the shape set. 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 backmost shape in the set, or null if the set is empty
Removes all of the shapes from this set. The set will be empty after this call returns.
Returns true if this set contains the specified shape.
true if this set contains the specified shape
Returns true if this set contains all of the shapes of the specified collection.
true if this set contains all of the shapes of the specified collection
Compares the specified object with this set for equality.
true if the specified object is equal to this set
Gets the frontmost shape in the shape set. 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 set is empty
Access an iterator that traverses the collection from "front" (top) to "back" (bottom) in terms of drawing order.
An iterator representing this traversal order.
This method is intended for internal and advanced usage
only. Gets the JBox2D World
that manages the physical
bodies inside this shape view.
the JBox2D world that manages the physical bodies inside this shape view
Gets the gravity of the physical world represented by this shape view.
a PointF
object whose x and y components are the
horizontal and vertical acceleration due to gravity (in units/sec^2)
of the physical world represented by this shape view
Gets a filter that can be used to find shapes that match a certain set of criteria. The search criteria are specified by chaining method calls to the returned filter. For example, to find all the red shapes that intersect with a particular rectangular area on the screen, one can write:
getShapes().withColor(Color.red).intersecting(0, 0, 50, 50)
The ShapeFilter
object returned by one of these filter chains
implements the Iterable
interface so you can easily use it in a
for-each loop to process the matching shapes. It also supports other
convenience methods; see the documentation for ShapeFilter
for
more information.
a ShapeFilter
that matches and allows iteration over the
shapes that match a set of criteria
Returns the hash code value for this set.
the hash code value for this set
Returns true if this set contains no shapes.
true if this set contains no shapes
Returns an iterator over the shapes in this set. The shapes are returned in order from farthest back (lowest z-index) to farthest forward (highest z-index).
an iterator over the shapes in this set
Removes the specified shape from this set if it is present.
true if this set contained the specified shape
Removes from this set all of its shapes that are contained in the specified collection.
true if this set changed as a result of the call
Retains only the shapes in this set that are contained in the specified collection. In other words, removes from this set all of its shapes that are not contained in the specified collection.
true if this set changed as a result of the call
Change the shape order for this shape set.
Sets the gravity of the physical world represented by this shape view.
Sets the gravity of the physical world represented by this shape view.
PointF
whose x and y components are the
horizontal and vertical acceleration due to gravity (in units/sec^2)
of the physical world represented by this shape view
Returns the number of shapes in this set (its cardinality).
the number of shapes in this set (its cardinality)
Returns an array containing all of the shapes in this set; the runtime type of the returned array is that of the specified array. If the set fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this set.
If this set fits in the specified array with room to spare (i.e., the array has more elements than this set), the element in the array immediately following the end of the set is set to null. (This is useful in determining the length of this set only if the caller knows that this set does not contain any null elements.)
The shapes are returned in order from farthest back (lowest z-index) to farthest forward (highest z-index).
Returns an array containing all of the shapes in this set. The shapes are returned in order from farthest back (lowest z-index) to farthest forward (highest z-index).