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 setShowSequenceFeatureCounts(vs.isShowSequenceFeatureCounts());
223 setShowComplementFeatures(vs.isShowComplementFeatures());
224 setShowComplementFeaturesOnTop(vs.isShowComplementFeaturesOnTop());
225 setShowText(vs.getShowText());
226 setShowUnconserved(vs.getShowUnconserved());
227 setTextColour(vs.getTextColour());
228 setTextColour2(vs.getTextColour2());
229 setThreshold(vs.getThreshold());
230 setThresholdTextColour(vs.getThresholdTextColour());
231 setUpperCasebold(vs.isUpperCasebold());
232 setWrapAlignment(vs.getWrapAlignment());
233 setWrappedWidth(vs.getWrappedWidth());
234 // ViewStyle.configureFrom(this, viewStyle);
242 * Returns true if all attributes of the ViewStyles have the same value
245 public boolean equals(Object other)
247 if (other == null || !(other instanceof ViewStyle))
251 ViewStyle vs = (ViewStyle) other;
253 boolean match = (getAbovePIDThreshold() == vs.getAbovePIDThreshold()
254 && isCentreColumnLabels() == vs.isCentreColumnLabels()
255 && getCharHeight() == vs.getCharHeight()
256 && getCharWidth() == vs.getCharWidth()
257 && getColourAppliesToAllGroups() == vs
258 .getColourAppliesToAllGroups()
259 && isColourByReferenceSeq() == vs.isColourByReferenceSeq()
260 && getColourText() == vs.getColourText()
261 && isConservationColourSelected() == vs
262 .isConservationColourSelected()
263 && getConservationSelected() == vs.getConservationSelected()
264 && isDisplayReferenceSeq() == vs.isDisplayReferenceSeq()
265 && getFontSize() == vs.getFontSize()
266 && getFontStyle() == vs.getFontStyle()
267 && getIdWidth() == vs.getIdWidth()
268 && getIncrement() == vs.getIncrement()
269 && isRenderGaps() == vs.isRenderGaps()
270 && isRightAlignIds() == vs.isRightAlignIds()
271 && getScaleAboveWrapped() == vs.getScaleAboveWrapped()
272 && getScaleLeftWrapped() == vs.getScaleLeftWrapped()
273 && isScaleProteinAsCdna() == vs.isScaleProteinAsCdna()
274 && isProteinFontAsCdna() == vs.isProteinFontAsCdna()
275 && getScaleRightWrapped() == vs.getScaleRightWrapped()
276 && isSeqNameItalics() == vs.isSeqNameItalics()
277 && isShowAnnotation() == vs.isShowAnnotation()
278 && getShowBoxes() == vs.getShowBoxes()
279 && isShowColourText() == vs.isShowColourText()
280 && isShowDBRefs() == vs.isShowDBRefs()
281 && getShowHiddenMarkers() == vs.getShowHiddenMarkers()
282 && getShowJVSuffix() == vs.getShowJVSuffix()
283 && isShowNPFeats() == vs.isShowNPFeats()
284 && isShowSequenceFeaturesHeight() == vs
285 .isShowSequenceFeaturesHeight()
286 && isShowSequenceFeatureCounts() == vs
287 .isShowSequenceFeatureCounts()
288 && isShowSequenceFeatures() == vs.isShowSequenceFeatures()
289 && isShowComplementFeatures() == vs.isShowComplementFeatures()
290 && isShowComplementFeaturesOnTop() == vs
291 .isShowComplementFeaturesOnTop()
292 && getShowText() == vs.getShowText()
293 && getShowUnconserved() == vs.getShowUnconserved()
294 && getThreshold() == vs.getThreshold()
295 && getThresholdTextColour() == vs.getThresholdTextColour()
296 && isUpperCasebold() == vs.isUpperCasebold()
297 && getWrapAlignment() == vs.getWrapAlignment()
298 && getWrappedWidth() == vs.getWrappedWidth());
300 * and compare non-primitive types; syntax below will match null with null
303 match = match && String.valueOf(getFontName())
304 .equals(String.valueOf(vs.getFontName()));
305 match = match && String.valueOf(getTextColour())
306 .equals(String.valueOf(vs.getTextColour()));
307 match = match && String.valueOf(getTextColour2())
308 .equals(String.valueOf(vs.getTextColour2()));
310 // return equivalent(this, (ViewStyle) other);
314 * Overridden to ensure that whenever vs1.equals(vs2) then vs1.hashCode() ==
318 public int hashCode()
321 * No need to include all properties, just a selection...
325 // Boolean.hashCode returns 1231 or 1237
326 hash += m++ * Boolean.valueOf(this.abovePIDThreshold).hashCode();
327 hash += m++ * Boolean.valueOf(this.centreColumnLabels).hashCode();
328 hash += m++ * Boolean.valueOf(this.colourAppliesToAllGroups).hashCode();
329 hash += m++ * Boolean.valueOf(this.displayReferenceSeq).hashCode();
330 hash += m++ * Boolean.valueOf(this.renderGaps).hashCode();
331 hash += m++ * Boolean.valueOf(this.rightAlignIds).hashCode();
332 hash += m++ * Boolean.valueOf(this.scaleProteinAsCdna).hashCode();
333 hash += m++ * Boolean.valueOf(this.scaleRightWrapped).hashCode();
334 hash += m++ * Boolean.valueOf(this.seqNameItalics).hashCode();
335 hash += m++ * Boolean.valueOf(this.showAnnotation).hashCode();
336 hash += m++ * Boolean.valueOf(this.showBoxes).hashCode();
337 hash += m++ * Boolean.valueOf(this.showdbrefs).hashCode();
338 hash += m++ * Boolean.valueOf(this.showJVSuffix).hashCode();
339 hash += m++ * Boolean.valueOf(this.showSequenceFeatures).hashCode();
340 hash += m++ * Boolean.valueOf(this.showUnconserved).hashCode();
341 hash += m++ * Boolean.valueOf(this.wrapAlignment).hashCode();
342 hash += m++ * this.charHeight;
343 hash += m++ * this.charWidth;
344 hash += m++ * fontSize;
345 hash += m++ * fontStyle;
346 hash += m++ * idWidth;
347 hash += String.valueOf(this.fontName).hashCode();
352 * @return the upperCasebold
355 public boolean isUpperCasebold()
357 return upperCasebold;
361 * @param upperCasebold
362 * the upperCasebold to set
365 public void setUpperCasebold(boolean upperCasebold)
367 this.upperCasebold = upperCasebold;
373 boolean wrapAlignment = false;
376 * number columns in wrapped alignment
380 private int fontStyle;
382 private boolean showComplementFeatures;
384 private boolean showComplementFeaturesOnTop;
389 * @return true if percent identity threshold is applied to shading
392 public boolean getAbovePIDThreshold()
394 return abovePIDThreshold;
400 * @return DOCUMENT ME!
403 public int getCharHeight()
411 * @return DOCUMENT ME!
414 public int getCharWidth()
422 * @return flag indicating if colourchanges propagated to all groups
425 public boolean getColourAppliesToAllGroups()
427 return colourAppliesToAllGroups;
433 * @return DOCUMENT ME!
436 public boolean getColourText()
438 return showColourText;
444 * @return true if conservation based shading is enabled
447 public boolean getConservationSelected()
449 return conservationColourSelected;
455 * @return get scalar for bleaching colourschemes by conservation
458 public int getIncrement()
466 * @return DOCUMENT ME!
469 public boolean getScaleAboveWrapped()
471 return scaleAboveWrapped;
477 * @return DOCUMENT ME!
480 public boolean getScaleLeftWrapped()
482 return scaleLeftWrapped;
488 * @return DOCUMENT ME!
491 public boolean getScaleRightWrapped()
493 return scaleRightWrapped;
499 * @return DOCUMENT ME!
502 public boolean getShowBoxes()
508 public boolean getShowHiddenMarkers()
510 return showHiddenMarkers;
516 * @return DOCUMENT ME!
519 public boolean getShowJVSuffix()
527 * @return DOCUMENT ME!
530 public boolean getShowText()
536 public boolean getShowUnconserved()
538 return showUnconserved;
542 * @return the textColour
545 public Color getTextColour()
551 * @return the textColour2
554 public Color getTextColour2()
562 * @return DOCUMENT ME!
565 public int getThreshold()
571 * @return the thresholdTextColour
574 public int getThresholdTextColour()
576 return thresholdTextColour;
582 * @return DOCUMENT ME!
585 public boolean getWrapAlignment()
587 return wrapAlignment;
593 * @return DOCUMENT ME!
596 public int getWrappedWidth()
602 public boolean isColourByReferenceSeq()
604 return colourByReferenceSeq;
608 * @return the conservationColourSelected
611 public boolean isConservationColourSelected()
613 return conservationColourSelected;
617 public boolean isDisplayReferenceSeq()
619 return displayReferenceSeq;
623 * @return the renderGaps
626 public boolean isRenderGaps()
632 public boolean isRightAlignIds()
634 return rightAlignIds;
638 * @return the seqNameItalics
641 public boolean isSeqNameItalics()
643 return seqNameItalics;
647 public boolean isShowAnnotation()
649 return showAnnotation;
653 * @return the showColourText
656 public boolean isShowColourText()
658 return showColourText;
662 * @return the showSeqFeaturesHeight
665 public boolean isShowSequenceFeaturesHeight()
667 return showSeqFeaturesHeight;
671 public boolean isShowSequenceFeatures()
673 return showSequenceFeatures;
681 * indicate if percent identity threshold is applied to shading
684 public void setAbovePIDThreshold(boolean b)
686 abovePIDThreshold = b;
696 public void setCharHeight(int h)
708 public void setCharWidth(int w)
715 * indicating if subsequent colourscheme changes will be propagated
719 public void setColourAppliesToAllGroups(boolean b)
721 colourAppliesToAllGroups = b;
725 public void setColourByReferenceSeq(boolean colourByReferenceSeq)
727 this.colourByReferenceSeq = colourByReferenceSeq;
737 public void setColourText(boolean state)
739 showColourText = state;
743 * @param conservationColourSelected
744 * the conservationColourSelected to set
747 public void setConservationColourSelected(
748 boolean conservationColourSelected)
750 this.conservationColourSelected = conservationColourSelected;
757 * enable conservation based shading
760 public void setConservationSelected(boolean b)
762 conservationColourSelected = b;
766 public void setDisplayReferenceSeq(boolean displayReferenceSeq)
768 this.displayReferenceSeq = displayReferenceSeq;
774 * set the scalar for bleaching colourschemes according to degree of
778 public void setIncrement(int inc)
790 public void setRenderGaps(boolean state)
796 public void setRightAlignIds(boolean rightAlignIds)
798 this.rightAlignIds = rightAlignIds;
808 public void setScaleAboveWrapped(boolean b)
810 scaleAboveWrapped = b;
820 public void setScaleLeftWrapped(boolean b)
822 scaleLeftWrapped = b;
828 * @param scaleRightWrapped
833 public void setScaleRightWrapped(boolean b)
835 scaleRightWrapped = b;
839 public void setSeqNameItalics(boolean italics)
841 seqNameItalics = italics;
845 public void setShowAnnotation(boolean b)
857 public void setShowBoxes(boolean state)
863 * @param showColourText
864 * the showColourText to set
867 public void setShowColourText(boolean showColourText)
869 this.showColourText = showColourText;
873 public void setShowHiddenMarkers(boolean show)
875 showHiddenMarkers = show;
885 public void setShowJVSuffix(boolean b)
891 public void setShowSequenceFeaturesHeight(boolean selected)
893 showSeqFeaturesHeight = selected;
901 * features are displayed if true
904 public void setShowSequenceFeatures(boolean b)
906 showSequenceFeatures = b;
916 public void setShowText(boolean state)
922 public void setShowUnconserved(boolean showunconserved)
924 showUnconserved = showunconserved;
929 * the textColour to set
932 public void setTextColour(Color textColour)
934 this.textColour = textColour;
939 * the textColour2 to set
942 public void setTextColour2(Color textColour2)
944 this.textColour2 = textColour2;
954 public void setThreshold(int thresh)
960 * @param thresholdTextColour
961 * the thresholdTextColour to set
964 public void setThresholdTextColour(int thresholdTextColour)
966 this.thresholdTextColour = thresholdTextColour;
976 public void setWrapAlignment(boolean state)
978 wrapAlignment = state;
988 public void setWrappedWidth(int w)
990 this.wrappedWidth = w;
994 public boolean sameStyle(ViewStyleI that)
996 return this.equals(that);
1000 public String getFontName()
1006 public int getFontSize()
1012 public int getFontStyle()
1018 public void setFontName(String name)
1024 public void setFontSize(int size)
1031 public void setFontStyle(int style)
1037 public int getIdWidth()
1044 * the idWidth to set
1047 public void setIdWidth(int idWidth)
1049 this.idWidth = idWidth;
1053 * @return the centreColumnLabels
1056 public boolean isCentreColumnLabels()
1058 return centreColumnLabels;
1062 * @param centreColumnLabels
1063 * the centreColumnLabels to set
1066 public void setCentreColumnLabels(boolean centreColumnLabels)
1068 this.centreColumnLabels = centreColumnLabels;
1072 * @return the showdbrefs
1075 public boolean isShowDBRefs()
1082 * the showdbrefs to set
1085 public void setShowDBRefs(boolean showdbrefs)
1087 this.showdbrefs = showdbrefs;
1091 * @return the shownpfeats
1094 public boolean isShowNPFeats()
1100 * @param shownpfeats
1101 * the shownpfeats to set
1104 public void setShowNPFeats(boolean shownpfeats)
1106 this.shownpfeats = shownpfeats;
1110 public boolean isScaleProteinAsCdna()
1112 return this.scaleProteinAsCdna;
1116 public void setScaleProteinAsCdna(boolean b)
1118 this.scaleProteinAsCdna = b;
1122 public boolean isProteinFontAsCdna()
1124 return proteinFontAsCdna;
1128 public void setProteinFontAsCdna(boolean b)
1130 proteinFontAsCdna = b;
1134 public void setShowComplementFeatures(boolean b)
1136 showComplementFeatures = b;
1140 public boolean isShowComplementFeatures()
1142 return showComplementFeatures;
1146 public void setShowComplementFeaturesOnTop(boolean b)
1148 showComplementFeaturesOnTop = b;
1152 public boolean isShowComplementFeaturesOnTop()
1154 return showComplementFeaturesOnTop;
1158 public void setShowSequenceFeatureCounts(boolean show)
1160 showSequenceFeatureCounts = show;
1164 public boolean isShowSequenceFeatureCounts()
1166 return showSequenceFeatureCounts;