Project

General

Profile

Download (2.7 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 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.workingSet.matrix;
10

    
11
import java.util.ArrayList;
12
import java.util.Collections;
13
import java.util.List;
14

    
15
import eu.etaxonomy.cdm.model.description.CategoricalData;
16
import eu.etaxonomy.cdm.model.description.Feature;
17
import eu.etaxonomy.cdm.model.description.FeatureTree;
18
import eu.etaxonomy.cdm.model.description.QuantitativeData;
19
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
20
import eu.etaxonomy.cdm.model.description.State;
21
import eu.etaxonomy.cdm.model.description.WorkingSet;
22
import eu.etaxonomy.cdm.model.name.Rank;
23

    
24
/**
25
 * @author pplitzner
26
 * @since Nov 26, 2017
27
 *
28
 */
29
public class DataSource {
30

    
31
    private static final Feature LEAF_COLOR_FEATURE = Feature.NewInstance("color of the leaf", "leaf color", "leaf color");
32
    private static final Feature LEAF_LENGTH_FEATURE = Feature.NewInstance("length of the leaf", "Leaf length", "leaf length");
33

    
34
    public static WorkingSet getWorkingSet(){
35
        FeatureTree tree = FeatureTree.NewInstance(getFeatures());
36

    
37
        WorkingSet workingSet = WorkingSet.NewInstance();
38
        workingSet.setDescriptiveSystem(tree);
39
        workingSet.setMaxRank(Rank.GENUS());
40
        workingSet.setMinRank(Rank.SUBSPECIES());
41
        getDescriptions().forEach(description -> workingSet.addDescription(description));
42
        workingSet.setLabel("PP-Wset");
43
        return workingSet;
44

    
45
    }
46

    
47
    public static List<SpecimenDescription> getDescriptions(){
48
        List<SpecimenDescription> descriptions = new ArrayList<>();
49
        descriptions.add(createDescription(0.3f, 2.4f, "blue"));
50
        descriptions.add(createDescription(1.6f, 6.4f, "red"));
51
        return descriptions;
52
    }
53

    
54
    private static List<Feature> getFeatures(){
55
        List<Feature> features = new ArrayList<>();
56
        features.add(LEAF_LENGTH_FEATURE);
57
        features.add(LEAF_COLOR_FEATURE);
58

    
59
        return features;
60
    }
61

    
62
    private static SpecimenDescription createDescription(Float min, Float max, String colorLabel) {
63
        SpecimenDescription desc = SpecimenDescription.NewInstance();
64

    
65
        QuantitativeData length = QuantitativeData.NewInstance(LEAF_LENGTH_FEATURE);
66
        length.setMinimum(min, Collections.emptySet());
67
        length.setMaximum(max, Collections.emptySet());
68
        desc.addElement(length);
69

    
70
        CategoricalData color = CategoricalData.NewInstance(LEAF_COLOR_FEATURE);
71
        color.addStateData(State.NewInstance(colorLabel, colorLabel, colorLabel));
72

    
73

    
74
        return desc;
75
    }
76

    
77
}
(2-2/3)