replace all occurrences of workingSet by descriptiveDataSet and fix some other compil...
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / descriptiveDataSet / matrix / MatrixUtility.java
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.Feature;
14 import eu.etaxonomy.cdm.model.description.QuantitativeData;
15 import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
16 import eu.etaxonomy.cdm.model.taxon.Classification;
17 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
18
19 /**
20 * Utility class for the character matrix editor
21 * @author pplitzner
22 * @since Jan 4, 2018
23 *
24 */
25 public class MatrixUtility {
26
27 /**
28 * Returns the column property string for the given {@link Feature}
29 * @param feature
30 * @return
31 */
32 public static String getProperty(Feature feature){
33 return feature.getLabel();
34 }
35
36 /**
37 * Returns a string representation for the given {@link QuantitativeData}
38 * @param data the quantitative data
39 * @return a string representation of the data
40 */
41 public static String getQuantitativeLabel(QuantitativeData data) {
42 Float min = data.getMin();
43 Float max = data.getMax();
44 return getQuantitativeLabel(min, max);
45 }
46
47 /**
48 * Returns a string representation for the given min/max values
49 * @param minTotal the min value
50 * @param maxTotal the max value
51 * @return a string representation of the data
52 */
53 public static String getQuantitativeLabel(Float min, Float max) {
54 return (min==null?"?":min.toString()) //$NON-NLS-1$
55 +" - " //$NON-NLS-1$
56 +(max==null?"?":max.toString()); //$NON-NLS-1$
57 }
58
59
60 public static Classification getClassificationForDescriptiveDataSet(DescriptiveDataSet descriptiveDataSet){
61 Set<TaxonNode> taxonSubtreeFilter = descriptiveDataSet.getTaxonSubtreeFilter();
62 if(taxonSubtreeFilter!=null && !taxonSubtreeFilter.isEmpty()){
63 return taxonSubtreeFilter.iterator().next().getClassification();
64 }
65 return null;
66 }
67 }
68