X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FScalePanel.java;h=262d1e1a26d184b448e3861fde87a37e4af6f179;hb=3596077c79b7aa2051b9aaa978481004b513101c;hp=87e72dc4d34d97e0cc2225cd03bb95a7d20e27a2;hpb=31aef90c8108c0c781d77c7c32402a940b122aa2;p=jalview.git diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 87e72dc..262d1e1 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -43,6 +43,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener, MouseList boolean stretchingGroup = false; int min; //used by mouseDragged to see if user int max; //used by mouseDragged to see if user + boolean mouseDragging = false; // wants to delete columns public ScalePanel(AlignViewport av, AlignmentPanel ap) @@ -80,23 +81,27 @@ public class ScalePanel extends JPanel implements MouseMotionListener, MouseList { public void actionPerformed(ActionEvent e) { - av.getColumnSelection().revealHiddenColumns(reveal[0], av); + av.showColumn(reveal[0]); reveal = null; ap.repaint(); + if(ap.overviewPanel != null) + ap.overviewPanel.updateOverviewImage(); } }); pop.add(item); - if(av.getColumnSelection().hiddenColumns.size()>1) + if(av.getColumnSelection().getHiddenColumns().size()>1) { item = new JMenuItem("Reveal All"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - av.getColumnSelection().revealAllHiddenColumns(av); + av.showAllHiddenColumns(); reveal = null; ap.repaint(); + if(ap.overviewPanel != null) + ap.overviewPanel.updateOverviewImage(); } }); pop.add(item); @@ -105,7 +110,8 @@ public class ScalePanel extends JPanel implements MouseMotionListener, MouseList pop.show(this, evt.getX(), evt.getY()); } - else if (av.getColumnSelection().contains(res)) + else + if (av.getColumnSelection().contains(res)) { if( SwingUtilities.isRightMouseButton(evt)) { @@ -115,8 +121,10 @@ public class ScalePanel extends JPanel implements MouseMotionListener, MouseList { public void actionPerformed(ActionEvent e) { - av.getColumnSelection().hideColumns(res, av); + av.hideColumns(res, res); ap.repaint(); + if(ap.overviewPanel != null) + ap.overviewPanel.updateOverviewImage(); } }); pop.add(item); @@ -155,8 +163,15 @@ public class ScalePanel extends JPanel implements MouseMotionListener, MouseList */ public void mouseReleased(MouseEvent evt) { + mouseDragging = false; + int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); + if(res> av.alignment.getWidth()) + { + res = av.alignment.getWidth()-1; + } + if(av.hasHiddenColumns) res = av.getColumnSelection().adjustForHiddenColumns(res); @@ -189,11 +204,21 @@ public class ScalePanel extends JPanel implements MouseMotionListener, MouseList */ public void mouseDragged(MouseEvent evt) { + mouseDragging = true; + int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); + if(res<0) + res = 0; if(av.hasHiddenColumns) res = av.getColumnSelection().adjustForHiddenColumns(res); + + if(res> av.alignment.getWidth()) + { + res = av.alignment.getWidth()-1; + } + if (res < min) { min = res; @@ -204,6 +229,8 @@ public class ScalePanel extends JPanel implements MouseMotionListener, MouseList max = res; } + + SequenceGroup sg = av.getSelectionGroup(); if (sg != null) @@ -219,7 +246,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener, MouseList { sg.setEndRes(res); } - else if (res < sg.getStartRes()) + if (res < sg.getStartRes()) { sg.setStartRes(res); } @@ -240,8 +267,18 @@ public class ScalePanel extends JPanel implements MouseMotionListener, MouseList } } - public void mouseEntered(MouseEvent evt){} - public void mouseExited(MouseEvent evt){} + public void mouseEntered(MouseEvent evt) + { + if(mouseDragging) + ap.seqPanel.scrollCanvas(null); + } + + public void mouseExited(MouseEvent evt) + { + if(mouseDragging) + ap.seqPanel.scrollCanvas(evt); + } + public void mouseClicked(MouseEvent evt){} public void mouseMoved(MouseEvent evt) @@ -260,8 +297,13 @@ public class ScalePanel extends JPanel implements MouseMotionListener, MouseList if(res+1==region[0] || res-1==region[1]) { reveal = region; + ToolTipManager.sharedInstance().registerComponent(this); + this.setToolTipText("Reveal Hidden Columns with Right Mouse Button"); break; } + else + this.setToolTipText(null); + } repaint(); @@ -325,16 +367,27 @@ public class ScalePanel extends JPanel implements MouseMotionListener, MouseList scalestartx += 5; } + String string; + int maxX=0; + for (int i = scalestartx; i < endx; i += 5) { if ((i % 10) == 0) { - gg.drawString(String.valueOf(av.getColumnSelection().adjustForHiddenColumns(i)), - (i - startx - 1) * av.charWidth, y); - gg.drawLine((int) (((i - startx - 1) * av.charWidth) + - (av.charWidth / 2)), y + 2, - (int) (((i - startx - 1) * av.charWidth) + - (av.charWidth / 2)), y + (fm.getDescent() * 2)); + string = String.valueOf(av.getColumnSelection().adjustForHiddenColumns(i)); + if ( (i - startx - 1) * av.charWidth > maxX) + { + gg.drawString(string, + (i - startx - 1) * av.charWidth, y); + maxX = (i - startx + 1) * av.charWidth + fm.stringWidth(string); + } + + gg.drawLine( (int) ( ( (i - startx - 1) * av.charWidth) + + (av.charWidth / 2)), y + 2, + (int) ( ( (i - startx - 1) * av.charWidth) + + (av.charWidth / 2)), + y + (fm.getDescent() * 2)); + } else { @@ -349,19 +402,29 @@ public class ScalePanel extends JPanel implements MouseMotionListener, MouseList { gg.setColor(Color.blue); int res; - for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); i++) + if(av.getShowHiddenMarkers()) { - res = av.getColumnSelection().findHiddenRegionPosition( i )-startx; + for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); + i++) + { + + res = av.getColumnSelection().findHiddenRegionPosition(i) - + startx; - gg.fillPolygon(new int[] { res*av.charWidth - 4, - res*av.charWidth + 4, - res*av.charWidth }, - new int[] - { - y-av.charHeight/2 , y-av.charHeight/2 , - y + 8 - }, 3); + if(res < 0 || res > endx-scalestartx) + continue; + gg.fillPolygon(new int[] + {res * av.charWidth - av.charHeight / 4, + res * av.charWidth + av.charHeight / 4, + res * av.charWidth}, + new int[] + { + y - av.charHeight / 2, y - av.charHeight / 2, + y + 8 + }, 3); + + } } if (reveal != null && reveal[0] > startx && reveal[0] < endx)