1 package jalview.viewmodel.styles;
3 import jalview.api.ViewStyleI;
6 import java.lang.reflect.Method;
7 import java.util.HashMap;
10 * A container for holding alignment view properties. View properties are
11 * data-independent, which means they can be safely copied between views
12 * involving different alignment data without causing exceptions in the
18 public class ViewStyle implements ViewStyleI
21 private boolean abovePIDThreshold = false;
28 * gui state - changes to colour scheme propagated to all groups
30 private boolean colourAppliesToAllGroups;
33 * colour according to the reference sequence defined on the alignment
35 private boolean colourByReferenceSeq = false;
37 boolean conservationColourSelected = false;
40 * show the reference sequence in the alignment view
42 private boolean displayReferenceSeq = false;
44 private int increment;
47 * display gap characters
49 boolean renderGaps = true;
51 private boolean rightAlignIds = false;
53 boolean scaleAboveWrapped = false;
55 boolean scaleLeftWrapped = true;
57 boolean scaleRightWrapped = true;
59 boolean seqNameItalics;
62 * show annotation tracks on the alignment
64 private boolean showAnnotation = true;
67 * render each residue in a coloured box
69 boolean showBoxes = true;
72 * Colour sequence text
74 boolean showColourText = false;
79 boolean showHiddenMarkers = true;
82 * show /start-end in ID panel
84 boolean showJVSuffix = true;
87 * scale features height according to score
89 boolean showSeqFeaturesHeight;
92 * display setting for showing/hiding sequence features on alignment view
94 boolean showSequenceFeatures = false;
97 * display sequence symbols
99 boolean showText = true;
102 * show non-conserved residues only
104 protected boolean showUnconserved = false;
106 Color textColour = Color.black;
108 Color textColour2 = Color.white;
111 * PID or consensus threshold
116 * threshold for switching between textColour & textColour2
118 int thresholdTextColour = 0;
121 * upper case characters in sequence are shown in bold
123 boolean upperCasebold = false;
125 public ViewStyle(ViewStyleI viewStyle)
127 configureFrom(viewStyle);
134 private void configureFrom(ViewStyleI viewStyle)
136 HashMap<String, Method> getters = new HashMap<String, Method>(), isErs = new HashMap<String, Method>();
137 HashMap<String, Method> setters = new HashMap<String, Method>();
138 // Match Getters and Setters
139 for (Method m : ViewStyleI.class.getMethods())
141 if (m.getDeclaringClass() == ViewStyleI.class)
143 if (m.getName().startsWith("get"))
145 getters.put(m.getName().substring(3), m);
147 if (m.getName().startsWith("is"))
149 isErs.put(m.getName().substring(2), m);
151 if (m.getName().startsWith("set"))
153 setters.put(m.getName().substring(3), m);
157 // try and do the set thing
158 for (String prop : setters.keySet())
160 Method getter = getters.get(prop);
161 Method setter = setters.get(prop);
164 getter = isErs.get(prop);
166 if (getter != null && setter != null)
170 setter.invoke(this, getter.invoke(viewStyle));
171 } catch (Exception q)
173 System.err.println("Unexpected exception setting view property "
174 + prop + " by reflection");
183 * @return the upperCasebold
186 public boolean isUpperCasebold()
188 return upperCasebold;
192 * @param upperCasebold
193 * the upperCasebold to set
196 public void setUpperCasebold(boolean upperCasebold)
198 this.upperCasebold = upperCasebold;
204 boolean wrapAlignment = false;
207 * number columns in wrapped alignment
214 * @return true if percent identity threshold is applied to shading
217 public boolean getAbovePIDThreshold()
219 return abovePIDThreshold;
225 * @return DOCUMENT ME!
228 public int getCharHeight()
236 * @return DOCUMENT ME!
239 public int getCharWidth()
247 * @return flag indicating if colourchanges propagated to all groups
250 public boolean getColourAppliesToAllGroups()
252 return colourAppliesToAllGroups;
258 * @return DOCUMENT ME!
261 public boolean getColourText()
263 return showColourText;
269 * @return true if conservation based shading is enabled
272 public boolean getConservationSelected()
274 return conservationColourSelected;
280 * @return get scalar for bleaching colourschemes by conservation
283 public int getIncrement()
291 * @return DOCUMENT ME!
294 public boolean getScaleAboveWrapped()
296 return scaleAboveWrapped;
302 * @return DOCUMENT ME!
305 public boolean getScaleLeftWrapped()
307 return scaleLeftWrapped;
313 * @return DOCUMENT ME!
316 public boolean getScaleRightWrapped()
318 return scaleRightWrapped;
324 * @return DOCUMENT ME!
327 public boolean getShowBoxes()
333 public boolean getShowHiddenMarkers()
335 return showHiddenMarkers;
341 * @return DOCUMENT ME!
344 public boolean getShowJVSuffix()
352 * @return DOCUMENT ME!
355 public boolean getShowText()
361 public boolean getShowUnconserved()
363 return showUnconserved;
367 * @return the textColour
370 public Color getTextColour()
376 * @return the textColour2
379 public Color getTextColour2()
387 * @return DOCUMENT ME!
390 public int getThreshold()
396 * @return the thresholdTextColour
399 public int getThresholdTextColour()
401 return thresholdTextColour;
407 * @return DOCUMENT ME!
410 public boolean getWrapAlignment()
412 return wrapAlignment;
418 * @return DOCUMENT ME!
421 public int getWrappedWidth()
427 public boolean isColourByReferenceSeq()
429 return colourByReferenceSeq;
433 * @return the conservationColourSelected
436 public boolean isConservationColourSelected()
438 return conservationColourSelected;
442 public boolean isDisplayReferenceSeq()
444 return displayReferenceSeq;
448 * @return the renderGaps
451 public boolean isRenderGaps()
457 public boolean isRightAlignIds()
459 return rightAlignIds;
463 * @return the seqNameItalics
466 public boolean isSeqNameItalics()
468 return seqNameItalics;
472 public boolean isShowAnnotation()
474 return showAnnotation;
478 * @return the showColourText
481 public boolean isShowColourText()
483 return showColourText;
487 * @return the showSeqFeaturesHeight
490 public boolean isShowSeqFeaturesHeight()
492 return showSeqFeaturesHeight;
496 public boolean isShowSequenceFeatures()
498 return showSequenceFeatures;
502 public boolean isShowSequenceFeaturesHeight()
505 return showSeqFeaturesHeight;
513 * indicate if percent identity threshold is applied to shading
516 public void setAbovePIDThreshold(boolean b)
518 abovePIDThreshold = b;
528 public void setCharHeight(int h)
540 public void setCharWidth(int w)
548 * indicating if subsequent colourscheme changes will be propagated
552 public void setColourAppliesToAllGroups(boolean b)
554 colourAppliesToAllGroups = b;
558 public void setColourByReferenceSeq(boolean colourByReferenceSeq)
560 this.colourByReferenceSeq = colourByReferenceSeq;
570 public void setColourText(boolean state)
572 showColourText = state;
576 * @param conservationColourSelected
577 * the conservationColourSelected to set
580 public void setConservationColourSelected(
581 boolean conservationColourSelected)
583 this.conservationColourSelected = conservationColourSelected;
590 * enable conservation based shading
593 public void setConservationSelected(boolean b)
595 conservationColourSelected = b;
599 public void setDisplayReferenceSeq(boolean displayReferenceSeq)
601 this.displayReferenceSeq = displayReferenceSeq;
607 * set the scalar for bleaching colourschemes according to degree of
611 public void setIncrement(int inc)
623 public void setRenderGaps(boolean state)
629 public void setRightAlignIds(boolean rightAlignIds)
631 this.rightAlignIds = rightAlignIds;
641 public void setScaleAboveWrapped(boolean b)
643 scaleAboveWrapped = b;
653 public void setScaleLeftWrapped(boolean b)
655 scaleLeftWrapped = b;
661 * @param scaleRightWrapped
666 public void setScaleRightWrapped(boolean b)
668 scaleRightWrapped = b;
672 public void setSeqNameItalics(boolean italics)
674 seqNameItalics = italics;
678 public void setShowAnnotation(boolean b)
690 public void setShowBoxes(boolean state)
696 * @param showColourText
697 * the showColourText to set
700 public void setShowColourText(boolean showColourText)
702 this.showColourText = showColourText;
706 public void setShowHiddenMarkers(boolean show)
708 showHiddenMarkers = show;
718 public void setShowJVSuffix(boolean b)
724 public void setShowSeqFeaturesHeight(boolean selected)
726 showSeqFeaturesHeight = selected;
734 * features are displayed if true
737 public void setShowSequenceFeatures(boolean b)
739 showSequenceFeatures = b;
749 public void setShowText(boolean state)
755 public void setShowUnconserved(boolean showunconserved)
757 showUnconserved = showunconserved;
762 * the textColour to set
765 public void setTextColour(Color textColour)
767 this.textColour = textColour;
772 * the textColour2 to set
775 public void setTextColour2(Color textColour2)
777 this.textColour2 = textColour2;
787 public void setThreshold(int thresh)
793 * @param thresholdTextColour
794 * the thresholdTextColour to set
797 public void setThresholdTextColour(int thresholdTextColour)
799 this.thresholdTextColour = thresholdTextColour;
809 public void setWrapAlignment(boolean state)
811 wrapAlignment = state;
821 public void setWrappedWidth(int w)
823 this.wrappedWidth = w;