public abstract class

ShapeScreen

extends Screen
java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.view.ContextThemeWrapper
         ↳ android.app.Activity
           ↳ sofia.app.Screen
             ↳ sofia.app.ShapeScreen
Known Direct Subclasses

Class Overview

ShapeScreen is a subclass of screen that provides a built-in ShapeView and convenience methods for manipulating shapes directly in the screen class instead of having to call getShapeView() for every operation.

When you subclass ShapeScreen, by default it will create a new ShapeView that occupies the entire width and height of the screen. If this is not what you want (for example, if you want to have a ShapeView alongside other widgets but still retain the convenience of methods like add(Shape) directly on the screen), then place an instance of ShapeView in your layout file with the ID shapeView. Then the ShapeScreen will use that view for all of its other methods instead of creating its own.

Summary

[Expand]
Inherited Constants
From class android.app.Activity
From class android.content.Context
[Expand]
Inherited Fields
From class android.app.Activity
Public Constructors
ShapeScreen()
Public Methods
void add(Shape shape)
Adds a shape to the screen.
void clear()
Removes all shapes currently on the screen.
boolean doInitializeAfterLayout()

Determines whether the user's initialize() method should be postponed until layout of the views has already occurred.

void enableRotateGestures()
Turn on detection of rotation gestures on the ShapeView.
void enableScaleGestures()
Turn on detection of scale (pinch) gestures on the ShapeView.
CoordinateSystem getCoordinateSystem()
PointF getGravity()
Gets the gravity of the physical world represented by this shape screen.
float getHeight()
Return the height of your view.
ShapeField getShapeField()
ShapeView getShapeView()
Gets the ShapeView that holds all of the shapes on this screen.
ShapeFilter<Shape> getShapes()
float getWidth()
Return the width of the your view.
void remove(Shape shape)
Removes a shape from the screen.
void setBackgroundColor(Color color)
Sets the background color of the screen's ShapeView.
void setGravity(float xGravity, float yGravity)
Sets the gravity of the physical world represented by this shape screen.
void setGravity(PointF gravity)
Sets the gravity of the physical world represented by this shape screen.
void setShapeField(ShapeField newField)
Protected Methods
void afterLayoutInflated(boolean inflated)
This method is called after an attempted was made to inflate the screen's layout.
ShapeView createShapeView(ShapeScreen parent)
This factory method is used to create the ShapeView that will be contained by this screen.
[Expand]
Inherited Methods
From class sofia.app.Screen
From class android.app.Activity
From class android.view.ContextThemeWrapper
From class android.content.ContextWrapper
From class android.content.Context
From class java.lang.Object
From interface android.content.ComponentCallbacks
From interface android.view.KeyEvent.Callback
From interface android.view.LayoutInflater.Factory
From interface android.view.View.OnCreateContextMenuListener
From interface android.view.Window.Callback
From interface sofia.app.ScreenMethods

Public Constructors

public ShapeScreen ()

Public Methods

public void add (Shape shape)

Adds a shape to the screen.

Parameters
shape The shape to add to the screen.

public void clear ()

Removes all shapes currently on the screen.

public boolean doInitializeAfterLayout ()

Determines whether the user's initialize() method should be postponed until layout of the views has already occurred.

In most cases, the default behavior of false is preferred, which will cause initialize() to be called during the activity's onCreate(Bundle) method, where the view hierarchy of the activity can be created. But some specialized subclasses of Screen, like ShapeScreen, postpone the call to initialize() until later, after its ShapeView has already been laid out, so that users can access the width and height of the view in order lay out shapes using that information in calculations.

Returns
  • true if initialize() should be postponed until the screen's views are already laid out, or false to call it immediately in onCreate(Bundle)

public void enableRotateGestures ()

Turn on detection of rotation gestures on the ShapeView.

public void enableScaleGestures ()

Turn on detection of scale (pinch) gestures on the ShapeView.

public CoordinateSystem getCoordinateSystem ()

public PointF getGravity ()

Gets the gravity of the physical world represented by this shape screen.

Returns
  • 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 screen

public float getHeight ()

Return the height of your view.

Returns
  • The height of your view, in pixels.

public ShapeField getShapeField ()

public ShapeView getShapeView ()

Gets the ShapeView that holds all of the shapes on this screen.

Returns
  • The ShapeView that holds all of the shapes on this screen.

public ShapeFilter<Shape> getShapes ()

public float getWidth ()

Return the width of the your view.

Returns
  • The width of your view, in pixels.

public void remove (Shape shape)

Removes a shape from the screen.

Parameters
shape The shape to remove from the screen.

public void setBackgroundColor (Color color)

Sets the background color of the screen's ShapeView. Note that if you provide your own layout where the ShapeView only occupies a portion of the screen, this method will only affect the ShapeView portion and not the entire screen.

Parameters
color the desired background color

public void setGravity (float xGravity, float yGravity)

Sets the gravity of the physical world represented by this shape screen.

Parameters
xGravity the horizontal acceleration due to gravity (in units/sec^2)
yGravity the vertical acceleration due to gravity (in units/sec^2)

public void setGravity (PointF gravity)

Sets the gravity of the physical world represented by this shape screen.

Parameters
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 screen

public void setShapeField (ShapeField newField)

Protected Methods

protected void afterLayoutInflated (boolean inflated)

This method is called after an attempted was made to inflate the screen's layout. Most users will not need to call or override this method; it is provided for Sofia's own subclasses of Screen to support custom behavior depending on whether a user layout was provided or not.

Returns
  • true if a layout was found and inflated, otherwise false

protected ShapeView createShapeView (ShapeScreen parent)

This factory method is used to create the ShapeView that will be contained by this screen. It is provided for subclass extensibility, in case a subclass of ShapeScreen wants to use a more specialized ShapeView instance.

Parameters
parent The screen that will contain the view (e.g., "this")
Returns
  • A new ShapeView object to use for this screen.