本文整理汇总了Java中org.geotools.styling.Style类的典型用法代码示例。如果您正苦于以下问题:Java Style类的具体用法?Java Style怎么用?Java Style使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Style类属于org.geotools.styling包,在下文中一共展示了Style类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createRGBStyle
import org.geotools.styling.Style; //导入依赖的package包/类
/**
* Creates the rgb style.
*
* @param reader the reader
* @param raster the raster
* @return the style
*/
private Style createRGBStyle(AbstractGridCoverage2DReader reader, WritableRaster raster) {
RasterSymbolizer sym = sf.getDefaultRasterSymbolizer();
GridCoverage2D cov = null;
try {
cov = reader.read(null);
} catch (IOException giveUp) {
throw new RuntimeException(giveUp);
}
// We need at least three bands to create an RGB style
int numBands = cov.getNumSampleDimensions();
if (numBands < 3) {
createRGBImageSymbol(sym, cov, raster);
} else {
createRGBChannelSymbol(sym, cov, numBands);
}
return SLD.wrapSymbolizers(sym);
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:26,代码来源:RasterReader.java
示例2: FeatureLayer
import org.geotools.styling.Style; //导入依赖的package包/类
public FeatureLayer(LayerType layerType, final FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
PropertySet configuration) {
super(layerType, configuration);
crs = fc.getSchema().getGeometryDescriptor().getCoordinateReferenceSystem();
if (crs == null) {
// todo - check me! Why can this happen??? (nf)
crs = DefaultGeographicCRS.WGS84;
}
final ReferencedEnvelope envelope = new ReferencedEnvelope(fc.getBounds(), crs);
modelBounds = new Rectangle2D.Double(envelope.getMinX(), envelope.getMinY(),
envelope.getWidth(), envelope.getHeight());
mapContext = new DefaultMapContext(crs);
final Style style = (Style) configuration.getValue(FeatureLayerType.PROPERTY_NAME_SLD_STYLE);
mapContext.addLayer(fc, style);
renderer = new StreamingRenderer();
workaroundLabelCacheBug();
style.accept(new RetrievingStyleVisitor());
renderer.setContext(mapContext);
}
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:21,代码来源:FeatureLayer.java
示例3: renderVectorMap
import org.geotools.styling.Style; //导入依赖的package包/类
/**
* Render vector map.
*
* @param features the results
* @param imageSize the image size
* @param style the style
* @param dpi the dpi
*/
private void renderVectorMap(FeatureSource<SimpleFeatureType, SimpleFeature> features,
Rectangle imageSize, Style style, int dpi) {
List<Layer> layerList = new ArrayList<Layer>();
if (style != null) {
FeatureLayer featureLayer = new FeatureLayer(features, style);
layerList.add(featureLayer);
}
boolean hasGeometry = false;
ReferencedEnvelope bounds = null;
if (features != null) {
bounds = calculateBounds();
wmsEnvVarValues.setMapBounds(bounds);
EnvironmentVariableManager.getInstance().setWMSEnvVarValues(wmsEnvVarValues);
if (features.getSchema() != null) {
hasGeometry = (features.getSchema().getGeometryDescriptor() != null);
}
}
internal_renderMap(layerList, bounds, imageSize, hasGeometry, dpi);
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:34,代码来源:RenderPanelImpl.java
示例4: shouldRenderSymbol
import org.geotools.styling.Style; //导入依赖的package包/类
/**
* Should render symbol.
*
* @param style the style
* @param ruleToRender the rule to render
* @return true, if successful
*/
private boolean shouldRenderSymbol(Style style, FeatureTypeStyle ftsToRender,
Rule ruleToRender) {
if (ruleToRender == null) {
return true;
}
for (FeatureTypeStyle fts : style.featureTypeStyles()) {
if (fts == ftsToRender) {
for (Rule rule : fts.rules()) {
if (rule == ruleToRender) {
return true;
}
}
}
}
return false;
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:27,代码来源:RenderSymbol.java
示例5: createSingleStyleLegend
import org.geotools.styling.Style; //导入依赖的package包/类
/**
* Creates the legend for a single SLD style.
*
* @param styleMap the style map
* @param selectedStyledLayer the selected styled layer
* @param selectedStyle the selected style
*/
private void createSingleStyleLegend(Map<String, Style> styleMap,
StyledLayer selectedStyledLayer, Style selectedStyle) {
// A style has been selected
List<Style> styleList = null;
if (selectedStyledLayer instanceof NamedLayerImpl) {
NamedLayerImpl namedLayer = (NamedLayerImpl) selectedStyledLayer;
styleList = namedLayer.styles();
} else if (selectedStyledLayer instanceof UserLayerImpl) {
UserLayerImpl userLayer = (UserLayerImpl) selectedStyledLayer;
styleList = userLayer.userStyles();
}
String styleName;
if (selectedStyle.getName() != null) {
styleName = selectedStyle.getName();
} else {
styleName = String.format("Style %d", styleList.indexOf(selectedStyle));
}
styleMap.put(styleName, selectedStyle);
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:32,代码来源:LegendManager.java
示例6: populate
import org.geotools.styling.Style; //导入依赖的package包/类
/**
* Populate.
*
* @param selectedSymbol the selected symbol
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.selectedsymbol.SelectedSymbol)
*/
@Override
public void populate(SelectedSymbol selectedSymbol) {
if (selectedSymbol != null) {
Style style = selectedSymbol.getStyle();
populateStandardData(style);
if (style != null) {
fieldConfigVisitor.populateBooleanField(FieldIdEnum.DEFAULT_STYLE,
style.isDefault());
}
}
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:24,代码来源:StyleDetails.java
示例7: updateSymbol
import org.geotools.styling.Style; //导入依赖的package包/类
/**
* Update symbol.
*/
private void updateSymbol() {
if (!Controller.getInstance().isPopulating()) {
StandardData standardData = getStandardData();
boolean isDefault = fieldConfigVisitor.getBoolean(FieldIdEnum.DEFAULT_STYLE);
Style existingStyle = SelectedSymbol.getInstance().getStyle();
if (existingStyle != null) {
List<org.opengis.style.FeatureTypeStyle> newFTSList =
new ArrayList<org.opengis.style.FeatureTypeStyle>();
for (org.opengis.style.FeatureTypeStyle fts : existingStyle.featureTypeStyles()) {
newFTSList.add(fts);
}
Symbolizer defaultSymbolizer = null;
Style newStyle = (Style) getStyleFactory().style(standardData.name,
standardData.description, isDefault, newFTSList, defaultSymbolizer);
SelectedSymbol.getInstance().replaceStyle(newStyle);
this.fireUpdateSymbol();
}
}
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:28,代码来源:StyleDetails.java
示例8: isRasterSymbol
import org.geotools.styling.Style; //导入依赖的package包/类
/**
* Checks if the selected Style contains a raster symbol.
*
* @return true, if is raster symbol
*/
public boolean isRasterSymbol() {
Style style = getStyle();
if (style != null) {
for (FeatureTypeStyle fts : style.featureTypeStyles()) {
for (Rule rule : fts.rules()) {
for (Symbolizer symbolizer : rule.symbolizers()) {
if (symbolizer instanceof RasterSymbolizer) {
return true;
}
}
}
}
}
return false;
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:22,代码来源:SelectedSymbol.java
示例9: highlightSelectedPolygon
import org.geotools.styling.Style; //导入依赖的package包/类
/**
* hightlight the selected Polygon.
* @param polygonID the selected Polygon
*/
public void highlightSelectedPolygon(String polygonID) {
for (SimpleFeature simpleFeature : polygonFeatureCollection) {
String featureID = (String) simpleFeature.getAttribute("id");
if (featureID.equals(polygonID)) {
Style style =
createSelectedStyle(simpleFeature.getIdentifier());
org.geotools.map.Layer layer = null;
for (org.geotools.map.Layer layers : mapPane.getMapContent()
.layers()) {
String t = layers.getTitle();
if (t != null && t.equals(POLYGON_LAYER_TITLE)) {
layer = layers;
}
}
if (layer instanceof FeatureLayer) {
((FeatureLayer) layer).setStyle(style);
}
}
}
}
开发者ID:gdi-by,项目名称:downloadclient,代码行数:25,代码来源:WMSMapSwing.java
示例10: getStyle
import org.geotools.styling.Style; //导入依赖的package包/类
public Style getStyle()
{
Style style = null;
if ( geometry instanceof Point )
{
style = SLD.createPointStyle( CIRCLE, strokeColor, fillColor,
fillOpacity, radius );
}
else if ( geometry instanceof Polygon || geometry instanceof MultiPolygon )
{
if ( MapLayerType.BOUNDARY.equals( mapLayerType ) )
{
style = SLD.createLineStyle( strokeColor, LINE_STROKE_WIDTH );
}
else
{
style = SLD.createPolygonStyle( strokeColor, fillColor, fillOpacity );
}
}
else
{
style = SLD.createSimpleStyle( getFeatureType() );
}
return style;
}
开发者ID:dhis2,项目名称:dhis2-core,代码行数:28,代码来源:InternalMapObject.java
示例11: createFeatureLayerFromMapObject
import org.geotools.styling.Style; //导入依赖的package包/类
/**
* Creates a feature layer based on a map object.
*/
public static Layer createFeatureLayerFromMapObject( InternalMapObject mapObject )
{
Style style = mapObject.getStyle();
SimpleFeatureType featureType = mapObject.getFeatureType();
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder( featureType );
DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();
featureBuilder.add( mapObject.getGeometry() );
SimpleFeature feature = featureBuilder.buildFeature( null );
featureCollection.add( feature );
return new FeatureLayer( featureCollection, style );
}
开发者ID:dhis2,项目名称:dhis2-core,代码行数:19,代码来源:MapUtils.java
示例12: getStyle
import org.geotools.styling.Style; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Style getStyle(SimpleFeatureCollection collection, String attribute) {
this.attribute = attribute;
Style style = styler.getStyle(collection, attribute);
List<String> titles = styler.getTitles();
List<Color> colors = styler.getColors();
for (int i = 0; i < titles.size(); i++) {
tableModel.setValueAt(titles.get(i), i, TITLE_COL);
tableModel.setValueAt(colors.get(i), i, COLOR_COL);
}
this.repaint();
return style;
}
开发者ID:ianturton,项目名称:ShapefileViewer,代码行数:17,代码来源:JLegendPanel.java
示例13: updateStyle
import org.geotools.styling.Style; //导入依赖的package包/类
private void updateStyle() {
System.out.println("updating "+styler.getPaletteName()+" of "+getNumberOfClasses());
if (layer != null) {
FeatureSource<?, ?> featureSource = layer.getFeatureSource();
try {
Style style = getStyle(
(SimpleFeatureCollection) featureSource.getFeatures(),
attribute);
System.out.println("setting style");
layer.setStyle(style);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
开发者ID:ianturton,项目名称:ShapefileViewer,代码行数:20,代码来源:JLegendPanel.java
示例14: getFeatureFilterFromStyle
import org.geotools.styling.Style; //导入依赖的package包/类
/**
* Retrieve Filter information from the Layer Style.
* TODO maybe there is a better method to do that e.g. using a {@link org.geotools.styling.StyleVisitor}
*
* @param style the style of the layer
* @param ff the filter factory to create (concat) filters
* @param currentScaleDenominator the current scale denominator of the reuquested tiles
*
* @return The filter containing all relevant filters for the current solutions or null if no filter is difined.
*/
private Filter getFeatureFilterFromStyle(Style style, FilterFactory2 ff, double currentScaleDenominator) {
List<Filter> filter = new ArrayList<>();
for (FeatureTypeStyle featureTypeStyle : style.featureTypeStyles()) {
for (Rule rule : featureTypeStyle.rules()) {
if ((rule.getMaxScaleDenominator() < Double.POSITIVE_INFINITY && currentScaleDenominator < rule.getMaxScaleDenominator())
|| (rule.getMinScaleDenominator() > 0 && currentScaleDenominator > rule.getMinScaleDenominator())) {
if (rule.getFilter() != null) {
filter.add(rule.getFilter());
}
} else if (rule.getMinScaleDenominator() == 0 && rule.getMaxScaleDenominator() == Double.POSITIVE_INFINITY) {
//No Scale denominator defined so render all
if (rule.getFilter() == null) {
return null;
} else {
filter.add(rule.getFilter());
}
}
}
}
return filter.isEmpty() ? null : ff.or(filter);
}
开发者ID:stefan0722,项目名称:gs-mvt,代码行数:32,代码来源:StreamingMVTMap.java
示例15: createPolygonStyle
import org.geotools.styling.Style; //导入依赖的package包/类
/**
* Create a default polygon style.
*
* @return the created style.
*/
public static Style createPolygonStyle() {
// create a partially opaque outline stroke
final Stroke stroke = styleFactory.createStroke(filterFactory.literal(Color.BLUE), filterFactory.literal(1),
filterFactory.literal(0.5));
// create a partial opaque fill
final Fill fill = styleFactory.createFill(filterFactory.literal(Color.CYAN), filterFactory.literal(0.5));
/*
* Setting the geometryPropertyName arg to null signals that we want to draw the default geomettry of features
*/
final PolygonSymbolizer sym = styleFactory.createPolygonSymbolizer(stroke, fill, null);
final Rule rule = styleFactory.createRule();
rule.symbolizers().add(sym);
final FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(new Rule[] { rule });
final Style style = styleFactory.createStyle();
style.featureTypeStyles().add(fts);
return style;
}
开发者ID:gama-platform,项目名称:gama,代码行数:28,代码来源:Utils.java
示例16: createLineStyle
import org.geotools.styling.Style; //导入依赖的package包/类
/**
* Create a default line style.
*
* @return the created style.
*/
public static Style createLineStyle() {
final Stroke stroke = styleFactory.createStroke(filterFactory.literal(Color.BLUE), filterFactory.literal(1));
/*
* Setting the geometryPropertyName arg to null signals that we want to draw the default geomettry of features
*/
final LineSymbolizer sym = styleFactory.createLineSymbolizer(stroke, null);
final Rule rule = styleFactory.createRule();
rule.symbolizers().add(sym);
final FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(new Rule[] { rule });
final Style style = styleFactory.createStyle();
style.featureTypeStyles().add(fts);
return style;
}
开发者ID:gama-platform,项目名称:gama,代码行数:22,代码来源:Utils.java
示例17: getStyle
import org.geotools.styling.Style; //导入依赖的package包/类
/**
* Retrieves the style object from the style blackboard.
*
* @return Style
*/
protected Style getStyle() {
assert featureCollection != null;
Style style = this.style;
if (style == null) {
final SimpleFeatureType schema = featureCollection.getSchema();
if (SLDs.isLine(schema)) {
style = SLD.createLineStyle(Color.red, 1);
} else if (SLDs.isPoint(schema)) {
style = SLD.createPointStyle("Circle", Color.red, Color.green, 1f, 3f);
} else if (SLDs.isPolygon(schema)) {
style = SLD.createPolygonStyle(Color.red, Color.green, 1f);
}
}
this.style = style;
return style;
}
开发者ID:gama-platform,项目名称:gama,代码行数:22,代码来源:AbstractSimpleConfigurator.java
示例18: getRasterSymbolizerRule
import org.geotools.styling.Style; //导入依赖的package包/类
/**
* Find the first rule which contains a rastersymbolizer, and return it
*
* @param s
* A style to search in
* @return a rule, or null if no raster symbolizers are found.
*/
public static Rule getRasterSymbolizerRule(final Style s) {
final List<FeatureTypeStyle> fts = s.featureTypeStyles();
for (int i = 0; i < fts.size(); i++) {
final FeatureTypeStyle featureTypeStyle = fts.get(i);
final List<Rule> rules = featureTypeStyle.rules();
for (int j = 0; j < rules.size(); j++) {
final Rule rule = rules.get(j);
final Symbolizer[] symbolizers = rule.getSymbolizers();
for (int k = 0; k < symbolizers.length; k++) {
final Symbolizer symbolizer = symbolizers[k];
if (symbolizer instanceof RasterSymbolizer) {
return rule;
}
}
}
}
return null;
}
开发者ID:gama-platform,项目名称:gama,代码行数:27,代码来源:SLDs.java
示例19: run
import org.geotools.styling.Style; //导入依赖的package包/类
@Override
public void run() {
final Display display = WorkbenchHelper.getDisplay();
final Shell shell = new Shell(display);
final File openFile = JFileImageChooser.showOpenFile(shell);
if (openFile != null && openFile.exists()) {
final AbstractGridFormat format = GridFormatFinder.findFormat(openFile);
final AbstractGridCoverage2DReader tiffReader = format.getReader(openFile);
final StyleFactoryImpl sf = new StyleFactoryImpl();
final RasterSymbolizer symbolizer = sf.getDefaultRasterSymbolizer();
final Style defaultStyle = SLD.wrapSymbolizers(symbolizer);
final MapContent mapContent = mapPane.getMapContent();
final Layer layer = new GridReaderLayer(tiffReader, defaultStyle);
layer.setTitle(openFile.getName());
mapContent.addLayer(layer);
mapPane.redraw();
}
}
开发者ID:gama-platform,项目名称:gama,代码行数:21,代码来源:OpenGeotiffAction.java
示例20: run
import org.geotools.styling.Style; //导入依赖的package包/类
@Override
public void run() {
final Display display = WorkbenchHelper.getDisplay();
final Shell shell = new Shell(display);
final File openFile = JFileDataStoreChooser.showOpenFile(new String[] { "*.shp" }, shell); //$NON-NLS-1$
try {
if (openFile != null && openFile.exists()) {
final MapContent mapContent = mapPane.getMapContent();
final FileDataStore store = FileDataStoreFinder.getDataStore(openFile);
final SimpleFeatureSource featureSource = store.getFeatureSource();
final Style style = Utils.createStyle(openFile, featureSource);
final FeatureLayer featureLayer = new FeatureLayer(featureSource, style);
mapContent.addLayer(featureLayer);
mapPane.redraw();
}
} catch (final IOException e) {
e.printStackTrace();
}
}
开发者ID:gama-platform,项目名称:gama,代码行数:21,代码来源:OpenShapefileAction.java
注:本文中的org.geotools.styling.Style类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论