This is an automated email from the ASF dual-hosted git repository.
jsorel pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 054d322 Portrayal : update mapitem API
054d322 is described below
commit 054d322fcf25381f03cb2a7fa6cf7373e6bc46db
Author: jsorel <[email protected]>
AuthorDate: Mon Jan 27 15:01:30 2020 +0100
Portrayal : update mapitem API
---
.../java/org/apache/sis/internal/map/MapItem.java | 75 ++++++++++++++++++++++
.../java/org/apache/sis/internal/map/MapLayer.java | 1 -
2 files changed, 75 insertions(+), 1 deletion(-)
diff --git
a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/MapItem.java
b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/MapItem.java
index 7d45f4d..d34dc9b 100644
--- a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/MapItem.java
+++ b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/MapItem.java
@@ -18,6 +18,8 @@ package org.apache.sis.internal.map;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Objects;
import javax.swing.event.EventListenerList;
@@ -36,30 +38,70 @@ import javax.swing.event.EventListenerList;
*/
public abstract class MapItem {
+ /** Identifies a change in the map item identifier. */
+ public static final String IDENTIFIER_PROPERTY = "identifier";
/** Identifies a change in the map item title. */
public static final String TITLE_PROPERTY = "title";
+ /** Identifies a change in the map item abstract description. */
+ public static final String ABSTRACT_PROPERTY = "abstract";
/** Identifies a change in the map item visibility state. */
public static final String VISIBLE_PROPERTY = "visible";
private final EventListenerList listeners = new EventListenerList();
/**
+ * Identifier of this map item.
+ */
+ private String identifier;
+ /**
* The title of this map item, for display to the user.
*/
private CharSequence title;
/**
+ * A description of this map item, for display to the user.
+ */
+ private CharSequence abtract;
+
+ /**
* Whether this item should be shown on the map.
*/
private boolean visible = true;
/**
+ * Additional user defined properties.
+ */
+ private Map<String,Object> userMap;
+
+ /**
* Only used by classes in this package.
*/
MapItem() {
}
/**
+ * Returns the identifier of this map item.
+ *
+ * @return identifier, or {@code null} if none.
+ */
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ /**
+ * Sets a new identifier for this map item.
+ *
+ * @param identifier identifier, or {@code null} if none.
+ */
+ public void setIdentifier(String identifier) {
+ if (!Objects.equals(this.identifier, identifier)) {
+ CharSequence old = this.identifier;
+ this.identifier = identifier;
+ firePropertyChange(IDENTIFIER_PROPERTY, old, identifier);
+ }
+ }
+
+ /**
* Returns the title of this map item.
* This title should be user friendly and may be an {@link
org.opengis.util.InternationalString}.
* It shall not be used as an identifier.
@@ -84,6 +126,29 @@ public abstract class MapItem {
}
/**
+ * Returns the description of this map item.
+ * This description should be user friendly and may be an {@link
org.opengis.util.InternationalString}.
+ *
+ * @return description to be shown to the user, or {@code null} if none.
+ */
+ public CharSequence getAbstract() {
+ return abtract;
+ }
+
+ /**
+ * Sets a new description for this map item.
+ *
+ * @param abtract title to be shown to the user, or {@code null} if none.
+ */
+ public void setAbstract(CharSequence abtract) {
+ if (!Objects.equals(this.abtract, abtract)) {
+ CharSequence old = this.abtract;
+ this.abtract = abtract;
+ firePropertyChange(ABSTRACT_PROPERTY, old, abtract);
+ }
+ }
+
+ /**
* Return whether this item should be shown on the map.
*
* @return {@code true} if this item is visible.
@@ -106,6 +171,16 @@ public abstract class MapItem {
}
/**
+ * @return map of all user properties.
+ * This is the live map.
+ */
+ public synchronized Map<String,Object> getUserProperties() {
+ if (userMap == null) {
+ userMap = new HashMap<>();
+ }
+ return userMap;
+ }
+ /**
* Register a property listener.
*
* @param listener property listener to register
diff --git
a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/MapLayer.java
b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/MapLayer.java
index 08a3990..3373907 100644
--- a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/MapLayer.java
+++ b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/MapLayer.java
@@ -33,7 +33,6 @@ import org.opengis.style.Style;
*
* <p>
* NOTE: this class is a first draft subject to modifications.
- * TODO : missing events
* </p>
*
* @author Johann Sorel (Geomatys)