|
NASA World Wind | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgov.nasa.worldwind.symbology.AbstractIconRetriever
public abstract class AbstractIconRetriever
Base class for icon retrievers. This class provides methods for loading and manipulating icons.
readImage retrieves images relative to this
base path. The retrieval path may be a file URL to a directory on the local file system (for example,
file:///symbols/mil-std-2525). A URL to a network resource (http://myserver.com/milstd2525/), or a URL to a JAR or
ZIP file (jar:file:milstd2525-symbols.zip!).
A simple icon retriever might use a symbol repository that is a simple directory of PNG files, where each file name
matches a symbol identifier. Such an icon retriever could be implemented like this:
class SimpleIconRetriever extends AbstractIconRetriever
{
public BufferedImage createIcon(String symbolId)
{
// Retrieves retrievalPath/symbolId.png
return this.readImage(symbolId + ".png");
}
}
drawImage helps build a complex symbol from
simple pieces. For example, if a symbol is composed of a frame and an icon, the icon retriever could load the frame
and icon independently, draw the icon over the frame, and return the composite image:
// Load the frame and icon as separate pieces.
BufferedImage frame = this.readImage("path/to/frame.png");
BufferedImage icon = this.readImage("path/to/icon.png");
// Draw the icon on top of the frame. This call modifies the frame image.
BufferedImage fullImage = this.drawImage(icon, frame);
// Return the composite image.
return fullImage;
multiply can change the color of an image by
multiplying each pixel in the image by a color. The multiplication color will replace any white pixels and black
pixels will be unaffected. For example, a symbol set in which hostile symbols are drawn in red and friendly symbols
are drawn in green could be implemented by creating white icons, and then multiplying by either red or green when the
retriever constructs the icon.
| Field Summary | |
|---|---|
protected String |
retrieverPath
Path in the file system or network to the symbol repository. |
| Constructor Summary | |
|---|---|
AbstractIconRetriever(String retrieverPath)
Create a new retriever that will retrieve icons from the specified location. |
|
| Method Summary | |
|---|---|
protected BufferedImage |
drawImage(BufferedImage src,
BufferedImage dest)
Draw one image into another image. |
boolean |
equals(Object o)
Indicates whether or not this retriever is equal to another. |
String |
getRetrieverPath()
Indicates the file system or network path of the symbol directory.. |
int |
hashCode()
|
protected void |
multiply(BufferedImage image,
Color color)
Multiply each pixel in an image by a color. |
protected BufferedImage |
readImage(String path)
Load an image from a local or remote path. |
protected void |
replaceColor(BufferedImage image,
Color color)
Replace the color of each pixel in an image. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface gov.nasa.worldwind.symbology.IconRetriever |
|---|
createIcon |
| Field Detail |
|---|
protected String retrieverPath
| Constructor Detail |
|---|
public AbstractIconRetriever(String retrieverPath)
retrieverPath - URL to to the base symbol directory on the local file system or the network.| Method Detail |
|---|
protected BufferedImage drawImage(BufferedImage src,
BufferedImage dest)
src - Image to draw.dest - Image to draw into.
dest BufferedImage.public boolean equals(Object o)
equals in class Objecto - Object to compare.
true if o is an instance of AbstractIconRetriever and has the same retrieval path as this
retriever.public String getRetrieverPath()
public int hashCode()
hashCode in class Object
protected void multiply(BufferedImage image,
Color color)
image - Image to operate on.color - Color to multiply by.replaceColor(java.awt.image.BufferedImage, java.awt.Color)protected BufferedImage readImage(String path)
path - Path to the icon resource, relative to this retriever's retrieval path.
protected void replaceColor(BufferedImage image,
Color color)
multiply, this method changes the color of all pixels.
image - Image to operate on.color - Color to apply to to each pixel.multiply(java.awt.image.BufferedImage, java.awt.Color)
|
NASA World Wind | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||