4 package eu
.etaxonomy
.taxeditor
.labels
;
6 import org
.eclipse
.swt
.graphics
.Image
;
8 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationshipType
;
9 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
10 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
11 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
14 * Returns labels and images that are dependent on a nomenclatural
15 * code using a code-specific ILabelImageStrategy.
20 public class LabelImageProvider
implements ILabelImageStrategy
{
22 private ILabelImageStrategy strategy
;
25 * <p>getLabelStrategy</p>
27 * @param name a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
28 * @return a {@link eu.etaxonomy.taxeditor.labels.ILabelImageStrategy} object.
30 public static ILabelImageStrategy
getLabelStrategy(TaxonName name
) {
32 if (PreferencesUtil
.getPreferredNomenclaturalCode().
33 equals(NomenclaturalCode
.ICZN
)) {
34 return new ZoologicalNameLabelStrategy();
36 } else if (name
.getNomenclaturalCode() != null &&
37 name
.getNomenclaturalCode().equals(NomenclaturalCode
.ICZN
)) {
38 return new ZoologicalNameLabelStrategy();
40 return new DefaultLabelStrategy();
44 * <p>Constructor for LabelImageProvider.</p>
46 * @param strategy a {@link eu.etaxonomy.taxeditor.labels.ILabelImageStrategy} object.
48 public LabelImageProvider(ILabelImageStrategy strategy
) {
49 this.strategy
= strategy
;
53 * @see eu.etaxonomy.taxeditor.editor.labels.IEditorLabelStrategy#getNameRelationTypeLabel(eu.etaxonomy.cdm.model.name.NameRelationshipType)
56 public String
getNameRelationTypeLabel(NameRelationshipType type
) {
57 return strategy
.getNameRelationTypeLabel(type
);
61 * @see eu.etaxonomy.taxeditor.editor.labels.IEditorLabelStrategy#getNameRelationInverseTypeLabel(eu.etaxonomy.cdm.model.name.NameRelationshipType)
64 public String
getNameRelationTypeInverseLabel(NameRelationshipType type
) {
65 return strategy
.getNameRelationTypeInverseLabel(type
);
69 * @see eu.etaxonomy.taxeditor.editor.labels.ILabelImageStrategy#getNameRelationImage(eu.etaxonomy.cdm.model.name.NameRelationship)
72 public Image
getNameRelationTypeImage(NameRelationshipType type
) {
73 return strategy
.getNameRelationTypeImage(type
);
77 * @see eu.etaxonomy.taxeditor.labels.ILabelImageStrategy#getNameRelationDescription(eu.etaxonomy.cdm.model.name.NameRelationshipType)
80 public String
getNameRelationTypeDescription(NameRelationshipType type
) {
81 return strategy
.getNameRelationTypeDescription(type
);