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 jalview.api.ViewStyleI;
25 import java.awt.Color;
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 setShowText(vs.getShowText());
217 setShowUnconserved(vs.getShowUnconserved());
218 setTextColour(vs.getTextColour());
219 setTextColour2(vs.getTextColour2());
220 setThreshold(vs.getThreshold());
221 setThresholdTextColour(vs.getThresholdTextColour());
222 setUpperCasebold(vs.isUpperCasebold());
223 setWrapAlignment(vs.getWrapAlignment());
224 setWrappedWidth(vs.getWrappedWidth());
225 // ViewStyle.configureFrom(this, viewStyle);
233 * Returns true if all attributes of the ViewStyles have the same value
236 public boolean equals(Object other)
238 if (other == null || !(other instanceof ViewStyle))
242 ViewStyle vs = (ViewStyle) other;
244 boolean match = (getAbovePIDThreshold() == vs.getAbovePIDThreshold()
245 && isCentreColumnLabels() == vs.isCentreColumnLabels()
246 && getCharHeight() == vs.getCharHeight()
247 && getCharWidth() == vs.getCharWidth()
248 && getColourAppliesToAllGroups() == vs
249 .getColourAppliesToAllGroups()
250 && isColourByReferenceSeq() == vs.isColourByReferenceSeq()
251 && getColourText() == vs.getColourText()
252 && isConservationColourSelected() == vs
253 .isConservationColourSelected()
254 && getConservationSelected() == vs.getConservationSelected()
255 && isDisplayReferenceSeq() == vs.isDisplayReferenceSeq()
256 && getFontSize() == vs.getFontSize()
257 && getFontStyle() == vs.getFontStyle()
258 && getIdWidth() == vs.getIdWidth()
259 && getIncrement() == vs.getIncrement()
260 && isRenderGaps() == vs.isRenderGaps()
261 && isRightAlignIds() == vs.isRightAlignIds()
262 && getScaleAboveWrapped() == vs.getScaleAboveWrapped()
263 && getScaleLeftWrapped() == vs.getScaleLeftWrapped()
264 && isScaleProteinAsCdna() == vs.isScaleProteinAsCdna()
265 && isProteinFontAsCdna() == vs.isProteinFontAsCdna()
266 && getScaleRightWrapped() == vs.getScaleRightWrapped()
267 && isSeqNameItalics() == vs.isSeqNameItalics()
268 && isShowAnnotation() == vs.isShowAnnotation()
269 && getShowBoxes() == vs.getShowBoxes()
270 && isShowColourText() == vs.isShowColourText()
271 && isShowDBRefs() == vs.isShowDBRefs()
272 && getShowHiddenMarkers() == vs.getShowHiddenMarkers()
273 && getShowJVSuffix() == vs.getShowJVSuffix()
274 && isShowNPFeats() == vs.isShowNPFeats()
275 && isShowSequenceFeaturesHeight() == vs
276 .isShowSequenceFeaturesHeight()
277 && isShowSequenceFeatures() == vs.isShowSequenceFeatures()
278 && getShowText() == vs.getShowText()
279 && getShowUnconserved() == vs.getShowUnconserved()
280 && getThreshold() == vs.getThreshold()
281 && getThresholdTextColour() == vs.getThresholdTextColour()
282 && isUpperCasebold() == vs.isUpperCasebold()
283 && getWrapAlignment() == vs.getWrapAlignment() && getWrappedWidth() == vs
286 * and compare non-primitive types; syntax below will match null with null
290 && String.valueOf(getFontName()).equals(
291 String.valueOf(vs.getFontName()));
293 && String.valueOf(getTextColour()).equals(
294 String.valueOf(vs.getTextColour()));
296 && String.valueOf(getTextColour2()).equals(
297 String.valueOf(vs.getTextColour2()));
299 // return equivalent(this, (ViewStyle) other);
303 * Overridden to ensure that whenever vs1.equals(vs2) then vs1.hashCode() ==
307 public int hashCode()
310 * No need to include all properties, just a selection...
314 // Boolean.hashCode returns 1231 or 1237
315 hash += m++ * Boolean.valueOf(this.abovePIDThreshold).hashCode();
316 hash += m++ * Boolean.valueOf(this.centreColumnLabels).hashCode();
317 hash += m++ * Boolean.valueOf(this.colourAppliesToAllGroups).hashCode();
318 hash += m++ * Boolean.valueOf(this.displayReferenceSeq).hashCode();
319 hash += m++ * Boolean.valueOf(this.renderGaps).hashCode();
320 hash += m++ * Boolean.valueOf(this.rightAlignIds).hashCode();
321 hash += m++ * Boolean.valueOf(this.scaleProteinAsCdna).hashCode();
322 hash += m++ * Boolean.valueOf(this.scaleRightWrapped).hashCode();
323 hash += m++ * Boolean.valueOf(this.seqNameItalics).hashCode();
324 hash += m++ * Boolean.valueOf(this.showAnnotation).hashCode();
325 hash += m++ * Boolean.valueOf(this.showBoxes).hashCode();
326 hash += m++ * Boolean.valueOf(this.showdbrefs).hashCode();
327 hash += m++ * Boolean.valueOf(this.showJVSuffix).hashCode();
328 hash += m++ * Boolean.valueOf(this.showSequenceFeatures).hashCode();
329 hash += m++ * Boolean.valueOf(this.showUnconserved).hashCode();
330 hash += m++ * Boolean.valueOf(this.wrapAlignment).hashCode();
331 hash += m++ * this.charHeight;
332 hash += m++ * this.charWidth;
333 hash += m++ * fontSize;
334 hash += m++ * fontStyle;
335 hash += m++ * idWidth;
336 hash += String.valueOf(this.fontName).hashCode();
341 * @return the upperCasebold
344 public boolean isUpperCasebold()
346 return upperCasebold;
350 * @param upperCasebold
351 * the upperCasebold to set
354 public void setUpperCasebold(boolean upperCasebold)
356 this.upperCasebold = upperCasebold;
362 boolean wrapAlignment = false;
365 * number columns in wrapped alignment
369 private int fontStyle;
374 * @return true if percent identity threshold is applied to shading
377 public boolean getAbovePIDThreshold()
379 return abovePIDThreshold;
385 * @return DOCUMENT ME!
388 public int getCharHeight()
396 * @return DOCUMENT ME!
399 public int getCharWidth()
407 * @return flag indicating if colourchanges propagated to all groups
410 public boolean getColourAppliesToAllGroups()
412 return colourAppliesToAllGroups;
418 * @return DOCUMENT ME!
421 public boolean getColourText()
423 return showColourText;
429 * @return true if conservation based shading is enabled
432 public boolean getConservationSelected()
434 return conservationColourSelected;
440 * @return get scalar for bleaching colourschemes by conservation
443 public int getIncrement()
451 * @return DOCUMENT ME!
454 public boolean getScaleAboveWrapped()
456 return scaleAboveWrapped;
462 * @return DOCUMENT ME!
465 public boolean getScaleLeftWrapped()
467 return scaleLeftWrapped;
473 * @return DOCUMENT ME!
476 public boolean getScaleRightWrapped()
478 return scaleRightWrapped;
484 * @return DOCUMENT ME!
487 public boolean getShowBoxes()
493 public boolean getShowHiddenMarkers()
495 return showHiddenMarkers;
501 * @return DOCUMENT ME!
504 public boolean getShowJVSuffix()
512 * @return DOCUMENT ME!
515 public boolean getShowText()
521 public boolean getShowUnconserved()
523 return showUnconserved;
527 * @return the textColour
530 public Color getTextColour()
536 * @return the textColour2
539 public Color getTextColour2()
547 * @return DOCUMENT ME!
550 public int getThreshold()
556 * @return the thresholdTextColour
559 public int getThresholdTextColour()
561 return thresholdTextColour;
567 * @return DOCUMENT ME!
570 public boolean getWrapAlignment()
572 return wrapAlignment;
578 * @return DOCUMENT ME!
581 public int getWrappedWidth()
587 public boolean isColourByReferenceSeq()
589 return colourByReferenceSeq;
593 * @return the conservationColourSelected
596 public boolean isConservationColourSelected()
598 return conservationColourSelected;
602 public boolean isDisplayReferenceSeq()
604 return displayReferenceSeq;
608 * @return the renderGaps
611 public boolean isRenderGaps()
617 public boolean isRightAlignIds()
619 return rightAlignIds;
623 * @return the seqNameItalics
626 public boolean isSeqNameItalics()
628 return seqNameItalics;
632 public boolean isShowAnnotation()
634 return showAnnotation;
638 * @return the showColourText
641 public boolean isShowColourText()
643 return showColourText;
647 * @return the showSeqFeaturesHeight
650 public boolean isShowSequenceFeaturesHeight()
652 return showSeqFeaturesHeight;
656 public boolean isShowSequenceFeatures()
658 return showSequenceFeatures;
666 * indicate if percent identity threshold is applied to shading
669 public void setAbovePIDThreshold(boolean b)
671 abovePIDThreshold = b;
681 public void setCharHeight(int h)
693 public void setCharWidth(int w)
700 * indicating if subsequent colourscheme changes will be propagated
704 public void setColourAppliesToAllGroups(boolean b)
706 colourAppliesToAllGroups = b;
710 public void setColourByReferenceSeq(boolean colourByReferenceSeq)
712 this.colourByReferenceSeq = colourByReferenceSeq;
722 public void setColourText(boolean state)
724 showColourText = state;
728 * @param conservationColourSelected
729 * the conservationColourSelected to set
732 public void setConservationColourSelected(
733 boolean conservationColourSelected)
735 this.conservationColourSelected = conservationColourSelected;
742 * enable conservation based shading
745 public void setConservationSelected(boolean b)
747 conservationColourSelected = b;
751 public void setDisplayReferenceSeq(boolean displayReferenceSeq)
753 this.displayReferenceSeq = displayReferenceSeq;
759 * set the scalar for bleaching colourschemes according to degree of
763 public void setIncrement(int inc)
775 public void setRenderGaps(boolean state)
781 public void setRightAlignIds(boolean rightAlignIds)
783 this.rightAlignIds = rightAlignIds;
793 public void setScaleAboveWrapped(boolean b)
795 scaleAboveWrapped = b;
805 public void setScaleLeftWrapped(boolean b)
807 scaleLeftWrapped = b;
813 * @param scaleRightWrapped
818 public void setScaleRightWrapped(boolean b)
820 scaleRightWrapped = b;
824 public void setSeqNameItalics(boolean italics)
826 seqNameItalics = italics;
830 public void setShowAnnotation(boolean b)
842 public void setShowBoxes(boolean state)
848 * @param showColourText
849 * the showColourText to set
852 public void setShowColourText(boolean showColourText)
854 this.showColourText = showColourText;
858 public void setShowHiddenMarkers(boolean show)
860 showHiddenMarkers = show;
870 public void setShowJVSuffix(boolean b)
876 public void setShowSequenceFeaturesHeight(boolean selected)
878 showSeqFeaturesHeight = selected;
886 * features are displayed if true
889 public void setShowSequenceFeatures(boolean b)
891 showSequenceFeatures = b;
901 public void setShowText(boolean state)
907 public void setShowUnconserved(boolean showunconserved)
909 showUnconserved = showunconserved;
914 * the textColour to set
917 public void setTextColour(Color textColour)
919 this.textColour = textColour;
924 * the textColour2 to set
927 public void setTextColour2(Color textColour2)
929 this.textColour2 = textColour2;
939 public void setThreshold(int thresh)
945 * @param thresholdTextColour
946 * the thresholdTextColour to set
949 public void setThresholdTextColour(int thresholdTextColour)
951 this.thresholdTextColour = thresholdTextColour;
961 public void setWrapAlignment(boolean state)
963 wrapAlignment = state;
973 public void setWrappedWidth(int w)
975 this.wrappedWidth = w;
979 public boolean sameStyle(ViewStyleI that)
981 return this.equals(that);
985 public String getFontName()
991 public int getFontSize()
997 public int getFontStyle()
1003 public void setFontName(String name)
1009 public void setFontSize(int size)
1016 public void setFontStyle(int style)
1022 public int getIdWidth()
1029 * the idWidth to set
1032 public void setIdWidth(int idWidth)
1034 this.idWidth = idWidth;
1038 * @return the centreColumnLabels
1041 public boolean isCentreColumnLabels()
1043 return centreColumnLabels;
1047 * @param centreColumnLabels
1048 * the centreColumnLabels to set
1051 public void setCentreColumnLabels(boolean centreColumnLabels)
1053 this.centreColumnLabels = centreColumnLabels;
1057 * @return the showdbrefs
1060 public boolean isShowDBRefs()
1067 * the showdbrefs to set
1070 public void setShowDBRefs(boolean showdbrefs)
1072 this.showdbrefs = showdbrefs;
1076 * @return the shownpfeats
1079 public boolean isShowNPFeats()
1085 * @param shownpfeats
1086 * the shownpfeats to set
1089 public void setShowNPFeats(boolean shownpfeats)
1091 this.shownpfeats = shownpfeats;
1095 public boolean isScaleProteinAsCdna()
1097 return this.scaleProteinAsCdna;
1101 public void setScaleProteinAsCdna(boolean b)
1103 this.scaleProteinAsCdna = b;
1107 public boolean isProteinFontAsCdna()
1109 return proteinFontAsCdna;
1113 public void setProteinFontAsCdna(boolean b)
1115 proteinFontAsCdna = b;