001    //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.3_testing/src/org/deegree/graphics/sld/StyleFactory.java $
002    /*----------------------------------------------------------------------------
003     This file is part of deegree, http://deegree.org/
004     Copyright (C) 2001-2009 by:
005       Department of Geography, University of Bonn
006     and
007       lat/lon GmbH
008    
009     Additional copyright notes:
010     The basic version of this class was taken from the Geotools2 project
011     (StyleBuilder.java): Geotools2 - OpenSource mapping toolkit
012     http://geotools.org
013     (C) 2002, Geotools Project Managment Committee (PMC)      
014    
015     This library is free software; you can redistribute it and/or modify it under
016     the terms of the GNU Lesser General Public License as published by the Free
017     Software Foundation; either version 2.1 of the License, or (at your option)
018     any later version.
019     This library is distributed in the hope that it will be useful, but WITHOUT
020     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
021     FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
022     details.
023     You should have received a copy of the GNU Lesser General Public License
024     along with this library; if not, write to the Free Software Foundation, Inc.,
025     59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
026    
027     Contact information:
028    
029     lat/lon GmbH
030     Aennchenstr. 19, 53177 Bonn
031     Germany
032     http://lat-lon.de/
033    
034     Department of Geography, University of Bonn
035     Prof. Dr. Klaus Greve
036     Postfach 1147, 53001 Bonn
037     Germany
038     http://www.geographie.uni-bonn.de/deegree/
039    
040     e-mail: info@deegree.org
041    ----------------------------------------------------------------------------*/
042    package org.deegree.graphics.sld;
043    
044    import java.awt.Color;
045    import java.net.MalformedURLException;
046    import java.net.URL;
047    import java.util.HashMap;
048    
049    import org.deegree.framework.util.ColorUtils;
050    import org.deegree.model.filterencoding.Expression;
051    import org.deegree.model.filterencoding.Filter;
052    import org.deegree.ogcbase.PropertyPath;
053    
054    /**
055     * An utility class designed to easy creation of style by convinience methods.
056     * 
057     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth </a>
058     */
059    public class StyleFactory {
060    
061        /**
062         * creates a <tt>ParameterValueType</tt> instance with a <tt>String</tt> as value
063         * 
064         * @param value
065         *            value of the <tt>ParameterValueType</tt>
066         * 
067         * @return the ParameterValueType created
068         */
069        public static ParameterValueType createParameterValueType( String value ) {
070            return new ParameterValueType( new Object[] { value } );
071        }
072    
073        /**
074         * creates a <tt>ParameterValueType</tt> instance with a <tt>int</tt> as value
075         * 
076         * @param value
077         *            value of the <tt>ParameterValueType</tt>
078         * 
079         * @return the ParameterValueType created
080         */
081        public static ParameterValueType createParameterValueType( int value ) {
082            return new ParameterValueType( new Object[] { "" + value } );
083        }
084    
085        /**
086         * creates a <tt>ParameterValueType</tt> instance with a <tt>String</tt> as value
087         * 
088         * @param value
089         *            value of the <tt>ParameterValueType</tt>
090         * 
091         * @return the ParameterValueType created
092         */
093        public static ParameterValueType createParameterValueType( double value ) {
094            return new ParameterValueType( new Object[] { "" + value } );
095        }
096    
097        /**
098         * creates a <tt>ParameterValueType</tt> instance with an array of <tt>Expression</tt> s as value
099         * 
100         * @param expressions
101         * 
102         * @return the the ParameterValueType created
103         */
104        public static ParameterValueType createParameterValueType( Expression[] expressions ) {
105            return new ParameterValueType( expressions );
106        }
107    
108        /**
109         * creates a CssParameter with a name and a value
110         * 
111         * @param name
112         *            name of the css parameter
113         * @param value
114         *            value of the css parameter
115         * 
116         * @return the CssParameter created
117         */
118        public static CssParameter createCssParameter( String name, String value ) {
119            ParameterValueType pvt = createParameterValueType( value );
120            return new CssParameter( name, pvt );
121        }
122    
123        /**
124         * creates a CssParameter with a name and a value
125         * 
126         * @param name
127         *            name of the css parameter
128         * @param value
129         *            value of the css parameter
130         * 
131         * @return the CssParameter created
132         */
133        public static CssParameter createCssParameter( String name, int value ) {
134            ParameterValueType pvt = createParameterValueType( value );
135            return new CssParameter( name, pvt );
136        }
137    
138        /**
139         * creates a CssParameter with a name and a value
140         * 
141         * @param name
142         *            name of the css parameter
143         * @param value
144         *            value of the css parameter
145         * 
146         * @return the CssParameter created
147         */
148        public static CssParameter createCssParameter( String name, double value ) {
149            ParameterValueType pvt = createParameterValueType( value );
150            return new CssParameter( name, pvt );
151        }
152    
153        /**
154         * creates a <tt>GraphicStroke</tt> from a <tt>Graphic</tt> object
155         * 
156         * @param graphic
157         *            <tt>Graphic</tt object
158         *
159         * @return the GraphicStroke created
160         */
161        public static GraphicStroke createGraphicStroke( Graphic graphic ) {
162            return new GraphicStroke( graphic );
163        }
164    
165        /**
166         * creates a <tt>GraphicFill</tt> from a <tt>Graphic</tt> object
167         * 
168         * @param graphic
169         *            <tt>Graphic</tt object
170         *
171         * @return the GraphicFill created
172         */
173        public static GraphicFill createGraphicFill( Graphic graphic ) {
174            return new GraphicFill( graphic );
175        }
176    
177        /**
178         * create a default Stroke that black, 1 pixel width, complete opaque, with round linejoin and square line cap
179         * 
180         * @return the Stroke created
181         */
182        public static Stroke createStroke() {
183            return createStroke( Color.BLACK, 1, "round", "square" );
184        }
185    
186        /**
187         * create a default stroke with the supplied width
188         * 
189         * @param width
190         *            the width of the line
191         * 
192         * @return the stroke created
193         */
194        public static Stroke createStroke( double width ) {
195            return createStroke( Color.BLACK, width );
196        }
197    
198        /**
199         * Create a default stroke with the supplied color
200         * 
201         * @param color
202         *            the color of the line
203         * 
204         * @return the created stroke
205         */
206        public static Stroke createStroke( Color color ) {
207            return createStroke( color, 1 );
208        }
209    
210        /**
211         * create a stroke with the passed width and color
212         * 
213         * @param color
214         *            the color of the line
215         * @param width
216         *            the width of the line
217         * 
218         * @return the created stroke
219         */
220        public static Stroke createStroke( Color color, double width ) {
221            return createStroke( color, width, "round", "square" );
222        }
223    
224        /**
225         * create a stroke with color, width, linejoin type and lineCap type.
226         * 
227         * @param color
228         *            the color of the line
229         * @param width
230         *            the width of the line
231         * @param lineJoin
232         *            the type of join to be used at points along the line
233         * @param lineCap
234         *            the type of cap to be used at the end of the line
235         * 
236         * @return the stroke created
237         */
238        public static Stroke createStroke( Color color, double width, String lineJoin, String lineCap ) {
239            return createStroke( color, width, 1, null, lineJoin, lineCap );
240        }
241    
242        /**
243         * create a stroke with color, width, linejoin type and lineCap type.
244         * 
245         * @param color
246         *            the color of the line
247         * @param width
248         *            the width of the line
249         * @param opacity
250         *            the opacity or <I>see throughness </I> of the line, 0 - is transparent, 1 is completely drawn
251         * @param dashArray
252         * @param lineJoin
253         *            the type of join to be used at points along the line
254         * @param lineCap
255         *            the type of cap to be used at the end of the line
256         * 
257         * @return the stroke created
258         */
259        public static Stroke createStroke( Color color, double width, double opacity, float[] dashArray, String lineJoin,
260                                           String lineCap ) {
261            HashMap<String, Object> cssParams = new HashMap<String, Object>();
262    
263            CssParameter stroke = createCssParameter( "stroke", ColorUtils.toHexCode( "#", color ) );
264            cssParams.put( "stroke", stroke );
265            CssParameter strokeOp = createCssParameter( "stroke-opacity", opacity );
266            cssParams.put( "stroke-opacity", strokeOp );
267            CssParameter strokeWi = createCssParameter( "stroke-width", width );
268            cssParams.put( "stroke-width", strokeWi );
269            CssParameter strokeLJ = createCssParameter( "stroke-linejoin", lineJoin );
270            cssParams.put( "stroke-linejoin", strokeLJ );
271            CssParameter strokeCap = createCssParameter( "stroke-linecap", lineCap );
272            cssParams.put( "stroke-linecap", strokeCap );
273    
274            if ( dashArray != null ) {
275                String s = "";
276                for ( int i = 0; i < dashArray.length - 1; i++ ) {
277                    s = s + dashArray[i] + ",";
278                }
279                s = s + dashArray[dashArray.length - 1];
280                CssParameter strokeDash = createCssParameter( "stroke-dasharray", s );
281                cssParams.put( "stroke-dasharray", strokeDash );
282            }
283    
284            return new Stroke( cssParams, null, null );
285        }
286    
287        /**
288         * create a dashed line of color and width
289         * 
290         * @param color
291         *            the color of the line
292         * @param width
293         *            the width of the line
294         * @param dashArray
295         *            an array of floats describing the length of line and spaces
296         * 
297         * @return the stroke created
298         */
299        public static Stroke createStroke( Color color, double width, float[] dashArray ) {
300            HashMap<String, Object> cssParams = new HashMap<String, Object>();
301    
302            CssParameter stroke = createCssParameter( "stroke", ColorUtils.toHexCode( "#", color ) );
303            cssParams.put( "stroke", stroke );
304            CssParameter strokeOp = createCssParameter( "stroke-opacity", "1" );
305            cssParams.put( "stroke-opacity", strokeOp );
306            CssParameter strokeWi = createCssParameter( "stroke-width", width );
307            cssParams.put( "stroke-width", strokeWi );
308            CssParameter strokeLJ = createCssParameter( "stroke-linejoin", "mitre" );
309            cssParams.put( "stroke-linejoin", strokeLJ );
310            CssParameter strokeCap = createCssParameter( "stroke-linecap", "butt" );
311            cssParams.put( "stroke-linecap", strokeCap );
312    
313            if ( dashArray != null ) {
314                String s = "";
315                for ( int i = 0; i < dashArray.length - 1; i++ ) {
316                    s = s + dashArray[i] + ",";
317                }
318                s = s + dashArray[dashArray.length - 1];
319                CssParameter strokeDash = createCssParameter( "stroke-dasharray", s );
320                cssParams.put( "stroke-dasharray", strokeDash );
321            }
322    
323            return new Stroke( cssParams, null, null );
324        }
325    
326        /**
327         * create a stroke with color, width and opacity supplied
328         * 
329         * @param color
330         *            the color of the line
331         * @param width
332         *            the width of the line
333         * @param opacity
334         *            the opacity or <I>see throughness </I> of the line, 0 - is transparent, 1 is completely drawn
335         * 
336         * @return the stroke created
337         */
338        public static Stroke createStroke( Color color, double width, double opacity ) {
339            return createStroke( color, width, opacity, null, "mitre", "butt" );
340        }
341    
342        /**
343         * create a default fill 50% gray
344         * 
345         * @return the fill created
346         */
347        public static Fill createFill() {
348            return createFill( Color.GRAY, 1d, null );
349        }
350    
351        /**
352         * create a fill of color
353         * 
354         * @param color
355         *            the color of the fill
356         * 
357         * @return the fill created
358         */
359        public static Fill createFill( Color color ) {
360            return createFill( color, 1d, null );
361        }
362    
363        /**
364         * create a fill with the supplied color and opacity
365         * 
366         * @param color
367         *            the color to fill with
368         * @param opacity
369         *            the opacity of the fill 0 - transparent, 1 - completly filled
370         * 
371         * @return the fill created
372         */
373        public static Fill createFill( Color color, double opacity ) {
374            return createFill( color, opacity, null );
375        }
376    
377        /**
378         * create a fill with color and opacity supplied and uses the graphic fill supplied for the fill
379         * 
380         * @param color
381         *            the foreground color
382         * @param opacity
383         *            the opacity of the fill
384         * @param fill
385         *            the graphic object to use to fill the fill
386         * 
387         * @return the fill created
388         */
389        public static Fill createFill( Color color, double opacity, GraphicFill fill ) {
390            HashMap<String, Object> cssParams = new HashMap<String, Object>();
391            CssParameter fillCo = createCssParameter( "fill", ColorUtils.toHexCode( "#", color ) );
392            cssParams.put( "fill", fillCo );
393            CssParameter fillOp = createCssParameter( "fill-opacity", opacity );
394            cssParams.put( "fill-opacity", fillOp );
395            return new Fill( cssParams, fill );
396        }
397    
398        /**
399         * create the named mark
400         * 
401         * @param wellKnownName
402         *            the wellknown name of the mark
403         * 
404         * @return the mark created
405         */
406        public static Mark createMark( String wellKnownName ) {
407            return new Mark( wellKnownName, createStroke(), createFill() );
408        }
409    
410        /**
411         * create the named mark with the colors etc supplied
412         * 
413         * @param wellKnownName
414         *            the well known name of the mark
415         * @param fillColor
416         *            the color of the mark
417         * @param borderColor
418         *            the outline color of the mark
419         * @param borderWidth
420         *            the width of the outline
421         * 
422         * @return the mark created
423         */
424        public static Mark createMark( String wellKnownName, Color fillColor, Color borderColor, double borderWidth ) {
425            Stroke stroke = createStroke( borderColor, borderWidth );
426            Fill fill = createFill( fillColor );
427            return new Mark( wellKnownName, stroke, fill );
428        }
429    
430        /**
431         * create a mark with default fill (50% gray) and the supplied outline
432         * 
433         * @param wellKnownName
434         *            the well known name of the mark
435         * @param borderColor
436         *            the outline color
437         * @param borderWidth
438         *            the outline width
439         * 
440         * @return the mark created
441         */
442        public static Mark createMark( String wellKnownName, Color borderColor, double borderWidth ) {
443            Stroke stroke = createStroke( borderColor, borderWidth );
444            Fill fill = createFill();
445            return new Mark( wellKnownName, stroke, fill );
446        }
447    
448        /**
449         * create a mark of the supplied color and a default outline (black)
450         * 
451         * @param wellKnownName
452         *            the well known name of the mark
453         * @param fillColor
454         *            the color of the mark
455         * 
456         * @return the created mark
457         */
458        public static Mark createMark( String wellKnownName, Color fillColor ) {
459            Stroke stroke = createStroke();
460            Fill fill = createFill( fillColor );
461            return new Mark( wellKnownName, stroke, fill );
462        }
463    
464        /**
465         * create a mark with the supplied fill and stroke
466         * 
467         * @param wellKnownName
468         *            the well known name of the mark
469         * @param fill
470         *            the fill to use
471         * @param stroke
472         *            the stroke to use
473         * 
474         * @return the mark created
475         */
476        public static Mark createMark( String wellKnownName, Fill fill, Stroke stroke ) {
477            return new Mark( wellKnownName, stroke, fill );
478        }
479    
480        /**
481         * wrapper for stylefactory method
482         * 
483         * @param uri
484         *            the uri of the image
485         * @param format
486         *            mime type of the image
487         * 
488         * @return the external graphic
489         * @throws MalformedURLException
490         */
491        public static ExternalGraphic createExternalGraphic( String uri, String format )
492                                throws MalformedURLException {
493            return createExternalGraphic( new URL( uri ), format );
494        }
495    
496        /**
497         * wrapper for stylefactory method
498         * 
499         * @param url
500         *            the url of the image
501         * @param format
502         *            mime type of the image
503         * 
504         * @return the external graphic
505         */
506        public static ExternalGraphic createExternalGraphic( java.net.URL url, String format ) {
507            return new ExternalGraphic( format, url );
508        }
509    
510        /**
511         * creates a graphic object
512         * 
513         * @param externalGraphic
514         *            an external graphic to use if displayable
515         * @param mark
516         *            a mark to use
517         * @param opacity -
518         *            the opacity of the graphic
519         * @param size -
520         *            the size of the graphic
521         * @param rotation -
522         *            the rotation from the top of the page of the graphic
523         * 
524         * @return the graphic created
525         */
526        public static Graphic createGraphic( ExternalGraphic externalGraphic, Mark mark, double opacity, double size,
527                                             double rotation ) {
528    
529            Object[] mae = null;
530            if ( externalGraphic != null && mark != null ) {
531                mae = new Object[] { externalGraphic, mark };
532            } else if ( externalGraphic != null ) {
533                mae = new Object[] { externalGraphic };
534            } else if ( mark != null ) {
535                mae = new Object[] { mark };
536            }
537            ParameterValueType op_pvt = createParameterValueType( opacity );
538            ParameterValueType sz_pvt = createParameterValueType( size );
539            ParameterValueType ro_pvt = createParameterValueType( rotation );
540            return new Graphic( mae, op_pvt, sz_pvt, ro_pvt );
541        }
542    
543        /**
544         * wrapper round Stylefactory Method
545         * 
546         * @return the default pointplacement
547         */
548        public static PointPlacement createPointPlacement() {
549            return new PointPlacement();
550        }
551    
552        /**
553         * wrapper round Stylefactory Method
554         * 
555         * @param anchorX -
556         *            the X coordinate
557         * @param anchorY -
558         *            the Y coordinate
559         * @param rotation -
560         *            the rotaion of the label
561         * 
562         * @return the pointplacement created
563         */
564        public static PointPlacement createPointPlacement( double anchorX, double anchorY, double rotation ) {
565            ParameterValueType pvt1 = createParameterValueType( anchorX );
566            ParameterValueType pvt2 = createParameterValueType( anchorY );
567            ParameterValueType[] anchorPoint = new ParameterValueType[] { pvt1, pvt2 };
568            ParameterValueType rot = createParameterValueType( rotation );
569            return new PointPlacement( anchorPoint, null, rot, false );
570        }
571    
572        /**
573         * wrapper round Stylefactory Method
574         * 
575         * @param anchorX -
576         *            the X coordinate
577         * @param anchorY -
578         *            the Y coordinate
579         * @param displacementX -
580         *            the X distance from the anchor
581         * @param displacementY -
582         *            the Y distance from the anchor
583         * @param rotation -
584         *            the rotaion of the label
585         * 
586         * @return the pointplacement created
587         */
588        public static PointPlacement createPointPlacement( double anchorX, double anchorY, double displacementX,
589                                                           double displacementY, double rotation ) {
590            ParameterValueType pvt1 = createParameterValueType( anchorX );
591            ParameterValueType pvt2 = createParameterValueType( anchorY );
592            ParameterValueType[] anchorPoint = new ParameterValueType[] { pvt1, pvt2 };
593    
594            ParameterValueType pvt3 = createParameterValueType( displacementX );
595            ParameterValueType pvt4 = createParameterValueType( displacementY );
596            ParameterValueType[] displacement = new ParameterValueType[] { pvt3, pvt4 };
597    
598            ParameterValueType rot = createParameterValueType( rotation );
599            return new PointPlacement( anchorPoint, displacement, rot, false );
600        }
601    
602        /**
603         * @param anchorX -
604         *            the X coordinate
605         * @param anchorY -
606         *            the Y coordinate
607         * @param displacementX -
608         *            the X distance from the anchor
609         * @param displacementY -
610         *            the Y distance from the anchor
611         * @param rotation -
612         *            the rotaion of the label
613         * @param auto -
614         *            auto positioning of the label
615         * 
616         * @return the pointplacement created
617         */
618        public static PointPlacement createPointPlacement( double anchorX, double anchorY, double displacementX,
619                                                           double displacementY, double rotation, boolean auto ) {
620            ParameterValueType pvt1 = createParameterValueType( anchorX );
621            ParameterValueType pvt2 = createParameterValueType( anchorY );
622            ParameterValueType[] anchorPoint = new ParameterValueType[] { pvt1, pvt2 };
623    
624            ParameterValueType pvt3 = createParameterValueType( displacementX );
625            ParameterValueType pvt4 = createParameterValueType( displacementY );
626            ParameterValueType[] displacement = new ParameterValueType[] { pvt3, pvt4 };
627    
628            ParameterValueType rot = createParameterValueType( rotation );
629            return new PointPlacement( anchorPoint, displacement, rot, auto );
630        }
631    
632        /**
633         * creates a <tt>LinePlacement</tt> with a user defined distance between the labels and the lines. A positive
634         * value indicates a position above the line, a negative value indicates a position below. The line width is asumed
635         * to be 2 pixel and the gap between the labels is set to factor 10 of the label width.
636         * 
637         * @param offset -
638         *            the distance between the line and the label
639         * 
640         * @return the LinePlacement created
641         */
642        public static LinePlacement createLinePlacement( double offset ) {
643    
644            ParameterValueType perpendicularOffset = createParameterValueType( offset );
645            ParameterValueType lineWidth = createParameterValueType( 2 );
646            ParameterValueType gap = createParameterValueType( 10 );
647    
648            return new LinePlacement( perpendicularOffset, lineWidth, gap );
649        }
650    
651        /**
652         * creates a <tt>LinePlacement</tt> with a relative position of the label according to the line the lines. The
653         * line width is asumed to be 2 pixel and the gap between the labels is set to factor 10 of the label width.
654         * 
655         * @param position
656         *            of the label relative to the line
657         * 
658         * @return the LinePlacement created
659         */
660        public static LinePlacement createLinePlacement( String position ) {
661    
662            ParameterValueType perpendicularOffset = createParameterValueType( position );
663            ParameterValueType lineWidth = createParameterValueType( 2 );
664            ParameterValueType gap = createParameterValueType( 10 );
665    
666            return new LinePlacement( perpendicularOffset, lineWidth, gap );
667        }
668    
669        /**
670         * creates a <tt>LinePlacement</tt> with a user defined distance between the labels and the lines. A positive
671         * value indicates a position above the line, a negative value indicates a position below.
672         * 
673         * @param offset -
674         *            the distance between the line and the label
675         * @param lineWidth -
676         *            assumed lineWidth
677         * @param gap -
678         *            gap between the labels measured in label width
679         * 
680         * @return the LinePlacement created
681         */
682        public static LinePlacement createLinePlacement( double offset, double lineWidth, int gap ) {
683    
684            ParameterValueType perpendicularOffset = createParameterValueType( offset );
685            ParameterValueType lineWidth_ = createParameterValueType( lineWidth );
686            ParameterValueType gap_ = createParameterValueType( gap );
687    
688            return new LinePlacement( perpendicularOffset, lineWidth_, gap_ );
689        }
690    
691        /**
692         * creates a <tt>LinePlacement</tt> with a user defined distance between the labels and the lines. A positive
693         * value indicates a position above the line, a negative value indicates a position below.
694         * 
695         * @param position -
696         *            relative position of the label to the line
697         * @param lineWidth -
698         *            assumed lineWidth
699         * @param gap -
700         *            gap between the labels measured in label width
701         * 
702         * @return the LinePlacement created
703         */
704        public static LinePlacement createLinePlacement( String position, double lineWidth, int gap ) {
705    
706            ParameterValueType perpendicularOffset = createParameterValueType( position );
707            ParameterValueType lineWidth_ = createParameterValueType( lineWidth );
708            ParameterValueType gap_ = createParameterValueType( gap );
709    
710            return new LinePlacement( perpendicularOffset, lineWidth_, gap_ );
711        }
712    
713        /**
714         * creates a label placement that is orientated on a line
715         * 
716         * @param linePlacement
717         *            description of the line where the lable will be orientated on
718         * @return created LabelPlacement
719         */
720        public static LabelPlacement createLabelPlacement( LinePlacement linePlacement ) {
721            return new LabelPlacement( linePlacement );
722        }
723    
724        /**
725         * creates a label placement that is orientated on a point
726         * 
727         * @param pointPlacement
728         *            description of the point where the lable will be orientated on
729         * @return created LabelPlacement
730         */
731        public static LabelPlacement createLabelPlacement( PointPlacement pointPlacement ) {
732            return new LabelPlacement( pointPlacement );
733        }
734    
735        /**
736         * create a geotools font object from a java font
737         * 
738         * @param font -
739         *            the font to be converted
740         * 
741         * @return - the deegree sld font
742         */
743        public static Font createFont( java.awt.Font font ) {
744            return createFont( font.getFamily(), font.isItalic(), font.isBold(), font.getSize() );
745        }
746    
747        /**
748         * create font of supplied family and size
749         * 
750         * @param fontFamily -
751         *            the font family
752         * @param fontSize -
753         *            the size of the font in points
754         * 
755         * @return the font object created
756         */
757        public static Font createFont( String fontFamily, double fontSize ) {
758            return createFont( fontFamily, false, false, fontSize );
759        }
760    
761        /**
762         * create font of supplied family, size and weight/style
763         * 
764         * @param fontFamily -
765         *            the font family
766         * @param italic -
767         *            should the font be italic?
768         * @param bold -
769         *            should the font be bold?
770         * @param fontSize -
771         *            the size of the font in points
772         * 
773         * @return the new font object
774         */
775        public static Font createFont( String fontFamily, boolean italic, boolean bold, double fontSize ) {
776            HashMap<String, CssParameter> cssParams = new HashMap<String, CssParameter>();
777    
778            cssParams.put( "font-family", createCssParameter( "font-family", fontFamily ) );
779            cssParams.put( "font-size", createCssParameter( "font-size", "" + fontSize ) );
780            if ( bold ) {
781                cssParams.put( "font-weight", createCssParameter( "font-weight", "bold" ) );
782            } else {
783                cssParams.put( "font-weight", createCssParameter( "font-weight", "normal" ) );
784            }
785            if ( italic ) {
786                cssParams.put( "font-style", createCssParameter( "font-style", "italic" ) );
787            } else {
788                cssParams.put( "font-style", createCssParameter( "font-style", "normal" ) );
789            }
790    
791            return new Font( cssParams );
792        }
793    
794        /**
795         * wrapper round StyleFactory method to create default halo
796         * 
797         * @return the new halo
798         */
799        public static Halo createHalo() {
800            return createHalo( createFill(), createStroke(), -1 );
801        }
802    
803        /**
804         * wrapper round StyleFactory method to create halo
805         * 
806         * @param color -
807         *            the color of the halo
808         * @param radius -
809         *            the radius of the halo use a value <= 0 for rectangle
810         * 
811         * @return the new halo
812         */
813        public static Halo createHalo( Color color, double radius ) {
814            return createHalo( createFill( color ), createStroke(), radius );
815        }
816    
817        /**
818         * wrapper round StyleFactory method to create halo
819         * 
820         * @param fillColor -
821         *            the fill color of the halo
822         * @param opacity -
823         *            the opacity of the halo fill 0 - transparent 1 - solid
824         * @param strokeColor -
825         *            the stroke color of the halo
826         * @param radius -
827         *            the radius of the halo use a value <= 0 for rectangle
828         * 
829         * @return the new halo
830         */
831        public static Halo createHalo( Color fillColor, double opacity, Color strokeColor, double radius ) {
832            Fill fill = createFill( fillColor, opacity );
833            Stroke stroke = createStroke( strokeColor );
834            return createHalo( fill, stroke, radius );
835        }
836    
837        /**
838         * wrapper round StyleFactory method to create halo
839         * 
840         * @param fill -
841         *            the fill of the halo
842         * @param stroke -
843         *            the stroke of the halo
844         * @param radius -
845         *            the radius of the halo use a value <= 0 for rectangle
846         * 
847         * @return the new halo
848         */
849        public static Halo createHalo( Fill fill, Stroke stroke, double radius ) {
850            ParameterValueType pvt = null;
851            if ( radius > 0 ) {
852                pvt = createParameterValueType( radius );
853            }
854            return new Halo( pvt, fill, stroke );
855        }
856    
857        /**
858         * create a default line symboliser
859         * 
860         * @return the new line symbolizer
861         */
862        public static LineSymbolizer createLineSymbolizer() {
863            return createLineSymbolizer( createStroke( 1 ), null );
864        }
865    
866        /**
867         * create a new line symbolizer
868         * 
869         * @param width
870         *            the width of the line
871         * 
872         * @return the new line symbolizer
873         */
874        public static LineSymbolizer createLineSymbolizer( double width ) {
875            return createLineSymbolizer( createStroke( width ), null );
876        }
877    
878        /**
879         * create a LineSymbolizer
880         * 
881         * @param color -
882         *            the color of the line
883         * 
884         * @return the new line symbolizer
885         */
886        public static LineSymbolizer createLineSymbolizer( Color color ) {
887            return createLineSymbolizer( createStroke( color ), null );
888        }
889    
890        /**
891         * create a LineSymbolizer
892         * 
893         * @param color -
894         *            the color of the line
895         * @param width -
896         *            the width of the line
897         * 
898         * @return the new line symbolizer
899         */
900        public static LineSymbolizer createLineSymbolizer( Color color, double width ) {
901            return createLineSymbolizer( createStroke( color, width ), null );
902        }
903    
904        /**
905         * create a LineSymbolizer
906         * 
907         * @param color -
908         *            the color of the line
909         * @param width -
910         *            the width of the line
911         * @param geometryPropertyName -
912         *            the name of the geometry to be drawn
913         * 
914         * @return the new line symbolizer
915         */
916        public static LineSymbolizer createLineSymbolizer( Color color, double width, PropertyPath geometryPropertyName ) {
917            return createLineSymbolizer( createStroke( color, width ), geometryPropertyName );
918        }
919    
920        /**
921         * create a LineSymbolizer
922         * 
923         * @param stroke -
924         *            the stroke to be used to draw the line
925         * 
926         * @return the new line symbolizer
927         */
928        public static LineSymbolizer createLineSymbolizer( Stroke stroke ) {
929            return createLineSymbolizer( stroke, null );
930        }
931    
932        /**
933         * create a LineSymbolizer
934         * 
935         * @param stroke -
936         *            the stroke to be used to draw the line
937         * @param geometryPropertyName -
938         *            the name of the geometry to be drawn
939         * 
940         * @return the new line symbolizer
941         */
942        public static LineSymbolizer createLineSymbolizer( Stroke stroke, PropertyPath geometryPropertyName ) {
943            return createLineSymbolizer( stroke, geometryPropertyName, 0, Double.MAX_VALUE );
944        }
945    
946        /**
947         * create a LineSymbolizer
948         * 
949         * @param stroke -
950         *            the stroke to be used to draw the line
951         * @param geometryPropertyName -
952         *            the name of the geometry to be drawn
953         * @param min
954         *            min scale denominator
955         * @param max
956         *            max scale denominator
957         * 
958         * @return the new line symbolizer
959         */
960        public static LineSymbolizer createLineSymbolizer( Stroke stroke, PropertyPath geometryPropertyName, double min,
961                                                           double max ) {
962            Geometry geom = null;
963            if ( geometryPropertyName != null ) {
964                geom = new Geometry( geometryPropertyName, null );
965            }
966            return new LineSymbolizer( stroke, geom, min, max );
967        }
968    
969        /**
970         * create a default polygon symbolizer
971         * 
972         * @return the new polygon symbolizer
973         */
974        public static PolygonSymbolizer createPolygonSymbolizer() {
975            return createPolygonSymbolizer( createStroke(), createFill() );
976        }
977    
978        /**
979         * create a polygon symbolizer
980         * 
981         * @param fillColor -
982         *            the color to fill the polygon
983         * 
984         * @return the new polygon symbolizer
985         */
986        public static PolygonSymbolizer createPolygonSymbolizer( Color fillColor ) {
987            return createPolygonSymbolizer( createStroke(), createFill( fillColor ) );
988        }
989    
990        /**
991         * create a polygon symbolizer
992         * 
993         * @param fillColor -
994         *            the color to fill the polygon
995         * @param borderColor -
996         *            the outline color of the polygon
997         * @param borderWidth -
998         *            the width of the outline
999         * 
1000         * @return the new polygon symbolizer
1001         */
1002        public static PolygonSymbolizer createPolygonSymbolizer( Color fillColor, Color borderColor, double borderWidth ) {
1003            return createPolygonSymbolizer( createStroke( borderColor, borderWidth ), createFill( fillColor ) );
1004        }
1005    
1006        /**
1007         * create a polygon symbolizer
1008         * 
1009         * @param borderColor -
1010         *            the outline color of the polygon
1011         * @param borderWidth -
1012         *            the width of the outline
1013         * 
1014         * @return the new polygon symbolizer
1015         */
1016        public static PolygonSymbolizer createPolygonSymbolizer( Color borderColor, double borderWidth ) {
1017            Stroke stroke = createStroke( borderColor, borderWidth );
1018            return createPolygonSymbolizer( stroke, createFill() );
1019        }
1020    
1021        /**
1022         * create a polygon symbolizer
1023         * 
1024         * @param stroke -
1025         *            the stroke to use to outline the polygon
1026         * @param fill -
1027         *            the fill to use to color the polygon
1028         * 
1029         * @return the new polygon symbolizer
1030         */
1031        public static PolygonSymbolizer createPolygonSymbolizer( Stroke stroke, Fill fill ) {
1032            return createPolygonSymbolizer( stroke, fill, null );
1033        }
1034    
1035        /**
1036         * create a polygon symbolizer
1037         * 
1038         * @param stroke -
1039         *            the stroke to use to outline the polygon
1040         * @param fill -
1041         *            the fill to use to color the polygon
1042         * @param geometryPropertyName -
1043         *            the name of the geometry to be drawn
1044         * 
1045         * @return the new polygon symbolizer
1046         */
1047        public static PolygonSymbolizer createPolygonSymbolizer( Stroke stroke, Fill fill, PropertyPath geometryPropertyName ) {
1048            return createPolygonSymbolizer( stroke, fill, geometryPropertyName, 0, Double.MAX_VALUE );
1049        }
1050    
1051        /**
1052         * create a polygon symbolizer
1053         * 
1054         * @param stroke -
1055         *            the stroke to use to outline the polygon
1056         * @param fill -
1057         *            the fill to use to color the polygon
1058         * @param geometryPropertyName -
1059         *            the name of the geometry to be drawn
1060         * @param min
1061         *            min scale denominator
1062         * @param max
1063         *            max scale denominator
1064         * 
1065         * @return the new polygon symbolizer
1066         */
1067        public static PolygonSymbolizer createPolygonSymbolizer( Stroke stroke, Fill fill,
1068                                                                 PropertyPath geometryPropertyName, double min, double max ) {
1069            Geometry geom = null;
1070            if ( geometryPropertyName != null ) {
1071                geom = new Geometry( geometryPropertyName, null );
1072            }
1073            return new PolygonSymbolizer( fill, stroke, geom, min, max );
1074        }
1075    
1076        /**
1077         * create a default point symbolizer
1078         * 
1079         * @return the new point symbolizer
1080         */
1081        public static PointSymbolizer createPointSymbolizer() {
1082            Graphic graphic = createGraphic( null, null, 1, 5, 0 );
1083            return createPointSymbolizer( graphic );
1084        }
1085    
1086        /**
1087         * create a point symbolizer
1088         * 
1089         * @param graphic -
1090         *            the graphic object to draw at the point
1091         * 
1092         * @return the new point symbolizer
1093         */
1094        public static PointSymbolizer createPointSymbolizer( Graphic graphic ) {
1095            return createPointSymbolizer( graphic, null );
1096        }
1097    
1098        /**
1099         * create a point symbolizer
1100         * 
1101         * @param graphic -
1102         *            the graphic object to draw at the point
1103         * @param geometryPropertyName -
1104         *            the name of the geometry to be drawn
1105         * 
1106         * @return the new point symbolizer
1107         */
1108        public static PointSymbolizer createPointSymbolizer( Graphic graphic, PropertyPath geometryPropertyName ) {
1109            return createPointSymbolizer( graphic, geometryPropertyName, 0, Double.MAX_VALUE );
1110        }
1111    
1112        /**
1113         * create a point symbolizer
1114         * 
1115         * @param graphic -
1116         *            the graphic object to draw at the point
1117         * @param geometryPropertyName -
1118         *            the name of the geometry to be drawn
1119         * @param min
1120         *            min scale denominator
1121         * @param max
1122         *            max scale denominator
1123         * 
1124         * @return the new point symbolizer
1125         */
1126        public static PointSymbolizer createPointSymbolizer( Graphic graphic, PropertyPath geometryPropertyName,
1127                                                             double min, double max ) {
1128            Geometry geom = null;
1129            if ( geometryPropertyName != null ) {
1130                geom = new Geometry( geometryPropertyName, null );
1131            }
1132            return new PointSymbolizer( graphic, geom, min, max );
1133        }
1134    
1135        /**
1136         * create a textsymbolizer
1137         * 
1138         * @param color
1139         *            the color of the text
1140         * @param font
1141         *            the font to use
1142         * @param attributeName
1143         *            the attribute to use for the label
1144         * @param labelPlacement
1145         * 
1146         * @return the new textsymbolizer
1147         * 
1148         */
1149        public static TextSymbolizer createTextSymbolizer( Color color, Font font, String attributeName,
1150                                                           LabelPlacement labelPlacement ) {
1151            ParameterValueType label = createParameterValueType( attributeName );
1152            Fill fill = createFill( color );
1153            Halo halo = createHalo();
1154            return createTextSymbolizer( null, label, font, labelPlacement, halo, fill, 0, Double.MAX_VALUE );
1155        }
1156    
1157        /**
1158         * create a textsymbolizer
1159         * 
1160         * @param geometryPropertyName
1161         *            geometry assigned to the TextSymbolizer
1162         * @param attribute
1163         *            attribute to draw/print
1164         * @param labelPlacement
1165         *            defines the placement of the text
1166         * 
1167         * @return the new textsymbolizer
1168         * 
1169         */
1170        public static TextSymbolizer createTextSymbolizer( PropertyPath geometryPropertyName, String attribute,
1171                                                           LabelPlacement labelPlacement ) {
1172            Font font = createFont( java.awt.Font.decode( "Sans Serif" ) );
1173            return createTextSymbolizer( geometryPropertyName, attribute, font, labelPlacement, createHalo(), createFill(),
1174                                         0, Double.MAX_VALUE );
1175        }
1176    
1177        /**
1178         * create a textsymbolizer
1179         * 
1180         * @param geometryPropertyName
1181         *            geometry assigned to the TextSymbolizer
1182         * @param attribute
1183         *            attribute to draw/print
1184         * @param font
1185         *            font to use for the text
1186         * @param labelPlacement
1187         *            defines the placement of the text
1188         * @param halo
1189         *            halo/backgroud of the text
1190         * @param fill
1191         *            color, opacity of the text
1192         * @param min
1193         *            min scale denominator
1194         * @param max
1195         *            max scale denominator
1196         * 
1197         * @return the new textsymbolizer
1198         * 
1199         */
1200        public static TextSymbolizer createTextSymbolizer( PropertyPath geometryPropertyName, String attribute, Font font,
1201                                                           LabelPlacement labelPlacement, Halo halo, Fill fill, double min,
1202                                                           double max ) {
1203            Geometry geom = null;
1204            if ( geometryPropertyName != null ) {
1205                geom = new Geometry( geometryPropertyName, null );
1206            }
1207            ParameterValueType label = createParameterValueType( attribute );
1208            return createTextSymbolizer( geom, label, font, labelPlacement, halo, fill, min, max );
1209        }
1210    
1211        /**
1212         * create a textsymbolizer
1213         * 
1214         * @param geometry
1215         *            geometry assigned to the TextSymbolizer
1216         * @param label
1217         *            attribute to draw/print
1218         * @param font
1219         *            font to use for the text
1220         * @param labelPlacement
1221         *            defines the placement of the text
1222         * @param halo
1223         *            halo/backgroud of the text
1224         * @param fill
1225         *            color, opacity of the text
1226         * @param min
1227         *            min scale denominator
1228         * @param max
1229         *            max scale denominator
1230         * 
1231         * @return the new textsymbolizer
1232         * 
1233         */
1234        public static TextSymbolizer createTextSymbolizer( Geometry geometry, ParameterValueType label, Font font,
1235                                                           LabelPlacement labelPlacement, Halo halo, Fill fill, double min,
1236                                                           double max ) {
1237            return new TextSymbolizer( geometry, label, font, labelPlacement, halo, fill, min, max );
1238        }
1239    
1240        /**
1241         * Throws an UnsupportedOperationException, but should create a textsymbolizer which doesn't change
1242         * 
1243         * @param color
1244         *            the color of the text
1245         * @param font
1246         *            the font to use
1247         * @param label
1248         *            the label to use
1249         * 
1250         * @return the new textsymbolizer
1251         */
1252        @SuppressWarnings("unused")
1253        public static TextSymbolizer createStaticTextSymbolizer( Color color, Font font, String label ) {
1254            throw new UnsupportedOperationException( "method createStaticTextSymbolizer is not implemented yet" );
1255        }
1256    
1257        /**
1258         * Throws an UnsupportedOperationException, but should create a textsymbolizer which doesn't change
1259         * 
1260         * @param color
1261         *            the color of the text
1262         * @param fonts
1263         *            an array of fonts to use from the first to last
1264         * @param label
1265         *            the label to use
1266         * 
1267         * @return the new textsymbolizer
1268         */
1269        @SuppressWarnings("unused")
1270        public static TextSymbolizer createStaticTextSymbolizer( Color color, Font[] fonts, String label ) {
1271            throw new UnsupportedOperationException( "method createStaticTextSymbolizer is not implemented yet" );
1272        }
1273    
1274        /**
1275         * create a simple styling rule
1276         * 
1277         * @param symbolizer -
1278         *            the symbolizer to use
1279         * 
1280         * @return the new rule
1281         */
1282        public static Rule createRule( Symbolizer symbolizer ) {
1283            return createRule( symbolizer, 0, Double.MAX_VALUE );
1284        }
1285    
1286        /**
1287         * reate a simple styling rule
1288         * 
1289         * @param symbolizers -
1290         *            an array of symbolizers to use
1291         * 
1292         * @return the new rule
1293         */
1294        public static Rule createRule( Symbolizer[] symbolizers ) {
1295            return createRule( symbolizers, 0, Double.MAX_VALUE );
1296        }
1297    
1298        /**
1299         * create a simple styling rule, see the SLD Spec for more details of scaleDenominators
1300         * 
1301         * @param symbolizer -
1302         *            the symbolizer to use
1303         * @param minScaleDenominator -
1304         *            the minimim scale to draw the feature at
1305         * @param maxScaleDenominator -
1306         *            the maximum scale to draw the feature at
1307         * 
1308         * @return the new rule
1309         */
1310        public static Rule createRule( Symbolizer symbolizer, double minScaleDenominator, double maxScaleDenominator ) {
1311            return createRule( new Symbolizer[] { symbolizer }, minScaleDenominator, maxScaleDenominator );
1312        }
1313    
1314        /**
1315         * create a simple styling rule, see the SLD Spec for more details of scaleDenominators
1316         * 
1317         * @param symbolizers -
1318         *            an array of symbolizers to use
1319         * @param minScaleDenominator -
1320         *            the minimim scale to draw the feature at
1321         * @param maxScaleDenominator -
1322         *            the maximum scale to draw the feature at
1323         * 
1324         * @return the new rule
1325         */
1326        public static Rule createRule( Symbolizer[] symbolizers, double minScaleDenominator, double maxScaleDenominator ) {
1327            return createRule( symbolizers, "default", "default", "default", minScaleDenominator, maxScaleDenominator );
1328        }
1329    
1330        /**
1331         * create a simple styling rule, see the SLD Spec for more details of scaleDenominators
1332         * 
1333         * @param symbolizers -
1334         *            an array of symbolizers to use
1335         * @param name -
1336         *            name of the rule
1337         * @param title -
1338         *            title of the rule
1339         * @param abstract_ -
1340         *            text describing throws rule
1341         * @param minScaleDenominator -
1342         *            the minimim scale to draw the feature at
1343         * @param maxScaleDenominator -
1344         *            the maximum scale to draw the feature at
1345         * 
1346         * @return the new rule
1347         */
1348        public static Rule createRule( Symbolizer[] symbolizers, String name, String title, String abstract_,
1349                                       double minScaleDenominator, double maxScaleDenominator ) {
1350            return createRule( symbolizers, name, title, abstract_, null, null, false, minScaleDenominator,
1351                               maxScaleDenominator );
1352        }
1353    
1354        /**
1355         * create a complex styling rule, see the SLD Spec for more details of scaleDenominators
1356         * 
1357         * @param symbolizers -
1358         *            an array of symbolizers to use
1359         * @param name -
1360         *            name of the rule
1361         * @param title -
1362         *            title of the rule
1363         * @param abstract_ -
1364         *            text describing throws rule
1365         * @param legendGraphic
1366         * @param filter -
1367         *            filter to use with the rule
1368         * @param elseFilter -
1369         *            true if the passed is an ElseFilter (see SLD spec)
1370         * @param minScaleDenominator -
1371         *            the minimim scale to draw the feature at
1372         * @param maxScaleDenominator -
1373         *            the maximum scale to draw the feature at
1374         * 
1375         * @return the new rule
1376         */
1377        public static Rule createRule( Symbolizer[] symbolizers, String name, String title, String abstract_,
1378                                       LegendGraphic legendGraphic, Filter filter, boolean elseFilter,
1379                                       double minScaleDenominator, double maxScaleDenominator ) {
1380            return new Rule( symbolizers, name, title, abstract_, legendGraphic, filter, elseFilter, minScaleDenominator,
1381                             maxScaleDenominator );
1382        }
1383    
1384        /**
1385         * create a Feature type styler
1386         * 
1387         * @param symbolizer -
1388         *            the symbolizer to use
1389         * 
1390         * @return the new feature type styler
1391         */
1392        public static FeatureTypeStyle createFeatureTypeStyle( Symbolizer symbolizer ) {
1393            return createFeatureTypeStyle( null, symbolizer, 0, Double.MAX_VALUE );
1394        }
1395    
1396        /**
1397         * create a Feature type styler see the SLD Spec for more details of scaleDenominators
1398         * 
1399         * @param symbolizer -
1400         *            the symbolizer to use
1401         * @param minScaleDenominator -
1402         *            the minimim scale to draw the feature at
1403         * @param maxScaleDenominator -
1404         *            the maximum scale to draw the feature at
1405         * 
1406         * @return the new feature type styler
1407         */
1408        public static FeatureTypeStyle createFeatureTypeStyle( Symbolizer symbolizer, double minScaleDenominator,
1409                                                               double maxScaleDenominator ) {
1410            return createFeatureTypeStyle( null, symbolizer, minScaleDenominator, maxScaleDenominator );
1411        }
1412    
1413        /**
1414         * create a Feature type styler see the SLD Spec for more details of scaleDenominators
1415         * 
1416         * @param symbolizers -
1417         *            an array of symbolizers to use
1418         * @param minScaleDenominator -
1419         *            the minimim scale to draw the feature at
1420         * @param maxScaleDenominator -
1421         *            the maximum scale to draw the feature at
1422         * 
1423         * @return the new feature type styler
1424         */
1425        public static FeatureTypeStyle createFeatureTypeStyle( Symbolizer[] symbolizers, double minScaleDenominator,
1426                                                               double maxScaleDenominator ) {
1427            return createFeatureTypeStyle( null, symbolizers, minScaleDenominator, maxScaleDenominator );
1428        }
1429    
1430        /**
1431         * create a Feature type styler
1432         * 
1433         * @param featureTypeStyleName -
1434         *            name for the feature type styler
1435         * @param symbolizer -
1436         *            the symbolizer to use
1437         * 
1438         * @return the new feature type styler
1439         */
1440        public static FeatureTypeStyle createFeatureTypeStyle( String featureTypeStyleName, Symbolizer symbolizer ) {
1441            return createFeatureTypeStyle( featureTypeStyleName, symbolizer, 0, Double.MAX_VALUE );
1442        }
1443    
1444        /**
1445         * create a Feature type styler
1446         * 
1447         * @param featureTypeStyleName -
1448         *            name for the feature type styler
1449         * @param symbolizers -
1450         *            an array of symbolizers to use
1451         * 
1452         * @return the new feature type styler
1453         */
1454        public static FeatureTypeStyle createFeatureTypeStyle( String featureTypeStyleName, Symbolizer[] symbolizers ) {
1455            return createFeatureTypeStyle( featureTypeStyleName, symbolizers, 0, Double.MAX_VALUE );
1456        }
1457    
1458        /**
1459         * create a Feature type styler see the SLD Spec for more details of scaleDenominators
1460         * 
1461         * @param featureTypeStyleName -
1462         *            name for the feature type styler
1463         * @param symbolizer -
1464         *            the symbolizer to use
1465         * @param minScaleDenominator -
1466         *            the minimim scale to draw the feature at
1467         * @param maxScaleDenominator -
1468         *            the maximum scale to draw the feature at
1469         * 
1470         * @return the new feature type styler
1471         */
1472        public static FeatureTypeStyle createFeatureTypeStyle( String featureTypeStyleName, Symbolizer symbolizer,
1473                                                               double minScaleDenominator, double maxScaleDenominator ) {
1474            return createFeatureTypeStyle( featureTypeStyleName, new Symbolizer[] { symbolizer }, minScaleDenominator,
1475                                           maxScaleDenominator );
1476        }
1477    
1478        /**
1479         * create a Feature type styler see the SLD Spec for more details of scaleDenominators
1480         * 
1481         * @param featureTypeStyleName -
1482         *            name for the feature type styler
1483         * @param symbolizers -
1484         *            an array of symbolizers to use
1485         * @param minScaleDenominator -
1486         *            the minimim scale to draw the feature at
1487         * @param maxScaleDenominator -
1488         *            the maximum scale to draw the feature at
1489         * 
1490         * @return the new feature type styler
1491         */
1492        public static FeatureTypeStyle createFeatureTypeStyle( String featureTypeStyleName, Symbolizer[] symbolizers,
1493                                                               double minScaleDenominator, double maxScaleDenominator ) {
1494            Rule rule = createRule( symbolizers, minScaleDenominator, maxScaleDenominator );
1495    
1496            return createFeatureTypeStyle( featureTypeStyleName, rule );
1497        }
1498    
1499        /**
1500         * create a Feature type styler
1501         * 
1502         * @param rule -
1503         *            rule contained in the featureTypeStyle
1504         * 
1505         * @return the new feature type styler
1506         */
1507        public static FeatureTypeStyle createFeatureTypeStyle( Rule rule ) {
1508    
1509            return createFeatureTypeStyle( new Rule[] { rule } );
1510        }
1511    
1512        /**
1513         * create a Feature type styler
1514         * 
1515         * @param rules -
1516         *            rules contained in the featureTypeStyle
1517         * 
1518         * @return the new feature type styler
1519         */
1520        public static FeatureTypeStyle createFeatureTypeStyle( Rule[] rules ) {
1521    
1522            return createFeatureTypeStyle( null, rules );
1523        }
1524    
1525        /**
1526         * create a Feature type styler
1527         * 
1528         * @param featureTypeStyleName -
1529         *            name for the feature type styler
1530         * @param rule -
1531         *            rule contained in the featureTypeStyle
1532         * 
1533         * @return the new feature type styler
1534         */
1535        public static FeatureTypeStyle createFeatureTypeStyle( String featureTypeStyleName, Rule rule ) {
1536    
1537            return createFeatureTypeStyle( featureTypeStyleName, new Rule[] { rule } );
1538        }
1539    
1540        /**
1541         * create a Feature type styler
1542         * 
1543         * @param featureTypeStyleName -
1544         *            name for the feature type styler
1545         * @param rules -
1546         *            rules contained in the featureTypeStyle
1547         * 
1548         * @return the new feature type styler
1549         */
1550        public static FeatureTypeStyle createFeatureTypeStyle( String featureTypeStyleName, Rule[] rules ) {
1551    
1552            return createFeatureTypeStyle( featureTypeStyleName, null, null, null, rules );
1553        }
1554    
1555        /**
1556         * create a Feature type styler
1557         * 
1558         * @param featureTypeStyleName -
1559         *            name for the feature type styler
1560         * @param featureTypeName -
1561         *            name of the feature type the Feature type style shall be assigned to
1562         * @param title -
1563         *            title of the FeatureTypeStyle
1564         * @param abstract_ -
1565         *            text describing the FeatureTypeStyle
1566         * @param rules -
1567         *            rules contained in the featureTypeStyle
1568         * 
1569         * @return the new feature type styler
1570         */
1571        public static FeatureTypeStyle createFeatureTypeStyle( String featureTypeStyleName, String title, String abstract_,
1572                                                               String featureTypeName, Rule[] rules ) {
1573    
1574            return new FeatureTypeStyle( featureTypeStyleName, title, abstract_, featureTypeName, null, rules );
1575        }
1576    
1577        /**
1578         * create a new style
1579         * 
1580         * @param symbolizer -
1581         *            the symbolizer to use
1582         * 
1583         * @return the new style
1584         */
1585        public static AbstractStyle createStyle( Symbolizer symbolizer ) {
1586            return createStyle( null, symbolizer, 0, Double.MAX_VALUE );
1587        }
1588    
1589        /**
1590         * create a new style with name 'default'
1591         * 
1592         * @param symbolizer -
1593         *            the symbolizer to use
1594         * @param minScaleDenominator -
1595         *            the minimim scale to draw the feature at
1596         * @param maxScaleDenominator -
1597         *            the maximum scale to draw the feature at
1598         * 
1599         * @return the new style
1600         */
1601        public static AbstractStyle createStyle( Symbolizer symbolizer, double minScaleDenominator,
1602                                                 double maxScaleDenominator ) {
1603            return createStyle( "default", symbolizer, minScaleDenominator, maxScaleDenominator );
1604        }
1605    
1606        /**
1607         * create a new style
1608         * 
1609         * @param name -
1610         *            the name of the style
1611         * @param symbolizer -
1612         *            the symbolizer to use
1613         * 
1614         * @return the new style
1615         */
1616        public static AbstractStyle createStyle( String name, Symbolizer symbolizer ) {
1617            return createStyle( name, symbolizer, 0, Double.MAX_VALUE );
1618        }
1619    
1620        /**
1621         * create a new style
1622         * 
1623         * @param name -
1624         *            the name of the style
1625         * @param symbolizer -
1626         *            the symbolizer to use
1627         * @param minScaleDenominator -
1628         *            the minimim scale to draw the feature at
1629         * @param maxScaleDenominator -
1630         *            the maximum scale to draw the feature at
1631         * 
1632         * @return the new style
1633         */
1634        public static AbstractStyle createStyle( String name, Symbolizer symbolizer, double minScaleDenominator,
1635                                                 double maxScaleDenominator ) {
1636            // create the feature type style
1637            FeatureTypeStyle fts = createFeatureTypeStyle( name, symbolizer, minScaleDenominator, maxScaleDenominator );
1638    
1639            return createStyle( name, null, null, fts );
1640        }
1641    
1642        /**
1643         * create a style
1644         * 
1645         * @param name -
1646         *            the name of the style
1647         * @param featureTypeName -
1648         *            name of the feature type the Feature type style shall be assigned to
1649         * @param title -
1650         *            title of the FeatureTypeStyle
1651         * @param abstract_ -
1652         *            text describing the FeatureTypeStyle
1653         * @param rules -
1654         *            rules contained in the featureTypeStyle
1655         * 
1656         * @return the new style
1657         */
1658        public static AbstractStyle createStyle( String name, String title, String abstract_, String featureTypeName,
1659                                                 Rule[] rules ) {
1660    
1661            FeatureTypeStyle fts = createFeatureTypeStyle( name, title, abstract_, featureTypeName, rules );
1662            return createStyle( name, null, null, fts );
1663        }
1664    
1665        /**
1666         * create a new style
1667         * 
1668         * @param name -
1669         *            the name of the style
1670         * @param title -
1671         *            title of the style
1672         * @param abstract_ -
1673         *            text describing the style
1674         * @param featureTypeStyle -
1675         *            featureTypeStyle
1676         * 
1677         * @return the new style
1678         */
1679        public static AbstractStyle createStyle( String name, String title, String abstract_,
1680                                                 FeatureTypeStyle featureTypeStyle ) {
1681            return createStyle( name, title, abstract_, new FeatureTypeStyle[] { featureTypeStyle } );
1682        }
1683    
1684        /**
1685         * create a new style
1686         * 
1687         * @param name -
1688         *            the name of the style
1689         * @param title -
1690         *            title of the style
1691         * @param abstract_ -
1692         *            text describing the style
1693         * @param featureTypeStyles -
1694         *            featureTypeStyle
1695         * 
1696         * @return the new style
1697         */
1698        public static AbstractStyle createStyle( String name, String title, String abstract_,
1699                                                 FeatureTypeStyle[] featureTypeStyles ) {
1700            return new UserStyle( name, title, abstract_, false, featureTypeStyles );
1701        }
1702    
1703        /**
1704         * creates a style with name 'defaultPoint' for rendering point geometries
1705         * 
1706         * @param wellKnownName
1707         *            the well known name of the mark
1708         * @param fillColor
1709         *            the color of the mark
1710         * @param borderColor
1711         *            the outline color of the mark
1712         * @param borderWidth
1713         *            the width of the outline
1714         * @param opacity -
1715         *            the opacity of the graphic
1716         * @param size -
1717         *            the size of the graphic
1718         * @param rotation -
1719         *            the rotation from the top of the page of the graphic
1720         * @param min -
1721         *            the minimim scale to draw the feature at
1722         * @param max -
1723         *            the maximum scale to draw the feature at
1724         * 
1725         * @return the style created
1726         */
1727        public static AbstractStyle createPointStyle( String wellKnownName, Color fillColor, Color borderColor,
1728                                                      double borderWidth, double opacity, double size, double rotation,
1729                                                      double min, double max ) {
1730            Mark mark = createMark( wellKnownName, fillColor, borderColor, borderWidth );
1731            Graphic graphic = createGraphic( null, mark, opacity, size, rotation );
1732            Symbolizer symbolizer = createPointSymbolizer( graphic, null, min, max );
1733            return createStyle( "defaultPoint", symbolizer );
1734        }
1735    
1736        /**
1737         * creates a style with name 'defaultLine' for rendering line geometries
1738         * 
1739         * @param color
1740         *            the line color
1741         * @param width
1742         *            the width of the line
1743         * @param opacity -
1744         *            the opacity of the line
1745         * @param min -
1746         *            the minimim scale to draw the feature at
1747         * @param max -
1748         *            the maximum scale to draw the feature at
1749         * 
1750         * @return the style created
1751         */
1752        public static AbstractStyle createLineStyle( Color color, double width, double opacity, double min, double max ) {
1753            Stroke stroke = createStroke( color, width, opacity );
1754            Symbolizer symbolizer = createLineSymbolizer( stroke, null, min, max );
1755            return createStyle( "defaultLine", symbolizer );
1756        }
1757    
1758        /**
1759         * creates a style with name 'defaultPolygon' for rendering polygon geometries
1760         * 
1761         * @param fillColor -
1762         *            the fill color of the polygon
1763         * @param fillOpacity -
1764         *            the fill opacity of the polygon
1765         * @param strokeColor -
1766         *            the line color
1767         * @param strokeWidth -
1768         *            the width of the line
1769         * @param strokeOpacity -
1770         *            the opacity of the line
1771         * @param min -
1772         *            the minimim scale to draw the feature at
1773         * @param max -
1774         *            the maximum scale to draw the feature at
1775         * 
1776         * @return the style created
1777         */
1778        public static AbstractStyle createPolygonStyle( Color fillColor, double fillOpacity, Color strokeColor,
1779                                                        double strokeWidth, double strokeOpacity, double min, double max ) {
1780            Stroke stroke = createStroke( strokeColor, strokeWidth, strokeOpacity );
1781            Fill fill = createFill( fillColor, fillOpacity );
1782            Symbolizer symbolizer = createPolygonSymbolizer( stroke, fill, null, min, max );
1783            return createStyle( "defaultPolygon", symbolizer );
1784        }
1785    
1786        /**
1787         * Throws an UnsupportedOperationException, but should create a style with name 'defaultPoint' for rendering point
1788         * geometries. The style contains 1..n rules depending on the value range and the number of steps within it. So it
1789         * is possible to create a style that creates different rendering depending on the value of one feature attribute.
1790         * <p>
1791         * there will be a linear interpolation between colors, size and width of the first and the last rule considering
1792         * the number of passed steps (rules)
1793         * 
1794         * @param wellKnownNames -
1795         *            list of well known names of the mark. the first field will be assigned to the starting rule the last
1796         *            to the ending rule.
1797         * @param startFillColor -
1798         *            the color of the mark of the first rule
1799         * @param endFillColor -
1800         *            the color of the mark of the last rule
1801         * @param startBorderColor -
1802         *            the outline color of the mark of the first rule
1803         * @param endBorderColor -
1804         *            the outline color of the mark of the last rule
1805         * @param startBorderWidth -
1806         *            the width of the outline of the first rule
1807         * @param endBorderWidth -
1808         *            the width of the outline of the last rule
1809         * @param opacity -
1810         *            the opacity of the graphic
1811         * @param startSize -
1812         *            the size of the graphic of the first rule
1813         * @param endSize -
1814         *            the size of the graphic of the last rule
1815         * @param rotation -
1816         *            the rotation from the top of the page of the graphic
1817         * @param min -
1818         *            the minimim scale to draw the feature at
1819         * @param max -
1820         *            the maximum scale to draw the feature at
1821         * @param featurePropertyName -
1822         *            name of the feature property that determines the selection of the rule for drawing
1823         * @param numberOfSteps -
1824         *            number of steps used for the interpolation between first and last value. It is identical with the
1825         *            number of rules that will be created.
1826         * 
1827         * @return the style created
1828         */
1829        @SuppressWarnings("unused")
1830        public static AbstractStyle createPointStyle( String[] wellKnownNames, Color startFillColor, Color endFillColor,
1831                                                      Color startBorderColor, Color endBorderColor,
1832                                                      double startBorderWidth, double endBorderWidth, double opacity,
1833                                                      double startSize, double endSize, double rotation, double min,
1834                                                      double max, String featurePropertyName, int numberOfSteps ) {
1835            throw new UnsupportedOperationException( "method createPointStyle is not implemented yet" );
1836        }
1837    
1838        /**
1839         * Throws an UnsupportedOperationException, but should create a style with name 'defaultLine' for rendering line geometries. The style contains 1..n rules depending on
1840         * the value range and the number of steps within it. So it is possible to create a style that creates different
1841         * rendering depending on the value of one feature attribute.
1842         * <p>
1843         * there will be a linear interpolation between colors, size and width of the first and the last rule considering
1844         * the number of passed steps (rules)
1845         * 
1846         * @param startColor -
1847         *            the color of the first rule
1848         * @param endColor -
1849         *            the color of the last rule
1850         * @param startWidth -
1851         *            the width of the line of the first rule
1852         * @param endWidth -
1853         *            the width of the line of the last rule
1854         * @param opacity -
1855         *            the opacity of the graphic
1856         * @param min -
1857         *            the minimim scale to draw the feature at
1858         * @param max -
1859         *            the maximum scale to draw the feature at
1860         * @param featurePropertyName -
1861         *            name of the feature property that determines the selection of the rule for drawing
1862         * @param numberOfSteps -
1863         *            number of steps used for the interpolation between first and last value. It is identical with the
1864         *            number of rules that will be created.
1865         * 
1866         * @return the style created
1867         */
1868        @SuppressWarnings("unused")
1869        public static AbstractStyle createLineStyle( Color startColor, Color endColor, double startWidth, double endWidth,
1870                                                     double opacity, double min, double max, String featurePropertyName,
1871                                                     int numberOfSteps ) {
1872            throw new UnsupportedOperationException( "method createLineStyle is not implemented yet" );
1873        }
1874    
1875        /**
1876         * Throws an UnsupportedOperationException, but should create a style with name 'defaultPoint' for rendering point geometries. The style contains 1..n rules depending
1877         * on the value range and the number of steps within it. So it is possible to create a style that creates different
1878         * rendering depending on the value of one feature attribute.
1879         * <p>
1880         * there will be a linear interpolation between colors, size and width of the first and the last rule considering
1881         * the number of passed steps (rules)
1882         * 
1883         * @param startFillColor -
1884         *            the fill color of the first rule
1885         * @param endFillColor -
1886         *            the fill color of the last rule
1887         * @param fillOpacity -
1888         *            the opacity of the fill
1889         * @param startStrokeColor -
1890         *            the line color of the first rule
1891         * @param endStrokeColor -
1892         *            the line color of the last rule
1893         * @param startStrokeWidth -
1894         *            the width of the outline of the first rule
1895         * @param endStrokeWidth -
1896         *            the width of the outline of the last rule
1897         * @param strokeOpacity -
1898         *            the opacity of the outline
1899         * @param min -
1900         *            the minimim scale to draw the feature at
1901         * @param max -
1902         *            the maximum scale to draw the feature at
1903         * @param featurePropertyName -
1904         *            name of the feature property that determines the selection of the rule for drawing
1905         * @param numberOfSteps -
1906         *            number of steps used for the interpolation between first and last value. It is identical with the
1907         *            number of rules that will be created.
1908         * 
1909         * @return the style created
1910         */
1911        @SuppressWarnings("unused")    
1912        public static AbstractStyle createPolygonStyle( Color startFillColor, Color endFillColor, double fillOpacity,
1913                                                        Color startStrokeColor, Color endStrokeColor,
1914                                                        double startStrokeWidth, double endStrokeWidth,
1915                                                        double strokeOpacity, double min, double max,
1916                                                        String featurePropertyName, int numberOfSteps ) {
1917            throw new UnsupportedOperationException( "method createPolygonStyle is not implemented yet" );
1918        }
1919    
1920        /**
1921         * create a new default style
1922         * 
1923         * @return the new style
1924         */
1925        public static AbstractStyle createStyle() {
1926            return null;
1927        }
1928    
1929    }