2 * Copyright (C) 2018 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
.descriptiveDataSet
.matrix
;
11 import java
.util
.ArrayList
;
12 import java
.util
.List
;
14 import org
.apache
.commons
.math3
.stat
.Frequency
;
16 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
17 import eu
.etaxonomy
.cdm
.model
.description
.State
;
24 public class CategoricalDataHistogram
{
26 private Feature feature
;
27 private Frequency frequency
;
28 private List
<State
> states
;
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
)));
39 public void addState(State state
){
40 frequency
.addValue(state
.getLabel());
43 public long getCount(State state
){
44 return frequency
.getCount(state
.getLabel());
47 public List
<State
> getStates() {
51 public Feature
getFeature() {