3 import jalview.datamodel.*;
\r
4 import jalview.schemes.*;
\r
8 public class DrawableSequence implements SequenceI {
\r
9 protected boolean fastDraw = true;
\r
10 protected Color color = Color.black;
\r
12 protected SequenceI sequence;
\r
14 ColourSchemeI cs = null;
\r
16 public Vector sequenceFeatures = new Vector();
\r
17 public void setSequenceFeatures(Vector v)
\r
18 { sequenceFeatures = v; }
\r
19 public Vector getSequenceFeatures()
\r
20 {return sequenceFeatures; }
\r
23 public void setPDBId(String id)
\r
25 public String getPDBId()
\r
29 public DrawableSequence(SequenceI s) {
\r
35 public DrawableSequence(String name,String seq, int start, int end) {
\r
36 sequence = new Sequence(name,seq,start,end);
\r
41 private void _init() {
\r
45 public void setColourScheme(ColourSchemeI cs) {
\r
49 public Color getResidueBoxColour(int i) {
\r
50 Color c = cs.findColour( sequence.getSequence(i,i+1),i,null);
\r
54 public void drawSequence(Graphics g,int start, int end, int x1, int y1, int width, int height,boolean showScores, boolean displayBoxes, boolean displayText) {
\r
56 if (displayBoxes == true) {
\r
57 drawBoxes(g,start,end,x1,y1,width, height);
\r
59 if (displayText == true) {
\r
60 drawText(g,start,end,x1,y1,width,height);
\r
64 public void drawBoxes(Graphics g,int start, int end, int x1, int y1, int width, int height) {
\r
66 int length = getSequence().length();
\r
68 Color currentColor = Color.white;
\r
71 int curWidth = width;
\r
73 while (i <= end && i < length) {
\r
74 Color c = getResidueBoxColour(i);
\r
76 if (c != currentColor || c != null) {
\r
77 g.fillRect(x1+width*(curStart-start),y1,curWidth,height);
\r
90 g.fillRect(x1+width*(curStart-start),y1,curWidth,height);
\r
93 public void drawText(Graphics g, int start, int end, int x1, int y1, int width, int height) {
\r
95 g.setColor(Color.black);
\r
96 System.out.println("drawablesequence is drawing");
\r
97 // Need to find the sequence position here.
\r
101 if (end < getSequence().length()) {
\r
102 s = getSequence().substring(start,end+1);
\r
104 s = getSequence().substring(start);
\r
106 System.out.println(s+" "+x1+" "+y1);
\r
107 g.drawString(s,x1,y1+height-pady);
\r
110 for (int i=start; i <= end; i++) {
\r
113 if (i < end && i < getSequence().length()) {
\r
114 s = getSequence().substring(i,i+1);
\r
116 s = getSequence().substring(i,i+1);
\r
120 g.drawString(s,x1+width*(i-start),y1+height-pady);
\r
127 public int getPosition(int res) {
\r
132 public int getResidue(int pos) {
\r
137 // SequenceI methods
\r
139 public void setName(String name) {
\r
140 sequence.setName(name);
\r
142 public String getName() {
\r
143 return sequence.getName();
\r
145 public String getDisplayId() {
\r
146 return sequence.getDisplayId();
\r
149 public void setStart(int start) {
\r
150 sequence.setStart(start);
\r
152 public int getStart() {
\r
153 return sequence.getStart();
\r
156 public void setEnd(int end) {
\r
157 sequence.setEnd(end);
\r
159 public int getEnd() {
\r
160 return sequence.getEnd();
\r
163 public int getLength() {
\r
164 return sequence.getLength();
\r
167 public void setSequence(String seq) {
\r
168 sequence.setSequence(seq);
\r
170 public String getSequence() {
\r
171 return sequence.getSequence();
\r
173 public String getSequence(int start,int end) {
\r
174 return sequence.getSequence(start,end);
\r
176 public char getCharAt(int i) {
\r
177 return sequence.getCharAt(i);
\r
180 public void setDescription(String desc) {
\r
181 sequence.setDescription(desc);
\r
183 public String getDescription() {
\r
184 return sequence.getDescription();
\r
187 public int findIndex(int pos) {
\r
188 return sequence.findIndex(pos);
\r
190 public int findPosition(int i) {
\r
191 return sequence.findPosition(i);
\r
195 public void deleteCharAt(int i) {
\r
196 sequence.deleteCharAt(i);
\r
199 public void insertCharAt(int i,char c) {
\r
200 sequence.insertCharAt(i,c);
\r
204 public void insertCharAt(int i,char c,boolean chop) {
\r
205 sequence.insertCharAt(i,c,chop);
\r
208 public Color getColor() {
\r
212 public void setColor(Color c) {
\r