From: kiramt Date: Tue, 25 Apr 2017 13:52:11 +0000 (+0100) Subject: JAL-2388 Reverted and re-did applet changes X-Git-Tag: Release_2_10_2~3^2~92^2~9 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a714684d20bb1b8423e0e63d6f3257c2bffa850b;p=jalview.git JAL-2388 Reverted and re-did applet changes --- diff --git a/src/jalview/appletgui/OverviewCanvas.java b/src/jalview/appletgui/OverviewCanvas.java index c763308..ffba5b9 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.seqfeatures.FeatureColourFinder; import jalview.viewmodel.OverviewDimensions; import java.awt.Color; @@ -28,9 +29,10 @@ import java.awt.Dimension; import java.awt.Frame; import java.awt.Graphics; import java.awt.Image; -import java.awt.Panel; -public class OverviewCanvas extends Panel +import javax.swing.JComponent; + +public class OverviewCanvas extends JComponent { // This is set true if the alignment view changes whilst // the overview is being calculated @@ -101,16 +103,6 @@ public class OverviewCanvas extends Panel } } - /** - * Draw the overview sequences - * - * @param showSequenceFeatures - * true if sequence features are to be shown - * @param showAnnotation - * true if the annotation is to be shown - * @param transferRenderer - * the renderer to transfer feature colouring from - */ public void draw(boolean showSequenceFeatures, boolean showAnnotation, FeatureRenderer transferRenderer) { @@ -120,10 +112,11 @@ public class OverviewCanvas extends Panel { fr.transferSettings(transferRenderer); } + FeatureColourFinder finder = new FeatureColourFinder(fr); setPreferredSize(new Dimension(od.getWidth(), od.getHeight())); - OverviewRenderer or = new OverviewRenderer(sr, fr, od); + OverviewRenderer or = new OverviewRenderer(sr, finder, od); miniMe = nullFrame.createImage(od.getWidth(), od.getHeight()); offscreen = nullFrame.createImage(od.getWidth(), od.getHeight()); @@ -132,8 +125,7 @@ public class OverviewCanvas extends Panel Graphics mg = miniMe.getGraphics(); - // checks for conservation annotation to make sure overview works for DNA - // too + // check for conservation annotation to make sure overview works for DNA too if (showAnnotation) { mg.translate(0, od.getSequencesHeight()); diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 5cac6f5..cf72daf 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -28,18 +28,19 @@ import jalview.viewmodel.OverviewDimensionsWithHidden; import java.awt.BorderLayout; import java.awt.Dimension; -import java.awt.MenuItem; import java.awt.Panel; -import java.awt.PopupMenu; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; -import java.awt.event.InputEvent; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; + public class OverviewPanel extends Panel implements Runnable, MouseMotionListener, MouseListener { @@ -104,8 +105,7 @@ public class OverviewPanel extends Panel implements Runnable, @Override public void mouseClicked(MouseEvent evt) { - // right button press - if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) + if (SwingUtilities.isRightMouseButton(evt)) { showPopupMenu(evt); } @@ -136,8 +136,7 @@ public class OverviewPanel extends Panel implements Runnable, private void mouseAction(MouseEvent evt) { - // right button press - if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) + if (SwingUtilities.isRightMouseButton(evt)) { if (!Platform.isAMac()) { @@ -209,7 +208,7 @@ public class OverviewPanel extends Panel implements Runnable, */ private void showPopupMenu(MouseEvent e) { - PopupMenu popup = new PopupMenu(); + JPopupMenu popup = new JPopupMenu(); ActionListener menuListener = new ActionListener() { @Override @@ -219,7 +218,7 @@ public class OverviewPanel extends Panel implements Runnable, toggleHiddenColumns(); } }; - MenuItem item = new MenuItem( + JMenuItem item = new JMenuItem( MessageManager.getString("label.togglehidden")); popup.add(item); item.addActionListener(menuListener); diff --git a/src/jalview/gui/OverviewCanvas.java b/src/jalview/gui/OverviewCanvas.java index 05db6c2..920547f 100644 --- a/src/jalview/gui/OverviewCanvas.java +++ b/src/jalview/gui/OverviewCanvas.java @@ -22,6 +22,7 @@ package jalview.gui; import jalview.api.AlignViewportI; import jalview.renderer.OverviewRenderer; +import jalview.renderer.seqfeatures.FeatureColourFinder; import jalview.viewmodel.OverviewDimensions; import java.awt.Color; @@ -117,10 +118,13 @@ public class OverviewCanvas extends JComponent { fr.transferSettings(transferRenderer); } + FeatureColourFinder finder = new FeatureColourFinder(fr); + // why do we need to set preferred size again? was set in + // updateOverviewImage setPreferredSize(new Dimension(od.getWidth(), od.getHeight())); - OverviewRenderer or = new OverviewRenderer(sr, fr, od); + OverviewRenderer or = new OverviewRenderer(sr, finder, od); miniMe = or.draw(od.getRows(av.getAlignment()), od.getColumns(av.getAlignment().getHiddenColumns())); diff --git a/src/jalview/renderer/OverviewRenderer.java b/src/jalview/renderer/OverviewRenderer.java index 60f80b1..75b8198 100644 --- a/src/jalview/renderer/OverviewRenderer.java +++ b/src/jalview/renderer/OverviewRenderer.java @@ -26,7 +26,6 @@ import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.Annotation; import jalview.datamodel.SequenceI; import jalview.renderer.seqfeatures.FeatureColourFinder; -import jalview.renderer.seqfeatures.FeatureRenderer; import jalview.viewmodel.OverviewDimensions; import java.awt.Color; @@ -49,10 +48,10 @@ public class OverviewRenderer private float pixelsPerSeq; public OverviewRenderer(jalview.api.SequenceRenderer seqRenderer, - FeatureRenderer ftRenderer, OverviewDimensions od) + FeatureColourFinder colfinder, OverviewDimensions od) { sr = seqRenderer; - finder = new FeatureColourFinder(ftRenderer); + finder = colfinder; pixelsPerCol = od.getPixelsPerCol(); pixelsPerSeq = od.getPixelsPerSeq();