git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replaced image
[jalview.git]
/
src
/
jalview
/
appletgui
/
SequenceRenderer.java
diff --git
a/src/jalview/appletgui/SequenceRenderer.java
b/src/jalview/appletgui/SequenceRenderer.java
index
0fa8b2e
..
9103c1d
100755
(executable)
--- a/
src/jalview/appletgui/SequenceRenderer.java
+++ b/
src/jalview/appletgui/SequenceRenderer.java
@@
-40,10
+40,18
@@
public class SequenceRenderer
this.av = av;
\r
}
\r
\r
this.av = av;
\r
}
\r
\r
- public void renderGaps(boolean b)
\r
+ /**
\r
+ * DOCUMENT ME!
\r
+ *
\r
+ * @param b DOCUMENT ME!
\r
+ */
\r
+ public void prepare(Graphics g, boolean renderGaps)
\r
{
\r
{
\r
- renderGaps = b;
\r
- }
\r
+ graphics = g;
\r
+ fm = g.getFontMetrics();
\r
+
\r
+ this.renderGaps = renderGaps;
\r
+ }
\r
\r
public Color getResidueBoxColour(SequenceI seq, int i)
\r
{
\r
\r
public Color getResidueBoxColour(SequenceI seq, int i)
\r
{
\r
@@
-84,33
+92,30
@@
public class SequenceRenderer
public Color findSequenceColour(SequenceI seq, int i)
\r
{
\r
allGroups = av.alignment.findAllGroups(seq);
\r
public Color findSequenceColour(SequenceI seq, int i)
\r
{
\r
allGroups = av.alignment.findAllGroups(seq);
\r
- drawBoxes(seq, i,i, 0, 0, 1,1);
\r
+ drawBoxes(seq, i,i, 0);
\r
return resBoxColour;
\r
}
\r
\r
return resBoxColour;
\r
}
\r
\r
- public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg,
\r
- int start, int end, int x1, int y1, int width,
\r
- int height)
\r
+ public void drawSequence(SequenceI seq, SequenceGroup[] sg,
\r
+ int start, int end, int y1)
\r
{
\r
allGroups = sg;
\r
\r
{
\r
allGroups = sg;
\r
\r
- graphics = g;
\r
-
\r
- drawBoxes(seq, start, end, x1, y1, (int) width, height);
\r
-
\r
- fm = g.getFontMetrics();
\r
- drawText(seq, start, end, x1, y1, (int) width, height);
\r
+ drawBoxes(seq, start, end, y1);
\r
\r
\r
+ if(av.validCharWidth)
\r
+ {
\r
+ drawText(seq, start, end, y1);
\r
+ }
\r
}
\r
\r
}
\r
\r
- public void drawBoxes(SequenceI seq, int start, int end, int x1, int y1,
\r
- int width, int height)
\r
+ public void drawBoxes(SequenceI seq, int start, int end, int y1)
\r
{
\r
int i = start;
\r
int length = seq.getLength();
\r
\r
int curStart = -1;
\r
{
\r
int i = start;
\r
int length = seq.getLength();
\r
\r
int curStart = -1;
\r
- int curWidth = width;
\r
+ int curWidth = av.charWidth;
\r
\r
Color tempColour = null;
\r
while (i <= end)
\r
\r
Color tempColour = null;
\r
while (i <= end)
\r
@@
-136,32
+141,31
@@
public class SequenceRenderer
{
\r
if (tempColour != null)
\r
{
\r
{
\r
if (tempColour != null)
\r
{
\r
- graphics.fillRect(x1 + width * (curStart - start), y1, curWidth,
\r
- height);
\r
+ graphics.fillRect(av.charWidth * (curStart - start), y1, curWidth,
\r
+ av.charHeight);
\r
}
\r
graphics.setColor(resBoxColour);
\r
\r
curStart = i;
\r
}
\r
graphics.setColor(resBoxColour);
\r
\r
curStart = i;
\r
- curWidth = width;
\r
+ curWidth = av.charWidth;
\r
tempColour = resBoxColour;
\r
\r
}
\r
else
\r
{
\r
tempColour = resBoxColour;
\r
\r
}
\r
else
\r
{
\r
- curWidth += width;
\r
+ curWidth += av.charWidth;
\r
}
\r
\r
i++;
\r
}
\r
\r
}
\r
\r
i++;
\r
}
\r
\r
- graphics.fillRect(x1 + width * (curStart - start), y1, curWidth, height);
\r
+ graphics.fillRect(av.charWidth * (curStart - start), y1, curWidth, av.charHeight);
\r
}
\r
\r
}
\r
\r
- public void drawText(SequenceI seq, int start, int end, int x1, int y1,
\r
- int width, int height)
\r
+ public void drawText(SequenceI seq, int start, int end, int y1)
\r
{
\r
\r
{
\r
\r
- y1 += height - height / 5; // height/5 replaces pady
\r
+ y1 += av.charHeight - av.charHeight / 5; // height/5 replaces pady
\r
\r
int charOffset = 0;
\r
\r
\r
int charOffset = 0;
\r
\r
@@
-215,9
+219,9
@@
public class SequenceRenderer
}
\r
}
\r
\r
}
\r
}
\r
\r
- charOffset = (width - fm.charWidth(s)) / 2;
\r
+ charOffset = (av.charWidth - fm.charWidth(s)) / 2;
\r
graphics.drawString(String.valueOf(s),
\r
graphics.drawString(String.valueOf(s),
\r
- charOffset + x1 + width * (i - start),
\r
+ charOffset + av.charWidth * (i - start),
\r
y1 );
\r
}
\r
\r
y1 );
\r
}
\r
\r
@@
-242,29
+246,52
@@
public class SequenceRenderer
return false;
\r
}
\r
\r
return false;
\r
}
\r
\r
- public void drawHighlightedText(SequenceI seq, int start, int end, int x1,
\r
- int y1, int width, int height)
\r
+ public void drawHighlightedText(SequenceI seq, int start, int end, int x1, int y1)
\r
{
\r
{
\r
- int pady = height / 5;
\r
+ int pady = av.charHeight / 5;
\r
int charOffset = 0;
\r
graphics.setColor(Color.black);
\r
int charOffset = 0;
\r
graphics.setColor(Color.black);
\r
- graphics.fillRect(x1, y1, width * (end - start + 1), height);
\r
+ graphics.fillRect(x1, y1, av.charWidth * (end - start + 1), av.charHeight);
\r
graphics.setColor(Color.white);
\r
\r
char s = '~';
\r
// Need to find the sequence position here.
\r
graphics.setColor(Color.white);
\r
\r
char s = '~';
\r
// Need to find the sequence position here.
\r
- for (int i = start; i <= end; i++)
\r
+ if(av.validCharWidth)
\r
{
\r
{
\r
- if (i < seq.getLength())
\r
+ for (int i = start; i <= end; i++)
\r
{
\r
{
\r
- s = seq.getSequence().charAt(i);
\r
+ if (i < seq.getLength())
\r
+ {
\r
+ s = seq.getSequence().charAt(i);
\r
+ }
\r
+
\r
+ charOffset = (av.charWidth - fm.charWidth(s)) / 2;
\r
+ graphics.drawString(String.valueOf(s),
\r
+ charOffset + x1 + av.charWidth * (i - start),
\r
+ y1 + av.charHeight - pady);
\r
}
\r
}
\r
+ }
\r
+ }
\r
+
\r
+ public void drawCursor(SequenceI seq, int res, int x1, int y1)
\r
+ {
\r
+ int pady = av.charHeight / 5;
\r
+ int charOffset = 0;
\r
+ graphics.setColor(Color.black);
\r
+ graphics.fillRect(x1, y1, av.charWidth, av.charHeight);
\r
+ graphics.setColor(Color.white);
\r
\r
\r
- charOffset = (width - fm.charWidth(s)) / 2;
\r
+ graphics.setColor(Color.white);
\r
+
\r
+ char s = seq.getCharAt(res);
\r
+ if (av.validCharWidth)
\r
+ {
\r
+
\r
+ charOffset = (av.charWidth - fm.charWidth(s)) / 2;
\r
graphics.drawString(String.valueOf(s),
\r
graphics.drawString(String.valueOf(s),
\r
- charOffset + x1 + width * (i - start),
\r
- y1 + height - pady);
\r
+ charOffset + x1,
\r
+ (y1 + av.charHeight) - pady);
\r
+ }
\r
}
\r
}
\r
- }
\r
\r
}
\r
\r
}
\r