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


Java StyleBuilder.createStyle方法代码示例

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


在下文中一共展示了StyleBuilder.createStyle方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: featureTypeStyleExample

import org.geotools.styling.StyleBuilder; //导入方法依赖的package包/类
private void featureTypeStyleExample() {
    // featureTypeStyleExample start
    StyleBuilder styleBuilder = new StyleBuilder();
    Style style = styleBuilder.createStyle();
    
    PointSymbolizer pointSymbolizer = styleBuilder.createPointSymbolizer();
    
    Graphic graphic = styleBuilder.createGraphic();
    ExternalGraphic external = styleBuilder.createExternalGraphic("file:///C:/images/house.gif",
            "image/gif");
    graphic.graphicalSymbols().add(external);
    graphic.graphicalSymbols().add(styleBuilder.createMark("circle"));
    
    pointSymbolizer.setGraphic(graphic);
    
    Rule rule = styleBuilder.createRule(pointSymbolizer);
    FeatureTypeStyle featureTypeStyle = styleBuilder.createFeatureTypeStyle("Feature", rule);
    style.featureTypeStyles().add(featureTypeStyle);
    
    // featureTypeStyleExample end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:22,代码来源:StyleExamples.java

示例2: quickPointSymbolizer

import org.geotools.styling.StyleBuilder; //导入方法依赖的package包/类
private void quickPointSymbolizer() {
    // quickPointSymbolizer start
    // "testPoint" feature type style
    StyleBuilder sb = new StyleBuilder();
    FilterFactory2 ff = sb.getFilterFactory();
    
    Mark testMark = sb.createMark(sb.attributeExpression("name"), sb.createFill(Color.RED, 0.5),
            null);
    Graphic graph = sb.createGraphic(null, // An external graphics if needed
            new Mark[] { testMark }, // a Mark if not an external graphics
            null, // aSymbol
            ff.literal(1), // opacity
            ff.property("size"), // read from feature "size" attribute
            ff.property("rotation")); // rotation, here read into the feature
    PointSymbolizer aPointSymbolizer = sb.createPointSymbolizer(graph);
    
    // creation of the style
    Style style = sb.createStyle(aPointSymbolizer);
    // quickPointSymbolizer end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:21,代码来源:StyleExamples.java

示例3: create

import org.geotools.styling.StyleBuilder; //导入方法依赖的package包/类
public static Style create(DataStore dataStore, ShapeFileParameter param,
		FeatureType type) {
	try {
		StyleBuilder styleBuilder = new StyleBuilder();
		Style style = styleBuilder.createStyle();
		double[] breaks = createBreaks(param.min, param.max);
		Color[] colors = createColors();
		Rule[] rules = createRules(param.name, styleBuilder, breaks,
				colors, type);
		String typeName = dataStore.getTypeNames()[0];
		FeatureTypeStyle fts = styleBuilder.createFeatureTypeStyle(
				typeName, rules);
		style.featureTypeStyles().add(fts);
		return style;
	} catch (Exception e) {
		Logger log = LoggerFactory.getLogger(SFMapStyle.class);
		log.error("failed to create shape file style", e);
		return null;
	}
}
 
开发者ID:GreenDelta,项目名称:olca-app,代码行数:21,代码来源:SFMapStyle.java

示例4: splatExample

import org.geotools.styling.StyleBuilder; //导入方法依赖的package包/类
private void splatExample() {
    // splatExample start
    StyleBuilder builder = new StyleBuilder();
    FilterFactory2 ff = builder.getFilterFactory();
    
    Graphic splat = builder.createGraphic(null, builder.createMark("splat"), null);
    PointSymbolizer symbolizer = builder.createPointSymbolizer(splat);
    
    // builder will fill in all the other classes with defaults
    Style style = builder.createStyle(symbolizer);
    // splatExample end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:13,代码来源:StyleExamples.java

示例5: quickTextSymbolizer

import org.geotools.styling.StyleBuilder; //导入方法依赖的package包/类
private void quickTextSymbolizer() {
    // quickTextSymbolizer start
    // "labelPoint" feature type style
    StyleBuilder sb = new StyleBuilder();
    FilterFactory2 ff = sb.getFilterFactory();
    
    // creation of the TextSymbolizer
    AnchorPoint anchorPoint = sb.createAnchorPoint(sb.attributeExpression("X"),
            sb.attributeExpression("Y"));
    PointPlacement pointPlacement = sb.createPointPlacement(anchorPoint, null,
            sb.literalExpression(0));
    TextSymbolizer textSymbolizer = sb.createTextSymbolizer(sb.createFill(Color.BLACK), new Font[] {
            sb.createFont("Lucida Sans", 10), sb.createFont("Arial", 10) }, sb.createHalo(),
            sb.attributeExpression("name"), pointPlacement, null);
    
    // creation of the Point symbolizer
    Mark circle = sb.createMark(StyleBuilder.MARK_CIRCLE, Color.RED);
    Graphic graph2 = sb.createGraphic(null, circle, null, 1, 4, 0);
    PointSymbolizer pointSymbolizer = sb.createPointSymbolizer(graph2);
    
    // creation of the style
    Style style = sb.createStyle();
    FeatureTypeStyle featureTypeStyle = sb.createFeatureTypeStyle("labelPoint", new Symbolizer[] {
            textSymbolizer, pointSymbolizer });
    style.featureTypeStyles().add(featureTypeStyle);
    
    // creation of the style
    // quickTextSymbolizer end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:30,代码来源:StyleExamples.java

示例6: quickPolygonSymbolizer

import org.geotools.styling.StyleBuilder; //导入方法依赖的package包/类
private void quickPolygonSymbolizer() {
    // quickPolygonSymbolizer start
    StyleBuilder styleBuilder = new StyleBuilder();
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
    
    PolygonSymbolizer polygonSymbolizer = styleBuilder.createPolygonSymbolizer(Color.BLUE);
    polygonSymbolizer.getFill().setOpacity(ff.literal(0.5)); // 50% blue
    
    polygonSymbolizer.setStroke(styleBuilder.createStroke(Color.BLACK, 2.0));
    
    // will create a default feature type style and rule etc...
    Style style = styleBuilder.createStyle(polygonSymbolizer);
    // quickPolygonSymbolizer end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:15,代码来源:StyleExamples.java

示例7: markTestSLD

import org.geotools.styling.StyleBuilder; //导入方法依赖的package包/类
private void markTestSLD() {
    // markTestSLD start
    StyleBuilder sb = new StyleBuilder();
    FilterFactory ff = sb.getFilterFactory();
    Style style = sb.createStyle();
    style.setName("MyStyle");
    
    // "testPoint" feature type style
    Mark testMark = sb.createMark(sb.attributeExpression("name"), sb.createFill(Color.RED, 0.5),
            null);
    Graphic graph = sb.createGraphic(null, new Mark[] { testMark }, null, sb.literalExpression(1),
            sb.attributeExpression("size"), sb.attributeExpression("rotation"));
    style.featureTypeStyles().add(
            sb.createFeatureTypeStyle("testPoint", sb.createPointSymbolizer(graph)));
    
    // "labelPoint" feature type style
    AnchorPoint anchorPoint = sb.createAnchorPoint(sb.attributeExpression("X"),
            sb.attributeExpression("Y"));
    PointPlacement pointPlacement = sb.createPointPlacement(anchorPoint, null,
            sb.literalExpression(0));
    TextSymbolizer textSymbolizer = sb.createTextSymbolizer(sb.createFill(Color.BLACK), new Font[] {
            sb.createFont("Lucida Sans", 10), sb.createFont("Arial", 10) }, sb.createHalo(),
            sb.attributeExpression("name"), pointPlacement, null);
    Mark circle = sb.createMark(StyleBuilder.MARK_CIRCLE, Color.RED);
    Graphic graph2 = sb.createGraphic(null, circle, null, 1, 4, 0);
    PointSymbolizer pointSymbolizer = sb.createPointSymbolizer(graph2);
    style.featureTypeStyles().add(
            sb.createFeatureTypeStyle("labelPoint", new Symbolizer[] { textSymbolizer,
                    pointSymbolizer }));
    // markTestSLD end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:32,代码来源:StyleExamples.java

示例8: styleBuilderExample

import org.geotools.styling.StyleBuilder; //导入方法依赖的package包/类
private void styleBuilderExample() throws Exception {
    // styleBuilderExample start
    //
    // We are using the GeoTools StyleBuilder that is helpful for quickly making things
    StyleBuilder builder = new StyleBuilder();
    FilterFactory2 ff = builder.getFilterFactory();
    
    // RULE 1
    // first rule to draw cities
    
    // define a point symbolizer representing a city
    Graphic city = builder.createGraphic();
    city.setSize(ff.literal(10));
    city.graphicalSymbols().add(builder.createExternalGraphic("file:city.svg", "svg")); // svg
                                                                                        // preferred
    city.graphicalSymbols().add(builder.createExternalGraphic("file:city.png", "png")); // png next
    city.graphicalSymbols().add(
            builder.createMark(StyleBuilder.MARK_CIRCLE, Color.BLUE, Color.BLACK, 1));
    PointSymbolizer pointSymbolizer = builder.createPointSymbolizer(city, "the_geom");
    
    Rule rule1 = builder.createRule(pointSymbolizer);
    rule1.setName("rule1");
    rule1.getDescription().setTitle("City");
    rule1.getDescription().setAbstract("Rule for drawing cities");
    rule1.setFilter(ff.less(ff.property("POPULATION"), ff.literal(50000)));
    
    //
    // RULE 2 Default
    Graphic dotGraphic = builder.createGraphic(null, builder.createMark(StyleBuilder.MARK_CIRCLE),
            null);
    PointSymbolizer dotSymbolize = builder.createPointSymbolizer(dotGraphic);
    Rule rule2 = builder.createRule(dotSymbolize);
    rule2.setIsElseFilter(true);
    
    //
    // define feature type styles used to actually define how features are rendered
    Rule rules[] = new Rule[] { rule1, rule2 };
    FeatureTypeStyle featureTypeStyle = builder.createFeatureTypeStyle("Feature", rules);
    
    //
    // create a "user defined" style
    Style style = builder.createStyle();
    style.setName("style");
    style.getDescription().setTitle("User Style");
    style.getDescription().setAbstract("Definition of Style");
    style.featureTypeStyles().add(featureTypeStyle);
    // styleBuilderExample end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:49,代码来源:StyleExamples.java


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