/** * Create an instance of {@link Style} * */ public static Style createStyle() { return new Style(); }
/** * Encodes a transparent KML LabelStyle */ protected void setDefaultLabelStyle(Style style) { LabelStyle ls = style.createAndSetLabelStyle(); ls.setColor("00ffffff"); }
/** * add a value to the styleObjectExtension property collection * * @param styleObjectExtension * Objects of the following type are allowed in the list: {@link AbstractObject} * @return * <tt>true</tt> (as general contract of <tt>Collection.add</tt>). */ public Style addToStyleObjectExtension(final AbstractObject styleObjectExtension) { this.getStyleObjectExtension().add(styleObjectExtension); return this; }
public String getKMLStyle(String label, Folder folder) { if (kmlStyles.containsKey(label)) return (String) kmlStyles.get(label); int pushpingLinkCounter = kmlStylesCounter % kmlPushPings.length; int colorCounter = kmlStylesCounter % kmlColors.length; Style style = folder.createAndAddStyle().withId( String.valueOf(kmlStylesCounter)); style.createAndSetIconStyle() .withScale(1.399999976158142) .withIcon( new Icon().withHref(kmlPushPings[pushpingLinkCounter])); style.createAndSetLineStyle().withColor(kmlColors[colorCounter]) .withWidth(2); style.createAndSetPolyStyle().withColor(kmlColors[colorCounter]); kmlStyles.put(label, String.valueOf(kmlStylesCounter)); kmlStylesCounter++; return String.valueOf(kmlStylesCounter - 1); } private String getKMLLabel(SimpleFeature feature) {
sf.setVisibility(false); sf.createAndAddStyle().withId("Valid") .withIconStyle( validIconStyle ) .withLabelStyle(labelStyle) .withLabelStyle(idLabelStyle) .withLineStyle(validLineStyle) .withBalloonStyle(balloonStyle); sf.createAndAddStyle().withId("Invalid") .withIconStyle( invalidIconStyle ) .withLabelStyle( labelStyle ) .withLabelStyle( idLabelStyle ) .withLineStyle( invalidLineStyle ) .withBalloonStyle( balloonStyle ); sf.createAndAddStyle().withId("track") .withLineStyle( lineStyle_t ) .withIconStyle( trackIconStyle ) .withLabelStyle( labelStyle ) .withLabelStyle( idLabelStyle );
.withName(worksheet.getTitle()).withOpen(true); Style style = folder.createAndAddStyle().withId("karma"); style.createAndSetIconStyle().withScale(1.399999976158142).withIcon(new Icon().withHref("http://maps.google.com/mapfiles/ms/icons/blue-pushpin.png")); else style.createAndSetIconStyle().withScale(1.399999976158142).withIcon(new Icon().withHref("http://maps.google.com/mapfiles/ms/icons/red-pushpin.png"));
protected void setInlineIconStyle(Style style, org.geotools.styling.Style sld, IconProperties properties, KmlEncodingContext context) { final String name = properties.getIconName(sld); Map<String,org.geotools.styling.Style> iconStyles = context.getIconStyles(); if (!iconStyles.containsKey(name)) { final org.geotools.styling.Style injectedStyle = IconPropertyInjector.injectProperties(sld, properties.getProperties()); iconStyles.put(name, injectedStyle); } final Double scale = properties.getScale(); final String path = "icons/" + name + ".png"; IconStyle is = style.createAndSetIconStyle(); if (properties.getHeading() != null) { is.setHeading(0.0); } if (scale != null) { is.setScale(scale); } Icon icon = is.createAndSetIcon(); icon.setHref(path); }
@Override public Style clone() { Style copy; copy = ((Style) super.clone()); copy.iconStyle = ((iconStyle == null)?null:((IconStyle) iconStyle.clone())); copy.labelStyle = ((labelStyle == null)?null:((LabelStyle) labelStyle.clone())); copy.lineStyle = ((lineStyle == null)?null:((LineStyle) lineStyle.clone())); copy.polyStyle = ((polyStyle == null)?null:((PolyStyle) polyStyle.clone())); copy.balloonStyle = ((balloonStyle == null)?null:((BalloonStyle) balloonStyle.clone())); copy.listStyle = ((listStyle == null)?null:((ListStyle) listStyle.clone())); copy.styleSimpleExtension = new ArrayList<Object>((getStyleSimpleExtension().size())); for (Object iter: styleSimpleExtension) { copy.styleSimpleExtension.add(iter); } copy.styleObjectExtension = new ArrayList<AbstractObject>((getStyleObjectExtension().size())); for (AbstractObject iter: styleObjectExtension) { copy.styleObjectExtension.add(iter.clone()); } return copy; }
LineStyle ls = style.createAndSetLineStyle();
/** * Encodes a KML IconStyle + PolyStyle from a polygon style and symbolizer. */ protected void setPolygonStyle(Style style, SimpleFeature feature, PolygonSymbolizer symbolizer, boolean forceOutline) { // if stroke specified add line style as well (it has to be before the fill, otherwise // we'll get a white filling...) if (symbolizer.getStroke() != null) { setLineStyle(style, feature, symbolizer.getStroke()); } // fill PolyStyle ps = style.createAndSetPolyStyle(); Fill fill = symbolizer.getFill(); if (fill != null) { // get opacity Double opacity = fill.getOpacity().evaluate(feature, Double.class); if (opacity == null || Double.isNaN(opacity)) { opacity = 1.0; } Color color = (Color) fill.getColor().evaluate(feature, Color.class); ps.setColor(colorToHex(color, opacity)); } else { // make it transparent ps.setColor("00aaaaaa"); } // outline if (symbolizer.getStroke() != null || forceOutline) { ps.setOutline(true); } }
/** * fluent setter * @see #setBalloonStyle(BalloonStyle) * * @param balloonStyle * required parameter */ public Style withBalloonStyle(final BalloonStyle balloonStyle) { this.setBalloonStyle(balloonStyle); return this; }
/** * fluent setter * @see #setIconStyle(IconStyle) * * @param iconStyle * required parameter */ public Style withIconStyle(final IconStyle iconStyle) { this.setIconStyle(iconStyle); return this; }
/** * add a value to the styleSimpleExtension property collection * * @param styleSimpleExtension * Objects of the following type are allowed in the list: {@link Object} * @return * <tt>true</tt> (as general contract of <tt>Collection.add</tt>). */ public Style addToStyleSimpleExtension(final Object styleSimpleExtension) { this.getStyleSimpleExtension().add(styleSimpleExtension); return this; }
protected void setDefaultIconStyle(Style style, SimpleFeature feature, KmlEncodingContext context) { // figure out if line or polygon boolean line = feature.getDefaultGeometry() != null && (feature.getDefaultGeometry() instanceof LineString || feature .getDefaultGeometry() instanceof MultiLineString); boolean poly = feature.getDefaultGeometry() != null && (feature.getDefaultGeometry() instanceof Polygon || feature .getDefaultGeometry() instanceof MultiPolygon); // Final pre-flight check if (!line && !poly) { LOGGER.log(Level.FINER, "Unexpectedly entered encodeDefaultIconStyle() " + "with something that does not have a multipoint geometry."); return; } IconStyle is = style.createAndSetIconStyle(); // make transparent if they ask for attributes, since we'll have a label if (context.isDescriptionEnabled()) { is.setColor("00ffffff"); } // if line or polygon scale the label if (line || poly) { is.setScale(0.4); } String imageURL = "http://icons.opengeo.org/markers/icon-" + (poly ? "poly.1" : "line.1") + ".png"; Icon icon = is.createAndSetIcon(); icon.setHref(imageURL); icon.setViewBoundScale(1); }
@Override public Style clone() { Style copy; copy = ((Style) super.clone()); copy.iconStyle = ((iconStyle == null)?null:((IconStyle) iconStyle.clone())); copy.labelStyle = ((labelStyle == null)?null:((LabelStyle) labelStyle.clone())); copy.lineStyle = ((lineStyle == null)?null:((LineStyle) lineStyle.clone())); copy.polyStyle = ((polyStyle == null)?null:((PolyStyle) polyStyle.clone())); copy.balloonStyle = ((balloonStyle == null)?null:((BalloonStyle) balloonStyle.clone())); copy.listStyle = ((listStyle == null)?null:((ListStyle) listStyle.clone())); copy.styleSimpleExtension = new ArrayList<Object>((getStyleSimpleExtension().size())); for (Object iter: styleSimpleExtension) { copy.styleSimpleExtension.add(iter); } copy.styleObjectExtension = new ArrayList<AbstractObject>((getStyleObjectExtension().size())); for (AbstractObject iter: styleObjectExtension) { copy.styleObjectExtension.add(iter.clone()); } return copy; }
/** * fluent setter * @see #setBalloonStyle(BalloonStyle) * * @param balloonStyle * required parameter */ public Style withBalloonStyle(final BalloonStyle balloonStyle) { this.setBalloonStyle(balloonStyle); return this; }
/** * fluent setter * @see #setIconStyle(IconStyle) * * @param iconStyle * required parameter */ public Style withIconStyle(final IconStyle iconStyle) { this.setIconStyle(iconStyle); return this; }
/** * add a value to the styleSimpleExtension property collection * * @param styleSimpleExtension * Objects of the following type are allowed in the list: {@link Object} * @return * <tt>true</tt> (as general contract of <tt>Collection.add</tt>). */ public Style addToStyleSimpleExtension(final Object styleSimpleExtension) { this.getStyleSimpleExtension().add(styleSimpleExtension); return this; }
protected void setLiveIconStyle(Style style, org.geotools.styling.Style sld, IconProperties properties, KmlEncodingContext context) { final Double opacity = properties.getOpacity(); final Double scale = properties.getScale(); final Double heading = properties.getHeading(); IconStyle is = style.createAndSetIconStyle(); if (opacity != null) { is.setColor(colorToHex(Color.WHITE, opacity)); } if (scale != null) { is.setScale(scale); } if (heading != null) { is.setHeading(heading); } // Get the name of the workspace WorkspaceInfo ws = context.getWms().getCatalog().getStyleByName(sld.getName()).getWorkspace(); String wsName = null; if(ws!=null) wsName = ws.getName(); Icon icon = is.createAndSetIcon(); icon.setHref(properties.href(context.getMapContent().getRequest().getBaseUrl(), wsName, sld.getName())); }
/** * Create an instance of {@link Style} * */ public static Style createStyle() { return new Style(); }