import jalview.renderer.OverviewRenderer;
import jalview.viewmodel.OverviewDimensions;
-import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
-import javax.swing.Timer;
public class OverviewCanvas extends JComponent
{
- private static final long RUNNING_TIME = 1000;
-
- private static final int SPEED = 40;
-
private static final Color TRANS_GREY = new Color(100, 100, 100, 25);
// This is set true if the alignment view changes whilst
private BufferedImage lastMiniMe = null;
- private BufferedImage veryLastMiniMe = null;
-
// Can set different properties in this seqCanvas than
// main visible SeqCanvas
private SequenceRenderer sr;
private AlignViewportI av;
- private float alpha = 0f;
-
- private long startTime = -1;
-
- private final Timer timer;
-
private ProgressPanel progressPanel;
public OverviewCanvas(OverviewDimensions overviewDims,
fr = new jalview.renderer.seqfeatures.FeatureRenderer(av);
setSize(od.getWidth(), od.getHeight());
-
- timer = new Timer(SPEED, new ActionListener()
- {
-
- @Override
- public void actionPerformed(ActionEvent e)
- {
- if (startTime < 0)
- {
- startTime = System.currentTimeMillis();
- }
- else
- {
-
- long time = System.currentTimeMillis();
- long duration = time - startTime;
- if (duration >= RUNNING_TIME)
- {
- startTime = -1;
- ((Timer) e.getSource()).stop();
- alpha = 0f;
- }
- else
- {
- alpha = 1f - ((float) duration / (float) RUNNING_TIME);
- }
- repaint();
- }
- }
- });
}
/**
FeatureRenderer transferRenderer)
{
miniMe = null;
- veryLastMiniMe = lastMiniMe;
if (showSequenceFeatures)
{
{
updaterunning = false;
lastMiniMe = miniMe;
- alpha = 1f;
- timer.start();
}
}
}
else // not a resize
{
- if (alpha != 0) // this is a timer triggered dissolve
- {
- Graphics2D g2d = (Graphics2D) g.create();
-
- // draw the original image
- g2d.drawImage(veryLastMiniMe, 0, 0, getWidth(), getHeight(),
- this);
-
- // draw the new image on top with varying degrees of transparency
- g2d.setComposite(AlphaComposite.SrcOver.derive(1f - alpha));
- g2d.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this);
-
- g2d.dispose();
- }
- else
- {
- // fall back to normal behaviour
- g.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this);
- }
+ // fall back to normal behaviour
+ g.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this);
}
}