Package com.starpoints.painter
Class PainterBase
- java.lang.Object
-
- com.starpoints.painter.PainterBase
-
- All Implemented Interfaces:
Painter
- Direct Known Subclasses:
Painter2DArena
,PainterBackground
,PainterBackgroundAnimation
,PainterControlButtons
,PainterCredits
,PainterDimmer
,PainterFlashAnimation
,PainterFlashAnimationEditor
,PainterGameFinishedAnimation
,PainterKeyboard
,PainterLevelInfo
,PainterLevelOverview
,PainterMenu
,PainterMessageText
,PainterPlayerInfos
,PainterSet
,PainterShopEditor
,PainterText
public abstract class PainterBase extends java.lang.Object implements Painter
Base class for Painter implementations.
-
-
Field Summary
Fields Modifier and Type Field Description protected Rectangle
area
The paint area.protected int[]
areas
The mouse areas with menu itemsprotected Font
bigFont
A big font.protected StarpointController
controller
Reference to the Controller.protected static boolean
DEBUG
Debug flag.protected UpdateInfo
gameInfo
The game.protected Font
medFont
A medium size font.protected int
mouseArea
The current area the mouse is over.protected int
offset
Indent for textprotected int
oldMouseArea
The last area the mouse was over.protected Options
options
The options.protected Font
smallFont
A small font.protected GameState
state
The game state.protected Font
verysmallFont
A small font.protected double
xfactor
The x scaling factor (based on a resolution of 1024x768).protected double
yfactor
The y scaling factor (based on a resolution of 1024x768)..
-
Constructor Summary
Constructors Constructor Description PainterBase()
Base constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
draw(Graphics g, java.lang.String s, int indent, int yPosition, int c, Font f)
Draws a string on a virtual 20*25 coordinate system.protected void
drawShaded(Graphics g, java.lang.String s, int x, int y, int c, int shadeColor, Font f)
Draws a shaded string.protected void
drawShaded(Graphics g, java.lang.String s, int x, int y, int c, Font f)
Draws a shaded string.Rectangle
getArea()
Gets the size for this Painter.int
getBaseHeight()
Gets the base height of this painter.int
getBaseWidth()
Gets the base width of this painter.StarpointEditor
getEditor()
Gets the editor.int
getHeight()
Gets this fields height.int
getIndent()
The x indentprotected int
getRepaintFactor()
Gets a factor for repaint cycles depending on the current frame rate (1 for 20 FPS).int
getWidth()
Gets this fields width.double
getXFactor()
Gets the x scaling factordouble
getYFactor()
Gets the y scaling factorboolean
isActive()
Checks, if this painter is currently active and wants to handle events.boolean
isInputController()
Returns true, if the painter implements InputController.void
onStartGame(GameState state)
Called when a new game is started.abstract void
paint(Graphics g, GameState state)
Paints on the screen.void
setArea(Rectangle area)
Sets the size for this Painter.void
setController(StarpointController controller)
Sets the reference to the Controller.protected void
setFontSize()
Sets the standard fonts.void
setLevel(Level currentLevel)
Sets the level.void
setOptions(Options opt)
Sets the options.void
setState(GameState state)
Sets the game state reference during painting routine.
-
-
-
Field Detail
-
DEBUG
protected static final boolean DEBUG
Debug flag.- See Also:
- Constant Field Values
-
area
protected Rectangle area
The paint area.
-
mouseArea
protected int mouseArea
The current area the mouse is over.
-
oldMouseArea
protected int oldMouseArea
The last area the mouse was over.
-
offset
protected int offset
Indent for text
-
xfactor
protected double xfactor
The x scaling factor (based on a resolution of 1024x768).
-
yfactor
protected double yfactor
The y scaling factor (based on a resolution of 1024x768)..
-
options
protected Options options
The options.
-
areas
protected int[] areas
The mouse areas with menu items
-
gameInfo
protected UpdateInfo gameInfo
The game.
-
bigFont
protected Font bigFont
A big font.
-
medFont
protected Font medFont
A medium size font.
-
smallFont
protected Font smallFont
A small font.
-
verysmallFont
protected Font verysmallFont
A small font.
-
controller
protected StarpointController controller
Reference to the Controller.
-
state
protected GameState state
The game state. Updated directly before painting.
-
-
Method Detail
-
getBaseWidth
public int getBaseWidth()
Gets the base width of this painter.- Specified by:
getBaseWidth
in interfacePainter
- Returns:
- 1920.
-
getBaseHeight
public int getBaseHeight()
Gets the base height of this painter.- Specified by:
getBaseHeight
in interfacePainter
- Returns:
- 1061.
-
setArea
public void setArea(Rectangle area)
Sets the size for this Painter. All graphic operations should be restricted to this area.
-
getArea
public Rectangle getArea()
Gets the size for this Painter.
-
getWidth
public int getWidth()
Gets this fields width.- Returns:
- The width
-
getHeight
public int getHeight()
Gets this fields height.- Returns:
- The height
-
setOptions
public void setOptions(Options opt)
Sets the options.- Specified by:
setOptions
in interfacePainter
- Parameters:
opt
- The new options.
-
getRepaintFactor
protected int getRepaintFactor()
Gets a factor for repaint cycles depending on the current frame rate (1 for 20 FPS).- Returns:
- e.g. 1 fo 20FPS, 6 for 120 FPS
-
draw
protected void draw(Graphics g, java.lang.String s, int indent, int yPosition, int c, Font f)
Draws a string on a virtual 20*25 coordinate system.- Parameters:
g
- The Graphics to draw on.s
- The string.indent
- The x indent.yPosition
- The y Position.c
- The color.f
- The Font.
-
drawShaded
protected void drawShaded(Graphics g, java.lang.String s, int x, int y, int c, Font f)
Draws a shaded string.- Parameters:
g
- The Graphics to draw on.s
- The string.x
- The x indent.y
- The y Position.c
- The color.f
- The Font.
-
drawShaded
protected void drawShaded(Graphics g, java.lang.String s, int x, int y, int c, int shadeColor, Font f)
Draws a shaded string.- Parameters:
g
- The Graphics to draw on.s
- The string.x
- The x indent.y
- The y Position.c
- The color.shadeColor
- The shade color.f
- The Font.
-
getIndent
public int getIndent()
The x indent- Returns:
- The indent.
-
paint
public abstract void paint(Graphics g, GameState state)
Paints on the screen. Override this method for own graphic effects.
-
setController
public void setController(StarpointController controller)
Sets the reference to the Controller.- Parameters:
controller
- Controller
-
setFontSize
protected void setFontSize()
Sets the standard fonts.
-
getXFactor
public double getXFactor()
Gets the x scaling factor- Specified by:
getXFactor
in interfacePainter
- Returns:
- the xfactor
-
getYFactor
public double getYFactor()
Gets the y scaling factor- Specified by:
getYFactor
in interfacePainter
- Returns:
- the yfactor
-
isInputController
public boolean isInputController()
Returns true, if the painter implements InputController.- Returns:
- true, if implementing interface InputController.
-
setLevel
public void setLevel(Level currentLevel)
Sets the level.- Parameters:
currentLevel
- The level.
-
setState
public void setState(GameState state)
Sets the game state reference during painting routine.
-
onStartGame
public void onStartGame(GameState state)
Called when a new game is started.- Specified by:
onStartGame
in interfacePainter
- Parameters:
state
- The game state.
-
getEditor
public StarpointEditor getEditor()
Gets the editor.- Returns:
- The editor.
-
-