net.refractions.udig.ui
Class Drawing

java.lang.Object
  extended by net.refractions.udig.ui.Drawing

public final class Drawing
extends java.lang.Object

Drawing utility package - make your own previews and glyphs!

Since:
0.6.0
Author:
jones

Method Summary
static Drawing create()
          Retrieve the default Drawing implementation.
static ViewportGraphics createGraphics(GC gc, Display display, java.awt.Dimension displaySize)
          Creates a ViewportGraphics object based backed by SWT.
static ViewportGraphics createGraphics(java.awt.Graphics2D graphics)
          Creates a ViewportGraphics object based backed by SWT.
 void drawDirect(Image image, Display display, SimpleFeature feature, Style style)
          Used to draw a freature directly onto the provided image.
 void drawFeature(ViewportGraphics graphics, SimpleFeature feature, java.awt.geom.AffineTransform worldToScreenTransform)
           
 void drawFeature(ViewportGraphics graphics, SimpleFeature feature, java.awt.geom.AffineTransform worldToScreenTransform, boolean drawVertices, MathTransform mt)
           
 void drawFeature(ViewportGraphics graphics, SimpleFeature feature, java.awt.geom.AffineTransform worldToScreenTransform, boolean drawVertices, Symbolizer[] symbs, MathTransform mt)
           
 void drawFeature(ViewportGraphics graphics, SimpleFeature feature, java.awt.geom.AffineTransform worldToScreenTransform, boolean drawVertices, Symbolizer symbolizer, MathTransform mathTransform, LiteShape shape)
           
 void drawFeature(ViewportGraphics graphics, SimpleFeature feature, java.awt.geom.AffineTransform worldToScreenTransform, Style style)
           
 SimpleFeature feature(Geometry geom)
          Just a convinient method to create feature from geometry.
static Symbolizer[] getSymbolizers(java.lang.Class<? extends Geometry> type, java.awt.Color baseColor)
           
static Symbolizer[] getSymbolizers(java.lang.Class<? extends Geometry> type, java.awt.Color baseColor, boolean useTransparency)
           
 LineString line(int[] xy)
          Generate LineStrings from two dimensional ordinates
 MultiLineString lines(int[][] xy)
          Generate a MultiLineString from two dimensional ordinates
 Point point(int x, int y)
          Generate Point from two dimensional ordinates
 Polygon polygon(int[] xy)
          Convience constructor for GeometryFactory.createPolygon.
 Polygon polygon(int[] xy, int[][] holes)
          Convience constructor for GeometryFactory.createPolygon.
 LinearRing ring(int[] xy)
          Convience constructor for GeometryFactory.createLinearRing.
 SimpleFeatureType schema(java.lang.String name, java.lang.String spec)
          Create a SimpleFeatureType schema using a type short hand.
 java.awt.Point worldToPixel(Coordinate coord, java.awt.geom.AffineTransform worldToScreenTransform)
           
static java.awt.geom.AffineTransform worldToScreenTransform(BoundingBox mapExtent, java.awt.Rectangle screenSize)
          TODO summary sentence for worldToScreenTransform ...
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static Drawing create()
Retrieve the default Drawing implementation.

Returns:
Drawing ready for use

createGraphics

public static ViewportGraphics createGraphics(GC gc,
                                              Display display,
                                              java.awt.Dimension displaySize)
Creates a ViewportGraphics object based backed by SWT.

REMEMBER to dispose of graphics.

Parameters:
gc - A SWT GC object that the ViewportGraphics object will draw on.
display - The display object that will be used to create new
displaySize -
Returns:
Wrapper around a normal SWT Image

createGraphics

public static ViewportGraphics createGraphics(java.awt.Graphics2D graphics)
Creates a ViewportGraphics object based backed by SWT.

Parameters:
graphics -
Returns:
Wrapper allowing system to draw onto j2d images

drawDirect

public void drawDirect(Image image,
                       Display display,
                       SimpleFeature feature,
                       Style style)
Used to draw a freature directly onto the provided image.

SimpleFeature coordintes are in the same coordinates as the image.

You may call this method multiple times to draw several features onto the same Image (say for glyph creation).

Parameters:
image - Image to render on to
display - Needed to create Colors for image
feature - SimpleFeature to be rendered
style - Style to render feature with

drawFeature

public void drawFeature(ViewportGraphics graphics,
                        SimpleFeature feature,
                        java.awt.geom.AffineTransform worldToScreenTransform,
                        boolean drawVertices,
                        MathTransform mt)

drawFeature

public void drawFeature(ViewportGraphics graphics,
                        SimpleFeature feature,
                        java.awt.geom.AffineTransform worldToScreenTransform)

drawFeature

public void drawFeature(ViewportGraphics graphics,
                        SimpleFeature feature,
                        java.awt.geom.AffineTransform worldToScreenTransform,
                        Style style)

drawFeature

public void drawFeature(ViewportGraphics graphics,
                        SimpleFeature feature,
                        java.awt.geom.AffineTransform worldToScreenTransform,
                        boolean drawVertices,
                        Symbolizer[] symbs,
                        MathTransform mt)

drawFeature

public void drawFeature(ViewportGraphics graphics,
                        SimpleFeature feature,
                        java.awt.geom.AffineTransform worldToScreenTransform,
                        boolean drawVertices,
                        Symbolizer symbolizer,
                        MathTransform mathTransform,
                        LiteShape shape)

worldToPixel

public java.awt.Point worldToPixel(Coordinate coord,
                                   java.awt.geom.AffineTransform worldToScreenTransform)

getSymbolizers

public static Symbolizer[] getSymbolizers(java.lang.Class<? extends Geometry> type,
                                          java.awt.Color baseColor)

getSymbolizers

public static Symbolizer[] getSymbolizers(java.lang.Class<? extends Geometry> type,
                                          java.awt.Color baseColor,
                                          boolean useTransparency)

worldToScreenTransform

public static java.awt.geom.AffineTransform worldToScreenTransform(BoundingBox mapExtent,
                                                                   java.awt.Rectangle screenSize)
TODO summary sentence for worldToScreenTransform ...

Parameters:
bounds -
rectangle -
Returns:

schema

public SimpleFeatureType schema(java.lang.String name,
                                java.lang.String spec)
Create a SimpleFeatureType schema using a type short hand.

Code Example:


 new Drawing().schema("namespace.typename", "id:0,*geom:LineString,name:String,*centroid:Point");
 

Parameters:
name - namespace.name
spec -
Returns:
Generated SimpleFeatureType

feature

public SimpleFeature feature(Geometry geom)
Just a convinient method to create feature from geometry.

Parameters:
geom - the geometry to create feature from
Returns:
feature instance

point

public Point point(int x,
                   int y)
Generate Point from two dimensional ordinates

Parameters:
x -
y -
Returns:
Point

line

public LineString line(int[] xy)
Generate LineStrings from two dimensional ordinates

Parameters:
xy -
Returns:
LineStirng

lines

public MultiLineString lines(int[][] xy)
Generate a MultiLineString from two dimensional ordinates

Parameters:
xy -
Returns:
MultiLineStirng

polygon

public Polygon polygon(int[] xy)
Convience constructor for GeometryFactory.createPolygon.

The provided xy ordinates are turned into a linear rings.

Parameters:
xy - Two dimensional ordiantes.
Returns:
Polygon

polygon

public Polygon polygon(int[] xy,
                       int[][] holes)
Convience constructor for GeometryFactory.createPolygon.

The provided xy and holes are turned into linear rings.

Parameters:
xy - Two dimensional ordiantes.
holes - Holes in polygon or null.
Returns:
Polygon

ring

public LinearRing ring(int[] xy)
Convience constructor for GeometryFactory.createLinearRing.

Parameters:
xy - Two dimensional ordiantes.
Returns:
LinearRing for use with polygon