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 ColourSchemeI globalColourScheme = null;
\r
27 boolean conservationColourSelected = false;
\r
29 SequenceGroup rubberbandGroup = null;
\r
31 RendererI renderer = new SequenceRenderer(this);
\r
38 Font font = new Font("SansSerif",Font.PLAIN,10);
\r
39 AlignmentI alignment;
\r
41 Selection sel = new Selection(this);
\r
42 ColumnSelection colSel = new ColumnSelection();
\r
44 String visibleConsensus;
\r
49 NJTree currentTree = null;
\r
52 public AlignViewport(AlignmentI da,
\r
56 boolean wrapAlignment) {
\r
57 this(0,da.getWidth()-1,0,da.getHeight()-1,showScores,
\r
65 public AlignViewport(int startRes, int endRes,
\r
66 int startSeq, int endSeq,
\r
70 boolean wrapAlignment) {
\r
72 this.startRes = startRes;
\r
73 this.endRes = endRes;
\r
74 this.startSeq = startSeq;
\r
75 this.endSeq = endSeq;
\r
77 this.showScores = showScores;
\r
78 this.showText = showText;
\r
79 this.showBoxes = showBoxes;
\r
80 this.wrapAlignment = wrapAlignment;
\r
82 // og = new AlignmentOutputGenerator(this);
\r
87 public void showSequenceFeatures(boolean b)
\r
89 showSequenceFeatures = b;
\r
92 public String getVisibleConsensus()
\r
94 return visibleConsensus;
\r
97 Vector consensus = new Vector();
\r
98 public Vector getConsensus(boolean recalculate)
\r
100 if(recalculate || consensus.size()<1)
\r
102 consensus = alignment.getAAFrequency();
\r
103 StringBuffer sb = new StringBuffer();
\r
104 Hashtable hash = null;
\r
105 for (int i = 0; i < consensus.size(); i++)
\r
107 hash = (Hashtable) consensus.elementAt(i);
\r
108 sb.append(hash.get("maxResidue").toString().charAt(0));
\r
110 visibleConsensus = sb.toString();
\r
117 public SequenceGroup getRubberbandGroup()
\r
119 return rubberbandGroup;
\r
122 public void setRubberbandGroup(SequenceGroup sg)
\r
124 rubberbandGroup = sg;
\r
127 public boolean getConservationSelected()
\r
129 return conservationColourSelected;
\r
132 public void setConservationSelected(boolean b)
\r
134 conservationColourSelected = b;
\r
137 public int getStartRes() {
\r
141 public int getEndRes() {
\r
145 public int getStartSeq() {
\r
149 public void setGlobalColourScheme(ColourSchemeI cs)
\r
151 globalColourScheme = cs;
\r
154 public ColourSchemeI getGlobalColourScheme()
\r
156 return globalColourScheme;
\r
160 public void setStartRes(int res) {
\r
161 this.startRes = res;
\r
163 public void setStartSeq(int seq) {
\r
164 this.startSeq = seq;
\r
166 public void setEndRes(int res) {
\r
167 if (res > alignment.getWidth()-1) {
\r
168 System.out.println(" Corrected res from " + res + " to maximum " + (alignment.getWidth()-1));
\r
169 res = alignment.getWidth() -1;
\r
176 public void setEndSeq(int seq) {
\r
177 if (seq > alignment.getHeight()) {
\r
178 seq = alignment.getHeight();
\r
185 public int getEndSeq() {
\r
189 public void setFont(Font f) {
\r
191 javax.swing.JFrame temp = new javax.swing.JFrame();
\r
193 java.awt.FontMetrics fm = temp.getGraphics().getFontMetrics(font);
\r
194 setCharHeight(fm.getHeight());
\r
195 setCharWidth(fm.charWidth('M'));
\r
198 public Font getFont() {
\r
201 public void setCharWidth(int w) {
\r
202 this.charWidth = w;
\r
204 public int getCharWidth() {
\r
207 public void setCharHeight(int h) {
\r
208 this.charHeight = h;
\r
210 public int getCharHeight() {
\r
213 public void setChunkWidth(int w) {
\r
214 this.chunkWidth = w;
\r
216 public int getChunkWidth() {
\r
219 public void setChunkHeight(int h) {
\r
220 this.chunkHeight = h;
\r
222 public int getChunkHeight() {
\r
223 return chunkHeight;
\r
225 public AlignmentI getAlignment() {
\r
228 public void setAlignment(AlignmentI align) {
\r
229 this.alignment = align;
\r
231 public void setShowScores(boolean state) {
\r
232 showScores = state;
\r
234 public void setWrapAlignment(boolean state) {
\r
235 wrapAlignment = state;
\r
237 public void setShowText(boolean state) {
\r
241 public void setRenderGaps(boolean state){
\r
242 renderGaps = state;
\r
243 if(renderer instanceof SequenceRenderer)
\r
245 SequenceRenderer sr = (SequenceRenderer)renderer;
\r
246 sr.renderGaps(state);
\r
251 public boolean getColourText()
\r
253 return showColourText;
\r
256 public void setColourText(boolean state)
\r
258 showColourText = state;
\r
261 public void setShowBoxes(boolean state) {
\r
264 public boolean getShowScores() {
\r
267 public boolean getWrapAlignment() {
\r
268 return wrapAlignment;
\r
270 public boolean getShowText() {
\r
273 public boolean getShowBoxes() {
\r
277 public char getGapCharacter() {
\r
278 return getAlignment().getGapCharacter();
\r
280 public void setGapCharacter(char gap) {
\r
281 if (getAlignment() != null) {
\r
282 getAlignment().setGapCharacter(gap);
\r
285 public void setThreshold(int thresh) {
\r
286 threshold = thresh;
\r
288 public int getThreshold() {
\r
291 public void setIncrement(int inc) {
\r
294 public int getIncrement() {
\r
297 public int getIndex(int y) {
\r
299 int starty = getStartSeq();
\r
300 int endy = getEndSeq();
\r
302 for (int i = starty; i <= endy; i++) {
\r
303 if (i < alignment.getHeight() && alignment.getSequenceAt(i) != null) {
\r
304 int y2 = y1 + getCharHeight();
\r
306 if (y>=y1 && y <=y2) {
\r
316 public Selection getSelection() {
\r
319 public ColumnSelection getColumnSelection() {
\r
323 public void resetSeqLimits(int height) {
\r
325 setEndSeq(height/getCharHeight());
\r
327 public void setCurrentTree(NJTree tree) {
\r
328 currentTree = tree;
\r
330 public NJTree getCurrentTree() {
\r
331 return currentTree;
\r
334 public void setRenderer(RendererI rend) {
\r
335 this.renderer = rend;
\r
338 public RendererI getRenderer() {
\r