本文整理汇总了Java中org.geotools.styling.StyleBuilder.createGraphic方法的典型用法代码示例。如果您正苦于以下问题:Java StyleBuilder.createGraphic方法的具体用法?Java StyleBuilder.createGraphic怎么用?Java StyleBuilder.createGraphic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.styling.StyleBuilder
的用法示例。
在下文中一共展示了StyleBuilder.createGraphic方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDefaultPointFeatureTypeStyle
import org.geotools.styling.StyleBuilder; //导入方法依赖的package包/类
private FeatureTypeStyle createDefaultPointFeatureTypeStyle(String radius, String color, String opacity){
Fill pointFill = sf.getDefaultFill();
pointFill.setColor(filterFactory.literal(color));
pointFill.setOpacity(filterFactory.literal(opacity));
Stroke pointStroke = sf.getDefaultStroke();
pointStroke.setWidth(filterFactory.literal(new Integer(DEFAULT_STROKE_WIDTH)));
pointStroke.setColor(filterFactory.literal(DEFAULT_COLOR));
pointStroke.setOpacity(filterFactory.literal(opacity));
StyleBuilder sb = new StyleBuilder();
Mark circle = sb.createMark(StyleBuilder.MARK_CIRCLE, pointFill,pointStroke);
Graphic graph = sb.createGraphic(null, circle, null, Double.parseDouble(opacity), Double.parseDouble(radius) , DEFAULT_POINT_ROTATION);
PointSymbolizer pointSymbolizer = sb.createPointSymbolizer(graph);
Rule pointRule = sf.createRule();
pointRule.symbolizers().add(pointSymbolizer);
FeatureTypeStyle pointFeatureTypeStyle = sf.createFeatureTypeStyle(new Rule[]{pointRule});
return pointFeatureTypeStyle;
}
示例2: 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
}
示例3: 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
}
示例4: setGraphic
import org.geotools.styling.StyleBuilder; //导入方法依赖的package包/类
/**
* TODO summary sentence for setGraphic ...
*
* @param graphic
* @param mode
* @param enabled
*/
public void setGraphic(Graphic graphic, final Mode mode, final Color defaultColor) {
boolean enabled = true;
if ( graphic == null ) {
final StyleBuilder builder = new StyleBuilder();
graphic = builder.createGraphic(null, builder.createMark(StyleBuilder.MARK_SQUARE, defaultColor), null);
enabled = true;
}
this.width = SLDs.size(graphic);
final String text = MessageFormat.format("{0,number,#0}", this.width); //$NON-NLS-1$
if ( text != null ) {
this.size.setText(text);
this.size.select(this.size.indexOf(text));
}
boolean marked = false;
if ( graphic != null && graphic.graphicalSymbols() != null && !graphic.graphicalSymbols().isEmpty() ) {
for ( final GraphicalSymbol symbol : graphic.graphicalSymbols() ) {
if ( symbol instanceof Mark ) {
final Mark mark = (Mark) symbol;
setMark(mark, mode);
marked = true;
break;
}
}
}
if ( !marked ) {
setMark(null, mode);
}
this.enabled = this.enabled && enabled;
}
示例5: 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
}
示例6: 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
}
示例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
}
示例8: testGetFill
import org.geotools.styling.StyleBuilder; //导入方法依赖的package包/类
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename#getFill(org.opengis.style.GraphicFill, com.sldeditor.ui.detail.GraphicPanelFieldManager)}.
*/
@Test
public void testGetFill() {
boolean valueOnly = true;
FieldConfigFilename field = new FieldConfigFilename(
new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly),
null, null, null);
GraphicFill graphicFill = null;
GraphicPanelFieldManager fieldConfigManager = null;
assertNull(field.getFill(graphicFill, fieldConfigManager));
Class<?> panelId = PointFillDetails.class;
FieldIdEnum colourFieldId = FieldIdEnum.FILL_COLOUR;
FieldConfigColour colourField = new FieldConfigColour(
new FieldConfigCommonData(panelId, colourFieldId, "", false));
colourField.createUI();
String expectedColourValue = "#012345";
colourField.setTestValue(FieldIdEnum.UNKNOWN, expectedColourValue);
double expectedOpacityValue = 0.72;
FieldConfigSlider opacityField = new FieldConfigSlider(
new FieldConfigCommonData(panelId, colourFieldId, "", false));
opacityField.createUI();
opacityField.populateField(expectedOpacityValue);
FieldConfigBase symbolSelectionField = new FieldConfigSymbolType(
new FieldConfigCommonData(panelId, colourFieldId, "", false));
symbolSelectionField.createUI();
fieldConfigManager = new GraphicPanelFieldManager(panelId);
fieldConfigManager.add(colourFieldId, colourField);
FieldIdEnum opacityFieldId = FieldIdEnum.OVERALL_OPACITY;
fieldConfigManager.add(opacityFieldId, opacityField);
FieldIdEnum symbolSelectionFieldId = FieldIdEnum.SYMBOL_TYPE;
fieldConfigManager.add(symbolSelectionFieldId, symbolSelectionField);
field.createUI();
StyleBuilder styleBuilder = new StyleBuilder();
graphicFill = styleBuilder.createGraphic();
Fill actualValue = field.getFill(graphicFill, fieldConfigManager);
assertTrue(actualValue.getOpacity().toString()
.compareTo(String.valueOf(expectedOpacityValue)) == 0);
}
示例9: testGetFill
import org.geotools.styling.StyleBuilder; //导入方法依赖的package包/类
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker#getFill(org.opengis.style.GraphicFill, com.sldeditor.ui.detail.GraphicPanelFieldManager)}.
*/
@Test
public void testGetFill() {
// Test it with null values
boolean valueOnly = true;
ColourFieldConfig fillConfig = new ColourFieldConfig(GroupIdEnum.FILL,
FieldIdEnum.FILL_COLOUR, FieldIdEnum.OVERALL_OPACITY, FieldIdEnum.STROKE_WIDTH);
ColourFieldConfig strokeConfig = new ColourFieldConfig(GroupIdEnum.STROKE,
FieldIdEnum.STROKE_STROKE_COLOUR, FieldIdEnum.OVERALL_OPACITY,
FieldIdEnum.STROKE_FILL_WIDTH);
FieldConfigMarker field = new FieldConfigMarker(
new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly),
fillConfig, strokeConfig, null);
assertNull(field.getStringValue());
GraphicFill graphicFill = null;
GraphicPanelFieldManager fieldConfigManager = null;
Fill actualValue = field.getFill(graphicFill, fieldConfigManager);
assertNull(actualValue);
Class<?> panelId = PointFillDetails.class;
fieldConfigManager = new GraphicPanelFieldManager(panelId);
actualValue = field.getFill(graphicFill, fieldConfigManager);
assertNotNull(actualValue);
assertNull(actualValue.getColor());
assertNull(actualValue.getGraphicFill());
assertNull(actualValue.getOpacity());
// Test it with non null values
FieldIdEnum colourFieldId = FieldIdEnum.FILL_COLOUR;
FieldConfigColour colourField = new FieldConfigColour(
new FieldConfigCommonData(panelId, colourFieldId, "", false));
colourField.createUI();
String expectedColourValue = "#012345";
colourField.setTestValue(null, expectedColourValue);
double expectedOpacityValue = 0.72;
FieldConfigSlider opacityField = new FieldConfigSlider(
new FieldConfigCommonData(panelId, colourFieldId, "", false));
opacityField.createUI();
opacityField.populateField(expectedOpacityValue);
FieldConfigBase symbolSelectionField = new FieldConfigSymbolType(
new FieldConfigCommonData(panelId, colourFieldId, "", false));
symbolSelectionField.createUI();
fieldConfigManager.add(colourFieldId, colourField);
FieldIdEnum opacityFieldId = FieldIdEnum.OVERALL_OPACITY;
fieldConfigManager.add(opacityFieldId, opacityField);
FieldIdEnum symbolSelectionFieldId = FieldIdEnum.SYMBOL_TYPE;
fieldConfigManager.add(symbolSelectionFieldId, symbolSelectionField);
FieldConfigMarker field2 = new FieldConfigMarker(
new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly),
fillConfig, strokeConfig, symbolSelectionFieldId);
actualValue = field2.getFill(graphicFill, fieldConfigManager);
assertNotNull(actualValue);
LiteralExpressionImpl literalExpressionImpl = (LiteralExpressionImpl) actualValue
.getColor();
String actualColourString = literalExpressionImpl.toString();
assertTrue(actualColourString.compareTo(expectedColourValue) == 0);
StyleBuilder styleBuilder = new StyleBuilder();
graphicFill = styleBuilder.createGraphic();
actualValue = field2.getFill(graphicFill, fieldConfigManager);
assertNull(actualValue.getColor());
assertNull(actualValue.getOpacity());
}
示例10: 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
}