001    /* EVolve - an Extensible Software Visualization Framework
002     * Copyright (C) 2001-2002 Qin Wang
003     *
004     * This library is free software; you can redistribute it and/or
005     * modify it under the terms of the GNU Library General Public
006     * License as published by the Free Software Foundation; either
007     * version 2 of the License, or (at your option) any later version.
008     *
009     * This library is distributed in the hope that it will be useful,
010     * but WITHOUT ANY WARRANTY; without even the implied warranty of
011     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012     * Library General Public License for more details.
013     *
014     * You should have received a copy of the GNU Library General Public
015     * License along with this library; if not, write to the
016     * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
017     * Boston, MA 02111-1307, USA.
018     */
019    
020    /*
021     * EVolve is distributed at http://www.sable.mcgill.ca/EVolve/
022     */
023    
024    package EVolve.visualization;
025    
026    import EVolve.data.DataFilter;
027    import EVolve.data.Element;
028    
029    public abstract class Dimension implements Cloneable{
030        private String name; // name of the dimension
031        protected DataFilter dataFilter; // data filter that gets data for the dimension
032    
033        /**
034         * Gets the name of the dimension.
035         *
036         * @return  name of the dimension
037         */
038        public String getName() {
039            return name;
040        }
041    
042        /**
043         * Sets the data filter.
044         *
045         * @param  dataFilter  data filter
046         */
047        public void setDataFilter(DataFilter dataFilter) {
048            this.name = dataFilter.getName();
049            this.dataFilter = dataFilter;
050        }
051    
052        /**
053         * Gets the data filter.
054         *
055         * @return  data filter
056         */
057        public DataFilter getDataFilter() {
058            return dataFilter;
059        }
060    
061        /**
062         * Gets the data from the element.
063         *
064         * @return  id of the entity if the field is a reference, or the value if the field is a value
065         */
066        public abstract long getField(Element element);
067    
068        public abstract void preVisualize();
069    
070        public int getEntityNumber() {
071            return 0;
072        }
073    
074        public Object clone() {
075            Dimension o = null;
076            try {
077                o = (Dimension)super.clone();
078            } catch (CloneNotSupportedException e) {
079                e.printStackTrace();
080                return null;
081            }
082            o.name = name;
083            o.dataFilter = (dataFilter == null) ? null : (DataFilter) dataFilter.clone();
084            return o;
085        }
086    }