Sofia API Reference

  • Package Index
  • Class Index
  • Packages
  • sofia.app
    • Interfaces
    • ScreenMethods
    • Classes
    • ActivityStarter
    • ListScreen
    • Screen
    • ShapeScreen
    • Annotations
    • OptionsMenu
    • Persistent
    • Persistor
    • ScreenLayout
  • sofia.content
  • sofia.data
  • sofia.graphics
  • sofia.util
  • sofia.view
  • sofia.widget

public abstract class
ShapeScreen

extends Screen

Inheritance

  • java.lang.Object
    • Activity
      • sofia.app.Screen
        • sofia.app.ShapeScreen

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

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.
Methods inherited from class sofia.app.Screen
void afterInitialize()
Called once the screen has been created and made visible.
void afterLayoutInflated(boolean inflated)
This method is called after an attempted was made to inflate the screen's layout.
void beforeInitialize()
Called before initialize() during the screen creation process.
boolean doInitializeAfterLayout()

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

void finish(Object result)
Call this method when the current screen is finished and should be closed.
LayoutInflater getLayoutInflater()
ScreenMixin getScreenMixin()
Not intended to be called by users; this method is public as an implementation detail.
Object getSystemService(String service)
This method is overridden to replace the default Android layout inflater with one that supports Sofia's enhancements.
void initialize()
Called when the screen has been created and is about to be displayed on the device.
void log(String message)
Prints an informational message to the system log, tagged with the "User Log" tag so that it can be easily identified in the LogCat view.
void onActivityResult(int requestCode, int resultCode, Intent data)
Called when a sub-activity returns yielding a result.
void onCreate(Bundle savedInstanceState)
Called when the activity is created.
boolean onCreateOptionsMenu(Menu menu)
void onDestroy()
boolean onMenuItemSelected(int featureId, MenuItem item)
void onPause()
void onResume()
void onSaveInstanceState(Bundle bundle)
void onStop()
void presentActivity(Intent intent, String returnMethod)
Starts the activity with the specified intent.
void presentScreen(Class<? extends Activity> screenClass, Object... args)
Starts the activity represented by the specified Screen subclass and slides it into view.
void showAlertDialog(String title, String message)
Displays an alert dialog and waits for the user to dismiss it.
boolean showConfirmationDialog(String title, String message)
Displays a confirmation dialog and waits for the user to select an option.
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 sofia.app.ScreenMethods
abstract void finish(Object result)
Call this method when the current screen is finished and should be closed.
abstract void presentActivity(Intent intent, String returnMethod)
Starts the activity with the specified intent.
abstract void presentScreen(Class<? extends Activity> screenClass, Object... args)
Starts the activity represented by the specified screen class and slides it into view.
abstract void showAlertDialog(String title, String message)
Displays an alert dialog and waits for the user to dismiss it.
abstract boolean showConfirmationDialog(String title, String message)
Displays a confirmation dialog and waits for the user to select an option.

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.