001    //$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/graphics/displayelements/AbstractDisplayElement.java $
002    /*----------------------------------------------------------------------------
003     This file is part of deegree, http://deegree.org/
004     Copyright (C) 2001-2009 by:
005       Department of Geography, University of Bonn
006     and
007       lat/lon GmbH
008    
009     This library is free software; you can redistribute it and/or modify it under
010     the terms of the GNU Lesser General Public License as published by the Free
011     Software Foundation; either version 2.1 of the License, or (at your option)
012     any later version.
013     This library is distributed in the hope that it will be useful, but WITHOUT
014     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
015     FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
016     details.
017     You should have received a copy of the GNU Lesser General Public License
018     along with this library; if not, write to the Free Software Foundation, Inc.,
019     59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020    
021     Contact information:
022    
023     lat/lon GmbH
024     Aennchenstr. 19, 53177 Bonn
025     Germany
026     http://lat-lon.de/
027    
028     Department of Geography, University of Bonn
029     Prof. Dr. Klaus Greve
030     Postfach 1147, 53001 Bonn
031     Germany
032     http://www.geographie.uni-bonn.de/deegree/
033    
034     e-mail: info@deegree.org
035    ----------------------------------------------------------------------------*/
036    package org.deegree.graphics.displayelements;
037    
038    import java.io.Serializable;
039    
040    import org.deegree.model.feature.Feature;
041    
042    /**
043     * Base class for all display elements.
044     * <p>
045     * A <code>DisplayElement</code> is associated to one feature that may have a geometry property or not (this is the
046     * common case).
047     *
048     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
049     * @author <a href="mailto:mschneider@lat-lon.de">Markus Schneider</a>
050     * @author last edited by: $Author: mschneider $
051     *
052     * @version $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18 Jun 2009) $
053     */
054    abstract class AbstractDisplayElement implements DisplayElement, Serializable {
055    
056        /** Use serialVersionUID for interoperability. */
057        private final static long serialVersionUID = 1226236249388451855L;
058    
059        /**
060         * The feature to display
061         */
062        protected Feature feature;
063    
064        private boolean highlighted;
065    
066        private boolean selected;
067    
068        /**
069         * An empty constructor doing nothing
070         */
071        AbstractDisplayElement() {
072            // nothing
073        }
074    
075        /**
076         *
077         *
078         * @param feature
079         */
080        AbstractDisplayElement( Feature feature ) {
081            if ( feature != null ) {
082                setFeature( feature );
083            }
084        }
085    
086        /**
087         * Returns the associated <tt>Feature</tt>.
088         *
089         */
090        public Feature getFeature() {
091            return feature;
092        }
093    
094        /**
095         * sets the feature encapsulated by a DisplayElement
096         *
097         * @param feature
098         */
099        public void setFeature( Feature feature ) {
100            this.feature = new ScaledFeature( feature, -1 );
101        }
102    
103        /**
104         * returns the id of the feature that's associated with the DisplayElement
105         */
106        public String getAssociateFeatureId() {
107            return feature.getId();
108        }
109    
110        /**
111         * marks a <tt>DisplayElement</tt> as selected or not
112         *
113         */
114        public void setSelected( boolean selected ) {
115            this.selected = selected;
116        }
117    
118        /**
119         * returns if the <tt>DisplayElement</tt> is selected or not
120         *
121         */
122        public boolean isSelected() {
123            return selected;
124        }
125    
126        /**
127         * marks the <tt>DisplayElement</tt> as highlighted or not
128         *
129         */
130        public void setHighlighted( boolean highlighted ) {
131            this.highlighted = highlighted;
132        }
133    
134        /**
135         * returns if the <tt>DisplayElement</tt> is highlighted or not.
136         *
137         */
138        public boolean isHighlighted() {
139            return highlighted;
140        }
141    
142        /**
143         * Returns whether the <code>DisplayElement</code> should be painted at the current scale or not.
144         */
145        public abstract boolean doesScaleConstraintApply( double scale );
146    }