public abstract class

CanvasScreen

extends Screen
java.lang.Object
   ↳ com.neomades.app.Screen
     ↳ com.neomades.graphics.CanvasScreen

Class Overview

A canvas screen is used to perform 2D drawing operations. By overriding the paint method, you can draw to the screen.

Summary

[Expand]
Inherited Constants
From class com.neomades.app.Screen
From interface com.neomades.app.Keys
From interface com.neomades.app.Orientation
From interface com.neomades.ui.Alignment
From interface com.neomades.ui.StretchMode
[Expand]
Inherited Fields
From class com.neomades.app.Screen
Public Constructors
CanvasScreen()
Create a new CanvasScreen.
Public Methods
final int getHeight()
Returns the height of the canvas screen in pixels.
Rect getScreenRect()
Returns the rectangle corresponding to the screen.
final int getWidth()
Returns the width of the canvas screen in pixels.
void refresh()
Refresh the entire screen.
void startAutoRefresh(int timer)
Indicates that the screen will be refreshed at a regular interval.
void stopAutoRefresh()
Stops the screen from being automatically refreshed.
Protected Methods
View getContent()
Cannot be called for CanvasScreen.
void onSizeChanged(int w, int h)
Override this method to provide a behavior when the size of the canvas screen is changed For example, when the device is set in landscape mode.
void onUpdate()
abstract void paint(Graphics g)
Override this method to do the painting to the screen.
void setContent(View content)
Cannot be called for CanvasScreen.
[Expand]
Inherited Methods
From class com.neomades.app.Screen
From class java.lang.Object

Public Constructors

public CanvasScreen ()

Create a new CanvasScreen.

Public Methods

public final int getHeight ()

Returns the height of the canvas screen in pixels.

Returns
  • the height of the canvas screen in pixels

public Rect getScreenRect ()

Returns the rectangle corresponding to the screen.

Returns
  • the rectangle corresponding to the screen

public final int getWidth ()

Returns the width of the canvas screen in pixels.

Returns
  • the width of the canvas screen in pixels

public void refresh ()

Refresh the entire screen.

public void startAutoRefresh (int timer)

Indicates that the screen will be refreshed at a regular interval. this will create a timer that will refresh the screen. The timer is started when this method is called.

Parameters
timer the time between two refresh call

public void stopAutoRefresh ()

Stops the screen from being automatically refreshed.

Protected Methods

protected View getContent ()

Cannot be called for CanvasScreen.

Returns
  • null

protected void onSizeChanged (int w, int h)

Override this method to provide a behavior when the size of the canvas screen is changed For example, when the device is set in landscape mode.

Parameters
w the new canvas width
h the new canvas height

protected void onUpdate ()

protected abstract void paint (Graphics g)

Override this method to do the painting to the screen.

Parameters
g the graphics used to draw

protected void setContent (View content)

Cannot be called for CanvasScreen.

Parameters
content the content of this screen