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 = false;
\r
24 boolean groupEdit = false;
\r
25 boolean groupDefiningMode = true;
\r
27 ColourSchemeI globalColourScheme = null;
\r
28 boolean conservationColourSelected = false;
\r
30 SequenceGroup rubberbandGroup = null;
\r
32 RendererI renderer = new SequenceRenderer(this);
\r
39 Font font = new Font("SansSerif",Font.PLAIN,10);
\r
40 AlignmentI alignment;
\r
42 Selection sel = new Selection();
\r
43 ColumnSelection colSel = new ColumnSelection();
\r
47 String visibleConsensus;
\r
52 NJTree currentTree = null;
\r
59 public AlignViewport(AlignmentI da,
\r
63 boolean wrapAlignment) {
\r
64 this(0,da.getWidth()-1,0,da.getHeight()-1,showScores,
\r
72 public AlignViewport(int startRes, int endRes,
\r
73 int startSeq, int endSeq,
\r
77 boolean wrapAlignment) {
\r
79 this.startRes = startRes;
\r
80 this.endRes = endRes;
\r
81 this.startSeq = startSeq;
\r
82 this.endSeq = endSeq;
\r
84 this.showScores = showScores;
\r
85 this.showText = showText;
\r
86 this.showBoxes = showBoxes;
\r
87 this.wrapAlignment = wrapAlignment;
\r
89 // og = new AlignmentOutputGenerator(this);
\r
95 public String getVisibleConsensus()
\r
97 return visibleConsensus;
\r
100 Vector consensus = new Vector();
\r
101 public Vector getConsensus(boolean recalculate)
\r
103 if(recalculate || consensus.size()<1)
\r
105 consensus = alignment.getAAFrequency();
\r
106 StringBuffer sb = new StringBuffer();
\r
107 Hashtable hash = null;
\r
108 for (int i = 0; i < consensus.size(); i++)
\r
110 hash = (Hashtable) consensus.elementAt(i);
\r
111 sb.append(hash.get("maxResidue").toString().charAt(0));
\r
113 visibleConsensus = sb.toString();
\r
120 public SequenceGroup getRubberbandGroup()
\r
122 return rubberbandGroup;
\r
125 public void setRubberbandGroup(SequenceGroup sg)
\r
127 rubberbandGroup = sg;
\r
130 public boolean getConservationSelected()
\r
132 return conservationColourSelected;
\r
135 public void setConservationSelected(boolean b)
\r
137 conservationColourSelected = b;
\r
140 public int getStartRes() {
\r
144 public int getEndRes() {
\r
148 public int getStartSeq() {
\r
152 public void setGlobalColourScheme(ColourSchemeI cs)
\r
154 globalColourScheme = cs;
\r
157 public ColourSchemeI getGlobalColourScheme()
\r
159 return globalColourScheme;
\r
163 public void setStartRes(int res) {
\r
164 this.startRes = res;
\r
166 public void setStartSeq(int seq) {
\r
167 this.startSeq = seq;
\r
169 public void setEndRes(int res) {
\r
170 if (res > alignment.getWidth()-1) {
\r
171 System.out.println(" Corrected res from " + res + " to maximum " + (alignment.getWidth()-1));
\r
172 res = alignment.getWidth() -1;
\r
179 public void setEndSeq(int seq) {
\r
180 if (seq > alignment.getHeight()) {
\r
181 seq = alignment.getHeight();
\r
188 public int getEndSeq() {
\r
192 public void setFont(Font f) {
\r
194 javax.swing.JFrame temp = new javax.swing.JFrame();
\r
196 java.awt.FontMetrics fm = temp.getGraphics().getFontMetrics(font);
\r
197 setCharHeight(fm.getHeight());
\r
198 setCharWidth(fm.charWidth('M'));
\r
201 public Font getFont() {
\r
204 public void setCharWidth(int w) {
\r
205 this.charWidth = w;
\r
207 public int getCharWidth() {
\r
210 public void setCharHeight(int h) {
\r
211 this.charHeight = h;
\r
213 public int getCharHeight() {
\r
216 public void setChunkWidth(int w) {
\r
217 this.chunkWidth = w;
\r
219 public int getChunkWidth() {
\r
222 public void setChunkHeight(int h) {
\r
223 this.chunkHeight = h;
\r
225 public int getChunkHeight() {
\r
226 return chunkHeight;
\r
228 public AlignmentI getAlignment() {
\r
231 public void setAlignment(AlignmentI align) {
\r
232 this.alignment = align;
\r
234 public void setShowScores(boolean state) {
\r
235 showScores = state;
\r
237 public void setWrapAlignment(boolean state) {
\r
238 wrapAlignment = state;
\r
240 public void setShowText(boolean state) {
\r
244 public void setRenderGaps(boolean state){
\r
245 renderGaps = state;
\r
246 if(renderer instanceof SequenceRenderer)
\r
248 SequenceRenderer sr = (SequenceRenderer)renderer;
\r
249 sr.renderGaps(state);
\r
254 public boolean getColourText()
\r
256 return showColourText;
\r
259 public void setColourText(boolean state)
\r
261 showColourText = state;
\r
264 public void setShowBoxes(boolean state) {
\r
267 public boolean getShowScores() {
\r
270 public boolean getWrapAlignment() {
\r
271 return wrapAlignment;
\r
273 public boolean getShowText() {
\r
276 public boolean getShowBoxes() {
\r
279 // public CommandParser getCommandLog() {
\r
282 public boolean getGroupEdit() {
\r
285 public void setGroupEdit(boolean state) {
\r
288 public char getGapCharacter() {
\r
289 return getAlignment().getGapCharacter();
\r
291 public void setGapCharacter(char gap) {
\r
292 if (getAlignment() != null) {
\r
293 getAlignment().setGapCharacter(gap);
\r
296 public void setThreshold(int thresh) {
\r
297 threshold = thresh;
\r
299 public int getThreshold() {
\r
302 public void setIncrement(int inc) {
\r
305 public int getIncrement() {
\r
308 public int getIndex(int y) {
\r
310 int starty = getStartSeq();
\r
311 int endy = getEndSeq();
\r
313 for (int i = starty; i <= endy; i++) {
\r
314 if (i < alignment.getHeight() && alignment.getSequenceAt(i) != null) {
\r
315 int y2 = y1 + getCharHeight();
\r
317 if (y>=y1 && y <=y2) {
\r
327 public Selection getSelection() {
\r
330 public ColumnSelection getColumnSelection() {
\r
333 public OutputGenerator getOutputGenerator() {
\r
336 public void resetSeqLimits(int height) {
\r
338 setEndSeq(height/getCharHeight());
\r
340 public void setCurrentTree(NJTree tree) {
\r
341 currentTree = tree;
\r
343 public NJTree getCurrentTree() {
\r
344 return currentTree;
\r
347 public void setRenderer(RendererI rend) {
\r
348 this.renderer = rend;
\r
351 public RendererI getRenderer() {
\r
354 public int getPIDWindow() {
\r
357 public void setPIDWindow(int window) {
\r
358 this.window = window;
\r
361 public int getPIDBaseline() {
\r
364 public void setPIDBaseline(int baseline) {
\r
365 this.baseline = baseline;
\r
368 public void setKmers(Vector kmers) {
\r
369 this.kmers = kmers;
\r
372 public Vector getKmers() {
\r