5 import jalview.analysis.NJTree;
\r
6 import jalview.datamodel.*;
\r
7 import jalview.schemes.*;
\r
10 public class AlignViewport
\r
18 boolean showScores=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 = true;
\r
26 ColourSchemeI globalColourScheme = null;
\r
27 boolean conservationColourSelected = false;
\r
29 SequenceGroup rubberbandGroup = null;
\r
31 RendererI renderer = new SequenceRenderer(this);
\r
38 Font font = new Font("SansSerif",Font.PLAIN,10);
\r
39 AlignmentI alignment;
\r
41 Selection sel = new Selection(this);
\r
42 ColumnSelection colSel = new ColumnSelection();
\r
46 String visibleConsensus;
\r
51 NJTree currentTree = null;
\r
58 public AlignViewport(AlignmentI da,
\r
62 boolean wrapAlignment) {
\r
63 this(0,da.getWidth()-1,0,da.getHeight()-1,showScores,
\r
71 public AlignViewport(int startRes, int endRes,
\r
72 int startSeq, int endSeq,
\r
76 boolean wrapAlignment) {
\r
78 this.startRes = startRes;
\r
79 this.endRes = endRes;
\r
80 this.startSeq = startSeq;
\r
81 this.endSeq = endSeq;
\r
83 this.showScores = showScores;
\r
84 this.showText = showText;
\r
85 this.showBoxes = showBoxes;
\r
86 this.wrapAlignment = wrapAlignment;
\r
88 // og = new AlignmentOutputGenerator(this);
\r
93 public void showSequenceFeatures(boolean b)
\r
95 showSequenceFeatures = b;
\r
98 public String getVisibleConsensus()
\r
100 return visibleConsensus;
\r
103 Vector consensus = new Vector();
\r
104 public Vector getConsensus(boolean recalculate)
\r
106 if(recalculate || consensus.size()<1)
\r
108 consensus = alignment.getAAFrequency();
\r
109 StringBuffer sb = new StringBuffer();
\r
110 Hashtable hash = null;
\r
111 for (int i = 0; i < consensus.size(); i++)
\r
113 hash = (Hashtable) consensus.elementAt(i);
\r
114 sb.append(hash.get("maxResidue").toString().charAt(0));
\r
116 visibleConsensus = sb.toString();
\r
123 public SequenceGroup getRubberbandGroup()
\r
125 return rubberbandGroup;
\r
128 public void setRubberbandGroup(SequenceGroup sg)
\r
130 rubberbandGroup = sg;
\r
133 public boolean getConservationSelected()
\r
135 return conservationColourSelected;
\r
138 public void setConservationSelected(boolean b)
\r
140 conservationColourSelected = 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
237 public void setShowScores(boolean state) {
\r
238 showScores = state;
\r
240 public void setWrapAlignment(boolean state) {
\r
241 wrapAlignment = state;
\r
243 public void setShowText(boolean state) {
\r
247 public void setRenderGaps(boolean state){
\r
248 renderGaps = state;
\r
249 if(renderer instanceof SequenceRenderer)
\r
251 SequenceRenderer sr = (SequenceRenderer)renderer;
\r
252 sr.renderGaps(state);
\r
257 public boolean getColourText()
\r
259 return showColourText;
\r
262 public void setColourText(boolean state)
\r
264 showColourText = state;
\r
267 public void setShowBoxes(boolean state) {
\r
270 public boolean getShowScores() {
\r
273 public boolean getWrapAlignment() {
\r
274 return wrapAlignment;
\r
276 public boolean getShowText() {
\r
279 public boolean getShowBoxes() {
\r
283 public char getGapCharacter() {
\r
284 return getAlignment().getGapCharacter();
\r
286 public void setGapCharacter(char gap) {
\r
287 if (getAlignment() != null) {
\r
288 getAlignment().setGapCharacter(gap);
\r
291 public void setThreshold(int thresh) {
\r
292 threshold = thresh;
\r
294 public int getThreshold() {
\r
297 public void setIncrement(int inc) {
\r
300 public int getIncrement() {
\r
303 public int getIndex(int y) {
\r
305 int starty = getStartSeq();
\r
306 int endy = getEndSeq();
\r
308 for (int i = starty; i <= endy; i++) {
\r
309 if (i < alignment.getHeight() && alignment.getSequenceAt(i) != null) {
\r
310 int y2 = y1 + getCharHeight();
\r
312 if (y>=y1 && y <=y2) {
\r
322 public Selection getSelection() {
\r
325 public ColumnSelection getColumnSelection() {
\r
328 public OutputGenerator getOutputGenerator() {
\r
331 public void resetSeqLimits(int height) {
\r
333 setEndSeq(height/getCharHeight());
\r
335 public void setCurrentTree(NJTree tree) {
\r
336 currentTree = tree;
\r
338 public NJTree getCurrentTree() {
\r
339 return currentTree;
\r
342 public void setRenderer(RendererI rend) {
\r
343 this.renderer = rend;
\r
346 public RendererI getRenderer() {
\r
349 public int getPIDWindow() {
\r
352 public void setPIDWindow(int window) {
\r
353 this.window = window;
\r
356 public int getPIDBaseline() {
\r
359 public void setPIDBaseline(int baseline) {
\r
360 this.baseline = baseline;
\r
363 public void setKmers(Vector kmers) {
\r
364 this.kmers = kmers;
\r
367 public Vector getKmers() {
\r