001    //$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_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        public static TextSymbolizer createStaticTextSymbolizer( Color color, Font font, String label ) {
1253            throw new UnsupportedOperationException( "method createStaticTextSymbolizer is not implemented yet" );
1254        }
1255    
1256        /**
1257         * Throws an UnsupportedOperationException, but should create a textsymbolizer which doesn't change
1258         * 
1259         * @param color
1260         *            the color of the text
1261         * @param fonts
1262         *            an array of fonts to use from the first to last
1263         * @param label
1264         *            the label to use
1265         * 
1266         * @return the new textsymbolizer
1267         */
1268        public static TextSymbolizer createStaticTextSymbolizer( Color color, Font[] fonts, String label ) {
1269            throw new UnsupportedOperationException( "method createStaticTextSymbolizer is not implemented yet" );
1270        }
1271    
1272        /**
1273         * create a simple styling rule
1274         * 
1275         * @param symbolizer -
1276         *            the symbolizer to use
1277         * 
1278         * @return the new rule
1279         */
1280        public static Rule createRule( Symbolizer symbolizer ) {
1281            return createRule( symbolizer, 0, Double.MAX_VALUE );
1282        }
1283    
1284        /**
1285         * reate a simple styling rule
1286         * 
1287         * @param symbolizers -
1288         *            an array of symbolizers to use
1289         * 
1290         * @return the new rule
1291         */
1292        public static Rule createRule( Symbolizer[] symbolizers ) {
1293            return createRule( symbolizers, 0, Double.MAX_VALUE );
1294        }
1295    
1296        /**
1297         * create a simple styling rule, see the SLD Spec for more details of scaleDenominators
1298         * 
1299         * @param symbolizer -
1300         *            the symbolizer to use
1301         * @param minScaleDenominator -
1302         *            the minimim scale to draw the feature at
1303         * @param maxScaleDenominator -
1304         *            the maximum scale to draw the feature at
1305         * 
1306         * @return the new rule
1307         */
1308        public static Rule createRule( Symbolizer symbolizer, double minScaleDenominator, double maxScaleDenominator ) {
1309            return createRule( new Symbolizer[] { symbolizer }, minScaleDenominator, maxScaleDenominator );
1310        }
1311    
1312        /**
1313         * create a simple styling rule, see the SLD Spec for more details of scaleDenominators
1314         * 
1315         * @param symbolizers -
1316         *            an array of symbolizers to use
1317         * @param minScaleDenominator -
1318         *            the minimim scale to draw the feature at
1319         * @param maxScaleDenominator -
1320         *            the maximum scale to draw the feature at
1321         * 
1322         * @return the new rule
1323         */
1324        public static Rule createRule( Symbolizer[] symbolizers, double minScaleDenominator, double maxScaleDenominator ) {
1325            return createRule( symbolizers, "default", "default", "default", minScaleDenominator, maxScaleDenominator );
1326        }
1327    
1328        /**
1329         * create a simple styling rule, see the SLD Spec for more details of scaleDenominators
1330         * 
1331         * @param symbolizers -
1332         *            an array of symbolizers to use
1333         * @param name -
1334         *            name of the rule
1335         * @param title -
1336         *            title of the rule
1337         * @param abstract_ -
1338         *            text describing throws rule
1339         * @param minScaleDenominator -
1340         *            the minimim scale to draw the feature at
1341         * @param maxScaleDenominator -
1342         *            the maximum scale to draw the feature at
1343         * 
1344         * @return the new rule
1345         */
1346        public static Rule createRule( Symbolizer[] symbolizers, String name, String title, String abstract_,
1347                                       double minScaleDenominator, double maxScaleDenominator ) {
1348            return createRule( symbolizers, name, title, abstract_, null, null, false, minScaleDenominator,
1349                               maxScaleDenominator );
1350        }
1351    
1352        /**
1353         * create a complex styling rule, see the SLD Spec for more details of scaleDenominators
1354         * 
1355         * @param symbolizers -
1356         *            an array of symbolizers to use
1357         * @param name -
1358         *            name of the rule
1359         * @param title -
1360         *            title of the rule
1361         * @param abstract_ -
1362         *            text describing throws rule
1363         * @param legendGraphic
1364         * @param filter -
1365         *            filter to use with the rule
1366         * @param elseFilter -
1367         *            true if the passed is an ElseFilter (see SLD spec)
1368         * @param minScaleDenominator -
1369         *            the minimim scale to draw the feature at
1370         * @param maxScaleDenominator -
1371         *            the maximum scale to draw the feature at
1372         * 
1373         * @return the new rule
1374         */
1375        public static Rule createRule( Symbolizer[] symbolizers, String name, String title, String abstract_,
1376                                       LegendGraphic legendGraphic, Filter filter, boolean elseFilter,
1377                                       double minScaleDenominator, double maxScaleDenominator ) {
1378            return new Rule( symbolizers, name, title, abstract_, legendGraphic, filter, elseFilter, minScaleDenominator,
1379                             maxScaleDenominator );
1380        }
1381    
1382        /**
1383         * create a Feature type styler
1384         * 
1385         * @param symbolizer -
1386         *            the symbolizer to use
1387         * 
1388         * @return the new feature type styler
1389         */
1390        public static FeatureTypeStyle createFeatureTypeStyle( Symbolizer symbolizer ) {
1391            return createFeatureTypeStyle( null, symbolizer, 0, Double.MAX_VALUE );
1392        }
1393    
1394        /**
1395         * create a Feature type styler see the SLD Spec for more details of scaleDenominators
1396         * 
1397         * @param symbolizer -
1398         *            the symbolizer to use
1399         * @param minScaleDenominator -
1400         *            the minimim scale to draw the feature at
1401         * @param maxScaleDenominator -
1402         *            the maximum scale to draw the feature at
1403         * 
1404         * @return the new feature type styler
1405         */
1406        public static FeatureTypeStyle createFeatureTypeStyle( Symbolizer symbolizer, double minScaleDenominator,
1407                                                               double maxScaleDenominator ) {
1408            return createFeatureTypeStyle( null, symbolizer, minScaleDenominator, maxScaleDenominator );
1409        }
1410    
1411        /**
1412         * create a Feature type styler see the SLD Spec for more details of scaleDenominators
1413         * 
1414         * @param symbolizers -
1415         *            an array of symbolizers to use
1416         * @param minScaleDenominator -
1417         *            the minimim scale to draw the feature at
1418         * @param maxScaleDenominator -
1419         *            the maximum scale to draw the feature at
1420         * 
1421         * @return the new feature type styler
1422         */
1423        public static FeatureTypeStyle createFeatureTypeStyle( Symbolizer[] symbolizers, double minScaleDenominator,
1424                                                               double maxScaleDenominator ) {
1425            return createFeatureTypeStyle( null, symbolizers, minScaleDenominator, maxScaleDenominator );
1426        }
1427    
1428        /**
1429         * create a Feature type styler
1430         * 
1431         * @param featureTypeStyleName -
1432         *            name for the feature type styler
1433         * @param symbolizer -
1434         *            the symbolizer to use
1435         * 
1436         * @return the new feature type styler
1437         */
1438        public static FeatureTypeStyle createFeatureTypeStyle( String featureTypeStyleName, Symbolizer symbolizer ) {
1439            return createFeatureTypeStyle( featureTypeStyleName, symbolizer, 0, Double.MAX_VALUE );
1440        }
1441    
1442        /**
1443         * create a Feature type styler
1444         * 
1445         * @param featureTypeStyleName -
1446         *            name for the feature type styler
1447         * @param symbolizers -
1448         *            an array of symbolizers to use
1449         * 
1450         * @return the new feature type styler
1451         */
1452        public static FeatureTypeStyle createFeatureTypeStyle( String featureTypeStyleName, Symbolizer[] symbolizers ) {
1453            return createFeatureTypeStyle( featureTypeStyleName, symbolizers, 0, Double.MAX_VALUE );
1454        }
1455    
1456        /**
1457         * create a Feature type styler see the SLD Spec for more details of scaleDenominators
1458         * 
1459         * @param featureTypeStyleName -
1460         *            name for the feature type styler
1461         * @param symbolizer -
1462         *            the symbolizer to use
1463         * @param minScaleDenominator -
1464         *            the minimim scale to draw the feature at
1465         * @param maxScaleDenominator -
1466         *            the maximum scale to draw the feature at
1467         * 
1468         * @return the new feature type styler
1469         */
1470        public static FeatureTypeStyle createFeatureTypeStyle( String featureTypeStyleName, Symbolizer symbolizer,
1471                                                               double minScaleDenominator, double maxScaleDenominator ) {
1472            return createFeatureTypeStyle( featureTypeStyleName, new Symbolizer[] { symbolizer }, minScaleDenominator,
1473                                           maxScaleDenominator );
1474        }
1475    
1476        /**
1477         * create a Feature type styler see the SLD Spec for more details of scaleDenominators
1478         * 
1479         * @param featureTypeStyleName -
1480         *            name for the feature type styler
1481         * @param symbolizers -
1482         *            an array of symbolizers to use
1483         * @param minScaleDenominator -
1484         *            the minimim scale to draw the feature at
1485         * @param maxScaleDenominator -
1486         *            the maximum scale to draw the feature at
1487         * 
1488         * @return the new feature type styler
1489         */
1490        public static FeatureTypeStyle createFeatureTypeStyle( String featureTypeStyleName, Symbolizer[] symbolizers,
1491                                                               double minScaleDenominator, double maxScaleDenominator ) {
1492            Rule rule = createRule( symbolizers, minScaleDenominator, maxScaleDenominator );
1493    
1494            return createFeatureTypeStyle( featureTypeStyleName, rule );
1495        }
1496    
1497        /**
1498         * create a Feature type styler
1499         * 
1500         * @param rule -
1501         *            rule contained in the featureTypeStyle
1502         * 
1503         * @return the new feature type styler
1504         */
1505        public static FeatureTypeStyle createFeatureTypeStyle( Rule rule ) {
1506    
1507            return createFeatureTypeStyle( new Rule[] { rule } );
1508        }
1509    
1510        /**
1511         * create a Feature type styler
1512         * 
1513         * @param rules -
1514         *            rules contained in the featureTypeStyle
1515         * 
1516         * @return the new feature type styler
1517         */
1518        public static FeatureTypeStyle createFeatureTypeStyle( Rule[] rules ) {
1519    
1520            return createFeatureTypeStyle( null, rules );
1521        }
1522    
1523        /**
1524         * create a Feature type styler
1525         * 
1526         * @param featureTypeStyleName -
1527         *            name for the feature type styler
1528         * @param rule -
1529         *            rule contained in the featureTypeStyle
1530         * 
1531         * @return the new feature type styler
1532         */
1533        public static FeatureTypeStyle createFeatureTypeStyle( String featureTypeStyleName, Rule rule ) {
1534    
1535            return createFeatureTypeStyle( featureTypeStyleName, new Rule[] { rule } );
1536        }
1537    
1538        /**
1539         * create a Feature type styler
1540         * 
1541         * @param featureTypeStyleName -
1542         *            name for the feature type styler
1543         * @param rules -
1544         *            rules contained in the featureTypeStyle
1545         * 
1546         * @return the new feature type styler
1547         */
1548        public static FeatureTypeStyle createFeatureTypeStyle( String featureTypeStyleName, Rule[] rules ) {
1549    
1550            return createFeatureTypeStyle( featureTypeStyleName, null, null, null, rules );
1551        }
1552    
1553        /**
1554         * create a Feature type styler
1555         * 
1556         * @param featureTypeStyleName -
1557         *            name for the feature type styler
1558         * @param featureTypeName -
1559         *            name of the feature type the Feature type style shall be assigned to
1560         * @param title -
1561         *            title of the FeatureTypeStyle
1562         * @param abstract_ -
1563         *            text describing the FeatureTypeStyle
1564         * @param rules -
1565         *            rules contained in the featureTypeStyle
1566         * 
1567         * @return the new feature type styler
1568         */
1569        public static FeatureTypeStyle createFeatureTypeStyle( String featureTypeStyleName, String title, String abstract_,
1570                                                               String featureTypeName, Rule[] rules ) {
1571    
1572            return new FeatureTypeStyle( featureTypeStyleName, title, abstract_, featureTypeName, null, rules );
1573        }
1574    
1575        /**
1576         * create a new style
1577         * 
1578         * @param symbolizer -
1579         *            the symbolizer to use
1580         * 
1581         * @return the new style
1582         */
1583        public static AbstractStyle createStyle( Symbolizer symbolizer ) {
1584            return createStyle( null, symbolizer, 0, Double.MAX_VALUE );
1585        }
1586    
1587        /**
1588         * create a new style with name 'default'
1589         * 
1590         * @param symbolizer -
1591         *            the symbolizer to use
1592         * @param minScaleDenominator -
1593         *            the minimim scale to draw the feature at
1594         * @param maxScaleDenominator -
1595         *            the maximum scale to draw the feature at
1596         * 
1597         * @return the new style
1598         */
1599        public static AbstractStyle createStyle( Symbolizer symbolizer, double minScaleDenominator,
1600                                                 double maxScaleDenominator ) {
1601            return createStyle( "default", symbolizer, minScaleDenominator, maxScaleDenominator );
1602        }
1603    
1604        /**
1605         * create a new style
1606         * 
1607         * @param name -
1608         *            the name of the style
1609         * @param symbolizer -
1610         *            the symbolizer to use
1611         * 
1612         * @return the new style
1613         */
1614        public static AbstractStyle createStyle( String name, Symbolizer symbolizer ) {
1615            return createStyle( name, symbolizer, 0, Double.MAX_VALUE );
1616        }
1617    
1618        /**
1619         * create a new style
1620         * 
1621         * @param name -
1622         *            the name of the style
1623         * @param symbolizer -
1624         *            the symbolizer to use
1625         * @param minScaleDenominator -
1626         *            the minimim scale to draw the feature at
1627         * @param maxScaleDenominator -
1628         *            the maximum scale to draw the feature at
1629         * 
1630         * @return the new style
1631         */
1632        public static AbstractStyle createStyle( String name, Symbolizer symbolizer, double minScaleDenominator,
1633                                                 double maxScaleDenominator ) {
1634            // create the feature type style
1635            FeatureTypeStyle fts = createFeatureTypeStyle( name, symbolizer, minScaleDenominator, maxScaleDenominator );
1636    
1637            return createStyle( name, null, null, fts );
1638        }
1639    
1640        /**
1641         * create a style
1642         * 
1643         * @param name -
1644         *            the name of the style
1645         * @param featureTypeName -
1646         *            name of the feature type the Feature type style shall be assigned to
1647         * @param title -
1648         *            title of the FeatureTypeStyle
1649         * @param abstract_ -
1650         *            text describing the FeatureTypeStyle
1651         * @param rules -
1652         *            rules contained in the featureTypeStyle
1653         * 
1654         * @return the new style
1655         */
1656        public static AbstractStyle createStyle( String name, String title, String abstract_, String featureTypeName,
1657                                                 Rule[] rules ) {
1658    
1659            FeatureTypeStyle fts = createFeatureTypeStyle( name, title, abstract_, featureTypeName, rules );
1660            return createStyle( name, null, null, fts );
1661        }
1662    
1663        /**
1664         * create a new style
1665         * 
1666         * @param name -
1667         *            the name of the style
1668         * @param title -
1669         *            title of the style
1670         * @param abstract_ -
1671         *            text describing the style
1672         * @param featureTypeStyle -
1673         *            featureTypeStyle
1674         * 
1675         * @return the new style
1676         */
1677        public static AbstractStyle createStyle( String name, String title, String abstract_,
1678                                                 FeatureTypeStyle featureTypeStyle ) {
1679            return createStyle( name, title, abstract_, new FeatureTypeStyle[] { featureTypeStyle } );
1680        }
1681    
1682        /**
1683         * create a new style
1684         * 
1685         * @param name -
1686         *            the name of the style
1687         * @param title -
1688         *            title of the style
1689         * @param abstract_ -
1690         *            text describing the style
1691         * @param featureTypeStyles -
1692         *            featureTypeStyle
1693         * 
1694         * @return the new style
1695         */
1696        public static AbstractStyle createStyle( String name, String title, String abstract_,
1697                                                 FeatureTypeStyle[] featureTypeStyles ) {
1698            return new UserStyle( name, title, abstract_, false, featureTypeStyles );
1699        }
1700    
1701        /**
1702         * creates a style with name 'defaultPoint' for rendering point geometries
1703         * 
1704         * @param wellKnownName
1705         *            the well known name of the mark
1706         * @param fillColor
1707         *            the color of the mark
1708         * @param borderColor
1709         *            the outline color of the mark
1710         * @param borderWidth
1711         *            the width of the outline
1712         * @param opacity -
1713         *            the opacity of the graphic
1714         * @param size -
1715         *            the size of the graphic
1716         * @param rotation -
1717         *            the rotation from the top of the page of the graphic
1718         * @param min -
1719         *            the minimim scale to draw the feature at
1720         * @param max -
1721         *            the maximum scale to draw the feature at
1722         * 
1723         * @return the style created
1724         */
1725        public static AbstractStyle createPointStyle( String wellKnownName, Color fillColor, Color borderColor,
1726                                                      double borderWidth, double opacity, double size, double rotation,
1727                                                      double min, double max ) {
1728            Mark mark = createMark( wellKnownName, fillColor, borderColor, borderWidth );
1729            Graphic graphic = createGraphic( null, mark, opacity, size, rotation );
1730            Symbolizer symbolizer = createPointSymbolizer( graphic, null, min, max );
1731            return createStyle( "defaultPoint", symbolizer );
1732        }
1733    
1734        /**
1735         * creates a style with name 'defaultLine' for rendering line geometries
1736         * 
1737         * @param color
1738         *            the line color
1739         * @param width
1740         *            the width of the line
1741         * @param opacity -
1742         *            the opacity of the line
1743         * @param min -
1744         *            the minimim scale to draw the feature at
1745         * @param max -
1746         *            the maximum scale to draw the feature at
1747         * 
1748         * @return the style created
1749         */
1750        public static AbstractStyle createLineStyle( Color color, double width, double opacity, double min, double max ) {
1751            Stroke stroke = createStroke( color, width, opacity );
1752            Symbolizer symbolizer = createLineSymbolizer( stroke, null, min, max );
1753            return createStyle( "defaultLine", symbolizer );
1754        }
1755    
1756        /**
1757         * creates a style with name 'defaultPolygon' for rendering polygon geometries
1758         * 
1759         * @param fillColor -
1760         *            the fill color of the polygon
1761         * @param fillOpacity -
1762         *            the fill opacity of the polygon
1763         * @param strokeColor -
1764         *            the line color
1765         * @param strokeWidth -
1766         *            the width of the line
1767         * @param strokeOpacity -
1768         *            the opacity of the line
1769         * @param min -
1770         *            the minimim scale to draw the feature at
1771         * @param max -
1772         *            the maximum scale to draw the feature at
1773         * 
1774         * @return the style created
1775         */
1776        public static AbstractStyle createPolygonStyle( Color fillColor, double fillOpacity, Color strokeColor,
1777                                                        double strokeWidth, double strokeOpacity, double min, double max ) {
1778            Stroke stroke = createStroke( strokeColor, strokeWidth, strokeOpacity );
1779            Fill fill = createFill( fillColor, fillOpacity );
1780            Symbolizer symbolizer = createPolygonSymbolizer( stroke, fill, null, min, max );
1781            return createStyle( "defaultPolygon", symbolizer );
1782        }
1783    
1784        /**
1785         * Throws an UnsupportedOperationException, but should create a style with name 'defaultPoint' for rendering point
1786         * geometries. The style contains 1..n rules depending on the value range and the number of steps within it. So it
1787         * is possible to create a style that creates different rendering depending on the value of one feature attribute.
1788         * <p>
1789         * there will be a linear interpolation between colors, size and width of the first and the last rule considering
1790         * the number of passed steps (rules)
1791         * 
1792         * @param wellKnownNames -
1793         *            list of well known names of the mark. the first field will be assigned to the starting rule the last
1794         *            to the ending rule.
1795         * @param startFillColor -
1796         *            the color of the mark of the first rule
1797         * @param endFillColor -
1798         *            the color of the mark of the last rule
1799         * @param startBorderColor -
1800         *            the outline color of the mark of the first rule
1801         * @param endBorderColor -
1802         *            the outline color of the mark of the last rule
1803         * @param startBorderWidth -
1804         *            the width of the outline of the first rule
1805         * @param endBorderWidth -
1806         *            the width of the outline of the last rule
1807         * @param opacity -
1808         *            the opacity of the graphic
1809         * @param startSize -
1810         *            the size of the graphic of the first rule
1811         * @param endSize -
1812         *            the size of the graphic of the last rule
1813         * @param rotation -
1814         *            the rotation from the top of the page of the graphic
1815         * @param min -
1816         *            the minimim scale to draw the feature at
1817         * @param max -
1818         *            the maximum scale to draw the feature at
1819         * @param featurePropertyName -
1820         *            name of the feature property that determines the selection of the rule for drawing
1821         * @param numberOfSteps -
1822         *            number of steps used for the interpolation between first and last value. It is identical with the
1823         *            number of rules that will be created.
1824         * 
1825         * @return the style created
1826         */
1827        public static AbstractStyle createPointStyle( String[] wellKnownNames, Color startFillColor, Color endFillColor,
1828                                                      Color startBorderColor, Color endBorderColor,
1829                                                      double startBorderWidth, double endBorderWidth, double opacity,
1830                                                      double startSize, double endSize, double rotation, double min,
1831                                                      double max, String featurePropertyName, int numberOfSteps ) {
1832            throw new UnsupportedOperationException( "method createPointStyle is not implemented yet" );
1833        }
1834    
1835        /**
1836         * Throws an UnsupportedOperationException, but should create a style with name 'defaultLine' for rendering line geometries. The style contains 1..n rules depending on
1837         * the value range and the number of steps within it. So it is possible to create a style that creates different
1838         * rendering depending on the value of one feature attribute.
1839         * <p>
1840         * there will be a linear interpolation between colors, size and width of the first and the last rule considering
1841         * the number of passed steps (rules)
1842         * 
1843         * @param startColor -
1844         *            the color of the first rule
1845         * @param endColor -
1846         *            the color of the last rule
1847         * @param startWidth -
1848         *            the width of the line of the first rule
1849         * @param endWidth -
1850         *            the width of the line of the last rule
1851         * @param opacity -
1852         *            the opacity of the graphic
1853         * @param min -
1854         *            the minimim scale to draw the feature at
1855         * @param max -
1856         *            the maximum scale to draw the feature at
1857         * @param featurePropertyName -
1858         *            name of the feature property that determines the selection of the rule for drawing
1859         * @param numberOfSteps -
1860         *            number of steps used for the interpolation between first and last value. It is identical with the
1861         *            number of rules that will be created.
1862         * 
1863         * @return the style created
1864         */
1865        public static AbstractStyle createLineStyle( Color startColor, Color endColor, double startWidth, double endWidth,
1866                                                     double opacity, double min, double max, String featurePropertyName,
1867                                                     int numberOfSteps ) {
1868            throw new UnsupportedOperationException( "method createLineStyle is not implemented yet" );
1869        }
1870    
1871        /**
1872         * Throws an UnsupportedOperationException, but should create a style with name 'defaultPoint' for rendering point geometries. The style contains 1..n rules depending
1873         * on the value range and the number of steps within it. So it is possible to create a style that creates different
1874         * rendering depending on the value of one feature attribute.
1875         * <p>
1876         * there will be a linear interpolation between colors, size and width of the first and the last rule considering
1877         * the number of passed steps (rules)
1878         * 
1879         * @param startFillColor -
1880         *            the fill color of the first rule
1881         * @param endFillColor -
1882         *            the fill color of the last rule
1883         * @param fillOpacity -
1884         *            the opacity of the fill
1885         * @param startStrokeColor -
1886         *            the line color of the first rule
1887         * @param endStrokeColor -
1888         *            the line color of the last rule
1889         * @param startStrokeWidth -
1890         *            the width of the outline of the first rule
1891         * @param endStrokeWidth -
1892         *            the width of the outline of the last rule
1893         * @param strokeOpacity -
1894         *            the opacity of the outline
1895         * @param min -
1896         *            the minimim scale to draw the feature at
1897         * @param max -
1898         *            the maximum scale to draw the feature at
1899         * @param featurePropertyName -
1900         *            name of the feature property that determines the selection of the rule for drawing
1901         * @param numberOfSteps -
1902         *            number of steps used for the interpolation between first and last value. It is identical with the
1903         *            number of rules that will be created.
1904         * 
1905         * @return the style created
1906         */
1907        public static AbstractStyle createPolygonStyle( Color startFillColor, Color endFillColor, double fillOpacity,
1908                                                        Color startStrokeColor, Color endStrokeColor,
1909                                                        double startStrokeWidth, double endStrokeWidth,
1910                                                        double strokeOpacity, double min, double max,
1911                                                        String featurePropertyName, int numberOfSteps ) {
1912            throw new UnsupportedOperationException( "method createPolygonStyle is not implemented yet" );
1913        }
1914    
1915        /**
1916         * create a new default style
1917         * 
1918         * @return the new style
1919         */
1920        public static AbstractStyle createStyle() {
1921            return null;
1922        }
1923    
1924    }