Skip to content

Text layer #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/gov/nasa/worldwind/formats/vpf/VPFLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class VPFLayer extends AbstractLayer
protected ArrayList<Renderable> renderableObjects = new ArrayList<Renderable>();

// Renderers
protected GeographicTextRenderer textRenderer = new GeographicTextRenderer();
protected BasicGeographicTextRenderer textRenderer = new BasicGeographicTextRenderer();
protected VPFSymbolSupport symbolSupport = new VPFSymbolSupport(GeoSymConstants.GEOSYM, "image/png");

// Threaded requests
Expand Down
2 changes: 1 addition & 1 deletion src/gov/nasa/worldwind/layers/GraticuleSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public int hashCode()
private Map<String, GraticuleRenderingParams> namedParams = new HashMap<String, GraticuleRenderingParams>();
private Map<String, ShapeAttributes> namedShapeAttributes = new HashMap<String, ShapeAttributes>();
private AVList defaultParams;
private GeographicTextRenderer textRenderer = new GeographicTextRenderer();
private BasicGeographicTextRenderer textRenderer = new BasicGeographicTextRenderer();

public GraticuleSupport()
{
Expand Down
120 changes: 120 additions & 0 deletions src/gov/nasa/worldwind/layers/TextLayer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/**
* Copyright (C) 2014, United States Government as represented by the
* Administrator of the National Aeronautics and Space Administration,
* All Rights Reserved.
*/
package gov.nasa.worldwind.layers;

import gov.nasa.worldwind.render.DeclutteringTextRenderer;
import gov.nasa.worldwind.render.DrawContext;
import gov.nasa.worldwind.render.GeographicText;
import gov.nasa.worldwind.render.GeographicTextRenderer;
import gov.nasa.worldwind.util.Logging;

import java.util.Collection;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
* Layer to support objects of type {@link GeographicText}
*
* @author Bruno Spyckerelle
* @version $Id$
*/
public class TextLayer extends AbstractLayer
{
protected GeographicTextRenderer textRenderer;
protected Collection<GeographicText> geographicTexts;

public TextLayer()
{
this.textRenderer = new DeclutteringTextRenderer();
this.geographicTexts = new ConcurrentLinkedQueue<GeographicText>();
}

public GeographicTextRenderer getGeographicTextRenderer()
{
return this.textRenderer;
}

public void setGeographicTextRenderer(GeographicTextRenderer textRenderer)
{
this.textRenderer = textRenderer;
}

/**
* Adds the specified <code>text</code> to this layer's internal collection.
* @param text {@link GeographicText} to add.
* @throws IllegalArgumentException If <code>text</code> is null.
*/
public void addGeographicText(GeographicText text)
{
if (text == null)
{
String msg = "nullValue.GeographicTextIsNull";
Logging.logger().severe(msg);
throw new IllegalArgumentException(msg);
}
this.geographicTexts.add(text);
}

public void addGeographicTexts(Iterable<? extends GeographicText> texts)
{
if (texts == null)
{
String msg = Logging.getMessage("nullValue.IterableIsNull");
Logging.logger().severe(msg);
throw new IllegalArgumentException(msg);
}
for (GeographicText text : texts)
{
if (text != null)
{
this.geographicTexts.add(text);
}
}
}

public void removeGeographicText(GeographicText text)
{
if (text == null)
{
String msg = "nullValue.GeographicTextIsNull";
Logging.logger().severe(msg);
throw new IllegalArgumentException(msg);
}
this.geographicTexts.remove(text);
}

public void removeGeographicTexts(Iterable<? extends GeographicText> texts)
{
if (texts == null)
{
String msg = Logging.getMessage("nullValue.IterableIsNull");
Logging.logger().severe(msg);
throw new IllegalArgumentException(msg);
}
for (GeographicText text : texts)
{
if (text != null)
{
this.geographicTexts.remove(text);
}
}
}

public void removeAllGeographicTexts()
{
this.geographicTexts.clear();
}

public Iterable<GeographicText> getActiveGeographicTexts()
{
return this.geographicTexts;
}

@Override
protected void doRender(DrawContext dc)
{
this.textRenderer.render(dc, getActiveGeographicTexts());
}
}
Loading