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 boolean colourAppliesToAllGroups = true;
\r
27 ColourSchemeI globalColourScheme = null;
\r
28 boolean conservationColourSelected = false;
\r
29 boolean abovePIDThreshold = false;
\r
31 SequenceGroup rubberbandGroup = null;
\r
33 RendererI renderer = new SequenceRenderer(this);
\r
40 Font font = new Font("SansSerif",Font.PLAIN,10);
\r
41 AlignmentI alignment;
\r
43 Selection sel = new Selection(this);
\r
44 ColumnSelection colSel = new ColumnSelection();
\r
46 String visibleConsensus;
\r
51 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 void showSequenceFeatures(boolean b)
\r
91 showSequenceFeatures = b;
\r
94 public String getVisibleConsensus()
\r
96 return visibleConsensus;
\r
99 Vector consensus = new Vector();
\r
100 public Vector getConsensus(boolean recalculate)
\r
102 if(recalculate || consensus.size()<1)
\r
104 consensus = alignment.getAAFrequency();
\r
105 StringBuffer sb = new StringBuffer();
\r
106 Hashtable hash = null;
\r
107 for (int i = 0; i < consensus.size(); i++)
\r
109 hash = (Hashtable) consensus.elementAt(i);
\r
110 sb.append(hash.get("maxResidue").toString().charAt(0));
\r
112 visibleConsensus = sb.toString();
\r
119 public SequenceGroup getRubberbandGroup()
\r
121 return rubberbandGroup;
\r
124 public void setRubberbandGroup(SequenceGroup sg)
\r
126 rubberbandGroup = sg;
\r
129 public boolean getConservationSelected()
\r
131 return conservationColourSelected;
\r
134 public void setConservationSelected(boolean b)
\r
136 conservationColourSelected = b;
\r
139 public boolean getAbovePIDThreshold()
\r
141 return abovePIDThreshold;
\r
144 public void setAbovePIDThreshold(boolean b)
\r
146 abovePIDThreshold = b;
\r
149 public int getStartRes() {
\r
153 public int getEndRes() {
\r
157 public int getStartSeq() {
\r
161 public void setGlobalColourScheme(ColourSchemeI cs)
\r
163 globalColourScheme = cs;
\r
166 public ColourSchemeI getGlobalColourScheme()
\r
168 return globalColourScheme;
\r
172 public void setStartRes(int res) {
\r
173 this.startRes = res;
\r
175 public void setStartSeq(int seq) {
\r
176 this.startSeq = seq;
\r
178 public void setEndRes(int res) {
\r
179 if (res > alignment.getWidth()-1) {
\r
180 System.out.println(" Corrected res from " + res + " to maximum " + (alignment.getWidth()-1));
\r
181 res = alignment.getWidth() -1;
\r
188 public void setEndSeq(int seq) {
\r
189 if (seq > alignment.getHeight()) {
\r
190 seq = alignment.getHeight();
\r
197 public int getEndSeq() {
\r
201 public void setFont(Font f) {
\r
203 javax.swing.JFrame temp = new javax.swing.JFrame();
\r
205 java.awt.FontMetrics fm = temp.getGraphics().getFontMetrics(font);
\r
206 setCharHeight(fm.getHeight());
\r
207 setCharWidth(fm.charWidth('M'));
\r
210 public Font getFont() {
\r
213 public void setCharWidth(int w) {
\r
214 this.charWidth = w;
\r
216 public int getCharWidth() {
\r
219 public void setCharHeight(int h) {
\r
220 this.charHeight = h;
\r
222 public int getCharHeight() {
\r
225 public void setChunkWidth(int w) {
\r
226 this.chunkWidth = w;
\r
228 public int getChunkWidth() {
\r
231 public void setChunkHeight(int h) {
\r
232 this.chunkHeight = h;
\r
234 public int getChunkHeight() {
\r
235 return chunkHeight;
\r
237 public AlignmentI getAlignment() {
\r
240 public void setAlignment(AlignmentI align) {
\r
241 this.alignment = align;
\r
243 public void setShowScores(boolean state) {
\r
244 showScores = state;
\r
246 public void setWrapAlignment(boolean state) {
\r
247 wrapAlignment = state;
\r
249 public void setShowText(boolean state) {
\r
253 public void setRenderGaps(boolean state){
\r
254 renderGaps = state;
\r
255 if(renderer instanceof SequenceRenderer)
\r
257 SequenceRenderer sr = (SequenceRenderer)renderer;
\r
258 sr.renderGaps(state);
\r
263 public boolean getColourText()
\r
265 return showColourText;
\r
268 public void setColourText(boolean state)
\r
270 showColourText = state;
\r
273 public void setShowBoxes(boolean state) {
\r
276 public boolean getShowScores() {
\r
279 public boolean getWrapAlignment() {
\r
280 return wrapAlignment;
\r
282 public boolean getShowText() {
\r
285 public boolean getShowBoxes() {
\r
289 public char getGapCharacter() {
\r
290 return getAlignment().getGapCharacter();
\r
292 public void setGapCharacter(char gap) {
\r
293 if (getAlignment() != null) {
\r
294 getAlignment().setGapCharacter(gap);
\r
297 public void setThreshold(int thresh) {
\r
298 threshold = thresh;
\r
300 public int getThreshold() {
\r
303 public void setIncrement(int inc) {
\r
306 public int getIncrement() {
\r
309 public int getIndex(int y) {
\r
311 int starty = getStartSeq();
\r
312 int endy = getEndSeq();
\r
314 for (int i = starty; i <= endy; i++) {
\r
315 if (i < alignment.getHeight() && alignment.getSequenceAt(i) != null) {
\r
316 int y2 = y1 + getCharHeight();
\r
318 if (y>=y1 && y <=y2) {
\r
328 public Selection getSelection() {
\r
331 public ColumnSelection getColumnSelection() {
\r
335 public void resetSeqLimits(int height) {
\r
337 setEndSeq(height/getCharHeight());
\r
339 public void setCurrentTree(NJTree tree) {
\r
340 currentTree = tree;
\r
342 public NJTree getCurrentTree() {
\r
343 return currentTree;
\r
346 public void setRenderer(RendererI rend) {
\r
347 this.renderer = rend;
\r
350 public RendererI getRenderer() {
\r
354 public void setColourAppliesToAllGroups(boolean b)
\r
355 { colourAppliesToAllGroups = b; }
\r
357 public boolean getColourAppliesToAllGroups()
\r
358 {return colourAppliesToAllGroups; }
\r