boxX = evt.getX();\r
boxY = evt.getY();\r
checkValid();\r
- if (!resizing)\r
- {\r
- ap.setScrollValues( (int) (boxX / scalew / av.getCharWidth()),\r
+ ap.setScrollValues( (int) (boxX / scalew / av.getCharWidth()),\r
(int) (boxY / scaleh / av.getCharHeight()));\r
- }\r
}\r
\r
public void doMouseDragged(MouseEvent evt)\r
boxX = evt.getX();\r
boxY = evt.getY();\r
checkValid();\r
- if (!resizing)\r
- {\r
- ap.setScrollValues( (int) (boxX / scalew / av.getCharWidth()),\r
+ ap.setScrollValues( (int) (boxX / scalew / av.getCharWidth()),\r
(int) (boxY / scaleh / av.getCharHeight()));\r
- }\r
+\r
repaint();\r
ap.repaint();\r
}\r
*/\r
public void updateOverviewImage()\r
{\r
- if (resizing)\r
- {\r
- resizeAgain = true;\r
- return;\r
- }\r
+ if (resizing)\r
+ {\r
+ resizeAgain = true;\r
+ return;\r
+ }\r
\r
- resizing = true;\r
+ resizing = true;\r
\r
- Thread thread = new Thread(this);\r
- thread.start();\r
- repaint();\r
+ if ( (getSize().width > 0) && (getSize().height > 0))\r
+ {\r
+ width = getSize().width;\r
+ sequencesHeight = getSize().height - graphHeight;\r
+ }\r
+ setSize(new Dimension(width, sequencesHeight + graphHeight));\r
+ setBoxPosition();\r
+\r
+ Thread thread = new Thread(this);\r
+ thread.start();\r
+ repaint();\r
}\r
\r
// This is set true if the user resizes whilst\r
\r
public void paint(Graphics g)\r
{\r
- if (resizing)\r
+ if (miniMe != null)\r
+ {\r
+ g.drawImage(miniMe, 0, 0, this);\r
+ }\r
+ else\r
{\r
g.setColor(Color.white);\r
g.fillRect(0, 0, getSize().width, getSize().height);\r
g.setColor(Color.black);\r
-\r
g.setFont(new Font("Verdana", Font.BOLD, 15));\r
g.drawString("Recalculating", 5, sequencesHeight / 2);\r
- g.drawString("Overview.....", 5, sequencesHeight / 2 + 20);\r
+ g.drawString("Overview.....", 5, (sequencesHeight / 2) + 20);\r
}\r
- else\r
- {\r
- if (miniMe != null)\r
- {\r
- g.drawImage(miniMe, 0, 0, this);\r
- }\r
\r
- g.setColor(Color.red);\r
- g.drawRect(boxX, boxY, boxWidth, boxHeight);\r
- g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2);\r
- }\r
+ g.setColor(Color.red);\r
+ g.drawRect(boxX, boxY, boxWidth, boxHeight);\r
+ g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2);\r
}\r
\r
}\r
\r
public void fastPaint(int horizontal, int vertical)\r
{\r
- if (horizontal == 0 && vertical == 0 || gg == null)\r
+ if (gg == null)\r
{\r
return;\r
}\r
{\r
do\r
{\r
- int oldY = -1;\r
- int i = 0;\r
- boolean inGroup = false;\r
- int top = -1, bottom = -1;\r
- for (i = y1; i < y2; i++)\r
- {\r
- sx = (group.getStartRes() - startx) * av.charWidth;\r
- sy = offset + (i-starty)*av.charHeight;\r
- ex = (group.getEndRes() + 1 - group.getStartRes()) * av.charWidth - 1;\r
+ int oldY = -1;\r
+ int i = 0;\r
+ boolean inGroup = false;\r
+ int top = -1;\r
+ int bottom = -1;\r
\r
- if (sx < getSize().width\r
- && ex > 0\r
- && group.sequences.contains(av.alignment.getSequenceAt(i)))\r
+ for (i = y1; i < y2; i++)\r
{\r
- if (bottom == -1 && (i == av.alignment.getHeight() - 1 ||\r
- !group.sequences.contains(av.alignment.\r
- getSequenceAt(i + 1))))\r
- {\r
- bottom = sy + av.charHeight;\r
- }\r
+ sx = (group.getStartRes() - startx) * av.charWidth;\r
+ sy = offset + ((i - starty) * av.charHeight);\r
+ ex = (((group.getEndRes() + 1) - group.getStartRes()) * av.charWidth) -\r
+ 1;\r
\r
- if (!inGroup)\r
- {\r
- if (top == -1 && i == 0 ||\r
- !group.sequences.contains(av.alignment.getSequenceAt(i - 1)))\r
+ if(sx+ex<0 || sx>imgWidth)\r
{\r
- top = sy;\r
+ continue;\r
}\r
\r
- oldY = sy;\r
- inGroup = true;\r
- if (group == av.getSelectionGroup())\r
+ if ( (sx <= (x2-x1)*av.charWidth) &&\r
+ group.sequences.contains(av.alignment.getSequenceAt(\r
+ i)))\r
{\r
- g.setColor(new Color(255, 0, 0));\r
+ if ((bottom == -1) &&\r
+ !group.sequences.contains(\r
+ av.alignment.getSequenceAt(i + 1)))\r
+ {\r
+ bottom = sy + av.charHeight;\r
+ }\r
+\r
+ if (!inGroup)\r
+ {\r
+ if (((top == -1) && (i == 0)) ||\r
+ !group.sequences.contains(\r
+ av.alignment.getSequenceAt(i - 1)))\r
+ {\r
+ top = sy;\r
+ }\r
+\r
+ oldY = sy;\r
+ inGroup = true;\r
+\r
+ if (group == av.getSelectionGroup())\r
+ {\r
+ g.setColor(Color.red);\r
+ }\r
+ else\r
+ {\r
+ g.setColor(group.getOutlineColour());\r
+ }\r
+ }\r
}\r
else\r
{\r
- g.setColor(group.getOutlineColour());\r
+ if (inGroup)\r
+ {\r
+ if (sx >= 0 && sx < imgWidth)\r
+ g.drawLine(sx, oldY, sx, sy);\r
+\r
+ if (sx + ex < imgWidth)\r
+ g.drawLine(sx + ex, oldY, sx + ex, sy);\r
+\r
+ if (sx < 0)\r
+ {\r
+ ex += sx;\r
+ sx = 0;\r
+ }\r
+\r
+ if (sx + ex > imgWidth)\r
+ ex = imgWidth;\r
+\r
+ else if (sx + ex >= (x2 - x1 + 1) * av.charWidth)\r
+ ex = (x2 - x1 + 1) * av.charWidth;\r
+\r
+ if (top != -1)\r
+ {\r
+ g.drawLine(sx, top, sx + ex, top);\r
+ top = -1;\r
+ }\r
+\r
+ if (bottom != -1)\r
+ {\r
+ g.drawLine(sx, bottom, sx + ex, bottom);\r
+ bottom = -1;\r
+ }\r
+\r
+ inGroup = false;\r
+ }\r
}\r
- }\r
}\r
- else\r
+\r
+ if (inGroup)\r
{\r
- if (inGroup)\r
- {\r
+ sy = offset + ( (i - starty) * av.charHeight);\r
+ if (sx >= 0 && sx < imgWidth)\r
g.drawLine(sx, oldY, sx, sy);\r
+\r
+ if (sx + ex < imgWidth)\r
g.drawLine(sx + ex, oldY, sx + ex, sy);\r
\r
- if (top != -1)\r
- {\r
- g.drawLine(sx, top, sx + ex, top);\r
- top = -1;\r
- }\r
- if (bottom != -1)\r
- {\r
- g.drawLine(sx, bottom, sx + ex, bottom);\r
- bottom = -1;\r
- }\r
+ if (sx < 0)\r
+ {\r
+ ex += sx;\r
+ sx = 0;\r
+ }\r
\r
- inGroup = false;\r
+ if (sx + ex > imgWidth)\r
+ ex = imgWidth;\r
+ else if (sx + ex >= (x2 - x1 + 1) * av.charWidth)\r
+ ex = (x2 - x1 + 1) * av.charWidth;\r
+\r
+ if (top != -1)\r
+ {\r
+ g.drawLine(sx, top, sx + ex, top);\r
+ top = -1;\r
}\r
- }\r
- }\r
\r
- if (inGroup)\r
- {\r
+ if (bottom != -1)\r
+ {\r
+ g.drawLine(sx, bottom - 1, sx + ex, bottom - 1);\r
+ bottom = -1;\r
+ }\r
\r
- if (top != -1)\r
- {\r
- g.drawLine(sx, top, sx + ex, top);\r
- top = -1;\r
+ inGroup = false;\r
}\r
- if (bottom != -1)\r
- {\r
- g.drawLine(sx, bottom - 1, sx + ex, bottom - 1);\r
- bottom = -1;\r
\r
- }\r
- sy = offset + (i-starty)*av.charHeight;\r
- g.drawLine(sx, oldY, sx, sy);\r
- g.drawLine(sx + ex, oldY, sx + ex, sy);\r
- inGroup = false;\r
- }\r
- groupIndex++;\r
- if (groupIndex >= groups.size())\r
- {\r
- break;\r
- }\r
+ groupIndex++;\r
\r
- group = (SequenceGroup) groups.elementAt(groupIndex);\r
+ if (groupIndex >= groups.size())\r
+ {\r
+ break;\r
+ }\r
\r
+ group = (SequenceGroup) groups.elementAt(groupIndex);\r
}\r
while (groupIndex < groups.size());\r
}\r
boxY = evt.getY();\r
checkValid();\r
\r
- if (!resizing)\r
- {\r
- ap.setScrollValues((int) (boxX / scalew / av.getCharWidth()),\r
+ ap.setScrollValues((int) (boxX / scalew / av.getCharWidth()),\r
(int) (boxY / scaleh / av.getCharHeight()));\r
- }\r
}\r
\r
/**\r
boxY = evt.getY();\r
checkValid();\r
\r
- if (!resizing)\r
- {\r
- ap.setScrollValues((int) (boxX / scalew / av.getCharWidth()),\r
- (int) (boxY / scaleh / av.getCharHeight()));\r
- }\r
+ ap.setScrollValues( (int) (boxX / scalew / av.getCharWidth()),\r
+ (int) (boxY / scaleh / av.getCharHeight()));\r
+ repaint();\r
}\r
\r
/**\r
\r
resizing = true;\r
\r
+ if ( (getWidth() > 0) && (getHeight() > 0))\r
+ {\r
+ width = getWidth();\r
+ sequencesHeight = getHeight() - graphHeight;\r
+ }\r
+ setPreferredSize(new Dimension(width, sequencesHeight + graphHeight));\r
+ setBoxPosition();\r
+\r
Thread thread = new Thread(this);\r
thread.start();\r
repaint();\r
int alwidth = av.alignment.getWidth();\r
int alheight = av.alignment.getHeight();\r
\r
- if ((getWidth() > 0) && (getHeight() > 0))\r
- {\r
- width = getWidth();\r
- sequencesHeight = getHeight() - graphHeight;\r
- }\r
-\r
setPreferredSize(new Dimension(width, sequencesHeight + graphHeight));\r
\r
int fullsizeWidth = alwidth * av.getCharWidth();\r
miniMe = new BufferedImage(width, sequencesHeight + graphHeight,\r
BufferedImage.TYPE_INT_RGB);\r
\r
+\r
+\r
Graphics mg = miniMe.getGraphics();\r
- BufferedImage consensus = new BufferedImage(fullsizeWidth, 60,\r
- BufferedImage.TYPE_3BYTE_BGR);\r
- Graphics g = consensus.getGraphics();\r
- ap.annotationPanel.drawGraph(g, av.conservation, fullsizeWidth, 60);\r
- mg.drawImage(consensus, 0, sequencesHeight, width,\r
- sequencesHeight + graphHeight, 0, 0, fullsizeWidth, 60, this);\r
+ BufferedImage consensus;\r
+ Graphics cg;\r
+ Graphics g ;\r
+\r
+ mg.setColor(Color.white);\r
+ mg.fillRect(0, 0, getWidth(), getHeight());\r
+ mg.setColor(Color.black);\r
+ mg.setFont(new Font("Verdana", Font.BOLD, 15));\r
+ mg.drawString("Recalculating", 5, sequencesHeight / 2);\r
+ mg.drawString("Overview.....", 5, (sequencesHeight / 2) + 20);\r
\r
boolean oldRenderGaps = av.renderGaps;\r
\r
for (int sSeq = 0, chunky = 0; sSeq < alheight;\r
sSeq += maxSize, chunky++)\r
{\r
+ if (resizeAgain)\r
+ break;\r
eSeq += maxSize;\r
\r
if (eSeq > alheight)\r
\r
blocky += (int) ((float) sSeq / (float) alheight * sequencesHeight);\r
\r
+ if(av.conservation!=null)\r
+ {\r
+ consensus = new BufferedImage( (eRes - sRes) * av.charWidth, 60,\r
+ BufferedImage.TYPE_3BYTE_BGR);\r
+ cg = consensus.getGraphics();\r
+\r
+ ap.annotationPanel.drawGraph(cg, av.conservation,\r
+ (eRes - sRes) * av.charWidth, 60, sRes, eRes);\r
+\r
+ mg.drawImage(consensus, blockx, sequencesHeight, blockx + blockw,\r
+\r
+ sequencesHeight + graphHeight, 0, 0,\r
+ (eRes - sRes) * av.charWidth, 60, this);\r
+ }\r
+\r
mg.drawImage(block, blockx, blocky, blockx + blockw,\r
blocky + blockh, 0, 0, block.getWidth(),\r
block.getHeight(), null);\r
\r
block = null;\r
+ repaint();\r
}\r
+\r
+\r
}\r
}\r
catch (OutOfMemoryError error)\r
*/\r
public void paintComponent(Graphics g)\r
{\r
- g.setColor(Color.white);\r
- g.fillRect(0, 0, getWidth(), getHeight());\r
- g.setColor(Color.black);\r
-\r
- if (resizing)\r
+ if (miniMe != null)\r
{\r
- g.setFont(new Font("Verdana", Font.BOLD, 15));\r
- g.drawString("Recalculating", 5, sequencesHeight / 2);\r
- g.drawString("Overview.....", 5, (sequencesHeight / 2) + 20);\r
+ g.drawImage(miniMe, 0, 0, this);\r
}\r
else\r
{\r
- if (miniMe != null)\r
- {\r
- g.drawImage(miniMe, 0, 0, this);\r
- }\r
-\r
- g.setColor(Color.red);\r
- g.drawRect(boxX, boxY, boxWidth, boxHeight);\r
- g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2);\r
+ g.setColor(Color.white);\r
+ g.fillRect(0, 0, getWidth(), getHeight());\r
+ g.setColor(Color.black);\r
+ g.setFont(new Font("Verdana", Font.BOLD, 15));\r
+ g.drawString("Recalculating", 5, sequencesHeight / 2);\r
+ g.drawString("Overview.....", 5, (sequencesHeight / 2) + 20);\r
}\r
+\r
+ g.setColor(Color.red);\r
+ g.drawRect(boxX, boxY, boxWidth, boxHeight);\r
+ g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2);\r
+\r
}\r
}\r
*/\r
public void fastPaint(int horizontal, int vertical)\r
{\r
- if (((horizontal == 0) && (vertical == 0)) || (gg == null))\r
+ if (gg == null)\r
{\r
return;\r
}\r
\r
if (horizontal > 0) // scrollbar pulled right, image to the left\r
{\r
+ er ++;\r
transX = (er - sr - horizontal) * av.charWidth;\r
sr = er - horizontal;\r
}\r
else if (horizontal < 0)\r
{\r
- er = sr - horizontal;\r
+ er = sr - horizontal-1;\r
}\r
else if (vertical > 0) // scroll down\r
{\r
}\r
\r
gg.translate(transX, transY);\r
-\r
- gg.setColor(Color.white);\r
- gg.fillRect(0, 0, (er - sr + 1) * av.charWidth,\r
- (es - ss) * av.charHeight);\r
drawPanel(gg, sr, er, ss, es, sr, ss, 0);\r
gg.translate(-transX, -transY);\r
\r
img = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB);\r
gg = (Graphics2D) img.getGraphics();\r
gg.setFont(av.getFont());\r
- gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,\r
- RenderingHints.VALUE_ANTIALIAS_ON);\r
+ // gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,\r
+ // RenderingHints.VALUE_ANTIALIAS_ON);\r
\r
gg.setColor(Color.white);\r
gg.fillRect(0, 0, imgWidth, imgHeight);\r
cWidth * av.charWidth, (int) clip.getBounds().getHeight());\r
}\r
\r
- if(av.alignment.getWidth() >= av.vconsensus.size())\r
- {\r
- endx = av.vconsensus.size()-2;\r
- }\r
-\r
drawPanel(g, startRes, endx, 0, al.getHeight(), startRes, 0, ypos);\r
g.setClip(clip);\r
g.translate(-LABEL_WEST, 0);\r
ex = (((group.getEndRes() + 1) - group.getStartRes()) * av.charWidth) -\r
1;\r
\r
+ if(sx+ex<0 || sx>imgWidth)\r
+ {\r
+ continue;\r
+ }\r
\r
- if ((sx < (x2-x1)*av.charWidth) &&\r
+ if ( (sx <= (x2-x1)*av.charWidth) &&\r
group.sequences.contains(av.alignment.getSequenceAt(\r
i)))\r
{\r
}\r
else\r
{\r
- if (inGroup)\r
+ if (inGroup)\r
+ {\r
+ if (sx >= 0 && sx < imgWidth)\r
+ g.drawLine(sx, oldY, sx, sy);\r
+\r
+ if (sx + ex < imgWidth)\r
+ g.drawLine(sx + ex, oldY, sx + ex, sy);\r
+\r
+ if (sx < 0)\r
{\r
- g.drawLine(sx, oldY, sx, sy);\r
- g.drawLine(sx + ex, oldY, sx + ex, sy);\r
+ ex += sx;\r
+ sx = 0;\r
+ }\r
\r
- if (top != -1)\r
- {\r
- g.drawLine(sx, top, sx + ex, top);\r
- top = -1;\r
- }\r
+ if (sx + ex > imgWidth)\r
+ ex = imgWidth;\r
\r
- if (bottom != -1)\r
- {\r
- g.drawLine(sx, bottom, sx + ex, bottom);\r
- bottom = -1;\r
- }\r
+ else if (sx + ex >= (x2 - x1 + 1) * av.charWidth)\r
+ ex = (x2 - x1 + 1) * av.charWidth;\r
\r
- inGroup = false;\r
+ if (top != -1)\r
+ {\r
+ g.drawLine(sx, top, sx + ex, top);\r
+ top = -1;\r
+ }\r
+\r
+ if (bottom != -1)\r
+ {\r
+ g.drawLine(sx, bottom, sx + ex, bottom);\r
+ bottom = -1;\r
+ }\r
+\r
+ inGroup = false;\r
}\r
}\r
}\r
\r
-\r
if (inGroup)\r
{\r
- if (top != -1)\r
- {\r
- g.drawLine(sx, top, sx + ex, top);\r
- top = -1;\r
- }\r
-\r
- if (bottom != -1)\r
- {\r
- g.drawLine(sx, bottom - 1, sx + ex, bottom - 1);\r
- bottom = -1;\r
- }\r
-\r
- sy = offset + ((i - starty) * av.charHeight);\r
+ sy = offset + ( (i - starty) * av.charHeight);\r
+ if (sx >= 0 && sx < imgWidth)\r
g.drawLine(sx, oldY, sx, sy);\r
+\r
+ if (sx + ex < imgWidth)\r
g.drawLine(sx + ex, oldY, sx + ex, sy);\r
+\r
+ if (sx < 0)\r
+ {\r
+ ex += sx;\r
+ sx = 0;\r
+ }\r
+\r
+ if (sx + ex > imgWidth)\r
+ ex = imgWidth;\r
+ else if (sx + ex >= (x2 - x1 + 1) * av.charWidth)\r
+ ex = (x2 - x1 + 1) * av.charWidth;\r
+\r
+ if (top != -1)\r
+ {\r
+ g.drawLine(sx, top, sx + ex, top);\r
+ top = -1;\r
+ }\r
+\r
+ if (bottom != -1)\r
+ {\r
+ g.drawLine(sx, bottom - 1, sx + ex, bottom - 1);\r
+ bottom = -1;\r
+ }\r
+\r
inGroup = false;\r
}\r
\r