Package gov.nasa.worldwind.render
Class BasicShapeAttributes
- java.lang.Object
-
- gov.nasa.worldwind.render.BasicShapeAttributes
-
- All Implemented Interfaces:
Exportable,ShapeAttributes
- Direct Known Subclasses:
BasicAirspaceAttributes,BasicBalloonAttributes
public class BasicShapeAttributes extends java.lang.Object implements ShapeAttributes
Basic implementation of theShapeAttributesinterface.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleandrawInteriorIndicates whether or not the shape's interior is drawn.protected booleandrawOutlineIndicates whether or not the shape's outline is drawn.protected booleanenableAntialiasingIndicates whether or not the shape should be rendered with smooth lines and edges.protected booleanenableLightingIndicates whether lighting is applied to the shape.protected doubleimageScaleIndicates the amount the balloon's texture is scaled by as a floating-point value.protected java.lang.ObjectimageSourceIndicates the image source that is applied as a texture to the shape's interior.protected MaterialinteriorMaterialIndicates the material properties of the shape's interior.protected doubleinteriorOpacityIndicates the opacity of the shape's interior as a floating-point value in the range 0.0 to 1.0.protected MaterialoutlineMaterialIndicates the material properties of the shape's outline.protected doubleoutlineOpacityIndicates the opacity of the shape's outline as a floating-point value in the range 0.0 to 1.0.protected intoutlineStippleFactorIndicates the number of times each bit in the outline stipple pattern is repeated.protected shortoutlineStipplePatternIndicates the 16-bit integer that defines which pixels are rendered in the shape's outline.protected doubleoutlineWidthIndicates the line width (in pixels) used when rendering the shape's outline.protected booleanunresolvedIndicates 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
Constructors Constructor Description BasicShapeAttributes()Creates a newBasicShapeAttributeswith the default attributes.BasicShapeAttributes(ShapeAttributes attributes)Creates a newBasicShapeAttributesconfigured with the specifiedattributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ShapeAttributescopy()Returns a new ShapeAttributes instance of the same type as this ShapeAttributes who's properties are configured exactly as this ShapeAttributes.voidcopy(ShapeAttributes attributes)Copies the specified ShapeAttributes' properties into this object's properties.booleanequals(java.lang.Object o)voidexport(java.lang.String mimeType, java.lang.Object output)Exports the object to a format.protected voidexportAsKML(java.lang.Object output)Export the placemark attributes to KML as a<Style>element.doublegetImageScale()Indicates the amount the shape's texture is scaled by as a floating-point value.java.lang.ObjectgetImageSource()Indicates the image source that is applied as a texture to the shape's interior.MaterialgetInteriorMaterial()Indicates the material properties of the shape's interior.doublegetInteriorOpacity()Indicates the opacity of the shape's interior as a floating-point value in the range 0.0 to 1.0.MaterialgetOutlineMaterial()Indicates the material properties of the shape's outline.doublegetOutlineOpacity()Indicates the opacity of the shape's outline as a floating-point value in the range 0.0 to 1.0.intgetOutlineStippleFactor()Indicates the number of times each bit in the outline stipple pattern is repeated before the next bit is used.shortgetOutlineStipplePattern()Indicates the 16-bit integer that defines which pixels are rendered in the shape's outline.doublegetOutlineWidth()Indicates the line width (in pixels) used when rendering the shape's outline.voidgetRestorableState(RestorableSupport rs, RestorableSupport.StateObject so)Saves the attributes' current state in the specifiedRestorableSupport.inthashCode()booleanisDrawInterior()Indicates whether the shape's interior geometry is drawn.booleanisDrawOutline()Indicates whether the shape's outline geometry is drawn.booleanisEnableAntialiasing()Indicates whether the shape is rendered with smooth lines and edges.booleanisEnableLighting()Indicates whether lighting is applied to the shape.java.lang.StringisExportFormatSupported(java.lang.String mimeType)Does this object support a certain export format?booleanisUnresolved()Indicates whether some of the shape's attributes are unresolved.voidrestoreState(RestorableSupport rs, RestorableSupport.StateObject so)Restores the state of any attributes contained in the specifiedRestorableSupport.voidsetDrawInterior(boolean draw)Specifies whether to draw the shape's interior geometry.voidsetDrawOutline(boolean draw)Specifies whether to draw the shape's outline geometry.voidsetEnableAntialiasing(boolean enable)Specifies whether the shape should be rendered with smooth lines and edges.voidsetEnableLighting(boolean enableLighting)Specifies whether to apply lighting to the shape.voidsetImageScale(double scale)Specifies the amount to scale the shape's texture as a floating-point value.voidsetImageSource(java.lang.Object imageSource)Specifies the image source to apply as a texture to the shape's interior, ornullto specify that the shape should not have a texture.voidsetInteriorMaterial(Material material)Specifies the material properties of the shape's interior.voidsetInteriorOpacity(double opacity)Specifies the opacity of the shape's interior as a floating-point value in the range 0.0 to 1.0.voidsetOutlineMaterial(Material material)Specifies the material properties of the shape's outline.voidsetOutlineOpacity(double opacity)Specifies the opacity of the shape's outline as a floating-point value in the range 0.0 to 1.0.voidsetOutlineStippleFactor(int factor)Specifies the number of times each bit in the outline stipple pattern should be repeated before the next bit is used.voidsetOutlineStipplePattern(short pattern)Specifies a 16-bit integer that defines which pixels are rendered in the shape's outline.voidsetOutlineWidth(double width)Specifies the line width (in pixels) to use when rendering the shape's outline.voidsetUnresolved(boolean unresolved)Specifies whether some of the shape's attributes are unresolved.
-
-
-
Field Detail
-
unresolved
protected boolean unresolved
Indicates whether or not some of the shape's attributes are unresolved. Initiallyfalse.
-
drawInterior
protected boolean drawInterior
Indicates whether or not the shape's interior is drawn. Initiallyfalse.
-
drawOutline
protected boolean drawOutline
Indicates whether or not the shape's outline is drawn. Initiallyfalse.
-
enableAntialiasing
protected boolean enableAntialiasing
Indicates whether or not the shape should be rendered with smooth lines and edges. Initiallyfalse.
-
enableLighting
protected boolean enableLighting
Indicates whether lighting is applied to the shape. Initiallyfalse.
-
interiorMaterial
protected Material interiorMaterial
Indicates the material properties of the shape's interior. Initiallynull.
-
outlineMaterial
protected Material outlineMaterial
Indicates the material properties of the shape's outline. Initiallynull.
-
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.
-
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.
-
outlineWidth
protected double outlineWidth
Indicates the line width (in pixels) used when rendering the shape's outline. 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.
-
imageSource
protected java.lang.Object imageSource
Indicates the image source that is applied as a texture to the shape's interior. Initiallynull.
-
imageScale
protected double imageScale
Indicates the amount the balloon's texture is scaled by as a floating-point value. Initially 0.0.
-
-
Constructor Detail
-
BasicShapeAttributes
public BasicShapeAttributes()
Creates a newBasicShapeAttributeswith the default attributes. The default attributes are as follows:Default Attributes Attribute Default Value unresolved truedrawInterior truedrawOutline trueenableAntialiasing trueenableLighting falseinteriorMaterial Material.WHITEoutlineMaterial Material.BLACKinteriorOpacity 1.0 outlineOpacity 1.0 outlineWidth 1.0 outlineStippleFactor 0 outlineStipplePattern 0xF0F0 imageSource nullimageScale 1.0
-
BasicShapeAttributes
public BasicShapeAttributes(ShapeAttributes attributes)
Creates a newBasicShapeAttributesconfigured with the specifiedattributes.- Parameters:
attributes- the attributes to configure the newBasicShapeAttributeswith.- Throws:
java.lang.IllegalArgumentException- ifattributesisnull.
-
-
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:
copyin interfaceShapeAttributes- 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 isnull.- Specified by:
copyin interfaceShapeAttributes- Parameters:
attributes- the attributes to copy.
-
isUnresolved
public boolean isUnresolved()
Indicates whether some of the shape's attributes are unresolved.- Specified by:
isUnresolvedin interfaceShapeAttributes- Returns:
trueto indicate that one or more attributes are unresolved, otherwisefalse.- See Also:
ShapeAttributes.setUnresolved(boolean)
-
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 totrue, then sets it tofalseonce the retrieval is complete. Code that interprets the attributes knows that the attributes are complete when unresolved isfalse.- Specified by:
setUnresolvedin interfaceShapeAttributes- Parameters:
unresolved-trueto specify that one or more attributes are unresolved, otherwisefalse.- See Also:
ShapeAttributes.isUnresolved()
-
isDrawInterior
public boolean isDrawInterior()
Indicates whether the shape's interior geometry is drawn.- Specified by:
isDrawInteriorin interfaceShapeAttributes- Returns:
trueif the shape's interior is drawn, otherwisefalse.- See Also:
ShapeAttributes.setDrawInterior(boolean)
-
setDrawInterior
public void setDrawInterior(boolean draw)
Specifies whether to draw the shape's interior geometry.- Specified by:
setDrawInteriorin interfaceShapeAttributes- Parameters:
draw-trueto draw the shape's interior, otherwisefalse.- See Also:
ShapeAttributes.isDrawInterior()
-
isDrawOutline
public boolean isDrawOutline()
Indicates whether the shape's outline geometry is drawn.- Specified by:
isDrawOutlinein interfaceShapeAttributes- Returns:
trueif the shape's outline is drawn, otherwisefalse.- See Also:
ShapeAttributes.setDrawOutline(boolean)
-
setDrawOutline
public void setDrawOutline(boolean draw)
Specifies whether to draw the shape's outline geometry.- Specified by:
setDrawOutlinein interfaceShapeAttributes- Parameters:
draw-trueto draw the shape's outline, otherwisefalse.- See Also:
ShapeAttributes.isDrawOutline()
-
isEnableAntialiasing
public boolean isEnableAntialiasing()
Indicates whether the shape is rendered with smooth lines and edges.- Specified by:
isEnableAntialiasingin interfaceShapeAttributes- Returns:
trueif the shape is drawn with smooth lines and edges, otherwisefalse.- See Also:
ShapeAttributes.setEnableAntialiasing(boolean)
-
setEnableAntialiasing
public void setEnableAntialiasing(boolean enable)
Specifies whether the shape should be rendered with smooth lines and edges.- Specified by:
setEnableAntialiasingin interfaceShapeAttributes- Parameters:
enable-trueto draw the shape with smooth lines and edges, otherwisefalse.- See Also:
ShapeAttributes.isEnableAntialiasing()
-
isEnableLighting
public boolean isEnableLighting()
Indicates whether lighting is applied to the shape.- Specified by:
isEnableLightingin interfaceShapeAttributes- Returns:
trueto apply lighting, otherwisefalse.- See Also:
ShapeAttributes.setEnableLighting(boolean)
-
setEnableLighting
public void setEnableLighting(boolean enableLighting)
Specifies whether to apply lighting to the shape. By default, the shape is lit using theDrawContext's standard lighting by callingDrawContext.beginStandardLighting()andDrawContext.endStandardLighting()before and after the shape is rendered, respectively.- Specified by:
setEnableLightingin interfaceShapeAttributes- Parameters:
enableLighting-trueto apply lighting, otherwisefalse.- See Also:
ShapeAttributes.isEnableLighting()
-
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:
getInteriorMaterialin interfaceShapeAttributes- Returns:
- the material applied to the shape's interior.
- See Also:
ShapeAttributes.setInteriorMaterial(Material)
-
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:
setInteriorMaterialin interfaceShapeAttributes- Parameters:
material- the material to apply to the shape's interior.- See Also:
ShapeAttributes.getInteriorMaterial()
-
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:
getOutlineMaterialin interfaceShapeAttributes- Returns:
- the material applied to the shape's outline.
- See Also:
ShapeAttributes.setOutlineMaterial(Material)
-
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:
setOutlineMaterialin interfaceShapeAttributes- Parameters:
material- the material to apply to the shape's outline.- See Also:
ShapeAttributes.getOutlineMaterial()
-
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:
getInteriorOpacityin interfaceShapeAttributes- Returns:
- the interior opacity as a floating-point value from 0.0 to 1.0.
- See Also:
ShapeAttributes.setInteriorOpacity(double)
-
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:
setInteriorOpacityin interfaceShapeAttributes- Parameters:
opacity- the interior opacity as a floating-point value from 0.0 to 1.0.- See Also:
ShapeAttributes.getInteriorOpacity()
-
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:
getOutlineOpacityin interfaceShapeAttributes- Returns:
- the outline opacity as a floating-point value from 0.0 to 1.0.
- See Also:
ShapeAttributes.setOutlineOpacity(double)
-
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:
setOutlineOpacityin interfaceShapeAttributes- Parameters:
opacity- the outline opacity as a floating-point value from 0.0 to 1.0.- See Also:
ShapeAttributes.getOutlineOpacity()
-
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:
getOutlineWidthin interfaceShapeAttributes- Returns:
- the line width in pixels.
- See Also:
ShapeAttributes.setOutlineWidth(double)
-
setOutlineWidth
public void setOutlineWidth(double width)
Specifies the line width (in pixels) to use when rendering the shape's outline. The specifiedwidthmust be zero or a positive floating-point value. Specifying a line width of zero disables the shape's outline. Thewidthmay be limited by an implementation-defined maximum during rendering. The maximum width is typically 10 pixels.- Specified by:
setOutlineWidthin interfaceShapeAttributes- Parameters:
width- the line width in pixels.- See Also:
ShapeAttributes.getOutlineWidth()
-
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:
getOutlineStippleFactorin interfaceShapeAttributes- Returns:
- the number of times each bit in the outline stipple pattern is repeated.
- See Also:
ShapeAttributes.setOutlineStippleFactor(int)
-
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, iffactoris 3, each bit is repeated 3 times before using the next bit. The specifiedfactormust be either zero or an integer greater than zero. Thefactormay 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:
setOutlineStippleFactorin interfaceShapeAttributes- Parameters:
factor- the number of times each bit in the outline stipple pattern should be repeated.- See Also:
ShapeAttributes.getOutlineStippleFactor(),ShapeAttributes.setOutlineStipplePattern(short)
-
getOutlineStipplePattern
public short getOutlineStipplePattern()
Indicates the 16-bit integer that defines which pixels are rendered in the shape's outline.- Specified by:
getOutlineStipplePatternin interfaceShapeAttributes- Returns:
- a 16-bit integer whose bit pattern defines which pixels are rendered in the shape's outline.
- See Also:
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:
setOutlineStipplePatternin interfaceShapeAttributes- 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)
-
getImageSource
public java.lang.Object getImageSource()
Indicates the image source that is applied as a texture to the shape's interior.- Specified by:
getImageSourcein interfaceShapeAttributes- Returns:
- the source of the shape's texture, either a
Stringpath, aURL, aBufferedImage, ornull. - See Also:
ShapeAttributes.setImageSource(Object)
-
setImageSource
public void setImageSource(java.lang.Object imageSource)
Specifies the image source to apply as a texture to the shape's interior, ornullto specify that the shape should not have a texture. When notnull, the texture replaces the shape's interior material. The source type may be one of the following:Stringcontaining a path to a local file, or a resource on the classpath.URLBufferedImagenull
URL, it is read only when the shape is rendered.- Specified by:
setImageSourcein interfaceShapeAttributes- Parameters:
imageSource- the source of the shape's texture, either aStringpath, aURL, aBufferedImage, ornull.- See Also:
ShapeAttributes.getImageSource()
-
getImageScale
public double getImageScale()
Indicates the amount the shape's texture is scaled by as a floating-point value.- Specified by:
getImageScalein interfaceShapeAttributes- 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)
-
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:
setImageScalein interfaceShapeAttributes- Parameters:
scale- the amount to scale the shape's texture as a floating-point value.- See Also:
ShapeAttributes.getImageScale(),ShapeAttributes.setImageSource(Object)
-
getRestorableState
public void getRestorableState(RestorableSupport rs, RestorableSupport.StateObject so)
Saves the attributes' current state in the specifiedRestorableSupport. If theStateObjectis notnullthe state is appended to it. Otherwise the state is added to theRestorableSupportroot. This state can be restored later by callingShapeAttributes.restoreState(gov.nasa.worldwind.util.RestorableSupport, gov.nasa.worldwind.util.RestorableSupport.StateObject).- Specified by:
getRestorableStatein interfaceShapeAttributes- Parameters:
rs- theRestorableSupportthat receives the attributes' state.so- theStateObjectthe state is appended to, if notnull.
-
restoreState
public void restoreState(RestorableSupport rs, RestorableSupport.StateObject so)
Restores the state of any attributes contained in the specifiedRestorableSupport. If theStateObjectis notnullit's searched for attribute state values, otherwise theRestorableSupportroot is searched.- Specified by:
restoreStatein interfaceShapeAttributes- Parameters:
rs- theRestorableSupportthat contains the attributes' state.so- theStateObjectto search for state values, if notnull.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
isExportFormatSupported
public java.lang.String isExportFormatSupported(java.lang.String mimeType)
Does this object support a certain export format?- Specified by:
isExportFormatSupportedin interfaceExportable- Parameters:
mimeType- Desired export format.- Returns:
- One of
Exportable.FORMAT_SUPPORTED,Exportable.FORMAT_NOT_SUPPORTED, orExportable.FORMAT_PARTIALLY_SUPPORTED. - See Also:
Exportable.export(String, Object)
-
export
public void export(java.lang.String mimeType, java.lang.Object output) throws java.io.IOException, java.lang.UnsupportedOperationExceptionExports the object to a format.- Specified by:
exportin interfaceExportable- Parameters:
mimeType- Desired export format. CallExportable.isExportFormatSupported(String)to make sure that the object supports the format before trying to export, or be prepared to handleUnsupportedOperationException.output- Object that will receive the exported data. The type of this object depends on the export format. All formats should supportjava.io.OutputStream. Text based format (for example, XML formats) should also supportjava.io.Writer. Certain formats may also support other object types.- Throws:
java.io.IOException- if an exception occurs while exporting the data.java.lang.UnsupportedOperationException- if the format is not supported by this object, or if theoutputargument is not of a supported type.- See Also:
Exportable.isExportFormatSupported(String)
-
exportAsKML
protected void exportAsKML(java.lang.Object output) throws javax.xml.stream.XMLStreamExceptionExport the placemark attributes to KML as a<Style>element. Theoutputobject 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:
javax.xml.stream.XMLStreamException- If an exception occurs while writing the KML- See Also:
export(String, Object)
-
-