JTP
Class ScreenFrames

java.lang.Object
  extended by JTP.ScreenFrames

public class ScreenFrames
extends Object

Responsible for drawing borders and frames, also provides dimensions to other game components.

Author:
V.Termanis

Field Summary
static int CTRL_DEFAULT
           
static int CTRL_EDITOR
           
static int CTRL_NONE
           
static int CTRL_P_ALTERNATE
           
static int CTRL_P_CHALLENGE
           
static int CTRL_P_NORMAL
           
static int CTRL_P_SIMULTANEOUS
           
static int RENDERING_BALANCED
           
static int RENDERING_QUALITY
           
static int RENDERING_SPEED
           
 
Constructor Summary
ScreenFrames(Rectangle drawArea, Rectangle gridFrame, Rectangle ctrlFrame, Point editorFrameSplit, int gameCtrlTopFrameSize, Point[] gameCtrlFrameSplit, Color bgColor, Color gridFrameColor, Color ctrlFrameColor, int borderSpacing, int curvature, int tileSize, int heightPerLevel, float frameThickness)
          Creates a new ScreenFrames instance with the specified parameters.
 
Method Summary
 void drawAll(boolean background, boolean thirdBox, Graphics2D g)
          Draws all frames (as currently configured)
 void drawAll(boolean background, Graphics2D g)
          Draws all frames (as currently configured)
 void drawGridFrame(boolean background, Graphics2D g)
          Only draws the frame around tile grid
 Color getBgColor()
          Returns currently used background colour
 int getBorderSpacing()
          Returns border spacing used (between frames and screen border)
 Color getCtrlFrameColor()
          Returns colour of the control frame
 int getCtrlFrameType()
          Returns the type of control frame in use
 Rectangle getCtrlOffset()
          Returns default location of control frame
 Rectangle getDrawArea()
          Returns size of draw area.
 Rectangle[] getEditorCtrlOffset()
          Returns location of control frames as used in editor
 int getFrameThickness()
          Returns thickness rounded up to the nearest integer (pixel)
 Rectangle getGameCtrlOffset(int index)
          Returns location of a sub-control frame (in-game only)
 Rectangle getGridArea()
          Returns dimensions of the tile grid.
 Rectangle getGridOffset()
          Returns location of tile grid frame
 int getHeightPerLevel()
          Returns height per tile
 Rectangle getOffset()
          Returns offset from top-left window corner where to render tile grid (not frame)
 int getRenderQuality()
          Used by other game components to determine how they should render.
 int getTileSize()
          Returns width/height of tiles
 Rectangle getWholeDrawArea()
          Returns size of whole screen.
 void setBgColor(Color c)
          Sets the background colour to use
 void setCtrlFrameType(int type)
          Sets the type of control frame to use
 void setRenderingHints(Graphics2D g, boolean on)
          Turns rendering options for the current graphics context on or off.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RENDERING_SPEED

public static final int RENDERING_SPEED
See Also:
Constant Field Values

RENDERING_BALANCED

public static final int RENDERING_BALANCED
See Also:
Constant Field Values

RENDERING_QUALITY

public static final int RENDERING_QUALITY
See Also:
Constant Field Values

CTRL_NONE

public static final int CTRL_NONE
See Also:
Constant Field Values

CTRL_P_NORMAL

public static final int CTRL_P_NORMAL
See Also:
Constant Field Values

CTRL_P_CHALLENGE

public static final int CTRL_P_CHALLENGE
See Also:
Constant Field Values

CTRL_P_SIMULTANEOUS

public static final int CTRL_P_SIMULTANEOUS
See Also:
Constant Field Values

CTRL_P_ALTERNATE

public static final int CTRL_P_ALTERNATE
See Also:
Constant Field Values

CTRL_DEFAULT

public static final int CTRL_DEFAULT
See Also:
Constant Field Values

CTRL_EDITOR

public static final int CTRL_EDITOR
See Also:
Constant Field Values
Constructor Detail

ScreenFrames

public ScreenFrames(Rectangle drawArea,
                    Rectangle gridFrame,
                    Rectangle ctrlFrame,
                    Point editorFrameSplit,
                    int gameCtrlTopFrameSize,
                    Point[] gameCtrlFrameSplit,
                    Color bgColor,
                    Color gridFrameColor,
                    Color ctrlFrameColor,
                    int borderSpacing,
                    int curvature,
                    int tileSize,
                    int heightPerLevel,
                    float frameThickness)
             throws NullPointerException,
                    IllegalArgumentException
Creates a new ScreenFrames instance with the specified parameters.

Parameters:
drawArea - dimensions of the whole game screen
gridFrame - dimensions of the tile grid
ctrlFrame - dimensions of the status/button display (RHS)
editorFrameSplit - defines dimensions of the three editor control frames (i.e. height of first two, third takes the rest)
gameCtrlTopFrameSize - defines dimensions of the top status frame in-game
gameCtrlFrameSplit - dimensions for the other in-game status frames (normal, cahellgen, simultaneous, alternate)
bgColor - default background colour
gridFrameColor - colour of frame around tile grid
ctrlFrameColor - colour of frame around status/control buttons
borderSpacing - padding between frames and screen borders
curvature - how curvy should the frame corners be
tileSize - legacy option - should be set to 40
heightPerLevel - legacy option - should be set to 5
frameThickness - how thick should frames be
Throws:
NullPointerException
IllegalArgumentException
Method Detail

getRenderQuality

public int getRenderQuality()
Used by other game components to determine how they should render.

Returns:
the rendering quality (see Field summary)

setCtrlFrameType

public void setCtrlFrameType(int type)
                      throws IllegalArgumentException
Sets the type of control frame to use

Parameters:
type - (e.g. CTRL_P_NORMAL)
Throws:
IllegalArgumentException

getCtrlFrameType

public int getCtrlFrameType()
Returns the type of control frame in use

Returns:
frame type

drawAll

public void drawAll(boolean background,
                    Graphics2D g)
Draws all frames (as currently configured)

Parameters:
background - should the background be cleared also
g - graphics context for rendering

drawAll

public void drawAll(boolean background,
                    boolean thirdBox,
                    Graphics2D g)
Draws all frames (as currently configured)

Parameters:
background - should the background be cleared also
thirdBox - render third control frame?
g - graphics context for rendering

setRenderingHints

public void setRenderingHints(Graphics2D g,
                              boolean on)
Turns rendering options for the current graphics context on or off. Note: This only works for the RENDERING_BALANCED mode.

Parameters:
g - graphics context for rendering
on - should the hints be turned on or off?

drawGridFrame

public void drawGridFrame(boolean background,
                          Graphics2D g)
Only draws the frame around tile grid

Parameters:
background - should the background be cleared also?
g - graphics context for rendering

getWholeDrawArea

public Rectangle getWholeDrawArea()
Returns size of whole screen.

Returns:
dimensions

getDrawArea

public Rectangle getDrawArea()
Returns size of draw area.

Returns:
either dimensions of full window or, if the frame mode is not CTRL_NONE, dimensions of tile grid.

getOffset

public Rectangle getOffset()
Returns offset from top-left window corner where to render tile grid (not frame)

Returns:
location and dimensions

getGridOffset

public Rectangle getGridOffset()
Returns location of tile grid frame

Returns:
location and dimensions

getCtrlOffset

public Rectangle getCtrlOffset()
Returns default location of control frame

Returns:
location and dimensions

getGameCtrlOffset

public Rectangle getGameCtrlOffset(int index)
                            throws IndexOutOfBoundsException
Returns location of a sub-control frame (in-game only)

Parameters:
index - which sub-frame
Returns:
null if current ctrl setting is not one of the game ones or the dimensions of the sub-frame
Throws:
IndexOutOfBoundsException

getEditorCtrlOffset

public Rectangle[] getEditorCtrlOffset()
Returns location of control frames as used in editor

Returns:
location and dimensions

getBorderSpacing

public int getBorderSpacing()
Returns border spacing used (between frames and screen border)

Returns:
spacing in pixels

setBgColor

public void setBgColor(Color c)
                throws NullPointerException
Sets the background colour to use

Parameters:
c - the new background colour to use
Throws:
NullPointerException

getBgColor

public Color getBgColor()
Returns currently used background colour

Returns:
colour

getCtrlFrameColor

public Color getCtrlFrameColor()
Returns colour of the control frame

Returns:
colour

getTileSize

public int getTileSize()
Returns width/height of tiles

Returns:
size in pixels

getHeightPerLevel

public int getHeightPerLevel()
Returns height per tile

Returns:
height in pixels

getGridArea

public Rectangle getGridArea()
Returns dimensions of the tile grid.

Returns:
dimensions

getFrameThickness

public int getFrameThickness()
Returns thickness rounded up to the nearest integer (pixel)

Returns:
frame thickness in pixels