From 7720c1e94b0b88c9be05becae787078f152d8c5b Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Mon, 12 Sep 2005 12:23:43 +0000 Subject: [PATCH] Size checking in drawGraph --- src/jalview/appletgui/AnnotationPanel.java | 28 ++++++++++++++++------------ src/jalview/gui/AnnotationPanel.java | 8 ++++++-- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/jalview/appletgui/AnnotationPanel.java b/src/jalview/appletgui/AnnotationPanel.java index 6399b1c..ec5fbc6 100755 --- a/src/jalview/appletgui/AnnotationPanel.java +++ b/src/jalview/appletgui/AnnotationPanel.java @@ -479,19 +479,23 @@ public class AnnotationPanel } // used by overview window - public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, int y) + public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, int y, int sRes, int eRes) { - g.setColor(Color.white); - g.fillRect(0, 0, width, y); - g.setColor(new Color(0, 0, 180)); - int x = 0; - for (int j = 0; j < aa.annotations.length; j++) - { + g.setColor(Color.white); + g.fillRect(0, 0, width, y); g.setColor(new Color(0, 0, 180)); - int height = (int) ( (aa.annotations[j].value / aa.graphMax) * - GRAPH_HEIGHT); - g.fillRect(x, y - height, av.charWidth, height); - x += av.charWidth; + + int x = 0, height; + + for (int j = sRes; j < eRes; j++) + { + g.setColor(new Color(0, 0, 180)); + + height = (int) ((aa.annotations[j].value / aa.graphMax) * GRAPH_HEIGHT); + if(height>y) + height = y; + g.fillRect(x, y - height, av.charWidth, height); + x += av.charWidth; + } } - } } diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 9c2aac0..aeb0b9a 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -852,13 +852,17 @@ public class AnnotationPanel extends JPanel implements MouseListener, g.fillRect(0, 0, width, y); g.setColor(new Color(0, 0, 180)); - int x = 0; + + int x = 0, height; for (int j = sRes; j < eRes; j++) { g.setColor(new Color(0, 0, 180)); - int height = (int) ((aa.annotations[j].value / aa.graphMax) * GRAPH_HEIGHT); + height = (int) ((aa.annotations[j].value / aa.graphMax) * GRAPH_HEIGHT); + if(height>y) + height = y; + g.fillRect(x, y - height, av.charWidth, height); x += av.charWidth; } -- 1.7.10.2