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
;
12 import java
.util
.stream
.Collectors
;
14 import eu
.etaxonomy
.cdm
.model
.description
.DescriptiveDataSet
;
15 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
16 import eu
.etaxonomy
.cdm
.model
.description
.QuantitativeData
;
17 import eu
.etaxonomy
.cdm
.model
.description
.StatisticalMeasure
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
22 * Utility class for the character matrix editor
27 public class MatrixUtility
{
30 * Returns the column property string for the given {@link Feature}
34 public static String
getProperty(Feature feature
){
35 return feature
.getLabel();
39 * Returns a string representation for the given {@link QuantitativeData}
40 * @param data the quantitative data
41 * @return a string representation of the data
43 public static String
getQuantitativeLabel(QuantitativeData data
) {
44 return data
.getStatisticalValues().stream().
45 filter(value
->value
.getType().equals(StatisticalMeasure
.EXACT_VALUE()))
46 .map(exact
->Float
.toString(exact
.getValue()))
47 .collect(Collectors
.joining(", "));
51 * Returns a string representation for the given min/max values
52 * @param minTotal the min value
53 * @param maxTotal the max value
54 * @return a string representation of the data
56 public static String
getQuantitativeLabel(Float min
, Float exact
, Float max
) {
57 return (min
==null?
"":"("+min
.toString()+")") //$NON-NLS-1$
58 +(exact
==null?
"":exact
.toString()) //$NON-NLS-1$
59 +(max
==null?
"":"("+max
.toString()+")"); //$NON-NLS-1$
63 public static Classification
getClassificationForDescriptiveDataSet(DescriptiveDataSet descriptiveDataSet
){
64 Set
<TaxonNode
> taxonSubtreeFilter
= descriptiveDataSet
.getTaxonSubtreeFilter();
65 if(taxonSubtreeFilter
!=null && !taxonSubtreeFilter
.isEmpty()){
66 return taxonSubtreeFilter
.iterator().next().getClassification();