label.show_experimental = Enable experimental features
label.show_experimental_tip = Enable any new and currently 'experimental' features (see Latest Release Notes for details)
label.warning_hidden = Warning: {0} {1} is currently hidden
+label.oview_calc = Recalculating overview...
\ No newline at end of file
label.show_experimental = Habilitar funciones experimentales
label.show_experimental_tip = Habilitar funciones nuevas y experimentales (ver Latest Release Notes para más detalles)
label.warning_hidden = Advertencia: {0} {1} está actualmente oculto
+label.oview_calc = Recalculando resumen
\ No newline at end of file
--- /dev/null
+package jalview.api;
+
+import java.beans.PropertyChangeListener;
+
+public interface RendererListenerI extends PropertyChangeListener
+{
+
+}
public class OverviewCanvas extends JComponent
{
- public static final long RUNNING_TIME = 2000;
+ private static final long RUNNING_TIME = 2000;
+
+ 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 AlignViewportI av;
- private boolean resize = false;
-
private float alpha = 0f;
private long startTime = -1;
private final Timer timer;
+ private ProgressPanel progressPanel;
+
public OverviewCanvas(OverviewDimensions overviewDims,
- AlignViewportI alignvp)
+ AlignViewportI alignvp, ProgressPanel pp)
{
od = overviewDims;
av = alignvp;
+ progressPanel = pp;
sr = new SequenceRenderer(av);
sr.renderGaps = false;
sr.forOverview = true;
fr = new jalview.renderer.seqfeatures.FeatureRenderer(av);
- timer = new Timer(40, new ActionListener()
+ timer = new Timer(SPEED, new ActionListener()
{
@Override
setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
or = new OverviewRenderer(sr, fr, od);
+ or.addPropertyChangeListener(progressPanel);
miniMe = or.draw(od.getRows(av.getAlignment()),
od.getColumns(av.getAlignment()));
}
System.gc();
+ or.removePropertyChangeListener(progressPanel);
if (restart)
{
restart = false;
*/
package jalview.gui;
+import jalview.renderer.OverviewRenderer;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.viewmodel.OverviewDimensions;
private boolean draggingBox = false;
+ private ProgressPanel progressPanel;
+
/**
* Creates a new OverviewPanel object.
*
setSize(od.getWidth(), od.getHeight());
- oviewCanvas = new OverviewCanvas(od, av);
setLayout(new BorderLayout());
+ progressPanel = new ProgressPanel(OverviewRenderer.UPDATE,
+ MessageManager.getString("label.oview_calc"));
+ this.add(progressPanel, BorderLayout.SOUTH);
+ oviewCanvas = new OverviewCanvas(od, av, progressPanel);
+
add(oviewCanvas, BorderLayout.CENTER);
+
av.getRanges().addPropertyChangeListener(this);
addComponentListener(new ComponentAdapter()
return;
}
+ // oviewCanvas.addPropertyChangeListener(OverviewRenderer.UPDATE, this);
+
Thread thread = new Thread(this);
thread.start();
repaint();
+
+
}
@Override
av.getRanges().removePropertyChangeListener(this);
} finally
{
+ progressPanel = null;
av = null;
oviewCanvas = null;
ap = null;
od = null;
}
}
+
+ /* private void addProgressBar()
+ {
+ progressPanel = new JPanel(new BorderLayout(10, 0));
+ progressPanel.setBorder(new EmptyBorder(0, 3, 0, 20));
+
+ this.add(progressPanel, BorderLayout.SOUTH);
+
+ progressBar = new OvProgressBar();
+ progressBar.setMinimum(0);
+
+ progressPanel.add(new JLabel("Recalculating overview..."),
+ BorderLayout.WEST);
+ progressPanel.add(progressBar, BorderLayout.CENTER);
+ }
+
+ private void removeProgressBar()
+ {
+ if (progressPanel != null)
+ {
+ synchronized (progressPanel)
+ {
+ progressPanel.remove(progressBar);
+ this.remove(progressPanel);
+ progressPanel = null;
+ }
+ }
+ }*/
}
--- /dev/null
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.gui;
+
+import jalview.api.RendererListenerI;
+
+import java.awt.BorderLayout;
+import java.beans.PropertyChangeEvent;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+import javax.swing.border.EmptyBorder;
+
+/**
+ * A class to manage a panel containing a label and progress bar updated by an
+ * event firing
+ *
+ * @author kmourao
+ *
+ */
+public class ProgressPanel extends JPanel implements RendererListenerI
+{
+ // max value of progress bar: values expected to be %s
+ private final int MAXVALUE = 100;
+
+ // name of event property which updates the progress bar
+ private String eventName;
+
+ private JProgressBar progressBar;
+
+ private JLabel progressLabel;
+
+ /**
+ * Construct a JPanel containing a progress bar and a label.
+ *
+ * @param eventPropertyName
+ * The name of the event property to update the progress bar
+ * @param label
+ * The label to place next to the progress bar
+ */
+ public ProgressPanel(String eventPropertyName, String label)
+ {
+ super(new BorderLayout(10, 0));
+ setBorder(new EmptyBorder(0, 3, 0, 20));
+
+ eventName = eventPropertyName;
+
+ progressBar = new JProgressBar();
+ progressBar.setMinimum(0);
+ progressLabel = new JLabel(label);
+
+ add(progressLabel, BorderLayout.WEST);
+ add(progressBar, BorderLayout.CENTER);
+ }
+
+ @Override
+ /**
+ * Update the progress bar in response to the event. Expects the value
+ * supplied by the event to be in the range 0-100 i.e. a percentage
+ */
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ if (evt.getPropertyName().equals(eventName))
+ {
+ int progress = (int) evt.getNewValue();
+
+ System.out.println(progress);
+
+ progressBar.setValue(progress);
+ if (progress < MAXVALUE && !progressBar.isVisible())
+ {
+ progressBar.setVisible(true);
+ progressLabel.setVisible(true);
+ }
+ else if (progress >= MAXVALUE)
+ {
+ progressBar.setVisible(false);
+ progressLabel.setVisible(false);
+ }
+ }
+ }
+}
import jalview.api.AlignmentColsCollectionI;
import jalview.api.AlignmentRowsCollectionI;
+import jalview.api.RendererListenerI;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
import jalview.datamodel.SequenceI;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
+import java.beans.PropertyChangeSupport;
public class OverviewRenderer
{
+ public static final String UPDATE = "OverviewUpdate";
+
+ protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(
+ this);
+
private FeatureColourFinder finder;
private jalview.api.SequenceRenderer sr;
// raw number of pixels to allocate to each row
private float pixelsPerSeq;
+ // height in pixels of graph
+ private int graphHeight;
+
// flag to indicate whether to halt drawing
private volatile boolean redraw = false;
pixelsPerCol = od.getPixelsPerCol();
pixelsPerSeq = od.getPixelsPerSeq();
+ graphHeight = od.getGraphHeight();
miniMe = new BufferedImage(od.getWidth(), od.getHeight(),
BufferedImage.TYPE_INT_RGB);
}
int rgbcolor = Color.white.getRGB();
int seqIndex = 0;
int pixelRow = 0;
+ int alignmentHeight = miniMe.getHeight() - graphHeight;
for (int alignmentRow : rows)
{
{
if (redraw)
{
+
break;
}
}
colIndex++;
}
- pixelRow = endRow + 1;
+
+ if (pixelRow != endRow + 1)
+ {
+ changeSupport.firePropertyChange(UPDATE,
+ Math.round(100 * (float) pixelRow / alignmentHeight),
+ Math.round(
+ 100 * ((float) (endRow + 1) / alignmentHeight)));
+ pixelRow = endRow + 1;
+ }
seqIndex++;
}
+
+ // final update to progress bar if present
+ if (redraw)
+ {
+ changeSupport.firePropertyChange(UPDATE,
+ Math.round(100 * (float) (pixelRow - 1) / alignmentHeight),
+ 0);
+ }
+ else
+ {
+ changeSupport.firePropertyChange(UPDATE,
+ Math.round(100 * alignmentHeight / miniMe.getHeight() - 1),
+ Math.round(100 * alignmentHeight / miniMe.getHeight()));
+ }
return miniMe;
}
{
if (redraw)
{
+ changeSupport.firePropertyChange(UPDATE, 99, 0);
break;
}
+
if (alignmentCol >= annotations.length)
{
break; // no more annotations to draw here
colIndex++;
}
}
+ changeSupport.firePropertyChange(UPDATE, 99, 100);
}
public void setRedraw(boolean b)
redraw = b;
}
}
+
+ public void addPropertyChangeListener(RendererListenerI listener)
+ {
+ changeSupport.addPropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(RendererListenerI listener)
+ {
+ changeSupport.removePropertyChangeListener(listener);
+ }
}