import jalview.datamodel.SequenceI;
import jalview.gui.Help.HelpId;
import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
import jalview.schemabinding.version2.JalviewUserColours;
import jalview.schemes.FeatureColour;
import jalview.util.Format;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
+import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridLayout;
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;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
JPanel transPanel = new JPanel(new GridLayout(1, 2));
+ private static final int MIN_WIDTH = 400;
+
+ private static final int MIN_HEIGHT = 400;
+
public FeatureSettings(AlignFrame af)
{
this.af = af;
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(),
}
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)
{
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;
}
}
MessageManager.getString("label.sequence_feature_settings"),
400, 450);
}
+ frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
{
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<String, float[][]> minmax, int x,
int y)
{
@Override
public void actionPerformed(ActionEvent e)
{
- me.af.avc.sortAlignmentByFeatureScore(new String[] { type });
+ me.af.avc.sortAlignmentByFeatureScore(Arrays
+ .asList(new String[] { type }));
}
});
@Override
public void actionPerformed(ActionEvent e)
{
- me.af.avc.sortAlignmentByFeatureDensity(new String[] { type });
+ me.af.avc.sortAlignmentByFeatureDensity(Arrays
+ .asList(new String[] { type }));
}
});
{
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(),
MessageManager.getString("label.select_columns_containing"));
selCols.addActionListener(new ActionListener()
{
-
@Override
public void actionPerformed(ActionEvent arg0)
{
MessageManager.getString("label.select_columns_not_containing"));
clearCols.addActionListener(new ActionListener()
{
-
@Override
public void actionPerformed(ActionEvent arg0)
{
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);
}
void load()
{
- JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
- new String[] { "fc" },
- new String[] { "Sequence Feature Colours" },
+ JalviewFileChooser chooser = new JalviewFileChooser("fc",
"Sequence Feature Colours");
- chooser.setFileView(new jalview.io.JalviewFileView());
+ chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
.getString("label.load_feature_colours"));
chooser.setToolTipText(MessageManager.getString("action.load"));
void save()
{
- JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
- new String[] { "fc" },
- new String[] { "Sequence Feature Colours" },
+ JalviewFileChooser chooser = new JalviewFileChooser("fc",
"Sequence Feature Colours");
- chooser.setFileView(new jalview.io.JalviewFileView());
+ chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
.getString("label.save_feature_colours"));
chooser.setToolTipText(MessageManager.getString("action.save"));
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;
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);
}
// ///////////////////////////////////////////////////////////////////////