org.gwtopenmaps.openlayers.client
Class Style

java.lang.Object
  extended by org.gwtopenmaps.openlayers.client.util.JSObjectWrapper
      extended by org.gwtopenmaps.openlayers.client.OpenLayersObjectWrapper
          extended by org.gwtopenmaps.openlayers.client.Style

public class Style
extends OpenLayersObjectWrapper

From OpenLayers documentation: "OpenLayers features can have a number of style attributes. The 'default' style will typically be used if no other style is specified. These styles correspond for the most part, to the styling properties defined by the SVG standard. Information on fill properties: http://www.w3.org/TR/SVG/painting.html#FillProperties Information on stroke properties: http://www.w3.org/TR/SVG/painting.html#StrokeProperties"

Author:
Edwin Commandeur - Atlis EJS, Curtis Jensen, Rafael Ceravolo - LOGANN, Lukas Johansson

Field Summary
static String STROKE_DASHSTYLE_DASHDOT
           
static String STROKE_DASHSTYLE_SOLID
           
 
Constructor Summary
  Style()
           
protected Style(JSObject element)
           
  Style(String string)
          This constructor is to be used when you want to get an empty Style object, instead of a Style initialized to default.
 
Method Summary
 String getBackgroundGraphic()
          Url to a graphic to be used as the background under an externalGraphic.
 int getBackgroundGraphicZIndex()
          The integer z-index value to use in rendering the background graphic.
 int getBackgroundHeight()
          The height of the background graphic.
 int getBackgroundWidth()
          The width of the background width.
 String getCursor()
          Cursor.
 String getExternalGraphic()
          Url to an external graphic that will be used for rendering points.
 boolean getFill()
          Set to false if no fill is desired.
 String getFillColor()
          Hex fill color.
 double getFillOpacity()
          Fill opacity (0-1).
 boolean getGraphic()
          Set to false if no graphic is desired.
 int getGraphicHeight()
          Pixel height for sizing an external graphic.
 String getGraphicName()
          Named graphic to use when rendering points.
 String getGraphicTitle()
          Tooltip for an external graphic.
 int getGraphicWidth()
          Pixel width for sizing an external graphic.
 int getGraphicZIndex()
          The integer z-index value to use in rendering.
 String getId()
           
 String getLabelAlign()
          Vertical Label alignment.
 String getName()
           
 double getPointRadius()
          Deprecated. 
 double getPointRadiusAsDouble()
          Pixel point radius.
 String getPointRadiusAsString()
          The name of the attribute which value determines the point radius
 String getRotation()
          Url to an external graphic that will be used for rendering points.
 boolean getStroke()
          Set to false if no stroke is desired.
 String getStrokeColor()
          Hex stroke html color.
 String getStrokeDashstyle()
          Stroke dash style.
 String getStrokeLinecap()
          Stroke linecap.
 double getStrokeOpacity()
           
 double getStrokeWidth()
          Pixel stroke width.
static Style narrowToOpenLayersStyle(JSObject element)
           
 void setBackgroundGraphic(String graphicURL)
          Url to a graphic to be used as the background under an externalGraphic.
 void setBackgroundGraphicSize(int backgroundWidth, int backgroundHeight)
          Sets the size of the background graphic.
 void setBackgroundGraphicZIndex(int backgroundGraphicZIndex)
          The integer z-index value to use in rendering the background graphic.
 void setBackgroundHeight(int backgroundHeight)
          The height of the background graphic.
 void setBackgroundOffset(int backgroundXOffset, int backgroundYOffset)
          Sets the offset for the displacement of the background graphic.
 void setBackgroundWidth(int backgroundWidth)
          The width of the background width.
 void setCursor(String cursor)
          Cursor.
 void setExternalGraphic(String graphicURL)
          Url to an external graphic that will be used for rendering points.
 void setFill(boolean fill)
          Set to false if no fill is desired.
 void setFillColor(String c)
          Hex fill color.
 void setFillOpacity(double o)
          Fill opacity (0-1).
 void setFontColor(String fontColor)
          The font color for the label, to be provided like CSS.
 void setFontFamily(String fontFamily)
          The font family for the label, to be provided like in CSS.
 void setFontSize(String fontSize)
          The font size for the label, to be provided like in CSS.
 void setFontWeight(String fontWeight)
          The font weight for the label, to be provided like in CSS.
 void setGraphic(boolean graphic)
          Set to false if no graphic is desired.
 void setGraphicName(String graphicName)
          Directly sets the named graphic to use when rendering points.
 void setGraphicOffset(int xOffset, int yOffset)
          Sets the offset for the displacement of the external graphic.
 void setGraphicSize(int width, int height)
          Convenient method to set the pixel width and height for sizing an external graphic.
 void setGraphicTitle(String graphicTitle)
          Tooltip for an external graphic.
 void setGraphicZIndex(int graphicZIndex)
          The integer z-index value to use in rendering.
 void setLabel(String label)
          The text for an optional label.
 void setLabelAlign(String align)
          Sets the Label alignment string directly.
 void setPointRadius(double r)
          Pixel point radius.
 void setPointRadius(String r)
          The passed String is the name of the attribute whose value will determine the point radius
 void setRotation(String rotation)
          Url to an external graphic that will be used for rendering points.
 void setStroke(boolean stroke)
          Set to false if no stroke is desired.
 void setStrokeColor(String c)
          Hex stroke color.
 void setStrokeDashstyle(String strokeDashstyle)
          Directly sets the stroke dash style string.
 void setStrokeLinecap(String strokeLinecap)
          Directly sets the StrokeLineCap string.
 void setStrokeOpacity(double strokeOpacity)
          Stroke opacity (0-1).
 void setStrokeWidth(double w)
          Pixel stroke width.
 
Methods inherited from class org.gwtopenmaps.openlayers.client.OpenLayersObjectWrapper
getClassName, getEvents, narrowToOpenLayersObjectWrapper
 
Methods inherited from class org.gwtopenmaps.openlayers.client.util.JSObjectWrapper
getJSObject, setJSObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STROKE_DASHSTYLE_SOLID

public static final String STROKE_DASHSTYLE_SOLID
See Also:
Constant Field Values

STROKE_DASHSTYLE_DASHDOT

public static final String STROKE_DASHSTYLE_DASHDOT
See Also:
Constant Field Values
Constructor Detail

Style

protected Style(JSObject element)

Style

public Style()

Style

public Style(String string)
This constructor is to be used when you want to get an empty Style object, instead of a Style initialized to default. For example : Style emptyStyle = new Style("{}");

Parameters:
string - The JSON representation of the properties used to initialize the Style object
Method Detail

getId

public String getId()

getName

public String getName()

setFillColor

public void setFillColor(String c)
Hex fill color. Default is '#ee9900'.

Parameters:
c - - hexidecimal color code or a W3C standard color name

getFillColor

public String getFillColor()
Hex fill color.


setFillOpacity

public void setFillOpacity(double o)
Fill opacity (0-1). Default is 0.4


getFillOpacity

public double getFillOpacity()
Fill opacity (0-1).


setPointRadius

public void setPointRadius(double r)
Pixel point radius. Default is 6.


getPointRadiusAsDouble

public double getPointRadiusAsDouble()
Pixel point radius.


getPointRadius

@Deprecated
public double getPointRadius()
Deprecated. 

Use getPointRadiusAsDouble() instead


setPointRadius

public void setPointRadius(String r)
The passed String is the name of the attribute whose value will determine the point radius


getPointRadiusAsString

public String getPointRadiusAsString()
The name of the attribute which value determines the point radius


setStrokeColor

public void setStrokeColor(String c)
Hex stroke color. Default is '#ee9900'.

Parameters:
c - - see setFillColor

getStrokeColor

public String getStrokeColor()
Hex stroke html color.


setStrokeWidth

public void setStrokeWidth(double w)
Pixel stroke width. Default is 1.


getStrokeWidth

public double getStrokeWidth()
Pixel stroke width.


setExternalGraphic

public void setExternalGraphic(String graphicURL)
Url to an external graphic that will be used for rendering points.


getExternalGraphic

public String getExternalGraphic()
Url to an external graphic that will be used for rendering points.


setRotation

public void setRotation(String rotation)
Url to an external graphic that will be used for rendering points.


getRotation

public String getRotation()
Url to an external graphic that will be used for rendering points.


setGraphicSize

public void setGraphicSize(int width,
                           int height)
Convenient method to set the pixel width and height for sizing an external graphic.

Parameters:
width - The width (in pixels) to set
height - The height (in pixels) to set

getGraphicWidth

public int getGraphicWidth()
Pixel width for sizing an external graphic.


getGraphicHeight

public int getGraphicHeight()
Pixel height for sizing an external graphic.


setGraphicOffset

public void setGraphicOffset(int xOffset,
                             int yOffset)
Sets the offset for the displacement of the external graphic. The offset is from the top-lef of the image (which is considered the point 0,0).

Parameters:
xOffset - Pixel offset along the positive x axis for displacing an external graphic.
yOffset - Pixel offset along the positive y axis for displacing an external graphic.

setBackgroundGraphicSize

public void setBackgroundGraphicSize(int backgroundWidth,
                                     int backgroundHeight)
Sets the size of the background graphic. If none of the dimensions are set, the external graphic size is used.

Parameters:
backgroundWidth - The width of the background width.
backgroundHeight - The height of the background graphic.

setBackgroundHeight

public void setBackgroundHeight(int backgroundHeight)
The height of the background graphic. If not provided, the graphicHeight will be used.


getBackgroundHeight

public int getBackgroundHeight()
The height of the background graphic.


setBackgroundWidth

public void setBackgroundWidth(int backgroundWidth)
The width of the background width. If not provided, the graphicWidth will be used.


getBackgroundWidth

public int getBackgroundWidth()
The width of the background width.


setBackgroundGraphic

public void setBackgroundGraphic(String graphicURL)
Url to a graphic to be used as the background under an externalGraphic.


getBackgroundGraphic

public String getBackgroundGraphic()
Url to a graphic to be used as the background under an externalGraphic.


setBackgroundOffset

public void setBackgroundOffset(int backgroundXOffset,
                                int backgroundYOffset)
Sets the offset for the displacement of the background graphic. The offset is from the top-left of the image (which is considered the point 0,0).

Parameters:
backgroundXOffset - Pixel offset along the positive x axis for displacing an background graphic.
backgroundYOffset - Pixel offset along the positive y axis for displacing an background graphic.

setGraphicZIndex

public void setGraphicZIndex(int graphicZIndex)
The integer z-index value to use in rendering.


getGraphicZIndex

public int getGraphicZIndex()
The integer z-index value to use in rendering.


setBackgroundGraphicZIndex

public void setBackgroundGraphicZIndex(int backgroundGraphicZIndex)
The integer z-index value to use in rendering the background graphic. Usually is a number smaller then the GraphicZIndex, so the background can be behind the feature graphic.


getBackgroundGraphicZIndex

public int getBackgroundGraphicZIndex()
The integer z-index value to use in rendering the background graphic.


setStrokeOpacity

public void setStrokeOpacity(double strokeOpacity)
Stroke opacity (0-1). Default is 1.


getStrokeOpacity

public double getStrokeOpacity()

setLabel

public void setLabel(String label)
The text for an optional label. For browsers that use the canvas renderer, this requires either fillText or mozDrawText to be available.

Note: you can set a custom label for each feature added to a layer by using tags in the label, and setting attributes using Attributes. For example, set the style.label to "${customLabel}", then, for each feature added to the layer, add an "customLabel" attribute with

attributes.setAttribute("customLabel","myLabel for this specific feature")

Note: this can also be used in any style field of type String, such as fillColor, fontColor, etc


setFontColor

public void setFontColor(String fontColor)
The font color for the label, to be provided like CSS.


setFontSize

public void setFontSize(String fontSize)
The font size for the label, to be provided like in CSS.


setFontFamily

public void setFontFamily(String fontFamily)
The font family for the label, to be provided like in CSS.


setFontWeight

public void setFontWeight(String fontWeight)
The font weight for the label, to be provided like in CSS.


setLabelAlign

public void setLabelAlign(String align)
Sets the Label alignment string directly. This specifies the insertion point relative to the text. It is a string composed of two characters.

The first character is for the horizontal alignment, the second for the vertical alignment.

Valid values for horizontal alignment: 'l'=left, 'c'=center, 'r'=right. Valid values for vertical alignment: 't'=top, 'm'=middle, 'b'=bottom. Example values: 'lt', 'cm', 'rb'. The canvas renderer does not support vertical alignment, it will always use 'b'.


getLabelAlign

public String getLabelAlign()
Vertical Label alignment. This specifies the insertion point relative to the text.


getStrokeLinecap

public String getStrokeLinecap()
Stroke linecap.


setStrokeLinecap

public void setStrokeLinecap(String strokeLinecap)
Directly sets the StrokeLineCap string. Default is 'round'. [butt | round | square]


setStrokeDashstyle

public void setStrokeDashstyle(String strokeDashstyle)
Directly sets the stroke dash style string. Default is Default is 'solid'. [dot | dash | dashdot | longdash | longdashdot | solid]


getStrokeDashstyle

public String getStrokeDashstyle()
Stroke dash style.


setFill

public void setFill(boolean fill)
Set to false if no fill is desired.


getFill

public boolean getFill()
Set to false if no fill is desired.


setStroke

public void setStroke(boolean stroke)
Set to false if no stroke is desired.


getStroke

public boolean getStroke()
Set to false if no stroke is desired.


setGraphic

public void setGraphic(boolean graphic)
Set to false if no graphic is desired.


getGraphic

public boolean getGraphic()
Set to false if no graphic is desired.


setCursor

public void setCursor(String cursor)
Cursor. Default is ''.


getCursor

public String getCursor()
Cursor.


setGraphicName

public void setGraphicName(String graphicName)
Directly sets the named graphic to use when rendering points. Default is 'circle'.

Supported values include 'circle' (default), 'square', 'star', 'x', 'cross', 'triangle'.


getGraphicName

public String getGraphicName()
Named graphic to use when rendering points. Supported values include 'circle' (default), 'square', 'star', 'x', 'cross', 'triangle'.


setGraphicTitle

public void setGraphicTitle(String graphicTitle)
Tooltip for an external graphic. Only supported in Firefox and Internet Explorer.


getGraphicTitle

public String getGraphicTitle()
Tooltip for an external graphic. Only supported in Firefox and Internet Explorer.


narrowToOpenLayersStyle

public static Style narrowToOpenLayersStyle(JSObject element)


Copyright © 2011 sourceforge. All Rights Reserved.