twaver.gis
Class ImageLayer

java.lang.Object
  extended bytwaver.gis.ImageLayer
All Implemented Interfaces:
GeographyLayer

public class ImageLayer
extends java.lang.Object
implements GeographyLayer

The ImageLayer is an implements of the interface ImageLayer. The ImageLayer is used to manage the raster data as a GeographyLayer object.


Field Summary
 
Fields inherited from interface twaver.gis.GeographyLayer
IMAGELAYER_NAME
 
Constructor Summary
ImageLayer(GeographyMap map)
           
 
Method Summary
 void addCustomRule(java.lang.String attributeName, int operator, java.lang.Object value, java.awt.Color strokeColor, double width, java.awt.Color fillColor, double alpha)
          Adds a rule to a GeographyLayer.
 void clearRules()
           
 GeographyFeature[] getAllFeatures()
          Gets all the GeographyFeatures of the layer.
 double getAlpha()
          Gets the alpha value of the style which has been set to the layer.
 java.lang.String getAttributeName()
          Gets the name of the attribute which is used as the label.
 GeographyFeature[] getFeatures(double longitude, double latitude)
          Gets the features which geometric shape contains the coordinates.
 java.util.Collection getFeaturesByAttribute(java.lang.String attributename, java.lang.Object value)
          Gets the features referring to the specified attribute's value.
 java.lang.String getFeatureTypeName()
          Gets the name of the feature type.
 java.awt.Color getFillColor()
          Gets the color used to fill the layer.
 java.awt.Font getFont()
          Gets the font used to paint the label.
 java.awt.Color getFontColor()
          Gets the color used to paint the label.
 java.awt.geom.Rectangle2D getLayerBounds()
          Gets the bound of the layer.
 java.lang.String getLayerGeometryTypeName()
          Gets the name of the layer's geometry type.
 java.lang.String[] getLayerPropertiesNames()
          Gets the names of all the properties stored in the layer.
 int getScaleFactor()
          Gets the scale factor of the layer.
 java.awt.Color getStrokeColor()
          Gets the stroke color used to paint the layer.
 double getStrokeWidth()
          Gets the stroke width used to paint the layer.
 java.lang.String getTitle()
          Gets the title of the GeographyLayer.
 boolean isLabelVisible()
          Determines whether the label can be visible.
 boolean isPermittedVisible()
          Indicates whether the layer's visibility gets the permission.
 boolean isScaleVisible()
          Indicates whether the layer can be visible under some scale of the map.
 boolean isVisible()
          Indicates whether the layer is visible.
 void removeRules()
          Removes all the custom rules, and clears all the custom styles of the features stored in the layer.
 void setAlpha(double alpha)
          Sets the alpha of the style which is set to the layer.
 void setAttributeName(java.lang.String attributeName)
          Defines which attribute is used to as the label and the attribute is specified by the attribute name.
 void setFillColor(java.awt.Color fillColor)
          Sets the color used to fill the layer.
 void setFont(java.awt.Font font)
          Sets the font used to paint the label.
 void setFontColor(java.awt.Color fontColor)
          Sets the color used to paint the label.
 void setLabelVisible(java.lang.String attributeName, boolean visible)
          Defines if the specified attribute used as the label is visible.
 void setLabelVisible(java.lang.String attributeName, boolean visible, java.awt.Color fontColor, java.awt.Font font)
          Defines if the specified attribute used as the label is visible.
 void setLayerBounds(double minLongitude, double minLatitude, double maxLongitude, double maxLatitude)
           
 void setLayerComplexStyle(java.awt.Color strokeColor, java.awt.Color fillColor, double width, double alpha, boolean needText, java.awt.Font font, java.awt.Color fontColor, boolean withHalo, java.awt.Color haloColor, java.lang.String property)
          Sets the style of the Layer.
 void setLayerComplexStyle(java.awt.Color strokeColor, java.awt.Color fillColor, double width, double alpha, boolean needText, java.awt.Font font, java.awt.Color fontColor, java.lang.String property)
          Sets the style of the Layer.
 void setScaleFactor(int scaleFactor)
          Sets the scale factor of the layer.
 void setScaleVisible(boolean value)
          Sets the scale factor of the layer.
 void setStrokeColor(java.awt.Color strokeColor)
          Sets the stroke color used to paint the layer
 void setStrokeWidth(double strokeWidth)
          Sets the stroke width used to paint the layer.
 void setVisibilityPermission(boolean value)
          Sets the permission of the layer's visibility.
 void setVisible(boolean value)
          Decides whether the layer is visible.
 void updateDisplay()
          After add the rules to a GeographyLayer, you will have to invoke this method, otherwise, what you have added into the layer will not works.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageLayer

public ImageLayer(GeographyMap map)
Method Detail

addCustomRule

public void addCustomRule(java.lang.String attributeName,
                          int operator,
                          java.lang.Object value,
                          java.awt.Color strokeColor,
                          double width,
                          java.awt.Color fillColor,
                          double alpha)
Description copied from interface: GeographyLayer
Adds a rule to a GeographyLayer. The rule is used to define different style to those features according to their attributes.

For example:

There are a lot of features in a GeographyLayer.They have the same attribute named "NAME", but have different attribute values.There is one feature and the value of the "NAME" attribute is "New York". If the feature is supposed to be painted in green color, filled with red color, and be transparent described by a alpha value, you can use layer.addCustomRule("NAME",TWaverGisConst.OPERATOR_EQUAL, "New York",Color.GREEN,1,Color.RED,0.5). After that, you should invoke layer.updateDisplay to display your settings.

Specified by:
addCustomRule in interface GeographyLayer
Parameters:
attributeName - the attribute name which you want to refer to.
operator - the type to compare the attribute's values. You should use the following choices:
value - the attribute's value used to be compared with.
strokeColor - the color used to paint the feature.
width - the width of the stroke.
fillColor - the color used to fill the feature.
alpha - the alpha value used to fill the feature.
See Also:
TWaverGisConst.OPERATOR_NULL, TWaverGisConst.OPERATOR_LESSOREQUAL, TWaverGisConst.OPERATOR_LESS, TWaverGisConst.OPERATOR_GREATER, TWaverGisConst.OPERATOR_GREATEROREQUAL, TWaverGisConst.OPERATOR_EQUAL

clearRules

public void clearRules()
Specified by:
clearRules in interface GeographyLayer

getAllFeatures

public GeographyFeature[] getAllFeatures()
Description copied from interface: GeographyLayer
Gets all the GeographyFeatures of the layer.

Specified by:
getAllFeatures in interface GeographyLayer
Returns:
all the GeographyFeatures of the layer in an array.

getAlpha

public double getAlpha()
Description copied from interface: GeographyLayer
Gets the alpha value of the style which has been set to the layer.

Specified by:
getAlpha in interface GeographyLayer
Returns:
the alpha value of the style.

getAttributeName

public java.lang.String getAttributeName()
Description copied from interface: GeographyLayer
Gets the name of the attribute which is used as the label.

Specified by:
getAttributeName in interface GeographyLayer
Returns:
the name of the attribute.

getFeatureTypeName

public java.lang.String getFeatureTypeName()
Description copied from interface: GeographyLayer
Gets the name of the feature type. If the layer is described by shape file. The features stored in the file has the same feature type name.

Specified by:
getFeatureTypeName in interface GeographyLayer
Returns:
the name of the feature type.

getFeatures

public GeographyFeature[] getFeatures(double longitude,
                                      double latitude)
Description copied from interface: GeographyLayer
Gets the features which geometric shape contains the coordinates.

Specified by:
getFeatures in interface GeographyLayer
Parameters:
longitude - the longitude coordinate.
latitude - the latitude coordinate.
Returns:
the features which contains the specified coordinates.

getFeaturesByAttribute

public java.util.Collection getFeaturesByAttribute(java.lang.String attributename,
                                                   java.lang.Object value)
Description copied from interface: GeographyLayer
Gets the features referring to the specified attribute's value.

Specified by:
getFeaturesByAttribute in interface GeographyLayer
Parameters:
attributename - the name of a attribute.
value - the value of the attribute.
Returns:
a collection filled with the features which have the specified attribute value.

getFillColor

public java.awt.Color getFillColor()
Description copied from interface: GeographyLayer
Gets the color used to fill the layer.

Specified by:
getFillColor in interface GeographyLayer
Returns:
the color used to fill the layer.

getFont

public java.awt.Font getFont()
Description copied from interface: GeographyLayer
Gets the font used to paint the label.

Specified by:
getFont in interface GeographyLayer
Returns:
the font used to paint the label.

getFontColor

public java.awt.Color getFontColor()
Description copied from interface: GeographyLayer
Gets the color used to paint the label.

Specified by:
getFontColor in interface GeographyLayer
Returns:
the color used to paint the label.

getLayerBounds

public java.awt.geom.Rectangle2D getLayerBounds()
Description copied from interface: GeographyLayer
Gets the bound of the layer.

Specified by:
getLayerBounds in interface GeographyLayer
Returns:
a Rectangle2D object, described by geography coordinates.
            For example:
            		Rectange2D layerBound = getLayerBounds();
            		System.out.println(layerBound.getMinx());
 

getLayerGeometryTypeName

public java.lang.String getLayerGeometryTypeName()
Description copied from interface: GeographyLayer
Gets the name of the layer's geometry type. A GeographyLayer object has geometry property and a lot of non-geometry properties. They are loaded into the object when the source file is being loaded.

Specified by:
getLayerGeometryTypeName in interface GeographyLayer
Returns:
the name of the geometry type. Such as MultiPolygon,Point,MultiLineString and so on.

getLayerPropertiesNames

public java.lang.String[] getLayerPropertiesNames()
Description copied from interface: GeographyLayer
Gets the names of all the properties stored in the layer.

Specified by:
getLayerPropertiesNames in interface GeographyLayer
Returns:
a String array, filled with the names of all the properties.

getScaleFactor

public int getScaleFactor()
Description copied from interface: GeographyLayer
Gets the scale factor of the layer.

Specified by:
getScaleFactor in interface GeographyLayer
Returns:
the scale factor of the layer.
See Also:
GeographyLayer.isVisible(), GeographyLayer.setVisible(boolean), GeographyLayer.isPermittedVisible(), GeographyLayer.setVisibilityPermission(boolean), GeographyLayer.setScaleFactor(int), GeographyLayer.setScaleVisible(boolean), GeographyLayer.isScaleVisible()

getStrokeColor

public java.awt.Color getStrokeColor()
Description copied from interface: GeographyLayer
Gets the stroke color used to paint the layer.

Specified by:
getStrokeColor in interface GeographyLayer
Returns:
the stroke color used to paint the layer.

getStrokeWidth

public double getStrokeWidth()
Description copied from interface: GeographyLayer
Gets the stroke width used to paint the layer.

Specified by:
getStrokeWidth in interface GeographyLayer
Returns:
the stroke width.

getTitle

public java.lang.String getTitle()
Description copied from interface: GeographyLayer
Gets the title of the GeographyLayer.

Specified by:
getTitle in interface GeographyLayer
Returns:
the title of the GeographyLayer.

isLabelVisible

public boolean isLabelVisible()
Description copied from interface: GeographyLayer
Determines whether the label can be visible.

Specified by:
isLabelVisible in interface GeographyLayer
Returns:
true if the label can be visible, false otherwise.

isPermittedVisible

public boolean isPermittedVisible()
Description copied from interface: GeographyLayer
Indicates whether the layer's visibility gets the permission.

Specified by:
isPermittedVisible in interface GeographyLayer
Returns:
true if the layer gets the permission to be visible, false otherwise.
See Also:
GeographyLayer.isVisible(), GeographyLayer.setVisible(boolean), GeographyLayer.setVisibilityPermission(boolean), GeographyLayer.setScaleFactor(int), GeographyLayer.getScaleFactor(), GeographyLayer.setScaleVisible(boolean), GeographyLayer.isScaleVisible()

isScaleVisible

public boolean isScaleVisible()
Description copied from interface: GeographyLayer
Indicates whether the layer can be visible under some scale of the map.

Specified by:
isScaleVisible in interface GeographyLayer
Returns:
true if the layer can be visible, false otherwise.
See Also:
GeographyLayer.isVisible(), GeographyLayer.setVisible(boolean), GeographyLayer.setVisibilityPermission(boolean), GeographyLayer.isPermittedVisible(), GeographyLayer.setScaleFactor(int), GeographyLayer.getScaleFactor(), GeographyLayer.setScaleVisible(boolean)

isVisible

public boolean isVisible()
Description copied from interface: GeographyLayer
Indicates whether the layer is visible.

Specified by:
isVisible in interface GeographyLayer
Returns:
true if the layer is visible, false otherwise.
See Also:
GeographyLayer.setVisible(boolean), GeographyLayer.setVisibilityPermission(boolean), GeographyLayer.isPermittedVisible(), GeographyLayer.setScaleFactor(int), GeographyLayer.getScaleFactor(), GeographyLayer.setScaleVisible(boolean), GeographyLayer.isScaleVisible()

removeRules

public void removeRules()
Description copied from interface: GeographyLayer
Removes all the custom rules, and clears all the custom styles of the features stored in the layer.

Specified by:
removeRules in interface GeographyLayer

setAlpha

public void setAlpha(double alpha)
Description copied from interface: GeographyLayer
Sets the alpha of the style which is set to the layer.

Specified by:
setAlpha in interface GeographyLayer
Parameters:
alpha - the specified alpha value.

setAttributeName

public void setAttributeName(java.lang.String attributeName)
Description copied from interface: GeographyLayer
Defines which attribute is used to as the label and the attribute is specified by the attribute name.

Specified by:
setAttributeName in interface GeographyLayer
Parameters:
attributeName - the specified attribute name.

setFillColor

public void setFillColor(java.awt.Color fillColor)
Description copied from interface: GeographyLayer
Sets the color used to fill the layer.

Specified by:
setFillColor in interface GeographyLayer
Parameters:
fillColor - the specified color used to fill the layer.

setFont

public void setFont(java.awt.Font font)
Description copied from interface: GeographyLayer
Sets the font used to paint the label.

Specified by:
setFont in interface GeographyLayer
Parameters:
font - the specified font used to paint the label

setFontColor

public void setFontColor(java.awt.Color fontColor)
Description copied from interface: GeographyLayer
Sets the color used to paint the label.

Specified by:
setFontColor in interface GeographyLayer
Parameters:
fontColor - the specified color used to paint the label.

setLabelVisible

public void setLabelVisible(java.lang.String attributeName,
                            boolean visible)
Description copied from interface: GeographyLayer
Defines if the specified attribute used as the label is visible.

Specified by:
setLabelVisible in interface GeographyLayer
Parameters:
attributeName - the specified attribute used as the label.
visible - if true, makes the label is visible, otherwise, hides the label.

setLabelVisible

public void setLabelVisible(java.lang.String attributeName,
                            boolean visible,
                            java.awt.Color fontColor,
                            java.awt.Font font)
Description copied from interface: GeographyLayer
Defines if the specified attribute used as the label is visible. The specified font color and font will be used to render the label.

Specified by:
setLabelVisible in interface GeographyLayer
Parameters:
attributeName - the specified attribute used as the label.
visible - if true, makes the label is visible;otherwise, hides the label.
fontColor - a Color object used to render the label.
font - a Font object used to render the label.

setLayerComplexStyle

public void setLayerComplexStyle(java.awt.Color strokeColor,
                                 java.awt.Color fillColor,
                                 double width,
                                 double alpha,
                                 boolean needText,
                                 java.awt.Font font,
                                 java.awt.Color fontColor,
                                 java.lang.String property)
Description copied from interface: GeographyLayer
Sets the style of the Layer. The style determines how to paint the layer.

Specified by:
setLayerComplexStyle in interface GeographyLayer
Parameters:
strokeColor - the color of the stroke.
fillColor - the color used to fill the geometric shape.
width - the width of the stroke.
alpha - the alpha value used to fill the geometric shape.
needText - defines if the label should be displayed.
font - the font used by the label.
fontColor - the color of the font.
property - the name of the property, which you want to be displayed as labels.

setScaleFactor

public void setScaleFactor(int scaleFactor)
Description copied from interface: GeographyLayer
Sets the scale factor of the layer.

There is a private property named scale factor in layer object. The property is used to determine whether the layer can be visible under the current scale of the map. If the factor is more than current scale of the map, the layer will be visible if it has the visibility permission at the same time. Otherwise the layer will be invisible. For example:

If we set the scale factor as 10000 by invoking the method GeographyLayer.setScaleFactor(int), and the current scale of the map is 1:20000, and the layer has the visibility permission, the layer will be invisible.Otherwise,is the factor is changed to 30000, the layer will be visible.

Specified by:
setScaleFactor in interface GeographyLayer
Parameters:
scaleFactor - the scale factor you want to set.
See Also:
GeographyLayer.isVisible(), GeographyLayer.setVisible(boolean), GeographyLayer.setVisibilityPermission(boolean), GeographyLayer.isPermittedVisible(), GeographyLayer.getScaleFactor(), GeographyLayer.setScaleVisible(boolean), GeographyLayer.isScaleVisible()

setScaleVisible

public void setScaleVisible(boolean value)
Description copied from interface: GeographyLayer
Sets the scale factor of the layer.

By default, a GeographyLayer object monitor the changing of the scale of a map. The layer will be set visible or invisible automatically by comparing current scale of the map and the scale factor of the layer. If you want to monitor the changing of the scale of a map or the changing of the scale factor of a layer, don't forget to artificially invoke setScaleVisible after comparing the scale of the map and the scale factor of the layer.

Specified by:
setScaleVisible in interface GeographyLayer
Parameters:
value - the specified scale factor.
See Also:
GeographyLayer.isVisible(), GeographyLayer.setVisible(boolean), GeographyLayer.setVisibilityPermission(boolean), GeographyLayer.isPermittedVisible(), GeographyLayer.setScaleFactor(int), GeographyLayer.getScaleFactor(), GeographyLayer.isScaleVisible()

setStrokeColor

public void setStrokeColor(java.awt.Color strokeColor)
Description copied from interface: GeographyLayer
Sets the stroke color used to paint the layer

Specified by:
setStrokeColor in interface GeographyLayer
Parameters:
strokeColor - the specified stroke color used to paint the layer

setStrokeWidth

public void setStrokeWidth(double strokeWidth)
Description copied from interface: GeographyLayer
Sets the stroke width used to paint the layer.

Specified by:
setStrokeWidth in interface GeographyLayer
Parameters:
strokeWidth - the specified width.

setVisibilityPermission

public void setVisibilityPermission(boolean value)
Description copied from interface: GeographyLayer
Sets the permission of the layer's visibility.

There are two factors influencing the visibility of the layer. One is the visibility permission, and the other is scale factorGeographyLayer.setScaleFactor(int). The following table explains the relationships between the factors and the layer's visibility. If the layer gets the permission and the scale of the map is smaller than the layer's scaleFactor, the layer will be visible.

                    			--------------------------------------------------------
                    			| isLayerVisible | isPermittedVisible | isScaleVisible |
                   			--------------------------------------------------------
                    			|     TRUE       |        TRUE        |      TRUE      |
                    			--------------------------------------------------------
                    			|     FALSE      |        FALSE       |      TRUE      |
                    			--------------------------------------------------------
                    			|     FALSE      |        TRUE        |      FALSE     |
                    			--------------------------------------------------------
                    			|     FALSE      |        FALSE       |      FALSE     |
                    			--------------------------------------------------------
 

Specified by:
setVisibilityPermission in interface GeographyLayer
Parameters:
value - the permission value.
See Also:
GeographyLayer.isVisible(), GeographyLayer.setVisible(boolean), GeographyLayer.isPermittedVisible(), GeographyLayer.setScaleFactor(int), GeographyLayer.getScaleFactor(), GeographyLayer.setScaleVisible(boolean), GeographyLayer.isScaleVisible()

setVisible

public void setVisible(boolean value)
Description copied from interface: GeographyLayer
Decides whether the layer is visible.

Specified by:
setVisible in interface GeographyLayer
Parameters:
value - true if you want to set the layer visible, false otherwise.
See Also:
GeographyLayer.isVisible(), GeographyLayer.setVisibilityPermission(boolean), GeographyLayer.isPermittedVisible(), GeographyLayer.setScaleFactor(int), GeographyLayer.getScaleFactor(), GeographyLayer.setScaleVisible(boolean), GeographyLayer.isScaleVisible()

updateDisplay

public void updateDisplay()
Description copied from interface: GeographyLayer
After add the rules to a GeographyLayer, you will have to invoke this method, otherwise, what you have added into the layer will not works.

Specified by:
updateDisplay in interface GeographyLayer

setLayerComplexStyle

public void setLayerComplexStyle(java.awt.Color strokeColor,
                                 java.awt.Color fillColor,
                                 double width,
                                 double alpha,
                                 boolean needText,
                                 java.awt.Font font,
                                 java.awt.Color fontColor,
                                 boolean withHalo,
                                 java.awt.Color haloColor,
                                 java.lang.String property)
Description copied from interface: GeographyLayer
Sets the style of the Layer. The style determines how to paint the layer.

Specified by:
setLayerComplexStyle in interface GeographyLayer
Parameters:
strokeColor - the color of the stroke.
fillColor - the color used to fill the geometric shape.
width - the width of the stroke.
alpha - the alpha value used to fill the geometric shape.
needText - defines if the label should be displayed.
font - the font used by the label.
fontColor - the color of the font.
withHalo - defines if the label has a halo
haloColor - specify the color used to render the label's halo
property - the name of the property, which you want to be displayed as labels.

setLayerBounds

public void setLayerBounds(double minLongitude,
                           double minLatitude,
                           double maxLongitude,
                           double maxLatitude)
Specified by:
setLayerBounds in interface GeographyLayer