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 setShowComplementFeatures(vs.isShowComplementFeatures());
217 setShowText(vs.getShowText());
218 setShowUnconserved(vs.getShowUnconserved());
219 setTextColour(vs.getTextColour());
220 setTextColour2(vs.getTextColour2());
221 setThreshold(vs.getThreshold());
222 setThresholdTextColour(vs.getThresholdTextColour());
223 setUpperCasebold(vs.isUpperCasebold());
224 setWrapAlignment(vs.getWrapAlignment());
225 setWrappedWidth(vs.getWrappedWidth());
226 // ViewStyle.configureFrom(this, viewStyle);
234 * Returns true if all attributes of the ViewStyles have the same value
237 public boolean equals(Object other)
239 if (other == null || !(other instanceof ViewStyle))
243 ViewStyle vs = (ViewStyle) other;
245 boolean match = (getAbovePIDThreshold() == vs.getAbovePIDThreshold()
246 && isCentreColumnLabels() == vs.isCentreColumnLabels()
247 && getCharHeight() == vs.getCharHeight()
248 && getCharWidth() == vs.getCharWidth()
249 && getColourAppliesToAllGroups() == vs
250 .getColourAppliesToAllGroups()
251 && isColourByReferenceSeq() == vs.isColourByReferenceSeq()
252 && getColourText() == vs.getColourText()
253 && isConservationColourSelected() == vs
254 .isConservationColourSelected()
255 && getConservationSelected() == vs.getConservationSelected()
256 && isDisplayReferenceSeq() == vs.isDisplayReferenceSeq()
257 && getFontSize() == vs.getFontSize()
258 && getFontStyle() == vs.getFontStyle()
259 && getIdWidth() == vs.getIdWidth()
260 && getIncrement() == vs.getIncrement()
261 && isRenderGaps() == vs.isRenderGaps()
262 && isRightAlignIds() == vs.isRightAlignIds()
263 && getScaleAboveWrapped() == vs.getScaleAboveWrapped()
264 && getScaleLeftWrapped() == vs.getScaleLeftWrapped()
265 && isScaleProteinAsCdna() == vs.isScaleProteinAsCdna()
266 && isProteinFontAsCdna() == vs.isProteinFontAsCdna()
267 && getScaleRightWrapped() == vs.getScaleRightWrapped()
268 && isSeqNameItalics() == vs.isSeqNameItalics()
269 && isShowAnnotation() == vs.isShowAnnotation()
270 && getShowBoxes() == vs.getShowBoxes()
271 && isShowColourText() == vs.isShowColourText()
272 && isShowDBRefs() == vs.isShowDBRefs()
273 && getShowHiddenMarkers() == vs.getShowHiddenMarkers()
274 && getShowJVSuffix() == vs.getShowJVSuffix()
275 && isShowNPFeats() == vs.isShowNPFeats()
276 && isShowSequenceFeaturesHeight() == vs
277 .isShowSequenceFeaturesHeight()
278 && isShowSequenceFeatures() == vs.isShowSequenceFeatures()
279 && isShowComplementFeatures() == vs.isShowComplementFeatures()
280 && getShowText() == vs.getShowText()
281 && getShowUnconserved() == vs.getShowUnconserved()
282 && getThreshold() == vs.getThreshold()
283 && getThresholdTextColour() == vs.getThresholdTextColour()
284 && isUpperCasebold() == vs.isUpperCasebold()
285 && getWrapAlignment() == vs.getWrapAlignment()
286 && getWrappedWidth() == vs.getWrappedWidth());
288 * and compare non-primitive types; syntax below will match null with null
291 match = match && String.valueOf(getFontName())
292 .equals(String.valueOf(vs.getFontName()));
293 match = match && String.valueOf(getTextColour())
294 .equals(String.valueOf(vs.getTextColour()));
295 match = match && String.valueOf(getTextColour2())
296 .equals(String.valueOf(vs.getTextColour2()));
298 // return equivalent(this, (ViewStyle) other);
302 * Overridden to ensure that whenever vs1.equals(vs2) then vs1.hashCode() ==
306 public int hashCode()
309 * No need to include all properties, just a selection...
313 // Boolean.hashCode returns 1231 or 1237
314 hash += m++ * Boolean.valueOf(this.abovePIDThreshold).hashCode();
315 hash += m++ * Boolean.valueOf(this.centreColumnLabels).hashCode();
316 hash += m++ * Boolean.valueOf(this.colourAppliesToAllGroups).hashCode();
317 hash += m++ * Boolean.valueOf(this.displayReferenceSeq).hashCode();
318 hash += m++ * Boolean.valueOf(this.renderGaps).hashCode();
319 hash += m++ * Boolean.valueOf(this.rightAlignIds).hashCode();
320 hash += m++ * Boolean.valueOf(this.scaleProteinAsCdna).hashCode();
321 hash += m++ * Boolean.valueOf(this.scaleRightWrapped).hashCode();
322 hash += m++ * Boolean.valueOf(this.seqNameItalics).hashCode();
323 hash += m++ * Boolean.valueOf(this.showAnnotation).hashCode();
324 hash += m++ * Boolean.valueOf(this.showBoxes).hashCode();
325 hash += m++ * Boolean.valueOf(this.showdbrefs).hashCode();
326 hash += m++ * Boolean.valueOf(this.showJVSuffix).hashCode();
327 hash += m++ * Boolean.valueOf(this.showSequenceFeatures).hashCode();
328 hash += m++ * Boolean.valueOf(this.showUnconserved).hashCode();
329 hash += m++ * Boolean.valueOf(this.wrapAlignment).hashCode();
330 hash += m++ * this.charHeight;
331 hash += m++ * this.charWidth;
332 hash += m++ * fontSize;
333 hash += m++ * fontStyle;
334 hash += m++ * idWidth;
335 hash += String.valueOf(this.fontName).hashCode();
340 * @return the upperCasebold
343 public boolean isUpperCasebold()
345 return upperCasebold;
349 * @param upperCasebold
350 * the upperCasebold to set
353 public void setUpperCasebold(boolean upperCasebold)
355 this.upperCasebold = upperCasebold;
361 boolean wrapAlignment = false;
364 * number columns in wrapped alignment
368 private int fontStyle;
370 private boolean showComplementFeatures;
375 * @return true if percent identity threshold is applied to shading
378 public boolean getAbovePIDThreshold()
380 return abovePIDThreshold;
386 * @return DOCUMENT ME!
389 public int getCharHeight()
397 * @return DOCUMENT ME!
400 public int getCharWidth()
408 * @return flag indicating if colourchanges propagated to all groups
411 public boolean getColourAppliesToAllGroups()
413 return colourAppliesToAllGroups;
419 * @return DOCUMENT ME!
422 public boolean getColourText()
424 return showColourText;
430 * @return true if conservation based shading is enabled
433 public boolean getConservationSelected()
435 return conservationColourSelected;
441 * @return get scalar for bleaching colourschemes by conservation
444 public int getIncrement()
452 * @return DOCUMENT ME!
455 public boolean getScaleAboveWrapped()
457 return scaleAboveWrapped;
463 * @return DOCUMENT ME!
466 public boolean getScaleLeftWrapped()
468 return scaleLeftWrapped;
474 * @return DOCUMENT ME!
477 public boolean getScaleRightWrapped()
479 return scaleRightWrapped;
485 * @return DOCUMENT ME!
488 public boolean getShowBoxes()
494 public boolean getShowHiddenMarkers()
496 return showHiddenMarkers;
502 * @return DOCUMENT ME!
505 public boolean getShowJVSuffix()
513 * @return DOCUMENT ME!
516 public boolean getShowText()
522 public boolean getShowUnconserved()
524 return showUnconserved;
528 * @return the textColour
531 public Color getTextColour()
537 * @return the textColour2
540 public Color getTextColour2()
548 * @return DOCUMENT ME!
551 public int getThreshold()
557 * @return the thresholdTextColour
560 public int getThresholdTextColour()
562 return thresholdTextColour;
568 * @return DOCUMENT ME!
571 public boolean getWrapAlignment()
573 return wrapAlignment;
579 * @return DOCUMENT ME!
582 public int getWrappedWidth()
588 public boolean isColourByReferenceSeq()
590 return colourByReferenceSeq;
594 * @return the conservationColourSelected
597 public boolean isConservationColourSelected()
599 return conservationColourSelected;
603 public boolean isDisplayReferenceSeq()
605 return displayReferenceSeq;
609 * @return the renderGaps
612 public boolean isRenderGaps()
618 public boolean isRightAlignIds()
620 return rightAlignIds;
624 * @return the seqNameItalics
627 public boolean isSeqNameItalics()
629 return seqNameItalics;
633 public boolean isShowAnnotation()
635 return showAnnotation;
639 * @return the showColourText
642 public boolean isShowColourText()
644 return showColourText;
648 * @return the showSeqFeaturesHeight
651 public boolean isShowSequenceFeaturesHeight()
653 return showSeqFeaturesHeight;
657 public boolean isShowSequenceFeatures()
659 return showSequenceFeatures;
667 * indicate if percent identity threshold is applied to shading
670 public void setAbovePIDThreshold(boolean b)
672 abovePIDThreshold = b;
682 public void setCharHeight(int h)
694 public void setCharWidth(int w)
701 * indicating if subsequent colourscheme changes will be propagated
705 public void setColourAppliesToAllGroups(boolean b)
707 colourAppliesToAllGroups = b;
711 public void setColourByReferenceSeq(boolean colourByReferenceSeq)
713 this.colourByReferenceSeq = colourByReferenceSeq;
723 public void setColourText(boolean state)
725 showColourText = state;
729 * @param conservationColourSelected
730 * the conservationColourSelected to set
733 public void setConservationColourSelected(
734 boolean conservationColourSelected)
736 this.conservationColourSelected = conservationColourSelected;
743 * enable conservation based shading
746 public void setConservationSelected(boolean b)
748 conservationColourSelected = b;
752 public void setDisplayReferenceSeq(boolean displayReferenceSeq)
754 this.displayReferenceSeq = displayReferenceSeq;
760 * set the scalar for bleaching colourschemes according to degree of
764 public void setIncrement(int inc)
776 public void setRenderGaps(boolean state)
782 public void setRightAlignIds(boolean rightAlignIds)
784 this.rightAlignIds = rightAlignIds;
794 public void setScaleAboveWrapped(boolean b)
796 scaleAboveWrapped = b;
806 public void setScaleLeftWrapped(boolean b)
808 scaleLeftWrapped = b;
814 * @param scaleRightWrapped
819 public void setScaleRightWrapped(boolean b)
821 scaleRightWrapped = b;
825 public void setSeqNameItalics(boolean italics)
827 seqNameItalics = italics;
831 public void setShowAnnotation(boolean b)
843 public void setShowBoxes(boolean state)
849 * @param showColourText
850 * the showColourText to set
853 public void setShowColourText(boolean showColourText)
855 this.showColourText = showColourText;
859 public void setShowHiddenMarkers(boolean show)
861 showHiddenMarkers = show;
871 public void setShowJVSuffix(boolean b)
877 public void setShowSequenceFeaturesHeight(boolean selected)
879 showSeqFeaturesHeight = selected;
887 * features are displayed if true
890 public void setShowSequenceFeatures(boolean b)
892 showSequenceFeatures = b;
902 public void setShowText(boolean state)
908 public void setShowUnconserved(boolean showunconserved)
910 showUnconserved = showunconserved;
915 * the textColour to set
918 public void setTextColour(Color textColour)
920 this.textColour = textColour;
925 * the textColour2 to set
928 public void setTextColour2(Color textColour2)
930 this.textColour2 = textColour2;
940 public void setThreshold(int thresh)
946 * @param thresholdTextColour
947 * the thresholdTextColour to set
950 public void setThresholdTextColour(int thresholdTextColour)
952 this.thresholdTextColour = thresholdTextColour;
962 public void setWrapAlignment(boolean state)
964 wrapAlignment = state;
974 public void setWrappedWidth(int w)
976 this.wrappedWidth = w;
980 public boolean sameStyle(ViewStyleI that)
982 return this.equals(that);
986 public String getFontName()
992 public int getFontSize()
998 public int getFontStyle()
1004 public void setFontName(String name)
1010 public void setFontSize(int size)
1017 public void setFontStyle(int style)
1023 public int getIdWidth()
1030 * the idWidth to set
1033 public void setIdWidth(int idWidth)
1035 this.idWidth = idWidth;
1039 * @return the centreColumnLabels
1042 public boolean isCentreColumnLabels()
1044 return centreColumnLabels;
1048 * @param centreColumnLabels
1049 * the centreColumnLabels to set
1052 public void setCentreColumnLabels(boolean centreColumnLabels)
1054 this.centreColumnLabels = centreColumnLabels;
1058 * @return the showdbrefs
1061 public boolean isShowDBRefs()
1068 * the showdbrefs to set
1071 public void setShowDBRefs(boolean showdbrefs)
1073 this.showdbrefs = showdbrefs;
1077 * @return the shownpfeats
1080 public boolean isShowNPFeats()
1086 * @param shownpfeats
1087 * the shownpfeats to set
1090 public void setShowNPFeats(boolean shownpfeats)
1092 this.shownpfeats = shownpfeats;
1096 public boolean isScaleProteinAsCdna()
1098 return this.scaleProteinAsCdna;
1102 public void setScaleProteinAsCdna(boolean b)
1104 this.scaleProteinAsCdna = b;
1108 public boolean isProteinFontAsCdna()
1110 return proteinFontAsCdna;
1114 public void setProteinFontAsCdna(boolean b)
1116 proteinFontAsCdna = b;
1120 public void setShowComplementFeatures(boolean b)
1122 showComplementFeatures = b;
1126 public boolean isShowComplementFeatures()
1128 return showComplementFeatures;