2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9)
3 * Copyright (C) 2015 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;
176 public ViewStyle(ViewStyleI vs)
178 setAbovePIDThreshold(vs.getAbovePIDThreshold());
179 setCentreColumnLabels(vs.isCentreColumnLabels());
180 setCharHeight(vs.getCharHeight());
181 setCharWidth(vs.getCharWidth());
182 setColourAppliesToAllGroups(vs.getColourAppliesToAllGroups());
183 setColourByReferenceSeq(vs.isColourByReferenceSeq());
184 setColourText(vs.getColourText());
185 setConservationColourSelected(vs.isConservationColourSelected());
186 setConservationSelected(vs.getConservationSelected());
187 setDisplayReferenceSeq(vs.isDisplayReferenceSeq());
188 setFontName(vs.getFontName());
189 setFontSize(vs.getFontSize());
190 setFontStyle(vs.getFontStyle());
191 setIdWidth(vs.getIdWidth());
192 setIncrement(vs.getIncrement());
193 setRenderGaps(vs.isRenderGaps());
194 setRightAlignIds(vs.isRightAlignIds());
195 setScaleAboveWrapped(vs.getScaleAboveWrapped());
196 setScaleLeftWrapped(vs.getScaleLeftWrapped());
197 setScaleProteinAsCdna(vs.isScaleProteinAsCdna());
198 setScaleRightWrapped(vs.getScaleRightWrapped());
199 setSeqNameItalics(vs.isSeqNameItalics());
200 setShowAnnotation(vs.isShowAnnotation());
201 setShowBoxes(vs.getShowBoxes());
202 setShowColourText(vs.isShowColourText());
203 setShowDBRefs(vs.isShowDBRefs());
204 setShowHiddenMarkers(vs.getShowHiddenMarkers());
205 setShowJVSuffix(vs.getShowJVSuffix());
206 setShowNPFeats(vs.isShowNPFeats());
207 setShowSequenceFeaturesHeight(vs.isShowSequenceFeaturesHeight());
208 setShowSequenceFeatures(vs.isShowSequenceFeatures());
209 setShowText(vs.getShowText());
210 setShowUnconserved(vs.getShowUnconserved());
211 setTextColour(vs.getTextColour());
212 setTextColour2(vs.getTextColour2());
213 setThreshold(vs.getThreshold());
214 setThresholdTextColour(vs.getThresholdTextColour());
215 setUpperCasebold(vs.isUpperCasebold());
216 setWrapAlignment(vs.getWrapAlignment());
217 setWrappedWidth(vs.getWrappedWidth());
218 // ViewStyle.configureFrom(this, viewStyle);
226 * Returns true if all attributes of the ViewStyles have the same value
229 public boolean equals(Object other)
231 if (other == null || !(other instanceof ViewStyle))
235 ViewStyle vs = (ViewStyle) other;
237 boolean match = (getAbovePIDThreshold() == vs.getAbovePIDThreshold()
238 && isCentreColumnLabels() == vs.isCentreColumnLabels()
239 && getCharHeight() == vs.getCharHeight()
240 && getCharWidth() == vs.getCharWidth()
241 && getColourAppliesToAllGroups() == vs
242 .getColourAppliesToAllGroups()
243 && isColourByReferenceSeq() == vs.isColourByReferenceSeq()
244 && getColourText() == vs.getColourText()
245 && isConservationColourSelected() == vs
246 .isConservationColourSelected()
247 && getConservationSelected() == vs.getConservationSelected()
248 && isDisplayReferenceSeq() == vs.isDisplayReferenceSeq()
249 && getFontSize() == vs.getFontSize()
250 && getFontStyle() == vs.getFontStyle()
251 && getIdWidth() == vs.getIdWidth()
252 && getIncrement() == vs.getIncrement()
253 && isRenderGaps() == vs.isRenderGaps()
254 && isRightAlignIds() == vs.isRightAlignIds()
255 && getScaleAboveWrapped() == vs.getScaleAboveWrapped()
256 && getScaleLeftWrapped() == vs.getScaleLeftWrapped()
257 && isScaleProteinAsCdna() == vs.isScaleProteinAsCdna()
258 && getScaleRightWrapped() == vs.getScaleRightWrapped()
259 && isSeqNameItalics() == vs.isSeqNameItalics()
260 && isShowAnnotation() == vs.isShowAnnotation()
261 && getShowBoxes() == vs.getShowBoxes()
262 && isShowColourText() == vs.isShowColourText()
263 && isShowDBRefs() == vs.isShowDBRefs()
264 && getShowHiddenMarkers() == vs.getShowHiddenMarkers()
265 && getShowJVSuffix() == vs.getShowJVSuffix()
266 && isShowNPFeats() == vs.isShowNPFeats()
267 && isShowSequenceFeaturesHeight() == vs
268 .isShowSequenceFeaturesHeight()
269 && isShowSequenceFeatures() == vs.isShowSequenceFeatures()
270 && getShowText() == vs.getShowText()
271 && getShowUnconserved() == vs.getShowUnconserved()
272 && getThreshold() == vs.getThreshold()
273 && getThresholdTextColour() == vs.getThresholdTextColour()
274 && isUpperCasebold() == vs.isUpperCasebold()
275 && getWrapAlignment() == vs.getWrapAlignment() && getWrappedWidth() == vs
278 * and compare non-primitive types; syntax below will match null with null
282 && String.valueOf(getFontName()).equals(
283 String.valueOf(vs.getFontName()));
285 && String.valueOf(getTextColour()).equals(
286 String.valueOf(vs.getTextColour()));
288 && String.valueOf(getTextColour2()).equals(
289 String.valueOf(vs.getTextColour2()));
291 // return equivalent(this, (ViewStyle) other);
295 * Overridden to ensure that whenever vs1.equals(vs2) then vs1.hashCode() ==
299 public int hashCode()
302 * No need to include all properties, just a selection...
306 // Boolean.hashCode returns 1231 or 1237
307 hash += m++ * Boolean.valueOf(this.abovePIDThreshold).hashCode();
308 hash += m++ * Boolean.valueOf(this.centreColumnLabels).hashCode();
309 hash += m++ * Boolean.valueOf(this.colourAppliesToAllGroups).hashCode();
310 hash += m++ * Boolean.valueOf(this.displayReferenceSeq).hashCode();
311 hash += m++ * Boolean.valueOf(this.renderGaps).hashCode();
312 hash += m++ * Boolean.valueOf(this.rightAlignIds).hashCode();
313 hash += m++ * Boolean.valueOf(this.scaleProteinAsCdna).hashCode();
314 hash += m++ * Boolean.valueOf(this.scaleRightWrapped).hashCode();
315 hash += m++ * Boolean.valueOf(this.seqNameItalics).hashCode();
316 hash += m++ * Boolean.valueOf(this.showAnnotation).hashCode();
317 hash += m++ * Boolean.valueOf(this.showBoxes).hashCode();
318 hash += m++ * Boolean.valueOf(this.showdbrefs).hashCode();
319 hash += m++ * Boolean.valueOf(this.showJVSuffix).hashCode();
320 hash += m++ * Boolean.valueOf(this.showSequenceFeatures).hashCode();
321 hash += m++ * Boolean.valueOf(this.showUnconserved).hashCode();
322 hash += m++ * Boolean.valueOf(this.wrapAlignment).hashCode();
323 hash += m++ * this.charHeight;
324 hash += m++ * this.charWidth;
325 hash += m++ * fontSize;
326 hash += m++ * fontStyle;
327 hash += m++ * idWidth;
328 hash += String.valueOf(this.fontName).hashCode();
333 * @return the upperCasebold
336 public boolean isUpperCasebold()
338 return upperCasebold;
342 * @param upperCasebold
343 * the upperCasebold to set
346 public void setUpperCasebold(boolean upperCasebold)
348 this.upperCasebold = upperCasebold;
354 boolean wrapAlignment = false;
357 * number columns in wrapped alignment
361 private int fontStyle;
366 * @return true if percent identity threshold is applied to shading
369 public boolean getAbovePIDThreshold()
371 return abovePIDThreshold;
377 * @return DOCUMENT ME!
380 public int getCharHeight()
388 * @return DOCUMENT ME!
391 public int getCharWidth()
399 * @return flag indicating if colourchanges propagated to all groups
402 public boolean getColourAppliesToAllGroups()
404 return colourAppliesToAllGroups;
410 * @return DOCUMENT ME!
413 public boolean getColourText()
415 return showColourText;
421 * @return true if conservation based shading is enabled
424 public boolean getConservationSelected()
426 return conservationColourSelected;
432 * @return get scalar for bleaching colourschemes by conservation
435 public int getIncrement()
443 * @return DOCUMENT ME!
446 public boolean getScaleAboveWrapped()
448 return scaleAboveWrapped;
454 * @return DOCUMENT ME!
457 public boolean getScaleLeftWrapped()
459 return scaleLeftWrapped;
465 * @return DOCUMENT ME!
468 public boolean getScaleRightWrapped()
470 return scaleRightWrapped;
476 * @return DOCUMENT ME!
479 public boolean getShowBoxes()
485 public boolean getShowHiddenMarkers()
487 return showHiddenMarkers;
493 * @return DOCUMENT ME!
496 public boolean getShowJVSuffix()
504 * @return DOCUMENT ME!
507 public boolean getShowText()
513 public boolean getShowUnconserved()
515 return showUnconserved;
519 * @return the textColour
522 public Color getTextColour()
528 * @return the textColour2
531 public Color getTextColour2()
539 * @return DOCUMENT ME!
542 public int getThreshold()
548 * @return the thresholdTextColour
551 public int getThresholdTextColour()
553 return thresholdTextColour;
559 * @return DOCUMENT ME!
562 public boolean getWrapAlignment()
564 return wrapAlignment;
570 * @return DOCUMENT ME!
573 public int getWrappedWidth()
579 public boolean isColourByReferenceSeq()
581 return colourByReferenceSeq;
585 * @return the conservationColourSelected
588 public boolean isConservationColourSelected()
590 return conservationColourSelected;
594 public boolean isDisplayReferenceSeq()
596 return displayReferenceSeq;
600 * @return the renderGaps
603 public boolean isRenderGaps()
609 public boolean isRightAlignIds()
611 return rightAlignIds;
615 * @return the seqNameItalics
618 public boolean isSeqNameItalics()
620 return seqNameItalics;
624 public boolean isShowAnnotation()
626 return showAnnotation;
630 * @return the showColourText
633 public boolean isShowColourText()
635 return showColourText;
639 * @return the showSeqFeaturesHeight
642 public boolean isShowSequenceFeaturesHeight()
644 return showSeqFeaturesHeight;
648 public boolean isShowSequenceFeatures()
650 return showSequenceFeatures;
658 * indicate if percent identity threshold is applied to shading
661 public void setAbovePIDThreshold(boolean b)
663 abovePIDThreshold = b;
673 public void setCharHeight(int h)
685 public void setCharWidth(int w)
692 * indicating if subsequent colourscheme changes will be propagated
696 public void setColourAppliesToAllGroups(boolean b)
698 colourAppliesToAllGroups = b;
702 public void setColourByReferenceSeq(boolean colourByReferenceSeq)
704 this.colourByReferenceSeq = colourByReferenceSeq;
714 public void setColourText(boolean state)
716 showColourText = state;
720 * @param conservationColourSelected
721 * the conservationColourSelected to set
724 public void setConservationColourSelected(
725 boolean conservationColourSelected)
727 this.conservationColourSelected = conservationColourSelected;
734 * enable conservation based shading
737 public void setConservationSelected(boolean b)
739 conservationColourSelected = b;
743 public void setDisplayReferenceSeq(boolean displayReferenceSeq)
745 this.displayReferenceSeq = displayReferenceSeq;
751 * set the scalar for bleaching colourschemes according to degree of
755 public void setIncrement(int inc)
767 public void setRenderGaps(boolean state)
773 public void setRightAlignIds(boolean rightAlignIds)
775 this.rightAlignIds = rightAlignIds;
785 public void setScaleAboveWrapped(boolean b)
787 scaleAboveWrapped = b;
797 public void setScaleLeftWrapped(boolean b)
799 scaleLeftWrapped = b;
805 * @param scaleRightWrapped
810 public void setScaleRightWrapped(boolean b)
812 scaleRightWrapped = b;
816 public void setSeqNameItalics(boolean italics)
818 seqNameItalics = italics;
822 public void setShowAnnotation(boolean b)
834 public void setShowBoxes(boolean state)
840 * @param showColourText
841 * the showColourText to set
844 public void setShowColourText(boolean showColourText)
846 this.showColourText = showColourText;
850 public void setShowHiddenMarkers(boolean show)
852 showHiddenMarkers = show;
862 public void setShowJVSuffix(boolean b)
868 public void setShowSequenceFeaturesHeight(boolean selected)
870 showSeqFeaturesHeight = selected;
878 * features are displayed if true
881 public void setShowSequenceFeatures(boolean b)
883 showSequenceFeatures = b;
893 public void setShowText(boolean state)
899 public void setShowUnconserved(boolean showunconserved)
901 showUnconserved = showunconserved;
906 * the textColour to set
909 public void setTextColour(Color textColour)
911 this.textColour = textColour;
916 * the textColour2 to set
919 public void setTextColour2(Color textColour2)
921 this.textColour2 = textColour2;
931 public void setThreshold(int thresh)
937 * @param thresholdTextColour
938 * the thresholdTextColour to set
941 public void setThresholdTextColour(int thresholdTextColour)
943 this.thresholdTextColour = thresholdTextColour;
953 public void setWrapAlignment(boolean state)
955 wrapAlignment = state;
965 public void setWrappedWidth(int w)
967 this.wrappedWidth = w;
971 public boolean sameStyle(ViewStyleI that)
973 return this.equals(that);
977 public String getFontName()
983 public int getFontSize()
989 public int getFontStyle()
995 public void setFontName(String name)
1001 public void setFontSize(int size)
1008 public void setFontStyle(int style)
1014 public int getIdWidth()
1021 * the idWidth to set
1024 public void setIdWidth(int idWidth)
1026 this.idWidth = idWidth;
1030 * @return the centreColumnLabels
1033 public boolean isCentreColumnLabels()
1035 return centreColumnLabels;
1039 * @param centreColumnLabels
1040 * the centreColumnLabels to set
1043 public void setCentreColumnLabels(boolean centreColumnLabels)
1045 this.centreColumnLabels = centreColumnLabels;
1049 * @return the showdbrefs
1052 public boolean isShowDBRefs()
1059 * the showdbrefs to set
1062 public void setShowDBRefs(boolean showdbrefs)
1064 this.showdbrefs = showdbrefs;
1068 * @return the shownpfeats
1071 public boolean isShowNPFeats()
1077 * @param shownpfeats
1078 * the shownpfeats to set
1081 public void setShowNPFeats(boolean shownpfeats)
1083 this.shownpfeats = shownpfeats;
1087 public boolean isScaleProteinAsCdna()
1089 return this.scaleProteinAsCdna;
1093 public void setScaleProteinAsCdna(boolean b)
1095 this.scaleProteinAsCdna = b;