5 import jalview.analysis.NJTree;
\r
6 import jalview.datamodel.*;
\r
7 import jalview.schemes.*;
\r
10 public class AlignViewport
\r
18 boolean showFullId = false;
\r
19 boolean showText=true;
\r
20 boolean showColourText=false;
\r
21 boolean showBoxes=true;
\r
22 boolean wrapAlignment=false;
\r
23 boolean renderGaps = true;
\r
24 boolean showSequenceFeatures = false;
\r
26 boolean colourAppliesToAllGroups = true;
\r
27 ColourSchemeI globalColourScheme = null;
\r
28 boolean conservationColourSelected = false;
\r
29 boolean abovePIDThreshold = false;
\r
31 SequenceGroup selectionGroup = new SequenceGroup();
\r
33 RendererI renderer = new SequenceRenderer(this);
\r
40 Font font = new Font("SansSerif",Font.PLAIN,10);
\r
41 AlignmentI alignment;
\r
43 ColumnSelection colSel = new ColumnSelection();
\r
45 String visibleConsensus;
\r
50 NJTree currentTree = null;
\r
53 public AlignViewport(AlignmentI da,
\r
56 boolean wrapAlignment) {
\r
57 this(0,da.getWidth()-1,0,da.getHeight()-1,
\r
65 public AlignViewport(int startRes, int endRes,
\r
66 int startSeq, int endSeq,
\r
69 boolean wrapAlignment) {
\r
71 this.startRes = startRes;
\r
72 this.endRes = endRes;
\r
73 this.startSeq = startSeq;
\r
74 this.endSeq = endSeq;
\r
75 this.showText = showText;
\r
76 this.showBoxes = showBoxes;
\r
77 this.wrapAlignment = wrapAlignment;
\r
82 public void showSequenceFeatures(boolean b)
\r
84 showSequenceFeatures = b;
\r
87 public String getVisibleConsensus()
\r
89 return visibleConsensus;
\r
92 Vector consensus = new Vector();
\r
93 public Vector getConsensus(boolean recalculate)
\r
95 if(recalculate || consensus.size()<1)
\r
97 consensus = alignment.getAAFrequency();
\r
98 StringBuffer sb = new StringBuffer();
\r
99 Hashtable hash = null;
\r
100 for (int i = 0; i < consensus.size(); i++)
\r
102 hash = (Hashtable) consensus.elementAt(i);
\r
103 sb.append(hash.get("maxResidue").toString().charAt(0));
\r
105 visibleConsensus = sb.toString();
\r
112 public SequenceGroup getSelectionGroup()
\r
114 return selectionGroup;
\r
117 public void setSelectionGroup(SequenceGroup sg)
\r
119 selectionGroup = sg;
\r
123 public boolean getConservationSelected()
\r
125 return conservationColourSelected;
\r
128 public void setConservationSelected(boolean b)
\r
130 conservationColourSelected = b;
\r
133 public boolean getAbovePIDThreshold()
\r
135 return abovePIDThreshold;
\r
138 public void setAbovePIDThreshold(boolean b)
\r
140 abovePIDThreshold = b;
\r
143 public int getStartRes() {
\r
147 public int getEndRes() {
\r
151 public int getStartSeq() {
\r
155 public void setGlobalColourScheme(ColourSchemeI cs)
\r
157 globalColourScheme = cs;
\r
160 public ColourSchemeI getGlobalColourScheme()
\r
162 return globalColourScheme;
\r
166 public void setStartRes(int res) {
\r
167 this.startRes = res;
\r
169 public void setStartSeq(int seq) {
\r
170 this.startSeq = seq;
\r
172 public void setEndRes(int res) {
\r
173 if (res > alignment.getWidth()-1) {
\r
174 System.out.println(" Corrected res from " + res + " to maximum " + (alignment.getWidth()-1));
\r
175 res = alignment.getWidth() -1;
\r
182 public void setEndSeq(int seq) {
\r
183 if (seq > alignment.getHeight()) {
\r
184 seq = alignment.getHeight();
\r
191 public int getEndSeq() {
\r
195 public void setFont(Font f) {
\r
197 javax.swing.JFrame temp = new javax.swing.JFrame();
\r
199 java.awt.FontMetrics fm = temp.getGraphics().getFontMetrics(font);
\r
200 setCharHeight(fm.getHeight());
\r
201 setCharWidth(fm.charWidth('M'));
\r
204 public Font getFont() {
\r
207 public void setCharWidth(int w) {
\r
208 this.charWidth = w;
\r
210 public int getCharWidth() {
\r
213 public void setCharHeight(int h) {
\r
214 this.charHeight = h;
\r
216 public int getCharHeight() {
\r
219 public void setChunkWidth(int w) {
\r
220 this.chunkWidth = w;
\r
222 public int getChunkWidth() {
\r
225 public void setChunkHeight(int h) {
\r
226 this.chunkHeight = h;
\r
228 public int getChunkHeight() {
\r
229 return chunkHeight;
\r
231 public AlignmentI getAlignment() {
\r
234 public void setAlignment(AlignmentI align) {
\r
235 this.alignment = align;
\r
238 public void setWrapAlignment(boolean state) {
\r
239 wrapAlignment = state;
\r
241 public void setShowText(boolean state) {
\r
245 public void setRenderGaps(boolean state){
\r
246 renderGaps = state;
\r
247 if(renderer instanceof SequenceRenderer)
\r
249 SequenceRenderer sr = (SequenceRenderer)renderer;
\r
250 sr.renderGaps(state);
\r
255 public boolean getColourText()
\r
257 return showColourText;
\r
260 public void setColourText(boolean state)
\r
262 showColourText = state;
\r
265 public void setShowBoxes(boolean state) {
\r
269 public boolean getWrapAlignment() {
\r
270 return wrapAlignment;
\r
272 public boolean getShowText() {
\r
275 public boolean getShowBoxes() {
\r
279 public char getGapCharacter() {
\r
280 return getAlignment().getGapCharacter();
\r
282 public void setGapCharacter(char gap) {
\r
283 if (getAlignment() != null) {
\r
284 getAlignment().setGapCharacter(gap);
\r
287 public void setThreshold(int thresh) {
\r
288 threshold = thresh;
\r
290 public int getThreshold() {
\r
293 public void setIncrement(int inc) {
\r
296 public int getIncrement() {
\r
299 public int getIndex(int y) {
\r
301 int starty = getStartSeq();
\r
302 int endy = getEndSeq();
\r
304 for (int i = starty; i <= endy; i++) {
\r
305 if (i < alignment.getHeight() && alignment.getSequenceAt(i) != null) {
\r
306 int y2 = y1 + getCharHeight();
\r
308 if (y>=y1 && y <=y2) {
\r
319 public ColumnSelection getColumnSelection() {
\r
323 public void resetSeqLimits(int height) {
\r
324 setEndSeq(height/getCharHeight());
\r
326 public void setCurrentTree(NJTree tree) {
\r
327 currentTree = tree;
\r
329 public NJTree getCurrentTree() {
\r
330 return currentTree;
\r
333 public void setRenderer(RendererI rend) {
\r
334 this.renderer = rend;
\r
337 public RendererI getRenderer() {
\r
341 public void setColourAppliesToAllGroups(boolean b)
\r
342 { colourAppliesToAllGroups = b; }
\r
344 public boolean getColourAppliesToAllGroups()
\r
345 {return colourAppliesToAllGroups; }
\r
347 public boolean getShowFullId()
\r
352 public void setShowFullId(boolean b)
\r