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
;
13 import org
.eclipse
.swt
.graphics
.Image
;
15 import eu
.etaxonomy
.cdm
.api
.service
.dto
.TaxonRowWrapperDTO
;
16 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionType
;
17 import eu
.etaxonomy
.cdm
.model
.description
.DescriptiveDataSet
;
18 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
21 import eu
.etaxonomy
.taxeditor
.model
.ImageResources
;
24 * Utility class for the character matrix editor
29 public class MatrixUtility
{
32 * Returns the column property string for the given {@link Feature}
36 public static String
getProperty(Feature feature
){
37 return feature
.getLabel();
41 * Returns a string representation for the given min/max values
42 * @param minTotal the min value
43 * @param maxTotal the max value
44 * @return a string representation of the data
46 public static String
getQuantitativeLabel(Float min
, Float exact
, Float max
) {
47 return (min
==null?
"":"("+min
.toString()+")") //$NON-NLS-1$
48 +(exact
==null?
"":exact
.toString()) //$NON-NLS-1$
49 +(max
==null?
"":"("+max
.toString()+")"); //$NON-NLS-1$
52 public static Classification
getClassificationForDescriptiveDataSet(DescriptiveDataSet descriptiveDataSet
){
53 Set
<TaxonNode
> taxonSubtreeFilter
= descriptiveDataSet
.getTaxonSubtreeFilter();
54 if(taxonSubtreeFilter
!=null && !taxonSubtreeFilter
.isEmpty()){
55 return taxonSubtreeFilter
.iterator().next().getClassification();
60 public static boolean isDefaultTaxonDescription(TaxonRowWrapperDTO taxonRowWrapperDTO
){
61 return hasType(taxonRowWrapperDTO
, DescriptionType
.DEFAULT_VALUES_FOR_AGGREGATION
);
64 public static boolean isAggregatedTaxonDescription(TaxonRowWrapperDTO taxonRowWrapperDTO
){
65 return hasType(taxonRowWrapperDTO
, DescriptionType
.AGGREGATED_STRUC_DESC
);
68 public static boolean isLiteratureTaxonDescription(TaxonRowWrapperDTO taxonRowWrapperDTO
){
69 return hasType(taxonRowWrapperDTO
, DescriptionType
.SECONDARY_DATA
);
72 private static boolean hasType(TaxonRowWrapperDTO taxonRowWrapperDTO
, DescriptionType descriptionType
){
73 return taxonRowWrapperDTO
.getDescription().getDescription().getTypes().stream()
74 .anyMatch(type
->type
.equals(descriptionType
));
77 public static Image
getLiteratureDescriptionIcon() {
78 return ImageResources
.getImage(ImageResources
.HELP_TOPIC
);
81 public static Image
getAggregatedDescriptionIcon() {
82 return ImageResources
.getImage(ImageResources
.FUNNEL_ICON
);
85 public static Image
getDefaultDescriptionIcon() {
86 return ImageResources
.getImage(ImageResources
.VALIDATE_ICON
);