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
.term
.DefinedTermBase
;
23 public class CategoricalDataHistogram
{
25 private Feature feature
;
26 private Frequency frequency
;
27 private List
<DefinedTermBase
<?
>> states
;
29 public CategoricalDataHistogram(Feature feature
) {
30 this.feature
= feature
;
31 this.states
= new ArrayList
<>();
32 this.frequency
= new Frequency();
33 feature
.getSupportedCategoricalEnumerations()
34 .forEach(terms
->terms
.getDistinctTerms()
35 .forEach(state
->states
.add(state
)));
38 public void addState(DefinedTermBase
<?
> state
){
39 frequency
.addValue(state
.getLabel());
42 public long getCount(DefinedTermBase
<?
> state
){
43 return frequency
.getCount(state
.getLabel());
46 public List
<DefinedTermBase
<?
>> getStates() {
50 public Feature
getFeature() {