de.lessvoid.nifty.elements
Class Element

java.lang.Object
  extended by de.lessvoid.nifty.elements.Element
All Implemented Interfaces:
NiftyEvent<Void>

public class Element
extends Object
implements NiftyEvent<Void>

The Element.

Author:
void

Nested Class Summary
 class Element.LocalEndNotify
          LocalEndNotify helper class.
 
Constructor Summary
Element(Nifty newNifty, ElementType newElementType, String newId, Element newParent, FocusHandler newFocusHandler, boolean newVisibleToMouseEvents, TimeProvider newTimeProvider, ElementRenderer... newElementRenderer)
          construct new instance of Element.
Element(Nifty newNifty, ElementType newElementType, String newId, Element newParent, LayoutPart newLayoutPart, FocusHandler newFocusHandler, boolean newVisibleToMouseEvents, TimeProvider newTimeProvider, ElementRenderer... newElementRenderer)
          construct new instance of Element using the given layoutPart instance.
 
Method Summary
 void add(Element widget)
          add a child element.
 void addInputHandler(KeyInputHandler handler)
          add additional input handler to this element or childs of the elements.
 void addPreInputHandler(KeyInputHandler handler)
          add additional input handler to this element or childs of the elements.
 void attachInputControl(NiftyInputControl newInputControl)
          attach an input control to this element.
 void bindControls(Screen target)
           
 void buildMouseOverElements(NiftyMouseInputEvent mouseEvent, long eventTime, MouseOverHandler mouseOverHandler)
          This should check if the mouse event is inside the current element and if it is forward the event to it's child.
 void disable()
          disable this element.
 void disableFocus()
           
 void enable()
          enable this element.
 void enableInternal()
           
<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)
           
 NiftyInputControl getAttachedInputControl()
           
 SizeValue getConstraintHeight()
          get current height constraint.
 HorizontalAlign getConstraintHorizontalAlign()
          get current horizontal align.
 VerticalAlign getConstraintVerticalAlign()
          get current vertical align.
 SizeValue getConstraintWidth()
          get current width constraint.
 SizeValue getConstraintX()
           
 SizeValue getConstraintY()
           
<T extends Controller>
T
getControl(Class<T> requestedControlClass)
           
 EffectManager getEffectManager()
          get the effect manager.
<T extends EffectImpl>
List<Effect>
getEffects(EffectEventId effectEventId, Class<T> requestedClass)
           
 ElementInteraction getElementInteraction()
           
 ElementRenderer[] getElementRenderer()
          get element renderer.
 List<Element> getElements()
          get all child elements of this element.
 String getElementStateString(String offset)
          get element state as string.
 String getElementStateString(String offset, String regex)
           
 ElementType getElementType()
          get element type.
 Falloff getFalloff()
           
 FocusHandler getFocusHandler()
           
 int getHeight()
          get height.
 String getId()
          get the id of this element.
 LayoutPart getLayoutPart()
          Get LayoutPart.
 Nifty getNifty()
           
<T extends NiftyControl>
T
getNiftyControl(Class<T> requestedControlClass)
           
 Element getParent()
          get parent.
<T extends ElementRenderer>
T
getRenderer(Class<T> requestedRendererClass)
           
 String getStyle()
           
 int getWidth()
          get width.
 int getX()
          get x.
 int getY()
          get y.
 void hide()
          hide this element.
 void hide(EndNotify perform)
           
 void hideWithoutEffect()
           
 void initControls()
           
 void initializeFromAttributes(Attributes attributes, NiftyRenderEngine renderEngine)
          This is used when the element is being created from an ElementType in the loading process.
 void initializeFromPostAttributes(Attributes attributes)
           
 void internalHide()
           
 boolean isClipChildren()
          Is clip children enabled?
 boolean isEffectActive(EffectEventId effectEventId)
          check if a certain effect is still active.
 boolean isEnabled()
          is this element enabled?
 boolean isFocusable()
          is focusable?
 boolean isMouseInsideElement(int mouseX, int mouseY)
           
 boolean isStarted()
           
 boolean isVisible()
          check if this element is visible.
 boolean isVisibleToMouseEvents()
          Is this element visible to mouse events.
 boolean keyEvent(KeyboardInputEvent inputEvent)
          keyboard event.
 void layoutElements()
           
 void markForMove(Element destination)
           
 void markForMove(Element destination, EndNotify endNotify)
           
 void markForRemoval()
           
 void markForRemoval(EndNotify endNotify)
           
 boolean mouseEvent(NiftyMouseInputEvent mouseEvent, long eventTime)
          MouseEvent.
 void mouseEventHoverPreprocess(NiftyMouseInputEvent mouseEvent, long eventTime)
           
 boolean mouseOverEvent(NiftyMouseInputEvent mouseEvent, long eventTime)
          Handle the MouseOverEvent.
 void onClick()
           
 void onEndScreen(Screen screen)
           
 void onStartScreen()
          On start screen event.
 void reactivate()
           
 void registerEffect(EffectEventId theId, Effect e)
          register an effect for this element.
 void removeFromFocusHandler()
          remove this and all children from the focushandler.
 void render(NiftyRenderEngine r)
          render this element.
 void resetAllEffects()
           
 void resetEffects()
          reset all effects.
 void resetForHide()
           
 void resetLayout()
           
 void resetMouseDown()
           
 void resetSingleEffect(EffectEventId effectEventId)
           
 void resetSingleEffect(EffectEventId effectEventId, String customKey)
           
 void setAlternateKey(String alternateKey)
          set alternate key.
 void setClipChildren(boolean clipChildrenParam)
          Set clip children.
 void setConstraintHeight(SizeValue newHeight)
          set new height constraint.
 void setConstraintHorizontalAlign(HorizontalAlign newHorizontalAlign)
          set new horizontal align.
 void setConstraintVerticalAlign(VerticalAlign newVerticalAlign)
          set new vertical align.
 void setConstraintWidth(SizeValue newWidth)
          set new width constraint.
 void setConstraintX(SizeValue newX)
          set new x position constraint.
 void setConstraintY(SizeValue newY)
          set new y position constraint.
 void setEffectManager(EffectManager effectManagerParam)
          Set a New EffectManager.
 void setFocus()
          Set the focus to this element.
 void setFocusable(boolean newFocusable)
          set focusable flag.
 void setHeight(int height)
          Sets the height of this element
 void setHotSpotFalloff(Falloff newFalloff)
          set a new Falloff.
 void setId(String newId)
          set id.
 void setLayoutManager(LayoutManager newLayout)
          Set a new LayoutManager.
 void setOnClickAlternateKey(String newAlternateKey)
          set a new alternate key.
 void setOnMouseOverMethod(NiftyMethodInvoker onMouseOverMethod)
          Set onMouseOverMethod.
 void setPaddingBottom(SizeValue paddingValue)
           
 void setPaddingLeft(SizeValue paddingValue)
           
 void setPaddingRight(SizeValue paddingValue)
           
 void setPaddingTop(SizeValue paddingValue)
           
 void setParent(Element element)
           
 void setStyle(String newStyle)
          set a new style.
 void setVisible(boolean visibleParam)
           
 void setVisibleToMouseEvents(boolean newVisibleToMouseEvents)
          Set visible to mouse flag.
 void setWidth(int width)
          Sets the width of this element
 void show()
          show this element.
 void showWithoutEffects()
           
 void startEffect(EffectEventId effectEventId)
           
 void startEffect(EffectEventId effectEventId, EndNotify effectEndNotiy)
           
 void startEffect(EffectEventId effectEventId, EndNotify effectEndNotiy, String customKey)
           
 void startEffectWithoutChildren(EffectEventId effectEventId)
           
 void startEffectWithoutChildren(EffectEventId effectEventId, EndNotify effectEndNotiy)
           
 void startEffectWithoutChildren(EffectEventId effectEventId, EndNotify effectEndNotiy, String customKey)
           
 void stopEffect(EffectEventId effectEventId)
          stop the given effect.
 void stopEffectWithoutChildren(EffectEventId effectEventId)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Element

public Element(Nifty newNifty,
               ElementType newElementType,
               String newId,
               Element newParent,
               FocusHandler newFocusHandler,
               boolean newVisibleToMouseEvents,
               TimeProvider newTimeProvider,
               ElementRenderer... newElementRenderer)
construct new instance of Element.

Parameters:
newNifty - Nifty
newElementType - elementType
newId - the id
newParent - new parent
newFocusHandler - the new focus handler
newVisibleToMouseEvents - visible to mouse
newTimeProvider - TimeProvider
newElementRenderer - the element renderer

Element

public Element(Nifty newNifty,
               ElementType newElementType,
               String newId,
               Element newParent,
               LayoutPart newLayoutPart,
               FocusHandler newFocusHandler,
               boolean newVisibleToMouseEvents,
               TimeProvider newTimeProvider,
               ElementRenderer... newElementRenderer)
construct new instance of Element using the given layoutPart instance.

Parameters:
newNifty - Nifty
newElementType - element type
newId - the id
newParent - new parent
newLayoutPart - the layout part
newFocusHandler - the new focus handler
newVisibleToMouseEvents - visible to mouse
newTimeProvider - TimeProvider
newElementRenderer - the element renderer
Method Detail

initializeFromAttributes

public void initializeFromAttributes(Attributes attributes,
                                     NiftyRenderEngine renderEngine)
This is used when the element is being created from an ElementType in the loading process.


initializeFromPostAttributes

public void initializeFromPostAttributes(Attributes attributes)

getId

public String getId()
get the id of this element.

Returns:
the id

getParent

public Element getParent()
get parent.

Returns:
parent

setParent

public void setParent(Element element)

getElementStateString

public String getElementStateString(String offset)
get element state as string.

Parameters:
offset - offset string
regex -
Returns:
the element state as string.

getElementStateString

public String getElementStateString(String offset,
                                    String regex)

getX

public int getX()
get x.

Returns:
x position of this element.

getY

public int getY()
get y.

Returns:
the y position of this element.

getHeight

public int getHeight()
get height.

Returns:
the height of this element.

getWidth

public int getWidth()
get width.

Returns:
the width of this element.

setHeight

public void setHeight(int height)
Sets the height of this element

Parameters:
height - the new height in pixels

setWidth

public void setWidth(int width)
Sets the width of this element

Parameters:
width - the new width in pixels

getElements

public List<Element> getElements()
get all child elements of this element.

Returns:
the list of child elements

add

public void add(Element widget)
add a child element.

Parameters:
widget - the child to add

render

public void render(NiftyRenderEngine r)
render this element.

Parameters:
r - the RenderDevice to use

setLayoutManager

public void setLayoutManager(LayoutManager newLayout)
Set a new LayoutManager.

Parameters:
newLayout - the new LayoutManager to use.

resetLayout

public void resetLayout()

layoutElements

public void layoutElements()

resetEffects

public void resetEffects()
reset all effects.


resetAllEffects

public void resetAllEffects()

resetForHide

public void resetForHide()

resetSingleEffect

public void resetSingleEffect(EffectEventId effectEventId)

resetSingleEffect

public void resetSingleEffect(EffectEventId effectEventId,
                              String customKey)

resetMouseDown

public void resetMouseDown()

setConstraintX

public void setConstraintX(SizeValue newX)
set new x position constraint.

Parameters:
newX - new x constraint.

setConstraintY

public void setConstraintY(SizeValue newY)
set new y position constraint.

Parameters:
newY - new y constaint.

setConstraintWidth

public void setConstraintWidth(SizeValue newWidth)
set new width constraint.

Parameters:
newWidth - new width constraint.

setConstraintHeight

public void setConstraintHeight(SizeValue newHeight)
set new height constraint.

Parameters:
newHeight - new height constraint.

getConstraintX

public SizeValue getConstraintX()

getConstraintY

public SizeValue getConstraintY()

getConstraintWidth

public SizeValue getConstraintWidth()
get current width constraint.

Returns:
current width constraint

getConstraintHeight

public SizeValue getConstraintHeight()
get current height constraint.

Returns:
current height constraint.

setConstraintHorizontalAlign

public void setConstraintHorizontalAlign(HorizontalAlign newHorizontalAlign)
set new horizontal align.

Parameters:
newHorizontalAlign - new horizontal align.

setConstraintVerticalAlign

public void setConstraintVerticalAlign(VerticalAlign newVerticalAlign)
set new vertical align.

Parameters:
newVerticalAlign - new vertical align.

getConstraintHorizontalAlign

public HorizontalAlign getConstraintHorizontalAlign()
get current horizontal align.

Returns:
current horizontal align.

getConstraintVerticalAlign

public VerticalAlign getConstraintVerticalAlign()
get current vertical align.

Returns:
current vertical align.

registerEffect

public void registerEffect(EffectEventId theId,
                           Effect e)
register an effect for this element.

Parameters:
theId - the effect id
e - the effect

startEffect

public void startEffect(EffectEventId effectEventId)

startEffect

public void startEffect(EffectEventId effectEventId,
                        EndNotify effectEndNotiy)

startEffect

public void startEffect(EffectEventId effectEventId,
                        EndNotify effectEndNotiy,
                        String customKey)

startEffectWithoutChildren

public void startEffectWithoutChildren(EffectEventId effectEventId)

startEffectWithoutChildren

public void startEffectWithoutChildren(EffectEventId effectEventId,
                                       EndNotify effectEndNotiy)

startEffectWithoutChildren

public void startEffectWithoutChildren(EffectEventId effectEventId,
                                       EndNotify effectEndNotiy,
                                       String customKey)

stopEffect

public void stopEffect(EffectEventId effectEventId)
stop the given effect.

Parameters:
effectEventId - effect event id to stop

stopEffectWithoutChildren

public void stopEffectWithoutChildren(EffectEventId effectEventId)

isEffectActive

public boolean isEffectActive(EffectEventId effectEventId)
check if a certain effect is still active. travels down to child elements.

Parameters:
effectEventId - the effect type id to check
Returns:
true, if the effect has ended and false otherwise

enable

public void enable()
enable this element.


enableInternal

public void enableInternal()

disable

public void disable()
disable this element.


disableFocus

public void disableFocus()

isEnabled

public boolean isEnabled()
is this element enabled?

Returns:
true, if enabled and false otherwise.

show

public void show()
show this element.


setVisible

public void setVisible(boolean visibleParam)

hide

public void hide()
hide this element.


hide

public void hide(EndNotify perform)

showWithoutEffects

public void showWithoutEffects()

hideWithoutEffect

public void hideWithoutEffect()

internalHide

public void internalHide()

isVisible

public boolean isVisible()
check if this element is visible.

Returns:
true, if this element is visible and false otherwise.

setHotSpotFalloff

public void setHotSpotFalloff(Falloff newFalloff)
set a new Falloff.

Parameters:
newFalloff - new Falloff

getFalloff

public Falloff getFalloff()

buildMouseOverElements

public void buildMouseOverElements(NiftyMouseInputEvent mouseEvent,
                                   long eventTime,
                                   MouseOverHandler mouseOverHandler)
This should check if the mouse event is inside the current element and if it is forward the event to it's child. The purpose of this is to build a list of all elements from front to back that are available for a certain mouse position.


mouseEventHoverPreprocess

public void mouseEventHoverPreprocess(NiftyMouseInputEvent mouseEvent,
                                      long eventTime)

mouseEvent

public boolean mouseEvent(NiftyMouseInputEvent mouseEvent,
                          long eventTime)
MouseEvent.

Parameters:
mouseEvent - mouse event
eventTime - event time

mouseOverEvent

public boolean mouseOverEvent(NiftyMouseInputEvent mouseEvent,
                              long eventTime)
Handle the MouseOverEvent. Must not call child elements. This is handled by caller.

Parameters:
mouseEvent - mouse event
eventTime - event time
Returns:
true the mouse event has been eated and false when the mouse event can be processed further down

isMouseInsideElement

public boolean isMouseInsideElement(int mouseX,
                                    int mouseY)

onClick

public void onClick()

findElementByName

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

Parameters:
name - the name of the element (id)
Returns:
the element or null

setOnClickAlternateKey

public void setOnClickAlternateKey(String newAlternateKey)
set a new alternate key.

Parameters:
newAlternateKey - new alternate key to use

setAlternateKey

public void setAlternateKey(String alternateKey)
set alternate key.

Parameters:
alternateKey - new alternate key

getEffectManager

public EffectManager getEffectManager()
get the effect manager.

Returns:
the EffectManager

setEffectManager

public void setEffectManager(EffectManager effectManagerParam)
Set a New EffectManager.

Parameters:
effectManagerParam - new Effectmanager

onStartScreen

public void onStartScreen()
On start screen event.


getRenderer

public <T extends ElementRenderer> T getRenderer(Class<T> requestedRendererClass)
Type Parameters:
T - the ElementRenderer type
Parameters:
requestedRendererClass - the special ElementRenderer type to check for
Returns:
the ElementRenderer that matches the class

setVisibleToMouseEvents

public void setVisibleToMouseEvents(boolean newVisibleToMouseEvents)
Set visible to mouse flag.

Parameters:
newVisibleToMouseEvents - true or false

keyEvent

public boolean keyEvent(KeyboardInputEvent inputEvent)
keyboard event.

Parameters:
inputEvent - keyboard event

setClipChildren

public void setClipChildren(boolean clipChildrenParam)
Set clip children.

Parameters:
clipChildrenParam - clip children flag

isClipChildren

public boolean isClipChildren()
Is clip children enabled?

Returns:
clip children

setFocus

public void setFocus()
Set the focus to this element.


attachInputControl

public void attachInputControl(NiftyInputControl newInputControl)
attach an input control to this element.

Parameters:
newInputControl - input control

setId

public void setId(String newId)
set id.

Parameters:
newId - new id

getElementType

public ElementType getElementType()
get element type.

Returns:
element type

getElementRenderer

public ElementRenderer[] getElementRenderer()
get element renderer.

Returns:
element renderer array

setFocusable

public void setFocusable(boolean newFocusable)
set focusable flag.

Parameters:
newFocusable - focusable flag

getAttachedInputControl

public NiftyInputControl getAttachedInputControl()
Returns:
the attachedInputControl

bindControls

public void bindControls(Screen target)

initControls

public void initControls()

removeFromFocusHandler

public void removeFromFocusHandler()
remove this and all children from the focushandler.


getFocusHandler

public FocusHandler getFocusHandler()

setStyle

public void setStyle(String newStyle)
set a new style.

Parameters:
newStyle - new style to set

getStyle

public String getStyle()

addInputHandler

public void addInputHandler(KeyInputHandler handler)
add additional input handler to this element or childs of the elements.

Parameters:
handler - additiona handler

addPreInputHandler

public void addPreInputHandler(KeyInputHandler handler)
add additional input handler to this element or childs of the elements.

Parameters:
handler - additiona handler

findControl

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

findNiftyControl

public <T extends NiftyControl> T findNiftyControl(String elementName,
                                                   Class<T> requestedControlClass)

getControl

public <T extends Controller> T getControl(Class<T> requestedControlClass)

getNiftyControl

public <T extends NiftyControl> T getNiftyControl(Class<T> requestedControlClass)

isFocusable

public boolean isFocusable()
is focusable?

Returns:
focusable

setOnMouseOverMethod

public void setOnMouseOverMethod(NiftyMethodInvoker onMouseOverMethod)
Set onMouseOverMethod.

Parameters:
onMouseOverMethod - new on mouse over method

getLayoutPart

public LayoutPart getLayoutPart()
Get LayoutPart.

Returns:
LayoutPart

isVisibleToMouseEvents

public boolean isVisibleToMouseEvents()
Is this element visible to mouse events.

Returns:
true visible and false not visible

setPaddingLeft

public void setPaddingLeft(SizeValue paddingValue)

setPaddingRight

public void setPaddingRight(SizeValue paddingValue)

setPaddingTop

public void setPaddingTop(SizeValue paddingValue)

setPaddingBottom

public void setPaddingBottom(SizeValue paddingValue)

toString

public String toString()
Overrides:
toString in class Object

isStarted

public boolean isStarted()

markForRemoval

public void markForRemoval()

markForRemoval

public void markForRemoval(EndNotify endNotify)

markForMove

public void markForMove(Element destination)

markForMove

public void markForMove(Element destination,
                        EndNotify endNotify)

reactivate

public void reactivate()

getNifty

public Nifty getNifty()

getEffects

public <T extends EffectImpl> List<Effect> getEffects(EffectEventId effectEventId,
                                                      Class<T> requestedClass)

onEndScreen

public void onEndScreen(Screen screen)

getElementInteraction

public ElementInteraction getElementInteraction()


Copyright © 2011. All Rights Reserved.