1 package jalview.viewmodel.styles;
3 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
262 && String.valueOf(getFontName()).equals(
263 String.valueOf(vs.getFontName()));
265 && String.valueOf(getTextColour()).equals(
266 String.valueOf(vs.getTextColour()));
268 && String.valueOf(getTextColour2()).equals(
269 String.valueOf(vs.getTextColour2()));
271 // return equivalent(this, (ViewStyle) other);
275 * Overridden to ensure that whenever vs1.equals(vs2) then vs1.hashCode() ==
279 public int hashCode()
282 * No need to include all properties, just a selection...
286 // Boolean.hashCode returns 1231 or 1237
287 hash += m++ * Boolean.valueOf(this.abovePIDThreshold).hashCode();
288 hash += m++ * Boolean.valueOf(this.centreColumnLabels).hashCode();
289 hash += m++ * Boolean.valueOf(this.colourAppliesToAllGroups).hashCode();
290 hash += m++ * Boolean.valueOf(this.displayReferenceSeq).hashCode();
291 hash += m++ * Boolean.valueOf(this.renderGaps).hashCode();
292 hash += m++ * Boolean.valueOf(this.rightAlignIds).hashCode();
293 hash += m++ * Boolean.valueOf(this.scaleProteinAsCdna).hashCode();
294 hash += m++ * Boolean.valueOf(this.scaleRightWrapped).hashCode();
295 hash += m++ * Boolean.valueOf(this.seqNameItalics).hashCode();
296 hash += m++ * Boolean.valueOf(this.showAnnotation).hashCode();
297 hash += m++ * Boolean.valueOf(this.showBoxes).hashCode();
298 hash += m++ * Boolean.valueOf(this.showdbrefs).hashCode();
299 hash += m++ * Boolean.valueOf(this.showJVSuffix).hashCode();
300 hash += m++ * Boolean.valueOf(this.showSequenceFeatures).hashCode();
301 hash += m++ * Boolean.valueOf(this.showUnconserved).hashCode();
302 hash += m++ * Boolean.valueOf(this.wrapAlignment).hashCode();
303 hash += m++ * this.charHeight;
304 hash += m++ * this.charWidth;
305 hash += m++ * fontSize;
306 hash += m++ * fontStyle;
307 hash += m++ * idWidth;
308 hash += String.valueOf(this.fontName).hashCode();
313 * @return the upperCasebold
316 public boolean isUpperCasebold()
318 return upperCasebold;
322 * @param upperCasebold
323 * the upperCasebold to set
326 public void setUpperCasebold(boolean upperCasebold)
328 this.upperCasebold = upperCasebold;
334 boolean wrapAlignment = false;
337 * number columns in wrapped alignment
341 private int fontStyle;
346 * @return true if percent identity threshold is applied to shading
349 public boolean getAbovePIDThreshold()
351 return abovePIDThreshold;
357 * @return DOCUMENT ME!
360 public int getCharHeight()
368 * @return DOCUMENT ME!
371 public int getCharWidth()
379 * @return flag indicating if colourchanges propagated to all groups
382 public boolean getColourAppliesToAllGroups()
384 return colourAppliesToAllGroups;
390 * @return DOCUMENT ME!
393 public boolean getColourText()
395 return showColourText;
401 * @return true if conservation based shading is enabled
404 public boolean getConservationSelected()
406 return conservationColourSelected;
412 * @return get scalar for bleaching colourschemes by conservation
415 public int getIncrement()
423 * @return DOCUMENT ME!
426 public boolean getScaleAboveWrapped()
428 return scaleAboveWrapped;
434 * @return DOCUMENT ME!
437 public boolean getScaleLeftWrapped()
439 return scaleLeftWrapped;
445 * @return DOCUMENT ME!
448 public boolean getScaleRightWrapped()
450 return scaleRightWrapped;
456 * @return DOCUMENT ME!
459 public boolean getShowBoxes()
465 public boolean getShowHiddenMarkers()
467 return showHiddenMarkers;
473 * @return DOCUMENT ME!
476 public boolean getShowJVSuffix()
484 * @return DOCUMENT ME!
487 public boolean getShowText()
493 public boolean getShowUnconserved()
495 return showUnconserved;
499 * @return the textColour
502 public Color getTextColour()
508 * @return the textColour2
511 public Color getTextColour2()
519 * @return DOCUMENT ME!
522 public int getThreshold()
528 * @return the thresholdTextColour
531 public int getThresholdTextColour()
533 return thresholdTextColour;
539 * @return DOCUMENT ME!
542 public boolean getWrapAlignment()
544 return wrapAlignment;
550 * @return DOCUMENT ME!
553 public int getWrappedWidth()
559 public boolean isColourByReferenceSeq()
561 return colourByReferenceSeq;
565 * @return the conservationColourSelected
568 public boolean isConservationColourSelected()
570 return conservationColourSelected;
574 public boolean isDisplayReferenceSeq()
576 return displayReferenceSeq;
580 * @return the renderGaps
583 public boolean isRenderGaps()
589 public boolean isRightAlignIds()
591 return rightAlignIds;
595 * @return the seqNameItalics
598 public boolean isSeqNameItalics()
600 return seqNameItalics;
604 public boolean isShowAnnotation()
606 return showAnnotation;
610 * @return the showColourText
613 public boolean isShowColourText()
615 return showColourText;
619 * @return the showSeqFeaturesHeight
622 public boolean isShowSequenceFeaturesHeight()
624 return showSeqFeaturesHeight;
628 public boolean isShowSequenceFeatures()
630 return showSequenceFeatures;
638 * indicate if percent identity threshold is applied to shading
641 public void setAbovePIDThreshold(boolean b)
643 abovePIDThreshold = b;
653 public void setCharHeight(int h)
665 public void setCharWidth(int w)
672 * indicating if subsequent colourscheme changes will be propagated
676 public void setColourAppliesToAllGroups(boolean b)
678 colourAppliesToAllGroups = b;
682 public void setColourByReferenceSeq(boolean colourByReferenceSeq)
684 this.colourByReferenceSeq = colourByReferenceSeq;
694 public void setColourText(boolean state)
696 showColourText = state;
700 * @param conservationColourSelected
701 * the conservationColourSelected to set
704 public void setConservationColourSelected(
705 boolean conservationColourSelected)
707 this.conservationColourSelected = conservationColourSelected;
714 * enable conservation based shading
717 public void setConservationSelected(boolean b)
719 conservationColourSelected = b;
723 public void setDisplayReferenceSeq(boolean displayReferenceSeq)
725 this.displayReferenceSeq = displayReferenceSeq;
731 * set the scalar for bleaching colourschemes according to degree of
735 public void setIncrement(int inc)
747 public void setRenderGaps(boolean state)
753 public void setRightAlignIds(boolean rightAlignIds)
755 this.rightAlignIds = rightAlignIds;
765 public void setScaleAboveWrapped(boolean b)
767 scaleAboveWrapped = b;
777 public void setScaleLeftWrapped(boolean b)
779 scaleLeftWrapped = b;
785 * @param scaleRightWrapped
790 public void setScaleRightWrapped(boolean b)
792 scaleRightWrapped = b;
796 public void setSeqNameItalics(boolean italics)
798 seqNameItalics = italics;
802 public void setShowAnnotation(boolean b)
814 public void setShowBoxes(boolean state)
820 * @param showColourText
821 * the showColourText to set
824 public void setShowColourText(boolean showColourText)
826 this.showColourText = showColourText;
830 public void setShowHiddenMarkers(boolean show)
832 showHiddenMarkers = show;
842 public void setShowJVSuffix(boolean b)
848 public void setShowSequenceFeaturesHeight(boolean selected)
850 showSeqFeaturesHeight = selected;
858 * features are displayed if true
861 public void setShowSequenceFeatures(boolean b)
863 showSequenceFeatures = b;
873 public void setShowText(boolean state)
879 public void setShowUnconserved(boolean showunconserved)
881 showUnconserved = showunconserved;
886 * the textColour to set
889 public void setTextColour(Color textColour)
891 this.textColour = textColour;
896 * the textColour2 to set
899 public void setTextColour2(Color textColour2)
901 this.textColour2 = textColour2;
911 public void setThreshold(int thresh)
917 * @param thresholdTextColour
918 * the thresholdTextColour to set
921 public void setThresholdTextColour(int thresholdTextColour)
923 this.thresholdTextColour = thresholdTextColour;
933 public void setWrapAlignment(boolean state)
935 wrapAlignment = state;
945 public void setWrappedWidth(int w)
947 this.wrappedWidth = w;
951 public boolean sameStyle(ViewStyleI that)
953 return this.equals(that);
957 public String getFontName()
963 public int getFontSize()
969 public int getFontStyle()
975 public void setFontName(String name)
981 public void setFontSize(int size)
988 public void setFontStyle(int style)
994 public int getIdWidth()
1001 * the idWidth to set
1004 public void setIdWidth(int idWidth)
1006 this.idWidth = idWidth;
1010 * @return the centreColumnLabels
1013 public boolean isCentreColumnLabels()
1015 return centreColumnLabels;
1019 * @param centreColumnLabels
1020 * the centreColumnLabels to set
1023 public void setCentreColumnLabels(boolean centreColumnLabels)
1025 this.centreColumnLabels = centreColumnLabels;
1029 * @return the showdbrefs
1032 public boolean isShowDBRefs()
1039 * the showdbrefs to set
1042 public void setShowDBRefs(boolean showdbrefs)
1044 this.showdbrefs = showdbrefs;
1048 * @return the shownpfeats
1051 public boolean isShowNPFeats()
1057 * @param shownpfeats
1058 * the shownpfeats to set
1061 public void setShowNPFeats(boolean shownpfeats)
1063 this.shownpfeats = shownpfeats;
1067 public boolean isScaleProteinAsCdna()
1069 return this.scaleProteinAsCdna;
1073 public void setScaleProteinAsCdna(boolean b)
1075 this.scaleProteinAsCdna = b;