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 * colour gaps in the alignment view according to the overview gap colour
134 boolean colourGaps = false;
136 * show non-conserved residues only
138 protected boolean showUnconserved = false;
140 Color textColour = Color.black;
142 Color textColour2 = Color.white;
145 * PID or consensus threshold
150 * threshold for switching between textColour & textColour2
152 int thresholdTextColour = 0;
155 * upper case characters in sequence are shown in bold
157 boolean upperCasebold = false;
160 * name of base font for view
162 private String fontName;
167 private int fontSize;
170 * If true, scale protein residues to 3 times width of cDNA bases (in
171 * SplitFrame views only)
173 private boolean scaleProteinAsCdna = true;
176 * if true, font changes to protein or cDNA are applied to both
177 * sides of a split screen
179 private boolean proteinFontAsCdna = true;
186 public ViewStyle(ViewStyleI vs)
188 setAbovePIDThreshold(vs.getAbovePIDThreshold());
189 setCentreColumnLabels(vs.isCentreColumnLabels());
190 setCharHeight(vs.getCharHeight());
191 setCharWidth(vs.getCharWidth());
192 setColourAppliesToAllGroups(vs.getColourAppliesToAllGroups());
193 setColourByReferenceSeq(vs.isColourByReferenceSeq());
194 setColourText(vs.getColourText());
195 setConservationColourSelected(vs.isConservationColourSelected());
196 setConservationSelected(vs.getConservationSelected());
197 setDisplayReferenceSeq(vs.isDisplayReferenceSeq());
198 setFontName(vs.getFontName());
199 setFontSize(vs.getFontSize());
200 setFontStyle(vs.getFontStyle());
201 setIdWidth(vs.getIdWidth());
202 setIncrement(vs.getIncrement());
203 setRenderGaps(vs.isRenderGaps());
204 setRightAlignIds(vs.isRightAlignIds());
205 setScaleAboveWrapped(vs.getScaleAboveWrapped());
206 setScaleLeftWrapped(vs.getScaleLeftWrapped());
207 setScaleProteinAsCdna(vs.isScaleProteinAsCdna());
208 setProteinFontAsCdna(vs.isProteinFontAsCdna());
209 setScaleRightWrapped(vs.getScaleRightWrapped());
210 setSeqNameItalics(vs.isSeqNameItalics());
211 setShowAnnotation(vs.isShowAnnotation());
212 setShowBoxes(vs.getShowBoxes());
213 setShowColourText(vs.isShowColourText());
214 setShowDBRefs(vs.isShowDBRefs());
215 setShowHiddenMarkers(vs.getShowHiddenMarkers());
216 setShowJVSuffix(vs.getShowJVSuffix());
217 setShowNPFeats(vs.isShowNPFeats());
218 setShowSequenceFeaturesHeight(vs.isShowSequenceFeaturesHeight());
219 setShowSequenceFeatures(vs.isShowSequenceFeatures());
220 setShowComplementFeatures(vs.isShowComplementFeatures());
221 setShowComplementFeaturesOnTop(vs.isShowComplementFeaturesOnTop());
222 setShowText(vs.getShowText());
223 setShowUnconserved(vs.getShowUnconserved());
224 setTextColour(vs.getTextColour());
225 setTextColour2(vs.getTextColour2());
226 setThreshold(vs.getThreshold());
227 setThresholdTextColour(vs.getThresholdTextColour());
228 setUpperCasebold(vs.isUpperCasebold());
229 setWrapAlignment(vs.getWrapAlignment());
230 setWrappedWidth(vs.getWrappedWidth());
231 setColourGaps(vs.getColourGaps());
232 // ViewStyle.configureFrom(this, viewStyle);
240 * Returns true if all attributes of the ViewStyles have the same value
243 public boolean equals(Object other)
245 if (other == null || !(other instanceof ViewStyle))
249 ViewStyle vs = (ViewStyle) other;
251 boolean match = (getAbovePIDThreshold() == vs.getAbovePIDThreshold()
252 && isCentreColumnLabels() == vs.isCentreColumnLabels()
253 && getCharHeight() == vs.getCharHeight()
254 && getCharWidth() == vs.getCharWidth()
255 && getColourAppliesToAllGroups() == vs
256 .getColourAppliesToAllGroups()
257 && isColourByReferenceSeq() == vs.isColourByReferenceSeq()
258 && getColourText() == vs.getColourText()
259 && isConservationColourSelected() == vs
260 .isConservationColourSelected()
261 && getConservationSelected() == vs.getConservationSelected()
262 && isDisplayReferenceSeq() == vs.isDisplayReferenceSeq()
263 && getFontSize() == vs.getFontSize()
264 && getFontStyle() == vs.getFontStyle()
265 && getIdWidth() == vs.getIdWidth()
266 && getIncrement() == vs.getIncrement()
267 && isRenderGaps() == vs.isRenderGaps()
268 && isRightAlignIds() == vs.isRightAlignIds()
269 && getScaleAboveWrapped() == vs.getScaleAboveWrapped()
270 && getScaleLeftWrapped() == vs.getScaleLeftWrapped()
271 && isScaleProteinAsCdna() == vs.isScaleProteinAsCdna()
272 && isProteinFontAsCdna() == vs.isProteinFontAsCdna()
273 && getScaleRightWrapped() == vs.getScaleRightWrapped()
274 && isSeqNameItalics() == vs.isSeqNameItalics()
275 && isShowAnnotation() == vs.isShowAnnotation()
276 && getShowBoxes() == vs.getShowBoxes()
277 && isShowColourText() == vs.isShowColourText()
278 && isShowDBRefs() == vs.isShowDBRefs()
279 && getShowHiddenMarkers() == vs.getShowHiddenMarkers()
280 && getShowJVSuffix() == vs.getShowJVSuffix()
281 && isShowNPFeats() == vs.isShowNPFeats()
282 && isShowSequenceFeaturesHeight() == vs
283 .isShowSequenceFeaturesHeight()
284 && isShowSequenceFeatures() == vs.isShowSequenceFeatures()
285 && isShowComplementFeatures() == vs.isShowComplementFeatures()
286 && isShowComplementFeaturesOnTop() == vs
287 .isShowComplementFeaturesOnTop()
288 && getShowText() == vs.getShowText()
289 && getShowUnconserved() == vs.getShowUnconserved()
290 && getThreshold() == vs.getThreshold()
291 && getThresholdTextColour() == vs.getThresholdTextColour()
292 && isUpperCasebold() == vs.isUpperCasebold()
293 && getWrapAlignment() == vs.getWrapAlignment()
294 && getWrappedWidth() == vs.getWrappedWidth()
295 && getColourGaps() == vs.getColourGaps());
297 * and compare non-primitive types; syntax below will match null with null
300 match = match && String.valueOf(getFontName())
301 .equals(String.valueOf(vs.getFontName()));
302 match = match && String.valueOf(getTextColour())
303 .equals(String.valueOf(vs.getTextColour()));
304 match = match && String.valueOf(getTextColour2())
305 .equals(String.valueOf(vs.getTextColour2()));
307 // return equivalent(this, (ViewStyle) other);
311 * Overridden to ensure that whenever vs1.equals(vs2) then vs1.hashCode() ==
315 public int hashCode()
318 * No need to include all properties, just a selection...
322 // Boolean.hashCode returns 1231 or 1237
323 hash += m++ * Boolean.valueOf(this.abovePIDThreshold).hashCode();
324 hash += m++ * Boolean.valueOf(this.centreColumnLabels).hashCode();
325 hash += m++ * Boolean.valueOf(this.colourAppliesToAllGroups).hashCode();
326 hash += m++ * Boolean.valueOf(this.displayReferenceSeq).hashCode();
327 hash += m++ * Boolean.valueOf(this.renderGaps).hashCode();
328 hash += m++ * Boolean.valueOf(this.rightAlignIds).hashCode();
329 hash += m++ * Boolean.valueOf(this.scaleProteinAsCdna).hashCode();
330 hash += m++ * Boolean.valueOf(this.scaleRightWrapped).hashCode();
331 hash += m++ * Boolean.valueOf(this.seqNameItalics).hashCode();
332 hash += m++ * Boolean.valueOf(this.showAnnotation).hashCode();
333 hash += m++ * Boolean.valueOf(this.showBoxes).hashCode();
334 hash += m++ * Boolean.valueOf(this.showdbrefs).hashCode();
335 hash += m++ * Boolean.valueOf(this.showJVSuffix).hashCode();
336 hash += m++ * Boolean.valueOf(this.showSequenceFeatures).hashCode();
337 hash += m++ * Boolean.valueOf(this.showUnconserved).hashCode();
338 hash += m++ * Boolean.valueOf(this.wrapAlignment).hashCode();
339 hash += m++ * Boolean.valueOf(this.colourGaps).hashCode();
340 hash += m++ * Boolean.valueOf(this.showColourText).hashCode();
341 hash += m++ * this.charHeight;
342 hash += m++ * this.charWidth;
343 hash += m++ * fontSize;
344 hash += m++ * fontStyle;
345 hash += m++ * idWidth;
346 hash += String.valueOf(this.fontName).hashCode();
351 * @return the upperCasebold
354 public boolean isUpperCasebold()
356 return upperCasebold;
360 * @param upperCasebold
361 * the upperCasebold to set
364 public void setUpperCasebold(boolean upperCasebold)
366 this.upperCasebold = upperCasebold;
372 boolean wrapAlignment = false;
375 * number columns in wrapped alignment
379 private int fontStyle;
381 private boolean showComplementFeatures;
383 private boolean showComplementFeaturesOnTop;
388 * @return true if percent identity threshold is applied to shading
391 public boolean getAbovePIDThreshold()
393 return abovePIDThreshold;
399 * @return DOCUMENT ME!
402 public int getCharHeight()
410 * @return DOCUMENT ME!
413 public int getCharWidth()
421 * @return flag indicating if colourchanges propagated to all groups
424 public boolean getColourAppliesToAllGroups()
426 return colourAppliesToAllGroups;
432 * @return DOCUMENT ME!
435 public boolean getColourText()
437 return showColourText;
443 * @return true if conservation based shading is enabled
446 public boolean getConservationSelected()
448 return conservationColourSelected;
454 * @return get scalar for bleaching colourschemes by conservation
457 public int getIncrement()
465 * @return DOCUMENT ME!
468 public boolean getScaleAboveWrapped()
470 return scaleAboveWrapped;
476 * @return DOCUMENT ME!
479 public boolean getScaleLeftWrapped()
481 return scaleLeftWrapped;
487 * @return DOCUMENT ME!
490 public boolean getScaleRightWrapped()
492 return scaleRightWrapped;
498 * @return DOCUMENT ME!
501 public boolean getShowBoxes()
507 public boolean getShowHiddenMarkers()
509 return showHiddenMarkers;
515 * @return DOCUMENT ME!
518 public boolean getShowJVSuffix()
526 * @return DOCUMENT ME!
529 public boolean getShowText()
535 public boolean getShowUnconserved()
537 return showUnconserved;
541 * @return the textColour
544 public Color getTextColour()
550 * @return the textColour2
553 public Color getTextColour2()
561 * @return DOCUMENT ME!
564 public int getThreshold()
570 * @return the thresholdTextColour
573 public int getThresholdTextColour()
575 return thresholdTextColour;
581 * @return DOCUMENT ME!
584 public boolean getWrapAlignment()
586 return wrapAlignment;
592 * @return DOCUMENT ME!
595 public int getWrappedWidth()
601 public boolean isColourByReferenceSeq()
603 return colourByReferenceSeq;
607 * @return the conservationColourSelected
610 public boolean isConservationColourSelected()
612 return conservationColourSelected;
616 public boolean isDisplayReferenceSeq()
618 return displayReferenceSeq;
622 * @return the renderGaps
625 public boolean isRenderGaps()
631 public boolean isRightAlignIds()
633 return rightAlignIds;
637 * @return the seqNameItalics
640 public boolean isSeqNameItalics()
642 return seqNameItalics;
646 public boolean isShowAnnotation()
648 return showAnnotation;
652 * @return the showColourText
655 public boolean isShowColourText()
657 return showColourText;
661 * @return the showSeqFeaturesHeight
664 public boolean isShowSequenceFeaturesHeight()
666 return showSeqFeaturesHeight;
670 public boolean isShowSequenceFeatures()
672 return showSequenceFeatures;
680 * indicate if percent identity threshold is applied to shading
683 public void setAbovePIDThreshold(boolean b)
685 abovePIDThreshold = b;
695 public void setCharHeight(int h)
707 public void setCharWidth(int w)
714 * indicating if subsequent colourscheme changes will be propagated
718 public void setColourAppliesToAllGroups(boolean b)
720 colourAppliesToAllGroups = b;
724 public void setColourByReferenceSeq(boolean colourByReferenceSeq)
726 this.colourByReferenceSeq = colourByReferenceSeq;
736 public void setColourText(boolean state)
738 showColourText = state;
742 * @param conservationColourSelected
743 * the conservationColourSelected to set
746 public void setConservationColourSelected(
747 boolean conservationColourSelected)
749 this.conservationColourSelected = conservationColourSelected;
756 * enable conservation based shading
759 public void setConservationSelected(boolean b)
761 conservationColourSelected = b;
765 public void setDisplayReferenceSeq(boolean displayReferenceSeq)
767 this.displayReferenceSeq = displayReferenceSeq;
773 * set the scalar for bleaching colourschemes according to degree of
777 public void setIncrement(int inc)
789 public void setRenderGaps(boolean state)
795 public void setRightAlignIds(boolean rightAlignIds)
797 this.rightAlignIds = rightAlignIds;
807 public void setScaleAboveWrapped(boolean b)
809 scaleAboveWrapped = b;
819 public void setScaleLeftWrapped(boolean b)
821 scaleLeftWrapped = b;
827 * @param scaleRightWrapped
832 public void setScaleRightWrapped(boolean b)
834 scaleRightWrapped = b;
838 public void setSeqNameItalics(boolean italics)
840 seqNameItalics = italics;
844 public void setShowAnnotation(boolean b)
856 public void setShowBoxes(boolean state)
862 * @param showColourText
863 * the showColourText to set
866 public void setShowColourText(boolean showColourText)
868 this.showColourText = showColourText;
872 public void setShowHiddenMarkers(boolean show)
874 showHiddenMarkers = show;
884 public void setShowJVSuffix(boolean b)
890 public void setShowSequenceFeaturesHeight(boolean selected)
892 showSeqFeaturesHeight = selected;
900 * features are displayed if true
903 public void setShowSequenceFeatures(boolean b)
905 showSequenceFeatures = b;
915 public void setShowText(boolean state)
921 public void setShowUnconserved(boolean showunconserved)
923 showUnconserved = showunconserved;
928 * the textColour to set
931 public void setTextColour(Color textColour)
933 this.textColour = textColour;
938 * the textColour2 to set
941 public void setTextColour2(Color textColour2)
943 this.textColour2 = textColour2;
953 public void setThreshold(int thresh)
959 * @param thresholdTextColour
960 * the thresholdTextColour to set
963 public void setThresholdTextColour(int thresholdTextColour)
965 this.thresholdTextColour = thresholdTextColour;
975 public void setWrapAlignment(boolean state)
977 wrapAlignment = state;
987 public void setWrappedWidth(int w)
989 this.wrappedWidth = w;
993 public boolean sameStyle(ViewStyleI that)
995 return this.equals(that);
999 public String getFontName()
1005 public int getFontSize()
1011 public int getFontStyle()
1017 public void setFontName(String name)
1023 public void setFontSize(int size)
1030 public void setFontStyle(int style)
1036 public int getIdWidth()
1043 * the idWidth to set
1046 public void setIdWidth(int idWidth)
1048 this.idWidth = idWidth;
1052 * @return the centreColumnLabels
1055 public boolean isCentreColumnLabels()
1057 return centreColumnLabels;
1061 * @param centreColumnLabels
1062 * the centreColumnLabels to set
1065 public void setCentreColumnLabels(boolean centreColumnLabels)
1067 this.centreColumnLabels = centreColumnLabels;
1071 * @return the showdbrefs
1074 public boolean isShowDBRefs()
1081 * the showdbrefs to set
1084 public void setShowDBRefs(boolean showdbrefs)
1086 this.showdbrefs = showdbrefs;
1090 * @return the shownpfeats
1093 public boolean isShowNPFeats()
1099 * @param shownpfeats
1100 * the shownpfeats to set
1103 public void setShowNPFeats(boolean shownpfeats)
1105 this.shownpfeats = shownpfeats;
1109 public boolean isScaleProteinAsCdna()
1111 return this.scaleProteinAsCdna;
1115 public void setScaleProteinAsCdna(boolean b)
1117 this.scaleProteinAsCdna = b;
1121 public boolean isProteinFontAsCdna()
1123 return proteinFontAsCdna;
1127 public void setProteinFontAsCdna(boolean b)
1129 proteinFontAsCdna = b;
1133 public void setShowComplementFeatures(boolean b)
1135 showComplementFeatures = b;
1139 public boolean isShowComplementFeatures()
1141 return showComplementFeatures;
1145 public void setShowComplementFeaturesOnTop(boolean b)
1147 showComplementFeaturesOnTop = b;
1151 public boolean isShowComplementFeaturesOnTop()
1153 return showComplementFeaturesOnTop;
1157 public void setColourGaps(boolean b)
1163 public boolean getColourGaps()