X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FOverviewCanvas.java;h=0827208e664fb4d010d5007b54f7f3b782155d7a;hb=5640ec0623c6d1205e62f9fe15292f32bfdab7d9;hp=586ac2c883f19a3b40d733ee1a6bdc5878121a49;hpb=7e04981d43b16398bd5bd2fad98a5216035d90bb;p=jalview.git diff --git a/src/jalview/gui/OverviewCanvas.java b/src/jalview/gui/OverviewCanvas.java index 586ac2c..0827208 100644 --- a/src/jalview/gui/OverviewCanvas.java +++ b/src/jalview/gui/OverviewCanvas.java @@ -24,11 +24,13 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.image.BufferedImage; +import java.awt.image.RasterFormatException; import javax.swing.JPanel; import jalview.api.AlignViewportI; import jalview.bin.Cache; +import jalview.bin.Console; import jalview.renderer.OverviewRenderer; import jalview.renderer.OverviewResColourFinder; import jalview.viewmodel.OverviewDimensions; @@ -93,8 +95,9 @@ public class OverviewCanvas extends JPanel OVERVIEW_DEFAULT_GAP); Color hiddenCol = Cache.getDefaultColour(Preferences.HIDDEN_COLOUR, OVERVIEW_DEFAULT_HIDDEN); - Color residueCol = useLegacy ? OVERVIEW_DEFAULT_LEGACY_RESIDUE : OVERVIEW_DEFAULT_RESIDUE; - + Color residueCol = useLegacy ? OVERVIEW_DEFAULT_LEGACY_RESIDUE + : OVERVIEW_DEFAULT_RESIDUE; + cf = new OverviewResColourFinder(gapCol, residueCol, hiddenCol); setSize(od.getWidth(), od.getHeight()); @@ -223,27 +226,36 @@ public class OverviewCanvas extends JPanel if (od.getGraphHeight() > 0 && od.getSequencesHeight() > 0 // BH 2019 ) { - BufferedImage topImage = lastMiniMe.getSubimage(0, 0, - od.getWidth(), od.getSequencesHeight()); - BufferedImage bottomImage = lastMiniMe.getSubimage(0, - od.getSequencesHeight(), od.getWidth(), - od.getGraphHeight()); - - // must be done at this point as we rely on using old width/height - // above, and new width/height below - od.setWidth(getWidth()); - od.setHeight(getHeight()); - - // stick the images back together so lastMiniMe is consistent in the - // event of a repaint - BUT probably not thread safe - lastMiniMe = new BufferedImage(od.getWidth(), od.getHeight(), - BufferedImage.TYPE_INT_RGB); - Graphics lg = lastMiniMe.getGraphics(); - lg.drawImage(topImage, 0, 0, od.getWidth(), - od.getSequencesHeight(), null); - lg.drawImage(bottomImage, 0, od.getSequencesHeight(), - od.getWidth(), od.getGraphHeight(), this); - lg.dispose(); + try + { + BufferedImage topImage = lastMiniMe.getSubimage(0, 0, + od.getWidth(), od.getSequencesHeight()); + BufferedImage bottomImage = lastMiniMe.getSubimage(0, + od.getSequencesHeight(), od.getWidth(), + od.getGraphHeight()); + + // must be done at this point as we rely on using old width/height + // above, and new width/height below + od.setWidth(getWidth()); + od.setHeight(getHeight()); + + // stick the images back together so lastMiniMe is consistent in the + // event of a repaint - BUT probably not thread safe + lastMiniMe = new BufferedImage(od.getWidth(), od.getHeight(), + BufferedImage.TYPE_INT_RGB); + Graphics lg = lastMiniMe.getGraphics(); + lg.drawImage(topImage, 0, 0, od.getWidth(), + od.getSequencesHeight(), null); + lg.drawImage(bottomImage, 0, od.getSequencesHeight(), + od.getWidth(), od.getGraphHeight(), this); + lg.dispose(); + } catch (RasterFormatException e) + { + Console.debug( + "Scaling miscalculation resizing Overview window"); + od.setWidth(getWidth()); + od.setHeight(getHeight()); + } } else {