0001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/graphics/sld/StyleFactory.java $
0002: /*---------------- FILE HEADER ------------------------------------------
0003:
0004: This file is part of deegree.
0005: Copyright (C) 2001-2008 by:
0006: EXSE, Department of Geography, University of Bonn
0007: http://www.giub.uni-bonn.de/deegree/
0008: lat/lon GmbH
0009: http://www.lat-lon.de
0010:
0011: The basic version of this class was taken from the Geotools2
0012: project (StyleBuilder.java):
0013: Geotools2 - OpenSource mapping toolkit
0014: http://geotools.org
0015: (C) 2002, Geotools Project Managment Committee (PMC)
0016:
0017: This library is free software; you can redistribute it and/or
0018: modify it under the terms of the GNU Lesser General Public
0019: License as published by the Free Software Foundation; either
0020: version 2.1 of the License, or (at your option) any later version.
0021:
0022: This library is distributed in the hope that it will be useful,
0023: but WITHOUT ANY WARRANTY; without even the implied warranty of
0024: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0025: Lesser General Public License for more details.
0026:
0027: You should have received a copy of the GNU Lesser General Public
0028: License along with this library; if not, write to the Free Software
0029: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0030:
0031: Contact:
0032:
0033: Andreas Poth
0034: lat/lon GmbH
0035: Aennchenstr. 19
0036: 53115 Bonn
0037: Germany
0038: E-Mail: poth@lat-lon.de
0039:
0040: Prof. Dr. Klaus Greve
0041: Department of Geography
0042: University of Bonn
0043: Meckenheimer Allee 166
0044: 53115 Bonn
0045: Germany
0046: E-Mail: greve@giub.uni-bonn.de
0047:
0048:
0049: ---------------------------------------------------------------------------*/
0050: package org.deegree.graphics.sld;
0051:
0052: import java.awt.Color;
0053: import java.net.MalformedURLException;
0054: import java.net.URL;
0055: import java.util.HashMap;
0056:
0057: import org.deegree.framework.util.ColorUtils;
0058: import org.deegree.model.filterencoding.Expression;
0059: import org.deegree.model.filterencoding.Filter;
0060: import org.deegree.ogcbase.PropertyPath;
0061:
0062: /**
0063: * An utility class designed to easy creation of style by convinience methods.
0064: *
0065: * @author <a href="mailto:poth@lat-lon.de">Andreas Poth </a>
0066: */
0067: public class StyleFactory {
0068:
0069: /**
0070: * creates a <tt>ParameterValueType</tt> instance with a <tt>String</tt> as value
0071: *
0072: * @param value
0073: * value of the <tt>ParameterValueType</tt>
0074: *
0075: * @return the ParameterValueType created
0076: */
0077: public static ParameterValueType createParameterValueType(
0078: String value) {
0079: return new ParameterValueType(new Object[] { value });
0080: }
0081:
0082: /**
0083: * creates a <tt>ParameterValueType</tt> instance with a <tt>int</tt> as value
0084: *
0085: * @param value
0086: * value of the <tt>ParameterValueType</tt>
0087: *
0088: * @return the ParameterValueType created
0089: */
0090: public static ParameterValueType createParameterValueType(int value) {
0091: return new ParameterValueType(new Object[] { "" + value });
0092: }
0093:
0094: /**
0095: * creates a <tt>ParameterValueType</tt> instance with a <tt>String</tt> as value
0096: *
0097: * @param value
0098: * value of the <tt>ParameterValueType</tt>
0099: *
0100: * @return the ParameterValueType created
0101: */
0102: public static ParameterValueType createParameterValueType(
0103: double value) {
0104: return new ParameterValueType(new Object[] { "" + value });
0105: }
0106:
0107: /**
0108: * creates a <tt>ParameterValueType</tt> instance with an array of <tt>Expression</tt> s as
0109: * value
0110: *
0111: * @param expressions
0112: *
0113: * @return the the ParameterValueType created
0114: */
0115: public static ParameterValueType createParameterValueType(
0116: Expression[] expressions) {
0117: return new ParameterValueType(expressions);
0118: }
0119:
0120: /**
0121: * creates a CssParameter with a name and a value
0122: *
0123: * @param name
0124: * name of the css parameter
0125: * @param value
0126: * value of the css parameter
0127: *
0128: * @return the CssParameter created
0129: */
0130: public static CssParameter createCssParameter(String name,
0131: String value) {
0132: ParameterValueType pvt = createParameterValueType(value);
0133: return new CssParameter(name, pvt);
0134: }
0135:
0136: /**
0137: * creates a CssParameter with a name and a value
0138: *
0139: * @param name
0140: * name of the css parameter
0141: * @param value
0142: * value of the css parameter
0143: *
0144: * @return the CssParameter created
0145: */
0146: public static CssParameter createCssParameter(String name, int value) {
0147: ParameterValueType pvt = createParameterValueType(value);
0148: return new CssParameter(name, pvt);
0149: }
0150:
0151: /**
0152: * creates a CssParameter with a name and a value
0153: *
0154: * @param name
0155: * name of the css parameter
0156: * @param value
0157: * value of the css parameter
0158: *
0159: * @return the CssParameter created
0160: */
0161: public static CssParameter createCssParameter(String name,
0162: double value) {
0163: ParameterValueType pvt = createParameterValueType(value);
0164: return new CssParameter(name, pvt);
0165: }
0166:
0167: /**
0168: * creates a <tt>GraphicStroke</tt> from a <tt>Graphic</tt> object
0169: *
0170: * @param graphic
0171: * <tt>Graphic</tt object
0172: *
0173: * @return the GraphicStroke created
0174: */
0175: public static GraphicStroke createGraphicStroke(Graphic graphic) {
0176: return new GraphicStroke(graphic);
0177: }
0178:
0179: /**
0180: * creates a <tt>GraphicFill</tt> from a <tt>Graphic</tt> object
0181: *
0182: * @param graphic
0183: * <tt>Graphic</tt object
0184: *
0185: * @return the GraphicFill created
0186: */
0187: public static GraphicFill createGraphicFill(Graphic graphic) {
0188: return new GraphicFill(graphic);
0189: }
0190:
0191: /**
0192: * create a default Stroke that black, 1 pixel width, complete opaque, with round linejoin and
0193: * square line cap
0194: *
0195: * @return the Stroke created
0196: */
0197: public static Stroke createStroke() {
0198: return createStroke(Color.BLACK, 1, "round", "square");
0199: }
0200:
0201: /**
0202: * create a default stroke with the supplied width
0203: *
0204: * @param width
0205: * the width of the line
0206: *
0207: * @return the stroke created
0208: */
0209: public static Stroke createStroke(double width) {
0210: return createStroke(Color.BLACK, width);
0211: }
0212:
0213: /**
0214: * Create a default stroke with the supplied color
0215: *
0216: * @param color
0217: * the color of the line
0218: *
0219: * @return the created stroke
0220: */
0221: public static Stroke createStroke(Color color) {
0222: return createStroke(color, 1);
0223: }
0224:
0225: /**
0226: * create a stroke with the passed width and color
0227: *
0228: * @param color
0229: * the color of the line
0230: * @param width
0231: * the width of the line
0232: *
0233: * @return the created stroke
0234: */
0235: public static Stroke createStroke(Color color, double width) {
0236: return createStroke(color, width, "round", "square");
0237: }
0238:
0239: /**
0240: * create a stroke with color, width, linejoin type and lineCap type.
0241: *
0242: * @param color
0243: * the color of the line
0244: * @param width
0245: * the width of the line
0246: * @param lineJoin
0247: * the type of join to be used at points along the line
0248: * @param lineCap
0249: * the type of cap to be used at the end of the line
0250: *
0251: * @return the stroke created
0252: */
0253: public static Stroke createStroke(Color color, double width,
0254: String lineJoin, String lineCap) {
0255: return createStroke(color, width, 1, null, lineJoin, lineCap);
0256: }
0257:
0258: /**
0259: * create a stroke with color, width, linejoin type and lineCap type.
0260: *
0261: * @param color
0262: * the color of the line
0263: * @param width
0264: * the width of the line
0265: * @param opacity
0266: * the opacity or <I>see throughness </I> of the line, 0 - is transparent, 1 is
0267: * completely drawn
0268: * @param lineJoin
0269: * the type of join to be used at points along the line
0270: * @param lineCap
0271: * the type of cap to be used at the end of the line
0272: *
0273: * @return the stroke created
0274: */
0275: public static Stroke createStroke(Color color, double width,
0276: double opacity, float[] dashArray, String lineJoin,
0277: String lineCap) {
0278: HashMap<String, Object> cssParams = new HashMap<String, Object>();
0279:
0280: CssParameter stroke = createCssParameter("stroke", ColorUtils
0281: .toHexCode("#", color));
0282: cssParams.put("stroke", stroke);
0283: CssParameter strokeOp = createCssParameter("stroke-opacity",
0284: opacity);
0285: cssParams.put("stroke-opacity", strokeOp);
0286: CssParameter strokeWi = createCssParameter("stroke-width",
0287: width);
0288: cssParams.put("stroke-width", strokeWi);
0289: CssParameter strokeLJ = createCssParameter("stroke-linejoin",
0290: lineJoin);
0291: cssParams.put("stroke-linejoin", strokeLJ);
0292: CssParameter strokeCap = createCssParameter("stroke-linecap",
0293: lineCap);
0294: cssParams.put("stroke-linecap", strokeCap);
0295:
0296: if (dashArray != null) {
0297: String s = "";
0298: for (int i = 0; i < dashArray.length - 1; i++) {
0299: s = s + dashArray[i] + ",";
0300: }
0301: s = s + dashArray[dashArray.length - 1];
0302: CssParameter strokeDash = createCssParameter(
0303: "stroke-dasharray", s);
0304: cssParams.put("stroke-dasharray", strokeDash);
0305: }
0306:
0307: return new Stroke(cssParams, null, null);
0308: }
0309:
0310: /**
0311: * create a dashed line of color and width
0312: *
0313: * @param color
0314: * the color of the line
0315: * @param width
0316: * the width of the line
0317: * @param dashArray
0318: * an array of floats describing the length of line and spaces
0319: *
0320: * @return the stroke created
0321: */
0322: public static Stroke createStroke(Color color, double width,
0323: float[] dashArray) {
0324: HashMap<String, Object> cssParams = new HashMap<String, Object>();
0325:
0326: CssParameter stroke = createCssParameter("stroke", ColorUtils
0327: .toHexCode("#", color));
0328: cssParams.put("stroke", stroke);
0329: CssParameter strokeOp = createCssParameter("stroke-opacity",
0330: "1");
0331: cssParams.put("stroke-opacity", strokeOp);
0332: CssParameter strokeWi = createCssParameter("stroke-width",
0333: width);
0334: cssParams.put("stroke-width", strokeWi);
0335: CssParameter strokeLJ = createCssParameter("stroke-linejoin",
0336: "mitre");
0337: cssParams.put("stroke-linejoin", strokeLJ);
0338: CssParameter strokeCap = createCssParameter("stroke-linecap",
0339: "butt");
0340: cssParams.put("stroke-linecap", strokeCap);
0341:
0342: if (dashArray != null) {
0343: String s = "";
0344: for (int i = 0; i < dashArray.length - 1; i++) {
0345: s = s + dashArray[i] + ",";
0346: }
0347: s = s + dashArray[dashArray.length - 1];
0348: CssParameter strokeDash = createCssParameter(
0349: "stroke-dasharray", s);
0350: cssParams.put("stroke-dasharray", strokeDash);
0351: }
0352:
0353: return new Stroke(cssParams, null, null);
0354: }
0355:
0356: /**
0357: * create a stroke with color, width and opacity supplied
0358: *
0359: * @param color
0360: * the color of the line
0361: * @param width
0362: * the width of the line
0363: * @param opacity
0364: * the opacity or <I>see throughness </I> of the line, 0 - is transparent, 1 is
0365: * completely drawn
0366: *
0367: * @return the stroke created
0368: */
0369: public static Stroke createStroke(Color color, double width,
0370: double opacity) {
0371: return createStroke(color, width, opacity, null, "mitre",
0372: "butt");
0373: }
0374:
0375: /**
0376: * create a default fill 50% gray
0377: *
0378: * @return the fill created
0379: */
0380: public static Fill createFill() {
0381: return createFill(Color.GRAY, 1d, null);
0382: }
0383:
0384: /**
0385: * create a fill of color
0386: *
0387: * @param color
0388: * the color of the fill
0389: *
0390: * @return the fill created
0391: */
0392: public static Fill createFill(Color color) {
0393: return createFill(color, 1d, null);
0394: }
0395:
0396: /**
0397: * create a fill with the supplied color and opacity
0398: *
0399: * @param color
0400: * the color to fill with
0401: * @param opacity
0402: * the opacity of the fill 0 - transparent, 1 - completly filled
0403: *
0404: * @return the fill created
0405: */
0406: public static Fill createFill(Color color, double opacity) {
0407: return createFill(color, opacity, null);
0408: }
0409:
0410: /**
0411: * create a fill with color and opacity supplied and uses the graphic fill supplied for the fill
0412: *
0413: * @param color
0414: * the foreground color
0415: * @param opacity
0416: * the opacity of the fill
0417: * @param fill
0418: * the graphic object to use to fill the fill
0419: *
0420: * @return the fill created
0421: */
0422: public static Fill createFill(Color color, double opacity,
0423: GraphicFill fill) {
0424: HashMap<String, Object> cssParams = new HashMap<String, Object>();
0425: CssParameter fillCo = createCssParameter("fill", ColorUtils
0426: .toHexCode("#", color));
0427: cssParams.put("fill", fillCo);
0428: CssParameter fillOp = createCssParameter("fill-opacity",
0429: opacity);
0430: cssParams.put("fill-opacity", fillOp);
0431: return new Fill(cssParams, fill);
0432: }
0433:
0434: /**
0435: * create the named mark
0436: *
0437: * @param wellKnownName
0438: * the wellknown name of the mark
0439: *
0440: * @return the mark created
0441: */
0442: public static Mark createMark(String wellKnownName) {
0443: return new Mark(wellKnownName, createStroke(), createFill());
0444: }
0445:
0446: /**
0447: * create the named mark with the colors etc supplied
0448: *
0449: * @param wellKnownName
0450: * the well known name of the mark
0451: * @param fillColor
0452: * the color of the mark
0453: * @param borderColor
0454: * the outline color of the mark
0455: * @param borderWidth
0456: * the width of the outline
0457: *
0458: * @return the mark created
0459: */
0460: public static Mark createMark(String wellKnownName,
0461: Color fillColor, Color borderColor, double borderWidth) {
0462: Stroke stroke = createStroke(borderColor, borderWidth);
0463: Fill fill = createFill(fillColor);
0464: return new Mark(wellKnownName, stroke, fill);
0465: }
0466:
0467: /**
0468: * create a mark with default fill (50% gray) and the supplied outline
0469: *
0470: * @param wellKnownName
0471: * the well known name of the mark
0472: * @param borderColor
0473: * the outline color
0474: * @param borderWidth
0475: * the outline width
0476: *
0477: * @return the mark created
0478: */
0479: public static Mark createMark(String wellKnownName,
0480: Color borderColor, double borderWidth) {
0481: Stroke stroke = createStroke(borderColor, borderWidth);
0482: Fill fill = createFill();
0483: return new Mark(wellKnownName, stroke, fill);
0484: }
0485:
0486: /**
0487: * create a mark of the supplied color and a default outline (black)
0488: *
0489: * @param wellKnownName
0490: * the well known name of the mark
0491: * @param fillColor
0492: * the color of the mark
0493: *
0494: * @return the created mark
0495: */
0496: public static Mark createMark(String wellKnownName, Color fillColor) {
0497: Stroke stroke = createStroke();
0498: Fill fill = createFill(fillColor);
0499: return new Mark(wellKnownName, stroke, fill);
0500: }
0501:
0502: /**
0503: * create a mark with the supplied fill and stroke
0504: *
0505: * @param wellKnownName
0506: * the well known name of the mark
0507: * @param fill
0508: * the fill to use
0509: * @param stroke
0510: * the stroke to use
0511: *
0512: * @return the mark created
0513: */
0514: public static Mark createMark(String wellKnownName, Fill fill,
0515: Stroke stroke) {
0516: return new Mark(wellKnownName, stroke, fill);
0517: }
0518:
0519: /**
0520: * wrapper for stylefactory method
0521: *
0522: * @param uri
0523: * the uri of the image
0524: * @param format
0525: * mime type of the image
0526: *
0527: * @return the external graphic
0528: */
0529: public static ExternalGraphic createExternalGraphic(String uri,
0530: String format) throws MalformedURLException {
0531: return createExternalGraphic(new URL(uri), format);
0532: }
0533:
0534: /**
0535: * wrapper for stylefactory method
0536: *
0537: * @param url
0538: * the url of the image
0539: * @param format
0540: * mime type of the image
0541: *
0542: * @return the external graphic
0543: */
0544: public static ExternalGraphic createExternalGraphic(
0545: java.net.URL url, String format) {
0546: return new ExternalGraphic(format, url);
0547: }
0548:
0549: /**
0550: * creates a graphic object
0551: *
0552: * @param externalGraphic
0553: * an external graphic to use if displayable
0554: * @param mark
0555: * a mark to use
0556: * @param opacity -
0557: * the opacity of the graphic
0558: * @param size -
0559: * the size of the graphic
0560: * @param rotation -
0561: * the rotation from the top of the page of the graphic
0562: *
0563: * @return the graphic created
0564: */
0565: public static Graphic createGraphic(
0566: ExternalGraphic externalGraphic, Mark mark, double opacity,
0567: double size, double rotation) {
0568:
0569: Object[] mae = null;
0570: if (externalGraphic != null && mark != null) {
0571: mae = new Object[] { externalGraphic, mark };
0572: } else if (externalGraphic != null) {
0573: mae = new Object[] { externalGraphic };
0574: } else if (mark != null) {
0575: mae = new Object[] { mark };
0576: }
0577: ParameterValueType op_pvt = createParameterValueType(opacity);
0578: ParameterValueType sz_pvt = createParameterValueType(size);
0579: ParameterValueType ro_pvt = createParameterValueType(rotation);
0580: return new Graphic(mae, op_pvt, sz_pvt, ro_pvt);
0581: }
0582:
0583: /**
0584: * wrapper round Stylefactory Method
0585: *
0586: * @return the default pointplacement
0587: */
0588: public static PointPlacement createPointPlacement() {
0589: return new PointPlacement();
0590: }
0591:
0592: /**
0593: * wrapper round Stylefactory Method
0594: *
0595: * @param anchorX -
0596: * the X coordinate
0597: * @param anchorY -
0598: * the Y coordinate
0599: * @param rotation -
0600: * the rotaion of the label
0601: *
0602: * @return the pointplacement created
0603: */
0604: public static PointPlacement createPointPlacement(double anchorX,
0605: double anchorY, double rotation) {
0606: ParameterValueType pvt1 = createParameterValueType(anchorX);
0607: ParameterValueType pvt2 = createParameterValueType(anchorY);
0608: ParameterValueType[] anchorPoint = new ParameterValueType[] {
0609: pvt1, pvt2 };
0610: ParameterValueType rot = createParameterValueType(rotation);
0611: return new PointPlacement(anchorPoint, null, rot, false);
0612: }
0613:
0614: /**
0615: * wrapper round Stylefactory Method
0616: *
0617: * @param anchorX -
0618: * the X coordinate
0619: * @param anchorY -
0620: * the Y coordinate
0621: * @param displacementX -
0622: * the X distance from the anchor
0623: * @param displacementY -
0624: * the Y distance from the anchor
0625: * @param rotation -
0626: * the rotaion of the label
0627: *
0628: * @return the pointplacement created
0629: */
0630: public static PointPlacement createPointPlacement(double anchorX,
0631: double anchorY, double displacementX, double displacementY,
0632: double rotation) {
0633: ParameterValueType pvt1 = createParameterValueType(anchorX);
0634: ParameterValueType pvt2 = createParameterValueType(anchorY);
0635: ParameterValueType[] anchorPoint = new ParameterValueType[] {
0636: pvt1, pvt2 };
0637:
0638: ParameterValueType pvt3 = createParameterValueType(displacementX);
0639: ParameterValueType pvt4 = createParameterValueType(displacementY);
0640: ParameterValueType[] displacement = new ParameterValueType[] {
0641: pvt3, pvt4 };
0642:
0643: ParameterValueType rot = createParameterValueType(rotation);
0644: return new PointPlacement(anchorPoint, displacement, rot, false);
0645: }
0646:
0647: /**
0648: * @param anchorX -
0649: * the X coordinate
0650: * @param anchorY -
0651: * the Y coordinate
0652: * @param displacementX -
0653: * the X distance from the anchor
0654: * @param displacementY -
0655: * the Y distance from the anchor
0656: * @param rotation -
0657: * the rotaion of the label
0658: * @param auto -
0659: * auto positioning of the label
0660: *
0661: * @return the pointplacement created
0662: */
0663: public static PointPlacement createPointPlacement(double anchorX,
0664: double anchorY, double displacementX, double displacementY,
0665: double rotation, boolean auto) {
0666: ParameterValueType pvt1 = createParameterValueType(anchorX);
0667: ParameterValueType pvt2 = createParameterValueType(anchorY);
0668: ParameterValueType[] anchorPoint = new ParameterValueType[] {
0669: pvt1, pvt2 };
0670:
0671: ParameterValueType pvt3 = createParameterValueType(displacementX);
0672: ParameterValueType pvt4 = createParameterValueType(displacementY);
0673: ParameterValueType[] displacement = new ParameterValueType[] {
0674: pvt3, pvt4 };
0675:
0676: ParameterValueType rot = createParameterValueType(rotation);
0677: return new PointPlacement(anchorPoint, displacement, rot, auto);
0678: }
0679:
0680: /**
0681: * creates a <tt>LinePlacement</tt> with a user defined distance between the labels and the
0682: * lines. A positive value indicates a position above the line, a negative value indicates a
0683: * position below. The line width is asumed to be 2 pixel and the gap between the labels is set
0684: * to factor 10 of the label width.
0685: *
0686: * @param offset -
0687: * the distance between the line and the label
0688: *
0689: * @return the LinePlacement created
0690: */
0691: public static LinePlacement createLinePlacement(double offset) {
0692:
0693: ParameterValueType perpendicularOffset = createParameterValueType(offset);
0694: ParameterValueType lineWidth = createParameterValueType(2);
0695: ParameterValueType gap = createParameterValueType(10);
0696:
0697: return new LinePlacement(perpendicularOffset, lineWidth, gap);
0698: }
0699:
0700: /**
0701: * creates a <tt>LinePlacement</tt> with a relative position of the label according to the
0702: * line the lines. The line width is asumed to be 2 pixel and the gap between the labels is set
0703: * to factor 10 of the label width.
0704: *
0705: * @param position
0706: * of the label relative to the line
0707: *
0708: * @return the LinePlacement created
0709: */
0710: public static LinePlacement createLinePlacement(String position) {
0711:
0712: ParameterValueType perpendicularOffset = createParameterValueType(position);
0713: ParameterValueType lineWidth = createParameterValueType(2);
0714: ParameterValueType gap = createParameterValueType(10);
0715:
0716: return new LinePlacement(perpendicularOffset, lineWidth, gap);
0717: }
0718:
0719: /**
0720: * creates a <tt>LinePlacement</tt> with a user defined distance between the labels and the
0721: * lines. A positive value indicates a position above the line, a negative value indicates a
0722: * position below.
0723: *
0724: * @param offset -
0725: * the distance between the line and the label
0726: * @param lineWidth -
0727: * assumed lineWidth
0728: * @param gap -
0729: * gap between the labels measured in label width
0730: *
0731: * @return the LinePlacement created
0732: */
0733: public static LinePlacement createLinePlacement(double offset,
0734: double lineWidth, int gap) {
0735:
0736: ParameterValueType perpendicularOffset = createParameterValueType(offset);
0737: ParameterValueType lineWidth_ = createParameterValueType(lineWidth);
0738: ParameterValueType gap_ = createParameterValueType(gap);
0739:
0740: return new LinePlacement(perpendicularOffset, lineWidth_, gap_);
0741: }
0742:
0743: /**
0744: * creates a <tt>LinePlacement</tt> with a user defined distance between the labels and the
0745: * lines. A positive value indicates a position above the line, a negative value indicates a
0746: * position below.
0747: *
0748: * @param position -
0749: * relative position of the label to the line
0750: * @param lineWidth -
0751: * assumed lineWidth
0752: * @param gap -
0753: * gap between the labels measured in label width
0754: *
0755: * @return the LinePlacement created
0756: */
0757: public static LinePlacement createLinePlacement(String position,
0758: double lineWidth, int gap) {
0759:
0760: ParameterValueType perpendicularOffset = createParameterValueType(position);
0761: ParameterValueType lineWidth_ = createParameterValueType(lineWidth);
0762: ParameterValueType gap_ = createParameterValueType(gap);
0763:
0764: return new LinePlacement(perpendicularOffset, lineWidth_, gap_);
0765: }
0766:
0767: /**
0768: * creates a label placement that is orientated on a line
0769: *
0770: * @param linePlacement
0771: * description of the line where the lable will be orientated on
0772: * @return created LabelPlacement
0773: */
0774: public static LabelPlacement createLabelPlacement(
0775: LinePlacement linePlacement) {
0776: return new LabelPlacement(linePlacement);
0777: }
0778:
0779: /**
0780: * creates a label placement that is orientated on a point
0781: *
0782: * @param pointPlacement
0783: * description of the point where the lable will be orientated on
0784: * @return created LabelPlacement
0785: */
0786: public static LabelPlacement createLabelPlacement(
0787: PointPlacement pointPlacement) {
0788: return new LabelPlacement(pointPlacement);
0789: }
0790:
0791: /**
0792: * create a geotools font object from a java font
0793: *
0794: * @param font -
0795: * the font to be converted
0796: *
0797: * @return - the deegree sld font
0798: */
0799: public static Font createFont(java.awt.Font font) {
0800: return createFont(font.getFamily(), font.isItalic(), font
0801: .isBold(), font.getSize());
0802: }
0803:
0804: /**
0805: * create font of supplied family and size
0806: *
0807: * @param fontFamily -
0808: * the font family
0809: * @param fontSize -
0810: * the size of the font in points
0811: *
0812: * @return the font object created
0813: */
0814: public static Font createFont(String fontFamily, double fontSize) {
0815: return createFont(fontFamily, false, false, fontSize);
0816: }
0817:
0818: /**
0819: * create font of supplied family, size and weight/style
0820: *
0821: * @param fontFamily -
0822: * the font family
0823: * @param italic -
0824: * should the font be italic?
0825: * @param bold -
0826: * should the font be bold?
0827: * @param fontSize -
0828: * the size of the font in points
0829: *
0830: * @return the new font object
0831: */
0832: public static Font createFont(String fontFamily, boolean italic,
0833: boolean bold, double fontSize) {
0834: HashMap<String, Object> cssParams = new HashMap<String, Object>();
0835:
0836: cssParams.put("font-family", createCssParameter("font-family",
0837: fontFamily));
0838: cssParams.put("font-size", createCssParameter("font-size", ""
0839: + fontSize));
0840: if (bold) {
0841: cssParams.put("font-weight", createCssParameter(
0842: "font-weight", "bold"));
0843: } else {
0844: cssParams.put("font-weight", createCssParameter(
0845: "font-weight", "normal"));
0846: }
0847: if (italic) {
0848: cssParams.put("font-style", createCssParameter(
0849: "font-style", "italic"));
0850: } else {
0851: cssParams.put("font-style", createCssParameter(
0852: "font-style", "normal"));
0853: }
0854:
0855: return new Font(cssParams);
0856: }
0857:
0858: /**
0859: * wrapper round StyleFactory method to create default halo
0860: *
0861: * @return the new halo
0862: */
0863: public static Halo createHalo() {
0864: return createHalo(createFill(), createStroke(), -1);
0865: }
0866:
0867: /**
0868: * wrapper round StyleFactory method to create halo
0869: *
0870: * @param color -
0871: * the color of the halo
0872: * @param radius -
0873: * the radius of the halo use a value <= 0 for rectangle
0874: *
0875: * @return the new halo
0876: */
0877: public static Halo createHalo(Color color, double radius) {
0878: return createHalo(createFill(color), createStroke(), radius);
0879: }
0880:
0881: /**
0882: * wrapper round StyleFactory method to create halo
0883: *
0884: * @param fillColor -
0885: * the fill color of the halo
0886: * @param opacity -
0887: * the opacity of the halo fill 0 - transparent 1 - solid
0888: * @param strokeColor -
0889: * the stroke color of the halo
0890: * @param radius -
0891: * the radius of the halo use a value <= 0 for rectangle
0892: *
0893: * @return the new halo
0894: */
0895: public static Halo createHalo(Color fillColor, double opacity,
0896: Color strokeColor, double radius) {
0897: Fill fill = createFill(fillColor, opacity);
0898: Stroke stroke = createStroke(strokeColor);
0899: return createHalo(fill, stroke, radius);
0900: }
0901:
0902: /**
0903: * wrapper round StyleFactory method to create halo
0904: *
0905: * @param fill -
0906: * the fill of the halo
0907: * @param stroke -
0908: * the stroke of the halo
0909: * @param radius -
0910: * the radius of the halo use a value <= 0 for rectangle
0911: *
0912: * @return the new halo
0913: */
0914: public static Halo createHalo(Fill fill, Stroke stroke,
0915: double radius) {
0916: ParameterValueType pvt = null;
0917: if (radius > 0) {
0918: pvt = createParameterValueType(radius);
0919: }
0920: return new Halo(pvt, fill, stroke);
0921: }
0922:
0923: /**
0924: * create a default line symboliser
0925: *
0926: * @return the new line symbolizer
0927: */
0928: public static LineSymbolizer createLineSymbolizer() {
0929: return createLineSymbolizer(createStroke(1), null);
0930: }
0931:
0932: /**
0933: * create a new line symbolizer
0934: *
0935: * @param width
0936: * the width of the line
0937: *
0938: * @return the new line symbolizer
0939: */
0940: public static LineSymbolizer createLineSymbolizer(double width) {
0941: return createLineSymbolizer(createStroke(width), null);
0942: }
0943:
0944: /**
0945: * create a LineSymbolizer
0946: *
0947: * @param color -
0948: * the color of the line
0949: *
0950: * @return the new line symbolizer
0951: */
0952: public static LineSymbolizer createLineSymbolizer(Color color) {
0953: return createLineSymbolizer(createStroke(color), null);
0954: }
0955:
0956: /**
0957: * create a LineSymbolizer
0958: *
0959: * @param color -
0960: * the color of the line
0961: * @param width -
0962: * the width of the line
0963: *
0964: * @return the new line symbolizer
0965: */
0966: public static LineSymbolizer createLineSymbolizer(Color color,
0967: double width) {
0968: return createLineSymbolizer(createStroke(color, width), null);
0969: }
0970:
0971: /**
0972: * create a LineSymbolizer
0973: *
0974: * @param color -
0975: * the color of the line
0976: * @param width -
0977: * the width of the line
0978: * @param geometryPropertyName -
0979: * the name of the geometry to be drawn
0980: *
0981: * @return the new line symbolizer
0982: */
0983: public static LineSymbolizer createLineSymbolizer(Color color,
0984: double width, PropertyPath geometryPropertyName) {
0985: return createLineSymbolizer(createStroke(color, width),
0986: geometryPropertyName);
0987: }
0988:
0989: /**
0990: * create a LineSymbolizer
0991: *
0992: * @param stroke -
0993: * the stroke to be used to draw the line
0994: *
0995: * @return the new line symbolizer
0996: */
0997: public static LineSymbolizer createLineSymbolizer(Stroke stroke) {
0998: return createLineSymbolizer(stroke, null);
0999: }
1000:
1001: /**
1002: * create a LineSymbolizer
1003: *
1004: * @param stroke -
1005: * the stroke to be used to draw the line
1006: * @param geometryPropertyName -
1007: * the name of the geometry to be drawn
1008: *
1009: * @return the new line symbolizer
1010: */
1011: public static LineSymbolizer createLineSymbolizer(Stroke stroke,
1012: PropertyPath geometryPropertyName) {
1013: return createLineSymbolizer(stroke, geometryPropertyName, 0,
1014: Double.MAX_VALUE);
1015: }
1016:
1017: /**
1018: * create a LineSymbolizer
1019: *
1020: * @param stroke -
1021: * the stroke to be used to draw the line
1022: * @param geometryPropertyName -
1023: * the name of the geometry to be drawn
1024: * @param min
1025: * min scale denominator
1026: * @param max
1027: * max scale denominator
1028: *
1029: * @return the new line symbolizer
1030: */
1031: public static LineSymbolizer createLineSymbolizer(Stroke stroke,
1032: PropertyPath geometryPropertyName, double min, double max) {
1033: Geometry geom = null;
1034: if (geometryPropertyName != null) {
1035: geom = new Geometry(geometryPropertyName, null);
1036: }
1037: return new LineSymbolizer(stroke, geom, min, max);
1038: }
1039:
1040: /**
1041: * create a default polygon symbolizer
1042: *
1043: * @return the new polygon symbolizer
1044: */
1045: public static PolygonSymbolizer createPolygonSymbolizer() {
1046: return createPolygonSymbolizer(createStroke(), createFill());
1047: }
1048:
1049: /**
1050: * create a polygon symbolizer
1051: *
1052: * @param fillColor -
1053: * the color to fill the polygon
1054: *
1055: * @return the new polygon symbolizer
1056: */
1057: public static PolygonSymbolizer createPolygonSymbolizer(
1058: Color fillColor) {
1059: return createPolygonSymbolizer(createStroke(),
1060: createFill(fillColor));
1061: }
1062:
1063: /**
1064: * create a polygon symbolizer
1065: *
1066: * @param fillColor -
1067: * the color to fill the polygon
1068: * @param borderColor -
1069: * the outline color of the polygon
1070: * @param borderWidth -
1071: * the width of the outline
1072: *
1073: * @return the new polygon symbolizer
1074: */
1075: public static PolygonSymbolizer createPolygonSymbolizer(
1076: Color fillColor, Color borderColor, double borderWidth) {
1077: return createPolygonSymbolizer(createStroke(borderColor,
1078: borderWidth), createFill(fillColor));
1079: }
1080:
1081: /**
1082: * create a polygon symbolizer
1083: *
1084: * @param borderColor -
1085: * the outline color of the polygon
1086: * @param borderWidth -
1087: * the width of the outline
1088: *
1089: * @return the new polygon symbolizer
1090: */
1091: public static PolygonSymbolizer createPolygonSymbolizer(
1092: Color borderColor, double borderWidth) {
1093: Stroke stroke = createStroke(borderColor, borderWidth);
1094: return createPolygonSymbolizer(stroke, createFill());
1095: }
1096:
1097: /**
1098: * create a polygon symbolizer
1099: *
1100: * @param stroke -
1101: * the stroke to use to outline the polygon
1102: * @param fill -
1103: * the fill to use to color the polygon
1104: *
1105: * @return the new polygon symbolizer
1106: */
1107: public static PolygonSymbolizer createPolygonSymbolizer(
1108: Stroke stroke, Fill fill) {
1109: return createPolygonSymbolizer(stroke, fill, null);
1110: }
1111:
1112: /**
1113: * create a polygon symbolizer
1114: *
1115: * @param stroke -
1116: * the stroke to use to outline the polygon
1117: * @param fill -
1118: * the fill to use to color the polygon
1119: * @param geometryPropertyName -
1120: * the name of the geometry to be drawn
1121: *
1122: * @return the new polygon symbolizer
1123: */
1124: public static PolygonSymbolizer createPolygonSymbolizer(
1125: Stroke stroke, Fill fill, PropertyPath geometryPropertyName) {
1126: return createPolygonSymbolizer(stroke, fill,
1127: geometryPropertyName, 0, Double.MAX_VALUE);
1128: }
1129:
1130: /**
1131: * create a polygon symbolizer
1132: *
1133: * @param stroke -
1134: * the stroke to use to outline the polygon
1135: * @param fill -
1136: * the fill to use to color the polygon
1137: * @param geometryPropertyName -
1138: * the name of the geometry to be drawn
1139: * @param min
1140: * min scale denominator
1141: * @param max
1142: * max scale denominator
1143: *
1144: * @return the new polygon symbolizer
1145: */
1146: public static PolygonSymbolizer createPolygonSymbolizer(
1147: Stroke stroke, Fill fill,
1148: PropertyPath geometryPropertyName, double min, double max) {
1149: Geometry geom = null;
1150: if (geometryPropertyName != null) {
1151: geom = new Geometry(geometryPropertyName, null);
1152: }
1153: return new PolygonSymbolizer(fill, stroke, geom, min, max);
1154: }
1155:
1156: /**
1157: * create a default point symbolizer
1158: *
1159: * @return the new point symbolizer
1160: */
1161: public static PointSymbolizer createPointSymbolizer() {
1162: Graphic graphic = createGraphic(null, null, 1, 5, 0);
1163: return createPointSymbolizer(graphic);
1164: }
1165:
1166: /**
1167: * create a point symbolizer
1168: *
1169: * @param graphic -
1170: * the graphic object to draw at the point
1171: *
1172: * @return the new point symbolizer
1173: */
1174: public static PointSymbolizer createPointSymbolizer(Graphic graphic) {
1175: return createPointSymbolizer(graphic, null);
1176: }
1177:
1178: /**
1179: * create a point symbolizer
1180: *
1181: * @param graphic -
1182: * the graphic object to draw at the point
1183: * @param geometryPropertyName -
1184: * the name of the geometry to be drawn
1185: *
1186: * @return the new point symbolizer
1187: */
1188: public static PointSymbolizer createPointSymbolizer(
1189: Graphic graphic, PropertyPath geometryPropertyName) {
1190: return createPointSymbolizer(graphic, geometryPropertyName, 0,
1191: Double.MAX_VALUE);
1192: }
1193:
1194: /**
1195: * create a point symbolizer
1196: *
1197: * @param graphic -
1198: * the graphic object to draw at the point
1199: * @param geometryPropertyName -
1200: * the name of the geometry to be drawn
1201: * @param min
1202: * min scale denominator
1203: * @param max
1204: * max scale denominator
1205: *
1206: * @return the new point symbolizer
1207: */
1208: public static PointSymbolizer createPointSymbolizer(
1209: Graphic graphic, PropertyPath geometryPropertyName,
1210: double min, double max) {
1211: Geometry geom = null;
1212: if (geometryPropertyName != null) {
1213: geom = new Geometry(geometryPropertyName, null);
1214: }
1215: return new PointSymbolizer(graphic, geom, min, max);
1216: }
1217:
1218: /**
1219: * create a textsymbolizer
1220: *
1221: * @param color
1222: * the color of the text
1223: * @param font
1224: * the font to use
1225: * @param attributeName
1226: * the attribute to use for the label
1227: *
1228: * @return the new textsymbolizer
1229: *
1230: */
1231: public static TextSymbolizer createTextSymbolizer(Color color,
1232: Font font, String attributeName,
1233: LabelPlacement labelPlacement) {
1234: ParameterValueType label = createParameterValueType(attributeName);
1235: Fill fill = createFill(color);
1236: Halo halo = createHalo();
1237: return createTextSymbolizer(null, label, font, labelPlacement,
1238: halo, fill, 0, Double.MAX_VALUE);
1239: }
1240:
1241: /**
1242: * create a textsymbolizer
1243: *
1244: * @param geometryPropertyName
1245: * geometry assigned to the TextSymbolizer
1246: * @param attribute
1247: * attribute to draw/print
1248: * @param labelPlacement
1249: * defines the placement of the text
1250: *
1251: * @return the new textsymbolizer
1252: *
1253: */
1254: public static TextSymbolizer createTextSymbolizer(
1255: PropertyPath geometryPropertyName, String attribute,
1256: LabelPlacement labelPlacement) {
1257: Font font = createFont(java.awt.Font.decode("Sans Serif"));
1258: return createTextSymbolizer(geometryPropertyName, attribute,
1259: font, labelPlacement, createHalo(), createFill(), 0,
1260: Double.MAX_VALUE);
1261: }
1262:
1263: /**
1264: * create a textsymbolizer
1265: *
1266: * @param geometryPropertyName
1267: * geometry assigned to the TextSymbolizer
1268: * @param attribute
1269: * attribute to draw/print
1270: * @param font
1271: * font to use for the text
1272: * @param labelPlacement
1273: * defines the placement of the text
1274: * @param halo
1275: * halo/backgroud of the text
1276: * @param fill
1277: * color, opacity of the text
1278: * @param min
1279: * min scale denominator
1280: * @param max
1281: * max scale denominator
1282: *
1283: * @return the new textsymbolizer
1284: *
1285: */
1286: public static TextSymbolizer createTextSymbolizer(
1287: PropertyPath geometryPropertyName, String attribute,
1288: Font font, LabelPlacement labelPlacement, Halo halo,
1289: Fill fill, double min, double max) {
1290: Geometry geom = null;
1291: if (geometryPropertyName != null) {
1292: geom = new Geometry(geometryPropertyName, null);
1293: }
1294: ParameterValueType label = createParameterValueType(attribute);
1295: return createTextSymbolizer(geom, label, font, labelPlacement,
1296: halo, fill, min, max);
1297: }
1298:
1299: /**
1300: * create a textsymbolizer
1301: *
1302: * @param geometry
1303: * geometry assigned to the TextSymbolizer
1304: * @param label
1305: * attribute to draw/print
1306: * @param font
1307: * font to use for the text
1308: * @param labelPlacement
1309: * defines the placement of the text
1310: * @param halo
1311: * halo/backgroud of the text
1312: * @param fill
1313: * color, opacity of the text
1314: * @param min
1315: * min scale denominator
1316: * @param max
1317: * max scale denominator
1318: *
1319: * @return the new textsymbolizer
1320: *
1321: */
1322: public static TextSymbolizer createTextSymbolizer(
1323: Geometry geometry, ParameterValueType label, Font font,
1324: LabelPlacement labelPlacement, Halo halo, Fill fill,
1325: double min, double max) {
1326: return new TextSymbolizer(geometry, label, font,
1327: labelPlacement, halo, fill, min, max);
1328: }
1329:
1330: /**
1331: * create a textsymbolizer which doesn't change
1332: *
1333: * @param color
1334: * the color of the text
1335: * @param font
1336: * the font to use
1337: * @param label
1338: * the label to use
1339: *
1340: * @return the new textsymbolizer
1341: */
1342: public static TextSymbolizer createStaticTextSymbolizer(
1343: Color color, Font font, String label) {
1344: throw new UnsupportedOperationException(
1345: "method createStaticTextSymbolizer is not implemented yet");
1346: }
1347:
1348: /**
1349: * create a textsymbolizer which doesn't change
1350: *
1351: * @param color
1352: * the color of the text
1353: * @param fonts
1354: * an array of fonts to use from the first to last
1355: * @param label
1356: * the label to use
1357: *
1358: * @return the new textsymbolizer
1359: */
1360: public static TextSymbolizer createStaticTextSymbolizer(
1361: Color color, Font[] fonts, String label) {
1362: throw new UnsupportedOperationException(
1363: "method createStaticTextSymbolizer is not implemented yet");
1364: }
1365:
1366: /**
1367: * create a simple styling rule
1368: *
1369: * @param symbolizer -
1370: * the symbolizer to use
1371: *
1372: * @return the new rule
1373: */
1374: public static Rule createRule(Symbolizer symbolizer) {
1375: return createRule(symbolizer, 0, Double.MAX_VALUE);
1376: }
1377:
1378: /**
1379: * reate a simple styling rule
1380: *
1381: * @param symbolizers -
1382: * an array of symbolizers to use
1383: *
1384: * @return the new rule
1385: */
1386: public static Rule createRule(Symbolizer[] symbolizers) {
1387: return createRule(symbolizers, 0, Double.MAX_VALUE);
1388: }
1389:
1390: /**
1391: * create a simple styling rule, see the SLD Spec for more details of scaleDenominators
1392: *
1393: * @param symbolizer -
1394: * the symbolizer to use
1395: * @param minScaleDenominator -
1396: * the minimim scale to draw the feature at
1397: * @param maxScaleDenominator -
1398: * the maximum scale to draw the feature at
1399: *
1400: * @return the new rule
1401: */
1402: public static Rule createRule(Symbolizer symbolizer,
1403: double minScaleDenominator, double maxScaleDenominator) {
1404: return createRule(new Symbolizer[] { symbolizer },
1405: minScaleDenominator, maxScaleDenominator);
1406: }
1407:
1408: /**
1409: * create a simple styling rule, see the SLD Spec for more details of scaleDenominators
1410: *
1411: * @param symbolizers -
1412: * an array of symbolizers to use
1413: * @param minScaleDenominator -
1414: * the minimim scale to draw the feature at
1415: * @param maxScaleDenominator -
1416: * the maximum scale to draw the feature at
1417: *
1418: * @return the new rule
1419: */
1420: public static Rule createRule(Symbolizer[] symbolizers,
1421: double minScaleDenominator, double maxScaleDenominator) {
1422: return createRule(symbolizers, "default", "default", "default",
1423: minScaleDenominator, maxScaleDenominator);
1424: }
1425:
1426: /**
1427: * create a simple styling rule, see the SLD Spec for more details of scaleDenominators
1428: *
1429: * @param symbolizers -
1430: * an array of symbolizers to use
1431: * @param name -
1432: * name of the rule
1433: * @param title -
1434: * title of the rule
1435: * @param abstract_ -
1436: * text describing throws rule
1437: * @param minScaleDenominator -
1438: * the minimim scale to draw the feature at
1439: * @param maxScaleDenominator -
1440: * the maximum scale to draw the feature at
1441: *
1442: * @return the new rule
1443: */
1444: public static Rule createRule(Symbolizer[] symbolizers,
1445: String name, String title, String abstract_,
1446: double minScaleDenominator, double maxScaleDenominator) {
1447: return createRule(symbolizers, name, title, abstract_, null,
1448: null, false, minScaleDenominator, maxScaleDenominator);
1449: }
1450:
1451: /**
1452: * create a complex styling rule, see the SLD Spec for more details of scaleDenominators
1453: *
1454: * @param symbolizers -
1455: * an array of symbolizers to use
1456: * @param name -
1457: * name of the rule
1458: * @param title -
1459: * title of the rule
1460: * @param abstract_ -
1461: * text describing throws rule
1462: * @param filter -
1463: * filter to use with the rule
1464: * @param elseFilter -
1465: * true if the passed is an ElseFilter (see SLD spec)
1466: * @param minScaleDenominator -
1467: * the minimim scale to draw the feature at
1468: * @param maxScaleDenominator -
1469: * the maximum scale to draw the feature at
1470: *
1471: * @return the new rule
1472: */
1473: public static Rule createRule(Symbolizer[] symbolizers,
1474: String name, String title, String abstract_,
1475: LegendGraphic legendGraphic, Filter filter,
1476: boolean elseFilter, double minScaleDenominator,
1477: double maxScaleDenominator) {
1478: return new Rule(symbolizers, name, title, abstract_,
1479: legendGraphic, filter, elseFilter, minScaleDenominator,
1480: maxScaleDenominator);
1481: }
1482:
1483: /**
1484: * create a Feature type styler
1485: *
1486: * @param symbolizer -
1487: * the symbolizer to use
1488: *
1489: * @return the new feature type styler
1490: */
1491: public static FeatureTypeStyle createFeatureTypeStyle(
1492: Symbolizer symbolizer) {
1493: return createFeatureTypeStyle(null, symbolizer, 0,
1494: Double.MAX_VALUE);
1495: }
1496:
1497: /**
1498: * create a Feature type styler see the SLD Spec for more details of scaleDenominators
1499: *
1500: * @param symbolizer -
1501: * the symbolizer to use
1502: * @param minScaleDenominator -
1503: * the minimim scale to draw the feature at
1504: * @param maxScaleDenominator -
1505: * the maximum scale to draw the feature at
1506: *
1507: * @return the new feature type styler
1508: */
1509: public static FeatureTypeStyle createFeatureTypeStyle(
1510: Symbolizer symbolizer, double minScaleDenominator,
1511: double maxScaleDenominator) {
1512: return createFeatureTypeStyle(null, symbolizer,
1513: minScaleDenominator, maxScaleDenominator);
1514: }
1515:
1516: /**
1517: * create a Feature type styler see the SLD Spec for more details of scaleDenominators
1518: *
1519: * @param symbolizers -
1520: * an array of symbolizers to use
1521: * @param minScaleDenominator -
1522: * the minimim scale to draw the feature at
1523: * @param maxScaleDenominator -
1524: * the maximum scale to draw the feature at
1525: *
1526: * @return the new feature type styler
1527: */
1528: public static FeatureTypeStyle createFeatureTypeStyle(
1529: Symbolizer[] symbolizers, double minScaleDenominator,
1530: double maxScaleDenominator) {
1531: return createFeatureTypeStyle(null, symbolizers,
1532: minScaleDenominator, maxScaleDenominator);
1533: }
1534:
1535: /**
1536: * create a Feature type styler
1537: *
1538: * @param featureTypeStyleName -
1539: * name for the feature type styler
1540: * @param symbolizer -
1541: * the symbolizer to use
1542: *
1543: * @return the new feature type styler
1544: */
1545: public static FeatureTypeStyle createFeatureTypeStyle(
1546: String featureTypeStyleName, Symbolizer symbolizer) {
1547: return createFeatureTypeStyle(featureTypeStyleName, symbolizer,
1548: 0, Double.MAX_VALUE);
1549: }
1550:
1551: /**
1552: * create a Feature type styler
1553: *
1554: * @param featureTypeStyleName -
1555: * name for the feature type styler
1556: * @param symbolizers -
1557: * an array of symbolizers to use
1558: *
1559: * @return the new feature type styler
1560: */
1561: public static FeatureTypeStyle createFeatureTypeStyle(
1562: String featureTypeStyleName, Symbolizer[] symbolizers) {
1563: return createFeatureTypeStyle(featureTypeStyleName,
1564: symbolizers, 0, Double.MAX_VALUE);
1565: }
1566:
1567: /**
1568: * create a Feature type styler see the SLD Spec for more details of scaleDenominators
1569: *
1570: * @param featureTypeStyleName -
1571: * name for the feature type styler
1572: * @param symbolizer -
1573: * the symbolizer to use
1574: * @param minScaleDenominator -
1575: * the minimim scale to draw the feature at
1576: * @param maxScaleDenominator -
1577: * the maximum scale to draw the feature at
1578: *
1579: * @return the new feature type styler
1580: */
1581: public static FeatureTypeStyle createFeatureTypeStyle(
1582: String featureTypeStyleName, Symbolizer symbolizer,
1583: double minScaleDenominator, double maxScaleDenominator) {
1584: return createFeatureTypeStyle(featureTypeStyleName,
1585: new Symbolizer[] { symbolizer }, minScaleDenominator,
1586: maxScaleDenominator);
1587: }
1588:
1589: /**
1590: * create a Feature type styler see the SLD Spec for more details of scaleDenominators
1591: *
1592: * @param featureTypeStyleName -
1593: * name for the feature type styler
1594: * @param symbolizers -
1595: * an array of symbolizers to use
1596: * @param minScaleDenominator -
1597: * the minimim scale to draw the feature at
1598: * @param maxScaleDenominator -
1599: * the maximum scale to draw the feature at
1600: *
1601: * @return the new feature type styler
1602: */
1603: public static FeatureTypeStyle createFeatureTypeStyle(
1604: String featureTypeStyleName, Symbolizer[] symbolizers,
1605: double minScaleDenominator, double maxScaleDenominator) {
1606: Rule rule = createRule(symbolizers, minScaleDenominator,
1607: maxScaleDenominator);
1608:
1609: return createFeatureTypeStyle(featureTypeStyleName, rule);
1610: }
1611:
1612: /**
1613: * create a Feature type styler
1614: *
1615: * @param rule -
1616: * rule contained in the featureTypeStyle
1617: *
1618: * @return the new feature type styler
1619: */
1620: public static FeatureTypeStyle createFeatureTypeStyle(Rule rule) {
1621:
1622: return createFeatureTypeStyle(new Rule[] { rule });
1623: }
1624:
1625: /**
1626: * create a Feature type styler
1627: *
1628: * @param rules -
1629: * rules contained in the featureTypeStyle
1630: *
1631: * @return the new feature type styler
1632: */
1633: public static FeatureTypeStyle createFeatureTypeStyle(Rule[] rules) {
1634:
1635: return createFeatureTypeStyle(null, rules);
1636: }
1637:
1638: /**
1639: * create a Feature type styler
1640: *
1641: * @param featureTypeStyleName -
1642: * name for the feature type styler
1643: * @param rule -
1644: * rule contained in the featureTypeStyle
1645: *
1646: * @return the new feature type styler
1647: */
1648: public static FeatureTypeStyle createFeatureTypeStyle(
1649: String featureTypeStyleName, Rule rule) {
1650:
1651: return createFeatureTypeStyle(featureTypeStyleName,
1652: new Rule[] { rule });
1653: }
1654:
1655: /**
1656: * create a Feature type styler
1657: *
1658: * @param featureTypeStyleName -
1659: * name for the feature type styler
1660: * @param rules -
1661: * rules contained in the featureTypeStyle
1662: *
1663: * @return the new feature type styler
1664: */
1665: public static FeatureTypeStyle createFeatureTypeStyle(
1666: String featureTypeStyleName, Rule[] rules) {
1667:
1668: return createFeatureTypeStyle(featureTypeStyleName, null, null,
1669: null, rules);
1670: }
1671:
1672: /**
1673: * create a Feature type styler
1674: *
1675: * @param featureTypeStyleName -
1676: * name for the feature type styler
1677: * @param featureTypeName -
1678: * name of the feature type the Feature type style shall be assigned to
1679: * @param title -
1680: * title of the FeatureTypeStyle
1681: * @param abstract_ -
1682: * text describing the FeatureTypeStyle
1683: * @param rules -
1684: * rules contained in the featureTypeStyle
1685: *
1686: * @return the new feature type styler
1687: */
1688: public static FeatureTypeStyle createFeatureTypeStyle(
1689: String featureTypeStyleName, String title,
1690: String abstract_, String featureTypeName, Rule[] rules) {
1691:
1692: return new FeatureTypeStyle(featureTypeStyleName, title,
1693: abstract_, featureTypeName, null, rules);
1694: }
1695:
1696: /**
1697: * create a new style
1698: *
1699: * @param symbolizer -
1700: * the symbolizer to use
1701: *
1702: * @return the new style
1703: */
1704: public static AbstractStyle createStyle(Symbolizer symbolizer) {
1705: return createStyle(null, symbolizer, 0, Double.MAX_VALUE);
1706: }
1707:
1708: /**
1709: * create a new style with name 'default'
1710: *
1711: * @param symbolizer -
1712: * the symbolizer to use
1713: * @param minScaleDenominator -
1714: * the minimim scale to draw the feature at
1715: * @param maxScaleDenominator -
1716: * the maximum scale to draw the feature at
1717: *
1718: * @return the new style
1719: */
1720: public static AbstractStyle createStyle(Symbolizer symbolizer,
1721: double minScaleDenominator, double maxScaleDenominator) {
1722: return createStyle("default", symbolizer, minScaleDenominator,
1723: maxScaleDenominator);
1724: }
1725:
1726: /**
1727: * create a new style
1728: *
1729: * @param name -
1730: * the name of the style
1731: * @param symbolizer -
1732: * the symbolizer to use
1733: *
1734: * @return the new style
1735: */
1736: public static AbstractStyle createStyle(String name,
1737: Symbolizer symbolizer) {
1738: return createStyle(name, symbolizer, 0, Double.MAX_VALUE);
1739: }
1740:
1741: /**
1742: * create a new style
1743: *
1744: * @param name -
1745: * the name of the style
1746: * @param symbolizer -
1747: * the symbolizer to use
1748: * @param minScaleDenominator -
1749: * the minimim scale to draw the feature at
1750: * @param maxScaleDenominator -
1751: * the maximum scale to draw the feature at
1752: *
1753: * @return the new style
1754: */
1755: public static AbstractStyle createStyle(String name,
1756: Symbolizer symbolizer, double minScaleDenominator,
1757: double maxScaleDenominator) {
1758: // create the feature type style
1759: FeatureTypeStyle fts = createFeatureTypeStyle(name, symbolizer,
1760: minScaleDenominator, maxScaleDenominator);
1761:
1762: return createStyle(name, null, null, fts);
1763: }
1764:
1765: /**
1766: * create a style
1767: *
1768: * @param name -
1769: * the name of the style
1770: * @param featureTypeName -
1771: * name of the feature type the Feature type style shall be assigned to
1772: * @param title -
1773: * title of the FeatureTypeStyle
1774: * @param abstract_ -
1775: * text describing the FeatureTypeStyle
1776: * @param rules -
1777: * rules contained in the featureTypeStyle
1778: *
1779: * @return the new style
1780: */
1781: public static AbstractStyle createStyle(String name, String title,
1782: String abstract_, String featureTypeName, Rule[] rules) {
1783:
1784: FeatureTypeStyle fts = createFeatureTypeStyle(name, title,
1785: abstract_, featureTypeName, rules);
1786: return createStyle(name, null, null, fts);
1787: }
1788:
1789: /**
1790: * create a new style
1791: *
1792: * @param name -
1793: * the name of the style
1794: * @param title -
1795: * title of the style
1796: * @param abstract_ -
1797: * text describing the style
1798: * @param featureTypeStyle -
1799: * featureTypeStyle
1800: *
1801: * @return the new style
1802: */
1803: public static AbstractStyle createStyle(String name, String title,
1804: String abstract_, FeatureTypeStyle featureTypeStyle) {
1805: return createStyle(name, title, abstract_,
1806: new FeatureTypeStyle[] { featureTypeStyle });
1807: }
1808:
1809: /**
1810: * create a new style
1811: *
1812: * @param name -
1813: * the name of the style
1814: * @param title -
1815: * title of the style
1816: * @param abstract_ -
1817: * text describing the style
1818: * @param featureTypeStyles -
1819: * featureTypeStyle
1820: *
1821: * @return the new style
1822: */
1823: public static AbstractStyle createStyle(String name, String title,
1824: String abstract_, FeatureTypeStyle[] featureTypeStyles) {
1825: return new UserStyle(name, title, abstract_, false,
1826: featureTypeStyles);
1827: }
1828:
1829: /**
1830: * creates a style with name 'defaultPoint' for rendering point geometries
1831: *
1832: * @param wellKnownName
1833: * the well known name of the mark
1834: * @param fillColor
1835: * the color of the mark
1836: * @param borderColor
1837: * the outline color of the mark
1838: * @param borderWidth
1839: * the width of the outline
1840: * @param opacity -
1841: * the opacity of the graphic
1842: * @param size -
1843: * the size of the graphic
1844: * @param rotation -
1845: * the rotation from the top of the page of the graphic
1846: * @param min -
1847: * the minimim scale to draw the feature at
1848: * @param max -
1849: * the maximum scale to draw the feature at
1850: *
1851: * @return the style created
1852: */
1853: public static AbstractStyle createPointStyle(String wellKnownName,
1854: Color fillColor, Color borderColor, double borderWidth,
1855: double opacity, double size, double rotation, double min,
1856: double max) {
1857: Mark mark = createMark(wellKnownName, fillColor, borderColor,
1858: borderWidth);
1859: Graphic graphic = createGraphic(null, mark, opacity, size,
1860: rotation);
1861: Symbolizer symbolizer = createPointSymbolizer(graphic, null,
1862: min, max);
1863: return createStyle("defaultPoint", symbolizer);
1864: }
1865:
1866: /**
1867: * creates a style with name 'defaultLine' for rendering line geometries
1868: *
1869: * @param color
1870: * the line color
1871: * @param width
1872: * the width of the line
1873: * @param opacity -
1874: * the opacity of the line
1875: * @param min -
1876: * the minimim scale to draw the feature at
1877: * @param max -
1878: * the maximum scale to draw the feature at
1879: *
1880: * @return the style created
1881: */
1882: public static AbstractStyle createLineStyle(Color color,
1883: double width, double opacity, double min, double max) {
1884: Stroke stroke = createStroke(color, width, opacity);
1885: Symbolizer symbolizer = createLineSymbolizer(stroke, null, min,
1886: max);
1887: return createStyle("defaultLine", symbolizer);
1888: }
1889:
1890: /**
1891: * creates a style with name 'defaultPolygon' for rendering polygon geometries
1892: *
1893: * @param fillColor -
1894: * the fill color of the polygon
1895: * @param fillOpacity -
1896: * the fill opacity of the polygon
1897: * @param strokeColor -
1898: * the line color
1899: * @param strokeWidth -
1900: * the width of the line
1901: * @param strokeOpacity -
1902: * the opacity of the line
1903: * @param min -
1904: * the minimim scale to draw the feature at
1905: * @param max -
1906: * the maximum scale to draw the feature at
1907: *
1908: * @return the style created
1909: */
1910: public static AbstractStyle createPolygonStyle(Color fillColor,
1911: double fillOpacity, Color strokeColor, double strokeWidth,
1912: double strokeOpacity, double min, double max) {
1913: Stroke stroke = createStroke(strokeColor, strokeWidth,
1914: strokeOpacity);
1915: Fill fill = createFill(fillColor, fillOpacity);
1916: Symbolizer symbolizer = createPolygonSymbolizer(stroke, fill,
1917: null, min, max);
1918: return createStyle("defaultPolygon", symbolizer);
1919: }
1920:
1921: /**
1922: * creates a style with name 'defaultPoint' for rendering point geometries. The style contains
1923: * 1..n rules depending on the value range and the number of steps within it. So it is possible
1924: * to create a style that creates different rendering depending on the value of one feature
1925: * attribute.
1926: * <p>
1927: * there will be a linear interpolation between colors, size and width of the first and the last
1928: * rule considering the number of passed steps (rules)
1929: *
1930: * @param wellKnownNames -
1931: * list of well known names of the mark. the first field will be assigned to the
1932: * starting rule the last to the ending rule.
1933: * @param startFillColor -
1934: * the color of the mark of the first rule
1935: * @param endFillColor -
1936: * the color of the mark of the last rule
1937: * @param startBorderColor -
1938: * the outline color of the mark of the first rule
1939: * @param endBorderColor -
1940: * the outline color of the mark of the last rule
1941: * @param startBorderWidth -
1942: * the width of the outline of the first rule
1943: * @param endBorderWidth -
1944: * the width of the outline of the last rule
1945: * @param opacity -
1946: * the opacity of the graphic
1947: * @param startSize -
1948: * the size of the graphic of the first rule
1949: * @param endSize -
1950: * the size of the graphic of the last rule
1951: * @param rotation -
1952: * the rotation from the top of the page of the graphic
1953: * @param min -
1954: * the minimim scale to draw the feature at
1955: * @param max -
1956: * the maximum scale to draw the feature at
1957: * @param featurePropertyName -
1958: * name of the feature property that determines the selection of the rule for drawing
1959: * @param numberOfSteps -
1960: * number of steps used for the interpolation between first and last value. It is
1961: * identical with the number of rules that will be created.
1962: *
1963: * @return the style created
1964: */
1965: public static AbstractStyle createPointStyle(
1966: String[] wellKnownNames, Color startFillColor,
1967: Color endFillColor, Color startBorderColor,
1968: Color endBorderColor, double startBorderWidth,
1969: double endBorderWidth, double opacity, double startSize,
1970: double endSize, double rotation, double min, double max,
1971: String featurePropertyName, int numberOfSteps) {
1972: throw new UnsupportedOperationException(
1973: "method createPointStyle is not implemented yet");
1974: }
1975:
1976: /**
1977: * creates a style with name 'defaultLine' for rendering line geometries. The style contains
1978: * 1..n rules depending on the value range and the number of steps within it. So it is possible
1979: * to create a style that creates different rendering depending on the value of one feature
1980: * attribute.
1981: * <p>
1982: * there will be a linear interpolation between colors, size and width of the first and the last
1983: * rule considering the number of passed steps (rules)
1984: *
1985: * @param startColor -
1986: * the color of the first rule
1987: * @param endColor -
1988: * the color of the last rule
1989: * @param startWidth -
1990: * the width of the line of the first rule
1991: * @param endWidth -
1992: * the width of the line of the last rule
1993: * @param opacity -
1994: * the opacity of the graphic
1995: * @param min -
1996: * the minimim scale to draw the feature at
1997: * @param max -
1998: * the maximum scale to draw the feature at
1999: * @param featurePropertyName -
2000: * name of the feature property that determines the selection of the rule for drawing
2001: * @param numberOfSteps -
2002: * number of steps used for the interpolation between first and last value. It is
2003: * identical with the number of rules that will be created.
2004: *
2005: * @return the style created
2006: */
2007: public static AbstractStyle createLineStyle(Color startColor,
2008: Color endColor, double startWidth, double endWidth,
2009: double opacity, double min, double max,
2010: String featurePropertyName, int numberOfSteps) {
2011: throw new UnsupportedOperationException(
2012: "method createLineStyle is not implemented yet");
2013: }
2014:
2015: /**
2016: * creates a style with name 'defaultPoint' for rendering point geometries. The style contains
2017: * 1..n rules depending on the value range and the number of steps within it. So it is possible
2018: * to create a style that creates different rendering depending on the value of one feature
2019: * attribute.
2020: * <p>
2021: * there will be a linear interpolation between colors, size and width of the first and the last
2022: * rule considering the number of passed steps (rules)
2023: *
2024: * @param startFillColor -
2025: * the fill color of the first rule
2026: * @param endFillColor -
2027: * the fill color of the last rule
2028: * @param fillOpacity -
2029: * the opacity of the fill
2030: * @param startStrokeColor -
2031: * the line color of the first rule
2032: * @param endStrokeColor -
2033: * the line color of the last rule
2034: * @param startStrokeWidth -
2035: * the width of the outline of the first rule
2036: * @param endStrokeWidth -
2037: * the width of the outline of the last rule
2038: * @param strokeOpacity -
2039: * the opacity of the outline
2040: * @param min -
2041: * the minimim scale to draw the feature at
2042: * @param max -
2043: * the maximum scale to draw the feature at
2044: * @param featurePropertyName -
2045: * name of the feature property that determines the selection of the rule for drawing
2046: * @param numberOfSteps -
2047: * number of steps used for the interpolation between first and last value. It is
2048: * identical with the number of rules that will be created.
2049: *
2050: * @return the style created
2051: */
2052: public static AbstractStyle createPolygonStyle(
2053: Color startFillColor, Color endFillColor,
2054: double fillOpacity, Color startStrokeColor,
2055: Color endStrokeColor, double startStrokeWidth,
2056: double endStrokeWidth, double strokeOpacity, double min,
2057: double max, String featurePropertyName, int numberOfSteps) {
2058: throw new UnsupportedOperationException(
2059: "method createPolygonStyle is not implemented yet");
2060: }
2061:
2062: /**
2063: * create a new default style
2064: *
2065: * @return the new style
2066: */
2067: public static AbstractStyle createStyle() {
2068: return null;
2069: }
2070:
2071: }
|