Skip to content

Commit 416f5a6

Browse files
arnaudboudier-sogelinklanseg
authored andcommitted
Paging: Add an option to add an overview layer to the main map that displays the position of the pages (#3618)
* Feature : paging add an option to add an overview layer to the main map that displays the position of the pages on the main map
1 parent 3473e43 commit 416f5a6

File tree

27 files changed

+580
-74
lines changed

27 files changed

+580
-74
lines changed

core/src/main/java/org/mapfish/print/Constants.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,15 @@ private OverviewMap() {
9494
/** The default style name for the bbox rectangle in the overview map. */
9595
public static final String NAME = "overview-map";
9696
}
97+
98+
public static final class PagingOverviewLayer {
99+
100+
private PagingOverviewLayer() {
101+
// not called
102+
}
103+
104+
/** The default style name for the bbox rectangle in the overview map. */
105+
public static final String NAME = "paging-overview-layer";
106+
}
97107
}
98108
}

core/src/main/java/org/mapfish/print/attribute/map/MapAttribute.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ public class MapAttributeValues extends GenericMapAttributeValues {
8787

8888
private MapBounds mapBounds;
8989

90+
/** Paging overview layer that displays the position of the pages on the main map. */
91+
private MapLayer pagingOverviewLayer;
92+
9093
/**
9194
* Constructor.
9295
*
@@ -122,6 +125,14 @@ public void setRawLayers(final PArray newLayers) {
122125
this.layers = newLayers;
123126
}
124127

128+
public void setPagingOverviewLayer(final MapLayer newPagingOverviewLayer) {
129+
this.pagingOverviewLayer = newPagingOverviewLayer;
130+
}
131+
132+
public MapLayer getPagingOverviewLayer() {
133+
return this.pagingOverviewLayer;
134+
}
135+
125136
@Override
126137
public final void postConstruct() throws FactoryException {
127138
super.postConstruct();

core/src/main/java/org/mapfish/print/attribute/map/PagingAttribute.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Attribute that defines how a map is displayed across many pages.
1111
*
1212
* <p>This is used by the <a href="processors.html#!paging">paging processor</a>.
13-
* [[examples=paging]]
13+
* [[examples=paging,paging_with_overview_layer]]
1414
*/
1515
public final class PagingAttribute
1616
extends ReflectiveAttribute<PagingAttribute.PagingProcessorValues> {
@@ -64,5 +64,16 @@ public static class PagingProcessorValues {
6464
* definition.
6565
*/
6666
@HasDefaultValue public String aoiStyle = null;
67+
68+
/**
69+
* If set to true will add an overview layer to the main map with all the pages and their label.
70+
*/
71+
@HasDefaultValue public Boolean renderPagingOverview = false;
72+
73+
/**
74+
* The style of the paging overview layer. This parameter is usefull only if
75+
* renderPagingOverview is true.
76+
*/
77+
@HasDefaultValue public String pagingOverviewStyle = null;
6778
}
6879
}

core/src/main/java/org/mapfish/print/config/Configuration.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@
1515
import javax.annotation.Nonnull;
1616
import javax.annotation.Nullable;
1717
import javax.annotation.PostConstruct;
18+
import org.geotools.api.filter.expression.Expression;
19+
import org.geotools.api.style.FeatureTypeStyle;
1820
import org.geotools.api.style.Fill;
21+
import org.geotools.api.style.Font;
1922
import org.geotools.api.style.Graphic;
23+
import org.geotools.api.style.Halo;
24+
import org.geotools.api.style.LineSymbolizer;
2025
import org.geotools.api.style.Mark;
2126
import org.geotools.api.style.Stroke;
2227
import org.geotools.api.style.Style;
2328
import org.geotools.api.style.Symbolizer;
29+
import org.geotools.api.style.TextSymbolizer;
2430
import org.geotools.styling.StyleBuilder;
2531
import org.json.JSONException;
2632
import org.json.JSONWriter;
@@ -43,6 +49,7 @@
4349
import org.mapfish.print.map.style.json.ColorParser;
4450
import org.mapfish.print.processor.http.matcher.URIMatcher;
4551
import org.mapfish.print.processor.http.matcher.UriMatchers;
52+
import org.mapfish.print.processor.map.CreateMapPagesProcessor;
4653
import org.mapfish.print.servlet.fileloader.ConfigFileLoaderManager;
4754
import org.slf4j.Logger;
4855
import org.slf4j.LoggerFactory;
@@ -372,6 +379,8 @@ public final Style getDefaultStyle(@Nonnull final String geometryType) {
372379
symbolizer = builder.createRasterSymbolizer();
373380
} else if (normalizedGeomName.startsWith(Constants.Style.OverviewMap.NAME)) {
374381
symbolizer = createMapOverviewStyle(normalizedGeomName, builder);
382+
} else if (normalizedGeomName.startsWith(Constants.Style.PagingOverviewLayer.NAME)) {
383+
return createOverviewPagingLayerStyle(builder);
375384
} else {
376385
final Style geomStyle = this.defaultStyle.get(Geometry.class.getSimpleName().toLowerCase());
377386
if (geomStyle != null) {
@@ -424,6 +433,28 @@ private Symbolizer createMapOverviewStyle(
424433
return builder.createPolygonSymbolizer(stroke, fill);
425434
}
426435

436+
private Style createOverviewPagingLayerStyle(@Nonnull final StyleBuilder builder) {
437+
Stroke stroke = builder.createStroke(Color.gray, 1.5);
438+
LineSymbolizer polygonSymbolizer = builder.createLineSymbolizer(stroke);
439+
440+
Font[] fonts = new Font[] {builder.createFont("Lucida Sans", 10.0D)};
441+
Halo halo = builder.createHalo(Color.white, 1);
442+
Expression name =
443+
builder.attributeExpression(CreateMapPagesProcessor.OVERVIEW_PAGING_ATTRIBUT_TEXT);
444+
Fill fillColor = builder.createFill(Color.black);
445+
TextSymbolizer textSymbolizer =
446+
builder.createTextSymbolizer(fillColor, fonts, halo, name, null, null);
447+
448+
FeatureTypeStyle features =
449+
builder.createFeatureTypeStyle(
450+
CreateMapPagesProcessor.OVERVIEW_PAGING_FEATURE_NAME,
451+
new Symbolizer[] {polygonSymbolizer, textSymbolizer});
452+
453+
Style s = builder.createStyle();
454+
s.featureTypeStyles().add(features);
455+
return s;
456+
}
457+
427458
/**
428459
* Set the default styles. the case of the keys are not important. The retrieval will be case
429460
* insensitive.

0 commit comments

Comments
 (0)