Class PainterMenu

    • Field Detail

      • numberEntries

        protected java.lang.String[] numberEntries
        Typical number entries.
      • numbers

        protected int[] numbers
        Typical numbers corresponding to the number entries.
      • buttonLeft

        protected static java.lang.String buttonLeft
        Left scroll button.
      • buttonRight

        protected static java.lang.String buttonRight
        Right scroll button.
      • image

        protected java.lang.String image
        Background image.
      • hideBackground

        protected boolean hideBackground
        Flag, if background image should be shown.
      • paintCount

        protected int paintCount
        Paint counter for cursor.
      • finished

        protected boolean finished
        Flag, if finished with entering.
      • firstTimeOpt

        protected boolean firstTimeOpt
        Flag, if finished with entering.
      • listeners

        protected java.util.List<MenuListener> listeners
        List of menu listeners
      • entries

        protected java.util.Map<java.lang.Integer,​MenuEntry> entries
        Map of menu entries.
      • active

        protected boolean active
        Flag, if explicitely made acitve.
      • buttonCounter

        protected int[] buttonCounter
      • button

        protected java.lang.String button
      • button_clicked

        protected java.lang.String button_clicked
      • showButtons

        protected boolean showButtons
    • Constructor Detail

      • PainterMenu

        public PainterMenu()
        Creates a new menu painter.
    • Method Detail

      • paintMenuEntry

        protected void paintMenuEntry​(Graphics g,
                                      MenuEntry me)
        Paints a menu entry.
        Parameters:
        g - The graphics.
        me - The menu entry.
      • draw

        protected void draw​(Graphics g,
                            java.lang.String s,
                            int indent,
                            int yPosition,
                            int c,
                            Font f,
                            int offset)
        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.
      • getButtonScalingFactor

        protected double getButtonScalingFactor​(MenuEntry me)
        Gets the scaling factor for the button image.
        Parameters:
        me - The MenuEntry.
        Returns:
        The scaling factor.
      • getButtonXPos

        protected int getButtonXPos​(MenuEntry me)
        Gets the x center position for the button image.
        Parameters:
        me - The MenuEntry.
        Returns:
        0.62.
      • getButtonYPos

        protected int getButtonYPos​(MenuEntry me)
        Gets the y center position for the button image.
        Parameters:
        me - The MenuEntry.
        Returns:
      • getFontSize

        protected Font getFontSize​(MenuEntry me)
        Gets the font for the menu entries fontsize.
        Parameters:
        me - The menu entry.
        Returns:
        The font.
      • drawBackgroundImage

        protected void drawBackgroundImage​(Graphics g)
        Draws the background image.
        Parameters:
        g - The graphics.
      • keyPressed

        public boolean keyPressed​(KeyEvent e)
        Processes keys in menu.
        Specified by:
        keyPressed in interface InputController
        Parameters:
        e - The event.
        Returns:
        true, if the event is handled by this InputController.
      • isDownKey

        protected boolean isDownKey​(KeyEvent e)
        Checks if the key event is a down key.
        Parameters:
        e - The event.
        Returns:
        true, if code is VK_DOWN or "s" is pressed.
      • isUpKey

        protected boolean isUpKey​(KeyEvent e)
        Checks if the key event is a up key.
        Parameters:
        e - The event.
        Returns:
        true, if code is VK_UP or "w" is pressed.
      • isLeftKey

        protected boolean isLeftKey​(KeyEvent e)
        Checks if the key event is a left key.
        Parameters:
        e - The event.
        Returns:
        true, if code is VK_LEFT or "a" is pressed.
      • isRightKey

        protected boolean isRightKey​(KeyEvent e)
        Checks if the key event is a right key.
        Parameters:
        e - The event.
        Returns:
        true, if code is VK_RIGHT or "d" is pressed.
      • isEnterKey

        protected boolean isEnterKey​(KeyEvent e)
        Checks if the key event is a enter key.
        Parameters:
        e - The event.
        Returns:
        true, if code is VK_ENTER, VK_SPACE or "r" is pressed.
      • mouseClicked

        public boolean mouseClicked​(MouseEvent e)
        Handles mouse clicks
        Specified by:
        mouseClicked in interface InputController
        Parameters:
        e - The event.
        Returns:
        true, if the event is handled by this InputController.
      • mouseMoved

        public boolean mouseMoved​(MouseEvent e)
        Handles mouse moves.
        Specified by:
        mouseMoved in interface InputController
        Parameters:
        e - The event.
        Returns:
        true, if the event is handled by this InputController.
      • setMouseArea

        protected void setMouseArea​(MouseEvent e)
        Sets the current mouse over area.
        Parameters:
        e - The mouse event.
      • getRightMouseBorder

        protected int getRightMouseBorder​(MenuEntry me)
        Gets the maximum mouse position to hit a menu entry.
        Parameters:
        me -
        Returns:
      • getLeftMouseBorder

        protected int getLeftMouseBorder​(MenuEntry me)
        Gets the minimum mouse position to hit a menu entry.
        Parameters:
        me -
        Returns:
      • getFocussedEntry

        protected MenuEntry getFocussedEntry()
        Gets the MenuEntry currently focussed.
        Returns:
        The MenuEntry.
      • handleEvent

        public boolean handleEvent​(int mouseMask)
        Handles mouse clicks
        Parameters:
        mouseMask - The MouseMask.
        Returns:
        true, if a menu entry was klicked.
      • focusFirst

        protected void focusFirst()
        Focusses the first menu entry.
      • setFinished

        public void setFinished​(boolean finished)
        Sets this menu finished.
        Parameters:
        finished - the finished to set
      • addMenuEntry

        public void addMenuEntry​(MenuEntry me)
        Adds a menu entry.
        Parameters:
        me - The entry.
      • removeMenuEntry

        public void removeMenuEntry​(MenuEntry me)
        Removes a menu entry.
        Parameters:
        me - The entry.
      • addMenuListener

        public void addMenuListener​(MenuListener listener)
        Adds a menu listener.
        Parameters:
        listener - The listener.
      • removeMenuListener

        public void removeMenuListener​(MenuListener listener)
        Removes a menu listener.
        Parameters:
        listener - The listener.
      • fireMenuEntrySelectedEvent

        protected void fireMenuEntrySelectedEvent​(MenuEntry me)
        Fires a menu entry selected event.
        Parameters:
        me - The menu entry.
      • fireMenuEntryMouseOverEvent

        protected void fireMenuEntryMouseOverEvent​(MenuEntry me)
        Fires a menu entry mouse over event.
        Parameters:
        me - The menu entry.
      • fireMenuEntrySelectionChangedEvent

        protected void fireMenuEntrySelectionChangedEvent​(SelectionMenuEntry me)
        Fires a menu entry selection change event.
        Parameters:
        me - The menu entry.
      • fireEmptyClickEvent

        protected void fireEmptyClickEvent()
        Fires a empty click event.
      • isFinished

        public boolean isFinished()
        Checks, if this menu has finsihed.
        Returns:
        true, if finished.
      • isActive

        public boolean isActive()
        Checks, if this painter is currently active and wants to handle events.
        Specified by:
        isActive in interface Painter
        Overrides:
        isActive in class PainterBase
        Returns:
        true, if no keyboard is supported.
      • setActive

        public void setActive​(boolean active)
        Sets the keyboard active or inactive.
        Parameters:
        active - true to set active.
      • findIntegerIndex

        protected int findIntegerIndex​(int i,
                                       java.lang.String[] numbers)
        Finds the index of i in numbers. If i is not contained, the index of the next higher number is returned
        Parameters:
        i - The int to search.
        numbers - A sorted array of int strings.
        Returns:
        The index.
      • findIntegerIndex

        protected int findIntegerIndex​(int i,
                                       int[] numbers)
        Finds the index of i in numbers. If i is not contained, the index of the next higher number is returned
        Parameters:
        i - The int to search.
        numbers - A sorted array of int strings.
        Returns:
        The index.
      • isShowingButtons

        public boolean isShowingButtons()
        Returns:
        the showButtons
      • setShowButtons

        public void setShowButtons​(boolean showButtons)
        Parameters:
        showButtons - the showButtons to set