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
vamsasDemo new branch
[jalview.git]
/
src
/
jalview
/
gui
/
AnnotationPanel.java
diff --git
a/src/jalview/gui/AnnotationPanel.java
b/src/jalview/gui/AnnotationPanel.java
index
b8570a9
..
d97c80f
100755
(executable)
--- a/
src/jalview/gui/AnnotationPanel.java
+++ b/
src/jalview/gui/AnnotationPanel.java
@@
-76,6
+76,12
@@
public class AnnotationPanel extends JPanel implements MouseListener,
ap.annotationScroller.getVerticalScrollBar().addAdjustmentListener(this);
\r
}
\r
\r
ap.annotationScroller.getVerticalScrollBar().addAdjustmentListener(this);
\r
}
\r
\r
+ public AnnotationPanel(AlignViewport av)
\r
+ {
\r
+ this.av = av;
\r
+ }
\r
+
\r
+
\r
/**
\r
* DOCUMENT ME!
\r
*
\r
/**
\r
* DOCUMENT ME!
\r
*
\r
@@
-89,9
+95,10
@@
public class AnnotationPanel extends JPanel implements MouseListener,
/**
\r
* DOCUMENT ME!
\r
*/
\r
/**
\r
* DOCUMENT ME!
\r
*/
\r
- public void adjustPanelHeight()
\r
+ public int adjustPanelHeight()
\r
{
\r
// setHeight of panels
\r
{
\r
// setHeight of panels
\r
+ image = null;
\r
AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
\r
int height = 0;
\r
\r
AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
\r
int height = 0;
\r
\r
@@
-135,6
+142,8
@@
public class AnnotationPanel extends JPanel implements MouseListener,
}
\r
\r
this.setPreferredSize(new Dimension(1, height));
\r
}
\r
\r
this.setPreferredSize(new Dimension(1, height));
\r
+
\r
+ return height;
\r
}
\r
\r
/**
\r
}
\r
\r
/**
\r
@@
-147,6
+156,8
@@
public class AnnotationPanel extends JPanel implements MouseListener,
if (activeRow == -1)
\r
{
\r
AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
\r
if (activeRow == -1)
\r
{
\r
AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
\r
+ if(aa==null)
\r
+ return;
\r
\r
for (int j = 0; j < aa.length; j++)
\r
{
\r
\r
for (int j = 0; j < aa.length; j++)
\r
{
\r
@@
-177,6
+188,8
@@
public class AnnotationPanel extends JPanel implements MouseListener,
if (activeRow == -1)
\r
{
\r
AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
\r
if (activeRow == -1)
\r
{
\r
AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
\r
+ if(aa==null)
\r
+ return;
\r
\r
for (int j = 0; j < aa.length; j++)
\r
{
\r
\r
for (int j = 0; j < aa.length; j++)
\r
{
\r
@@
-332,7
+345,10
@@
public class AnnotationPanel extends JPanel implements MouseListener,
\r
for (int i = 0; i < aa.length; i++)
\r
{
\r
\r
for (int i = 0; i < aa.length; i++)
\r
{
\r
- height += aa[i].height;
\r
+ if (aa[i].visible)
\r
+ {
\r
+ height += aa[i].height;
\r
+ }
\r
\r
if (evt.getY() < height)
\r
{
\r
\r
if (evt.getY() < height)
\r
{
\r
@@
-519,29
+535,32
@@
public class AnnotationPanel extends JPanel implements MouseListener,
*/
\r
public void paintComponent(Graphics g)
\r
{
\r
*/
\r
public void paintComponent(Graphics g)
\r
{
\r
- g.setColor(Color.white);
\r
- g.fillRect(0, 0, getWidth(), getHeight());
\r
+ g.setColor(Color.white);
\r
+ g.fillRect(0, 0, getWidth(), getHeight());
\r
\r
\r
- if (fastPaint)
\r
- {
\r
- g.drawImage(image, 0, 0, this);
\r
- fastPaint = false;
\r
-
\r
- return;
\r
- }
\r
+ if (fastPaint && image!=null)
\r
+ {
\r
+ g.drawImage(image, 0, 0, this);
\r
+ fastPaint = false;
\r
+ return;
\r
+ }
\r
\r
\r
- imgWidth = (av.endRes - av.startRes + 1) * av.charWidth;
\r
+ imgWidth = (av.endRes - av.startRes + 1) * av.charWidth;
\r
\r
\r
+ if (image == null || imgWidth != image.getWidth())
\r
+ {
\r
image = new BufferedImage(imgWidth, ap.annotationPanel.getHeight(),
\r
image = new BufferedImage(imgWidth, ap.annotationPanel.getHeight(),
\r
- BufferedImage.TYPE_INT_RGB);
\r
+ BufferedImage.TYPE_INT_RGB);
\r
gg = (Graphics2D) image.getGraphics();
\r
gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
\r
gg = (Graphics2D) image.getGraphics();
\r
gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
\r
- RenderingHints.VALUE_ANTIALIAS_ON);
\r
+ RenderingHints.VALUE_ANTIALIAS_ON);
\r
\r
gg.setFont(av.getFont());
\r
\r
gg.setFont(av.getFont());
\r
+ fm = gg.getFontMetrics();
\r
+ }
\r
\r
\r
- drawComponent(gg, av.startRes, av.endRes + 1);
\r
- g.drawImage(image, 0, 0, this);
\r
+ drawComponent(gg, av.startRes, av.endRes + 1);
\r
+ g.drawImage(image, 0, 0, this);
\r
}
\r
\r
/**
\r
}
\r
\r
/**
\r
@@
-583,7
+602,9
@@
public class AnnotationPanel extends JPanel implements MouseListener,
gg.translate(-transX, 0);
\r
\r
fastPaint = true;
\r
gg.translate(-transX, 0);
\r
\r
fastPaint = true;
\r
+
\r
repaint();
\r
repaint();
\r
+
\r
}
\r
\r
/**
\r
}
\r
\r
/**
\r
@@
-593,11
+614,14
@@
public class AnnotationPanel extends JPanel implements MouseListener,
* @param startRes DOCUMENT ME!
\r
* @param endRes DOCUMENT ME!
\r
*/
\r
* @param startRes DOCUMENT ME!
\r
* @param endRes DOCUMENT ME!
\r
*/
\r
- public void drawComponent(Graphics2D g, int startRes, int endRes)
\r
+ public void drawComponent(Graphics g, int startRes, int endRes)
\r
{
\r
{
\r
- if(fm==null)
\r
+ g.setFont(av.getFont());
\r
+
\r
+ if (fm == null)
\r
fm = g.getFontMetrics();
\r
\r
fm = g.getFontMetrics();
\r
\r
+
\r
g.setColor(Color.white);
\r
g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getHeight());
\r
\r
g.setColor(Color.white);
\r
g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getHeight());
\r
\r
@@
-632,6
+656,7
@@
public class AnnotationPanel extends JPanel implements MouseListener,
continue;
\r
}
\r
\r
continue;
\r
}
\r
\r
+
\r
if (row.isGraph)
\r
{
\r
// this is so that we draw the characters below the graph
\r
if (row.isGraph)
\r
{
\r
// this is so that we draw the characters below the graph
\r
@@
-697,14
+722,14
@@
public class AnnotationPanel extends JPanel implements MouseListener,
if (j == 0 || row.isGraph)
\r
{
\r
g.drawString(row.annotations[j].displayCharacter, x+charOffset,
\r
if (j == 0 || row.isGraph)
\r
{
\r
g.drawString(row.annotations[j].displayCharacter, x+charOffset,
\r
- y + iconOffset + 2);
\r
+ y + iconOffset + 3);
\r
}
\r
else if (((row.annotations[j - 1] == null) ||
\r
(row.annotations[j].displayCharacter != row.annotations[j -
\r
1].displayCharacter)))
\r
{
\r
g.drawString(row.annotations[j].displayCharacter, x+charOffset,
\r
}
\r
else if (((row.annotations[j - 1] == null) ||
\r
(row.annotations[j].displayCharacter != row.annotations[j -
\r
1].displayCharacter)))
\r
{
\r
g.drawString(row.annotations[j].displayCharacter, x+charOffset,
\r
- y + iconOffset + 2);
\r
+ y + iconOffset + 3);
\r
}
\r
}
\r
\r
}
\r
}
\r
\r
@@
-839,19
+864,23
@@
public class AnnotationPanel extends JPanel implements MouseListener,
}
\r
\r
// used by overview window
\r
}
\r
\r
// used by overview window
\r
- public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, int y)
\r
+ public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, int y, int sRes, int eRes)
\r
{
\r
g.setColor(Color.white);
\r
g.fillRect(0, 0, width, y);
\r
g.setColor(new Color(0, 0, 180));
\r
\r
{
\r
g.setColor(Color.white);
\r
g.fillRect(0, 0, width, y);
\r
g.setColor(new Color(0, 0, 180));
\r
\r
- int x = 0;
\r
\r
\r
- for (int j = 0; j < aa.annotations.length; j++)
\r
+ int x = 0, height;
\r
+
\r
+ for (int j = sRes; j < eRes; j++)
\r
{
\r
g.setColor(new Color(0, 0, 180));
\r
\r
{
\r
g.setColor(new Color(0, 0, 180));
\r
\r
- int height = (int) ((aa.annotations[j].value / aa.graphMax) * GRAPH_HEIGHT);
\r
+ height = (int) ((aa.annotations[j].value / aa.graphMax) * GRAPH_HEIGHT);
\r
+ if(height>y)
\r
+ height = y;
\r
+
\r
g.fillRect(x, y - height, av.charWidth, height);
\r
x += av.charWidth;
\r
}
\r
g.fillRect(x, y - height, av.charWidth, height);
\r
x += av.charWidth;
\r
}
\r