de.lessvoid.nifty.screen
Class Screen

java.lang.Object
  extended by de.lessvoid.nifty.screen.Screen
Direct Known Subclasses:
NullScreen

public class Screen
extends Object

A single screen with elements and input focus.

Author:
void

Nested Class Summary
 class Screen.ElementWithEndNotify
           
 class Screen.InputHandlerWithMapping
          InputMappingWithMapping helper.
 
Field Summary
 int layoutLayersCallCount
           
 
Constructor Summary
Screen(Nifty newNifty, String newId, ScreenController newScreenController, TimeProvider newTimeProvider)
           
 
Method Summary
 void addKeyboardInputHandler(NiftyInputMapping mapping, KeyInputHandler handler)
          add a keyboard input handler.
 void addLayerElement(Element layerElement)
           
 void addPopup(Element popup, Element defaultFocusElement)
           
 void addPreKeyboardInputHandler(NiftyInputMapping mapping, KeyInputHandler handler)
          add a keyboard input handler.
 void closePopup(Element popup, EndNotify closeNotify)
           
 String debugOutput()
           
 String debugOutput(String regexpElement, String regexpAttribute)
           
 String debugOutputFocusElements()
           
 void endScreen(EndNotify callback)
           
<T extends Controller>
T
findControl(String elementName, Class<T> requestedControlClass)
           
 Element findElementByName(String name)
          find an element by name.
<T extends NiftyControl>
T
findNiftyControl(String elementName, Class<T> requestedControlClass)
          Finds the Nifty Control matching the given id and control class on this screen and returns it.
 String getDefaultFocusElementId()
           
 FocusHandler getFocusHandler()
          get the screens focus handler.
 List<Element> getLayerElements()
           
 String getMouseOverInfoString()
          This returns an informational String containing all elements that Nifty is aware of that could handle mouse events with the ones currently hovering the mouse sorted from top to bottom.
 Element getRootElement()
          Get RootElement.
 ScreenController getScreenController()
          get current attached screen controller.
 String getScreenId()
           
 Element getTopMostPopup()
           
 boolean hasDynamicElements()
           
 boolean isActivePopup(Element element)
           
 boolean isActivePopup(String id)
           
 boolean isBound()
           
 boolean isEffectActive(EffectEventId effectEventId)
           
 boolean isMouseOverElement()
          Checks if the mouse currently hovers any element that is able to handle mouse events.
 boolean isNull()
           
 boolean isRunning()
           
 boolean keyEvent(KeyboardInputEvent inputEvent)
          keyboard event.
 void layoutLayers()
           
 boolean mouseEvent(NiftyMouseInputEvent inputEvent)
          Handle Mouse Events for this screen.
 String outputElement(Element w, String offset, String regexpElement, String regexpAttribute)
           
 void processAddAndRemoveLayerElements()
          Do things when the current frame has ended.
 void registerElementId(String id)
           
 void removeKeyboardInputHandler(KeyInputHandler handler)
           
 void removeLayerElement(Element layerElement)
           
 void removeLayerElement(String layerId)
           
 void removePreKeyboardInputHandler(KeyInputHandler handler)
           
 void renderLayers(NiftyRenderEngine renderDevice)
          render all layers.
 void resetLayout()
           
 void resetMouseDown()
           
 void setAlternateKey(String alternateKey)
          set alternate key.
 void setDefaultFocus()
           
 void setDefaultFocusElement(String defaultFocusElementIdParam)
           
 void setRootElement(Element rootElementParam)
          Set RootElement.
 void startScreen()
           
 void startScreen(EndNotify startScreenEndNotify)
           
 void unregisterElementId(String id)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

layoutLayersCallCount

public int layoutLayersCallCount
Constructor Detail

Screen

public Screen(Nifty newNifty,
              String newId,
              ScreenController newScreenController,
              TimeProvider newTimeProvider)
Method Detail

registerElementId

public void registerElementId(String id)

unregisterElementId

public void unregisterElementId(String id)

getScreenId

public String getScreenId()

getLayerElements

public List<Element> getLayerElements()

addLayerElement

public void addLayerElement(Element layerElement)

removeLayerElement

public void removeLayerElement(Element layerElement)

removeLayerElement

public void removeLayerElement(String layerId)

addPopup

public void addPopup(Element popup,
                     Element defaultFocusElement)

closePopup

public void closePopup(Element popup,
                       EndNotify closeNotify)

startScreen

public void startScreen()

startScreen

public void startScreen(EndNotify startScreenEndNotify)

endScreen

public void endScreen(EndNotify callback)

layoutLayers

public void layoutLayers()

setDefaultFocus

public void setDefaultFocus()

renderLayers

public final void renderLayers(NiftyRenderEngine renderDevice)
render all layers.

Parameters:
renderDevice - the renderDevice to use

resetLayout

public void resetLayout()

mouseEvent

public boolean mouseEvent(NiftyMouseInputEvent inputEvent)
Handle Mouse Events for this screen. Forwards the event to the layers.

Parameters:
inputEvent - MouseInputEvent
Returns:
true when processed and false when not

findElementByName

public Element findElementByName(String name)
find an element by name.

Parameters:
name - the id to find
Returns:
the element or null

findControl

public <T extends Controller> T findControl(String elementName,
                                            Class<T> requestedControlClass)

findNiftyControl

public <T extends NiftyControl> T findNiftyControl(String elementName,
                                                   Class<T> requestedControlClass)
Finds the Nifty Control matching the given id and control class on this screen and returns it. If no matching control is found then a Null version of the control will be returned to prevent NullPointerExceptions if you use it directly like: screen.findNiftyControl(...).doStuff(). There is no need to check the return value or catch exceptions. While testing your GUI please take a look at the console log so that you see the error message that is written in case a control can't be found (see also http://en.wikipedia.org/wiki/Null_Object_pattern for details).

Type Parameters:
T - The type of the control class being looked for
Parameters:
elementName - The id of the control
requestedControlClass - The class being looked for
Returns:
Either a NiftyControl or a Null version of a NiftyControl for the matching control class.

setAlternateKey

public void setAlternateKey(String alternateKey)
set alternate key.

Parameters:
alternateKey - alternate key to set

keyEvent

public boolean keyEvent(KeyboardInputEvent inputEvent)
keyboard event.

Parameters:
inputEvent - keyboard event

addKeyboardInputHandler

public void addKeyboardInputHandler(NiftyInputMapping mapping,
                                    KeyInputHandler handler)
add a keyboard input handler.

Parameters:
mapping - mapping
handler - new handler to add

removeKeyboardInputHandler

public void removeKeyboardInputHandler(KeyInputHandler handler)

addPreKeyboardInputHandler

public void addPreKeyboardInputHandler(NiftyInputMapping mapping,
                                       KeyInputHandler handler)
add a keyboard input handler.

Parameters:
mapping - mapping
handler - new handler to add

removePreKeyboardInputHandler

public void removePreKeyboardInputHandler(KeyInputHandler handler)

debugOutput

public String debugOutput()

debugOutputFocusElements

public String debugOutputFocusElements()

debugOutput

public String debugOutput(String regexpElement,
                          String regexpAttribute)

outputElement

public String outputElement(Element w,
                            String offset,
                            String regexpElement,
                            String regexpAttribute)

getScreenController

public ScreenController getScreenController()
get current attached screen controller.

Returns:
ScreenController

getFocusHandler

public FocusHandler getFocusHandler()
get the screens focus handler.

Returns:
focus handler

getRootElement

public Element getRootElement()
Get RootElement.

Returns:
root element

setRootElement

public void setRootElement(Element rootElementParam)
Set RootElement.

Parameters:
rootElementParam - new root element

processAddAndRemoveLayerElements

public void processAddAndRemoveLayerElements()
Do things when the current frame has ended.


hasDynamicElements

public boolean hasDynamicElements()

setDefaultFocusElement

public void setDefaultFocusElement(String defaultFocusElementIdParam)

getDefaultFocusElementId

public String getDefaultFocusElementId()

isRunning

public boolean isRunning()

isNull

public boolean isNull()

isEffectActive

public boolean isEffectActive(EffectEventId effectEventId)

getTopMostPopup

public Element getTopMostPopup()

isActivePopup

public boolean isActivePopup(String id)

isActivePopup

public boolean isActivePopup(Element element)

isMouseOverElement

public boolean isMouseOverElement()
Checks if the mouse currently hovers any element that is able to handle mouse events.

Returns:
true if the mouse hovers an element that is visibleToMouse and false if the mouse would hit the background and not any element at all

getMouseOverInfoString

public String getMouseOverInfoString()
This returns an informational String containing all elements that Nifty is aware of that could handle mouse events with the ones currently hovering the mouse sorted from top to bottom.

Returns:
String for debug output purpose

isBound

public boolean isBound()

resetMouseDown

public void resetMouseDown()


Copyright © 2012. All Rights Reserved.