twaver.gis
Interface GeographyLayer

All Known Implementing Classes:
ImageLayer

public interface GeographyLayer

The interface defines a layer object.

A layer stores a lot of features which have the same type of default geometry. GeographyLayer controls all the properties which determine how to display a layer.

For example, if you want to hide the layer, you can use setLayerVisible(false). If you want to change the style of the layer, you should use setLayerComplexStyle(...) to set new style.

A layer is an aggregation of a collection of features, a Style. Through a layer object, you can access the attributes' names, features, and event the specific property of the layer style.


Field Summary
static java.lang.String IMAGELAYER_NAME
           
 
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.
 

Field Detail

IMAGELAYER_NAME

public static final java.lang.String IMAGELAYER_NAME
See Also:
Constant Field Values
Method Detail

getTitle

public java.lang.String getTitle()
Gets the title of the GeographyLayer.

Returns:
the title of the GeographyLayer.

isVisible

public boolean isVisible()
Indicates whether the layer is visible.

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

setVisible

public void setVisible(boolean value)
Decides whether the layer is visible.

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

isPermittedVisible

public boolean isPermittedVisible()
Indicates whether the layer's visibility gets the permission.

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

setVisibilityPermission

public void setVisibilityPermission(boolean value)
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 factorsetScaleFactor(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     |
                    			--------------------------------------------------------
 

Parameters:
value - the permission value.
See Also:
isVisible(), setVisible(boolean), isPermittedVisible(), setScaleFactor(int), getScaleFactor(), setScaleVisible(boolean), isScaleVisible()

setScaleFactor

public void setScaleFactor(int scaleFactor)
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 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.

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

getScaleFactor

public int getScaleFactor()
Gets the scale factor of the layer.

Returns:
the scale factor of the layer.
See Also:
isVisible(), setVisible(boolean), isPermittedVisible(), setVisibilityPermission(boolean), setScaleFactor(int), setScaleVisible(boolean), isScaleVisible()

setScaleVisible

public void setScaleVisible(boolean value)
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.

Parameters:
value - the specified scale factor.
See Also:
isVisible(), setVisible(boolean), setVisibilityPermission(boolean), isPermittedVisible(), setScaleFactor(int), getScaleFactor(), isScaleVisible()

isScaleVisible

public boolean isScaleVisible()
Indicates whether the layer can be visible under some scale of the map.

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

getLayerGeometryTypeName

public java.lang.String getLayerGeometryTypeName()
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.

Returns:
the name of the geometry type. Such as MultiPolygon,Point,MultiLineString and so on.

getFeatureTypeName

public java.lang.String getFeatureTypeName()
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.

Returns:
the name of the feature type.

getLayerPropertiesNames

public java.lang.String[] getLayerPropertiesNames()
Gets the names of all the properties stored in the layer.

Returns:
a String array, filled with the names of all the properties.

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)
Sets the style of the Layer. The style determines how to paint the layer.

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.

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)
Sets the style of the Layer. The style determines how to paint the layer.

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.

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)
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.

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

removeRules

public void removeRules()
Removes all the custom rules, and clears all the custom styles of the features stored in the layer.


updateDisplay

public 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.


clearRules

public void clearRules()

getAllFeatures

public GeographyFeature[] getAllFeatures()
Gets all the GeographyFeatures of the layer.

Returns:
all the GeographyFeatures of the layer in an array.

getFeatures

public GeographyFeature[] getFeatures(double longitude,
                                      double latitude)
Gets the features which geometric shape contains the coordinates.

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)
Gets the features referring to the specified attribute's value.

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.

getAttributeName

public java.lang.String getAttributeName()
Gets the name of the attribute which is used as the label.

Returns:
the name of the attribute.

setAttributeName

public void setAttributeName(java.lang.String attributeName)
Defines which attribute is used to as the label and the attribute is specified by the attribute name.

Parameters:
attributeName - the specified attribute name.

getAlpha

public double getAlpha()
Gets the alpha value of the style which has been set to the layer.

Returns:
the alpha value of the style.

setAlpha

public void setAlpha(double alpha)
Sets the alpha of the style which is set to the layer.

Parameters:
alpha - the specified alpha value.

getStrokeWidth

public double getStrokeWidth()
Gets the stroke width used to paint the layer.

Returns:
the stroke width.

setStrokeWidth

public void setStrokeWidth(double strokeWidth)
Sets the stroke width used to paint the layer.

Parameters:
strokeWidth - the specified width.

getFillColor

public java.awt.Color getFillColor()
Gets the color used to fill the layer.

Returns:
the color used to fill the layer.

setFillColor

public void setFillColor(java.awt.Color fillColor)
Sets the color used to fill the layer.

Parameters:
fillColor - the specified color used to fill the layer.

getFont

public java.awt.Font getFont()
Gets the font used to paint the label.

Returns:
the font used to paint the label.

setFont

public void setFont(java.awt.Font font)
Sets the font used to paint the label.

Parameters:
font - the specified font used to paint the label

getFontColor

public java.awt.Color getFontColor()
Gets the color used to paint the label.

Returns:
the color used to paint the label.

setFontColor

public void setFontColor(java.awt.Color fontColor)
Sets the color used to paint the label.

Parameters:
fontColor - the specified color used to paint the label.

getStrokeColor

public java.awt.Color getStrokeColor()
Gets the stroke color used to paint the layer.

Returns:
the stroke color used to paint the layer.

setStrokeColor

public void setStrokeColor(java.awt.Color strokeColor)
Sets the stroke color used to paint the layer

Parameters:
strokeColor - the specified stroke color used to paint the layer

setLabelVisible

public void setLabelVisible(java.lang.String attributeName,
                            boolean visible)
Defines if the specified attribute used as the label is visible.

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)
Defines if the specified attribute used as the label is visible. The specified font color and font will be used to render the label.

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.

isLabelVisible

public boolean isLabelVisible()
Determines whether the label can be visible.

Returns:
true if the label can be visible, false otherwise.

getLayerBounds

public java.awt.geom.Rectangle2D getLayerBounds()
Gets the bound of the layer.

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

setLayerBounds

public void setLayerBounds(double minLongitude,
                           double minLatitude,
                           double maxLongitude,
                           double maxLatitude)