1 package jalview.viewmodel.styles;
5 import jalview.api.ViewStyleI;
8 * A container for holding alignment view properties. View properties are
9 * data-independent, which means they can be safely copied between views
10 * involving different alignment data without causing exceptions in the
16 public class ViewStyle implements ViewStyleI
18 private boolean abovePIDThreshold = false;
27 * gui state - changes to colour scheme propagated to all groups
29 private boolean colourAppliesToAllGroups;
32 * centre columnar annotation labels in displayed alignment annotation
34 boolean centreColumnLabels = false;
36 private boolean showdbrefs;
38 private boolean shownpfeats;
40 // --------END Structure Conservation
43 * colour according to the reference sequence defined on the alignment
45 private boolean colourByReferenceSeq = false;
47 boolean conservationColourSelected = false;
50 * show the reference sequence in the alignment view
52 private boolean displayReferenceSeq = false;
54 private int increment;
57 * display gap characters
59 boolean renderGaps = true;
61 private boolean rightAlignIds = false;
63 boolean scaleAboveWrapped = false;
65 boolean scaleLeftWrapped = true;
67 boolean scaleRightWrapped = true;
69 boolean seqNameItalics;
72 * show annotation tracks on the alignment
74 private boolean showAnnotation = true;
77 * render each residue in a coloured box
79 boolean showBoxes = true;
82 * Colour sequence text
84 boolean showColourText = false;
89 boolean showHiddenMarkers = true;
92 * show /start-end in ID panel
94 boolean showJVSuffix = true;
97 * scale features height according to score
99 boolean showSeqFeaturesHeight;
102 * display setting for showing/hiding sequence features on alignment view
104 boolean showSequenceFeatures = false;
107 * display sequence symbols
109 boolean showText = true;
112 * show non-conserved residues only
114 protected boolean showUnconserved = false;
116 Color textColour = Color.black;
118 Color textColour2 = Color.white;
121 * PID or consensus threshold
126 * threshold for switching between textColour & textColour2
128 int thresholdTextColour = 0;
131 * upper case characters in sequence are shown in bold
133 boolean upperCasebold = false;
136 * name of base font for view
138 private String fontName;
143 private int fontSize;
146 * If true, scale protein residues to 3 times width of cDNA bases (in
147 * SplitFrame views only)
149 private boolean scaleProteinAsCdna = true;
156 public ViewStyle(ViewStyleI vs)
158 setAbovePIDThreshold(vs.getAbovePIDThreshold());
159 setCentreColumnLabels(vs.isCentreColumnLabels());
160 setCharHeight(vs.getCharHeight());
161 setCharWidth(vs.getCharWidth());
162 setColourAppliesToAllGroups(vs.getColourAppliesToAllGroups());
163 setColourByReferenceSeq(vs.isColourByReferenceSeq());
164 setColourText(vs.getColourText());
165 setConservationColourSelected(vs.isConservationColourSelected());
166 setConservationSelected(vs.getConservationSelected());
167 setDisplayReferenceSeq(vs.isDisplayReferenceSeq());
168 setFontName(vs.getFontName());
169 setFontSize(vs.getFontSize());
170 setFontStyle(vs.getFontStyle());
171 setIdWidth(vs.getIdWidth());
172 setIncrement(vs.getIncrement());
173 setRenderGaps(vs.isRenderGaps());
174 setRightAlignIds(vs.isRightAlignIds());
175 setScaleAboveWrapped(vs.getScaleAboveWrapped());
176 setScaleLeftWrapped(vs.getScaleLeftWrapped());
177 setScaleProteinAsCdna(vs.isScaleProteinAsCdna());
178 setScaleRightWrapped(vs.getScaleRightWrapped());
179 setSeqNameItalics(vs.isSeqNameItalics());
180 setShowAnnotation(vs.isShowAnnotation());
181 setShowBoxes(vs.getShowBoxes());
182 setShowColourText(vs.isShowColourText());
183 setShowDBRefs(vs.isShowDBRefs());
184 setShowHiddenMarkers(vs.getShowHiddenMarkers());
185 setShowJVSuffix(vs.getShowJVSuffix());
186 setShowNPFeats(vs.isShowNPFeats());
187 setShowSequenceFeaturesHeight(vs.isShowSequenceFeaturesHeight());
188 setShowSequenceFeatures(vs.isShowSequenceFeatures());
189 setShowText(vs.getShowText());
190 setShowUnconserved(vs.getShowUnconserved());
191 setTextColour(vs.getTextColour());
192 setTextColour2(vs.getTextColour2());
193 setThreshold(vs.getThreshold());
194 setThresholdTextColour(vs.getThresholdTextColour());
195 setUpperCasebold(vs.isUpperCasebold());
196 setWrapAlignment(vs.getWrapAlignment());
197 setWrappedWidth(vs.getWrappedWidth());
198 // ViewStyle.configureFrom(this, viewStyle);
206 * Returns true if all attributes of the ViewStyles have the same value
209 public boolean equals(Object other)
211 if (other == null || !(other instanceof ViewStyle))
215 ViewStyle vs = (ViewStyle) other;
217 boolean match = (getAbovePIDThreshold() == vs.getAbovePIDThreshold()
218 && isCentreColumnLabels() == vs.isCentreColumnLabels()
219 && getCharHeight() == vs.getCharHeight()
220 && getCharWidth() == vs.getCharWidth()
221 && getColourAppliesToAllGroups() == vs
222 .getColourAppliesToAllGroups()
223 && isColourByReferenceSeq() == vs.isColourByReferenceSeq()
224 && getColourText() == vs.getColourText()
225 && isConservationColourSelected() == vs
226 .isConservationColourSelected()
227 && getConservationSelected() == vs.getConservationSelected()
228 && isDisplayReferenceSeq() == vs.isDisplayReferenceSeq()
229 && getFontSize() == vs.getFontSize()
230 && getFontStyle() == vs.getFontStyle()
231 && getIdWidth() == vs.getIdWidth()
232 && getIncrement() == vs.getIncrement()
233 && isRenderGaps() == vs.isRenderGaps()
234 && isRightAlignIds() == vs.isRightAlignIds()
235 && getScaleAboveWrapped() == vs.getScaleAboveWrapped()
236 && getScaleLeftWrapped() == vs.getScaleLeftWrapped()
237 && isScaleProteinAsCdna() == vs.isScaleProteinAsCdna()
238 && getScaleRightWrapped() == vs.getScaleRightWrapped()
239 && isSeqNameItalics() == vs.isSeqNameItalics()
240 && isShowAnnotation() == vs.isShowAnnotation()
241 && getShowBoxes() == vs.getShowBoxes()
242 && isShowColourText() == vs.isShowColourText()
243 && isShowDBRefs() == vs.isShowDBRefs()
244 && getShowHiddenMarkers() == vs.getShowHiddenMarkers()
245 && getShowJVSuffix() == vs.getShowJVSuffix()
246 && isShowNPFeats() == vs.isShowNPFeats()
247 && isShowSequenceFeaturesHeight() == vs
248 .isShowSequenceFeaturesHeight()
249 && isShowSequenceFeatures() == vs.isShowSequenceFeatures()
250 && getShowText() == vs.getShowText()
251 && getShowUnconserved() == vs.getShowUnconserved()
252 && getThreshold() == vs.getThreshold()
253 && getThresholdTextColour() == vs.getThresholdTextColour()
254 && isUpperCasebold() == vs.isUpperCasebold()
255 && getWrapAlignment() == vs.getWrapAlignment() && getWrappedWidth() == vs
258 * and compare non-primitive types; syntax below will match null with null values
261 && String.valueOf(getFontName()).equals(
262 String.valueOf(vs.getFontName()));
264 && String.valueOf(getTextColour()).equals(
265 String.valueOf(vs.getTextColour()));
267 && String.valueOf(getTextColour2()).equals(
268 String.valueOf(vs.getTextColour2()));
270 // return equivalent(this, (ViewStyle) other);
274 * Overridden to ensure that whenever vs1.equals(vs2) then vs1.hashCode() ==
278 public int hashCode()
281 * No need to include all properties, just a selection...
285 // Boolean.hashCode returns 1231 or 1237
286 hash += m++ * Boolean.valueOf(this.abovePIDThreshold).hashCode();
287 hash += m++ * Boolean.valueOf(this.centreColumnLabels).hashCode();
288 hash += m++ * Boolean.valueOf(this.colourAppliesToAllGroups).hashCode();
289 hash += m++ * Boolean.valueOf(this.displayReferenceSeq).hashCode();
290 hash += m++ * Boolean.valueOf(this.renderGaps).hashCode();
291 hash += m++ * Boolean.valueOf(this.rightAlignIds).hashCode();
292 hash += m++ * Boolean.valueOf(this.scaleProteinAsCdna).hashCode();
293 hash += m++ * Boolean.valueOf(this.scaleRightWrapped).hashCode();
294 hash += m++ * Boolean.valueOf(this.seqNameItalics).hashCode();
295 hash += m++ * Boolean.valueOf(this.showAnnotation).hashCode();
296 hash += m++ * Boolean.valueOf(this.showBoxes).hashCode();
297 hash += m++ * Boolean.valueOf(this.showdbrefs).hashCode();
298 hash += m++ * Boolean.valueOf(this.showJVSuffix).hashCode();
299 hash += m++ * Boolean.valueOf(this.showSequenceFeatures).hashCode();
300 hash += m++ * Boolean.valueOf(this.showUnconserved).hashCode();
301 hash += m++ * Boolean.valueOf(this.wrapAlignment).hashCode();
302 hash += m++ * this.charHeight;
303 hash += m++ * this.charWidth;
304 hash += m++ * fontSize;
305 hash += m++ * fontStyle;
306 hash += m++ * idWidth;
307 hash += String.valueOf(this.fontName).hashCode();
312 * @return the upperCasebold
315 public boolean isUpperCasebold()
317 return upperCasebold;
321 * @param upperCasebold
322 * the upperCasebold to set
325 public void setUpperCasebold(boolean upperCasebold)
327 this.upperCasebold = upperCasebold;
333 boolean wrapAlignment = false;
336 * number columns in wrapped alignment
340 private int fontStyle;
345 * @return true if percent identity threshold is applied to shading
348 public boolean getAbovePIDThreshold()
350 return abovePIDThreshold;
356 * @return DOCUMENT ME!
359 public int getCharHeight()
367 * @return DOCUMENT ME!
370 public int getCharWidth()
378 * @return flag indicating if colourchanges propagated to all groups
381 public boolean getColourAppliesToAllGroups()
383 return colourAppliesToAllGroups;
389 * @return DOCUMENT ME!
392 public boolean getColourText()
394 return showColourText;
400 * @return true if conservation based shading is enabled
403 public boolean getConservationSelected()
405 return conservationColourSelected;
411 * @return get scalar for bleaching colourschemes by conservation
414 public int getIncrement()
422 * @return DOCUMENT ME!
425 public boolean getScaleAboveWrapped()
427 return scaleAboveWrapped;
433 * @return DOCUMENT ME!
436 public boolean getScaleLeftWrapped()
438 return scaleLeftWrapped;
444 * @return DOCUMENT ME!
447 public boolean getScaleRightWrapped()
449 return scaleRightWrapped;
455 * @return DOCUMENT ME!
458 public boolean getShowBoxes()
464 public boolean getShowHiddenMarkers()
466 return showHiddenMarkers;
472 * @return DOCUMENT ME!
475 public boolean getShowJVSuffix()
483 * @return DOCUMENT ME!
486 public boolean getShowText()
492 public boolean getShowUnconserved()
494 return showUnconserved;
498 * @return the textColour
501 public Color getTextColour()
507 * @return the textColour2
510 public Color getTextColour2()
518 * @return DOCUMENT ME!
521 public int getThreshold()
527 * @return the thresholdTextColour
530 public int getThresholdTextColour()
532 return thresholdTextColour;
538 * @return DOCUMENT ME!
541 public boolean getWrapAlignment()
543 return wrapAlignment;
549 * @return DOCUMENT ME!
552 public int getWrappedWidth()
558 public boolean isColourByReferenceSeq()
560 return colourByReferenceSeq;
564 * @return the conservationColourSelected
567 public boolean isConservationColourSelected()
569 return conservationColourSelected;
573 public boolean isDisplayReferenceSeq()
575 return displayReferenceSeq;
579 * @return the renderGaps
582 public boolean isRenderGaps()
588 public boolean isRightAlignIds()
590 return rightAlignIds;
594 * @return the seqNameItalics
597 public boolean isSeqNameItalics()
599 return seqNameItalics;
603 public boolean isShowAnnotation()
605 return showAnnotation;
609 * @return the showColourText
612 public boolean isShowColourText()
614 return showColourText;
618 * @return the showSeqFeaturesHeight
621 public boolean isShowSequenceFeaturesHeight()
623 return showSeqFeaturesHeight;
627 public boolean isShowSequenceFeatures()
629 return showSequenceFeatures;
637 * indicate if percent identity threshold is applied to shading
640 public void setAbovePIDThreshold(boolean b)
642 abovePIDThreshold = b;
653 public void setCharHeight(int h)
665 public void setCharWidth(int w)
673 * indicating if subsequent colourscheme changes will be propagated
677 public void setColourAppliesToAllGroups(boolean b)
679 colourAppliesToAllGroups = b;
683 public void setColourByReferenceSeq(boolean colourByReferenceSeq)
685 this.colourByReferenceSeq = colourByReferenceSeq;
695 public void setColourText(boolean state)
697 showColourText = state;
701 * @param conservationColourSelected
702 * the conservationColourSelected to set
705 public void setConservationColourSelected(
706 boolean conservationColourSelected)
708 this.conservationColourSelected = conservationColourSelected;
715 * enable conservation based shading
718 public void setConservationSelected(boolean b)
720 conservationColourSelected = b;
724 public void setDisplayReferenceSeq(boolean displayReferenceSeq)
726 this.displayReferenceSeq = displayReferenceSeq;
732 * set the scalar for bleaching colourschemes according to degree of
736 public void setIncrement(int inc)
748 public void setRenderGaps(boolean state)
754 public void setRightAlignIds(boolean rightAlignIds)
756 this.rightAlignIds = rightAlignIds;
766 public void setScaleAboveWrapped(boolean b)
768 scaleAboveWrapped = b;
778 public void setScaleLeftWrapped(boolean b)
780 scaleLeftWrapped = b;
786 * @param scaleRightWrapped
791 public void setScaleRightWrapped(boolean b)
793 scaleRightWrapped = b;
797 public void setSeqNameItalics(boolean italics)
799 seqNameItalics = italics;
803 public void setShowAnnotation(boolean b)
815 public void setShowBoxes(boolean state)
821 * @param showColourText
822 * the showColourText to set
825 public void setShowColourText(boolean showColourText)
827 this.showColourText = showColourText;
831 public void setShowHiddenMarkers(boolean show)
833 showHiddenMarkers = show;
843 public void setShowJVSuffix(boolean b)
849 public void setShowSequenceFeaturesHeight(boolean selected)
851 showSeqFeaturesHeight = selected;
859 * features are displayed if true
862 public void setShowSequenceFeatures(boolean b)
864 showSequenceFeatures = b;
874 public void setShowText(boolean state)
880 public void setShowUnconserved(boolean showunconserved)
882 showUnconserved = showunconserved;
887 * the textColour to set
890 public void setTextColour(Color textColour)
892 this.textColour = textColour;
897 * the textColour2 to set
900 public void setTextColour2(Color textColour2)
902 this.textColour2 = textColour2;
912 public void setThreshold(int thresh)
918 * @param thresholdTextColour
919 * the thresholdTextColour to set
922 public void setThresholdTextColour(int thresholdTextColour)
924 this.thresholdTextColour = thresholdTextColour;
934 public void setWrapAlignment(boolean state)
936 wrapAlignment = state;
946 public void setWrappedWidth(int w)
948 this.wrappedWidth = w;
952 public boolean sameStyle(ViewStyleI that)
954 return this.equals(that);
958 public String getFontName()
964 public int getFontSize()
970 public int getFontStyle()
976 public void setFontName(String name)
982 public void setFontSize(int size)
989 public void setFontStyle(int style)
995 public int getIdWidth()
1002 * the idWidth to set
1005 public void setIdWidth(int idWidth)
1007 this.idWidth = idWidth;
1011 * @return the centreColumnLabels
1014 public boolean isCentreColumnLabels()
1016 return centreColumnLabels;
1020 * @param centreColumnLabels
1021 * the centreColumnLabels to set
1024 public void setCentreColumnLabels(boolean centreColumnLabels)
1026 this.centreColumnLabels = centreColumnLabels;
1030 * @return the showdbrefs
1033 public boolean isShowDBRefs()
1040 * the showdbrefs to set
1043 public void setShowDBRefs(boolean showdbrefs)
1045 this.showdbrefs = showdbrefs;
1049 * @return the shownpfeats
1052 public boolean isShowNPFeats()
1058 * @param shownpfeats
1059 * the shownpfeats to set
1062 public void setShowNPFeats(boolean shownpfeats)
1064 this.shownpfeats = shownpfeats;
1068 public boolean isScaleProteinAsCdna()
1070 return this.scaleProteinAsCdna;
1074 public void setScaleProteinAsCdna(boolean b)
1076 this.scaleProteinAsCdna = b;