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.*;
027    
028    import java.util.ArrayList;
029    
030    public class ValueDimension extends Dimension {
031        private int counter;
032        private int sum;
033        private ArrayList property;
034    
035        public ValueDimension() {
036            super();
037            property = new ArrayList();
038        }
039    
040        public void preVisualize() {
041            counter = 0;
042            sum = 0;
043            property.clear();
044            String[] temp = dataFilter.getProperty();
045            for (int i = 0; i< temp.length; i++) {
046                property.add(temp[i]);
047            }
048        }
049    
050        public int getField(Element element) {
051            int returnVal = dataFilter.getData(element);
052            counter ++;
053    
054            if (property.contains("sum")) {
055                sum += returnVal;
056                returnVal = sum;
057            } else if (property.contains("count")) {
058                returnVal = counter;
059            }
060    
061            return returnVal;
062        }
063    }