3 import jalview.datamodel.*;
\r
4 import jalview.schemes.*;
\r
5 import jalview.analysis.*;
\r
8 public class DrawableSequence implements SequenceI {
\r
9 protected boolean fastDraw = true;
\r
11 protected Color color = Color.black;
\r
13 protected SequenceI sequence;
\r
15 ColourSchemeI cs = new ZappoColourScheme();
\r
17 public DrawableSequence(SequenceI s) {
\r
23 public DrawableSequence(String name,String seq, int start, int end) {
\r
24 sequence = new Sequence(name,seq,start,end);
\r
29 private void _init() {
\r
33 public void setColourScheme(ColourSchemeI cs) {
\r
37 public Color getResidueBoxColour(int i) {
\r
38 Color c = cs.findColour(this,sequence.getSequence(i,i+1),i,null);
\r
42 public void drawSequence(Graphics g,int start, int end, int x1, int y1, int width, int height,boolean showScores, boolean displayBoxes, boolean displayText) {
\r
44 if (displayBoxes == true) {
\r
45 drawBoxes(g,start,end,x1,y1,width, height);
\r
47 if (displayText == true) {
\r
48 drawText(g,start,end,x1,y1,width,height);
\r
52 public void drawBoxes(Graphics g,int start, int end, int x1, int y1, int width, int height) {
\r
54 int length = getSequence().length();
\r
56 Color currentColor = Color.white;
\r
59 int curWidth = width;
\r
61 while (i <= end && i < length) {
\r
62 Color c = getResidueBoxColour(i);
\r
64 if (c != currentColor || c != null) {
\r
65 g.fillRect(x1+width*(curStart-start),y1,curWidth,height);
\r
78 g.fillRect(x1+width*(curStart-start),y1,curWidth,height);
\r
81 public void drawText(Graphics g, int start, int end, int x1, int y1, int width, int height) {
\r
83 g.setColor(Color.black);
\r
84 System.out.println("drawablesequence is drawing");
\r
85 // Need to find the sequence position here.
\r
89 if (end < getSequence().length()) {
\r
90 s = getSequence().substring(start,end+1);
\r
92 s = getSequence().substring(start);
\r
94 System.out.println(s+" "+x1+" "+y1);
\r
95 g.drawString(s,x1,y1+height-pady);
\r
98 for (int i=start; i <= end; i++) {
\r
101 if (i < end && i < getSequence().length()) {
\r
102 s = getSequence().substring(i,i+1);
\r
104 s = getSequence().substring(i,i+1);
\r
108 g.drawString(s,x1+width*(i-start),y1+height-pady);
\r
115 public int getPosition(int res) {
\r
120 public int getResidue(int pos) {
\r
125 // SequenceI methods
\r
127 public void setName(String name) {
\r
128 sequence.setName(name);
\r
130 public String getName() {
\r
131 return sequence.getName();
\r
133 public String getDisplayId() {
\r
134 return sequence.getDisplayId();
\r
137 public void setStart(int start) {
\r
138 sequence.setStart(start);
\r
140 public int getStart() {
\r
141 return sequence.getStart();
\r
144 public void setEnd(int end) {
\r
145 sequence.setEnd(end);
\r
147 public int getEnd() {
\r
148 return sequence.getEnd();
\r
151 public int getLength() {
\r
152 return sequence.getLength();
\r
155 public void setSequence(String seq) {
\r
156 sequence.setSequence(seq);
\r
158 public String getSequence() {
\r
159 return sequence.getSequence();
\r
161 public String getSequence(int start,int end) {
\r
162 return sequence.getSequence(start,end);
\r
164 public char getCharAt(int i) {
\r
165 return sequence.getCharAt(i);
\r
168 public void setDescription(String desc) {
\r
169 sequence.setDescription(desc);
\r
171 public String getDescription() {
\r
172 return sequence.getDescription();
\r
175 public int findIndex(int pos) {
\r
176 return sequence.findIndex(pos);
\r
178 public int findPosition(int i) {
\r
179 return sequence.findPosition(i);
\r
183 public void deleteCharAt(int i) {
\r
184 sequence.deleteCharAt(i);
\r
187 public void insertCharAt(int i,char c) {
\r
188 sequence.insertCharAt(i,c);
\r
192 public void insertCharAt(int i,char c,boolean chop) {
\r
193 sequence.insertCharAt(i,c,chop);
\r
196 public Color getColor() {
\r
200 public void setColor(Color c) {
\r