use of ol.color.Color in project gwt-ol3 by TDesjardins.
the class ClusterExample method show.
/* (non-Javadoc)
* @see de.desjardins.ol3.demo.client.example.Example#show() */
@Override
public void show(String exampleId) {
Collection<Feature> features = new Collection<Feature>();
int e = 450000;
for (int i = 0; i < 20000; ++i) {
// create a point
Coordinate coordinate = new Coordinate(2 * e * Math.random() - e, 2 * e * Math.random() - e);
Point point = new Point(coordinate);
// create feature
FeatureOptions featureOptions = new FeatureOptions();
featureOptions.setGeometry(point);
Feature feature = new Feature(featureOptions);
features.push(feature);
}
// create source
VectorOptions vectorSourceOptions = new VectorOptions();
vectorSourceOptions.setFeatures(features);
Vector vectorSource = new Vector(vectorSourceOptions);
// create clustering
ClusterOptions clusterOptions = new ClusterOptions();
clusterOptions.setDistance(40);
clusterOptions.setSource(vectorSource);
Cluster clusterSource = new Cluster(clusterOptions);
// create vector layer
VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
vectorLayerOptions.setSource(clusterSource);
vectorLayerOptions.setStyle(new GenericFunction<Feature, Style[]>() {
@Override
public Style[] call(Feature cluster) {
// create style
List<Style> style = new ArrayList<>();
Feature[] features = (Feature[]) cluster.get("features");
int clusterSize = features.length;
StyleOptions styleOptions = new StyleOptions();
TextOptions textOptions = new TextOptions();
textOptions.setText(String.valueOf(clusterSize));
styleOptions.setText(new Text(textOptions));
CircleOptions circleOptions = new CircleOptions();
circleOptions.setRadius(10);
Color color = Color.getColorFromString("#3399CC");
circleOptions.setFill(OLFactory.createFill(color));
styleOptions.setImage(new Circle(circleOptions));
style.add(new Style(styleOptions));
return style.toArray(new Style[0]);
}
});
ol.layer.Vector vectorLayer = new ol.layer.Vector(vectorLayerOptions);
// create a OSM-layer
XyzOptions osmSourceOptions = new XyzOptions();
Osm osmSource = new Osm(osmSourceOptions);
LayerOptions osmLayerOptions = new LayerOptions();
osmLayerOptions.setSource(osmSource);
Tile osmLayer = new Tile(osmLayerOptions);
// create a view
View view = new View();
Coordinate centerCoordinate = new Coordinate(0, 0);
view.setCenter(centerCoordinate);
view.setZoom(2);
// create the map
MapOptions mapOptions = new MapOptions();
mapOptions.setTarget(exampleId);
mapOptions.setView(view);
Collection<Base> lstLayer = new Collection<Base>();
lstLayer.push(osmLayer);
lstLayer.push(vectorLayer);
mapOptions.setLayers(lstLayer);
Map map = new Map(mapOptions);
// add some controls
map.addControl(new ScaleLine());
DemoUtils.addDefaultControls(map.getControls());
// add some interactions
map.addInteraction(new KeyboardPan());
map.addInteraction(new KeyboardZoom());
map.addControl(new Rotate());
}
use of ol.color.Color in project gwt-ol3 by TDesjardins.
the class FillTest method testFill.
public void testFill() {
injectUrlAndTest(() -> {
FillOptions fillOptions = new FillOptions();
fillOptions.setColor(new Color(0, 0, 0, 1));
Fill fill = new Fill(fillOptions);
assertNotNull(fill);
assertNotNull(fill.getColor());
});
}
use of ol.color.Color in project gwt-ol3 by TDesjardins.
the class StrokeTest method testStroke.
public void testStroke() {
injectUrlAndTest(() -> {
Stroke stroke = new Stroke();
assertNotNull(stroke);
StrokeOptions strokeOptions = new StrokeOptions();
strokeOptions.setColor(new Color(0, 0, 0, 1));
Stroke stroke2 = new Stroke(strokeOptions);
assertNotNull(stroke2);
assertNotNull(stroke2.getColor());
});
}
Aggregations