Package gov.nasa.worldwind.render
Class GeographicTextRenderer
- java.lang.Object
-
- gov.nasa.worldwind.render.GeographicTextRenderer
-
public class GeographicTextRenderer extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
GeographicTextRenderer.OrderedText
-
Constructor Summary
Constructors Constructor Description GeographicTextRenderer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.awt.Color
applyOpacity(java.awt.Color color, double opacity)
protected void
beginRendering(DrawContext dc)
protected double[]
computeDistanceScaleAndOpacity(DrawContext dc, GeographicTextRenderer.OrderedText ot)
protected java.awt.geom.Point2D.Float
computeDrawPoint(DrawContext dc, java.awt.geom.Rectangle2D rect, Vec4 screenPoint)
Computes the final draw point for the given rectangle lower left corner and target screen point.protected java.awt.geom.Rectangle2D
computeExpandedBounds(java.awt.geom.Rectangle2D bounds, int margin)
protected double
computeLookAtDistance(DrawContext dc)
protected java.awt.geom.Rectangle2D
computeScaledBounds(java.awt.geom.Rectangle2D bounds, double scale)
protected java.awt.geom.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 - seesetCullTextEnabled(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.java.lang.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, java.lang.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 - seesetCullTextEnabled(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(java.lang.String effect)
Set the effect used to decorate the text.
-
-
-
Method Detail
-
isCullTextEnabled
public boolean isCullTextEnabled()
Determines whether overlapping text are culled. Iftrue
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. Iffalse
all text will be drawn back to front whether they overlap or not.- Returns:
true
if overlapping text are culled.
-
setCullTextEnabled
public void setCullTextEnabled(boolean cullText)
Set whether overlapping text should be culled. Iftrue
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. Iffalse
all text will be drawn back to front whether they overlap or not.- Parameters:
cullText
-true
if overlapping text should be culled.
-
getCullTextMargin
public int getCullTextMargin()
Get the empty margin that surrounds a text item when considering it's bounding rectangle during text culling - seesetCullTextEnabled(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.
-
setCullTextMargin
public void setCullTextMargin(int margin)
Set the empty margin that surrounds a text item when considering it's bounding rectangle during text culling - seesetCullTextEnabled(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.
-
getEffect
public java.lang.String getEffect()
Get the effect used to decorate the text. Can be one ofAVKey.TEXT_EFFECT_SHADOW
(default),AVKey.TEXT_EFFECT_OUTLINE
orAVKey.TEXT_EFFECT_NONE
.- Returns:
- the effect used for text rendering.
-
setEffect
public void setEffect(java.lang.String effect)
Set the effect used to decorate the text. Can be one ofAVKey.TEXT_EFFECT_SHADOW
(default),AVKey.TEXT_EFFECT_OUTLINE
orAVKey.TEXT_EFFECT_NONE
.- Parameters:
effect
- the effect to use for text rendering.
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.
-
render
public void render(DrawContext dc, java.lang.Iterable<GeographicText> text)
-
render
public void render(DrawContext dc, GeographicText text, Vec4 textPoint)
-
isTextValid
protected static boolean isTextValid(GeographicText text, boolean checkPosition)
-
computeTextBounds
protected java.awt.geom.Rectangle2D computeTextBounds(DrawContext dc, GeographicTextRenderer.OrderedText uText, double scale) throws java.lang.Exception
- Throws:
java.lang.Exception
-
computeScaledBounds
protected java.awt.geom.Rectangle2D computeScaledBounds(java.awt.geom.Rectangle2D bounds, double scale)
-
computeExpandedBounds
protected java.awt.geom.Rectangle2D computeExpandedBounds(java.awt.geom.Rectangle2D bounds, int margin)
-
computeDistanceScaleAndOpacity
protected double[] computeDistanceScaleAndOpacity(DrawContext dc, GeographicTextRenderer.OrderedText ot)
-
computeLookAtDistance
protected double computeLookAtDistance(DrawContext dc)
-
beginRendering
protected void beginRendering(DrawContext dc)
-
endRendering
protected void endRendering(DrawContext dc)
-
drawText
protected Vec4 drawText(DrawContext dc, GeographicTextRenderer.OrderedText uText, double scale, double opacity) throws java.lang.Exception
- Throws:
java.lang.Exception
-
applyOpacity
protected java.awt.Color applyOpacity(java.awt.Color color, double opacity)
-
computeDrawPoint
protected java.awt.geom.Point2D.Float computeDrawPoint(DrawContext dc, java.awt.geom.Rectangle2D rect, Vec4 screenPoint)
Computes the final draw point for the given rectangle lower left corner and target screen point. If the returned point isnull
the text will not be drawn.- Parameters:
dc
- the currentDrawContext
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
.
-
setDepthFunc
protected void setDepthFunc(DrawContext dc, GeographicTextRenderer.OrderedText uText, Vec4 screenPoint)
-
-