5 import jalview.analysis.NJTree;
\r
6 import jalview.datamodel.*;
\r
9 public class AlignViewport
\r
17 boolean showScores=false;
\r
18 boolean showText=true;
\r
19 boolean showColourText=false;
\r
20 boolean showBoxes=true;
\r
21 boolean wrapAlignment=false;
\r
22 boolean renderGaps = false;
\r
24 boolean groupEdit = false;
\r
26 RendererI renderer = new SequenceRenderer();
\r
33 Color backgroundColour;
\r
35 Font font = new Font("SansSerif",Font.PLAIN,10);
\r
36 AlignmentI alignment;
\r
38 Selection sel = new Selection();
\r
39 ColumnSelection colSel = new ColumnSelection();
\r
43 String visibleConsensus;
\r
48 NJTree currentTree = null;
\r
55 public AlignViewport(AlignmentI da,
\r
59 boolean wrapAlignment) {
\r
60 this(0,da.getWidth()-1,0,da.getHeight()-1,showScores,
\r
68 public AlignViewport(int startRes, int endRes,
\r
69 int startSeq, int endSeq,
\r
73 boolean wrapAlignment) {
\r
75 this.startRes = startRes;
\r
76 this.endRes = endRes;
\r
77 this.startSeq = startSeq;
\r
78 this.endSeq = endSeq;
\r
80 this.showScores = showScores;
\r
81 this.showText = showText;
\r
82 this.showBoxes = showBoxes;
\r
83 this.wrapAlignment = wrapAlignment;
\r
85 // og = new AlignmentOutputGenerator(this);
\r
90 public AlignViewport(int startRes, int endRes,
\r
91 int startSeq, int endSeq,
\r
95 boolean wrapAlignment,
\r
96 Color backgroundColour) {
\r
97 this(startRes,endRes,startSeq,endSeq,showScores,showText,showBoxes,wrapAlignment);
\r
99 this.backgroundColour = backgroundColour;
\r
103 public String getVisibleConsensus()
\r
105 return visibleConsensus;
\r
108 Vector consensus = new Vector();
\r
109 public Vector getConsensus(boolean recalculate)
\r
111 if(recalculate || consensus.size()<1)
\r
113 consensus = alignment.getAAFrequency();
\r
114 StringBuffer sb = new StringBuffer();
\r
115 Hashtable hash = null;
\r
116 for (int i = 0; i < consensus.size(); i++)
\r
118 hash = (Hashtable) consensus.elementAt(i);
\r
119 sb.append(hash.get("maxResidue").toString().charAt(0));
\r
121 visibleConsensus = sb.toString();
\r
129 public int getStartRes() {
\r
133 public int getEndRes() {
\r
137 public int getStartSeq() {
\r
142 public void setStartRes(int res) {
\r
143 this.startRes = res;
\r
145 public void setStartSeq(int seq) {
\r
146 this.startSeq = seq;
\r
148 public void setEndRes(int res) {
\r
149 if (res > alignment.getWidth()-1) {
\r
150 System.out.println(" Corrected res from " + res + " to maximum " + (alignment.getWidth()-1));
\r
151 res = alignment.getWidth() -1;
\r
158 public void setEndSeq(int seq) {
\r
159 if (seq > alignment.getHeight()) {
\r
160 seq = alignment.getHeight();
\r
167 public int getEndSeq() {
\r
171 public void setFont(Font f) {
\r
173 javax.swing.JFrame temp = new javax.swing.JFrame();
\r
175 java.awt.FontMetrics fm = temp.getGraphics().getFontMetrics(font);
\r
176 setCharHeight(fm.getHeight());
\r
177 setCharWidth(fm.charWidth('M'));
\r
180 public Font getFont() {
\r
183 public void setCharWidth(double w) {
\r
184 this.charWidth = w;
\r
186 public double getCharWidth() {
\r
189 public void setCharHeight(int h) {
\r
190 this.charHeight = h;
\r
192 public int getCharHeight() {
\r
195 public void setChunkWidth(int w) {
\r
196 this.chunkWidth = w;
\r
198 public int getChunkWidth() {
\r
201 public void setChunkHeight(int h) {
\r
202 this.chunkHeight = h;
\r
204 public int getChunkHeight() {
\r
205 return chunkHeight;
\r
207 public AlignmentI getAlignment() {
\r
210 public void setAlignment(AlignmentI align) {
\r
211 this.alignment = align;
\r
213 public void setShowScores(boolean state) {
\r
214 showScores = state;
\r
216 public void setWrapAlignment(boolean state) {
\r
217 wrapAlignment = state;
\r
219 public void setShowText(boolean state) {
\r
223 public void setRenderGaps(boolean state){
\r
224 renderGaps = state;
\r
225 if(renderer instanceof SequenceRenderer)
\r
227 SequenceRenderer sr = (SequenceRenderer)renderer;
\r
228 sr.renderGaps(state);
\r
233 public boolean getColourText()
\r
235 return showColourText;
\r
238 public void setColourText(boolean state)
\r
240 showColourText = state;
\r
243 public void setShowBoxes(boolean state) {
\r
246 public boolean getShowScores() {
\r
249 public boolean getWrapAlignment() {
\r
250 return wrapAlignment;
\r
252 public boolean getShowText() {
\r
255 public boolean getShowBoxes() {
\r
258 // public CommandParser getCommandLog() {
\r
261 public boolean getGroupEdit() {
\r
264 public void setGroupEdit(boolean state) {
\r
267 public char getGapCharacter() {
\r
268 return getAlignment().getGapCharacter();
\r
270 public void setGapCharacter(char gap) {
\r
271 if (getAlignment() != null) {
\r
272 getAlignment().setGapCharacter(gap);
\r
275 public void setThreshold(int thresh) {
\r
276 threshold = thresh;
\r
278 public int getThreshold() {
\r
281 public void setIncrement(int inc) {
\r
284 public int getIncrement() {
\r
287 public int getIndex(int y) {
\r
289 int starty = getStartSeq();
\r
290 int endy = getEndSeq();
\r
292 for (int i = starty; i <= endy; i++) {
\r
293 if (i < alignment.getHeight() && alignment.getSequenceAt(i) != null) {
\r
294 int y2 = y1 + getCharHeight();
\r
296 if (y>=y1 && y <=y2) {
\r
306 public Selection getSelection() {
\r
309 public ColumnSelection getColumnSelection() {
\r
312 public OutputGenerator getOutputGenerator() {
\r
315 public void resetSeqLimits(int height) {
\r
317 setEndSeq(height/getCharHeight());
\r
319 public void setCurrentTree(NJTree tree) {
\r
320 currentTree = tree;
\r
322 public NJTree getCurrentTree() {
\r
323 return currentTree;
\r
326 public void setRenderer(RendererI rend) {
\r
327 this.renderer = rend;
\r
330 public RendererI getRenderer() {
\r
333 public int getPIDWindow() {
\r
336 public void setPIDWindow(int window) {
\r
337 this.window = window;
\r
340 public int getPIDBaseline() {
\r
343 public void setPIDBaseline(int baseline) {
\r
344 this.baseline = baseline;
\r
347 public void setKmers(Vector kmers) {
\r
348 this.kmers = kmers;
\r
351 public Vector getKmers() {
\r