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