本文整理汇总了Java中org.geotools.styling.TextSymbolizer.setLabel方法的典型用法代码示例。如果您正苦于以下问题:Java TextSymbolizer.setLabel方法的具体用法?Java TextSymbolizer.setLabel怎么用?Java TextSymbolizer.setLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.styling.TextSymbolizer
的用法示例。
在下文中一共展示了TextSymbolizer.setLabel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTextSymbolizer
import org.geotools.styling.TextSymbolizer; //导入方法依赖的package包/类
private TextSymbolizer createTextSymbolizer(LabelStyleInfo labelStyle, LayerType layerType) {
Fill fontFill = styleBuilder.createFill(styleBuilder.literalExpression(labelStyle.getFontStyle().getColor()),
styleBuilder.literalExpression(labelStyle.getFontStyle().getOpacity()));
TextSymbolizer symbolizer = styleBuilder.createTextSymbolizer();
symbolizer.setFill(fontFill);
FontStyleInfo fontInfo = labelStyle.getFontStyle();
symbolizer.setFont(styleBuilder.createFont(styleBuilder.literalExpression(fontInfo.getFamily()),
styleBuilder.literalExpression(fontInfo.getStyle()),
styleBuilder.literalExpression(fontInfo.getWeight()),
styleBuilder.literalExpression(fontInfo.getSize())));
symbolizer.setLabel(styleBuilder.attributeExpression(labelStyle.getLabelAttributeName()));
Fill haloFill = styleBuilder.createFill(
styleBuilder.literalExpression(labelStyle.getBackgroundStyle().getFillColor()),
styleBuilder.literalExpression(labelStyle.getBackgroundStyle().getFillOpacity()));
symbolizer.setHalo(styleBuilder.createHalo(haloFill, 1));
// label placement : point at bottom-center of label (same as vectorized)
switch (layerType) {
case MULTIPOINT:
case POINT:
symbolizer.setLabelPlacement(styleBuilder.createPointPlacement(0.5, 0, 0));
break;
default:
break;
}
return symbolizer;
}
示例2: visit
import org.geotools.styling.TextSymbolizer; //导入方法依赖的package包/类
/**
* (non-Javadoc)
*
* @see org.geotools.styling.visitor.DuplicatingStyleVisitor#visit(org.geotools.styling.TextSymbolizer)
*/
public void visit(TextSymbolizer text) {
TextSymbolizer copy = sf.createTextSymbolizer();
copy.setFill(copy(text.getFill()));
copy.fonts().clear();
copy.fonts().addAll(copyFonts(text.fonts()));
// Ignore geometry field so that symbol is rendered
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);
}
示例3: convert
import org.geotools.styling.TextSymbolizer; //导入方法依赖的package包/类
@Override
public void convert(List<Rule> labelRuleList, Rule rule, JsonElement json, int transparency)
{
if((json != null) && (rule != null) && (labelRuleList != null))
{
JsonObject jsonObj = json.getAsJsonObject();
TextSymbolizer textSymbolizer = styleFactory.createTextSymbolizer();
textSymbolizer.setUnitOfMeasure(NonSI.PIXEL);
textSymbolizer.setLabel(extractExpression(jsonObj));
JsonElement jsonElement = jsonObj.get(LabelEngineLayerPropertiesKey.SYMBOL);
SymbolManager.getInstance().convertTextSymbols(textSymbolizer, transparency, jsonElement);
// Yes, this really is round the wrong way
double maxScale = extractDouble(jsonObj, LabelEngineLayerPropertiesKey.ANNOTATION_MINIMUM_SCALE);
double minScale = extractDouble(jsonObj, LabelEngineLayerPropertiesKey.ANNOTATION_MAXIMUM_SCALE);
if((minScale > 0.0) || (maxScale > 0.0))
{
Rule labelRule = styleFactory.createRule();
labelRule.setName(extractString(jsonObj, LabelEngineLayerPropertiesKey.CLASS));
if(minScale > 0.0)
{
labelRule.setMinScaleDenominator(minScale);
}
if(maxScale > 0.0)
{
labelRule.setMaxScaleDenominator(maxScale);
}
labelRule.symbolizers().add(textSymbolizer);
labelRuleList.add(labelRule);
}
else
{
rule.symbolizers().add(textSymbolizer);
}
}
}