de.lessvoid.nifty.elements.render
Class TextRenderer

java.lang.Object
  extended by de.lessvoid.nifty.elements.render.TextRenderer
All Implemented Interfaces:
ElementRenderer

public class TextRenderer
extends Object
implements ElementRenderer

The TextRenderer implementation.

Author:
void

Nested Class Summary
 class TextRenderer.RenderFontNull
          RenderFont Null Object.
 
Constructor Summary
TextRenderer(Nifty nifty)
          default constructor.
TextRenderer(Nifty nifty, RenderFont newFont, String newText)
          create new renderer with the given font and text.
 
Method Summary
 Color getColor()
           
 RenderFont getFont()
          Get RenderFont.
 String getOriginalText()
          get original text.
protected static int getStartXWithHorizontalAlign(int textWidth, int elementWidth, HorizontalAlign horizontalAlign)
          Get start x for text rendering given the textWidth and the elementWidth.
protected static int getStartYWithVerticalAlign(int textHeight, int elementHeight, VerticalAlign verticalAlign)
          Get start Y for text rendering given the textHeight and the elementHeight.
 HorizontalAlign getTextHAlign()
           
 int getTextHeight()
          Helper method to get height of text.
 VerticalAlign getTextVAlign()
           
 int getTextWidth()
          Helper method to get width of text.
 String getWrappedText()
           
 boolean isLineWrapping()
           
 void render(Element w, NiftyRenderEngine r)
          render the stuff.
 void setColor(Color newColor)
          set color.
 void setFont(RenderFont fontParam)
          set font.
 void setLineWrapping(boolean lineWrapping)
           
 void setSelection(int selectionStartParam, int selectionEndParam)
          set a new selection.
 void setText(String newText)
          set Text.
 void setTextHAlign(HorizontalAlign newTextHAlign)
          set text horizontal alignment.
 void setTextLineHeight(SizeValue textLineHeight)
           
 void setTextMinHeight(SizeValue textMinHeight)
           
 void setTextSelectionColor(Color textSelectionColorParam)
          set new text selection color.
 void setTextVAlign(VerticalAlign newTextVAlign)
          set text vertical alignment.
 void setWidthConstraint(Element element, SizeValue elementConstraintWidth, int parentWidth, NiftyRenderEngine renderEngine)
           
 void setXoffsetHack(int newXoffsetHack)
          set thing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextRenderer

public TextRenderer(Nifty nifty)
default constructor.


TextRenderer

public TextRenderer(Nifty nifty,
                    RenderFont newFont,
                    String newText)
create new renderer with the given font and text.

Parameters:
newFont - the font to use
newText - the text to use
Method Detail

setText

public void setText(String newText)
set Text.

Parameters:
newText - text

render

public void render(Element w,
                   NiftyRenderEngine r)
render the stuff.

Specified by:
render in interface ElementRenderer
Parameters:
w - the widget we're connected to
r - the renderDevice we should use

getStartYWithVerticalAlign

protected static int getStartYWithVerticalAlign(int textHeight,
                                                int elementHeight,
                                                VerticalAlign verticalAlign)
Get start Y for text rendering given the textHeight and the elementHeight.

Parameters:
textHeight - text height
elementHeight - element height
verticalAlign - verticalAlign
Returns:
start y for text rendering

getStartXWithHorizontalAlign

protected static int getStartXWithHorizontalAlign(int textWidth,
                                                  int elementWidth,
                                                  HorizontalAlign horizontalAlign)
Get start x for text rendering given the textWidth and the elementWidth.

Parameters:
textWidth - text width
elementWidth - element width
horizontalAlign - horizontalAlign
Returns:
start x for text rendering

getTextWidth

public int getTextWidth()
Helper method to get width of text.

Returns:
the width in pixel of the current set text.

getTextHeight

public int getTextHeight()
Helper method to get height of text.

Returns:
the height in pixel of the current set text.

setXoffsetHack

public void setXoffsetHack(int newXoffsetHack)
set thing.

Parameters:
newXoffsetHack - xoffset

getFont

public RenderFont getFont()
Get RenderFont.

Returns:
render font

setSelection

public void setSelection(int selectionStartParam,
                         int selectionEndParam)
set a new selection.

Parameters:
selectionStartParam - start
selectionEndParam - end

setFont

public void setFont(RenderFont fontParam)
set font.

Parameters:
fontParam - font

setTextSelectionColor

public void setTextSelectionColor(Color textSelectionColorParam)
set new text selection color.

Parameters:
textSelectionColorParam - text selection color

setTextVAlign

public void setTextVAlign(VerticalAlign newTextVAlign)
set text vertical alignment.

Parameters:
newTextVAlign - text vertical alignment

setTextHAlign

public void setTextHAlign(HorizontalAlign newTextHAlign)
set text horizontal alignment.

Parameters:
newTextHAlign - text horizontal alignment

setColor

public void setColor(Color newColor)
set color.

Parameters:
newColor - color

getOriginalText

public String getOriginalText()
get original text.

Returns:
original text

getWrappedText

public String getWrappedText()

setTextLineHeight

public void setTextLineHeight(SizeValue textLineHeight)

setTextMinHeight

public void setTextMinHeight(SizeValue textMinHeight)

setWidthConstraint

public void setWidthConstraint(Element element,
                               SizeValue elementConstraintWidth,
                               int parentWidth,
                               NiftyRenderEngine renderEngine)

setLineWrapping

public void setLineWrapping(boolean lineWrapping)

isLineWrapping

public boolean isLineWrapping()

getTextVAlign

public VerticalAlign getTextVAlign()

getTextHAlign

public HorizontalAlign getTextHAlign()

getColor

public Color getColor()


Copyright © 2011. All Rights Reserved.