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 sequence symbols
129 boolean showText = true;
132 * show non-conserved residues only
134 protected boolean showUnconserved = false;
136 Color textColour = Color.black;
138 Color textColour2 = Color.white;
141 * PID or consensus threshold
146 * threshold for switching between textColour & textColour2
148 int thresholdTextColour = 0;
151 * upper case characters in sequence are shown in bold
153 boolean upperCasebold = false;
156 * name of base font for view
158 private String fontName;
163 private int fontSize;
166 * If true, scale protein residues to 3 times width of cDNA bases (in
167 * SplitFrame views only)
169 private boolean scaleProteinAsCdna = true;
172 * if true, font changes to protein or cDNA are applied to both
173 * sides of a split screen
175 private boolean proteinFontAsCdna = true;
182 public ViewStyle(ViewStyleI vs)
184 setAbovePIDThreshold(vs.getAbovePIDThreshold());
185 setCentreColumnLabels(vs.isCentreColumnLabels());
186 setCharHeight(vs.getCharHeight());
187 setCharWidth(vs.getCharWidth());
188 setColourAppliesToAllGroups(vs.getColourAppliesToAllGroups());
189 setColourByReferenceSeq(vs.isColourByReferenceSeq());
190 setColourText(vs.getColourText());
191 setConservationColourSelected(vs.isConservationColourSelected());
192 setConservationSelected(vs.getConservationSelected());
193 setDisplayReferenceSeq(vs.isDisplayReferenceSeq());
194 setFontName(vs.getFontName());
195 setFontSize(vs.getFontSize());
196 setFontStyle(vs.getFontStyle());
197 setIdWidth(vs.getIdWidth());
198 setIncrement(vs.getIncrement());
199 setRenderGaps(vs.isRenderGaps());
200 setRightAlignIds(vs.isRightAlignIds());
201 setScaleAboveWrapped(vs.getScaleAboveWrapped());
202 setScaleLeftWrapped(vs.getScaleLeftWrapped());
203 setScaleProteinAsCdna(vs.isScaleProteinAsCdna());
204 setProteinFontAsCdna(vs.isProteinFontAsCdna());
205 setScaleRightWrapped(vs.getScaleRightWrapped());
206 setSeqNameItalics(vs.isSeqNameItalics());
207 setShowAnnotation(vs.isShowAnnotation());
208 setShowBoxes(vs.getShowBoxes());
209 setShowColourText(vs.isShowColourText());
210 setShowDBRefs(vs.isShowDBRefs());
211 setShowHiddenMarkers(vs.getShowHiddenMarkers());
212 setShowJVSuffix(vs.getShowJVSuffix());
213 setShowNPFeats(vs.isShowNPFeats());
214 setShowSequenceFeaturesHeight(vs.isShowSequenceFeaturesHeight());
215 setShowSequenceFeatures(vs.isShowSequenceFeatures());
216 setShowComplementFeatures(vs.isShowComplementFeatures());
217 setShowComplementFeaturesOnTop(vs.isShowComplementFeaturesOnTop());
218 setShowText(vs.getShowText());
219 setShowUnconserved(vs.getShowUnconserved());
220 setTextColour(vs.getTextColour());
221 setTextColour2(vs.getTextColour2());
222 setThreshold(vs.getThreshold());
223 setThresholdTextColour(vs.getThresholdTextColour());
224 setUpperCasebold(vs.isUpperCasebold());
225 setWrapAlignment(vs.getWrapAlignment());
226 setWrappedWidth(vs.getWrappedWidth());
227 // ViewStyle.configureFrom(this, viewStyle);
235 * Returns true if all attributes of the ViewStyles have the same value
238 public boolean equals(Object other)
240 if (other == null || !(other instanceof ViewStyle))
244 ViewStyle vs = (ViewStyle) other;
246 boolean match = (getAbovePIDThreshold() == vs.getAbovePIDThreshold()
247 && isCentreColumnLabels() == vs.isCentreColumnLabels()
248 && getCharHeight() == vs.getCharHeight()
249 && getCharWidth() == vs.getCharWidth()
250 && getColourAppliesToAllGroups() == vs
251 .getColourAppliesToAllGroups()
252 && isColourByReferenceSeq() == vs.isColourByReferenceSeq()
253 && getColourText() == vs.getColourText()
254 && isConservationColourSelected() == vs
255 .isConservationColourSelected()
256 && getConservationSelected() == vs.getConservationSelected()
257 && isDisplayReferenceSeq() == vs.isDisplayReferenceSeq()
258 && getFontSize() == vs.getFontSize()
259 && getFontStyle() == vs.getFontStyle()
260 && getIdWidth() == vs.getIdWidth()
261 && getIncrement() == vs.getIncrement()
262 && isRenderGaps() == vs.isRenderGaps()
263 && isRightAlignIds() == vs.isRightAlignIds()
264 && getScaleAboveWrapped() == vs.getScaleAboveWrapped()
265 && getScaleLeftWrapped() == vs.getScaleLeftWrapped()
266 && isScaleProteinAsCdna() == vs.isScaleProteinAsCdna()
267 && isProteinFontAsCdna() == vs.isProteinFontAsCdna()
268 && getScaleRightWrapped() == vs.getScaleRightWrapped()
269 && isSeqNameItalics() == vs.isSeqNameItalics()
270 && isShowAnnotation() == vs.isShowAnnotation()
271 && getShowBoxes() == vs.getShowBoxes()
272 && isShowColourText() == vs.isShowColourText()
273 && isShowDBRefs() == vs.isShowDBRefs()
274 && getShowHiddenMarkers() == vs.getShowHiddenMarkers()
275 && getShowJVSuffix() == vs.getShowJVSuffix()
276 && isShowNPFeats() == vs.isShowNPFeats()
277 && isShowSequenceFeaturesHeight() == vs
278 .isShowSequenceFeaturesHeight()
279 && isShowSequenceFeatures() == vs.isShowSequenceFeatures()
280 && isShowComplementFeatures() == vs.isShowComplementFeatures()
281 && isShowComplementFeaturesOnTop() == vs
282 .isShowComplementFeaturesOnTop()
283 && getShowText() == vs.getShowText()
284 && getShowUnconserved() == vs.getShowUnconserved()
285 && getThreshold() == vs.getThreshold()
286 && getThresholdTextColour() == vs.getThresholdTextColour()
287 && isUpperCasebold() == vs.isUpperCasebold()
288 && getWrapAlignment() == vs.getWrapAlignment()
289 && getWrappedWidth() == vs.getWrappedWidth());
291 * and compare non-primitive types; syntax below will match null with null
294 match = match && String.valueOf(getFontName())
295 .equals(String.valueOf(vs.getFontName()));
296 match = match && String.valueOf(getTextColour())
297 .equals(String.valueOf(vs.getTextColour()));
298 match = match && String.valueOf(getTextColour2())
299 .equals(String.valueOf(vs.getTextColour2()));
301 // return equivalent(this, (ViewStyle) other);
305 * Overridden to ensure that whenever vs1.equals(vs2) then vs1.hashCode() ==
309 public int hashCode()
312 * No need to include all properties, just a selection...
316 // Boolean.hashCode returns 1231 or 1237
317 hash += m++ * Boolean.valueOf(this.abovePIDThreshold).hashCode();
318 hash += m++ * Boolean.valueOf(this.centreColumnLabels).hashCode();
319 hash += m++ * Boolean.valueOf(this.colourAppliesToAllGroups).hashCode();
320 hash += m++ * Boolean.valueOf(this.displayReferenceSeq).hashCode();
321 hash += m++ * Boolean.valueOf(this.renderGaps).hashCode();
322 hash += m++ * Boolean.valueOf(this.rightAlignIds).hashCode();
323 hash += m++ * Boolean.valueOf(this.scaleProteinAsCdna).hashCode();
324 hash += m++ * Boolean.valueOf(this.scaleRightWrapped).hashCode();
325 hash += m++ * Boolean.valueOf(this.seqNameItalics).hashCode();
326 hash += m++ * Boolean.valueOf(this.showAnnotation).hashCode();
327 hash += m++ * Boolean.valueOf(this.showBoxes).hashCode();
328 hash += m++ * Boolean.valueOf(this.showdbrefs).hashCode();
329 hash += m++ * Boolean.valueOf(this.showJVSuffix).hashCode();
330 hash += m++ * Boolean.valueOf(this.showSequenceFeatures).hashCode();
331 hash += m++ * Boolean.valueOf(this.showUnconserved).hashCode();
332 hash += m++ * Boolean.valueOf(this.wrapAlignment).hashCode();
333 hash += m++ * this.charHeight;
334 hash += m++ * this.charWidth;
335 hash += m++ * fontSize;
336 hash += m++ * fontStyle;
337 hash += m++ * idWidth;
338 hash += String.valueOf(this.fontName).hashCode();
343 * @return the upperCasebold
346 public boolean isUpperCasebold()
348 return upperCasebold;
352 * @param upperCasebold
353 * the upperCasebold to set
356 public void setUpperCasebold(boolean upperCasebold)
358 this.upperCasebold = upperCasebold;
364 boolean wrapAlignment = false;
367 * number columns in wrapped alignment
371 private int fontStyle;
373 private boolean showComplementFeatures;
375 private boolean showComplementFeaturesOnTop;
380 * @return true if percent identity threshold is applied to shading
383 public boolean getAbovePIDThreshold()
385 return abovePIDThreshold;
391 * @return DOCUMENT ME!
394 public int getCharHeight()
402 * @return DOCUMENT ME!
405 public int getCharWidth()
413 * @return flag indicating if colourchanges propagated to all groups
416 public boolean getColourAppliesToAllGroups()
418 return colourAppliesToAllGroups;
424 * @return DOCUMENT ME!
427 public boolean getColourText()
429 return showColourText;
435 * @return true if conservation based shading is enabled
438 public boolean getConservationSelected()
440 return conservationColourSelected;
446 * @return get scalar for bleaching colourschemes by conservation
449 public int getIncrement()
457 * @return DOCUMENT ME!
460 public boolean getScaleAboveWrapped()
462 return scaleAboveWrapped;
468 * @return DOCUMENT ME!
471 public boolean getScaleLeftWrapped()
473 return scaleLeftWrapped;
479 * @return DOCUMENT ME!
482 public boolean getScaleRightWrapped()
484 return scaleRightWrapped;
490 * @return DOCUMENT ME!
493 public boolean getShowBoxes()
499 public boolean getShowHiddenMarkers()
501 return showHiddenMarkers;
507 * @return DOCUMENT ME!
510 public boolean getShowJVSuffix()
518 * @return DOCUMENT ME!
521 public boolean getShowText()
527 public boolean getShowUnconserved()
529 return showUnconserved;
533 * @return the textColour
536 public Color getTextColour()
542 * @return the textColour2
545 public Color getTextColour2()
553 * @return DOCUMENT ME!
556 public int getThreshold()
562 * @return the thresholdTextColour
565 public int getThresholdTextColour()
567 return thresholdTextColour;
573 * @return DOCUMENT ME!
576 public boolean getWrapAlignment()
578 return wrapAlignment;
584 * @return DOCUMENT ME!
587 public int getWrappedWidth()
593 public boolean isColourByReferenceSeq()
595 return colourByReferenceSeq;
599 * @return the conservationColourSelected
602 public boolean isConservationColourSelected()
604 return conservationColourSelected;
608 public boolean isDisplayReferenceSeq()
610 return displayReferenceSeq;
614 * @return the renderGaps
617 public boolean isRenderGaps()
623 public boolean isRightAlignIds()
625 return rightAlignIds;
629 * @return the seqNameItalics
632 public boolean isSeqNameItalics()
634 return seqNameItalics;
638 public boolean isShowAnnotation()
640 return showAnnotation;
644 * @return the showColourText
647 public boolean isShowColourText()
649 return showColourText;
653 * @return the showSeqFeaturesHeight
656 public boolean isShowSequenceFeaturesHeight()
658 return showSeqFeaturesHeight;
662 public boolean isShowSequenceFeatures()
664 return showSequenceFeatures;
672 * indicate if percent identity threshold is applied to shading
675 public void setAbovePIDThreshold(boolean b)
677 abovePIDThreshold = b;
687 public void setCharHeight(int h)
699 public void setCharWidth(int w)
706 * indicating if subsequent colourscheme changes will be propagated
710 public void setColourAppliesToAllGroups(boolean b)
712 colourAppliesToAllGroups = b;
716 public void setColourByReferenceSeq(boolean colourByReferenceSeq)
718 this.colourByReferenceSeq = colourByReferenceSeq;
728 public void setColourText(boolean state)
730 showColourText = state;
734 * @param conservationColourSelected
735 * the conservationColourSelected to set
738 public void setConservationColourSelected(
739 boolean conservationColourSelected)
741 this.conservationColourSelected = conservationColourSelected;
748 * enable conservation based shading
751 public void setConservationSelected(boolean b)
753 conservationColourSelected = b;
757 public void setDisplayReferenceSeq(boolean displayReferenceSeq)
759 this.displayReferenceSeq = displayReferenceSeq;
765 * set the scalar for bleaching colourschemes according to degree of
769 public void setIncrement(int inc)
781 public void setRenderGaps(boolean state)
787 public void setRightAlignIds(boolean rightAlignIds)
789 this.rightAlignIds = rightAlignIds;
799 public void setScaleAboveWrapped(boolean b)
801 scaleAboveWrapped = b;
811 public void setScaleLeftWrapped(boolean b)
813 scaleLeftWrapped = b;
819 * @param scaleRightWrapped
824 public void setScaleRightWrapped(boolean b)
826 scaleRightWrapped = b;
830 public void setSeqNameItalics(boolean italics)
832 seqNameItalics = italics;
836 public void setShowAnnotation(boolean b)
848 public void setShowBoxes(boolean state)
854 * @param showColourText
855 * the showColourText to set
858 public void setShowColourText(boolean showColourText)
860 this.showColourText = showColourText;
864 public void setShowHiddenMarkers(boolean show)
866 showHiddenMarkers = show;
876 public void setShowJVSuffix(boolean b)
882 public void setShowSequenceFeaturesHeight(boolean selected)
884 showSeqFeaturesHeight = selected;
892 * features are displayed if true
895 public void setShowSequenceFeatures(boolean b)
897 showSequenceFeatures = b;
907 public void setShowText(boolean state)
913 public void setShowUnconserved(boolean showunconserved)
915 showUnconserved = showunconserved;
920 * the textColour to set
923 public void setTextColour(Color textColour)
925 this.textColour = textColour;
930 * the textColour2 to set
933 public void setTextColour2(Color textColour2)
935 this.textColour2 = textColour2;
945 public void setThreshold(int thresh)
951 * @param thresholdTextColour
952 * the thresholdTextColour to set
955 public void setThresholdTextColour(int thresholdTextColour)
957 this.thresholdTextColour = thresholdTextColour;
967 public void setWrapAlignment(boolean state)
969 wrapAlignment = state;
979 public void setWrappedWidth(int w)
981 this.wrappedWidth = w;
985 public boolean sameStyle(ViewStyleI that)
987 return this.equals(that);
991 public String getFontName()
997 public int getFontSize()
1003 public int getFontStyle()
1009 public void setFontName(String name)
1015 public void setFontSize(int size)
1022 public void setFontStyle(int style)
1028 public int getIdWidth()
1035 * the idWidth to set
1038 public void setIdWidth(int idWidth)
1040 this.idWidth = idWidth;
1044 * @return the centreColumnLabels
1047 public boolean isCentreColumnLabels()
1049 return centreColumnLabels;
1053 * @param centreColumnLabels
1054 * the centreColumnLabels to set
1057 public void setCentreColumnLabels(boolean centreColumnLabels)
1059 this.centreColumnLabels = centreColumnLabels;
1063 * @return the showdbrefs
1066 public boolean isShowDBRefs()
1073 * the showdbrefs to set
1076 public void setShowDBRefs(boolean showdbrefs)
1078 this.showdbrefs = showdbrefs;
1082 * @return the shownpfeats
1085 public boolean isShowNPFeats()
1091 * @param shownpfeats
1092 * the shownpfeats to set
1095 public void setShowNPFeats(boolean shownpfeats)
1097 this.shownpfeats = shownpfeats;
1101 public boolean isScaleProteinAsCdna()
1103 return this.scaleProteinAsCdna;
1107 public void setScaleProteinAsCdna(boolean b)
1109 this.scaleProteinAsCdna = b;
1113 public boolean isProteinFontAsCdna()
1115 return proteinFontAsCdna;
1119 public void setProteinFontAsCdna(boolean b)
1121 proteinFontAsCdna = b;
1125 public void setShowComplementFeatures(boolean b)
1127 showComplementFeatures = b;
1131 public boolean isShowComplementFeatures()
1133 return showComplementFeatures;
1137 public void setShowComplementFeaturesOnTop(boolean b)
1139 showComplementFeaturesOnTop = b;
1143 public boolean isShowComplementFeaturesOnTop()
1145 return showComplementFeaturesOnTop;