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 classGeographicTextRenderer.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.ColorapplyOpacity(java.awt.Color color, double opacity)protected voidbeginRendering(DrawContext dc)protected double[]computeDistanceScaleAndOpacity(DrawContext dc, GeographicTextRenderer.OrderedText ot)protected java.awt.geom.Point2D.FloatcomputeDrawPoint(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.Rectangle2DcomputeExpandedBounds(java.awt.geom.Rectangle2D bounds, int margin)protected doublecomputeLookAtDistance(DrawContext dc)protected java.awt.geom.Rectangle2DcomputeScaledBounds(java.awt.geom.Rectangle2D bounds, double scale)protected java.awt.geom.Rectangle2DcomputeTextBounds(DrawContext dc, GeographicTextRenderer.OrderedText uText, double scale)protected Vec4drawText(DrawContext dc, GeographicTextRenderer.OrderedText uText, double scale, double opacity)protected voidendRendering(DrawContext dc)intgetCullTextMargin()Get the empty margin that surrounds a text item when considering it's bounding rectangle during text culling - seesetCullTextEnabled(boolean).doublegetDistanceMaxScale()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.doublegetDistanceMinOpacity()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.doublegetDistanceMinScale()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.StringgetEffect()Get the effect used to decorate the text.booleanisCullTextEnabled()Determines whether overlapping text are culled.protected static booleanisTextValid(GeographicText text, boolean checkPosition)voidrender(DrawContext dc, GeographicText text, Vec4 textPoint)voidrender(DrawContext dc, java.lang.Iterable<GeographicText> text)voidsetCullTextEnabled(boolean cullText)Set whether overlapping text should be culled.voidsetCullTextMargin(int margin)Set the empty margin that surrounds a text item when considering it's bounding rectangle during text culling - seesetCullTextEnabled(boolean).protected voidsetDepthFunc(DrawContext dc, GeographicTextRenderer.OrderedText uText, Vec4 screenPoint)voidsetDistanceMaxScale(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.voidsetDistanceMinOpacity(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.voidsetDistanceMinScale(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.voidsetEffect(java.lang.String effect)Set the effect used to decorate the text.
-
-
-
Method Detail
-
isCullTextEnabled
public boolean isCullTextEnabled()
Determines whether overlapping text are culled. Iftruetext 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. Iffalseall text will be drawn back to front whether they overlap or not.- Returns:
trueif overlapping text are culled.
-
setCullTextEnabled
public void setCullTextEnabled(boolean cullText)
Set whether overlapping text should be culled. Iftruetext 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. Iffalseall text will be drawn back to front whether they overlap or not.- Parameters:
cullText-trueif 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_OUTLINEorAVKey.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_OUTLINEorAVKey.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 isnullthe text will not be drawn.- Parameters:
dc- the currentDrawContextrect- 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)
-
-