Package com.starpoints.painter.editor
Class PainterMenuHorizontal
- java.lang.Object
-
- com.starpoints.painter.PainterBase
-
- com.starpoints.painter.PainterMenu
-
- com.starpoints.painter.editor.PainterMenuHorizontal
-
- All Implemented Interfaces:
InputController
,LevelChangeListener
,Painter
- Direct Known Subclasses:
PainterFlashAnimationItems
,PainterFlashAnimationPlanets
,PainterLevelColors
,PainterLevelEnemies
,PainterLevelFogs
,PainterLevelItems
,PainterShopItems
public abstract class PainterMenuHorizontal extends PainterMenu implements LevelChangeListener
Abstract Painter superclass for horizontal menus in editor.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
focussedIndex
Menu entry index with mouse focusprotected int
selectionIndex
Selected Menu entry index.-
Fields inherited from class com.starpoints.painter.PainterMenu
active, button, button_clicked, buttonCounter, buttonLeft, buttonRight, entries, finished, firstTimeOpt, hideBackground, image, listeners, numberEntries, numbers, paintCount, showButtons
-
Fields inherited from class com.starpoints.painter.PainterBase
area, areas, bigFont, controller, gameInfo, medFont, mouseArea, offset, oldMouseArea, options, smallFont, state, verysmallFont, xfactor, yfactor
-
-
Constructor Summary
Constructors Constructor Description PainterMenuHorizontal()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
applyLevelProperties()
protected void
drawAmount(Graphics g, MenuEntry me, int count)
Draws an indication for the number of appearances for a menu entry.protected void
drawImageFrame(Graphics g, MenuEntry me, int color)
Draw a frame around an menu imageprotected boolean
drawProbability(SelectionMenuEntry me)
Checks, if the probability string should be drawn for the menu item.int
getBaseHeight()
Gets the base height of this painter.int
getBaseWidth()
Gets the base width of this painter.protected java.lang.String
getDisplayText(MenuEntry me)
Returns the display text for the MenuEntry.protected java.lang.String
getImage(MenuEntry me)
protected double
getImageScaleFactor()
Gets a scaling factor for the menu image.protected int
getMouseAreaYSplit()
Gets the vertical coordinate, beyond which mouse coordinates are in second column.protected int
getMouseSelectionUpperYCoordinate()
Gets the vertical coordinate, below which mouse coordinates must be to set the MenuEntry selected.protected java.lang.String
getProbabilityString(SelectionMenuEntry me)
Gets the probability string for the menu item.protected int
getSelectionIndex()
protected int
getTextXPosition(MenuEntry me)
Returns the X position for the menu text to draw.protected int
getXCenter(MenuEntry me)
int
getYCenter(MenuEntry me)
int
getYPercentageCoordinate(MenuEntry me)
Gets the draw y position for menu entries percentage.int
getYTextCoordinate(MenuEntry me)
Gets the draw y position for menu entries text.boolean
keyPressed(KeyEvent e)
Processes keys if focussed editor painter.void
levelChanged(LevelInfo li)
Calls the applyLevelProperties-method.boolean
mouseClicked(MouseEvent e)
Handles mouse clicksboolean
mouseMoved(MouseEvent e)
Handles mouse moves.protected void
onSelectedIndexChange()
void
onStartGame(GameState state)
Called when a new game is started.void
paint(Graphics g, GameState state)
Paints the menu.protected void
paintMenuEntry(Graphics g, MenuEntry me, java.lang.String i)
Paints a menu entry.protected void
paintSelectionIcon(Graphics g, MenuEntry me, boolean selected)
Paints a selection icon to the menu entry.protected void
paintSelectionIcon(Graphics g, MenuEntry me, boolean selected, double factor)
Paints a selection icon to the menu entry with the given scaling factor.protected void
setMouseArea(MouseEvent e)
Sets the current mouse over area.protected boolean
showSelected(MenuEntry me)
-
Methods inherited from class com.starpoints.painter.PainterMenu
addMenuEntry, addMenuListener, draw, drawBackgroundImage, findIntegerIndex, findIntegerIndex, fireEmptyClickEvent, fireMenuEntryMouseOverEvent, fireMenuEntrySelectedEvent, fireMenuEntrySelectionChangedEvent, focusFirst, getButtonScalingFactor, getButtonXPos, getButtonYPos, getFocussedEntry, getFontSize, getLeftMouseBorder, getRightMouseBorder, handleEvent, isActive, isDownKey, isEnterKey, isFinished, isLeftKey, isRightKey, isShowingButtons, isUpKey, paintMenuEntry, removeMenuEntry, removeMenuListener, setActive, setFinished, setShowButtons
-
Methods inherited from class com.starpoints.painter.PainterBase
draw, drawShaded, drawShaded, getArea, getEditor, getHeight, getIndent, getRepaintFactor, getWidth, getXFactor, getYFactor, isInputController, setArea, setController, setFontSize, setLevel, setOptions, setState
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.starpoints.event.InputController
getArea, getXFactor, getYFactor, setController
-
Methods inherited from interface com.starpoints.painter.editor.LevelChangeListener
levelSetChanged
-
-
-
-
Method Detail
-
paint
public void paint(Graphics g, GameState state)
Paints the menu.- Specified by:
paint
in interfacePainter
- Overrides:
paint
in classPainterMenu
- Parameters:
g
- The graphics.state
- The game state.
-
getBaseWidth
public int getBaseWidth()
Gets the base width of this painter.- Specified by:
getBaseWidth
in interfacePainter
- Overrides:
getBaseWidth
in classPainterBase
- Returns:
- 1070.
-
getBaseHeight
public int getBaseHeight()
Gets the base height of this painter.- Specified by:
getBaseHeight
in interfacePainter
- Overrides:
getBaseHeight
in classPainterBase
- Returns:
- 770.
-
getImage
protected java.lang.String getImage(MenuEntry me)
-
mouseClicked
public boolean mouseClicked(MouseEvent e)
Handles mouse clicks- Specified by:
mouseClicked
in interfaceInputController
- Overrides:
mouseClicked
in classPainterMenu
- Parameters:
e
-- Returns:
- true, if the event is handled by this InputController.
-
getMouseSelectionUpperYCoordinate
protected int getMouseSelectionUpperYCoordinate()
Gets the vertical coordinate, below which mouse coordinates must be to set the MenuEntry selected.- Returns:
- 50 as default.
-
mouseMoved
public boolean mouseMoved(MouseEvent e)
Handles mouse moves.- Specified by:
mouseMoved
in interfaceInputController
- Overrides:
mouseMoved
in classPainterMenu
- Parameters:
e
- The event.- Returns:
- true, if the event is handled by this InputController.
-
keyPressed
public boolean keyPressed(KeyEvent e)
Processes keys if focussed editor painter.- Specified by:
keyPressed
in interfaceInputController
- Overrides:
keyPressed
in classPainterMenu
- Parameters:
e
- The event.- Returns:
- true, if the event is handled by this InputController.
-
onSelectedIndexChange
protected void onSelectedIndexChange()
-
onStartGame
public void onStartGame(GameState state)
Description copied from class:PainterBase
Called when a new game is started.- Specified by:
onStartGame
in interfacePainter
- Overrides:
onStartGame
in classPainterBase
- Parameters:
state
- The game state.
-
applyLevelProperties
protected abstract void applyLevelProperties()
-
paintMenuEntry
protected void paintMenuEntry(Graphics g, MenuEntry me, java.lang.String i)
Paints a menu entry.- Parameters:
g
-me
-
-
showSelected
protected boolean showSelected(MenuEntry me)
- Parameters:
me
-- Returns:
-
getSelectionIndex
protected int getSelectionIndex()
- Returns:
-
getYTextCoordinate
public int getYTextCoordinate(MenuEntry me)
Gets the draw y position for menu entries text.- Parameters:
me
- The menu entry.- Returns:
- 6 or 16 for second column.
-
getYPercentageCoordinate
public int getYPercentageCoordinate(MenuEntry me)
Gets the draw y position for menu entries percentage.- Parameters:
me
- The menu entry.- Returns:
- 8 or 18 for second column.
-
getYCenter
public int getYCenter(MenuEntry me)
- Parameters:
me
-- Returns:
-
getXCenter
protected int getXCenter(MenuEntry me)
- Parameters:
me
-- Returns:
-
getDisplayText
protected java.lang.String getDisplayText(MenuEntry me)
Returns the display text for the MenuEntry.- Parameters:
me
- The MenuEntry- Returns:
- me.getDisplayText();
-
getTextXPosition
protected int getTextXPosition(MenuEntry me)
Returns the X position for the menu text to draw.- Parameters:
me
- The MenuEntry- Returns:
- me.getYpos()-2;
-
paintSelectionIcon
protected void paintSelectionIcon(Graphics g, MenuEntry me, boolean selected)
Paints a selection icon to the menu entry.- Parameters:
g
-me
-
-
paintSelectionIcon
protected void paintSelectionIcon(Graphics g, MenuEntry me, boolean selected, double factor)
Paints a selection icon to the menu entry with the given scaling factor.- Parameters:
g
-me
-
-
drawImageFrame
protected void drawImageFrame(Graphics g, MenuEntry me, int color)
Draw a frame around an menu image- Parameters:
g
- The Graphics.me
- The menu entry.color
- The frame color.
-
getImageScaleFactor
protected double getImageScaleFactor()
Gets a scaling factor for the menu image.- Returns:
- Scaling factor.
-
getProbabilityString
protected java.lang.String getProbabilityString(SelectionMenuEntry me)
Gets the probability string for the menu item.- Parameters:
me
- The menu entry.- Returns:
- Probability string.
-
drawProbability
protected boolean drawProbability(SelectionMenuEntry me)
Checks, if the probability string should be drawn for the menu item.- Parameters:
me
- The menu entry.- Returns:
- true, if the probability string should be drawn for the menu item.
-
drawAmount
protected void drawAmount(Graphics g, MenuEntry me, int count)
Draws an indication for the number of appearances for a menu entry.- Parameters:
g
- The graphics.me
- The MenuEntry.count
- The count to draw.
-
setMouseArea
protected void setMouseArea(MouseEvent e)
Sets the current mouse over area.- Overrides:
setMouseArea
in classPainterMenu
- Parameters:
e
- The mouse event.
-
getMouseAreaYSplit
protected int getMouseAreaYSplit()
Gets the vertical coordinate, beyond which mouse coordinates are in second column.- Returns:
- Baseheight / 2 as default
-
levelChanged
public void levelChanged(LevelInfo li)
Calls the applyLevelProperties-method.- Specified by:
levelChanged
in interfaceLevelChangeListener
- Parameters:
li
- The new LevelInfo.
-
-