NASA World Wind

gov.nasa.worldwind.render
Class BasicShapeAttributes

java.lang.Object
  extended by gov.nasa.worldwind.render.BasicShapeAttributes
All Implemented Interfaces:
Exportable, ShapeAttributes
Direct Known Subclasses:
BasicBalloonAttributes

public class BasicShapeAttributes
extends Object
implements ShapeAttributes

Basic implementation of the ShapeAttributes interface.


Field Summary
protected  boolean drawInterior
          Indicates whether or not the shape's interior is drawn.
protected  boolean drawOutline
          Indicates whether or not the shape's outline is drawn.
protected  boolean enableAntialiasing
          Indicates whether or not the shape should be rendered with smooth lines and edges.
protected  boolean enableLighting
          Indicates whether lighting is applied to the shape.
protected  double imageScale
          Indicates the amount the balloon's texture is scaled by as a floating-point value.
protected  Object imageSource
          Indicates the image source that is applied as a texture to the shape's interior.
protected  Material interiorMaterial
          Indicates the material properties of the shape's interior.
protected  double interiorOpacity
          Indicates the opacity of the shape's interior as a floating-point value in the range 0.0 to 1.0.
protected  Material outlineMaterial
          Indicates the material properties of the shape's outline.
protected  double outlineOpacity
          Indicates the opacity of the shape's outline as a floating-point value in the range 0.0 to 1.0.
protected  int outlineStippleFactor
          Indicates the number of times each bit in the outline stipple pattern is repeated.
protected  short outlineStipplePattern
          Indicates the 16-bit integer that defines which pixels are rendered in the shape's outline.
protected  double outlineWidth
          Indicates the line width (in pixels) used when rendering the shape's outline.
protected  boolean unresolved
          Indicates whether or not some of the shape's attributes are unresolved.
 
Fields inherited from interface gov.nasa.worldwind.Exportable
FORMAT_NOT_SUPPORTED, FORMAT_PARTIALLY_SUPPORTED, FORMAT_SUPPORTED
 
Constructor Summary
BasicShapeAttributes()
          Creates a new BasicShapeAttributes with the default attributes.
BasicShapeAttributes(ShapeAttributes attributes)
          Creates a new BasicShapeAttributes configured with the specified attributes.
 
Method Summary
 ShapeAttributes copy()
          Returns a new ShapeAttributes instance of the same type as this ShapeAttributes who's properties are configured exactly as this ShapeAttributes.
 void copy(ShapeAttributes attributes)
          Copies the specified ShapeAttributes' properties into this object's properties.
 boolean equals(Object o)
           
 void export(String mimeType, Object output)
          Exports the object to a format.
protected  void exportAsKML(Object output)
          Export the placemark attributes to KML as a <Style> element.
 double getImageScale()
          Indicates the amount the shape's texture is scaled by as a floating-point value.
 Object getImageSource()
          Indicates the image source that is applied as a texture to the shape's interior.
 Material getInteriorMaterial()
          Indicates the material properties of the shape's interior.
 double getInteriorOpacity()
          Indicates the opacity of the shape's interior as a floating-point value in the range 0.0 to 1.0.
 Material getOutlineMaterial()
          Indicates the material properties of the shape's outline.
 double getOutlineOpacity()
          Indicates the opacity of the shape's outline as a floating-point value in the range 0.0 to 1.0.
 int getOutlineStippleFactor()
          Indicates the number of times each bit in the outline stipple pattern is repeated before the next bit is used.
 short getOutlineStipplePattern()
          Indicates the 16-bit integer that defines which pixels are rendered in the shape's outline.
 double getOutlineWidth()
          Indicates the line width (in pixels) used when rendering the shape's outline.
 void getRestorableState(RestorableSupport rs, RestorableSupport.StateObject so)
          Saves the attributes' current state in the specified RestorableSupport.
 int hashCode()
           
 boolean isDrawInterior()
          Indicates whether the shape's interior geometry is drawn.
 boolean isDrawOutline()
          Indicates whether the shape's outline geometry is drawn.
 boolean isEnableAntialiasing()
          Indicates whether the shape is rendered with smooth lines and edges.
 boolean isEnableLighting()
          Indicates whether lighting is applied to the shape.
 String isExportFormatSupported(String mimeType)
          Does this object support a certain export format?
 boolean isUnresolved()
          Indicates whether some of the shape's attributes are unresolved.
 void restoreState(RestorableSupport rs, RestorableSupport.StateObject so)
          Restores the state of any attributes contained in the specified RestorableSupport.
 void setDrawInterior(boolean draw)
          Specifies whether to draw the shape's interior geometry.
 void setDrawOutline(boolean draw)
          Specifies whether to draw the shape's outline geometry.
 void setEnableAntialiasing(boolean enable)
          Specifies whether the shape should be rendered with smooth lines and edges.
 void setEnableLighting(boolean enableLighting)
          Specifies whether to apply lighting to the shape.
 void setImageScale(double scale)
          Specifies the amount to scale the shape's texture as a floating-point value.
 void setImageSource(Object imageSource)
          Specifies the image source to apply as a texture to the shape's interior, or null to specify that the shape should not have a texture.
 void setInteriorMaterial(Material material)
          Specifies the material properties of the shape's interior.
 void setInteriorOpacity(double opacity)
          Specifies the opacity of the shape's interior as a floating-point value in the range 0.0 to 1.0.
 void setOutlineMaterial(Material material)
          Specifies the material properties of the shape's outline.
 void setOutlineOpacity(double opacity)
          Specifies the opacity of the shape's outline as a floating-point value in the range 0.0 to 1.0.
 void setOutlineStippleFactor(int factor)
          Specifies the number of times each bit in the outline stipple pattern should be repeated before the next bit is used.
 void setOutlineStipplePattern(short pattern)
          Specifies a 16-bit integer that defines which pixels are rendered in the shape's outline.
 void setOutlineWidth(double width)
          Specifies the line width (in pixels) to use when rendering the shape's outline.
 void setUnresolved(boolean unresolved)
          Specifies whether some of the shape's attributes are unresolved.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

drawInterior

protected boolean drawInterior
Indicates whether or not the shape's interior is drawn. Initially false.


drawOutline

protected boolean drawOutline
Indicates whether or not the shape's outline is drawn. Initially false.


enableAntialiasing

protected boolean enableAntialiasing
Indicates whether or not the shape should be rendered with smooth lines and edges. Initially false.


enableLighting

protected boolean enableLighting
Indicates whether lighting is applied to the shape. Initially false.


imageScale

protected double imageScale
Indicates the amount the balloon's texture is scaled by as a floating-point value. Initially 0.0.


imageSource

protected Object imageSource
Indicates the image source that is applied as a texture to the shape's interior. Initially null.


interiorMaterial

protected Material interiorMaterial
Indicates the material properties of the shape's interior. Initially null.


interiorOpacity

protected double interiorOpacity
Indicates the opacity of the shape's interior as a floating-point value in the range 0.0 to 1.0. Initially 0.0.


outlineMaterial

protected Material outlineMaterial
Indicates the material properties of the shape's outline. Initially null.


outlineOpacity

protected double outlineOpacity
Indicates the opacity of the shape's outline as a floating-point value in the range 0.0 to 1.0. Initially 0.0.


outlineStippleFactor

protected int outlineStippleFactor
Indicates the number of times each bit in the outline stipple pattern is repeated. Initially 0.


outlineStipplePattern

protected short outlineStipplePattern
Indicates the 16-bit integer that defines which pixels are rendered in the shape's outline. Initially 0.


outlineWidth

protected double outlineWidth
Indicates the line width (in pixels) used when rendering the shape's outline. Initially 0.0.


unresolved

protected boolean unresolved
Indicates whether or not some of the shape's attributes are unresolved. Initially false.

Constructor Detail

BasicShapeAttributes

public BasicShapeAttributes()
Creates a new BasicShapeAttributes with the default attributes. The default attributes are as follows:

AttributeDefault Value
unresolvedtrue
drawInteriortrue
drawOutlinetrue
enableAntialiasingtrue
enableLightingfalse
interiorMaterialMaterial.WHITE
outlineMaterialMaterial.BLACK
interiorOpacity1.0
outlineOpacity1.0
outlineWidth1.0
outlineStippleFactor0
outlineStipplePattern0xF0F0
imageSourcenull
imageScale1.0


BasicShapeAttributes

public BasicShapeAttributes(ShapeAttributes attributes)
Creates a new BasicShapeAttributes configured with the specified attributes.

Parameters:
attributes - the attributes to configure the new BasicShapeAttributes with.
Throws:
IllegalArgumentException - if attributes is null.
Method Detail

copy

public ShapeAttributes copy()
Returns a new ShapeAttributes instance of the same type as this ShapeAttributes who's properties are configured exactly as this ShapeAttributes.

Specified by:
copy in interface ShapeAttributes
Returns:
a copy of this ShapeAttributes.

copy

public void copy(ShapeAttributes attributes)
Copies the specified ShapeAttributes' properties into this object's properties. This does nothing if the specified attributes is null.

Specified by:
copy in interface ShapeAttributes
Parameters:
attributes - the attributes to copy.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

export

public void export(String mimeType,
                   Object output)
            throws IOException,
                   UnsupportedOperationException
Exports the object to a format.

Specified by:
export in interface Exportable
Parameters:
mimeType - Desired export format. Call Exportable.isExportFormatSupported(String) to make sure that the object supports the format before trying to export, or be prepared to handle UnsupportedOperationException.
output - Object that will receive the exported data. The type of this object depends on the export format. All formats should support java.io.OutputStream. Text based format (for example, XML formats) should also support java.io.Writer. Certain formats may also support other object types.
Throws:
IOException - if an exception occurs while exporting the data.
UnsupportedOperationException - if the format is not supported by this object, or if the output argument is not of a supported type.
See Also:
Exportable.isExportFormatSupported(String)

exportAsKML

protected void exportAsKML(Object output)
                    throws XMLStreamException
Export the placemark attributes to KML as a <Style> element. The output object will receive the data. This object must be one of: java.io.Writer
java.io.OutputStream
javax.xml.stream.XMLStreamWriter

Parameters:
output - Object to receive the generated KML.
Throws:
XMLStreamException - If an exception occurs while writing the KML
See Also:
export(String, Object)

getImageScale

public double getImageScale()
Indicates the amount the shape's texture is scaled by as a floating-point value.

Specified by:
getImageScale in interface ShapeAttributes
Returns:
the amount the shape's texture is scaled by as a floating-point value. This value is always greater than zero.
See Also:
ShapeAttributes.setImageScale(double)

getImageSource

public Object getImageSource()
Indicates the image source that is applied as a texture to the shape's interior.

Specified by:
getImageSource in interface ShapeAttributes
Returns:
the source of the shape's texture, either a String path, a URL, a BufferedImage, or null.
See Also:
ShapeAttributes.setImageSource(Object)

getInteriorMaterial

public Material getInteriorMaterial()
Indicates the material properties of the shape's interior. If lighting is applied to the shape, this indicates the interior's ambient, diffuse, and specular colors, its shininess, and the color of any emitted light. Otherwise, the material's diffuse color indicates the shape's constant interior color.

Specified by:
getInteriorMaterial in interface ShapeAttributes
Returns:
the material applied to the shape's interior.
See Also:
ShapeAttributes.setInteriorMaterial(Material)

getInteriorOpacity

public double getInteriorOpacity()
Indicates the opacity of the shape's interior as a floating-point value in the range 0.0 to 1.0.

Specified by:
getInteriorOpacity in interface ShapeAttributes
Returns:
the interior opacity as a floating-point value from 0.0 to 1.0.
See Also:
ShapeAttributes.setInteriorOpacity(double)

getOutlineMaterial

public Material getOutlineMaterial()
Indicates the material properties of the shape's outline. If lighting is applied to the shape, this indicates the outline's ambient, diffuse, and specular colors, its shininess, and the color of any emitted light. Otherwise, the material's diffuse color indicates the shape's constant outline color.

Specified by:
getOutlineMaterial in interface ShapeAttributes
Returns:
the material applied to the shape's outline.
See Also:
ShapeAttributes.setOutlineMaterial(Material)

getOutlineOpacity

public double getOutlineOpacity()
Indicates the opacity of the shape's outline as a floating-point value in the range 0.0 to 1.0.

Specified by:
getOutlineOpacity in interface ShapeAttributes
Returns:
the outline opacity as a floating-point value from 0.0 to 1.0.
See Also:
ShapeAttributes.setOutlineOpacity(double)

getOutlineStippleFactor

public int getOutlineStippleFactor()
Indicates the number of times each bit in the outline stipple pattern is repeated before the next bit is used.

Specified by:
getOutlineStippleFactor in interface ShapeAttributes
Returns:
the number of times each bit in the outline stipple pattern is repeated.
See Also:
ShapeAttributes.setOutlineStippleFactor(int)

getOutlineStipplePattern

public short getOutlineStipplePattern()
Indicates the 16-bit integer that defines which pixels are rendered in the shape's outline.

Specified by:
getOutlineStipplePattern in interface ShapeAttributes
Returns:
a 16-bit integer whose bit pattern defines which pixels are rendered in the shape's outline.
See Also:
ShapeAttributes.setOutlineStipplePattern(short)

getOutlineWidth

public double getOutlineWidth()
Indicates the line width (in pixels) used when rendering the shape's outline. The returned value is either zero or a positive floating-point value.

Specified by:
getOutlineWidth in interface ShapeAttributes
Returns:
the line width in pixels.
See Also:
ShapeAttributes.setOutlineWidth(double)

getRestorableState

public void getRestorableState(RestorableSupport rs,
                               RestorableSupport.StateObject so)
Saves the attributes' current state in the specified RestorableSupport. If the StateObject is not null the state is appended to it. Otherwise the state is added to the RestorableSupport root. This state can be restored later by calling ShapeAttributes.restoreState(gov.nasa.worldwind.util.RestorableSupport, gov.nasa.worldwind.util.RestorableSupport.StateObject).

Specified by:
getRestorableState in interface ShapeAttributes
Parameters:
rs - the RestorableSupport that receives the attributes' state.
so - the StateObject the state is appended to, if not null.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isDrawInterior

public boolean isDrawInterior()
Indicates whether the shape's interior geometry is drawn.

Specified by:
isDrawInterior in interface ShapeAttributes
Returns:
true if the shape's interior is drawn, otherwise false.
See Also:
ShapeAttributes.setDrawInterior(boolean)

isDrawOutline

public boolean isDrawOutline()
Indicates whether the shape's outline geometry is drawn.

Specified by:
isDrawOutline in interface ShapeAttributes
Returns:
true if the shape's outline is drawn, otherwise false.
See Also:
ShapeAttributes.setDrawOutline(boolean)

isEnableAntialiasing

public boolean isEnableAntialiasing()
Indicates whether the shape is rendered with smooth lines and edges.

Specified by:
isEnableAntialiasing in interface ShapeAttributes
Returns:
true if the shape is drawn with smooth lines and edges, otherwise false.
See Also:
ShapeAttributes.setEnableAntialiasing(boolean)

isEnableLighting

public boolean isEnableLighting()
Indicates whether lighting is applied to the shape.

Specified by:
isEnableLighting in interface ShapeAttributes
Returns:
true to apply lighting, otherwise false.
See Also:
ShapeAttributes.setEnableLighting(boolean)

isExportFormatSupported

public String isExportFormatSupported(String mimeType)
Does this object support a certain export format?

Specified by:
isExportFormatSupported in interface Exportable
Parameters:
mimeType - Desired export format.
Returns:
One of Exportable.FORMAT_SUPPORTED, Exportable.FORMAT_NOT_SUPPORTED, or Exportable.FORMAT_PARTIALLY_SUPPORTED.
See Also:
Exportable.export(String, Object)

isUnresolved

public boolean isUnresolved()
Indicates whether some of the shape's attributes are unresolved.

Specified by:
isUnresolved in interface ShapeAttributes
Returns:
true to indicate that one or more attributes are unresolved, otherwise false.
See Also:
ShapeAttributes.setUnresolved(boolean)

restoreState

public void restoreState(RestorableSupport rs,
                         RestorableSupport.StateObject so)
Restores the state of any attributes contained in the specified RestorableSupport. If the StateObject is not null it's searched for attribute state values, otherwise the RestorableSupport root is searched.

Specified by:
restoreState in interface ShapeAttributes
Parameters:
rs - the RestorableSupport that contains the attributes' state.
so - the StateObject to search for state values, if not null.

setDrawInterior

public void setDrawInterior(boolean draw)
Specifies whether to draw the shape's interior geometry.

Specified by:
setDrawInterior in interface ShapeAttributes
Parameters:
draw - true to draw the shape's interior, otherwise false.
See Also:
ShapeAttributes.isDrawInterior()

setDrawOutline

public void setDrawOutline(boolean draw)
Specifies whether to draw the shape's outline geometry.

Specified by:
setDrawOutline in interface ShapeAttributes
Parameters:
draw - true to draw the shape's outline, otherwise false.
See Also:
ShapeAttributes.isDrawOutline()

setEnableAntialiasing

public void setEnableAntialiasing(boolean enable)
Specifies whether the shape should be rendered with smooth lines and edges.

Specified by:
setEnableAntialiasing in interface ShapeAttributes
Parameters:
enable - true to draw the shape with smooth lines and edges, otherwise false.
See Also:
ShapeAttributes.isEnableAntialiasing()

setEnableLighting

public void setEnableLighting(boolean enableLighting)
Specifies whether to apply lighting to the shape. By default, the shape is lit using the DrawContext's standard lighting by calling DrawContext.beginStandardLighting() and DrawContext.endStandardLighting() before and after the shape is rendered, respectively.

Specified by:
setEnableLighting in interface ShapeAttributes
Parameters:
enableLighting - true to apply lighting, otherwise false.
See Also:
ShapeAttributes.isEnableLighting()

setImageScale

public void setImageScale(double scale)
Specifies the amount to scale the shape's texture as a floating-point value. A value of 1.0 specifies that the texture should be applied without any scaling, a value greater than 1.0 specifies that the texture should be magnified, and a value less than 1.0 specifies that the texture should be minified. For example, a scale of 2.0 magnifies the texture by a factor of 2x.

Specified by:
setImageScale in interface ShapeAttributes
Parameters:
scale - the amount to scale the shape's texture as a floating-point value.
See Also:
ShapeAttributes.getImageScale(), ShapeAttributes.setImageSource(Object)

setImageSource

public void setImageSource(Object imageSource)
Specifies the image source to apply as a texture to the shape's interior, or null to specify that the shape should not have a texture. When not null, the texture replaces the shape's interior material. The source type may be one of the following: If the image source is a file or a URL, it is read only when the shape is rendered.

Specified by:
setImageSource in interface ShapeAttributes
Parameters:
imageSource - the source of the shape's texture, either a String path, a URL, a BufferedImage, or null.
See Also:
ShapeAttributes.getImageSource()

setInteriorMaterial

public void setInteriorMaterial(Material material)
Specifies the material properties of the shape's interior. If lighting is applied to the shape, this specifies the interior's ambient, diffuse, and specular colors, its shininess, and the color of any emitted light. Otherwise, the material's diffuse color specifies the shape's constant interior color.

Specified by:
setInteriorMaterial in interface ShapeAttributes
Parameters:
material - the material to apply to the shape's interior.
See Also:
ShapeAttributes.getInteriorMaterial()

setInteriorOpacity

public void setInteriorOpacity(double opacity)
Specifies the opacity of the shape's interior as a floating-point value in the range 0.0 to 1.0. A value of 1.0 specifies a completely opaque interior, and 0.0 specifies a completely transparent interior. Values in between specify a partially transparent interior.

Specified by:
setInteriorOpacity in interface ShapeAttributes
Parameters:
opacity - the interior opacity as a floating-point value from 0.0 to 1.0.
See Also:
ShapeAttributes.getInteriorOpacity()

setOutlineMaterial

public void setOutlineMaterial(Material material)
Specifies the material properties of the shape's outline. If lighting is applied to the shape, this specifies the outline's ambient, diffuse, and specular colors, its shininess, and the color of any emitted light. Otherwise, the material's diffuse color specifies as the shape's constant outline color.

Specified by:
setOutlineMaterial in interface ShapeAttributes
Parameters:
material - the material to apply to the shape's outline.
See Also:
ShapeAttributes.getOutlineMaterial()

setOutlineOpacity

public void setOutlineOpacity(double opacity)
Specifies the opacity of the shape's outline as a floating-point value in the range 0.0 to 1.0. A value of 1.0 specifies a completely opaque outline, and 0.0 specifies a completely transparent outline. Values in between specify a partially transparent outline.

Specified by:
setOutlineOpacity in interface ShapeAttributes
Parameters:
opacity - the outline opacity as a floating-point value from 0.0 to 1.0.
See Also:
ShapeAttributes.getOutlineOpacity()

setOutlineStippleFactor

public void setOutlineStippleFactor(int factor)
Specifies the number of times each bit in the outline stipple pattern should be repeated before the next bit is used. For example, if factor is 3, each bit is repeated 3 times before using the next bit. The specified factor must be either zero or an integer greater than zero. The factor may be limited by an implementation-defined maximum during rendering. The maximum stipple factor is typically 256.

To disable outline stippling, either specify a stipple factor of 0, or specify a stipple pattern of all 1 bits: 0xFFFF.

Specified by:
setOutlineStippleFactor in interface ShapeAttributes
Parameters:
factor - the number of times each bit in the outline stipple pattern should be repeated.
See Also:
ShapeAttributes.getOutlineStippleFactor(), ShapeAttributes.setOutlineStipplePattern(short)

setOutlineStipplePattern

public void setOutlineStipplePattern(short pattern)
Specifies a 16-bit integer that defines which pixels are rendered in the shape's outline. Starting at the least significant bit and moving to the most significant bit, the 16 bits define a repeating a pattern of which pixels in the outline are rendered and which are suppressed. Each bit corresponds to a pixel in the shape's outline, and the bit pattern repeats after reaching n*16 pixels, where n is the stipple factor. Each bit is repeated n-times according to the outline stipple factor. For example, if the outline stipple factor is 3, each bit is repeated 3 times before using the next bit.

To disable outline stippling, either specify a stipple factor of 0, or specify a stipple pattern of all 1 bits: 0xFFFF.

Specified by:
setOutlineStipplePattern in interface ShapeAttributes
Parameters:
pattern - a 16-bit integer whose bit pattern defines which pixels are rendered in the shape's outline.
See Also:
ShapeAttributes.getOutlineStipplePattern(), ShapeAttributes.setOutlineStippleFactor(int)

setOutlineWidth

public void setOutlineWidth(double width)
Specifies the line width (in pixels) to use when rendering the shape's outline. The specified width must be zero or a positive floating-point value. Specifying a line width of zero disables the shape's outline. The width may be limited by an implementation-defined maximum during rendering. The maximum width is typically 10 pixels.

Specified by:
setOutlineWidth in interface ShapeAttributes
Parameters:
width - the line width in pixels.
See Also:
ShapeAttributes.getOutlineWidth()

setUnresolved

public void setUnresolved(boolean unresolved)
Specifies whether some of the shape's attributes are unresolved. This can be used to denote that a shape's attributes are being retrieved from a non-local resource. During retrieval, the controlling code sets unresolved to true, then sets it to false once the retrieval is complete. Code that interprets the attributes knows that the attributes are complete when unresolved is false.

Specified by:
setUnresolved in interface ShapeAttributes
Parameters:
unresolved - true to specify that one or more attributes are unresolved, otherwise false.
See Also:
ShapeAttributes.isUnresolved()

NASA World Wind