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 RectangleareaThe paint area.protected int[]areasThe mouse areas with menu itemsprotected FontbigFontA big font.protected StarpointControllercontrollerReference to the Controller.protected static booleanDEBUGDebug flag.protected UpdateInfogameInfoThe game.protected FontmedFontA medium size font.protected intmouseAreaThe current area the mouse is over.protected intoffsetIndent for textprotected intoldMouseAreaThe last area the mouse was over.protected OptionsoptionsThe options.protected FontsmallFontA small font.protected GameStatestateThe game state.protected FontverysmallFontA small font.protected doublexfactorThe x scaling factor (based on a resolution of 1024x768).protected doubleyfactorThe 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 voiddraw(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 voiddrawShaded(Graphics g, java.lang.String s, int x, int y, int c, int shadeColor, Font f)Draws a shaded string.protected voiddrawShaded(Graphics g, java.lang.String s, int x, int y, int c, Font f)Draws a shaded string.RectanglegetArea()Gets the size for this Painter.intgetBaseHeight()Gets the base height of this painter.intgetBaseWidth()Gets the base width of this painter.StarpointEditorgetEditor()Gets the editor.intgetHeight()Gets this fields height.intgetIndent()The x indentprotected intgetRepaintFactor()Gets a factor for repaint cycles depending on the current frame rate (1 for 20 FPS).intgetWidth()Gets this fields width.doublegetXFactor()Gets the x scaling factordoublegetYFactor()Gets the y scaling factorbooleanisActive()Checks, if this painter is currently active and wants to handle events.booleanisInputController()Returns true, if the painter implements InputController.voidonStartGame(GameState state)Called when a new game is started.abstract voidpaint(Graphics g, GameState state)Paints on the screen.voidsetArea(Rectangle area)Sets the size for this Painter.voidsetController(StarpointController controller)Sets the reference to the Controller.protected voidsetFontSize()Sets the standard fonts.voidsetLevel(Level currentLevel)Sets the level.voidsetOptions(Options opt)Sets the options.voidsetState(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:
getBaseWidthin interfacePainter- Returns:
- 1920.
-
getBaseHeight
public int getBaseHeight()
Gets the base height of this painter.- Specified by:
getBaseHeightin 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:
setOptionsin 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:
getXFactorin interfacePainter- Returns:
- the xfactor
-
getYFactor
public double getYFactor()
Gets the y scaling factor- Specified by:
getYFactorin 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:
onStartGamein interfacePainter- Parameters:
state- The game state.
-
getEditor
public StarpointEditor getEditor()
Gets the editor.- Returns:
- The editor.
-
-