Mercurial > dive4elements > river
view gwt-client/src/main/java/org/dive4elements/river/client/shared/model/AttributedTheme.java @ 9416:05405292a7ca
Navigationtheme panel now shows themes of dWt and WQ charts grayed out, if the current station is outside the valid range of the theme.
author | gernotbelger |
---|---|
date | Thu, 16 Aug 2018 16:28:03 +0200 |
parents | ea9eef426962 |
children |
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.client.shared.model; import java.util.HashMap; import java.util.Map; import java.util.Set; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class AttributedTheme implements Theme { private static final long serialVersionUID = 1L; private Map<String, String> attributes; /** CollectionItem associated with this facet/themes artifact. */ private CollectionItem collectionItem; public AttributedTheme() { this.attributes = new HashMap<String, String>(); } /** Remark: only here so attributes is not final and serialization is happy */ public void setAttributes(final Map<String, String> attributes) { this.attributes = attributes; } public Set<String> getKeys() { return this.attributes.keySet(); } public void addAttr(final String name, final String value) { if (name != null && value != null) { this.attributes.put(name, value); } } public String getAttr(final String name) { return this.attributes.get(name); } public Integer getAttrAsInt(final String name) { final String attr = getAttr(name); if (attr != null && attr.length() > 0) { try { return Integer.parseInt(attr); } catch (final NumberFormatException nfe) { nfe.printStackTrace(); } } return null; } public Double getAttrAsDouble(final String name) { final String attr = getAttr(name); if (attr == null || attr.isEmpty()) return null; try { return Double.parseDouble(attr); } catch (final NumberFormatException nfe) { nfe.printStackTrace(); return null; } } public boolean getAttrAsBoolean(final String name) { final String attr = getAttr(name); if (attr != null) { try { final int num = Integer.valueOf(attr); return num > 0; } catch (final NumberFormatException nfe) { // do nothing nfe.printStackTrace(); } } return Boolean.valueOf(attr); } @Override public int getPosition() { final Integer pos = getAttrAsInt("pos"); return pos != null ? pos.intValue() : -1; } @Override public void setPosition(final int pos) { addAttr("pos", String.valueOf(pos)); } @Override public int getIndex() { final Integer idx = getAttrAsInt("index"); return idx != null ? idx.intValue() : -1; } @Override public int getActive() { return getAttrAsInt("active"); } @Override public void setActive(final int active) { addAttr("active", String.valueOf(active)); } @Override public String getArtifact() { return getAttr("artifact"); } @Override public String getFacet() { return getAttr("facet"); } @Override public String getDescription() { return getAttr("description"); } @Override public void setDescription(final String description) { if (description != null && description.length() > 0) { addAttr("description", description); } } @Override public int getVisible() { return getAttrAsInt("visible"); } @Override public void setVisible(final int visible) { addAttr("visible", String.valueOf(visible)); } @Override public boolean equals(final Object o) { if (!(o instanceof AttributedTheme)) { return false; } final AttributedTheme other = (AttributedTheme) o; if (other.getPosition() != getPosition()) { return false; } if (!other.getArtifact().equals(getArtifact())) { return false; } if (other.getActive() != getActive()) { return false; } if (!other.getFacet().equals(getFacet())) { return false; } if (!other.getDescription().equals(getDescription())) { return false; } if (other.getIndex() != getIndex()) { return false; } if (other.getVisible() != getVisible()) { return false; } return true; } /** Get the CollectionItem representing the facets artifact. */ @Override public CollectionItem getCollectionItem() { return this.collectionItem; } /** Set the CollectionItem representing the facets artifact. */ @Override public void setCollectionItem(final CollectionItem ci) { this.collectionItem = ci; } }