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.styles;
23 import java.awt.Color;
25 import jalview.api.ViewStyleI;
28 * A container for holding alignment view properties. View properties are
29 * data-independent, which means they can be safely copied between views
30 * involving different alignment data without causing exceptions in the
36 public class ViewStyle implements ViewStyleI
38 private boolean abovePIDThreshold = false;
47 * gui state - changes to colour scheme propagated to all groups
49 private boolean colourAppliesToAllGroups;
52 * centre columnar annotation labels in displayed alignment annotation
54 boolean centreColumnLabels = false;
56 private boolean showdbrefs;
58 private boolean shownpfeats;
60 // --------END Structure Conservation
63 * colour according to the reference sequence defined on the alignment
65 private boolean colourByReferenceSeq = false;
67 boolean conservationColourSelected = false;
70 * show the reference sequence in the alignment view
72 private boolean displayReferenceSeq = false;
74 private int increment;
77 * display gap characters
79 boolean renderGaps = true;
81 private boolean rightAlignIds = false;
83 boolean scaleAboveWrapped = false;
85 boolean scaleLeftWrapped = true;
87 boolean scaleRightWrapped = true;
89 boolean seqNameItalics;
92 * show annotation tracks on the alignment
94 private boolean showAnnotation = true;
97 * render each residue in a coloured box
99 boolean showBoxes = true;
102 * Colour sequence text
104 boolean showColourText = false;
107 * show blue triangles
109 boolean showHiddenMarkers = true;
112 * show /start-end in ID panel
114 boolean showJVSuffix = true;
117 * scale features height according to score
119 boolean showSeqFeaturesHeight;
122 * display setting for showing/hiding sequence features on alignment view
124 boolean showSequenceFeatures = false;
127 * display setting for showing/hiding annotation tracks reporting sequence
128 * feature counts in columns of alignment view
130 boolean showSequenceFeatureCounts = false;
133 * display sequence symbols
135 boolean showText = true;
138 * show non-conserved residues only
140 protected boolean showUnconserved = false;
142 Color textColour = Color.black;
144 Color textColour2 = Color.white;
147 * PID or consensus threshold
152 * threshold for switching between textColour & textColour2
154 int thresholdTextColour = 0;
157 * upper case characters in sequence are shown in bold
159 boolean upperCasebold = false;
162 * name of base font for view
164 private String fontName;
169 private int fontSize;
172 * If true, scale protein residues to 3 times width of cDNA bases (in
173 * SplitFrame views only)
175 private boolean scaleProteinAsCdna = true;
178 * if true, font changes to protein or cDNA are applied to both
179 * sides of a split screen
181 private boolean proteinFontAsCdna = true;
188 public ViewStyle(ViewStyleI vs)
190 setAbovePIDThreshold(vs.getAbovePIDThreshold());
191 setCentreColumnLabels(vs.isCentreColumnLabels());
192 setCharHeight(vs.getCharHeight());
193 setCharWidth(vs.getCharWidth());
194 setColourAppliesToAllGroups(vs.getColourAppliesToAllGroups());
195 setColourByReferenceSeq(vs.isColourByReferenceSeq());
196 setColourText(vs.getColourText());
197 setConservationColourSelected(vs.isConservationColourSelected());
198 setConservationSelected(vs.getConservationSelected());
199 setDisplayReferenceSeq(vs.isDisplayReferenceSeq());
200 setFontName(vs.getFontName());
201 setFontSize(vs.getFontSize());
202 setFontStyle(vs.getFontStyle());
203 setIdWidth(vs.getIdWidth());
204 setIncrement(vs.getIncrement());
205 setRenderGaps(vs.isRenderGaps());
206 setRightAlignIds(vs.isRightAlignIds());
207 setScaleAboveWrapped(vs.getScaleAboveWrapped());
208 setScaleLeftWrapped(vs.getScaleLeftWrapped());
209 setScaleProteinAsCdna(vs.isScaleProteinAsCdna());
210 setProteinFontAsCdna(vs.isProteinFontAsCdna());
211 setScaleRightWrapped(vs.getScaleRightWrapped());
212 setSeqNameItalics(vs.isSeqNameItalics());
213 setShowAnnotation(vs.isShowAnnotation());
214 setShowBoxes(vs.getShowBoxes());
215 setShowColourText(vs.isShowColourText());
216 setShowDBRefs(vs.isShowDBRefs());
217 setShowHiddenMarkers(vs.getShowHiddenMarkers());
218 setShowJVSuffix(vs.getShowJVSuffix());
219 setShowNPFeats(vs.isShowNPFeats());
220 setShowSequenceFeaturesHeight(vs.isShowSequenceFeaturesHeight());
221 setShowSequenceFeatures(vs.isShowSequenceFeatures());
222 setShowComplementFeatures(vs.isShowComplementFeatures());
223 setShowComplementFeaturesOnTop(vs.isShowComplementFeaturesOnTop());
224 setShowText(vs.getShowText());
225 setShowUnconserved(vs.getShowUnconserved());
226 setTextColour(vs.getTextColour());
227 setTextColour2(vs.getTextColour2());
228 setThreshold(vs.getThreshold());
229 setThresholdTextColour(vs.getThresholdTextColour());
230 setUpperCasebold(vs.isUpperCasebold());
231 setWrapAlignment(vs.getWrapAlignment());
232 setWrappedWidth(vs.getWrappedWidth());
233 // ViewStyle.configureFrom(this, viewStyle);
241 * Returns true if all attributes of the ViewStyles have the same value
244 public boolean equals(Object other)
246 if (other == null || !(other instanceof ViewStyle))
250 ViewStyle vs = (ViewStyle) other;
252 boolean match = (getAbovePIDThreshold() == vs.getAbovePIDThreshold()
253 && isCentreColumnLabels() == vs.isCentreColumnLabels()
254 && getCharHeight() == vs.getCharHeight()
255 && getCharWidth() == vs.getCharWidth()
256 && getColourAppliesToAllGroups() == vs
257 .getColourAppliesToAllGroups()
258 && isColourByReferenceSeq() == vs.isColourByReferenceSeq()
259 && getColourText() == vs.getColourText()
260 && isConservationColourSelected() == vs
261 .isConservationColourSelected()
262 && getConservationSelected() == vs.getConservationSelected()
263 && isDisplayReferenceSeq() == vs.isDisplayReferenceSeq()
264 && getFontSize() == vs.getFontSize()
265 && getFontStyle() == vs.getFontStyle()
266 && getIdWidth() == vs.getIdWidth()
267 && getIncrement() == vs.getIncrement()
268 && isRenderGaps() == vs.isRenderGaps()
269 && isRightAlignIds() == vs.isRightAlignIds()
270 && getScaleAboveWrapped() == vs.getScaleAboveWrapped()
271 && getScaleLeftWrapped() == vs.getScaleLeftWrapped()
272 && isScaleProteinAsCdna() == vs.isScaleProteinAsCdna()
273 && isProteinFontAsCdna() == vs.isProteinFontAsCdna()
274 && getScaleRightWrapped() == vs.getScaleRightWrapped()
275 && isSeqNameItalics() == vs.isSeqNameItalics()
276 && isShowAnnotation() == vs.isShowAnnotation()
277 && getShowBoxes() == vs.getShowBoxes()
278 && isShowColourText() == vs.isShowColourText()
279 && isShowDBRefs() == vs.isShowDBRefs()
280 && getShowHiddenMarkers() == vs.getShowHiddenMarkers()
281 && getShowJVSuffix() == vs.getShowJVSuffix()
282 && isShowNPFeats() == vs.isShowNPFeats()
283 && isShowSequenceFeaturesHeight() == vs
284 .isShowSequenceFeaturesHeight()
285 && isShowSequenceFeatures() == vs.isShowSequenceFeatures()
286 && isShowComplementFeatures() == vs.isShowComplementFeatures()
287 && isShowComplementFeaturesOnTop() == vs
288 .isShowComplementFeaturesOnTop()
289 && getShowText() == vs.getShowText()
290 && getShowUnconserved() == vs.getShowUnconserved()
291 && getThreshold() == vs.getThreshold()
292 && getThresholdTextColour() == vs.getThresholdTextColour()
293 && isUpperCasebold() == vs.isUpperCasebold()
294 && getWrapAlignment() == vs.getWrapAlignment()
295 && getWrappedWidth() == vs.getWrappedWidth());
297 * and compare non-primitive types; syntax below will match null with null
300 match = match && String.valueOf(getFontName())
301 .equals(String.valueOf(vs.getFontName()));
302 match = match && String.valueOf(getTextColour())
303 .equals(String.valueOf(vs.getTextColour()));
304 match = match && String.valueOf(getTextColour2())
305 .equals(String.valueOf(vs.getTextColour2()));
307 // return equivalent(this, (ViewStyle) other);
311 * Overridden to ensure that whenever vs1.equals(vs2) then vs1.hashCode() ==
315 public int hashCode()
318 * No need to include all properties, just a selection...
322 // Boolean.hashCode returns 1231 or 1237
323 hash += m++ * Boolean.valueOf(this.abovePIDThreshold).hashCode();
324 hash += m++ * Boolean.valueOf(this.centreColumnLabels).hashCode();
325 hash += m++ * Boolean.valueOf(this.colourAppliesToAllGroups).hashCode();
326 hash += m++ * Boolean.valueOf(this.displayReferenceSeq).hashCode();
327 hash += m++ * Boolean.valueOf(this.renderGaps).hashCode();
328 hash += m++ * Boolean.valueOf(this.rightAlignIds).hashCode();
329 hash += m++ * Boolean.valueOf(this.scaleProteinAsCdna).hashCode();
330 hash += m++ * Boolean.valueOf(this.scaleRightWrapped).hashCode();
331 hash += m++ * Boolean.valueOf(this.seqNameItalics).hashCode();
332 hash += m++ * Boolean.valueOf(this.showAnnotation).hashCode();
333 hash += m++ * Boolean.valueOf(this.showBoxes).hashCode();
334 hash += m++ * Boolean.valueOf(this.showdbrefs).hashCode();
335 hash += m++ * Boolean.valueOf(this.showJVSuffix).hashCode();
336 hash += m++ * Boolean.valueOf(this.showSequenceFeatures).hashCode();
337 hash += m++ * Boolean.valueOf(this.showUnconserved).hashCode();
338 hash += m++ * Boolean.valueOf(this.wrapAlignment).hashCode();
339 hash += m++ * this.charHeight;
340 hash += m++ * this.charWidth;
341 hash += m++ * fontSize;
342 hash += m++ * fontStyle;
343 hash += m++ * idWidth;
344 hash += String.valueOf(this.fontName).hashCode();
349 * @return the upperCasebold
352 public boolean isUpperCasebold()
354 return upperCasebold;
358 * @param upperCasebold
359 * the upperCasebold to set
362 public void setUpperCasebold(boolean upperCasebold)
364 this.upperCasebold = upperCasebold;
370 boolean wrapAlignment = false;
373 * number columns in wrapped alignment
377 private int fontStyle;
379 private boolean showComplementFeatures;
381 private boolean showComplementFeaturesOnTop;
386 * @return true if percent identity threshold is applied to shading
389 public boolean getAbovePIDThreshold()
391 return abovePIDThreshold;
397 * @return DOCUMENT ME!
400 public int getCharHeight()
408 * @return DOCUMENT ME!
411 public int getCharWidth()
419 * @return flag indicating if colourchanges propagated to all groups
422 public boolean getColourAppliesToAllGroups()
424 return colourAppliesToAllGroups;
430 * @return DOCUMENT ME!
433 public boolean getColourText()
435 return showColourText;
441 * @return true if conservation based shading is enabled
444 public boolean getConservationSelected()
446 return conservationColourSelected;
452 * @return get scalar for bleaching colourschemes by conservation
455 public int getIncrement()
463 * @return DOCUMENT ME!
466 public boolean getScaleAboveWrapped()
468 return scaleAboveWrapped;
474 * @return DOCUMENT ME!
477 public boolean getScaleLeftWrapped()
479 return scaleLeftWrapped;
485 * @return DOCUMENT ME!
488 public boolean getScaleRightWrapped()
490 return scaleRightWrapped;
496 * @return DOCUMENT ME!
499 public boolean getShowBoxes()
505 public boolean getShowHiddenMarkers()
507 return showHiddenMarkers;
513 * @return DOCUMENT ME!
516 public boolean getShowJVSuffix()
524 * @return DOCUMENT ME!
527 public boolean getShowText()
533 public boolean getShowUnconserved()
535 return showUnconserved;
539 * @return the textColour
542 public Color getTextColour()
548 * @return the textColour2
551 public Color getTextColour2()
559 * @return DOCUMENT ME!
562 public int getThreshold()
568 * @return the thresholdTextColour
571 public int getThresholdTextColour()
573 return thresholdTextColour;
579 * @return DOCUMENT ME!
582 public boolean getWrapAlignment()
584 return wrapAlignment;
590 * @return DOCUMENT ME!
593 public int getWrappedWidth()
599 public boolean isColourByReferenceSeq()
601 return colourByReferenceSeq;
605 * @return the conservationColourSelected
608 public boolean isConservationColourSelected()
610 return conservationColourSelected;
614 public boolean isDisplayReferenceSeq()
616 return displayReferenceSeq;
620 * @return the renderGaps
623 public boolean isRenderGaps()
629 public boolean isRightAlignIds()
631 return rightAlignIds;
635 * @return the seqNameItalics
638 public boolean isSeqNameItalics()
640 return seqNameItalics;
644 public boolean isShowAnnotation()
646 return showAnnotation;
650 * @return the showColourText
653 public boolean isShowColourText()
655 return showColourText;
659 * @return the showSeqFeaturesHeight
662 public boolean isShowSequenceFeaturesHeight()
664 return showSeqFeaturesHeight;
668 public boolean isShowSequenceFeatures()
670 return showSequenceFeatures;
678 * indicate if percent identity threshold is applied to shading
681 public void setAbovePIDThreshold(boolean b)
683 abovePIDThreshold = b;
693 public void setCharHeight(int h)
705 public void setCharWidth(int w)
712 * indicating if subsequent colourscheme changes will be propagated
716 public void setColourAppliesToAllGroups(boolean b)
718 colourAppliesToAllGroups = b;
722 public void setColourByReferenceSeq(boolean colourByReferenceSeq)
724 this.colourByReferenceSeq = colourByReferenceSeq;
734 public void setColourText(boolean state)
736 showColourText = state;
740 * @param conservationColourSelected
741 * the conservationColourSelected to set
744 public void setConservationColourSelected(
745 boolean conservationColourSelected)
747 this.conservationColourSelected = conservationColourSelected;
754 * enable conservation based shading
757 public void setConservationSelected(boolean b)
759 conservationColourSelected = b;
763 public void setDisplayReferenceSeq(boolean displayReferenceSeq)
765 this.displayReferenceSeq = displayReferenceSeq;
771 * set the scalar for bleaching colourschemes according to degree of
775 public void setIncrement(int inc)
787 public void setRenderGaps(boolean state)
793 public void setRightAlignIds(boolean rightAlignIds)
795 this.rightAlignIds = rightAlignIds;
805 public void setScaleAboveWrapped(boolean b)
807 scaleAboveWrapped = b;
817 public void setScaleLeftWrapped(boolean b)
819 scaleLeftWrapped = b;
825 * @param scaleRightWrapped
830 public void setScaleRightWrapped(boolean b)
832 scaleRightWrapped = b;
836 public void setSeqNameItalics(boolean italics)
838 seqNameItalics = italics;
842 public void setShowAnnotation(boolean b)
854 public void setShowBoxes(boolean state)
860 * @param showColourText
861 * the showColourText to set
864 public void setShowColourText(boolean showColourText)
866 this.showColourText = showColourText;
870 public void setShowHiddenMarkers(boolean show)
872 showHiddenMarkers = show;
882 public void setShowJVSuffix(boolean b)
888 public void setShowSequenceFeaturesHeight(boolean selected)
890 showSeqFeaturesHeight = selected;
898 * features are displayed if true
901 public void setShowSequenceFeatures(boolean b)
903 showSequenceFeatures = b;
913 public void setShowText(boolean state)
919 public void setShowUnconserved(boolean showunconserved)
921 showUnconserved = showunconserved;
926 * the textColour to set
929 public void setTextColour(Color textColour)
931 this.textColour = textColour;
936 * the textColour2 to set
939 public void setTextColour2(Color textColour2)
941 this.textColour2 = textColour2;
951 public void setThreshold(int thresh)
957 * @param thresholdTextColour
958 * the thresholdTextColour to set
961 public void setThresholdTextColour(int thresholdTextColour)
963 this.thresholdTextColour = thresholdTextColour;
973 public void setWrapAlignment(boolean state)
975 wrapAlignment = state;
985 public void setWrappedWidth(int w)
987 this.wrappedWidth = w;
991 public boolean sameStyle(ViewStyleI that)
993 return this.equals(that);
997 public String getFontName()
1003 public int getFontSize()
1009 public int getFontStyle()
1015 public void setFontName(String name)
1021 public void setFontSize(int size)
1028 public void setFontStyle(int style)
1034 public int getIdWidth()
1041 * the idWidth to set
1044 public void setIdWidth(int idWidth)
1046 this.idWidth = idWidth;
1050 * @return the centreColumnLabels
1053 public boolean isCentreColumnLabels()
1055 return centreColumnLabels;
1059 * @param centreColumnLabels
1060 * the centreColumnLabels to set
1063 public void setCentreColumnLabels(boolean centreColumnLabels)
1065 this.centreColumnLabels = centreColumnLabels;
1069 * @return the showdbrefs
1072 public boolean isShowDBRefs()
1079 * the showdbrefs to set
1082 public void setShowDBRefs(boolean showdbrefs)
1084 this.showdbrefs = showdbrefs;
1088 * @return the shownpfeats
1091 public boolean isShowNPFeats()
1097 * @param shownpfeats
1098 * the shownpfeats to set
1101 public void setShowNPFeats(boolean shownpfeats)
1103 this.shownpfeats = shownpfeats;
1107 public boolean isScaleProteinAsCdna()
1109 return this.scaleProteinAsCdna;
1113 public void setScaleProteinAsCdna(boolean b)
1115 this.scaleProteinAsCdna = b;
1119 public boolean isProteinFontAsCdna()
1121 return proteinFontAsCdna;
1125 public void setProteinFontAsCdna(boolean b)
1127 proteinFontAsCdna = b;
1131 public void setShowComplementFeatures(boolean b)
1133 showComplementFeatures = b;
1137 public boolean isShowComplementFeatures()
1139 return showComplementFeatures;
1143 public void setShowComplementFeaturesOnTop(boolean b)
1145 showComplementFeaturesOnTop = b;
1149 public boolean isShowComplementFeaturesOnTop()
1151 return showComplementFeaturesOnTop;
1155 public void setShowSequenceFeatureCounts(boolean show)
1157 showSequenceFeatureCounts = show;
1161 public boolean isShowSequenceFeatureCounts()
1163 return showSequenceFeatureCounts;