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
25 ColourSchemeI globalColourScheme = null;
\r
26 boolean conservationColourSelected = false;
\r
28 SequenceGroup rubberbandGroup = null;
\r
30 RendererI renderer = new SequenceRenderer(this);
\r
37 Font font = new Font("SansSerif",Font.PLAIN,10);
\r
38 AlignmentI alignment;
\r
40 Selection sel = new Selection(this);
\r
41 ColumnSelection colSel = new ColumnSelection();
\r
45 String visibleConsensus;
\r
50 NJTree currentTree = null;
\r
57 public AlignViewport(AlignmentI da,
\r
61 boolean wrapAlignment) {
\r
62 this(0,da.getWidth()-1,0,da.getHeight()-1,showScores,
\r
70 public AlignViewport(int startRes, int endRes,
\r
71 int startSeq, int endSeq,
\r
75 boolean wrapAlignment) {
\r
77 this.startRes = startRes;
\r
78 this.endRes = endRes;
\r
79 this.startSeq = startSeq;
\r
80 this.endSeq = endSeq;
\r
82 this.showScores = showScores;
\r
83 this.showText = showText;
\r
84 this.showBoxes = showBoxes;
\r
85 this.wrapAlignment = wrapAlignment;
\r
87 // og = new AlignmentOutputGenerator(this);
\r
93 public String getVisibleConsensus()
\r
95 return visibleConsensus;
\r
98 Vector consensus = new Vector();
\r
99 public Vector getConsensus(boolean recalculate)
\r
101 if(recalculate || consensus.size()<1)
\r
103 consensus = alignment.getAAFrequency();
\r
104 StringBuffer sb = new StringBuffer();
\r
105 Hashtable hash = null;
\r
106 for (int i = 0; i < consensus.size(); i++)
\r
108 hash = (Hashtable) consensus.elementAt(i);
\r
109 sb.append(hash.get("maxResidue").toString().charAt(0));
\r
111 visibleConsensus = sb.toString();
\r
118 public SequenceGroup getRubberbandGroup()
\r
120 return rubberbandGroup;
\r
123 public void setRubberbandGroup(SequenceGroup sg)
\r
125 rubberbandGroup = sg;
\r
128 public boolean getConservationSelected()
\r
130 return conservationColourSelected;
\r
133 public void setConservationSelected(boolean b)
\r
135 conservationColourSelected = b;
\r
138 public int getStartRes() {
\r
142 public int getEndRes() {
\r
146 public int getStartSeq() {
\r
150 public void setGlobalColourScheme(ColourSchemeI cs)
\r
152 globalColourScheme = cs;
\r
155 public ColourSchemeI getGlobalColourScheme()
\r
157 return globalColourScheme;
\r
161 public void setStartRes(int res) {
\r
162 this.startRes = res;
\r
164 public void setStartSeq(int seq) {
\r
165 this.startSeq = seq;
\r
167 public void setEndRes(int res) {
\r
168 if (res > alignment.getWidth()-1) {
\r
169 System.out.println(" Corrected res from " + res + " to maximum " + (alignment.getWidth()-1));
\r
170 res = alignment.getWidth() -1;
\r
177 public void setEndSeq(int seq) {
\r
178 if (seq > alignment.getHeight()) {
\r
179 seq = alignment.getHeight();
\r
186 public int getEndSeq() {
\r
190 public void setFont(Font f) {
\r
192 javax.swing.JFrame temp = new javax.swing.JFrame();
\r
194 java.awt.FontMetrics fm = temp.getGraphics().getFontMetrics(font);
\r
195 setCharHeight(fm.getHeight());
\r
196 setCharWidth(fm.charWidth('M'));
\r
199 public Font getFont() {
\r
202 public void setCharWidth(int w) {
\r
203 this.charWidth = w;
\r
205 public int getCharWidth() {
\r
208 public void setCharHeight(int h) {
\r
209 this.charHeight = h;
\r
211 public int getCharHeight() {
\r
214 public void setChunkWidth(int w) {
\r
215 this.chunkWidth = w;
\r
217 public int getChunkWidth() {
\r
220 public void setChunkHeight(int h) {
\r
221 this.chunkHeight = h;
\r
223 public int getChunkHeight() {
\r
224 return chunkHeight;
\r
226 public AlignmentI getAlignment() {
\r
229 public void setAlignment(AlignmentI align) {
\r
230 this.alignment = align;
\r
232 public void setShowScores(boolean state) {
\r
233 showScores = state;
\r
235 public void setWrapAlignment(boolean state) {
\r
236 wrapAlignment = state;
\r
238 public void setShowText(boolean state) {
\r
242 public void setRenderGaps(boolean state){
\r
243 renderGaps = state;
\r
244 if(renderer instanceof SequenceRenderer)
\r
246 SequenceRenderer sr = (SequenceRenderer)renderer;
\r
247 sr.renderGaps(state);
\r
252 public boolean getColourText()
\r
254 return showColourText;
\r
257 public void setColourText(boolean state)
\r
259 showColourText = state;
\r
262 public void setShowBoxes(boolean state) {
\r
265 public boolean getShowScores() {
\r
268 public boolean getWrapAlignment() {
\r
269 return wrapAlignment;
\r
271 public boolean getShowText() {
\r
274 public boolean getShowBoxes() {
\r
278 public char getGapCharacter() {
\r
279 return getAlignment().getGapCharacter();
\r
281 public void setGapCharacter(char gap) {
\r
282 if (getAlignment() != null) {
\r
283 getAlignment().setGapCharacter(gap);
\r
286 public void setThreshold(int thresh) {
\r
287 threshold = thresh;
\r
289 public int getThreshold() {
\r
292 public void setIncrement(int inc) {
\r
295 public int getIncrement() {
\r
298 public int getIndex(int y) {
\r
300 int starty = getStartSeq();
\r
301 int endy = getEndSeq();
\r
303 for (int i = starty; i <= endy; i++) {
\r
304 if (i < alignment.getHeight() && alignment.getSequenceAt(i) != null) {
\r
305 int y2 = y1 + getCharHeight();
\r
307 if (y>=y1 && y <=y2) {
\r
317 public Selection getSelection() {
\r
320 public ColumnSelection getColumnSelection() {
\r
323 public OutputGenerator getOutputGenerator() {
\r
326 public void resetSeqLimits(int height) {
\r
328 setEndSeq(height/getCharHeight());
\r
330 public void setCurrentTree(NJTree tree) {
\r
331 currentTree = tree;
\r
333 public NJTree getCurrentTree() {
\r
334 return currentTree;
\r
337 public void setRenderer(RendererI rend) {
\r
338 this.renderer = rend;
\r
341 public RendererI getRenderer() {
\r
344 public int getPIDWindow() {
\r
347 public void setPIDWindow(int window) {
\r
348 this.window = window;
\r
351 public int getPIDBaseline() {
\r
354 public void setPIDBaseline(int baseline) {
\r
355 this.baseline = baseline;
\r
358 public void setKmers(Vector kmers) {
\r
359 this.kmers = kmers;
\r
362 public Vector getKmers() {
\r