当前位置: 首页>>代码示例>>Java>>正文


Java TextSymbolizer.setFont方法代码示例

本文整理汇总了Java中org.geotools.styling.TextSymbolizer.setFont方法的典型用法代码示例。如果您正苦于以下问题:Java TextSymbolizer.setFont方法的具体用法?Java TextSymbolizer.setFont怎么用?Java TextSymbolizer.setFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.geotools.styling.TextSymbolizer的用法示例。


在下文中一共展示了TextSymbolizer.setFont方法的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;
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:27,代码来源:StyleConverterServiceImpl.java

示例2: testFindSymbolizer

import org.geotools.styling.TextSymbolizer; //导入方法依赖的package包/类
@Test
public void testFindSymbolizer() {
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    sld.layers().add(DefaultSymbols.createNewNamedLayer());
    sld.layers().add(namedLayer);
    String expectedNamedLayer = "namedLayer";
    namedLayer.setName(expectedNamedLayer);
    Style style = DefaultSymbols.createNewStyle();
    String expectedStyleLayer = "style";
    style.setName(expectedStyleLayer);
    namedLayer.addStyle(DefaultSymbols.createNewStyle());
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    String expectedFeatureTypeStyleLayer = "feature type style";
    fts.setName(expectedFeatureTypeStyleLayer);
    style.featureTypeStyles().add(DefaultSymbols.createNewFeatureTypeStyle());
    style.featureTypeStyles().add(fts);
    Rule rule = DefaultSymbols.createNewRule();
    fts.rules().add(DefaultSymbols.createNewRule());
    fts.rules().add(rule);
    String expectedRule = "rule";
    rule.setName(expectedRule);
    String expectedSymbolizer = "text symbolizer";
    TextSymbolizer symbolizer = DefaultSymbols.createDefaultTextSymbolizer();
    symbolizer.setName(expectedSymbolizer);
    rule.symbolizers().add(DefaultSymbols.createDefaultPolygonSymbolizer());
    rule.symbolizers().add(symbolizer);
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Font font = styleFactory.createFont(ff.literal("abc"), ff.literal("normal"),
            ff.literal("normal"), ff.literal(10));
    symbolizer.setFont(font);

    DuplicatingStyleVisitor duplicate = new DuplicatingStyleVisitor();
    duplicate.visit(sld);
    StyledLayerDescriptor sldCopy = (StyledLayerDescriptor) duplicate.getCopy();

    Symbolizer actualSymbolizer = SLDUtils.findSymbolizer(sld, symbolizer, sldCopy);

    assertNotNull(actualSymbolizer);
    assertEquals(symbolizer.getLabel().toString(),
            ((TextSymbolizer) actualSymbolizer).getLabel().toString());

    actualSymbolizer = SLDUtils.findSymbolizer(sld, null, sldCopy);
    assertNull(actualSymbolizer);

    actualSymbolizer = SLDUtils.findSymbolizer(sld, symbolizer, null);
    assertNull(actualSymbolizer);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:51,代码来源:SLDUtilsTest.java

示例3: testFindRule

import org.geotools.styling.TextSymbolizer; //导入方法依赖的package包/类
@Test
public void testFindRule() {
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    sld.layers().add(DefaultSymbols.createNewNamedLayer());
    sld.layers().add(namedLayer);
    String expectedNamedLayer = "namedLayer";
    namedLayer.setName(expectedNamedLayer);
    Style style = DefaultSymbols.createNewStyle();
    String expectedStyleLayer = "style";
    style.setName(expectedStyleLayer);
    namedLayer.addStyle(DefaultSymbols.createNewStyle());
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    String expectedFeatureTypeStyleLayer = "feature type style";
    fts.setName(expectedFeatureTypeStyleLayer);
    style.featureTypeStyles().add(DefaultSymbols.createNewFeatureTypeStyle());
    style.featureTypeStyles().add(fts);
    Rule rule = DefaultSymbols.createNewRule();
    fts.rules().add(DefaultSymbols.createNewRule());
    fts.rules().add(rule);
    String expectedRule = "rule";
    rule.setName(expectedRule);
    String expectedSymbolizer = "text symbolizer";
    TextSymbolizer symbolizer = DefaultSymbols.createDefaultTextSymbolizer();
    symbolizer.setName(expectedSymbolizer);
    rule.symbolizers().add(DefaultSymbols.createDefaultPolygonSymbolizer());
    rule.symbolizers().add(symbolizer);
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Font font = styleFactory.createFont(ff.literal("abc"), ff.literal("normal"),
            ff.literal("normal"), ff.literal(10));
    symbolizer.setFont(font);

    DuplicatingStyleVisitor duplicate = new DuplicatingStyleVisitor();
    duplicate.visit(sld);
    StyledLayerDescriptor sldCopy = (StyledLayerDescriptor) duplicate.getCopy();

    Rule actualRule = SLDUtils.findRule(sld, rule, sldCopy);

    assertNotNull(actualRule);
    assertEquals(rule.getName(), actualRule.getName());

    actualRule = SLDUtils.findRule(sld, null, sldCopy);
    assertNull(actualRule);

    actualRule = SLDUtils.findRule(sld, rule, null);
    assertNull(actualRule);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:50,代码来源:SLDUtilsTest.java


注:本文中的org.geotools.styling.TextSymbolizer.setFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。