/** * Retrieves the label from a TextSymbolizer. * * @param symbolizer Text symbolizer information. * @return Expression of the label's text, or null if unavailable. */ public static Expression textLabel(TextSymbolizer symbolizer) { if (symbolizer == null) { return null; } Expression exp = symbolizer.getLabel(); if (exp == null) { return null; } return exp; }
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; }
@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); }
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); }
if (symbol.getLabel() == null) { if (LOGGER.isLoggable(Level.WARNING)) LOGGER.warning(
@SuppressWarnings("unchecked") @Test public void testLabelLiteral() throws Exception { String yaml = "text: \n" + " label: test literal\n" + ""; StyledLayerDescriptor sld = Ysld.parse(yaml); FeatureTypeStyle fs = SLD.defaultStyle(sld).featureTypeStyles().get(0); TextSymbolizer symb = (TextSymbolizer) fs.rules().get(0).symbolizers().get(0); Expression label = symb.getLabel(); assertThat( label, allOf(instanceOf(Literal.class), hasProperty("value", equalTo("test literal")))); }
@Test public void testLabelAttribute() throws Exception { String yaml = "text: \n" + " label: ${testAttribute}\n" + ""; StyledLayerDescriptor sld = Ysld.parse(yaml); FeatureTypeStyle fs = SLD.defaultStyle(sld).featureTypeStyles().get(0); TextSymbolizer symb = (TextSymbolizer) fs.rules().get(0).symbolizers().get(0); Expression label = symb.getLabel(); assertThat(label, attribute("testAttribute")); }
String label = evalToString(symbolizer.getLabel(), feature, "");
@Test public void testLabelEmbeded() throws Exception { String yaml = "text: \n" + " label: literal0${attribute1}literal2\n" + ""; StyledLayerDescriptor sld = Ysld.parse(yaml); FeatureTypeStyle fs = SLD.defaultStyle(sld).featureTypeStyles().get(0); TextSymbolizer symb = (TextSymbolizer) fs.rules().get(0).symbolizers().get(0); Expression label = symb.getLabel(); assertThat(label, instanceOf(ConcatenateFunction.class)); List<Expression> params = ((ConcatenateFunction) label).getParameters(); assertThat(params.size(), is(3)); assertThat(params.get(0), literal(equalTo("literal0"))); assertThat(params.get(1), attribute("attribute1")); assertThat(params.get(2), literal(equalTo("literal2"))); }
@Override public void visit(TextSymbolizer text) { if (text.getDescription() != null) { text.getDescription().accept(this); } if (text.getFill() != null) { text.getFill().accept(this); } if (text.getFont() != null) { //text.getFont().accept(this, null); } if (text.getGeometry() != null) { //text.getGeometry().accept(visitor, extraData) } if (text.getHalo() != null) { text.getHalo().accept(this); } if (text.getLabel() != null) { //text.getLabel().accept(visitor, extraData) } if (text.getLabelPlacement() != null) { text.getLabelPlacement().accept(this); } if (text.getPriority() != null) { //text.getPriority().accept(visitor, extraData) } }
/** * Retrieves the label from a TextSymbolizer. * * @param symbolizer Text symbolizer information. * * @return Expression of the label's text, or null if unavailable. */ public static Expression textLabel(TextSymbolizer symbolizer) { if (symbolizer == null) { return null; } Expression exp = symbolizer.getLabel(); if (exp == null) { return null; } return exp; }
@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); }
/** * Grabs the label from the first TextSymbolizer. * * <p> * If you are using something fun like symbols you will need to do your * own thing. * </p> * * @param symbolizer Text symbolizer information. * * @return Expression of the label's text, or null if unavailable. */ public static Expression textLabel(TextSymbolizer symbolizer) { if (symbolizer == null) { return null; } Expression exp = symbolizer.getLabel(); if (exp == null) { return null; } return exp; }
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); }
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(); } }
copy.setLabel(copy(text.getLabel())); copy.setLabelPlacement(copy(text.getLabelPlacement())); copy.setPriority(copy(text.getPriority()));