From: Jim Procter Date: Thu, 22 Feb 2018 14:34:23 +0000 (+0000) Subject: JAL-984 remove all references to idwidth.gif and use int constants in place of width... X-Git-Tag: Release_2_10_4~56^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3ab70c7242fba39a5106deb39882648bacfc2ba6;p=jalview.git JAL-984 remove all references to idwidth.gif and use int constants in place of width/height of image when switching between margin adjustment active/inactive mouse cursor --- diff --git a/resources/images/idwidth.gif b/resources/images/idwidth.gif deleted file mode 100755 index c1bd8cb..0000000 Binary files a/resources/images/idwidth.gif and /dev/null differ diff --git a/src/jalview/appletgui/AnnotationLabels.java b/src/jalview/appletgui/AnnotationLabels.java index cbd2434..d8e7007 100755 --- a/src/jalview/appletgui/AnnotationLabels.java +++ b/src/jalview/appletgui/AnnotationLabels.java @@ -58,6 +58,16 @@ public class AnnotationLabels extends Panel { Image image; + /** + * width in pixels within which height adjuster arrows are shown and active + */ + private static final int HEIGHT_ADJUSTER_WIDTH = 50; + + /** + * height in pixels for allowing height adjuster to be active + */ + private static int HEIGHT_ADJUSTER_HEIGHT = 10; + boolean active = false; AlignmentPanel ap; @@ -93,23 +103,6 @@ public class AnnotationLabels extends Panel this.ap = ap; this.av = ap.av; setLayout(null); - - /** - * this retrieves the adjustable height glyph from resources. we don't use - * it at the moment. java.net.URL url = - * getClass().getResource("/images/idwidth.gif"); Image temp = null; - * - * if (url != null) { temp = - * java.awt.Toolkit.getDefaultToolkit().createImage(url); } - * - * try { MediaTracker mt = new MediaTracker(this); mt.addImage(temp, 0); - * mt.waitForID(0); } catch (Exception ex) { } - * - * BufferedImage bi = new BufferedImage(temp.getHeight(this), - * temp.getWidth(this), BufferedImage.TYPE_INT_RGB); Graphics2D g = - * (Graphics2D) bi.getGraphics(); g.rotate(Math.toRadians(90)); - * g.drawImage(temp, 0, -bi.getWidth(this), this); image = (Image) bi; - */ addMouseListener(this); addMouseMotionListener(this); } @@ -269,7 +262,8 @@ public class AnnotationLabels extends Panel @Override public void mouseMoved(MouseEvent evt) { - resizePanel = evt.getY() < 10 && evt.getX() < 14; + resizePanel = evt.getY() < HEIGHT_ADJUSTER_HEIGHT + && evt.getX() < HEIGHT_ADJUSTER_WIDTH; setCursor(Cursor.getPredefinedCursor( resizePanel ? Cursor.S_RESIZE_CURSOR : Cursor.DEFAULT_CURSOR)); int row = getSelectedRow(evt.getY() + scrollOffset); diff --git a/src/jalview/appletgui/IdwidthAdjuster.java b/src/jalview/appletgui/IdwidthAdjuster.java index 3de1ef6..51faa87 100755 --- a/src/jalview/appletgui/IdwidthAdjuster.java +++ b/src/jalview/appletgui/IdwidthAdjuster.java @@ -22,7 +22,6 @@ package jalview.appletgui; import java.awt.Cursor; import java.awt.Dimension; -import java.awt.Image; import java.awt.Panel; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; @@ -35,19 +34,12 @@ public class IdwidthAdjuster extends Panel int oldX = 0; - Image image; - AlignmentPanel ap; public IdwidthAdjuster(AlignmentPanel ap) { setLayout(null); this.ap = ap; - java.net.URL url = getClass().getResource("/images/idwidth.gif"); - if (url != null) - { - image = java.awt.Toolkit.getDefaultToolkit().getImage(url); - } addMouseListener(this); addMouseMotionListener(this); diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index d903979..15f1fe0 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -41,8 +41,6 @@ import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.MediaTracker; import java.awt.RenderingHints; import java.awt.Toolkit; import java.awt.datatransfer.StringSelection; @@ -52,7 +50,6 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.awt.geom.AffineTransform; -import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -73,9 +70,16 @@ import javax.swing.ToolTipManager; public class AnnotationLabels extends JPanel implements MouseListener, MouseMotionListener, ActionListener { - // width in pixels within which height adjuster arrows are shown and active + /** + * width in pixels within which height adjuster arrows are shown and active + */ private static final int HEIGHT_ADJUSTER_WIDTH = 50; + /** + * height in pixels for allowing height adjuster to be active + */ + private static int HEIGHT_ADJUSTER_HEIGHT = 10; + private static final Pattern LEFT_ANGLE_BRACKET_PATTERN = Pattern .compile("<"); @@ -105,10 +109,6 @@ public class AnnotationLabels extends JPanel private static final String COPYCONS_SEQ = MessageManager .getString("label.copy_consensus_sequence"); - private static Image adjusterImage; - - private static int adjusterImageHeight; - private final boolean debugRedraw = false; private AlignmentPanel ap; @@ -138,11 +138,6 @@ public class AnnotationLabels extends JPanel av = ap.av; ToolTipManager.sharedInstance().registerComponent(this); - if (adjusterImage == null) - { - loadAdjusterImage(); - } - addMouseListener(this); addMouseMotionListener(this); addMouseWheelListener(ap.getAnnotationPanel()); @@ -154,37 +149,6 @@ public class AnnotationLabels extends JPanel } /** - * Loads the gif for the panel height adjustment - */ - protected void loadAdjusterImage() - { - java.net.URL url = getClass().getResource("/images/idwidth.gif"); - Image temp = null; - - if (url != null) - { - temp = Toolkit.getDefaultToolkit().createImage(url); - } - - try - { - MediaTracker mt = new MediaTracker(this); - mt.addImage(temp, 0); - mt.waitForID(0); - } catch (Exception ex) - { - } - - BufferedImage bi = new BufferedImage(temp.getHeight(this), - temp.getWidth(this), BufferedImage.TYPE_INT_RGB); - Graphics2D g = (Graphics2D) bi.getGraphics(); - g.rotate(Math.toRadians(90)); - g.drawImage(temp, 0, -bi.getWidth(this), this); - adjusterImage = bi; - adjusterImageHeight = bi.getHeight(); - } - - /** * DOCUMENT ME! * * @param y @@ -818,7 +782,7 @@ public class AnnotationLabels extends JPanel protected void showOrHideAdjuster(MouseEvent evt) { boolean was = resizePanel; - resizePanel = evt.getY() < adjusterImageHeight && evt.getX() < HEIGHT_ADJUSTER_WIDTH; + resizePanel = evt.getY() < HEIGHT_ADJUSTER_HEIGHT && evt.getX() < HEIGHT_ADJUSTER_WIDTH; if (resizePanel != was) { diff --git a/src/jalview/gui/IdwidthAdjuster.java b/src/jalview/gui/IdwidthAdjuster.java index 99792c6..c6d5d2a 100755 --- a/src/jalview/gui/IdwidthAdjuster.java +++ b/src/jalview/gui/IdwidthAdjuster.java @@ -22,10 +22,8 @@ package jalview.gui; import jalview.api.AlignViewportI; -import java.awt.Color; import java.awt.Cursor; import java.awt.Graphics; -import java.awt.Image; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; @@ -45,8 +43,6 @@ public class IdwidthAdjuster extends JPanel int oldX = 0; - Image image; - AlignmentPanel ap; /** @@ -59,13 +55,6 @@ public class IdwidthAdjuster extends JPanel { this.ap = ap; - java.net.URL url = getClass().getResource("/images/idwidth.gif"); - - if (url != null) - { - image = java.awt.Toolkit.getDefaultToolkit().createImage(url); - } - addMouseListener(this); addMouseMotionListener(this); } @@ -192,20 +181,9 @@ public class IdwidthAdjuster extends JPanel @Override public void paintComponent(Graphics g) { - g.setColor(Color.white); - g.fillRect(0, 0, getWidth(), getHeight()); - if (active) { - if (image != null) - { - // g.drawImage(image, getWidth() - 20, 2, this); setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR)); - } - else - { - setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } } } }