/** * Retrieves the colour of the font fill from a TextSymbolizer. * * @param symbolizer Text symbolizer information. * @return Color of the font's fill, or null if unavailable. */ public static Color textFontFill(TextSymbolizer symbolizer) { if (symbolizer == null) { return null; } Fill fill = symbolizer.getFill(); if (fill == null) { return null; } return color(fill.getColor()); }
@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); }
assertEquals(Color.black, SLD.color(text.getFill()));
@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); }
@Test public void testLineWithDefaultLabel() throws Exception { // <UserStyle> // <Title>SLD Cook Book: Line with default label</Title> // <FeatureTypeStyle> // <Rule> // <LineSymbolizer> // <Stroke> // <CssParameter name="stroke">#FF0000</CssParameter> // </Stroke> // </LineSymbolizer> // <TextSymbolizer> // <Label> // <ogc:PropertyName>name</ogc:PropertyName> // </Label> // <Font /> // <Fill> // <CssParameter name="fill">#000000</CssParameter> // </Fill> // </TextSymbolizer> // </Rule> // </FeatureTypeStyle> // </UserStyle> Style style = parse("line", "default-label.sld"); LineSymbolizer line = SLD.lineSymbolizer(style); assertEquals(Color.red, SLD.color(line)); TextSymbolizer text = SLD.textSymbolizer(style); assertEquals("name", SLD.textLabelString(text)); assertEquals(Color.black, SLD.color(text.getFill())); }
@Override public void visit(TextSymbolizer text) { super.visit(text); TextSymbolizer textCopy = (TextSymbolizer) pages.peek(); Fill textFill = textCopy.getFill(); if (textFill != null) { Expression opacityExpression = textFill.getOpacity(); if (opacityExpression != null) { textOpacity = opacityExpression.evaluate(opacityExpression, Double.class); } } } }
@Override public void visit(TextSymbolizer text) { super.visit(text); TextSymbolizer textCopy = (TextSymbolizer) pages.peek(); Fill textFill = textCopy.getFill(); if (textFill != null) { textFill.setOpacity(textExp); } else { textCopy.setFill(defaultTextFill); } } }
@Override public void visit(TextSymbolizer text) { super.visit(text); TextSymbolizer textCopy = (TextSymbolizer) pages.peek(); Fill textFill = textCopy.getFill(); if (textFill != null) { textFill.setOpacity(textExp); } else { textCopy.setFill(defaultTextFill); } } }
assertEquals(Color.black, SLD.color(text.getFill()));
/** @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 populateFill(TextSymbolizer textSymbolizer) { Fill fill = textSymbolizer.getFill(); if (fill != null) { fieldConfigVisitor.populateField(FieldIdEnum.FILL_COLOUR, fill.getColor()); fieldConfigVisitor.populateField(FieldIdEnum.TEXT_OPACITY, fill.getOpacity()); } }
assertEquals(Color.black, SLD.color(text.getFill()));
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(); } }
@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); }