/** * Retrieves the halo width from a TextSymbolizer. * * @param symbolizer Text symbolizer information. * @return the halo's width, or 0 if unavailable. */ public static int textHaloWidth(TextSymbolizer symbolizer) { Halo halo = symbolizer.getHalo(); if (halo == null) { return 0; } Expression exp = halo.getRadius(); if (exp == null) { return 0; } int width = (int) Float.parseFloat(exp.toString()); if (width != 0) { return width; } return 0; }
/** * Retrieves the colour of the halo fill a TextSymbolizer. * * @param symbolizer Text symbolizer information. * @return Color of the halo's fill, or null if unavailable. */ public static Color textHaloFill(TextSymbolizer symbolizer) { Halo halo = symbolizer.getHalo(); if (halo == null) { return null; } Fill fill = halo.getFill(); if (fill == null) { return null; } return color(fill.getColor()); }
/** * Retrieves the halo opacity from the first TextSymbolizer. * * @param symbolizer Text symbolizer information. * @return double of the halo's opacity, or NaN if unavailable. */ public static double textHaloOpacity(TextSymbolizer symbolizer) { if (symbolizer == null) { return Double.NaN; } Halo halo = symbolizer.getHalo(); if (halo == null) { return Double.NaN; } Fill fill = halo.getFill(); if (fill == null) { return Double.NaN; } Expression expr = fill.getOpacity(); if (expr == null) { return Double.NaN; } return Filters.asDouble(expr); }
@Override public void visit(TextSymbolizer text) { if (text.getDescription() != null) { text.getDescription().accept(this); } if (text.getFill() != null) { text.getFill().accept(this); } if (text.getHalo() != null) { text.getHalo().accept(this); } if (text.getLabelPlacement() != null) { text.getLabelPlacement().accept(this); } }
public TextSymbolizerBuilder reset(TextSymbolizer symbolizer) { fill.reset(symbolizer.getFill()); halo.reset(symbolizer.getHalo()); label = symbolizer.getLabel(); geometry = null; LabelPlacement otherPlacement = symbolizer.getLabelPlacement(); if (symbolizer.getLabelPlacement() instanceof PointPlacement) { PointPlacementBuilder builder = new PointPlacementBuilder(this); builder.reset((PointPlacement) otherPlacement); placement = builder; } else if (symbolizer.getLabelPlacement() instanceof LabelPlacement) { LinePlacementBuilder builder = new LinePlacementBuilder(this); builder.reset((LinePlacement) otherPlacement); placement = builder; } else { throw new IllegalArgumentException("Unrecognized label placement: " + otherPlacement); } priority = symbolizer.getPriority(); unset = false; return this; }
public void visit(TextSymbolizer text) { TextSymbolizer copy = sf.createTextSymbolizer(); copy.setFill(copy(text.getFill())); copy.fonts().clear(); copy.fonts().addAll(copyFonts(text.fonts())); copy.setGeometry(copy(text.getGeometry())); copy.setUnitOfMeasure(text.getUnitOfMeasure()); copy.setHalo(copy(text.getHalo())); copy.setLabel(copy(text.getLabel())); copy.setLabelPlacement(copy(text.getLabelPlacement())); copy.setPriority(copy(text.getPriority())); copy.getOptions().putAll(text.getOptions()); if (text instanceof TextSymbolizer2) { TextSymbolizer2 text2 = (TextSymbolizer2) text; TextSymbolizer2 copy2 = (TextSymbolizer2) copy; copy2.setGraphic(copy(text2.getGraphic())); copy2.setSnippet(copy(text2.getSnippet())); copy2.setFeatureDescription(copy(text2.getFeatureDescription())); copy2.setOtherText(copy(text2.getOtherText())); } if (STRICT && !copy.equals(text)) { throw new IllegalStateException( "Was unable to duplicate provided TextSymbolizer:" + text); } pages.push(copy); }
Halo halo = symbolizer.getHalo();
@Override protected void encode(TextSymbolizer text) { put("label", text.getLabel()); put("priority", text.getPriority()); inline(new FillEncoder(text.getFill())); inline(new HaloEncoder(text.getHalo())); inline(new FontEncoder(text.getFont())); inline(new PlacementEncoder(text.getLabelPlacement())); if (text instanceof TextSymbolizer2) { inline(new GraphicEncoder(((TextSymbolizer2) text).getGraphic(), false)); } super.encode(text); }
/** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.TextSymbolizer) */ public void visit(TextSymbolizer text) { if (text instanceof TextSymbolizer2) { if (((TextSymbolizer2) text).getGraphic() != null) ((TextSymbolizer2) text).getGraphic().accept(this); } if (text.getFill() != null) { text.getFill().accept(this); } if (text.getHalo() != null) { text.getHalo().accept(this); } }
/** * Retrieves the colour of the halo fill a TextSymbolizer. * * @param symbolizer Text symbolizer information. * * @return Color of the halo's fill, or null if unavailable. */ public static Color textHaloFill(TextSymbolizer symbolizer) { Halo halo = symbolizer.getHalo(); if (halo == null) { return null; } Fill fill = halo.getFill(); if (fill == null) { return null; } return color(fill.getColor()); }
/** * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.TextSymbolizer) */ public void visit(TextSymbolizer text) { if (text instanceof TextSymbolizer2) { if (((TextSymbolizer2) text).getGraphic() != null) ((TextSymbolizer2) text).getGraphic().accept(this); } if (text.getFill() != null) { text.getFill().accept(this); } if (text.getHalo() != null) { text.getHalo().accept(this); } }
/** @param textSymbolizer */ private void populateHalo(TextSymbolizer textSymbolizer) { GroupConfigInterface group; Halo halo = textSymbolizer.getHalo(); group = getGroup(GroupIdEnum.HALO); group.enable(halo != null); if (halo != null) { Fill haloFill = halo.getFill(); fieldConfigVisitor.populateField(FieldIdEnum.HALO_COLOUR, haloFill.getColor()); fieldConfigVisitor.populateField(FieldIdEnum.HALO_RADIUS, halo.getRadius()); } else { fieldConfigVisitor.populateField(FieldIdEnum.HALO_COLOUR, (Expression) null); fieldConfigVisitor.populateField(FieldIdEnum.HALO_RADIUS, (Expression) null); } }
public void setEdited(TextSymbolizer sym) { symbol = (TextSymbolizer) sym; if (sym != null) { guiFill.setEdited(symbol.getFill()); guiLabel.setExpression(symbol.getLabel()); guiGeom.setGeom(symbol.getGeometryPropertyName()); guiFonts.setEdited(symbol.getFonts()); guiHalo.setEdited(symbol.getHalo()); guiPriority.setExpression(symbol.getPriority()); guiPlacement.setEdited(symbol.getPlacement()); //dont know how to handle that option map // lack informations //symbol.getOptions(); } }
public void visit(TextSymbolizer text) { TextSymbolizer copy = sf.createTextSymbolizer(); copy.setFill( copy( text.getFill())); copy.setFont( copy( text.getFont())); copy.setGeometry(copy(text.getGeometry())); copy.setUnitOfMeasure(text.getUnitOfMeasure()); copy.setHalo( copy( text.getHalo() )); copy.setLabel( copy( text.getLabel())); copy.setLabelPlacement( copy( text.getLabelPlacement())); copy.setPriority( copy( text.getPriority())); copy.getOptions().putAll(text.getOptions()); if (text instanceof TextSymbolizer2){ TextSymbolizer2 text2 = (TextSymbolizer2) text; TextSymbolizer2 copy2 = (TextSymbolizer2) copy; copy2.setGraphic( copy(text2.getGraphic())); copy2.setSnippet(copy(text2.getSnippet())); copy2.setFeatureDescription(copy(text2.getFeatureDescription())); copy2.setOtherText(copy(text2.getOtherText())); } if( STRICT && !copy.equals( text )){ throw new IllegalStateException("Was unable to duplicate provided TextSymbolizer:"+text ); } pages.push(copy); }
@Override protected void encode(TextSymbolizer text) { put("label", text.getLabel()); put("priority", text.getPriority()); inline(new FillEncoder(text.getFill())); inline(new HaloEncoder(text.getHalo())); inline(new FontEncoder(text.getFont())); inline(new PlacementEncoder(text.getLabelPlacement())); if (text instanceof TextSymbolizer2) { inline(new GraphicEncoder(((TextSymbolizer2) text).getGraphic(), false)); } super.encode(text); }