From: kiramt Date: Wed, 30 Aug 2017 09:59:38 +0000 (+0100) Subject: JAL-2527 Wired up cached values to overview X-Git-Tag: Release_2_10_3b1~142^2~2^2~8 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=fc8a59878075498420187716fde697dfc81ff490;p=jalview.git JAL-2527 Wired up cached values to overview --- diff --git a/src/jalview/appletgui/OverviewCanvas.java b/src/jalview/appletgui/OverviewCanvas.java index 718c15b..9597b44 100644 --- a/src/jalview/appletgui/OverviewCanvas.java +++ b/src/jalview/appletgui/OverviewCanvas.java @@ -21,6 +21,7 @@ package jalview.appletgui; import jalview.renderer.OverviewRenderer; +import jalview.renderer.OverviewResColourFinder; import jalview.viewmodel.OverviewDimensions; import java.awt.Color; @@ -112,7 +113,7 @@ public class OverviewCanvas extends Component setPreferredSize(new Dimension(od.getWidth(), od.getHeight())); or = new OverviewRenderer(fr, od, av.getAlignment(), - av.getResidueShading()); + av.getResidueShading(), new OverviewResColourFinder()); miniMe = nullFrame.createImage(od.getWidth(), od.getHeight()); offscreen = nullFrame.createImage(od.getWidth(), od.getHeight()); diff --git a/src/jalview/gui/OverviewCanvas.java b/src/jalview/gui/OverviewCanvas.java index 987d6c1..3ea5e9b 100644 --- a/src/jalview/gui/OverviewCanvas.java +++ b/src/jalview/gui/OverviewCanvas.java @@ -21,7 +21,9 @@ 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.Color; @@ -65,7 +67,6 @@ public class OverviewCanvas extends JComponent sr = new SequenceRenderer(av); sr.renderGaps = false; - // sr.forOverview = true; fr = new jalview.renderer.seqfeatures.FeatureRenderer(av); } @@ -126,8 +127,13 @@ public class OverviewCanvas extends JComponent setPreferredSize(new Dimension(od.getWidth(), od.getHeight())); + boolean useLegacy = Cache.getDefault("USE_LEGACY_GAP", false); + Color gapCol = Cache.getDefaultColour("GAP_COLOUR", new Color(240, 240, 240)); + Color hiddenCol = Cache.getDefaultColour("HIDDEN_COLOUR", Color.DARK_GRAY.darker()); + OverviewResColourFinder cf = new OverviewResColourFinder(useLegacy, + gapCol, hiddenCol); or = new OverviewRenderer(fr, od, av.getAlignment(), - av.getResidueShading()); + av.getResidueShading(), cf); miniMe = or.draw(od.getRows(av.getAlignment()), od.getColumns(av.getAlignment())); diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index 28de801..d66bbf0 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -20,6 +20,7 @@ */ package jalview.gui; +import jalview.bin.Cache; import jalview.util.MessageManager; import jalview.util.Platform; import jalview.viewmodel.OverviewDimensions; @@ -79,9 +80,19 @@ public class OverviewPanel extends JPanel this.av = alPanel.av; this.ap = alPanel; - od = new OverviewDimensionsShowHidden(av.getRanges(), + showHidden = Cache.getDefault("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()); @@ -158,7 +169,6 @@ public class OverviewPanel extends JPanel } } else - // if (!av.getWrapAlignment()) { if (!od.isPositionInBox(evt.getX(), evt.getY())) { diff --git a/src/jalview/renderer/OverviewRenderer.java b/src/jalview/renderer/OverviewRenderer.java index 56dba82..992a1b2 100644 --- a/src/jalview/renderer/OverviewRenderer.java +++ b/src/jalview/renderer/OverviewRenderer.java @@ -42,6 +42,8 @@ public class OverviewRenderer // transparency of hidden cols/seqs overlay private final float TRANSPARENCY = 0.5f; + private final Color HIDDEN_COLOUR = Color.DARK_GRAY.darker(); + private FeatureColourFinder finder; // image to render on @@ -61,14 +63,14 @@ public class OverviewRenderer private ResidueShaderI shader; - private ResidueColourFinder resColFinder; + private OverviewResColourFinder resColFinder; public OverviewRenderer(FeatureRenderer fr, OverviewDimensions od, AlignmentI alignment, - ResidueShaderI resshader) + ResidueShaderI resshader, OverviewResColourFinder colFinder) { finder = new FeatureColourFinder(fr); - resColFinder = new OverviewResColourFinder(); + resColFinder = colFinder; al = alignment; shader = resshader; @@ -228,7 +230,7 @@ public class OverviewRenderer int colIndex = 0; int pixelCol = 0; - Color hidden = Color.DARK_GRAY.darker(); + Color hidden = resColFinder.getHiddenColour(); Graphics2D g2d = (Graphics2D) hiddenImage.getGraphics(); diff --git a/src/jalview/renderer/OverviewResColourFinder.java b/src/jalview/renderer/OverviewResColourFinder.java index c591f54..b28aa27 100644 --- a/src/jalview/renderer/OverviewResColourFinder.java +++ b/src/jalview/renderer/OverviewResColourFinder.java @@ -28,12 +28,42 @@ import java.awt.Color; public class OverviewResColourFinder extends ResidueColourFinder { - final Color GAP_COLOUR = new Color(240, 240, 240); + final Color GAP_COLOUR; + + final Color RESIDUE_COLOUR; + + final Color HIDDEN_COLOUR; + + boolean useLegacy = false; + + public OverviewResColourFinder() + { + GAP_COLOUR = new Color(240, 240, 240); + RESIDUE_COLOUR = Color.white; + HIDDEN_COLOUR = Color.DARK_GRAY.darker(); + } + + public OverviewResColourFinder(boolean useLegacyColouring, Color gapCol, + Color hiddenCol) + { + if (useLegacyColouring) + { + GAP_COLOUR = Color.white; + RESIDUE_COLOUR = new Color(240, 240, 240); + HIDDEN_COLOUR = hiddenCol; + } + else + { + GAP_COLOUR = gapCol; + RESIDUE_COLOUR = Color.white; + HIDDEN_COLOUR = hiddenCol; + } + } @Override public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i) { - Color resBoxColour = Color.white; + Color resBoxColour = RESIDUE_COLOUR; char currentChar = seq.getCharAt(i); // In the overview window, gaps are coloured grey, unless the colour scheme @@ -82,4 +112,9 @@ public class OverviewResColourFinder extends ResidueColourFinder return getBoxColour(currentShader, seq, i); } + + protected Color getHiddenColour() + { + return HIDDEN_COLOUR; + } }