NASA World Wind

gov.nasa.worldwind.render
Class GeographicTextRenderer

java.lang.Object
  extended by gov.nasa.worldwind.render.GeographicTextRenderer

public class GeographicTextRenderer
extends Object


Nested Class Summary
protected  class GeographicTextRenderer.OrderedText
           
 
Constructor Summary
GeographicTextRenderer()
           
 
Method Summary
protected  Color applyOpacity(Color color, double opacity)
           
protected  void beginRendering(DrawContext dc)
           
protected  double[] computeDistanceScaleAndOpacity(DrawContext dc, GeographicTextRenderer.OrderedText ot)
           
protected  Point2D.Float computeDrawPoint(DrawContext dc, Rectangle2D rect, Vec4 screenPoint)
          Computes the final draw point for the given rectangle lower left corner and target screen point.
protected  Rectangle2D computeExpandedBounds(Rectangle2D bounds, int margin)
           
protected  double computeLookAtDistance(DrawContext dc)
           
protected  Rectangle2D computeScaledBounds(Rectangle2D bounds, double scale)
           
protected  Rectangle2D computeTextBounds(DrawContext dc, GeographicTextRenderer.OrderedText uText, double scale)
           
protected  Vec4 drawText(DrawContext dc, GeographicTextRenderer.OrderedText uText, double scale, double opacity)
           
protected  void endRendering(DrawContext dc)
           
 int getCullTextMargin()
          Get the empty margin that surrounds a text item when considering it's bounding rectangle during text culling - see setCullTextEnabled(boolean).
 double getDistanceMaxScale()
          Get the maximum scale that can be applied to a text item when it gets closer to the eye than the view lookat point - screen center.
 double getDistanceMinOpacity()
          Get the minimum opacity that can be applied to a text item when it gets farther away from the eye than the view lookat point - screen center.
 double getDistanceMinScale()
          Get the minimum scale that can be applied to a text item when it gets farther away from the eye than the view lookat point - screen center.
 String getEffect()
          Get the effect used to decorate the text.
 boolean isCullTextEnabled()
          Determines whether overlapping text are culled.
protected static boolean isTextValid(GeographicText text, boolean checkPosition)
           
 void render(DrawContext dc, GeographicText text, Vec4 textPoint)
           
 void render(DrawContext dc, Iterable<GeographicText> text)
           
 void setCullTextEnabled(boolean cullText)
          Set whether overlapping text should be culled.
 void setCullTextMargin(int margin)
          Set the empty margin that surrounds a text item when considering it's bounding rectangle during text culling - see setCullTextEnabled(boolean).
protected  void setDepthFunc(DrawContext dc, GeographicTextRenderer.OrderedText uText, Vec4 screenPoint)
           
 void setDistanceMaxScale(double scale)
          Set the maximum scale that can be applied to a text item when it gets closer to the eye than the view lookat point - screen center.
 void setDistanceMinOpacity(double opacity)
          Set the minimum opacity that can be applied to a text item when it gets farther away from the eye than the view lookat point - screen center.
 void setDistanceMinScale(double scale)
          Set the minimum scale that can be applied to a text item when it gets farther away from the eye than the view lookat point - screen center.
 void setEffect(String effect)
          Set the effect used to decorate the text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeographicTextRenderer

public GeographicTextRenderer()
Method Detail

applyOpacity

protected Color applyOpacity(Color color,
                             double opacity)

beginRendering

protected void beginRendering(DrawContext dc)

computeDistanceScaleAndOpacity

protected double[] computeDistanceScaleAndOpacity(DrawContext dc,
                                                  GeographicTextRenderer.OrderedText ot)

computeDrawPoint

protected Point2D.Float computeDrawPoint(DrawContext dc,
                                         Rectangle2D rect,
                                         Vec4 screenPoint)
Computes the final draw point for the given rectangle lower left corner and target screen point. If the returned point is null the text will not be drawn.

Parameters:
dc - the current DrawContext
rect - the text rectangle to draw.
screenPoint - the projected screen point the text relates to.
Returns:
the final draw point for the given rectangle lower left corner or null.

computeExpandedBounds

protected Rectangle2D computeExpandedBounds(Rectangle2D bounds,
                                            int margin)

computeLookAtDistance

protected double computeLookAtDistance(DrawContext dc)

computeScaledBounds

protected Rectangle2D computeScaledBounds(Rectangle2D bounds,
                                          double scale)

computeTextBounds

protected Rectangle2D computeTextBounds(DrawContext dc,
                                        GeographicTextRenderer.OrderedText uText,
                                        double scale)
                                 throws Exception
Throws:
Exception

drawText

protected Vec4 drawText(DrawContext dc,
                        GeographicTextRenderer.OrderedText uText,
                        double scale,
                        double opacity)
                 throws Exception
Throws:
Exception

endRendering

protected void endRendering(DrawContext dc)

getCullTextMargin

public int getCullTextMargin()
Get the empty margin that surrounds a text item when considering it's bounding rectangle during text culling - see setCullTextEnabled(boolean). The smaller the margin, the closer text items can get before being considered as overlapping.

Returns:
the empty margin that surrounds a text item - in pixels.

getDistanceMaxScale

public double getDistanceMaxScale()
Get the maximum scale that can be applied to a text item when it gets closer to the eye than the view lookat point - screen center.

Returns:
the maximum scale that can be applied to a text item when it closer to the eye.

getDistanceMinOpacity

public double getDistanceMinOpacity()
Get the minimum opacity that can be applied to a text item when it gets farther away from the eye than the view lookat point - screen center.

Returns:
the minimum opacity that can be applied to a text item when it gets away from the eye.

getDistanceMinScale

public double getDistanceMinScale()
Get the minimum scale that can be applied to a text item when it gets farther away from the eye than the view lookat point - screen center.

Returns:
the minimum scale that can be applied to a text item when it gets away from the eye.

getEffect

public String getEffect()
Get the effect used to decorate the text. Can be one of AVKey.TEXT_EFFECT_SHADOW (default), AVKey.TEXT_EFFECT_OUTLINE or AVKey.TEXT_EFFECT_NONE.

Returns:
the effect used for text rendering.

isCullTextEnabled

public boolean isCullTextEnabled()
Determines whether overlapping text are culled. If true text items are sorted front to back according to their respective priority rather then back to front, and will be drawn only if they do not overlap an already drawn text. If false all text will be drawn back to front whether they overlap or not.

Returns:
true if overlapping text are culled.

isTextValid

protected static boolean isTextValid(GeographicText text,
                                     boolean checkPosition)

render

public void render(DrawContext dc,
                   GeographicText text,
                   Vec4 textPoint)

render

public void render(DrawContext dc,
                   Iterable<GeographicText> text)

setCullTextEnabled

public void setCullTextEnabled(boolean cullText)
Set whether overlapping text should be culled. If true text items will be sorted front to back according to their respective priority rather then back to front, and will be drawn only if they do not overlap an already drawn text. If false all text will be drawn back to front whether they overlap or not.

Parameters:
cullText - true if overlapping text should be culled.

setCullTextMargin

public void setCullTextMargin(int margin)
Set the empty margin that surrounds a text item when considering it's bounding rectangle during text culling - see setCullTextEnabled(boolean). The smaller the margin, the closer text items can get before being considered as overlapping.

Parameters:
margin - the empty margin that surrounds a text item - in pixels.

setDepthFunc

protected void setDepthFunc(DrawContext dc,
                            GeographicTextRenderer.OrderedText uText,
                            Vec4 screenPoint)

setDistanceMaxScale

public void setDistanceMaxScale(double scale)
Set the maximum scale that can be applied to a text item when it gets closer to the eye than the view lookat point - screen center. Use a value greater then one to have the text magnified in the foreground. A value of one will have no effect.

Parameters:
scale - the maximum scale that can be applied to a text item when it closer to the eye.

setDistanceMinOpacity

public void setDistanceMinOpacity(double opacity)
Set the minimum opacity that can be applied to a text item when it gets farther away from the eye than the view lookat point - screen center. Use a value less then one to have the text 'fade' away. A value of one will have no effect.

Parameters:
opacity - the minimum opacity that can be applied to a text item when it gets away from the eye.

setDistanceMinScale

public void setDistanceMinScale(double scale)
Set the minimum scale that can be applied to a text item when it gets farther away from the eye than the view lookat point - screen center. Use a value less then one to have the text 'fade' away. A value of one will have no effect.

Parameters:
scale - the minimum scale that can be applied to a text item when it gets away from the eye.

setEffect

public void setEffect(String effect)
Set the effect used to decorate the text. Can be one of AVKey.TEXT_EFFECT_SHADOW (default), AVKey.TEXT_EFFECT_OUTLINE or AVKey.TEXT_EFFECT_NONE.

Parameters:
effect - the effect to use for text rendering.

NASA World Wind