Java Examples for org.geotools.brewer.color.StyleGenerator
The following java examples will help you to understand the usage of org.geotools.brewer.color.StyleGenerator. These source code samples are taken from different open source projects.
Example 1
| Project: geotools_trunk-master File: BrewerExamples.java View source code |
void colorBrewerExample(SimpleFeatureCollection featureCollection) {
// colorBrewerExample start
// STEP 0 Set up Color Brewer
ColorBrewer brewer = ColorBrewer.instance();
// STEP 1 - call a classifier function to summarise your content
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
PropertyName propteryExpression = ff.property("height");
// classify into five categories
Function classify = ff.function("Quantile", propteryExpression, ff.literal(5));
Classifier groups = (Classifier) classify.evaluate(featureCollection);
// STEP 2 - look up a predefined palette from color brewer
String paletteName = "GrBu";
Color[] colors = brewer.getPalette(paletteName).getColors(5);
// STEP 3 - ask StyleGenerator to make a set of rules for the Classifier
// assigning features the correct color based on height
FeatureTypeStyle style = StyleGenerator.createFeatureTypeStyle(groups, propteryExpression, colors, "Generated FeatureTypeStyle for GreeBlue", featureCollection.getSchema().getGeometryDescriptor(), StyleGenerator.ELSEMODE_IGNORE, 0.95, null);
// colorBrewerExample end
}Example 2
| Project: geotools-master File: BrewerExamples.java View source code |
void colorBrewerExample(SimpleFeatureCollection featureCollection) {
// colorBrewerExample start
// STEP 0 Set up Color Brewer
ColorBrewer brewer = ColorBrewer.instance();
// STEP 1 - call a classifier function to summarise your content
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
PropertyName propteryExpression = ff.property("height");
// classify into five categories
Function classify = ff.function("Quantile", propteryExpression, ff.literal(5));
Classifier groups = (Classifier) classify.evaluate(featureCollection);
// STEP 2 - look up a predefined palette from color brewer
String paletteName = "GrBu";
Color[] colors = brewer.getPalette(paletteName).getColors(5);
// STEP 3 - ask StyleGenerator to make a set of rules for the Classifier
// assigning features the correct color based on height
FeatureTypeStyle style = StyleGenerator.createFeatureTypeStyle(groups, propteryExpression, colors, "Generated FeatureTypeStyle for GreeBlue", featureCollection.getSchema().getGeometryDescriptor(), StyleGenerator.ELSEMODE_IGNORE, 0.95, null);
// colorBrewerExample end
}Example 3
| Project: geotools-old-master File: BrewerExamples.java View source code |
void colorBrewerExample(SimpleFeatureCollection featureCollection) {
// colorBrewerExample start
// STEP 0 Set up Color Brewer
ColorBrewer brewer = ColorBrewer.instance();
// STEP 1 - call a classifier function to summarise your content
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
PropertyName propteryExpression = ff.property("height");
// classify into five categories
Function classify = ff.function("Quantile", propteryExpression, ff.literal(5));
Classifier groups = (Classifier) classify.evaluate(featureCollection);
// STEP 2 - look up a predefined palette from color brewer
String paletteName = "GrBu";
Color[] colors = brewer.getPalette(paletteName).getColors(5);
// STEP 3 - ask StyleGenerator to make a set of rules for the Classifier
// assigning features the correct color based on height
FeatureTypeStyle style = StyleGenerator.createFeatureTypeStyle(groups, propteryExpression, colors, "Generated FeatureTypeStyle for GreeBlue", featureCollection.getSchema().getGeometryDescriptor(), StyleGenerator.ELSEMODE_IGNORE, 0.95, null);
// colorBrewerExample end
}Example 4
| Project: geotools-cookbook-master File: BrewerExamples.java View source code |
void colorBrewerExample(SimpleFeatureCollection featureCollection) {
// colorBrewerExample start
// STEP 0 Set up Color Brewer
ColorBrewer brewer = ColorBrewer.instance();
// STEP 1 - call a classifier function to summarise your content
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
PropertyName propteryExpression = ff.property("height");
// classify into five categories
Function classify = ff.function("Quantile", propteryExpression, ff.literal(5));
Classifier groups = (Classifier) classify.evaluate(featureCollection);
// STEP 2 - look up a predefined palette from color brewer
String paletteName = "GrBu";
Color[] colors = brewer.getPalette(paletteName).getColors(5);
// STEP 3 - ask StyleGenerator to make a set of rules for the Classifier
// assigning features the correct color based on height
FeatureTypeStyle style = StyleGenerator.createFeatureTypeStyle(groups, propteryExpression, colors, "Generated FeatureTypeStyle for GreeBlue", featureCollection.getSchema().getGeometryDescriptor(), StyleGenerator.ELSEMODE_IGNORE, 0.95, null);
// colorBrewerExample end
}