Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
c86477a7
by Tony Chemit at 2023-11-22T15:37:45+01:00
-
d72c14b2
by Tony Chemit at 2023-11-22T17:45:06+01:00
8 changed files:
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/TripUIHelper.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/map/ObserveMapPane.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/map/ObserveMapPaneLegendItem.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/map/TripMapContentBuilderSupport.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/map/TripMapUIHandler.java
- client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/common/TripMapContentBuilder.java
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/common/TripMapContentBuilder.java
- core/api/dto/src/main/java/fr/ird/observe/dto/data/TripMapContentBuilder.java
Changes:
| ... | ... | @@ -25,6 +25,7 @@ package fr.ird.observe.client.datasource.editor.api.content.data; |
| 25 | 25 | import fr.ird.observe.client.WithClientUIContextApi;
|
| 26 | 26 | import fr.ird.observe.client.configuration.ClientConfig;
|
| 27 | 27 | import fr.ird.observe.client.datasource.editor.api.content.data.list.ContentListUIHandler;
|
| 28 | +import fr.ird.observe.client.datasource.editor.api.content.data.map.ObserveMapPane;
|
|
| 28 | 29 | import fr.ird.observe.client.datasource.editor.api.content.data.map.TripMapUI;
|
| 29 | 30 | import fr.ird.observe.client.datasource.editor.api.content.data.ropen.ContentRootOpenableUI;
|
| 30 | 31 | import fr.ird.observe.dto.data.RootOpenableDto;
|
| ... | ... | @@ -88,7 +89,7 @@ public abstract class TripUIHelper<D extends RootOpenableDto, U extends ContentR |
| 88 | 89 | updateMapModel();
|
| 89 | 90 | }
|
| 90 | 91 | });
|
| 91 | - |
|
| 92 | + tripMap.getObserveMapPane().addPropertyChangeListener(ObserveMapPane.PROPERTY_REBUILD_MODEL, e -> rebuildTripMap());
|
|
| 92 | 93 | ui.getMainTabbedPane().addChangeListener(this::onTabChanged);
|
| 93 | 94 | // Disable map tab because can't manage it :(
|
| 94 | 95 | ui.getMainTabbedPane().setEnabledAt(ui.getMainTabbedPane().getTabCount() - 1, false);
|
| ... | ... | @@ -121,8 +122,34 @@ public abstract class TripUIHelper<D extends RootOpenableDto, U extends ContentR |
| 121 | 122 | TripMapUI tripMap = ui.getTripMap();
|
| 122 | 123 | TripMapConfigDto tripMapConfig = tripMap.getTripMapConfig();
|
| 123 | 124 | log.info(prefix + String.format("Ask to build map: show observation? %s, show logbook? %s", tripMapConfig.isAddObservations(), tripMapConfig.isAddLogbook()));
|
| 124 | - TripMapDto tripLonglineMap = getMap(tripMapConfig);
|
|
| 125 | - tripMap.getHandler().doOpenMap(tripMapConfig, tripLonglineMap);
|
|
| 125 | + TripMapDto tripMapDto = getMap(tripMapConfig);
|
|
| 126 | + Set<String> excludedFeatureNames = tripMap.getObserveMapPane().getExcludedFeatureNames();
|
|
| 127 | + tripMap.getHandler().doOpenMap(tripMapConfig, tripMapDto, excludedFeatureNames);
|
|
| 128 | + } finally {
|
|
| 129 | + getBusyModel().popTask();
|
|
| 130 | + }
|
|
| 131 | + });
|
|
| 132 | + }
|
|
| 133 | + |
|
| 134 | + private void rebuildTripMap() {
|
|
| 135 | + if (ui.getModel().getStates().isCreatingMode()) {
|
|
| 136 | + return;
|
|
| 137 | + }
|
|
| 138 | + if (opening) {
|
|
| 139 | + return;
|
|
| 140 | + }
|
|
| 141 | + if (!ui.getModel().getStates().isOpened()) {
|
|
| 142 | + return;
|
|
| 143 | + }
|
|
| 144 | + |
|
| 145 | + SwingUtilities.invokeLater(() -> {
|
|
| 146 | + getBusyModel().addTask("Rebuild map");
|
|
| 147 | + try {
|
|
| 148 | + TripMapUI tripMap = ui.getTripMap();
|
|
| 149 | + TripMapConfigDto tripMapConfig = tripMap.getTripMapConfig();
|
|
| 150 | + TripMapDto tripMapDto = tripMap.getObserveMapPane().getTripMapDto();
|
|
| 151 | + Set<String> excludedFeatureNames = tripMap.getObserveMapPane().getExcludedFeatureNames();
|
|
| 152 | + tripMap.getHandler().doOpenMap(tripMapConfig, tripMapDto, excludedFeatureNames);
|
|
| 126 | 153 | } finally {
|
| 127 | 154 | getBusyModel().popTask();
|
| 128 | 155 | }
|
| ... | ... | @@ -22,6 +22,8 @@ package fr.ird.observe.client.datasource.editor.api.content.data.map; |
| 22 | 22 | * #L%
|
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | +import fr.ird.observe.client.util.UIHelper;
|
|
| 26 | +import fr.ird.observe.dto.data.TripMapDto;
|
|
| 25 | 27 | import org.apache.logging.log4j.LogManager;
|
| 26 | 28 | import org.apache.logging.log4j.Logger;
|
| 27 | 29 | import org.geotools.geometry.jts.ReferencedEnvelope;
|
| ... | ... | @@ -33,18 +35,25 @@ import org.geotools.swing.JMapPane; |
| 33 | 35 | import org.geotools.swing.event.MapPaneAdapter;
|
| 34 | 36 | import org.geotools.swing.event.MapPaneEvent;
|
| 35 | 37 | |
| 38 | +import javax.swing.Icon;
|
|
| 36 | 39 | import java.awt.Color;
|
| 37 | 40 | import java.awt.Font;
|
| 38 | 41 | import java.awt.FontMetrics;
|
| 39 | 42 | import java.awt.Graphics;
|
| 40 | 43 | import java.awt.Point;
|
| 41 | 44 | import java.awt.Polygon;
|
| 45 | +import java.awt.Rectangle;
|
|
| 42 | 46 | import java.awt.geom.Point2D;
|
| 43 | 47 | import java.awt.geom.Rectangle2D;
|
| 44 | 48 | import java.awt.image.BufferedImage;
|
| 45 | 49 | import java.util.ArrayList;
|
| 50 | +import java.util.LinkedHashMap;
|
|
| 46 | 51 | import java.util.List;
|
| 52 | +import java.util.Map;
|
|
| 47 | 53 | import java.util.Objects;
|
| 54 | +import java.util.Optional;
|
|
| 55 | +import java.util.Set;
|
|
| 56 | +import java.util.stream.Collectors;
|
|
| 48 | 57 | |
| 49 | 58 | import static io.ultreia.java4all.i18n.I18n.n;
|
| 50 | 59 | import static io.ultreia.java4all.i18n.I18n.t;
|
| ... | ... | @@ -54,6 +63,7 @@ import static io.ultreia.java4all.i18n.I18n.t; |
| 54 | 63 | */
|
| 55 | 64 | public class ObserveMapPane extends JMapPane {
|
| 56 | 65 | public static final String PROPERTY_ADD_POINT_COUNT = "addPointCount";
|
| 66 | + public static final String PROPERTY_REBUILD_MODEL = "rebuildModel";
|
|
| 57 | 67 | protected static final int MARGIN = 10;
|
| 58 | 68 | protected static final int SCALE_HEIGHT = 15;
|
| 59 | 69 | protected static final int SCALE_WIDTH_MAX = 200;
|
| ... | ... | @@ -74,6 +84,18 @@ public class ObserveMapPane extends JMapPane { |
| 74 | 84 | private boolean showLegend = true;
|
| 75 | 85 | private LegendPosition legendPosition = LegendPosition.BOTTOM;
|
| 76 | 86 | private boolean addPointCount = true;
|
| 87 | + private final Icon notSelectedIcon = UIHelper.getUIManagerIcon("checkbox.empty");
|
|
| 88 | + private final Icon selectedIcon = UIHelper.getUIManagerIcon("checkbox.full");
|
|
| 89 | + private TripMapDto tripMapDto;
|
|
| 90 | + private final Map<ObserveMapPaneLegendItem, Rectangle> legendItemPositions = new LinkedHashMap<>();
|
|
| 91 | + |
|
| 92 | + public void setTripMapDto(TripMapDto tripMapDto) {
|
|
| 93 | + this.tripMapDto = tripMapDto;
|
|
| 94 | + }
|
|
| 95 | + |
|
| 96 | + public TripMapDto getTripMapDto() {
|
|
| 97 | + return tripMapDto;
|
|
| 98 | + }
|
|
| 77 | 99 | |
| 78 | 100 | public enum LegendPosition {
|
| 79 | 101 | TOP, BOTTOM
|
| ... | ... | @@ -93,6 +115,23 @@ public class ObserveMapPane extends JMapPane { |
| 93 | 115 | |
| 94 | 116 | }
|
| 95 | 117 | |
| 118 | + public Set<String> getExcludedFeatureNames() {
|
|
| 119 | + return legendItems.stream().filter(i -> !i.isSelected()).map(ObserveMapPaneLegendItem::getName).collect(Collectors.toSet());
|
|
| 120 | + }
|
|
| 121 | + |
|
| 122 | + public void fireRebuildModel() {
|
|
| 123 | + firePropertyChange(PROPERTY_REBUILD_MODEL, null, true);
|
|
| 124 | + }
|
|
| 125 | + |
|
| 126 | + public Optional<ObserveMapPaneLegendItem> getLegendItem(Point point) {
|
|
| 127 | + for (Map.Entry<ObserveMapPaneLegendItem, Rectangle> entry : legendItemPositions.entrySet()) {
|
|
| 128 | + if (entry.getValue().contains(point)) {
|
|
| 129 | + return Optional.of(entry.getKey());
|
|
| 130 | + }
|
|
| 131 | + }
|
|
| 132 | + return Optional.empty();
|
|
| 133 | + }
|
|
| 134 | + |
|
| 96 | 135 | public long getScaleInMiles() {
|
| 97 | 136 | return scaleInMiles;
|
| 98 | 137 | }
|
| ... | ... | @@ -128,13 +167,13 @@ public class ObserveMapPane extends JMapPane { |
| 128 | 167 | }
|
| 129 | 168 | |
| 130 | 169 | public boolean isLegendPositionTop() {
|
| 131 | - return getLegendPosition()==LegendPosition.TOP;
|
|
| 170 | + return getLegendPosition() == LegendPosition.TOP;
|
|
| 132 | 171 | }
|
| 172 | + |
|
| 133 | 173 | public boolean isLegendPositionBottom() {
|
| 134 | - return getLegendPosition()==LegendPosition.BOTTOM;
|
|
| 174 | + return getLegendPosition() == LegendPosition.BOTTOM;
|
|
| 135 | 175 | }
|
| 136 | 176 | |
| 137 | - |
|
| 138 | 177 | public boolean isAddPointCount() {
|
| 139 | 178 | return addPointCount;
|
| 140 | 179 | }
|
| ... | ... | @@ -222,18 +261,18 @@ public class ObserveMapPane extends JMapPane { |
| 222 | 261 | |
| 223 | 262 | Point2D direction = cardinalPoint.getDirection(rotation, AXIS_LENGTH, center);
|
| 224 | 263 | |
| 225 | - Point2D sommet1 = cardinalPoint.getDirection(rotation - Math.PI / 4, SUB_AXIS_LENGTH, center);
|
|
| 264 | + Point2D top1 = cardinalPoint.getDirection(rotation - Math.PI / 4, SUB_AXIS_LENGTH, center);
|
|
| 226 | 265 | |
| 227 | - Point2D sommet2 = cardinalPoint.getDirection(rotation + Math.PI / 4, SUB_AXIS_LENGTH, center);
|
|
| 266 | + Point2D top2 = cardinalPoint.getDirection(rotation + Math.PI / 4, SUB_AXIS_LENGTH, center);
|
|
| 228 | 267 | |
| 229 | 268 | |
| 230 | 269 | Polygon polygon = new Polygon();
|
| 231 | 270 | polygon.addPoint((int) center.getX(), (int) center.getY());
|
| 232 | 271 | polygon.addPoint((int) direction.getX(), (int) direction.getY());
|
| 233 | - polygon.addPoint((int) sommet2.getX(), (int) sommet2.getY());
|
|
| 272 | + polygon.addPoint((int) top2.getX(), (int) top2.getY());
|
|
| 234 | 273 | graphics.fillPolygon(polygon);
|
| 235 | 274 | |
| 236 | - graphics.drawLine((int) sommet1.getX(), (int) sommet1.getY(), (int) direction.getX(), (int) direction.getY());
|
|
| 275 | + graphics.drawLine((int) top1.getX(), (int) top1.getY(), (int) direction.getX(), (int) direction.getY());
|
|
| 237 | 276 | |
| 238 | 277 | Rectangle2D textArea = fm.getStringBounds(cardinalPoint.getLabel(), graphics);
|
| 239 | 278 | |
| ... | ... | @@ -258,8 +297,10 @@ public class ObserveMapPane extends JMapPane { |
| 258 | 297 | this.legendItems = legendItems;
|
| 259 | 298 | }
|
| 260 | 299 | |
| 300 | + |
|
| 261 | 301 | protected void paintLegend(Graphics graphics) {
|
| 262 | 302 | |
| 303 | + legendItemPositions.clear();
|
|
| 263 | 304 | if (getLegendItems() != null && isShowLegend()) {
|
| 264 | 305 | |
| 265 | 306 | int x;
|
| ... | ... | @@ -291,25 +332,34 @@ public class ObserveMapPane extends JMapPane { |
| 291 | 332 | |
| 292 | 333 | int legendWidth = ObserveMapPaneLegendItem.LEGEND_SYMBOL_WIDTH + maxLabelWidth + ObserveMapPaneLegendItem.LEGEND_MARGIN * 2;
|
| 293 | 334 | |
| 294 | - graphics.setColor(ObserveMapPaneLegendItem.LEGEND_BACKGROUND);
|
|
| 295 | - graphics.fillRect(
|
|
| 296 | - x,
|
|
| 297 | - y,
|
|
| 298 | - legendWidth,
|
|
| 299 | - LEGEND_MARGIN);
|
|
| 335 | +// graphics.setColor(ObserveMapPaneLegendItem.LEGEND_BACKGROUND);
|
|
| 336 | +// graphics.fillRect(
|
|
| 337 | +// x,
|
|
| 338 | +// y,
|
|
| 339 | +// legendWidth,
|
|
| 340 | +// LEGEND_MARGIN);
|
|
| 300 | 341 | |
| 301 | 342 | y += LEGEND_MARGIN;
|
| 302 | 343 | |
| 303 | 344 | for (ObserveMapPaneLegendItem item : legendItems) {
|
| 304 | 345 | |
| 346 | + Rectangle itemPosition = new Rectangle(x, y, legendWidth, ObserveMapPaneLegendItem.LEGEND_ITEM_HEIGHT);
|
|
| 347 | + legendItemPositions.put(item, itemPosition);
|
|
| 348 | + |
|
| 349 | + |
|
| 350 | + int x2 = x + 22;
|
|
| 305 | 351 | graphics.setColor(ObserveMapPaneLegendItem.LEGEND_BACKGROUND);
|
| 306 | 352 | graphics.fillRect(
|
| 307 | 353 | x,
|
| 308 | 354 | y,
|
| 309 | - legendWidth,
|
|
| 355 | + legendWidth + 22,
|
|
| 310 | 356 | ObserveMapPaneLegendItem.LEGEND_ITEM_HEIGHT);
|
| 311 | - |
|
| 312 | - BufferedImage symbole = new BufferedImage(
|
|
| 357 | + if (item.isSelected()) {
|
|
| 358 | + selectedIcon.paintIcon(this, graphics, x, y);
|
|
| 359 | + } else {
|
|
| 360 | + notSelectedIcon.paintIcon(this, graphics, x, y);
|
|
| 361 | + }
|
|
| 362 | + BufferedImage symbol = new BufferedImage(
|
|
| 313 | 363 | ObserveMapPaneLegendItem.LEGEND_SYMBOL_WIDTH,
|
| 314 | 364 | ObserveMapPaneLegendItem.LEGEND_ITEM_HEIGHT,
|
| 315 | 365 | BufferedImage.TYPE_INT_ARGB);
|
| ... | ... | @@ -322,32 +372,33 @@ public class ObserveMapPane extends JMapPane { |
| 322 | 372 | |
| 323 | 373 | if (rule.getFilter().evaluate(item.getSimpleFeature())) {
|
| 324 | 374 | |
| 325 | - drawer.drawDirect(symbole, item.getSimpleFeature(), rule);
|
|
| 375 | + drawer.drawDirect(symbol, item.getSimpleFeature(), rule);
|
|
| 326 | 376 | |
| 327 | 377 | }
|
| 328 | 378 | }
|
| 329 | 379 | }
|
| 330 | 380 | |
| 331 | - graphics.drawImage(symbole, x + LEGEND_MARGIN, y, null);
|
|
| 381 | + graphics.drawImage(symbol, x2 + LEGEND_MARGIN, y, null);
|
|
| 332 | 382 | |
| 333 | - graphics.setColor(Color.BLACK);
|
|
| 383 | + Color textColor = item.isSelected() ? Color.BLACK : ObserveMapPaneLegendItem.LEGEND_TEXT_NOT_SELECTED;
|
|
| 384 | + graphics.setColor(textColor);
|
|
| 334 | 385 | |
| 335 | 386 | int labelMarginBottom = ((ObserveMapPaneLegendItem.LEGEND_ITEM_HEIGHT - fm.getHeight()) / 2) + fm.getDescent();
|
| 336 | 387 | |
| 337 | 388 | graphics.drawString(item.getLabel(addPointCount),
|
| 338 | - x + LEGEND_MARGIN + ObserveMapPaneLegendItem.LEGEND_SYMBOL_WIDTH,
|
|
| 389 | + x2 + LEGEND_MARGIN + ObserveMapPaneLegendItem.LEGEND_SYMBOL_WIDTH,
|
|
| 339 | 390 | y + ObserveMapPaneLegendItem.LEGEND_ITEM_HEIGHT - labelMarginBottom);
|
| 340 | 391 | |
| 341 | 392 | y += ObserveMapPaneLegendItem.LEGEND_ITEM_HEIGHT;
|
| 342 | 393 | |
| 343 | 394 | }
|
| 344 | 395 | |
| 345 | - graphics.setColor(ObserveMapPaneLegendItem.LEGEND_BACKGROUND);
|
|
| 346 | - graphics.fillRect(
|
|
| 347 | - x,
|
|
| 348 | - y,
|
|
| 349 | - legendWidth,
|
|
| 350 | - LEGEND_MARGIN);
|
|
| 396 | +// graphics.setColor(ObserveMapPaneLegendItem.LEGEND_BACKGROUND);
|
|
| 397 | +// graphics.fillRect(
|
|
| 398 | +// x,
|
|
| 399 | +// y,
|
|
| 400 | +// legendWidth+22,
|
|
| 401 | +// LEGEND_MARGIN);
|
|
| 351 | 402 | |
| 352 | 403 | }
|
| 353 | 404 |
| ... | ... | @@ -38,18 +38,23 @@ public class ObserveMapPaneLegendItem { |
| 38 | 38 | protected static final int LEGEND_SYMBOL_WIDTH = 50;
|
| 39 | 39 | protected static final int LEGEND_MARGIN = 5;
|
| 40 | 40 | protected static final Color LEGEND_BACKGROUND = new Color(1f, 1f, 1f, 0.8f);
|
| 41 | + protected static final Color LEGEND_TEXT_NOT_SELECTED = Color.RED;
|
|
| 41 | 42 | protected final SimpleFeature simpleFeature;
|
| 42 | 43 | protected final Style style;
|
| 43 | 44 | protected final String label;
|
| 44 | 45 | protected final int notValidCount;
|
| 45 | 46 | protected final int validCount;
|
| 47 | + protected final String name;
|
|
| 48 | + protected boolean selected;
|
|
| 46 | 49 | |
| 47 | - public ObserveMapPaneLegendItem(SimpleFeature simpleFeature, Style style, String label, int notValidCount, int validCount) {
|
|
| 50 | + public ObserveMapPaneLegendItem(String name, SimpleFeature simpleFeature, Style style, String label, int notValidCount, int validCount, boolean selected) {
|
|
| 51 | + this.name = name;
|
|
| 48 | 52 | this.simpleFeature = simpleFeature;
|
| 49 | 53 | this.style = style;
|
| 50 | 54 | this.label = label;
|
| 51 | 55 | this.notValidCount = notValidCount;
|
| 52 | 56 | this.validCount = validCount;
|
| 57 | + this.selected = selected;
|
|
| 53 | 58 | }
|
| 54 | 59 | |
| 55 | 60 | public static Coordinate[] lineCoordinates() {
|
| ... | ... | @@ -63,6 +68,10 @@ public class ObserveMapPaneLegendItem { |
| 63 | 68 | return new Coordinate(LEGEND_SYMBOL_WIDTH / 2., LEGEND_ITEM_HEIGHT / 2.);
|
| 64 | 69 | }
|
| 65 | 70 | |
| 71 | + public String getName() {
|
|
| 72 | + return name;
|
|
| 73 | + }
|
|
| 74 | + |
|
| 66 | 75 | public SimpleFeature getSimpleFeature() {
|
| 67 | 76 | return simpleFeature;
|
| 68 | 77 | }
|
| ... | ... | @@ -90,4 +99,12 @@ public class ObserveMapPaneLegendItem { |
| 90 | 99 | }
|
| 91 | 100 | return label;
|
| 92 | 101 | }
|
| 102 | + |
|
| 103 | + public boolean isSelected() {
|
|
| 104 | + return selected;
|
|
| 105 | + }
|
|
| 106 | + |
|
| 107 | + public void setSelected(boolean selected) {
|
|
| 108 | + this.selected = selected;
|
|
| 109 | + }
|
|
| 93 | 110 | } |
| ... | ... | @@ -108,7 +108,7 @@ public abstract class TripMapContentBuilderSupport implements TripMapContentBuil |
| 108 | 108 | protected StyledLayerDescriptor styledLayerDescriptor;
|
| 109 | 109 | private GeometryFactory geometryFactory;
|
| 110 | 110 | |
| 111 | - public static TripMapContentBuilderSupport of(TripMapConfig config, TripMapConfigDto tripMapConfig, TripMapDto tripMapDto, List<TripMapPoint> tripMapPoints) throws Exception {
|
|
| 111 | + public static TripMapContentBuilderSupport of(TripMapConfig config, TripMapConfigDto tripMapConfig, TripMapDto tripMapDto, List<TripMapPoint> tripMapPoints, Set<String> excludedFeatureNames) throws Exception {
|
|
| 112 | 112 | TripMapContentBuilderSupport builder = (TripMapContentBuilderSupport) config.getTripMapContentBuilders().stream().filter(t -> t.accept(tripMapDto)).findFirst().orElseThrow(IllegalStateException::new);
|
| 113 | 113 | builder.reset();
|
| 114 | 114 | String mapDateFormat = config.getMapDateFormat();
|
| ... | ... | @@ -134,8 +134,8 @@ public abstract class TripMapContentBuilderSupport implements TripMapContentBuil |
| 134 | 134 | for (File layerFile : config.getMapLayerFiles()) {
|
| 135 | 135 | builder.addLayer(layerFile);
|
| 136 | 136 | }
|
| 137 | - builder.addLines(tripMapConfig, tripMapPoints);
|
|
| 138 | - builder.addPoints(tripMapConfig, tripMapPoints);
|
|
| 137 | + builder.addLines(tripMapConfig, tripMapPoints, excludedFeatureNames);
|
|
| 138 | + builder.addPoints(tripMapConfig, tripMapPoints, excludedFeatureNames);
|
|
| 139 | 139 | return builder;
|
| 140 | 140 | }
|
| 141 | 141 | |
| ... | ... | @@ -242,22 +242,13 @@ public abstract class TripMapContentBuilderSupport implements TripMapContentBuil |
| 242 | 242 | mapContent.addLayer(layer);
|
| 243 | 243 | }
|
| 244 | 244 | |
| 245 | - protected void addPoint(DefaultFeatureCollection pointsFeatures, TripMapPoint tripMapPoint) {
|
|
| 246 | - Point point = getGeometryFactory().createPoint(create(tripMapPoint));
|
|
| 247 | - pointBuilder.add(point);
|
|
| 248 | - pointBuilder.add(formatDate(tripMapPoint.getTime()));
|
|
| 249 | - pointBuilder.add(tripMapPoint.getType().name());
|
|
| 250 | - pointsFeatures.add(pointBuilder.buildFeature(null));
|
|
| 251 | - validPoints.computeIfAbsent(tripMapPoint.getType(), e -> new LinkedList<>()).add(tripMapPoint);
|
|
| 252 | - }
|
|
| 253 | - |
|
| 254 | - public void addPoints(List<TripMapPoint> tripMapPoints, String layerName, String notValidPointsLabel) {
|
|
| 245 | + public void addPoints(List<TripMapPoint> tripMapPoints, String layerName, String notValidPointsLabel, Set<String> excludedFeatureNames) {
|
|
| 255 | 246 | DefaultFeatureCollection pointsFeatures = new DefaultFeatureCollection();
|
| 256 | 247 | Style stylePoints = findStyle(styledLayerDescriptor, layerName);
|
| 257 | 248 | |
| 258 | 249 | for (TripMapPoint tripMapPoint : tripMapPoints) {
|
| 259 | 250 | if (tripMapPoint.isValid()) {
|
| 260 | - addPoint(pointsFeatures, tripMapPoint);
|
|
| 251 | + addPoint(pointsFeatures, tripMapPoint, excludedFeatureNames);
|
|
| 261 | 252 | } else {
|
| 262 | 253 | notValidPoints.computeIfAbsent(tripMapPoint.getType(), e -> new LinkedList<>()).add(tripMapPoint);
|
| 263 | 254 | }
|
| ... | ... | @@ -281,15 +272,29 @@ public abstract class TripMapContentBuilderSupport implements TripMapContentBuil |
| 281 | 272 | if (notValidCount > 0) {
|
| 282 | 273 | notValidTypes.remove(type);
|
| 283 | 274 | }
|
| 284 | - addPointLegend(stylePoints, type.name(), label, notValidCount, validCount);
|
|
| 275 | + addPointLegend(stylePoints, type.name(), label, notValidCount, validCount, excludedFeatureNames);
|
|
| 285 | 276 | }
|
| 286 | 277 | if (!notValidTypes.isEmpty()) {
|
| 287 | 278 | for (TripMapPointType type : notValidTypes) {
|
| 288 | 279 | List<TripMapPoint> notValidPointsForType = notValidPoints.get(type);
|
| 289 | 280 | String label = I18n.t(notValidPointsLabel, notValidPointsForType.size()) + " - " + type.getLabel();
|
| 290 | - addPointLegend(stylePoints, "notValidPoint", label, 0, 0);
|
|
| 281 | + addPointLegend(stylePoints, "notValidPoint", label, 0, 0, excludedFeatureNames);
|
|
| 291 | 282 | }
|
| 292 | 283 | }
|
| 284 | + validPoints.clear();
|
|
| 285 | + notValidPoints.clear();
|
|
| 286 | + }
|
|
| 287 | + |
|
| 288 | + protected void addPoint(DefaultFeatureCollection pointsFeatures, TripMapPoint tripMapPoint, Set<String> excludedFeatureNames) {
|
|
| 289 | + if (!excludedFeatureNames.contains(tripMapPoint.getType().name())) {
|
|
| 290 | + // display this point
|
|
| 291 | + Point point = getGeometryFactory().createPoint(create(tripMapPoint));
|
|
| 292 | + pointBuilder.add(point);
|
|
| 293 | + pointBuilder.add(formatDate(tripMapPoint.getTime()));
|
|
| 294 | + pointBuilder.add(tripMapPoint.getType().name());
|
|
| 295 | + pointsFeatures.add(pointBuilder.buildFeature(null));
|
|
| 296 | + }
|
|
| 297 | + validPoints.computeIfAbsent(tripMapPoint.getType(), e -> new LinkedList<>()).add(tripMapPoint);
|
|
| 293 | 298 | }
|
| 294 | 299 | |
| 295 | 300 | protected GeometryFactory getGeometryFactory() {
|
| ... | ... | @@ -337,14 +342,20 @@ public abstract class TripMapContentBuilderSupport implements TripMapContentBuil |
| 337 | 342 | return DATE_FORMAT.format(date);
|
| 338 | 343 | }
|
| 339 | 344 | |
| 340 | - protected void addLine(DefaultFeatureCollection linesFeatures, String lineName, Coordinate[] coordinates) {
|
|
| 345 | + protected void addLine(DefaultFeatureCollection linesFeatures, String lineName, Coordinate[] coordinates, Set<String> excludedFeatureNames) {
|
|
| 346 | + if (excludedFeatureNames.contains(lineName)) {
|
|
| 347 | + return;
|
|
| 348 | + }
|
|
| 341 | 349 | LineString line = getGeometryFactory().createLineString(coordinates);
|
| 342 | 350 | lineBuilder.add(line);
|
| 343 | 351 | lineBuilder.add(lineName);
|
| 344 | 352 | linesFeatures.add(lineBuilder.buildFeature(null));
|
| 345 | 353 | }
|
| 346 | 354 | |
| 347 | - protected void addLine(DefaultFeatureCollection linesFeatures, String lineName, Coordinate[] coordinates, Date date) {
|
|
| 355 | + protected void addLine(DefaultFeatureCollection linesFeatures, String lineName, Coordinate[] coordinates, Date date, Set<String> excludedFeatureNames) {
|
|
| 356 | + if (excludedFeatureNames.contains(lineName)) {
|
|
| 357 | + return;
|
|
| 358 | + }
|
|
| 348 | 359 | LineString line = getGeometryFactory().createLineString(coordinates);
|
| 349 | 360 | lineBuilder.add(line);
|
| 350 | 361 | lineBuilder.add(date == null ? null : formatDate(date));
|
| ... | ... | @@ -352,7 +363,7 @@ public abstract class TripMapContentBuilderSupport implements TripMapContentBuil |
| 352 | 363 | linesFeatures.add(lineBuilder.buildFeature(null));
|
| 353 | 364 | }
|
| 354 | 365 | |
| 355 | - protected void addLineLegend(Style styleLines, String legendName, String legendLabel) {
|
|
| 366 | + protected void addLineLegend(Style styleLines, String legendName, String legendLabel, Set<String> excludedFeatureNames) {
|
|
| 356 | 367 | LineString line = getGeometryFactory().createLineString(ObserveMapPaneLegendItem.lineCoordinates());
|
| 357 | 368 | lineBuilder.add(line);
|
| 358 | 369 | if (withLabelLine) {
|
| ... | ... | @@ -360,17 +371,17 @@ public abstract class TripMapContentBuilderSupport implements TripMapContentBuil |
| 360 | 371 | }
|
| 361 | 372 | lineBuilder.add(legendName);
|
| 362 | 373 | SimpleFeature simpleFeature = lineBuilder.buildFeature(null);
|
| 363 | - ObserveMapPaneLegendItem legendTripDay = new ObserveMapPaneLegendItem(simpleFeature, styleLines, legendLabel, 0, 0);
|
|
| 374 | + ObserveMapPaneLegendItem legendTripDay = new ObserveMapPaneLegendItem(legendName, simpleFeature, styleLines, legendLabel, 0, 0, !excludedFeatureNames.contains(legendName));
|
|
| 364 | 375 | legendItems.add(legendTripDay);
|
| 365 | 376 | }
|
| 366 | 377 | |
| 367 | - protected void addPointLegend(Style stylePoints, String legendName, String legendLabel, int notValidCount, int validCount) {
|
|
| 378 | + protected void addPointLegend(Style stylePoints, String legendName, String legendLabel, int notValidCount, int validCount, Set<String> excludedFeatureNames) {
|
|
| 368 | 379 | Point point = getGeometryFactory().createPoint(ObserveMapPaneLegendItem.pointCoordinates());
|
| 369 | 380 | pointBuilder.add(point);
|
| 370 | 381 | pointBuilder.add("");
|
| 371 | 382 | pointBuilder.add(legendName);
|
| 372 | 383 | SimpleFeature simpleFeature = pointBuilder.buildFeature(null);
|
| 373 | - ObserveMapPaneLegendItem legendPoint = new ObserveMapPaneLegendItem(simpleFeature, stylePoints, legendLabel, notValidCount, validCount);
|
|
| 384 | + ObserveMapPaneLegendItem legendPoint = new ObserveMapPaneLegendItem(legendName, simpleFeature, stylePoints, legendLabel, notValidCount, validCount, !excludedFeatureNames.contains(legendName));
|
|
| 374 | 385 | legendItems.add(legendPoint);
|
| 375 | 386 | }
|
| 376 | 387 | } |
| ... | ... | @@ -47,6 +47,8 @@ import java.awt.geom.AffineTransform; |
| 47 | 47 | import java.awt.geom.Point2D;
|
| 48 | 48 | import java.util.ArrayList;
|
| 49 | 49 | import java.util.List;
|
| 50 | +import java.util.Optional;
|
|
| 51 | +import java.util.Set;
|
|
| 50 | 52 | |
| 51 | 53 | /**
|
| 52 | 54 | * @author Tony Chemit - dev@tchemit.fr
|
| ... | ... | @@ -76,7 +78,7 @@ public class TripMapUIHandler implements UIHandler<TripMapUI> { |
| 76 | 78 | return ui.getObserveMapPane();
|
| 77 | 79 | }
|
| 78 | 80 | |
| 79 | - public void doOpenMap(TripMapConfigDto tripMapConfig, TripMapDto tripMapDto) {
|
|
| 81 | + public void doOpenMap(TripMapConfigDto tripMapConfig, TripMapDto tripMapDto, Set<String> excludedFeatureNames) {
|
|
| 80 | 82 | try {
|
| 81 | 83 | flipContent();
|
| 82 | 84 | |
| ... | ... | @@ -89,10 +91,12 @@ public class TripMapUIHandler implements UIHandler<TripMapUI> { |
| 89 | 91 | |
| 90 | 92 | List<TripMapPoint> tripMapPoints = new ArrayList<>(tripMapDto.getPoints());
|
| 91 | 93 | log.info(String.format("Found %d point(s).", tripMapPoints.size()));
|
| 94 | + mapPane.setTripMapDto(tripMapDto);
|
|
| 92 | 95 | TripMapContentBuilderSupport mapContentBuilder = TripMapContentBuilderSupport.of(config,
|
| 93 | 96 | tripMapConfig,
|
| 94 | 97 | tripMapDto,
|
| 95 | - tripMapPoints);
|
|
| 98 | + tripMapPoints,
|
|
| 99 | + excludedFeatureNames);
|
|
| 96 | 100 | |
| 97 | 101 | // set zoom
|
| 98 | 102 | tripArea = new ReferencedEnvelope();
|
| ... | ... | @@ -224,7 +228,16 @@ public class TripMapUIHandler implements UIHandler<TripMapUI> { |
| 224 | 228 | |
| 225 | 229 | @Override
|
| 226 | 230 | public void mouseClicked(MouseEvent e) {
|
| 227 | - |
|
| 231 | + if (e.getClickCount() < 2) {
|
|
| 232 | + return;
|
|
| 233 | + }
|
|
| 234 | + Point point = e.getPoint();
|
|
| 235 | + Optional<ObserveMapPaneLegendItem> legendItem = getObserveMapPane().getLegendItem(point);
|
|
| 236 | + legendItem.ifPresent(i -> {
|
|
| 237 | + i.setSelected(!i.isSelected());
|
|
| 238 | + log.info("Change selected value for legend item: {} to value: {}", i.getName(), i.isSelected());
|
|
| 239 | + SwingUtilities.invokeLater(ui.getObserveMapPane()::fireRebuildModel);
|
|
| 240 | + });
|
|
| 228 | 241 | }
|
| 229 | 242 | |
| 230 | 243 | @Override
|
| ... | ... | @@ -95,26 +95,26 @@ public class TripMapContentBuilder extends TripMapContentBuilderSupport { |
| 95 | 95 | }
|
| 96 | 96 | |
| 97 | 97 | @Override
|
| 98 | - public void addLines(TripMapConfigDto tripMapConfig, List<TripMapPoint> tripMapPoints) {
|
|
| 98 | + public void addLines(TripMapConfigDto tripMapConfig, List<TripMapPoint> tripMapPoints, Set<String> excludedFeatureNames) {
|
|
| 99 | 99 | if (tripMapConfig.isAddObservations()) {
|
| 100 | 100 | List<TripMapPoint> obsPoints = getObsPoints(tripMapPoints);
|
| 101 | 101 | addFishingZone(OBSERVATIONS_ZONES_BUILDER, obsPoints);
|
| 102 | - addLines(OBSERVATIONS_LINES_BUILDER, obsPoints, tripMapConfig.isAddObservationsTripSegment());
|
|
| 102 | + addLines(OBSERVATIONS_LINES_BUILDER, obsPoints, tripMapConfig.isAddObservationsTripSegment(), excludedFeatureNames);
|
|
| 103 | 103 | }
|
| 104 | 104 | if (tripMapConfig.isAddLogbook()) {
|
| 105 | 105 | List<TripMapPoint> logbookPoints = getLogbookPoints(tripMapPoints);
|
| 106 | 106 | addFishingZone(LOGBOOK_ZONES_BUILDER, logbookPoints);
|
| 107 | - addLines(LOGBOOK_LINES_BUILDER, logbookPoints, tripMapConfig.isAddLogbookTripSegment());
|
|
| 107 | + addLines(LOGBOOK_LINES_BUILDER, logbookPoints, tripMapConfig.isAddLogbookTripSegment(), excludedFeatureNames);
|
|
| 108 | 108 | }
|
| 109 | 109 | }
|
| 110 | 110 | |
| 111 | 111 | @Override
|
| 112 | - public void addPoints(TripMapConfigDto tripMapConfig, List<TripMapPoint> tripMapPoints) {
|
|
| 112 | + public void addPoints(TripMapConfigDto tripMapConfig, List<TripMapPoint> tripMapPoints, Set<String> excludedFeatureNames) {
|
|
| 113 | 113 | if (tripMapConfig.isAddObservations()) {
|
| 114 | - addPoints(getObsPoints(tripMapPoints), OBSERVATION_POINTS_LAYER_NAME, n("observe.ui.datasource.editor.content.map.observation.points.not.valid"));
|
|
| 114 | + addPoints(getObsPoints(tripMapPoints), OBSERVATION_POINTS_LAYER_NAME, n("observe.ui.datasource.editor.content.map.observation.points.not.valid"), excludedFeatureNames);
|
|
| 115 | 115 | }
|
| 116 | 116 | if (tripMapConfig.isAddLogbook()) {
|
| 117 | - addPoints(getLogbookPoints(tripMapPoints), LOGBOOK_POINTS_LAYER_NAME, n("observe.ui.datasource.editor.content.map.logbook.points.not.valid"));
|
|
| 117 | + addPoints(getLogbookPoints(tripMapPoints), LOGBOOK_POINTS_LAYER_NAME, n("observe.ui.datasource.editor.content.map.logbook.points.not.valid"), excludedFeatureNames);
|
|
| 118 | 118 | }
|
| 119 | 119 | }
|
| 120 | 120 | |
| ... | ... | @@ -132,36 +132,36 @@ public class TripMapContentBuilder extends TripMapContentBuilderSupport { |
| 132 | 132 | }
|
| 133 | 133 | }
|
| 134 | 134 | |
| 135 | - private void addLines(LinesBuilder builder, List<TripMapPoint> tripMapPoints, boolean addTripSegment) {
|
|
| 135 | + private void addLines(LinesBuilder builder, List<TripMapPoint> tripMapPoints, boolean addTripSegment, Set<String> excludedFeatureNames) {
|
|
| 136 | 136 | DefaultFeatureCollection linesFeatures = new DefaultFeatureCollection();
|
| 137 | 137 | Set<String> lineTypes = new TreeSet<>();
|
| 138 | 138 | builder.build(tripMapPoints);
|
| 139 | 139 | if (addTripSegment) {
|
| 140 | - addLines(TRIP_LINE_TYPE, linesFeatures, lineTypes, builder.getTripLines());
|
|
| 140 | + addLines(TRIP_LINE_TYPE, linesFeatures, lineTypes, builder.getTripLines(), excludedFeatureNames);
|
|
| 141 | 141 | }
|
| 142 | - addLines(SETTING_LINE_TYPE, linesFeatures, lineTypes, builder.getSettingLines());
|
|
| 143 | - addLines(HAULING_LINE_TYPE, linesFeatures, lineTypes, builder.getHaulingLines());
|
|
| 142 | + addLines(SETTING_LINE_TYPE, linesFeatures, lineTypes, builder.getSettingLines(), excludedFeatureNames);
|
|
| 143 | + addLines(HAULING_LINE_TYPE, linesFeatures, lineTypes, builder.getHaulingLines(), excludedFeatureNames);
|
|
| 144 | 144 | if (!linesFeatures.isEmpty()) {
|
| 145 | 145 | Style styleLines = findStyle(styledLayerDescriptor, builder.layerName());
|
| 146 | 146 | Layer layerLines = new FeatureLayer(linesFeatures, styleLines, builder.layerName());
|
| 147 | 147 | mapContent.addLayer(layerLines);
|
| 148 | 148 | if (lineTypes.contains(TRIP_LINE_TYPE)) {
|
| 149 | - addLineLegend(styleLines, TRIP_LINE_TYPE, builder.tripLineTitle());
|
|
| 149 | + addLineLegend(styleLines, TRIP_LINE_TYPE, builder.tripLineTitle(), excludedFeatureNames);
|
|
| 150 | 150 | }
|
| 151 | 151 | if (lineTypes.contains(SETTING_LINE_TYPE)) {
|
| 152 | - addLineLegend(styleLines, SETTING_LINE_TYPE, builder.settingLineTitle());
|
|
| 152 | + addLineLegend(styleLines, SETTING_LINE_TYPE, builder.settingLineTitle(), excludedFeatureNames);
|
|
| 153 | 153 | }
|
| 154 | 154 | if (lineTypes.contains(HAULING_LINE_TYPE)) {
|
| 155 | - addLineLegend(styleLines, HAULING_LINE_TYPE, builder.haulingLineTitle());
|
|
| 155 | + addLineLegend(styleLines, HAULING_LINE_TYPE, builder.haulingLineTitle(), excludedFeatureNames);
|
|
| 156 | 156 | }
|
| 157 | 157 | }
|
| 158 | 158 | }
|
| 159 | 159 | |
| 160 | - private void addLines(String lineType, DefaultFeatureCollection linesFeatures, Set<String> lineTypes, List<Coordinate[]> lines) {
|
|
| 160 | + private void addLines(String lineType, DefaultFeatureCollection linesFeatures, Set<String> lineTypes, List<Coordinate[]> lines, Set<String> excludedFeatureNames) {
|
|
| 161 | 161 | if (!lines.isEmpty()) {
|
| 162 | 162 | lineTypes.add(lineType);
|
| 163 | 163 | for (Coordinate[] tripLine : lines) {
|
| 164 | - addLine(linesFeatures, lineType, tripLine);
|
|
| 164 | + addLine(linesFeatures, lineType, tripLine, excludedFeatureNames);
|
|
| 165 | 165 | }
|
| 166 | 166 | }
|
| 167 | 167 | }
|
| ... | ... | @@ -100,24 +100,24 @@ public class TripMapContentBuilder extends fr.ird.observe.client.datasource.edit |
| 100 | 100 | }
|
| 101 | 101 | |
| 102 | 102 | @Override
|
| 103 | - public void addPoints(TripMapConfigDto tripMapConfig, List<TripMapPoint> tripMapPoints) {
|
|
| 103 | + public void addPoints(TripMapConfigDto tripMapConfig, List<TripMapPoint> tripMapPoints, Set<String> excludedFeatureNames) {
|
|
| 104 | 104 | if (tripMapConfig.isAddObservations()) {
|
| 105 | - addPoints(tripMapPoints.stream().filter(f -> f.getType().isTrip() || f.getType().isObs()).collect(Collectors.toList()), OBSERVATION_POINTS_LAYER_NAME, n("observe.ui.datasource.editor.content.map.observation.points.not.valid"));
|
|
| 105 | + addPoints(tripMapPoints.stream().filter(f -> f.getType().isTrip() || f.getType().isObs()).collect(Collectors.toList()), OBSERVATION_POINTS_LAYER_NAME, n("observe.ui.datasource.editor.content.map.observation.points.not.valid"), excludedFeatureNames);
|
|
| 106 | 106 | }
|
| 107 | 107 | if (tripMapConfig.isAddLogbook()) {
|
| 108 | - addPoints(tripMapPoints.stream().filter(f -> f.getType().isTrip() || f.getType().isLogbook()).collect(Collectors.toList()), LOGBOOK_POINTS_LAYER_NAME, n("observe.ui.datasource.editor.content.map.logbook.points.not.valid"));
|
|
| 108 | + addPoints(tripMapPoints.stream().filter(f -> f.getType().isTrip() || f.getType().isLogbook()).collect(Collectors.toList()), LOGBOOK_POINTS_LAYER_NAME, n("observe.ui.datasource.editor.content.map.logbook.points.not.valid"), excludedFeatureNames);
|
|
| 109 | 109 | }
|
| 110 | 110 | }
|
| 111 | 111 | |
| 112 | 112 | @Override
|
| 113 | - public void addLines(TripMapConfigDto tripMapConfig, List<TripMapPoint> tripMapPoints) {
|
|
| 113 | + public void addLines(TripMapConfigDto tripMapConfig, List<TripMapPoint> tripMapPoints, Set<String> excludedFeatureNames) {
|
|
| 114 | 114 | if (tripMapConfig.isAddObservations() && tripMapConfig.isAddObservationsTripSegment()) {
|
| 115 | 115 | addLines0(tripMapPoints.stream().filter(f -> f.getType().isTrip() || f.getType().isObs()).collect(Collectors.toList()),
|
| 116 | 116 | "observationDay",
|
| 117 | 117 | "observationNight",
|
| 118 | 118 | true,
|
| 119 | 119 | t("observe.ui.datasource.editor.content.map.legend.obs.tripDay"),
|
| 120 | - t("observe.ui.datasource.editor.content.map.legend.obs.tripBetweenTwoDays"));
|
|
| 120 | + t("observe.ui.datasource.editor.content.map.legend.obs.tripBetweenTwoDays"), excludedFeatureNames);
|
|
| 121 | 121 | }
|
| 122 | 122 | if (tripMapConfig.isAddLogbook() && tripMapConfig.isAddLogbookTripSegment()) {
|
| 123 | 123 | addLines0(tripMapPoints.stream().filter(f -> f.getType().isTrip() || f.getType().isLogbook()).collect(Collectors.toList()),
|
| ... | ... | @@ -125,23 +125,23 @@ public class TripMapContentBuilder extends fr.ird.observe.client.datasource.edit |
| 125 | 125 | "logbookSegment",
|
| 126 | 126 | false,
|
| 127 | 127 | t("observe.ui.datasource.editor.content.map.legend.logbook.tripSegment"),
|
| 128 | - null);
|
|
| 128 | + null, excludedFeatureNames);
|
|
| 129 | 129 | }
|
| 130 | 130 | }
|
| 131 | 131 | |
| 132 | - protected void addTripDay(DefaultFeatureCollection linesFeatures, String label, List<Coordinate> coordinatesByDay, TripMapPoint previousPoint) {
|
|
| 132 | + protected void addTripDay(DefaultFeatureCollection linesFeatures, String label, List<Coordinate> coordinatesByDay, TripMapPoint previousPoint, Set<String> excludedFeatureNames) {
|
|
| 133 | 133 | if (coordinatesByDay.size() > 1) {
|
| 134 | 134 | Coordinate[] coordinates = coordinatesByDay.toArray(new Coordinate[0]);
|
| 135 | - addLine(linesFeatures, label, coordinates, previousPoint.getTime());
|
|
| 135 | + addLine(linesFeatures, label, coordinates, previousPoint.getTime(), excludedFeatureNames);
|
|
| 136 | 136 | }
|
| 137 | 137 | }
|
| 138 | 138 | |
| 139 | - protected void addTripBetweenTwoDay(DefaultFeatureCollection linesFeatures, String label, TripMapPoint previousPoint, TripMapPoint point, boolean addTime) {
|
|
| 139 | + protected void addTripBetweenTwoDay(DefaultFeatureCollection linesFeatures, String label, TripMapPoint previousPoint, TripMapPoint point, boolean addTime, Set<String> excludedFeatureNames) {
|
|
| 140 | 140 | Coordinate[] coordinates = create(previousPoint, point);
|
| 141 | - addLine(linesFeatures, label, coordinates, addTime ? previousPoint.getTime() : null);
|
|
| 141 | + addLine(linesFeatures, label, coordinates, addTime ? previousPoint.getTime() : null, excludedFeatureNames);
|
|
| 142 | 142 | }
|
| 143 | 143 | |
| 144 | - protected void addLines0(List<TripMapPoint> tripMapPoints, String pointDay, String pointNight, boolean addDate, String pointDayLabel, String pointNightLabel) {
|
|
| 144 | + protected void addLines0(List<TripMapPoint> tripMapPoints, String pointDay, String pointNight, boolean addDate, String pointDayLabel, String pointNightLabel, Set<String> excludedFeatureNames) {
|
|
| 145 | 145 | if (tripMapPoints.size() == 2 && tripMapPoints.stream().allMatch(t -> t.getType().isTrip())) {
|
| 146 | 146 | // Got only trip points, nothing to display then
|
| 147 | 147 | return;
|
| ... | ... | @@ -157,24 +157,24 @@ public class TripMapContentBuilder extends fr.ird.observe.client.datasource.edit |
| 157 | 157 | Coordinate coordinate = create(point);
|
| 158 | 158 | if (previousPoint != null && !DateUtils.isSameDay(previousPoint.getTime(), point.getTime())) {
|
| 159 | 159 | // changing day
|
| 160 | - addTripDay(linesFeatures, pointDay, coordinatesByDay, previousPoint);
|
|
| 161 | - addTripBetweenTwoDay(linesFeatures, pointNight, previousPoint, point, addDate);
|
|
| 160 | + addTripDay(linesFeatures, pointDay, coordinatesByDay, previousPoint, excludedFeatureNames);
|
|
| 161 | + addTripBetweenTwoDay(linesFeatures, pointNight, previousPoint, point, addDate, excludedFeatureNames);
|
|
| 162 | 162 | coordinatesByDay.clear();
|
| 163 | 163 | }
|
| 164 | 164 | coordinatesByDay.add(coordinate);
|
| 165 | 165 | previousPoint = point;
|
| 166 | 166 | }
|
| 167 | 167 | if (previousPoint != null) {
|
| 168 | - addTripDay(linesFeatures, pointDay, coordinatesByDay, previousPoint);
|
|
| 168 | + addTripDay(linesFeatures, pointDay, coordinatesByDay, previousPoint, excludedFeatureNames);
|
|
| 169 | 169 | }
|
| 170 | 170 | Style styleLines = findStyle(styledLayerDescriptor, LINES_LAYER_NAME);
|
| 171 | 171 | if (!linesFeatures.isEmpty()) {
|
| 172 | 172 | Layer layerLines = new FeatureLayer(linesFeatures, styleLines, LINES_LAYER_NAME);
|
| 173 | 173 | mapContent.addLayer(layerLines);
|
| 174 | 174 | }
|
| 175 | - addLineLegend(styleLines, pointDay, pointDayLabel);
|
|
| 175 | + addLineLegend(styleLines, pointDay, pointDayLabel, excludedFeatureNames);
|
|
| 176 | 176 | if (pointNightLabel != null) {
|
| 177 | - addLineLegend(styleLines, pointNight, pointNightLabel);
|
|
| 177 | + addLineLegend(styleLines, pointNight, pointNightLabel, excludedFeatureNames);
|
|
| 178 | 178 | }
|
| 179 | 179 | }
|
| 180 | 180 |
| ... | ... | @@ -43,9 +43,9 @@ public interface TripMapContentBuilder { |
| 43 | 43 | |
| 44 | 44 | boolean accept(TripMapDto tripMapDto);
|
| 45 | 45 | |
| 46 | - void addLines(TripMapConfigDto tripMapConfig, List<TripMapPoint> tripMapPoints) throws Exception;
|
|
| 46 | + void addLines(TripMapConfigDto tripMapConfig, List<TripMapPoint> tripMapPoints, Set<String> excludedFeatureNames) throws Exception;
|
|
| 47 | 47 | |
| 48 | - void addPoints(TripMapConfigDto tripMapConfig, List<TripMapPoint> tripMapPoints) throws Exception;
|
|
| 48 | + void addPoints(TripMapConfigDto tripMapConfig, List<TripMapPoint> tripMapPoints, Set<String> excludedFeatureNames) throws Exception;
|
|
| 49 | 49 | |
| 50 | 50 | File getStyleFile(Path mapDirectory);
|
| 51 | 51 |