public TextSymbolizer createTextSymbolizer( Fill fill, Font[] fonts, Halo halo, Expression label, LabelPlacement labelPlacement, String geometryPropertyName) { TextSymbolizer tSymb = new TextSymbolizerImpl(filterFactory); tSymb.setFill(fill); if (fonts != null) { tSymb.fonts().addAll(Arrays.asList(fonts)); } tSymb.setGeometryPropertyName(geometryPropertyName); tSymb.setHalo(halo); tSymb.setLabel(label); tSymb.setLabelPlacement(labelPlacement); return tSymb; }
@Override public void visit(TextSymbolizer text) { super.visit(text); TextSymbolizer ts = (TextSymbolizer) pages.peek(); // do we have follow line without line placement? if (ts.getLabelPlacement() == null && "true".equalsIgnoreCase(ts.getOptions().get("followLine"))) { ts.setLabelPlacement(new LinePlacementImpl()); } } }
fonts.add(parseFont(child)); } else if (childName.equalsIgnoreCase("LabelPlacement")) { symbol.setLabelPlacement(parseLabelPlacement(child)); } else if (childName.equalsIgnoreCase("Halo")) { symbol.setHalo(parseHalo(child));
ts.setLabelPlacement(labelPlacement);
symbol.setLabelPlacement((LabelPlacement) value[i].getValue());
public void testTextSymbolizer() { TextSymbolizer textSymb = styleFactory.createTextSymbolizer(); Expression offset = filterFactory.literal(10); textSymb.setLabelPlacement(styleFactory.createLinePlacement(offset)); TextSymbolizer clone = (TextSymbolizer) ((Cloneable) textSymb).clone(); assertClone(textSymb, clone); TextSymbolizer notEq = styleFactory.getDefaultTextSymbolizer(); Expression ancX = filterFactory.literal(10); Expression ancY = filterFactory.literal(10); AnchorPoint ancPoint = styleFactory.createAnchorPoint(ancX, ancY); LabelPlacement placement = styleFactory.createPointPlacement(ancPoint, null, null); notEq.setLabelPlacement(placement); assertEqualsContract(clone, notEq, textSymb); }
@Override public void handle(YamlObject<?> obj, YamlParseContext context) { YamlMap map = obj.map(); if (map.has("placement")) { sym.setLabelPlacement("line".equals(map.str("placement")) ? line : point); } else { sym.setLabelPlacement(point); } if (map.has("offset")) { line.setPerpendicularOffset(Util.expression(map.str("offset"), factory)); } if (map.has("anchor")) { point.setAnchorPoint(Util.anchor(map.get("anchor"), factory)); } if (map.has("displacement")) { point.setDisplacement(Util.displacement(map.get("displacement"), factory)); } if (map.has("rotation")) { point.setRotation(Util.expression(map.str("rotation"), factory)); } // anchor point is manditory for SLD encoding if (point.getAnchorPoint() == null) { AnchorPoint defaultAnchor = factory.style.getDefaultPointPlacement().getAnchorPoint(); point.setAnchorPoint(defaultAnchor); } } }
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); }
private static Style createLabelOffsetStyle() { StyleBuilder sb = new StyleBuilder(); PointPlacement pp = sb.createPointPlacement(0.5, 0.5, 50, 0, 0); TextSymbolizer ts = sb.createTextSymbolizer(); ts.setFont(sb.createFont("Bitstream Vera Sans", 20)); ts.setLabel(sb.getFilterFactory().literal("name")); ts.setLabelPlacement(pp); ts.getOptions().put("partials", "true"); return sb.createStyle(ts); }
public void testTextSymbolizer() { TextSymbolizer textSymb = sf.createTextSymbolizer(); Expression offset = ff.literal(10); textSymb.setLabelPlacement(sf.createLinePlacement(offset)); textSymb.accept(visitor); TextSymbolizer clone = (TextSymbolizer) visitor.getCopy(); assertCopy(textSymb, clone); assertEqualsContract(textSymb, clone); TextSymbolizer notEq = sf.getDefaultTextSymbolizer(); Expression ancX = ff.literal(10); Expression ancY = ff.literal(10); AnchorPoint ancPoint = sf.createAnchorPoint(ancX, ancY); LabelPlacement placement = sf.createPointPlacement(ancPoint, null, null); notEq.setLabelPlacement(placement); assertEqualsContract(clone, notEq, textSymb); }
public void testTextSymbolizerWithUOM() { TextSymbolizer textSymb = sf.createTextSymbolizer(); textSymb.setUnitOfMeasure(UomOgcMapping.METRE.getUnit()); Expression offset = ff.literal(10); textSymb.setLabelPlacement(sf.createLinePlacement(offset)); textSymb.accept(visitor); TextSymbolizer clone = (TextSymbolizer) visitor.getCopy(); assertCopy(textSymb, clone); assertEqualsContract(textSymb, clone); TextSymbolizer notEq = sf.getDefaultTextSymbolizer(); Expression ancX = ff.literal(10); Expression ancY = ff.literal(10); AnchorPoint ancPoint = sf.createAnchorPoint(ancX, ancY); LabelPlacement placement = sf.createPointPlacement(ancPoint, null, null); notEq.setLabelPlacement(placement); assertEqualsContract(clone, notEq, textSymb); }
@Test public void testTextDisplaced() { TextSymbolizer ts = sb.createTextSymbolizer(); ts.setFont(sb.createFont("Arial", 20)); PointPlacement pp = sb.createPointPlacement(1, 1, 10, 10, 0); ts.setLabelPlacement(pp); Style style = sb.createStyle(ts); MetaBufferEstimator rbe = new MetaBufferEstimator(); rbe.visit(style); // 20 (font) + 20 * 0.5 (anchor) + 10 (offset) assertEquals(40, rbe.getBuffer()); assertTrue(rbe.isEstimateAccurate()); }
ts.setLabelPlacement((LabelPlacement) node.getChildValue("LabelPlacement"));
rescale(linePlacement.getPerpendicularOffset())); copy.setLabelPlacement(placement);
rescale(linePlacement.getPerpendicularOffset(), uom)); copy.setLabelPlacement(placement);
@Override public void handle(YamlObject<?> obj, YamlParseContext context) { YamlMap map = obj.map(); if (map.has("placement")) { sym.setLabelPlacement("line".equals(map.str("placement")) ? line : point); } else { sym.setLabelPlacement(point); } if (map.has("offset")) { line.setPerpendicularOffset(Util.expression(map.str("offset"), factory)); } if (map.has("anchor")) { point.setAnchorPoint(Util.anchor(map.get("anchor"), factory)); } if (map.has("displacement")) { point.setDisplacement(Util.displacement(map.get("displacement"), factory)); } if (map.has("rotation")) { point.setRotation(Util.expression(map.str("rotation"), factory)); } // anchor point is manditory for SLD encoding if (point.getAnchorPoint() == null) { AnchorPoint defaultAnchor = factory.style.getDefaultPointPlacement().getAnchorPoint(); point.setAnchorPoint(defaultAnchor); } } }
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); }
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());
linePlacement.setPerpendicularOffset(rescale(linePlacement.getPerpendicularOffset())); copy.setLabelPlacement(placement);
mapScale, uom)); copy.setLabelPlacement(placement);