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
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;
71 * @param featureGroups
72 * @param featureColours
77 public FeatureRendererSettings(String[] renderOrder,
78 Map<String, Boolean> featureGroups,
79 Map<String, FeatureColourI> featureColours, float transparency,
80 Map<String, Float> featureOrder,
81 Map<String, FeatureMatcherSetI> filters)
84 this.renderOrder = Arrays.copyOf(renderOrder, renderOrder.length);
85 this.featureGroups = new ConcurrentHashMap<>(
87 this.featureColours = new ConcurrentHashMap<>(
89 this.transparency = transparency;
90 this.featureOrder = new ConcurrentHashMap<>(featureOrder);
91 featureFilters = filters;
95 * create an independent instance of the feature renderer settings
99 public FeatureRendererSettings(
100 jalview.viewmodel.seqfeatures.FeatureRendererModel fr)
103 featureGroups = new ConcurrentHashMap<>();
104 featureColours = new ConcurrentHashMap<>();
105 featureFilters = new HashMap<>();
106 featureOrder = new ConcurrentHashMap<>();
108 if (fr.renderOrder != null)
110 this.renderOrder = new String[fr.renderOrder.length];
111 System.arraycopy(fr.renderOrder, 0, renderOrder, 0,
112 fr.renderOrder.length);
114 if (fr.featureGroups != null)
116 this.featureGroups = new ConcurrentHashMap<>(
119 if (fr.featureColours != null)
121 this.featureColours = new ConcurrentHashMap<>(
124 Iterator<String> en = fr.featureColours.keySet().iterator();
127 String next = en.next();
128 FeatureColourI val = featureColours.get(next);
129 // if (val instanceof GraduatedColor)
130 if (val.isGraduatedColour() || val.isColourByLabel()) // why this test?
132 featureColours.put(next, new FeatureColour((FeatureColour) val));
136 if (fr.featureFilters != null)
138 this.featureFilters.putAll(fr.featureFilters);
141 this.transparency = fr.transparency;
142 if (fr.featureOrder != null)
144 this.featureOrder = new ConcurrentHashMap<>(