本文整理汇总了Java中org.geotools.styling.Style类的典型用法代码示例。如果您正苦于以下问题:Java Style类的具体用法?Java Style怎么用?Java Style使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Style类属于org.geotools.styling包,在下文中一共展示了Style类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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());
}
}
}
示例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();
}
}
}
示例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;
}
示例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);
}
}
}
}
示例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;
}
示例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 );
}
示例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;
}
示例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();
}
}
}
示例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);
}
示例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;
}