Project

General

Profile

Download (1.33 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
10

    
11
import java.util.ArrayList;
12
import java.util.List;
13

    
14
import org.apache.commons.math3.stat.Frequency;
15

    
16
import eu.etaxonomy.cdm.model.description.Feature;
17
import eu.etaxonomy.cdm.model.description.State;
18

    
19
/**
20
 * @author pplitzner
21
 * @since Jul 12, 2018
22
 *
23
 */
24
public class CategoricalDataHistogram {
25

    
26
    private Feature feature;
27
    private Frequency frequency;
28
    private List<State> states;
29

    
30
    public CategoricalDataHistogram(Feature feature) {
31
        this.feature = feature;
32
        this.states = new ArrayList<>();
33
        this.frequency = new Frequency();
34
        feature.getSupportedCategoricalEnumerations()
35
        .forEach(voc->voc.getTerms()
36
                .forEach(state->states.add(state)));
37
    }
38

    
39
    public void addState(State state){
40
        frequency.addValue(state.getLabel());
41
    }
42

    
43
    public long getCount(State state){
44
        return frequency.getCount(state.getLabel());
45
    }
46

    
47
    public List<State> getStates() {
48
        return states;
49
    }
50

    
51
    public Feature getFeature() {
52
        return feature;
53
    }
54
}
(3-3/20)