X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FFeatureSettings.java;h=d65016edd53875582e7e46dbd3346e18b6cc3d10;hb=483e7163b1fb8d4bcb9393014816c944befce328;hp=cf7bdb3cc8949e907f380bd3bc05aa894f191ec8;hpb=0b1c761dfaa8242f122cf868e8897a06ec6eb727;p=jalview.git diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index cf7bdb3..d65016e 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -58,6 +58,7 @@ import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.util.Arrays; import java.util.Hashtable; import java.util.Iterator; import java.util.List; @@ -173,7 +174,7 @@ public class FeatureSettings extends JPanel implements public void mousePressed(MouseEvent evt) { selectedRow = table.rowAtPoint(evt.getPoint()); - if (SwingUtilities.isRightMouseButton(evt)) + if (evt.isPopupTrigger()) { popupSort(selectedRow, (String) table.getValueAt(selectedRow, 0), table.getValueAt(selectedRow, 1), fr.getMinMax(), @@ -181,14 +182,16 @@ public class FeatureSettings extends JPanel implements } else if (evt.getClickCount() == 2) { + boolean invertSelection = evt.isAltDown(); + boolean toggleSelection = Platform.isControlDown(evt); + boolean extendSelection = evt.isShiftDown(); fr.ap.alignFrame.avc.markColumnsContainingFeatures( - evt.isAltDown(), evt.isShiftDown() || evt.isMetaDown(), - evt.isMetaDown(), + invertSelection, extendSelection, toggleSelection, (String) table.getValueAt(selectedRow, 0)); } } - // isPopupTrigger fires on mouseReleased on Mac + // isPopupTrigger fires on mouseReleased on Windows @Override public void mouseReleased(MouseEvent evt) { @@ -210,19 +213,22 @@ public class FeatureSettings extends JPanel implements int newRow = table.rowAtPoint(evt.getPoint()); if (newRow != selectedRow && selectedRow != -1 && newRow != -1) { - Object[] temp = new Object[3]; - temp[0] = table.getValueAt(selectedRow, 0); - temp[1] = table.getValueAt(selectedRow, 1); - temp[2] = table.getValueAt(selectedRow, 2); - - table.setValueAt(table.getValueAt(newRow, 0), selectedRow, 0); - table.setValueAt(table.getValueAt(newRow, 1), selectedRow, 1); - table.setValueAt(table.getValueAt(newRow, 2), selectedRow, 2); - - table.setValueAt(temp[0], newRow, 0); - table.setValueAt(temp[1], newRow, 1); - table.setValueAt(temp[2], newRow, 2); - + /* + * reposition 'selectedRow' to 'newRow' (the dragged to location) + * this could be more than one row away for a very fast drag action + * so just swap it with adjacent rows until we get it there + */ + Object[][] data = ((FeatureTableModel) table.getModel()) + .getData(); + int direction = newRow < selectedRow ? -1 : 1; + for (int i = selectedRow; i != newRow; i += direction) + { + Object[] temp = data[i]; + data[i] = data[i + direction]; + data[i + direction] = temp; + } + updateFeatureRenderer(data); + table.repaint(); selectedRow = newRow; } } @@ -286,7 +292,7 @@ public class FeatureSettings extends JPanel implements frame.setLayer(JLayeredPane.PALETTE_LAYER); } - protected void popupSort(final int row, final String type, + protected void popupSort(final int selectedRow, final String type, final Object typeCol, final Map minmax, int x, int y) { @@ -304,7 +310,8 @@ public class FeatureSettings extends JPanel implements @Override public void actionPerformed(ActionEvent e) { - me.af.avc.sortAlignmentByFeatureScore(new String[] { type }); + me.af.avc.sortAlignmentByFeatureScore(Arrays + .asList(new String[] { type })); } }); @@ -316,7 +323,8 @@ public class FeatureSettings extends JPanel implements @Override public void actionPerformed(ActionEvent e) { - me.af.avc.sortAlignmentByFeatureDensity(new String[] { type }); + me.af.avc.sortAlignmentByFeatureDensity(Arrays + .asList(new String[] { type })); } }); @@ -380,13 +388,15 @@ public class FeatureSettings extends JPanel implements { FeatureColourChooser fc = (FeatureColourChooser) e .getSource(); - table.setValueAt(fc.getLastColour(), row, 1); + table.setValueAt(fc.getLastColour(), selectedRow, 1); table.validate(); } else { // probably the color chooser! - table.setValueAt(colorChooser.getColor(), row, 1); + table.setValueAt( + new FeatureColour(colorChooser.getColor()), + selectedRow, 1); table.validate(); me.updateFeatureRenderer( ((FeatureTableModel) table.getModel()).getData(), @@ -402,7 +412,6 @@ public class FeatureSettings extends JPanel implements MessageManager.getString("label.select_columns_containing")); selCols.addActionListener(new ActionListener() { - @Override public void actionPerformed(ActionEvent arg0) { @@ -414,7 +423,6 @@ public class FeatureSettings extends JPanel implements MessageManager.getString("label.select_columns_not_containing")); clearCols.addActionListener(new ActionListener() { - @Override public void actionPerformed(ActionEvent arg0) { @@ -422,8 +430,30 @@ public class FeatureSettings extends JPanel implements false, type); } }); + JMenuItem hideCols = new JMenuItem( + MessageManager.getString("label.hide_columns_containing")); + hideCols.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent arg0) + { + fr.ap.alignFrame.hideFeatureColumns(type, true); + } + }); + JMenuItem hideOtherCols = new JMenuItem( + MessageManager.getString("label.hide_columns_not_containing")); + hideOtherCols.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent arg0) + { + fr.ap.alignFrame.hideFeatureColumns(type, false); + } + }); men.add(selCols); men.add(clearCols); + men.add(hideCols); + men.add(hideOtherCols); men.show(table, x, y); } @@ -719,10 +749,8 @@ public class FeatureSettings extends JPanel implements void load() { JalviewFileChooser chooser = new JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), - new String[] { "fc" }, - new String[] { "Sequence Feature Colours" }, - "Sequence Feature Colours"); + Cache.getProperty("LAST_DIRECTORY"), "fc", + "Sequence Feature Colours", "Sequence Feature Colours"); chooser.setFileView(new jalview.io.JalviewFileView()); chooser.setDialogTitle(MessageManager .getString("label.load_feature_colours")); @@ -814,10 +842,8 @@ public class FeatureSettings extends JPanel implements void save() { JalviewFileChooser chooser = new JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), - new String[] { "fc" }, - new String[] { "Sequence Feature Colours" }, - "Sequence Feature Colours"); + Cache.getProperty("LAST_DIRECTORY"), "fc", + "Sequence Feature Colours", "Sequence Feature Colours"); chooser.setFileView(new jalview.io.JalviewFileView()); chooser.setDialogTitle(MessageManager .getString("label.save_feature_colours")); @@ -970,10 +996,19 @@ public class FeatureSettings extends JPanel implements updateFeatureRenderer(data, true); } + /** + * Update the priority order of features; only repaint if this changed the + * order of visible features + * + * @param data + * @param visibleNew + */ private void updateFeatureRenderer(Object[][] data, boolean visibleNew) { - fr.setFeaturePriority(data, visibleNew); - af.alignPanel.paintAlignment(true); + if (fr.setFeaturePriority(data, visibleNew)) + { + af.alignPanel.paintAlignment(true); + } } int selectedRow = -1; @@ -1364,15 +1399,15 @@ public class FeatureSettings extends JPanel implements public void noDasSourceActive() { complete(); - JOptionPane + JvOptionPane .showInternalConfirmDialog( Desktop.desktop, MessageManager .getString("label.no_das_sources_selected_warn"), MessageManager .getString("label.no_das_sources_selected_title"), - JOptionPane.DEFAULT_OPTION, - JOptionPane.INFORMATION_MESSAGE); + JvOptionPane.DEFAULT_OPTION, + JvOptionPane.INFORMATION_MESSAGE); } // ///////////////////////////////////////////////////////////////////////