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


Java StyleFactory.createStyledLayerDescriptor方法代码示例

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


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

示例1: convertToSLD_1_1

import org.geotools.styling.StyleFactory; //导入方法依赖的package包/类
private void convertToSLD_1_1() {
	if (style == null) {
		JOptionPane.showMessageDialog(this, "Style not defined");
		return;
	}
	// Wrap style as an SLD
	StyleFactory factory = CommonFactoryFinder.getStyleFactory();
	StyledLayerDescriptor sld = factory.createStyledLayerDescriptor();

	org.geotools.sld.v1_1.SLDConfiguration configuration = new org.geotools.sld.v1_1.SLDConfiguration();
	Encoder encoder = new org.geotools.xml.Encoder(configuration);

	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	try {
		encoder.encode(style,
				org.geotools.sld.bindings.SLD.STYLEDLAYERDESCRIPTOR,
				outputStream);
		String document = outputStream.toString("UTF-8");

		display(document, SLD_1_1);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:25,代码来源:StyleConverter.java

示例2: createDefaultSLD

import org.geotools.styling.StyleFactory; //导入方法依赖的package包/类
public static StyledLayerDescriptor createDefaultSLD(Style style) {
	StyleFactory factory = CommonFactoryFinder.getStyleFactory();

	StyledLayerDescriptor sld = factory.createStyledLayerDescriptor();
	UserLayer layer = factory.createUserLayer();

	// FeatureTypeConstraint ftc =
	// styleFactory.createFeatureTypeConstraint(null, Filter.INCLUDE, null);
	layer.setLayerFeatureConstraints(new FeatureTypeConstraint[] { null });
	sld.addStyledLayer(layer);
	layer.addUserStyle((org.geotools.styling.Style) style);

	return sld;
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:15,代码来源:StyleConverter.java

示例3: sldExample

import org.geotools.styling.StyleFactory; //导入方法依赖的package包/类
private void sldExample() {
    // sldExample start
    StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();
    
    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
    sld.setName("example");
    sld.setAbstract("Example Style Layer Descriptor");
    
    UserLayer layer = styleFactory.createUserLayer();
    layer.setName("layer");
    
    FeatureTypeConstraint constraint = styleFactory.createFeatureTypeConstraint("Feature",
            Filter.INCLUDE, null);
    
    layer.layerFeatureConstraints().add(constraint);
    
    Style style = styleFactory.createStyle();
    
    style.getDescription().setTitle("Style");
    style.getDescription().setAbstract("Definition of Style");
    
    // define feature type styles used to actually
    // define how features are rendered
    //
    layer.userStyles().add(style);
    
    sld.layers().add(layer);
    // sldExample end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:30,代码来源:StyleExamples.java

示例4: getSuitabilityStyle

import org.geotools.styling.StyleFactory; //导入方法依赖的package包/类
public StyledLayerDescriptor getSuitabilityStyle(String columnName) {

    LOGGER.debug("creating a style for suitability column: for", columnName);

    StyleFactory sf = CommonFactoryFinder.getStyleFactory();
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();

    UserLayer layer = sf.createUserLayer();
    layer.setName("layer");

    StyledLayerDescriptor sld = sf.createStyledLayerDescriptor();
    sld.setName("sld");
    sld.setTitle("Example");
    sld.setAbstract("Example Style Layer Descriptor");

    // define constraint limited what features the sld applies to
    FeatureTypeConstraint constraint = sf.createFeatureTypeConstraint(
        "Feature", Filter.INCLUDE, null);

    layer.layerFeatureConstraints().add(constraint);

    //
    // create a "user defined" style
    Style style = sf.createStyle();
    style.setName("style");
    style.getDescription().setTitle("User Style");
    style.getDescription().setAbstract("Definition of Style");

    // define feature type styles used to actually define how features are
    // rendered
    FeatureTypeStyle featureTypeStyle = sf.createFeatureTypeStyle();

    // RULE 1
    // first rule to draw cities
    Rule rule1 = sf.createRule();
    rule1.setName("rule1");
    rule1.getDescription().setTitle("City");
    rule1.getDescription().setAbstract("Rule for drawing cities");
    rule1.setFilter(ff.less(ff.property("POPULATION"), ff.literal(50000)));

    //
    // create the graphical mark used to represent a city
    Stroke stroke = sf.stroke(ff.literal("#000000"), null, null, null, null,
        null, null);
    Fill fill = sf.fill(null, ff.literal(Color.BLUE), ff.literal(1.0));
    
StyleBuilder styleBuilder = new StyleBuilder();

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);
rule1.symbolizers().add(polygonSymbolizer);

    featureTypeStyle.rules().add(rule1);
    
style.featureTypeStyles().add(featureTypeStyle);
    
    layer.userStyles().add(style);
    
    sld.layers().add(layer);
    
    // // create the parser with the sld configuration
    // org.geotools.xml.Configuration configuration = new
    // org.geotools.sld.SLDConfiguration();
    // Parser parser = new org.geotools.xml.Parser(configuration);

    // // the xml instance document above
    // InputStream xml = new FileInputStream("markTest.sld");

    // // parse
    // StyledLayerDescriptor sld = (StyledLayerDescriptor) parser.parse(xml);

    // DuplicatingStyleVisitor xerox = new DuplicatingStyleVisitor();
    // style.accepts( xerox );
    // Style copy = (Style) xerox.getCopy();
    return sld;
  }
 
开发者ID:AURIN,项目名称:online-whatif,代码行数:82,代码来源:GeodataStyler.java

示例5: createTestLine

import org.geotools.styling.StyleFactory; //导入方法依赖的package包/类
/**
 * Creates the test line.
 *
 * @param url the url
 * @return the styled layer descriptor
 */
private StyledLayerDescriptor createTestLine(URL url) {
    StyleBuilder sb = new StyleBuilder();
    StyleFactory styleFactory = sb.getStyleFactory();

    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();

    NamedLayer namedLayer = styleFactory.createNamedLayer();

    sld.addStyledLayer(namedLayer);

    Style style = styleFactory.createStyle();
    namedLayer.addStyle(style);

    List<FeatureTypeStyle> ftsList = style.featureTypeStyles();

    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();

    ftsList.add(fts);

    Rule rule = styleFactory.createRule();

    fts.rules().add(rule);

    LineSymbolizer line = styleFactory.createLineSymbolizer();

    rule.symbolizers().add(line);

    Graphic graphicFill = createGraphic(url, styleFactory);
    Graphic graphicStroke = createGraphic(url, styleFactory);

    Stroke stroke = styleFactory.createStroke(null, null, null, null, null, null, null,
            graphicFill, graphicStroke);
    line.setStroke(stroke);

    return sld;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:43,代码来源:SLDExternalImagesTest.java

示例6: createTestPoint

import org.geotools.styling.StyleFactory; //导入方法依赖的package包/类
/**
 * Creates the test point.
 *
 * @param url the url
 * @return the styled layer descriptor
 */
private StyledLayerDescriptor createTestPoint(URL url) {
    StyleBuilder sb = new StyleBuilder();
    StyleFactory styleFactory = sb.getStyleFactory();

    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();

    NamedLayer namedLayer = styleFactory.createNamedLayer();

    sld.addStyledLayer(namedLayer);

    Style style = styleFactory.createStyle();
    namedLayer.addStyle(style);

    List<FeatureTypeStyle> ftsList = style.featureTypeStyles();

    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();

    ftsList.add(fts);

    Rule rule = styleFactory.createRule();

    fts.rules().add(rule);

    PointSymbolizer point = styleFactory.createPointSymbolizer();

    rule.symbolizers().add(point);

    Graphic graphic = createGraphic(url, styleFactory);

    point.setGraphic(graphic);

    return sld;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:40,代码来源:SLDExternalImagesTest.java

示例7: createTestPolygon

import org.geotools.styling.StyleFactory; //导入方法依赖的package包/类
/**
 * Creates the test polygon.
 *
 * @param url the url
 * @return the styled layer descriptor
 */
private StyledLayerDescriptor createTestPolygon(URL url) {
    StyleBuilder sb = new StyleBuilder();
    StyleFactory styleFactory = sb.getStyleFactory();

    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();

    NamedLayer namedLayer = styleFactory.createNamedLayer();

    sld.addStyledLayer(namedLayer);

    Style style = styleFactory.createStyle();
    namedLayer.addStyle(style);

    List<FeatureTypeStyle> ftsList = style.featureTypeStyles();

    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();

    ftsList.add(fts);

    Rule rule = styleFactory.createRule();

    fts.rules().add(rule);

    PolygonSymbolizer polygon = styleFactory.createPolygonSymbolizer();

    rule.symbolizers().add(polygon);

    Graphic graphicFill1 = createGraphic(url, styleFactory);
    Graphic graphicFill2 = createGraphic(url, styleFactory);
    Graphic graphicStroke = createGraphic(url, styleFactory);
    Fill fill = styleFactory.createFill(null, null, null, graphicFill1);

    polygon.setFill(fill);

    Stroke stroke = styleFactory.createStroke(null, null, null, null, null, null, null,
            graphicFill2, graphicStroke);
    polygon.setStroke(stroke);

    return sld;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:47,代码来源:SLDExternalImagesTest.java


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