Project

General

Profile

Download (2.66 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.Set;
12
import java.util.stream.Collectors;
13

    
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;
20

    
21
/**
22
 * Utility class for the character matrix editor
23
 * @author pplitzner
24
 * @since Jan 4, 2018
25
 *
26
 */
27
public class MatrixUtility {
28

    
29
    /**
30
     * Returns the column property string for the given {@link Feature}
31
     * @param feature
32
     * @return
33
     */
34
    public static String getProperty(Feature feature){
35
        return feature.getLabel();
36
    }
37

    
38
    /**
39
     * Returns a string representation for the given {@link QuantitativeData}
40
     * @param data the quantitative data
41
     * @return a string representation of the data
42
     */
43
    public static String getQuantitativeLabel(QuantitativeData data) {
44
        String label = "";
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():"?")+"] ";
49
        }
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(", "));
54

    
55
        return label;
56
    }
57

    
58
    /**
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
63
     */
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$
68
    }
69

    
70

    
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();
75
        }
76
        return null;
77
    }
78
}
79

    
(16-16/20)