org.geotools.swt.utils
Class Utils

Object
  extended by Utils

public class Utils
extends Object

Utilities class.

Author:
Andrea Antonello (www.hydrologis.com)

Field Summary
static FilterFactory filterFactory
          The default FilterFactory to use.
static StyleBuilder sb
          The default StyleBuilder to use.
static StyleFactory styleFactory
          The default StyleFactory to use.
 
Constructor Summary
Utils()
           
 
Method Summary
static Style createFromSLD(File sld)
          Create a Style object from a definition in a SLD document
static Style createLineStyle()
          Create a default line style.
static Style createPointStyle()
          Create a default point style.
static Style createPolygonStyle()
          Create a default polygon style.
static Style createRGBStyle(GridCoverage2DReader reader)
          This method examines the names of the sample dimensions in the provided coverage looking for "red
static Style createStyle(File file, SimpleFeatureSource featureSource)
          Create a Style to display the features.
static Style createStyle2(SimpleFeatureSource featureSource)
          Create a default Style ofr the featureSource.
static String getGridAttributeName(Layer layer)
           
static boolean isGridLayer(Layer layer)
          Check if the given map layer contains a grid coverage or a grid coverage reader.
static void runGuiRunnableSafe(Runnable runner, boolean sync)
          Run a Runnable that needs to run in the Display thread.
static void setShellLocation(Shell shell)
          Sets the location of the shell to the center of the screen.
static Rectangle toAwtRectangle(Rectangle rect)
          Transform a swt Rectangle instance into an awt one.
static File toSLDFile(File file)
          Figure out if a valid SLD file is available.
static Rectangle toSwtRectangle(Rectangle rect2d)
          Transform an awt Rectangle instance into a swt one.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

styleFactory

public static StyleFactory styleFactory
The default StyleFactory to use.


filterFactory

public static FilterFactory filterFactory
The default FilterFactory to use.


sb

public static StyleBuilder sb
The default StyleBuilder to use.

Constructor Detail

Utils

public Utils()
Method Detail

setShellLocation

public static void setShellLocation(Shell shell)
Sets the location of the shell to the center of the screen.

Parameters:
shell - the shell to place.

toSwtRectangle

public static Rectangle toSwtRectangle(Rectangle rect2d)
Transform an awt Rectangle instance into a swt one.

The coordinates are rounded to integer for the swt object.

Parameters:
rect2d - The awt rectangle to map.
Returns:
an swt Rectangle object.

toAwtRectangle

public static Rectangle toAwtRectangle(Rectangle rect)
Transform a swt Rectangle instance into an awt one.

Parameters:
rect - the swt Rectangle
Returns:
a Rectangle instance with the appropriate location and size.

createStyle

public static Style createStyle(File file,
                                SimpleFeatureSource featureSource)
Create a Style to display the features.

If an SLD file is in the same directory as the shapefile then we will create the Style by processing this.


toSLDFile

public static File toSLDFile(File file)
Figure out if a valid SLD file is available.

Parameters:
file - the file to search for style sidecar file.
Returns:
the style file or null.

createFromSLD

public static Style createFromSLD(File sld)
Create a Style object from a definition in a SLD document

Parameters:
sld - the sld file.
Returns:
the created Style or null.

createStyle2

public static Style createStyle2(SimpleFeatureSource featureSource)
Create a default Style ofr the featureSource.

Parameters:
featureSource - the source on which to create the style.
Returns:
the style created.

createPolygonStyle

public static Style createPolygonStyle()
Create a default polygon style.

Returns:
the created style.

createLineStyle

public static Style createLineStyle()
Create a default line style.

Returns:
the created style.

createPointStyle

public static Style createPointStyle()
Create a default point style.

Returns:
the created style.

runGuiRunnableSafe

public static void runGuiRunnableSafe(Runnable runner,
                                      boolean sync)
Run a Runnable that needs to run in the Display thread.

Parameters:
runner - the runnable to run.
sync - if true, the runnable is run in sync mode, else in async.

createRGBStyle

public static Style createRGBStyle(GridCoverage2DReader reader)
This method examines the names of the sample dimensions in the provided coverage looking for "red...", "green..." and "blue..." (case insensitive match). If these names are not found it uses bands 1, 2, and 3 for the red, green and blue channels. It then sets up a raster symbolizer and returns this wrapped in a Style.

Parameters:
reader -
Returns:
a new Style object containing a raster symbolizer set up for RGB image

isGridLayer

public static boolean isGridLayer(Layer layer)
Check if the given map layer contains a grid coverage or a grid coverage reader.

Implementation note: we avoid referencing org.geotools.coverage.grid classes directly here so that applications dealing only with other data types are not forced to have JAI in the classpath.

Parameters:
layer - the map layer
Returns:
true if this is a grid layer; false otherwise

getGridAttributeName

public static String getGridAttributeName(Layer layer)


Copyright © 1996-2014 Geotools. All Rights Reserved.