2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.viewmodel.seqfeatures;
23 import jalview.api.FeatureColourI;
24 import jalview.datamodel.features.FeatureMatcherSetI;
25 import jalview.schemes.FeatureColour;
27 import java.util.Arrays;
28 import java.util.HashMap;
29 import java.util.Iterator;
31 import java.util.concurrent.ConcurrentHashMap;
34 * A data bean that holds
36 * <li>feature types and their render order</li>
37 * <li>feature groups and their visibility</li>
38 * <li>colour for each feature type</li>
39 * <li>filters (if any) for each feature type</li>
40 * <li>feature colour transparency</li>
42 * Note that feature type visibility settings are not held here.
44 public class FeatureRendererSettings implements Cloneable
49 * map of {groupName, isDisplayed}
51 Map<String, Boolean> featureGroups;
54 * map of {featureType, colourScheme}
56 Map<String, FeatureColourI> featureColours;
59 * map of {featureType, filters}
61 Map<String, FeatureMatcherSetI> featureFilters;
65 Map<String, Float> featureOrder;
67 public FeatureRendererSettings(String[] renderOrder,
68 Map<String, Boolean> featureGroups,
69 Map<String, FeatureColourI> featureColours, float transparency,
70 Map<String, Float> featureOrder)
73 this.renderOrder = Arrays.copyOf(renderOrder, renderOrder.length);
74 this.featureGroups = new ConcurrentHashMap<>(
76 this.featureColours = new ConcurrentHashMap<>(
78 this.transparency = transparency;
79 this.featureOrder = new ConcurrentHashMap<>(featureOrder);
83 * create an independent instance of the feature renderer settings
87 public FeatureRendererSettings(
88 jalview.viewmodel.seqfeatures.FeatureRendererModel fr)
91 featureGroups = new ConcurrentHashMap<>();
92 featureColours = new ConcurrentHashMap<>();
93 featureFilters = new HashMap<>();
94 featureOrder = new ConcurrentHashMap<>();
96 if (fr.renderOrder != null)
98 this.renderOrder = new String[fr.renderOrder.length];
99 System.arraycopy(fr.renderOrder, 0, renderOrder, 0,
100 fr.renderOrder.length);
102 if (fr.featureGroups != null)
104 this.featureGroups = new ConcurrentHashMap<>(
107 if (fr.featureColours != null)
109 this.featureColours = new ConcurrentHashMap<>(
112 Iterator<String> en = fr.featureColours.keySet().iterator();
115 String next = en.next();
116 FeatureColourI val = featureColours.get(next);
117 // if (val instanceof GraduatedColor)
118 if (val.isGraduatedColour() || val.isColourByLabel()) // why this test?
120 featureColours.put(next, new FeatureColour((FeatureColour) val));
124 if (fr.featureFilters != null)
126 this.featureFilters.putAll(fr.featureFilters);
129 this.transparency = fr.transparency;
130 if (fr.featureOrder != null)
132 this.featureOrder = new ConcurrentHashMap<>(