jwo.landserf.structure
Class VectorStyles

java.lang.Object
  extended by jwo.landserf.structure.VectorStyles
All Implemented Interfaces:
Serializable

public class VectorStyles
extends Object
implements Serializable

Stores vector drawing styles such as line width, font size and position.

Version:
2.3, 22nd September, 2008.
Author:
Jo Wood
See Also:
Serialized Form

Field Summary
static int CENTRE
          Indicates label alignment above centred on point location.
static int EAST
          Indicates label alignment right of centre.
static int NORTH
          Indicates label alignment above centre.
static int NORTH_EAST
          Indicates label alignment above and right of centre.
static int NORTH_WEST
          Indicates label alignment above and left of centre.
static int QUALITY
          Indicates that rendering should be optimised for quality.
static int SOUTH
          Indicates label alignment below centre.
static int SOUTH_EAST
          Indicates label alignment below and right of centre.
static int SOUTH_WEST
          Indicates label alignment below and left of centre.
static int SPEED
          Indicates that rendering should be optimised for speed.
static int WEST
          Indicates label alignment left of centre.
 
Constructor Summary
VectorStyles()
          Creates a set of default vector styles.
VectorStyles(float pointSize, boolean isFixedPointSize, boolean isSurroundPoint, float lineWidth, boolean isFixedLineWidth, boolean isSurroundLine, float polyOpacity, Color boundColour, boolean showBoundary, int renderStyle, boolean showLabels, Color labelBgColour, Color labelFgColour, float labelFontSize, int labelPosition)
          Sets the vector styles to the given values.
VectorStyles(VectorStyles srcStyles)
          Creates a (cloned) copy of the given styles.
 
Method Summary
 Color getBoundaryColour()
          Reports the rendering colour of polygon boundaries.
 Color getLabelBackground()
          Reports the rendering colour of label backgrounds.
 float getLabelFontSize()
          Reports the label text size.
 Color getLabelForeground()
          Reports the rendering colour of label text.
 int getLabelPosition()
          Reports the label position relative to its location.
 String getLabelPositionAsText()
          Reports a textual description of the label text alignment.
 float getLineWidth()
          Reports the width of lines used when displaying vectors.
 float getPointSize()
          Reports the size of text labels used when displaying vectors.
 float getPolygonOpacity()
          Reports the polygon opacity used when displaying area objects.
 String getRenderingStyleAsText()
          Reports a textual description of the rendering style.
 int getRenderStyle()
          Reports the rendering style.
 boolean isFixedLineWidth()
          Reports whether or not line rendering style uses fixed width independently of zooming scale.
 boolean isFixedPointSize()
          Reports whether or not point rendering style uses fixed size independently of zooming scale.
 boolean isShowBoundary()
          Reports whether or not polygon boundaries are to be drawn.
 boolean isShowLabels()
          Reports whether or not vector labels are shown.
 boolean isSurroundLine()
          Reports whether or not line rendering style uses border style that surrounds line.
 boolean isSurroundPoint()
          Reports whether or not point rendering style uses border style that surrounds point.
 boolean readFile(String fileName)
          Reads vector drawing styles from a file and sets the styles accordingly.
 void setBoundaryColour(Color colour)
          Sets the rendering colour of polygon boundaries.
 void setFixedLineWidth(boolean isFixedLineWidth)
          Sets whether or not line rendering style uses fixed width independently of zooming scale.
 void setFixedPointSize(boolean isFixedPointSize)
          Sets whether or not point rendering style uses fixed size independently of zooming scale.
 void setLabelBackground(Color colour)
          Sets the rendering colour of label backgrounds.
 void setLabelFontSize(float size)
          Determines the label text size.
 void setLabelForeground(Color colour)
          Sets the rendering colour of label text.
 void setLabelPosition(int position)
          Sets the label position relative to its location.
 void setLineWidth(float lineWidth)
          Sets the width of lines used when displaying vectors.
 void setPointSize(float pointSize)
          Sets the size of text labels used when displaying vectors.
 void setPolygonOpacity(float opacity)
          Sets the polygon opacity used when displaying area objects.
 void setRenderStyle(int style)
          Sets the rendering style.
 void setShowBoundary(boolean showBoundary)
          Determines whether or not polygon boundaries are to be drawn.
 void setShowLabels(boolean showLabels)
          Determines whether or not vector labels are shown.
 void setSurroundLine(boolean isSurroundLine)
          Sets whether or not line rendering style uses border style that surrounds line.
 void setSurroundPoint(boolean isSurroundPoint)
          Sets whether or not point rendering style uses border style that surrounds point.
 boolean writeFile(String fileName)
          Writes vector drawing styles out as a file using the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORTH_WEST

public static final int NORTH_WEST
Indicates label alignment above and left of centre.

See Also:
Constant Field Values

NORTH

public static final int NORTH
Indicates label alignment above centre.

See Also:
Constant Field Values

NORTH_EAST

public static final int NORTH_EAST
Indicates label alignment above and right of centre.

See Also:
Constant Field Values

WEST

public static final int WEST
Indicates label alignment left of centre.

See Also:
Constant Field Values

CENTRE

public static final int CENTRE
Indicates label alignment above centred on point location.

See Also:
Constant Field Values

EAST

public static final int EAST
Indicates label alignment right of centre.

See Also:
Constant Field Values

SOUTH_WEST

public static final int SOUTH_WEST
Indicates label alignment below and left of centre.

See Also:
Constant Field Values

SOUTH

public static final int SOUTH
Indicates label alignment below centre.

See Also:
Constant Field Values

SOUTH_EAST

public static final int SOUTH_EAST
Indicates label alignment below and right of centre.

See Also:
Constant Field Values

SPEED

public static final int SPEED
Indicates that rendering should be optimised for speed.

See Also:
Constant Field Values

QUALITY

public static final int QUALITY
Indicates that rendering should be optimised for quality.

See Also:
Constant Field Values
Constructor Detail

VectorStyles

public VectorStyles()
Creates a set of default vector styles.


VectorStyles

public VectorStyles(VectorStyles srcStyles)
Creates a (cloned) copy of the given styles.

Parameters:
srcStyles - Styles to copy.

VectorStyles

public VectorStyles(float pointSize,
                    boolean isFixedPointSize,
                    boolean isSurroundPoint,
                    float lineWidth,
                    boolean isFixedLineWidth,
                    boolean isSurroundLine,
                    float polyOpacity,
                    Color boundColour,
                    boolean showBoundary,
                    int renderStyle,
                    boolean showLabels,
                    Color labelBgColour,
                    Color labelFgColour,
                    float labelFontSize,
                    int labelPosition)
Sets the vector styles to the given values.

Parameters:
pointSize - Point size of text labels.
isFixedPointSize - Point size will remain fixed size with zooming if true.
isSurroundPoint - If true, point features will be 'hollow' surround centre of point.
lineWidth - Width of vector lines in pixels (can be fractional).
isFixedLineWidth - Line width will remain fixed size with zooming if true.
isSurroundLine - If true, line features will be 'hollow' surround centre of line.
polyOpacity - Transparency scaled between 0 and 1 for polygon interiors.
boundColour - Boundary colour to use for polygons.
showBoundary - If true, polygon boundaries are shown.
renderStyle - Style of rendering. Either QUALITY or SPEED.
showLabels - Point labels shown if true.
labelBgColour - Label background colour.
labelFgColour - Label foreground colour.
labelFontSize - Size of label text in font point units.
labelPosition - Position of label.One of NORTH_WEST, NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST or CENTRE.
Method Detail

readFile

public boolean readFile(String fileName)
Reads vector drawing styles from a file and sets the styles accordingly. The file format is XML as generated by writeFile(). Styles not specified in the file are not changed by this method.

Parameters:
fileName - Name of file containing the drawing style information.
Returns:
True if file found and read successfully.

writeFile

public boolean writeFile(String fileName)
Writes vector drawing styles out as a file using the given name. The file can be read back in using the readFile() method.

Parameters:
fileName - Name of file to contain the drawing style information.
Returns:
True if file written successfully.

getPointSize

public float getPointSize()
Reports the size of text labels used when displaying vectors.

Returns:
Point size of vector labels in pixels.

setPointSize

public void setPointSize(float pointSize)
Sets the size of text labels used when displaying vectors. Must be at greater than 0.

Parameters:
pointSize - Point size of vector labels in pixels.

getLineWidth

public float getLineWidth()
Reports the width of lines used when displaying vectors.

Returns:
Vector line width in pixels. Can be fractional.

setLineWidth

public void setLineWidth(float lineWidth)
Sets the width of lines used when displaying vectors. Must be at greater than 0.

Parameters:
lineWidth - Vector line width in pixels. Can be fractional.

getPolygonOpacity

public float getPolygonOpacity()
Reports the polygon opacity used when displaying area objects.

Returns:
Polygon opacity scaled between 0 (transparent) and 1 (opaque).

setPolygonOpacity

public void setPolygonOpacity(float opacity)
Sets the polygon opacity used when displaying area objects.

Parameters:
opacity - Polygon opacity scaled between 0 (transparent) and 1 (opaque).

getRenderStyle

public int getRenderStyle()
Reports the rendering style. Should either be QUALITY or SPEED.

Returns:
Vector rendering style.

setRenderStyle

public void setRenderStyle(int style)
Sets the rendering style. Should either be QUALITY or SPEED.

Parameters:
style - Vector rendering style.

isFixedLineWidth

public boolean isFixedLineWidth()
Reports whether or not line rendering style uses fixed width independently of zooming scale.

Returns:
true if line rendering uses fixed width.

setFixedLineWidth

public void setFixedLineWidth(boolean isFixedLineWidth)
Sets whether or not line rendering style uses fixed width independently of zooming scale.

Parameters:
isFixedLineWidth - If true, line rendering uses fixed width, otherwise lines appear thicker when zoomed.

isFixedPointSize

public boolean isFixedPointSize()
Reports whether or not point rendering style uses fixed size independently of zooming scale.

Returns:
true if point rendering uses fixed size.

setFixedPointSize

public void setFixedPointSize(boolean isFixedPointSize)
Sets whether or not point rendering style uses fixed size independently of zooming scale.

Parameters:
isFixedPointSize - If true, point rendering uses fixed size.

isSurroundLine

public boolean isSurroundLine()
Reports whether or not line rendering style uses border style that surrounds line.

Returns:
true if line rendering uses uses surrounding border.

setSurroundLine

public void setSurroundLine(boolean isSurroundLine)
Sets whether or not line rendering style uses border style that surrounds line.

Parameters:
isSurroundLine - If true, line rendering uses uses surrounding border.

isSurroundPoint

public boolean isSurroundPoint()
Reports whether or not point rendering style uses border style that surrounds point.

Returns:
true if point rendering uses uses surrounding border.

setSurroundPoint

public void setSurroundPoint(boolean isSurroundPoint)
Sets whether or not point rendering style uses border style that surrounds point.

Parameters:
isSurroundPoint - If true, point rendering uses uses surrounding border.

getBoundaryColour

public Color getBoundaryColour()
Reports the rendering colour of polygon boundaries.

Returns:
Polygon boundary colour.

setBoundaryColour

public void setBoundaryColour(Color colour)
Sets the rendering colour of polygon boundaries.

Parameters:
colour - Polygon boundary colour to use.

isShowBoundary

public boolean isShowBoundary()
Reports whether or not polygon boundaries are to be drawn.

Returns:
True if boundaries are to be drawn.

setShowBoundary

public void setShowBoundary(boolean showBoundary)
Determines whether or not polygon boundaries are to be drawn.

Parameters:
showBoundary - If true, polygon boundaries are to be drawn.

isShowLabels

public boolean isShowLabels()
Reports whether or not vector labels are shown.

Returns:
True if point labels are shown.

setShowLabels

public void setShowLabels(boolean showLabels)
Determines whether or not vector labels are shown.

Parameters:
showLabels - If true, point labels are shown.

getLabelBackground

public Color getLabelBackground()
Reports the rendering colour of label backgrounds.

Returns:
Label background colour.

setLabelBackground

public void setLabelBackground(Color colour)
Sets the rendering colour of label backgrounds.

Parameters:
colour - Label background colour to use.

getLabelForeground

public Color getLabelForeground()
Reports the rendering colour of label text.

Returns:
Label text colour.

setLabelForeground

public void setLabelForeground(Color colour)
Sets the rendering colour of label text.

Parameters:
colour - Label text colour to use.

getLabelFontSize

public float getLabelFontSize()
Reports the label text size.

Returns:
Label text size in pixels. Can be fractional.

setLabelFontSize

public void setLabelFontSize(float size)
Determines the label text size. Should be greater than 0.

Parameters:
size - Label text size in pixels. Can be fractional.

getLabelPosition

public int getLabelPosition()
Reports the label position relative to its location.

Returns:
Label position. One of NORTH_WEST, NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST or CENTRE.

setLabelPosition

public void setLabelPosition(int position)
Sets the label position relative to its location.

Parameters:
position - Label position. Should be one of NORTH_WEST, NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST or CENTRE.

getLabelPositionAsText

public String getLabelPositionAsText()
Reports a textual description of the label text alignment.

Returns:
Text representing label alignment.

getRenderingStyleAsText

public String getRenderingStyleAsText()
Reports a textual description of the rendering style.

Returns:
Text representing rendering style.


Copyright Jo Wood, 1996-2009, last modified, 17th April, 2009