/** * Retrieves the font from a TextSymbolizer. Equivalent to {@code symbolizer.getFont()}. * * @param symbolizer the symbolizer * @return the first font defined in the symbolizer or null if unavailable. */ public static Font font(TextSymbolizer symbolizer) { if (symbolizer == null) { return null; } return symbolizer.getFont(); }
/** * Retrieves the font from a TextSymbolizer. Equivalent to * {@code symbolizer.getFont()}. * * @param symbolizer the symbolizer * * @return the first font defined in the symbolizer or null if unavailable. */ public static Font font( TextSymbolizer symbolizer ) { if(symbolizer == null) { return null; } return symbolizer.getFont(); }
@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); }
rescaledTextSymb.getFont().getSize().evaluate(null, Double.class); PointPlacement rescaledPlacement = (PointPlacement) rescaledTextSymb.getLabelPlacement();
rescaledTextSymb.getFont().getSize().evaluate(null, Double.class); LinePlacement rescaledPlacement = (LinePlacement) rescaledTextSymb.getLabelPlacement(); double rescaledPerpOffset =
protected void setLabelStyle(Style style, SimpleFeature feature, TextSymbolizer symbolizer) { LabelStyle ls = style.createAndSetLabelStyle(); double scale = 1; Font font = symbolizer.getFont(); if(font != null && font.getSize() != null) { // we make the scale proportional to the normal font size double size = font.getSize().evaluate(feature, Double.class); scale = Math.round(size / Font.DEFAULT_FONTSIZE * 100) / 100.0; } ls.setScale(scale); Fill fill = symbolizer.getFill(); if (fill != null) { Double opacity = fill.getOpacity().evaluate(feature, Double.class); if (opacity == null || Double.isNaN(opacity)) { opacity = 1.0; } Color color = fill.getColor().evaluate(feature, Color.class); ls.setColor(colorToHex(color, opacity)); } else { ls.setColor("ffffffff"); } }
/** @param textSymbolizer */ private void populateFont(TextSymbolizer textSymbolizer) { Font font = textSymbolizer.getFont(); GroupConfigInterface group = getGroup(GroupIdEnum.FONT); group.enable(font != null); if (font != null) { fieldConfigVisitor.populateFontField(FieldIdEnum.FONT_FAMILY, font); fieldConfigVisitor.populateField(FieldIdEnum.FONT_WEIGHT, font.getWeight()); fieldConfigVisitor.populateField(FieldIdEnum.FONT_STYLE, font.getStyle()); fieldConfigVisitor.populateField(FieldIdEnum.FONT_SIZE, font.getSize()); } fieldConfigVisitor.populateFontField(FieldIdEnum.FONT_PREVIEW, font); }
if (symbolizer instanceof TextSymbolizer) { TextSymbolizer textSymbol = (TextSymbolizer) symbolizer; Font font = textSymbol.getFont(); if (font != null) { if (dataList == null) {
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); }
@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) } }