From: Jim Procter Date: Sun, 3 Sep 2017 17:27:09 +0000 (+0100) Subject: Merge branch 'feature/JAL-2587' into documentation/JAL-2675_release2102b1 X-Git-Tag: Release_2_10_2b1~11^2~9^2~1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6d06be2714c9cba8c69148d5e2d26b50b7051840;p=jalview.git Merge branch 'feature/JAL-2587' into documentation/JAL-2675_release2102b1 --- 6d06be2714c9cba8c69148d5e2d26b50b7051840 diff --cc resources/lang/Messages.properties index 28fbfd5,d2e4933..9f3ab70 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@@ -1311,12 -1311,4 +1311,13 @@@ label.occupancy_descr = Number of align 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... +label.overview_settings = Overview settings +label.ov_legacy_gap = Use legacy gap colouring (gaps are white) +label.gap_colour = Gap colour: +label.ov_show_hide_default = Show hidden regions when opening overview +label.hidden_colour = Hidden colour: +label.select_gap_colour = Select gap colour +label.select_hidden_colour = Select hidden colour +label.overview = Overview - label.reset_to_defaults = Reset to defaults ++label.reset_to_defaults = Reset to defaults ++label.oview_calc = Recalculating overview... diff --cc resources/lang/Messages_es.properties index b5b5704,da03433..1e3a391 --- a/resources/lang/Messages_es.properties +++ b/resources/lang/Messages_es.properties @@@ -1311,12 -1311,4 +1311,13 @@@ label.togglehidden = Mostrar regiones o 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 +label.overview_settings = Ajustes para la ventana resumen +label.ov_legacy_gap = Utilizar el color heredado de huecos
(los huecos son blancos) +label.gap_colour = Color de huecos: +label.ov_show_hide_default = Mostrar regiones ocultas al abrir el resumen +label.hidden_colour = Color de las regiones ocultas: +label.select_gap_colour = Seleccionar color de huecos +label.select_hidden_colour = Seleccionar color de las regiones ocultas +label.overview = Resumen - label.reset_to_defaults = Restablecen a los predeterminados ++label.reset_to_defaults = Restablecen a los predeterminados ++label.oview_calc = Recalculando resumen diff --cc src/jalview/gui/OverviewCanvas.java index ed1497a,57070f2..04e34cd --- a/src/jalview/gui/OverviewCanvas.java +++ b/src/jalview/gui/OverviewCanvas.java @@@ -21,14 -21,15 +21,18 @@@ package jalview.gui; import jalview.api.AlignViewportI; +import jalview.bin.Cache; import jalview.renderer.OverviewRenderer; +import jalview.renderer.OverviewResColourFinder; import jalview.viewmodel.OverviewDimensions; + import java.awt.AlphaComposite; import java.awt.Color; +import java.awt.Dimension; 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; @@@ -59,10 -69,16 +72,19 @@@ public class OverviewCanvas extends JCo private AlignViewportI av; ++ + private OverviewResColourFinder cf; + + 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; @@@ -69,14 -86,40 +92,47 @@@ sr = new SequenceRenderer(av); sr.renderGaps = false; - sr.forOverview = true; fr = new jalview.renderer.seqfeatures.FeatureRenderer(av); + boolean useLegacy = Cache.getDefault(Preferences.USE_LEGACY_GAP, false); + Color gapCol = Cache.getDefaultColour(Preferences.GAP_COLOUR, + Preferences.OVERVIEW_DEFAULT_GAP); + Color hiddenCol = Cache.getDefaultColour(Preferences.HIDDEN_COLOUR, + Preferences.OVERVIEW_DEFAULT_HIDDEN); + cf = new OverviewResColourFinder(useLegacy, gapCol, hiddenCol); ++ + 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(); + } + } + }); ++ } /** @@@ -134,10 -178,8 +191,13 @@@ fr.transferSettings(transferRenderer); } - or = new OverviewRenderer(sr, fr, od); + setPreferredSize(new Dimension(od.getWidth(), od.getHeight())); + + or = new OverviewRenderer(fr, od, av.getAlignment(), + av.getResidueShading(), cf); ++ + or.addPropertyChangeListener(progressPanel); ++ miniMe = or.draw(od.getRows(av.getAlignment()), od.getColumns(av.getAlignment())); diff --cc src/jalview/gui/OverviewPanel.java index 3c94f26,593f7ae..5f4f157 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@@ -20,7 -20,7 +20,8 @@@ */ package jalview.gui; +import jalview.bin.Cache; + import jalview.renderer.OverviewRenderer; import jalview.util.MessageManager; import jalview.util.Platform; import jalview.viewmodel.OverviewDimensions; @@@ -80,25 -82,16 +83,27 @@@ public class OverviewPanel extends JPan this.av = alPanel.av; this.ap = alPanel; - od = new OverviewDimensionsShowHidden(av.getRanges(), - (av.isShowAnnotation() && av - .getAlignmentConservationAnnotation() != null)); + showHidden = Cache.getDefault(Preferences.SHOW_OV_HIDDEN_AT_START, + true); + if (showHidden) + { + od = new OverviewDimensionsShowHidden(av.getRanges(), + (av.isShowAnnotation() + && av.getAlignmentConservationAnnotation() != null)); + } + else + { + od = new OverviewDimensionsHideHidden(av.getRanges(), + (av.isShowAnnotation() + && av.getAlignmentConservationAnnotation() != null)); + } - setSize(od.getWidth(), od.getHeight()); - - oviewCanvas = new OverviewCanvas(od, av); setLayout(new BorderLayout()); + progressPanel = new ProgressPanel(OverviewRenderer.UPDATE, + MessageManager.getString("label.oview_calc"), getWidth()); + this.add(progressPanel, BorderLayout.SOUTH); + oviewCanvas = new OverviewCanvas(od, av, progressPanel); + add(oviewCanvas, BorderLayout.CENTER); av.getRanges().addPropertyChangeListener(this); diff --cc src/jalview/gui/PopupMenu.java index 3e2eba9,2c4eb7a..2ef71cc --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@@ -455,8 -452,7 +455,8 @@@ public class PopupMenu extends JPopupMe buildGroupURLMenu(sg, groupLinks); } // Add a 'show all structures' for the current selection - Hashtable pdbe = new Hashtable(), - reppdb = new Hashtable(); + Hashtable pdbe = new Hashtable<>(), reppdb = new Hashtable<>(); ++ SequenceI sqass = null; for (SequenceI sq : ap.av.getSequenceSelection()) { @@@ -1377,11 -1369,11 +1377,11 @@@ * Temporary store to hold distinct calcId / type pairs for the tooltip. * Using TreeMap means calcIds are shown in alphabetical order. */ - SortedMap tipEntries = new TreeMap(); - final Map> candidates = new LinkedHashMap>(); + SortedMap tipEntries = new TreeMap<>(); + final Map> candidates = new LinkedHashMap<>(); AlignmentI al = this.ap.av.getAlignment(); - AlignmentUtils.findAddableReferenceAnnotations(forSequences, - tipEntries, candidates, al); + AlignmentUtils.findAddableReferenceAnnotations(forSequences, tipEntries, + candidates, al); if (!candidates.isEmpty()) { StringBuilder tooltip = new StringBuilder(64); diff --cc src/jalview/renderer/OverviewRenderer.java index 992a1b2,416defb..73f66f0 --- a/src/jalview/renderer/OverviewRenderer.java +++ b/src/jalview/renderer/OverviewRenderer.java @@@ -22,30 -22,32 +22,39 @@@ package jalview.renderer import jalview.api.AlignmentColsCollectionI; import jalview.api.AlignmentRowsCollectionI; + import jalview.api.RendererListenerI; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; +import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.renderer.seqfeatures.FeatureColourFinder; import jalview.renderer.seqfeatures.FeatureRenderer; import jalview.viewmodel.OverviewDimensions; +import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.image.BufferedImage; + import java.beans.PropertyChangeSupport; public class OverviewRenderer { + // transparency of hidden cols/seqs overlay + private final float TRANSPARENCY = 0.5f; + + private final Color HIDDEN_COLOUR = Color.DARK_GRAY.darker(); + + public static final String UPDATE = "OverviewUpdate"; + + private static final int MAX_PROGRESS = 100; + + private PropertyChangeSupport changeSupport = new PropertyChangeSupport( + this); + private FeatureColourFinder finder; - private jalview.api.SequenceRenderer sr; - // image to render on private BufferedImage miniMe; @@@ -143,7 -144,9 +161,10 @@@ miniMe.setRGB(col, row, rgbcolor); } } - + + sendProgressUpdate((pixelCol + 1) * (endRow - pixelRow), + totalPixels, lastRowUpdate); ++ pixelCol = endCol + 1; } colIndex++; @@@ -152,24 -160,38 +178,48 @@@ seqIndex++; } + overlayHiddenRegions(rows, cols); + // final update to progress bar if present + if (redraw) + { + sendProgressUpdate(pixelRow - 1, alignmentHeight, 0); + } + else + { + sendProgressUpdate(alignmentHeight, miniMe.getHeight(), 0); + } return miniMe; } - /** + /* + * Calculate progress update value and fire event + */ + private int sendProgressUpdate(int position, int maximum, int offset) + { + int newUpdate = offset + + Math.round(MAX_PROGRESS * ((float) position / maximum)); + if (newUpdate > offset) + { + changeSupport.firePropertyChange(UPDATE, offset, newUpdate); + return newUpdate; + } + return offset; + } + + /* * Find the colour of a sequence at a specified column position + * + * @param seq + * sequence to get colour for + * @param lastcol + * column position to get colour for + * @param fcfinder + * FeatureColourFinder to use + * @return colour of sequence at this position, as RGB */ - private int getColumnColourFromSequence(jalview.datamodel.SequenceI seq, - boolean isHidden, int lastcol, FeatureColourFinder fcfinder) + private int getColumnColourFromSequence(SequenceGroup[] allGroups, + jalview.datamodel.SequenceI seq, + int lastcol, FeatureColourFinder fcfinder) { Color color = Color.white; @@@ -356,15 -274,10 +409,17 @@@ colIndex++; } } + changeSupport.firePropertyChange(UPDATE, MAX_PROGRESS - 1, + MAX_PROGRESS); } + /** + * Allows redraw flag to be set + * + * @param b + * value to set redraw to: true = redraw is occurring, false = no + * redraw + */ public void setRedraw(boolean b) { synchronized (this)