5 import jalview.analysis.NJTree;
\r
6 import jalview.datamodel.*;
\r
9 public class AlignViewport
\r
19 boolean showColourText;
\r
21 boolean wrapAlignment;
\r
23 boolean groupEdit = false;
\r
25 RendererI renderer = new SequenceRenderer();
\r
32 Color backgroundColour;
\r
34 Font font = new Font("SansSerif",Font.PLAIN,10);
\r
35 AlignmentI alignment;
\r
37 Selection sel = new Selection();
\r
38 ColumnSelection colSel = new ColumnSelection();
\r
42 String visibleConsensus;
\r
47 NJTree currentTree = null;
\r
54 public AlignViewport(AlignmentI da,
\r
58 boolean wrapAlignment) {
\r
59 this(0,da.getWidth()-1,0,da.getHeight()-1,showScores,
\r
67 public AlignViewport(int startRes, int endRes,
\r
68 int startSeq, int endSeq,
\r
72 boolean wrapAlignment) {
\r
74 this.startRes = startRes;
\r
75 this.endRes = endRes;
\r
76 this.startSeq = startSeq;
\r
77 this.endSeq = endSeq;
\r
79 this.showScores = showScores;
\r
80 this.showText = showText;
\r
81 this.showBoxes = showBoxes;
\r
82 this.wrapAlignment = wrapAlignment;
\r
84 // og = new AlignmentOutputGenerator(this);
\r
89 public AlignViewport(int startRes, int endRes,
\r
90 int startSeq, int endSeq,
\r
94 boolean wrapAlignment,
\r
95 Color backgroundColour) {
\r
96 this(startRes,endRes,startSeq,endSeq,showScores,showText,showBoxes,wrapAlignment);
\r
98 this.backgroundColour = backgroundColour;
\r
102 public String getVisibleConsensus()
\r
104 return visibleConsensus;
\r
107 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 boolean getColourText()
\r
225 return showColourText;
\r
228 public void setColourText(boolean state)
\r
230 showColourText = state;
\r
233 public void setShowBoxes(boolean state) {
\r
236 public boolean getShowScores() {
\r
239 public boolean getWrapAlignment() {
\r
240 return wrapAlignment;
\r
242 public boolean getShowText() {
\r
245 public boolean getShowBoxes() {
\r
248 // public CommandParser getCommandLog() {
\r
251 public boolean getGroupEdit() {
\r
254 public void setGroupEdit(boolean state) {
\r
257 public String getGapCharacter() {
\r
258 return getAlignment().getGapCharacter();
\r
260 public void setGapCharacter(String gap) {
\r
261 if (getAlignment() != null) {
\r
262 getAlignment().setGapCharacter(gap);
\r
265 public void setThreshold(int thresh) {
\r
266 threshold = thresh;
\r
268 public int getThreshold() {
\r
271 public void setIncrement(int inc) {
\r
274 public int getIncrement() {
\r
277 public int getIndex(int y) {
\r
279 int starty = getStartSeq();
\r
280 int endy = getEndSeq();
\r
282 for (int i = starty; i <= endy; i++) {
\r
283 if (i < alignment.getHeight() && alignment.getSequenceAt(i) != null) {
\r
284 int y2 = y1 + getCharHeight();
\r
286 if (y>=y1 && y <=y2) {
\r
296 public Selection getSelection() {
\r
299 public ColumnSelection getColumnSelection() {
\r
302 public OutputGenerator getOutputGenerator() {
\r
305 public void resetSeqLimits(int height) {
\r
307 setEndSeq(height/getCharHeight());
\r
309 public void setCurrentTree(NJTree tree) {
\r
310 currentTree = tree;
\r
312 public NJTree getCurrentTree() {
\r
313 return currentTree;
\r
316 public void setRenderer(RendererI rend) {
\r
317 this.renderer = rend;
\r
320 public RendererI getRenderer() {
\r
323 public int getPIDWindow() {
\r
326 public void setPIDWindow(int window) {
\r
327 this.window = window;
\r
330 public int getPIDBaseline() {
\r
333 public void setPIDBaseline(int baseline) {
\r
334 this.baseline = baseline;
\r
337 public void setKmers(Vector kmers) {
\r
338 this.kmers = kmers;
\r
341 public Vector getKmers() {
\r