for (Layer<?> layer : mapModel.getLayers()) {
if (layer.isShowing()) {
// Go over every truly visible layer:
if (layer instanceof VectorLayer) {
VectorLayer vLayer = (VectorLayer) layer;
// For vector layer; loop over the style definitions:
for (FeatureStyleInfo styleInfo : vLayer.getLayerInfo().getNamedStyleInfo().getFeatureStyles()) {
ShapeStyle style = new ShapeStyle(styleInfo);
graphics.drawSymbolDefinition(null, styleInfo.getStyleId(), styleInfo.getSymbol(),
new ShapeStyle(styleInfo), null);
lineCount++;
if (vLayer.getLayerInfo().getLayerType() == LayerType.LINESTRING
|| vLayer.getLayerInfo().getLayerType() == LayerType.MULTILINESTRING) {
// Lines, draw a LineString;
Coordinate[] coordinates = new Coordinate[4];
coordinates[0] = new Coordinate(10, y);
coordinates[1] = new Coordinate(10 + 10, y + 5);
coordinates[2] = new Coordinate(10 + 5, y + 10);
coordinates[3] = new Coordinate(10 + 15, y + 15);
LineString line = mapModel.getGeometryFactory().createLineString(coordinates);
graphics.drawLine(parentGroup, "style" + lineCount, line, style);
} else if (vLayer.getLayerInfo().getLayerType() == LayerType.POLYGON
|| vLayer.getLayerInfo().getLayerType() == LayerType.MULTIPOLYGON) {
// Polygons: draw a rectangle:
Bbox rect = new Bbox(10, y, 16, 16);
graphics.drawRectangle(parentGroup, "style" + lineCount, rect, style);
} else if (vLayer.getLayerInfo().getLayerType() == LayerType.POINT
|| vLayer.getLayerInfo().getLayerType() == LayerType.MULTIPOINT) {
// Points: draw a symbol:
graphics.drawSymbol(parentGroup, "style" + lineCount, new Coordinate(18, y + 8), style,
styleInfo.getStyleId());
}