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
) {
45 Float min
= data
.getMin();
46 Float max
= data
.getMax();
47 if(min
!=null||max
!=null){
48 label
+= "["+(min
!=null?min
.toString():"?")+"-"+(max
!=null?max
.toString():"?")+"] ";
50 label
+= data
.getStatisticalValues().stream().
51 filter(value
->value
.getType().equals(StatisticalMeasure
.EXACT_VALUE()))
52 .map(exact
->Float
.toString(exact
.getValue()))
53 .collect(Collectors
.joining(", "));
59 * Returns a string representation for the given min/max values
60 * @param minTotal the min value
61 * @param maxTotal the max value
62 * @return a string representation of the data
64 public static String
getQuantitativeLabel(Float min
, Float exact
, Float max
) {
65 return (min
==null?
"":"("+min
.toString()+")") //$NON-NLS-1$
66 +(exact
==null?
"":exact
.toString()) //$NON-NLS-1$
67 +(max
==null?
"":"("+max
.toString()+")"); //$NON-NLS-1$
71 public static Classification
getClassificationForDescriptiveDataSet(DescriptiveDataSet descriptiveDataSet
){
72 Set
<TaxonNode
> taxonSubtreeFilter
= descriptiveDataSet
.getTaxonSubtreeFilter();
73 if(taxonSubtreeFilter
!=null && !taxonSubtreeFilter
.isEmpty()){
74 return taxonSubtreeFilter
.iterator().next().getClassification();