java.lang.Object | |||
↳ | android.view.View | ||
↳ | android.view.SurfaceView | ||
↳ | sofia.graphics.ShapeView |
Known Direct Subclasses |
Represents a view containing drawn Shape objects.
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.View
|
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.View
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ShapeView(Context context)
Creates a new ShapeView.
| |||||||||||
ShapeView(Context context, AttributeSet attrs)
Creates a new ShapeView.
| |||||||||||
ShapeView(Context context, AttributeSet attrs, int defStyle)
Creates a new ShapeView.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
add(Shape shape)
Adds a shape to the ShapeField currently in use by this view.
| ||||||||||
void |
clear()
Removes all shapes from the ShapeField currently in use by this
view.
| ||||||||||
void | conditionallyRepaint() | ||||||||||
boolean | dispatchTouchEvent(MotionEvent e) | ||||||||||
void |
doRepaint()
The real method that performs shape drawing in response to a
callback from the repainting thread.
| ||||||||||
synchronized boolean |
doesAutoRepaint()
Does this view automatically repaint, or is an explicit call needed?
| ||||||||||
void |
enableRotateGestures()
Turn on support for rotation gestures.
| ||||||||||
void |
enableScaleGestures()
Turn on support for pinching/zoom gestures.
| ||||||||||
ShapeAnimationManager |
getAnimationManager()
Get the animation manager for this view.
| ||||||||||
Color |
getBackgroundColor()
Gets the background color of the view.
| ||||||||||
CoordinateSystem | getCoordinateSystem() | ||||||||||
PointF |
getGravity()
Gets the gravity of the physical world represented by this shape view.
| ||||||||||
<MyShape extends Shape> Set<MyShape> |
getNeighbors(Shape shape, float distance, boolean diag, Class<MyShape> cls)
Returns the neighbors to the given location.
| ||||||||||
ShapeField |
getShapeField()
Gets the ShapeField that the view is currently displaying and
simulating.
| ||||||||||
ShapeFilter<Shape> |
getShapes()
Gets a filter that can be used to find shapes that match certain
criteria.
| ||||||||||
<MyShape extends Shape> Set<MyShape> |
getShapesInDirection(float x, float y, float angle, float length, Class<MyShape> cls)
Return all objects that intersect a straight line from the location at
a specified angle.
| ||||||||||
<MyShape extends Shape> Set<MyShape> |
getShapesInRange(float x, float y, float r, Class<MyShape> cls)
Returns all objects with the logical location within the specified
circle.
| ||||||||||
synchronized void |
internalSetAutoRepaintForThread(boolean value)
Used internally to temporarily disable repainting.
| ||||||||||
boolean |
isInFrontOf(Shape left, Shape right)
Returns true if the left shape is drawn in front of (later than) the
shape on the right.
| ||||||||||
boolean | onKeyDown(int keyCode, KeyEvent e) | ||||||||||
boolean | onTouchEvent(MotionEvent e) | ||||||||||
void |
remove(Shape shape)
Removes a shape from the ShapeField currently in use by this
view.
| ||||||||||
void | repaint() | ||||||||||
synchronized void |
setAutoRepaint(boolean value)
Tell this view to automatically repaint when Shapes change (or not).
| ||||||||||
void |
setBackgroundColor(Color color)
Sets the background color of the view.
| ||||||||||
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.
| ||||||||||
void |
setShapeField(ShapeField newField)
Sets the ShapeField that the view is currently displaying and
simulating.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
drawContents(Canvas canvas)
Draw all of this view's shapes on the given canvas.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.SurfaceView
| |||||||||||
From class
android.view.View
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
android.graphics.drawable.Drawable.Callback
| |||||||||||
From interface
android.view.KeyEvent.Callback
| |||||||||||
From interface
android.view.accessibility.AccessibilityEventSource
|
Creates a new ShapeView.
context | This view's context. |
---|---|
attrs | This view's attributes. |
Creates a new ShapeView.
context | This view's context. |
---|---|
attrs | This view's attributes. |
defStyle | This view's default style. |
Adds a shape to the ShapeField currently in use by this view.
This method is a shortcut for getShapeField().add(shape)
.
shape | the shape to add |
---|
Removes all shapes from the ShapeField currently in use by this
view. This method is a shortcut for getShapeField().clear()
.
The real method that performs shape drawing in response to a callback from the repainting thread.
Does this view automatically repaint, or is an explicit call needed?
Turn on support for rotation gestures.
Turn on support for pinching/zoom gestures.
Get the animation manager for this view.
Gets the background color of the view.
Gets the gravity of the physical world represented by this shape view.
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
Returns the neighbors to the given location. This method only looks at the logical location and not the extent of objects. Hence it is most useful in scenarios where objects only span one cell.
shape | The shape whose neighbors will be located. |
---|---|
distance | Distance in which to look for other objects. |
diag | Is the distance also diagonal? |
cls | Class of objects to look for (null or Object.class will find all classes). |
Gets the ShapeField that the view is currently displaying and simulating.
Gets a filter that can be used to find shapes that match certain
criteria. This method is a shortcut for
getShapeField().getShapes()
.
Return all objects that intersect a straight line from the location at a specified angle. The angle is clockwise.
x | x-coordinate. |
---|---|
y | y-coordinate. |
angle | The angle relative to current rotation of the object. (0-359). |
length | How far we want to look (in cells). |
cls | Class of objects to look for (null or Object.class will find all classes). |
Returns all objects with the logical location within the specified circle. In other words an object A is within the range of an object B if the distance between the center of the two objects is less than r.
x | Center of the circle. |
---|---|
y | Center of the circle. |
r | Radius of the circle. |
cls | Class of objects to look for (null or Object.class will find all classes). |
Used internally to temporarily disable repainting.
value | Says whether the current thread is restoring auto-painting or disabling auto-painting. |
---|
Returns true if the left shape is drawn in front of (later than) the shape on the right.
left | The shape to check. |
---|---|
right | The shape to check against. |
Removes a shape from the ShapeField currently in use by this
view. This method is a shortcut for
getShapeField().remove(shape)
.
shape | the shape to remove |
---|
Tell this view to automatically repaint when Shapes change (or not).
value | Whether or not this view should automatically repaint when shapes change. |
---|
Sets the background color of the view.
color | the desired background Color |
---|
Sets the gravity of the physical world represented by this shape view.
xGravity | the horizontal acceleration due to gravity (in units/sec^2) |
---|---|
yGravity | the vertical acceleration due to gravity (in units/sec^2) |
Sets the gravity of the physical world represented by this shape view.
gravity | a 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
|
---|
Sets the ShapeField that the view is currently displaying and simulating. When developing games or simulations that involve multiple "levels" or other complex multiple shape layouts, this method can be used to quickly and easily swap out the entire set of shapes used by the view.
newField | the ShapeField to be used by the view |
---|
Draw all of this view's shapes on the given canvas.
canvas | The canvas to draw on. |
---|