本文整理汇总了Java中org.geotools.factory.CommonFactoryFinder.getStyleFactory方法的典型用法代码示例。如果您正苦于以下问题:Java CommonFactoryFinder.getStyleFactory方法的具体用法?Java CommonFactoryFinder.getStyleFactory怎么用?Java CommonFactoryFinder.getStyleFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.factory.CommonFactoryFinder
的用法示例。
在下文中一共展示了CommonFactoryFinder.getStyleFactory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testUpdateExtent
import org.geotools.factory.CommonFactoryFinder; //导入方法依赖的package包/类
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel#updateExtent(org.geotools.styling.FeatureTypeConstraint)}.
*/
@Test
public void testUpdateExtent() {
ExtentModel model = new ExtentModel(null);
Extent[] extentArray = null;
model.populate(extentArray);
extentArray = new Extent[2];
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
extentArray[0] = styleFactory.createExtent("extent 1", "1 1 1 1");
extentArray[1] = styleFactory.createExtent("extent 2", "2 2 2 2");
model.populate(extentArray);
FeatureTypeConstraint ftc = styleFactory.createFeatureTypeConstraint("feature type name",
Filter.INCLUDE, null);
model.updateExtent(null);
model.updateExtent(ftc);
assertNotNull(ftc.getExtents());
assertEquals(2, ftc.getExtents().length);
}
示例2: testGetSymbolList
import org.geotools.factory.CommonFactoryFinder; //导入方法依赖的package包/类
/**
* Test method for
* {@link com.sldeditor.common.data.SelectedSymbol#getSymbolList(org.opengis.style.GraphicalSymbol)}.
*/
@Test
public void testGetSymbolList() {
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
Stroke stroke = null;
Fill fill = styleFactory.createFill(ff.literal(DefaultSymbols.defaultColour()));
GraphicalSymbol symbolToAdd = styleFactory.mark(ff.literal("circle"), fill, stroke);
List<GraphicalSymbol> symbolList = SelectedSymbol.getInstance().getSymbolList(symbolToAdd);
assertEquals(1, symbolList.size());
assertEquals(symbolToAdd, symbolList.get(0));
}
示例3: createDefaultLineFeatureTypeStyle
import org.geotools.factory.CommonFactoryFinder; //导入方法依赖的package包/类
private FeatureTypeStyle createDefaultLineFeatureTypeStyle(String strokeWidth, String strokeColor, String opacity){
StyleFactory sf = CommonFactoryFinder.getStyleFactory(new Hints(Hints.KEY_RENDERING, Hints.VALUE_RENDER_SPEED));
FilterFactory filterFactory = new FilterFactoryImpl();
Stroke lineStroke = sf.getDefaultStroke();
lineStroke.setWidth(filterFactory.literal(new Integer(strokeWidth)));
lineStroke.setColor(filterFactory.literal(strokeColor));
lineStroke.setOpacity(filterFactory.literal(opacity));
LineSymbolizer lineSymbolizer = sf.createLineSymbolizer();
lineSymbolizer.setStroke(lineStroke);
Rule lineRule = sf.createRule();
lineRule.symbolizers().add(lineSymbolizer);
FeatureTypeStyle lineFeatureTypeStyle = sf.createFeatureTypeStyle(new Rule[]{lineRule});
return lineFeatureTypeStyle;
}
示例4: createStyle
import org.geotools.factory.CommonFactoryFinder; //导入方法依赖的package包/类
@SuppressWarnings({"deprecation"})
private static Style createStyle() {
StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(null);
FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(null);
PolygonSymbolizer symbolizer = styleFactory.createPolygonSymbolizer();
Fill fill = styleFactory.createFill(
filterFactory.literal("#FFAA00"),
filterFactory.literal(0.5)
);
symbolizer.setFill(fill);
Rule rule = styleFactory.createRule();
rule.setSymbolizers(new Symbolizer[]{symbolizer});
FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
fts.setRules(new Rule[]{rule});
Style style = styleFactory.createStyle();
style.addFeatureTypeStyle(fts);
return style;
}
示例5: convertToSLD_1_1
import org.geotools.factory.CommonFactoryFinder; //导入方法依赖的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();
}
}
示例6: getDirectRasterStyle
import org.geotools.factory.CommonFactoryFinder; //导入方法依赖的package包/类
private static FeatureTypeStyle getDirectRasterStyle(
final String geometryPropertyName,
final Expression transformation ) {
final StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();
final FeatureTypeStyle style = styleFactory.createFeatureTypeStyle();
final Rule rule = styleFactory.createRule();
rule.setName("distributed render - direct raster");
rule.setTitle("Distributed Render - Direct Raster");
final RasterSymbolizer symbolizer = styleFactory.createRasterSymbolizer();
symbolizer.setGeometryPropertyName(geometryPropertyName);
rule.symbolizers().add(
symbolizer);
style.rules().add(
rule);
style.setTransformation(transformation);
return style;
}
示例7: createSLDFromString
import org.geotools.factory.CommonFactoryFinder; //导入方法依赖的package包/类
/**
* Creates a StyledLayerDescriptor object containing a SLD from a string.
*
* @param sldData the sld data
* @return the styled layer descriptor
*/
public static StyledLayerDescriptor createSLDFromString(SLDDataInterface sldData) {
if ((sldData == null) || (sldData.getSld() == null)) {
return null;
}
StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();
InputStream stream = new ByteArrayInputStream(sldData.getSld().getBytes());
SLDParser styleReader = new SLDParser(styleFactory, stream);
URL resourceLocator = getResourceLocator(sldData);
sldData.setResourceLocator(resourceLocator);
setResourcelocator(styleReader, resourceLocator);
StyledLayerDescriptor sld = null;
try {
sld = styleReader.parseSLD();
} catch (RuntimeException e) {
String errorMessage = String.format("SLD Parser error : %s",
sldData.getStyle().toString());
ConsoleManager.getInstance().error(SLDUtils.class, errorMessage);
ConsoleManager.getInstance().error(SLDUtils.class, e.getMessage());
}
return sld;
}
示例8: testAddRaster
import org.geotools.factory.CommonFactoryFinder; //导入方法依赖的package包/类
/**
* Test method for {@link com.sldeditor.ui.tree.SLDTreeTools#addRaster()}.
*/
@Test
public void testAddRaster() {
SLDTreeTools treeTools = new SLDTreeTools();
TestSLDTree sldTree = new TestSLDTree(null, treeTools);
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
// Start off with just a top level SLD and no structure below it
StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
SelectedSymbol.getInstance().setSld(sld);
sldTree.populateSLD();
sldTree.selectFirstSymbol();
treeTools.addNewThing(NamedLayer.class);
treeTools.addNewThing(null);
treeTools.addNewThing(null);
treeTools.addNewThing(null);
DefaultMutableTreeNode rootNode = sldTree.getRootNode();
// Make sure we have a rule selected
DefaultMutableTreeNode rule = (DefaultMutableTreeNode) rootNode.getChildAt(0).getChildAt(0)
.getChildAt(0).getChildAt(0);
assertEquals(RuleImpl.class, rule.getUserObject().getClass());
assertEquals(0, rule.getChildCount());
treeTools.addNewRaster();
DefaultMutableTreeNode rasterNode = (DefaultMutableTreeNode) rule.getChildAt(0);
assertEquals(RasterSymbolizerImpl.class, rasterNode.getUserObject().getClass());
}
示例9: testAddNewLine
import org.geotools.factory.CommonFactoryFinder; //导入方法依赖的package包/类
/**
* Test method for {@link com.sldeditor.ui.tree.SLDTreeTools#addNewLine()}.
*/
@Test
public void testAddNewLine() {
SLDTreeTools treeTools = new SLDTreeTools();
TestSLDTree sldTree = new TestSLDTree(null, treeTools);
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
// Start off with just a top level SLD and no structure below it
StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
SelectedSymbol.getInstance().setSld(sld);
sldTree.populateSLD();
sldTree.selectFirstSymbol();
treeTools.addNewThing(NamedLayer.class);
treeTools.addNewThing(null);
treeTools.addNewThing(null);
treeTools.addNewThing(null);
DefaultMutableTreeNode rootNode = sldTree.getRootNode();
// Make sure we have a rule selected
DefaultMutableTreeNode rule = (DefaultMutableTreeNode) rootNode.getChildAt(0).getChildAt(0)
.getChildAt(0).getChildAt(0);
assertEquals(RuleImpl.class, rule.getUserObject().getClass());
assertEquals(0, rule.getChildCount());
treeTools.addNewLine();
DefaultMutableTreeNode lineNode = (DefaultMutableTreeNode) rule.getChildAt(0);
assertEquals(LineSymbolizerImpl.class, lineNode.getUserObject().getClass());
}
示例10: testAddNewPolygon
import org.geotools.factory.CommonFactoryFinder; //导入方法依赖的package包/类
/**
* Test method for {@link com.sldeditor.ui.tree.SLDTreeTools#addNewPolygon()}.
*/
@Test
public void testAddNewPolygon() {
SLDTreeTools treeTools = new SLDTreeTools();
TestSLDTree sldTree = new TestSLDTree(null, treeTools);
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
// Start off with just a top level SLD and no structure below it
StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
SelectedSymbol.getInstance().setSld(sld);
sldTree.populateSLD();
sldTree.selectFirstSymbol();
treeTools.addNewThing(NamedLayer.class);
treeTools.addNewThing(null);
treeTools.addNewThing(null);
treeTools.addNewThing(null);
DefaultMutableTreeNode rootNode = sldTree.getRootNode();
// Make sure we have a rule selected
DefaultMutableTreeNode rule = (DefaultMutableTreeNode) rootNode.getChildAt(0).getChildAt(0)
.getChildAt(0).getChildAt(0);
assertEquals(RuleImpl.class, rule.getUserObject().getClass());
assertEquals(0, rule.getChildCount());
treeTools.addNewPolygon();
DefaultMutableTreeNode polygonNode = (DefaultMutableTreeNode) rule.getChildAt(0);
assertEquals(PolygonSymbolizerImpl.class, polygonNode.getUserObject().getClass());
}
示例11: testAddNewImageOutlinePolygon
import org.geotools.factory.CommonFactoryFinder; //导入方法依赖的package包/类
/**
* Test method for {@link com.sldeditor.ui.tree.SLDTreeTools#addNewImageOutlinePolygon()}.
*/
@Test
public void testAddNewImageOutlinePolygon() {
SLDTreeTools treeTools = new SLDTreeTools();
TestSLDTree sldTree = new TestSLDTree(null, treeTools);
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
// Start off with just a top level SLD and no structure below it
StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
SelectedSymbol.getInstance().setSld(sld);
sldTree.populateSLD();
sldTree.selectFirstSymbol();
treeTools.addNewThing(NamedLayer.class);
treeTools.addNewThing(null);
treeTools.addNewThing(null);
treeTools.addNewThing(null);
DefaultMutableTreeNode rootNode = sldTree.getRootNode();
// Make sure we have a rule selected
DefaultMutableTreeNode rule = (DefaultMutableTreeNode) rootNode.getChildAt(0).getChildAt(0)
.getChildAt(0).getChildAt(0);
assertEquals(RuleImpl.class, rule.getUserObject().getClass());
assertEquals(0, rule.getChildCount());
treeTools.addNewRaster();
DefaultMutableTreeNode rasterNode = (DefaultMutableTreeNode) rule.getChildAt(0);
assertEquals(RasterSymbolizerImpl.class, rasterNode.getUserObject().getClass());
treeTools.addNewImageOutlinePolygon();
DefaultMutableTreeNode imageOutlineNode = (DefaultMutableTreeNode) rasterNode.getChildAt(0);
assertEquals(PolygonSymbolizerImpl.class, imageOutlineNode.getUserObject().getClass());
}
示例12: testAddNewImageOutlineLine
import org.geotools.factory.CommonFactoryFinder; //导入方法依赖的package包/类
/**
* Test method for {@link com.sldeditor.ui.tree.SLDTreeTools#addNewImageOutlineLine()}.
*/
@Test
public void testAddNewImageOutlineLine() {
SLDTreeTools treeTools = new SLDTreeTools();
TestSLDTree sldTree = new TestSLDTree(null, treeTools);
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
// Start off with just a top level SLD and no structure below it
StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
SelectedSymbol.getInstance().setSld(sld);
sldTree.populateSLD();
sldTree.selectFirstSymbol();
treeTools.addNewThing(NamedLayer.class);
treeTools.addNewThing(null);
treeTools.addNewThing(null);
treeTools.addNewThing(null);
DefaultMutableTreeNode rootNode = sldTree.getRootNode();
// Make sure we have a rule selected
DefaultMutableTreeNode rule = (DefaultMutableTreeNode) rootNode.getChildAt(0).getChildAt(0)
.getChildAt(0).getChildAt(0);
assertEquals(RuleImpl.class, rule.getUserObject().getClass());
assertEquals(0, rule.getChildCount());
treeTools.addNewRaster();
DefaultMutableTreeNode rasterNode = (DefaultMutableTreeNode) rule.getChildAt(0);
assertEquals(RasterSymbolizerImpl.class, rasterNode.getUserObject().getClass());
treeTools.addNewImageOutlineLine();
DefaultMutableTreeNode imageOutlineNode = (DefaultMutableTreeNode) rasterNode.getChildAt(0);
assertEquals(LineSymbolizerImpl.class, imageOutlineNode.getUserObject().getClass());
}
示例13: displayMaps
import org.geotools.factory.CommonFactoryFinder; //导入方法依赖的package包/类
@Execute
public void displayMaps() throws Exception {
sf = CommonFactoryFinder.getStyleFactory(GeoTools.getDefaultHints());
ff = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
sb = new StyleBuilder(sf, ff);
final MapContent map = new MapContent();
map.setTitle("Maps Viewer");
addImageMosaic(map);
addCoverages(map);
addFeatureCollections(map);
map.getViewport().setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84);
// Create a JMapFrame with a menu to choose the display style for the
final JMapFrame frame = new JMapFrame(map);
frame.setSize(1800, 1200);
frame.enableStatusBar(true);
frame.enableTool(JMapFrame.Tool.ZOOM, JMapFrame.Tool.PAN, JMapFrame.Tool.RESET);
frame.enableToolBar(true);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter(){
public void windowClosing( WindowEvent e ) {
frame.setVisible(false);
}
});
while( frame.isVisible() ) {
Thread.sleep(300);
}
}
示例14: convertDomToValue
import org.geotools.factory.CommonFactoryFinder; //导入方法依赖的package包/类
@Override
public Object convertDomToValue(DomElement parentElement, Object value) throws ConversionException,
ValidationException {
final DomElement child = parentElement.getChild(0);
SLDParser s = new SLDParser(CommonFactoryFinder.getStyleFactory(null), new StringReader(child.toXml()));
final Style[] styles = s.readXML();
return styles[0];
}
示例15: styleFactoryExample
import org.geotools.factory.CommonFactoryFinder; //导入方法依赖的package包/类
/**
* This example is limited to just the gt-opengis style interfaces which are immutable once created.
*
* @throws Exception
*/
private void styleFactoryExample() throws Exception {
// styleFactoryExample start
//
org.opengis.style.StyleFactory sf = CommonFactoryFinder.getStyleFactory();
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
//
// 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));
// OnLineResource implemented by gt-metadata - so no factory!
OnLineResourceImpl svg = new OnLineResourceImpl(new URI("file:city.svg"));
svg.freeze(); // freeze to prevent modification at runtime
OnLineResourceImpl png = new OnLineResourceImpl(new URI("file:city.png"));
png.freeze(); // freeze to prevent modification at runtime
//
// List of symbols is considered in order with the rendering engine choosing
// the first one it can handle. Allowing for svg, png, mark order
List<GraphicalSymbol> symbols = new ArrayList<GraphicalSymbol>();
symbols.add(sf.externalGraphic(svg, "svg", null)); // svg preferred
symbols.add(sf.externalGraphic(png, "png", null)); // png preferred
symbols.add(sf.mark(ff.literal("circle"), fill, stroke)); // simple circle backup plan
Expression opacity = null; // use default
Expression size = ff.literal(10);
Expression rotation = null; // use default
AnchorPoint anchor = null; // use default
Displacement displacement = null; // use default
// define a point symbolizer of a small circle
Graphic circle = sf.graphic(symbols, opacity, size, rotation, anchor, displacement);
PointSymbolizer pointSymbolizer = sf.pointSymbolizer("point", ff.property("the_geom"), null,
null, circle);
// styleFactoryExample end
}