Project

General

Profile

Download (2.35 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

    
13
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
14
import eu.etaxonomy.cdm.model.description.Feature;
15
import eu.etaxonomy.cdm.model.description.QuantitativeData;
16
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
17
import eu.etaxonomy.cdm.model.taxon.Classification;
18
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
19

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

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

    
37
    /**
38
     * Returns a string representation for the given {@link QuantitativeData}
39
     * @param data the quantitative data
40
     * @return a string representation of the data
41
     */
42
    public static String getQuantitativeLabel(QuantitativeData data) {
43
        Float min = data.getMin();
44
        Float max = data.getMax();
45
        Float exact = data.getSpecificStatisticalValue(StatisticalMeasure.EXACT_VALUE());
46
        return getQuantitativeLabel(min, exact, max);
47
    }
48

    
49
    /**
50
     * Returns a string representation for the given min/max values
51
     * @param minTotal the min value
52
     * @param maxTotal the max value
53
     * @return a string representation of the data
54
     */
55
    public static String getQuantitativeLabel(Float min, Float exact, Float max) {
56
        return (min==null?"":"("+min.toString()+")") //$NON-NLS-1$
57
                +(exact==null?"":exact.toString()) //$NON-NLS-1$
58
                +(max==null?"":"("+max.toString()+")"); //$NON-NLS-1$
59
    }
60

    
61

    
62
    public static Classification getClassificationForDescriptiveDataSet(DescriptiveDataSet descriptiveDataSet){
63
        Set<TaxonNode> taxonSubtreeFilter = descriptiveDataSet.getTaxonSubtreeFilter();
64
        if(taxonSubtreeFilter!=null && !taxonSubtreeFilter.isEmpty()){
65
            return taxonSubtreeFilter.iterator().next().getClassification();
66
        }
67
        return null;
68
    }
69
}
70

    
(16-16/19)