X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FFeatureSettings.java;h=f81ecce0e7a85853f21a51aea64cc4d977fff019;hb=b1613533d44e86c95bb2ae1e1428330b314df1f6;hp=37a51efd698914a976e9c7bbfe0cf4a61bf78eb9;hpb=df00247d68253d60eb5e0bd30843661ed31cceb2;p=jalview.git
diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java
index 37a51ef..f81ecce 100644
--- a/src/jalview/gui/FeatureSettings.java
+++ b/src/jalview/gui/FeatureSettings.java
@@ -22,7 +22,6 @@ package jalview.gui;
import jalview.api.FeatureColourI;
import jalview.api.FeatureSettingsControllerI;
-import jalview.bin.Jalview;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceI;
import jalview.datamodel.features.FeatureMatcher;
@@ -99,6 +98,7 @@ import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.table.AbstractTableModel;
+import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
@@ -131,7 +131,8 @@ public class FeatureSettings extends JPanel
private static final int MIN_HEIGHT = 400;
- private final static String BASE_TOOLTIP = MessageManager.getString("label.click_to_edit");
+ private final static String BASE_TOOLTIP = MessageManager
+ .getString("label.click_to_edit");
final FeatureRenderer fr;
@@ -163,12 +164,6 @@ public class FeatureSettings extends JPanel
int selectedRow = -1;
- JButton fetchDAS = new JButton();
-
- JButton saveDAS = new JButton();
-
- JButton cancelDAS = new JButton();
-
boolean resettingTable = false;
/*
@@ -208,33 +203,6 @@ public class FeatureSettings extends JPanel
table = new JTable()
{
-
-// @Override
-// public void repaint() {
-// System.out.println("FS repaint");
-// super.repaint();
-//
-// }
-//
-// @Override
-// public void repaint(long tm, int x, int y, int width, int height) {
-// System.out.println("FS repaint " + x + " " + y + " " + width + " " + height);
-// super.repaint(tm, x, y, width, height);
-//
-// }
-// @Override
-// public void invalidate() {
-// if (isValid())
-// System.out.println("FS invalidating ");
-// super.invalidate();
-// }
-//
-// @Override
-// public void validate() {
-// System.out.println("FS validating " + isValid());
-// super.validate();
-// }
-
@Override
public String getToolTipText(MouseEvent e)
{
@@ -257,16 +225,16 @@ public class FeatureSettings extends JPanel
FeatureMatcherSet o = (FeatureMatcherSet) table.getValueAt(row,
column);
tip = o.isEmpty()
- ? MessageManager.getString("label.filters_tooltip")
+ ? MessageManager
+ .getString("label.configure_feature_tooltip")
: o.toString();
break;
default:
break;
}
-
+
return tip;
}
-
/**
* Position the tooltip near the bottom edge of, and half way across, the
@@ -283,21 +251,17 @@ public class FeatureSettings extends JPanel
return loc;
}
};
-
- // next line is needed to avoid (quiet) exceptions thrown
- // when column ordering changes so that the above constants
- // no longer apply.
- table.getTableHeader().setReorderingAllowed(false); // BH 2018
-
- table.getTableHeader().setFont(new Font("Verdana", Font.PLAIN, 12));
+ JTableHeader tableHeader = table.getTableHeader();
+ tableHeader.setFont(new Font("Verdana", Font.PLAIN, 12));
+ tableHeader.setReorderingAllowed(false);
+ table.setFont(new Font("Verdana", Font.PLAIN, 12));
ToolTipManager.sharedInstance().registerComponent(table);
-
table.setDefaultEditor(FeatureColour.class, new ColorEditor());
table.setDefaultRenderer(FeatureColour.class, new ColorRenderer());
table.setDefaultEditor(FeatureMatcherSet.class, new FilterEditor());
table.setDefaultRenderer(FeatureMatcherSet.class, new FilterRenderer());
-
+
TableColumn colourColumn = new TableColumn(COLOUR_COLUMN, 75,
new ColorRenderer(), new ColorEditor());
table.addColumn(colourColumn);
@@ -402,18 +366,9 @@ public class FeatureSettings extends JPanel
frame = new JInternalFrame();
frame.setContentPane(this);
- if (Platform.isAMac())
- {
- Desktop.addInternalFrame(frame,
- MessageManager.getString("label.sequence_feature_settings"),
- 600, 480);
- }
- else
- {
- Desktop.addInternalFrame(frame,
- MessageManager.getString("label.sequence_feature_settings"),
- 600, 450);
- }
+ Desktop.addInternalFrame(frame,
+ MessageManager.getString("label.sequence_feature_settings"),
+ 600, Platform.isAMacAndNotJS() ? 480 : 450);
frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
frame.addInternalFrameListener(
@@ -430,59 +385,31 @@ public class FeatureSettings extends JPanel
inConstruction = false;
}
- /**
- * Constructs and shows a popup menu of possible actions on the selected row and
- * feature type
- *
- * @param rowSelected
- * @param type
- * @param typeCol
- * @param pt
- */
+ /**
+ * Constructs and shows a popup menu of possible actions on the selected row
+ * and feature type
+ *
+ * @param rowSelected
+ * @param type
+ * @param typeCol
+ * @param pt
+ */
protected void showPopupMenu(final int rowSelected, final String type,
final Object typeCol, final Point pt)
{
- final FeatureColourI featureColour = (FeatureColourI) typeCol;
-
JPopupMenu men = new JPopupMenu(MessageManager
.formatMessage("label.settings_for_param", new String[]
{ type }));
- JMenuItem scr = new JMenuItem(
- MessageManager.getString("label.sort_by_score"));
- men.add(scr);
- scr.addActionListener(new ActionListener()
- {
-
- @Override
- public void actionPerformed(ActionEvent e)
- {
- af.avc.sortAlignmentByFeatureScore(Arrays.asList(new String[]
- { type }));
- }
- });
- JMenuItem dens = new JMenuItem(
- MessageManager.getString("label.sort_by_density"));
- dens.addActionListener(new ActionListener()
- {
-
- @Override
- public void actionPerformed(ActionEvent e)
- {
- af.avc.sortAlignmentByFeatureDensity(Arrays.asList(new String[]
- { type }));
- }
- });
- men.add(dens);
+ final FeatureColourI featureColour = (FeatureColourI) typeCol;
/*
- * variable colour options include colour by label, by score,
- * by selected attribute text, or attribute value
+ * menu option to select (or deselect) variable colour
*/
final JCheckBoxMenuItem variableColourCB = new JCheckBoxMenuItem(
MessageManager.getString("label.variable_colour"));
variableColourCB.setSelected(!featureColour.isSimpleColour());
men.add(variableColourCB);
-
+
/*
* checkbox action listener doubles up as listener to OK
* from the variable colour / filters dialog
@@ -494,8 +421,10 @@ public class FeatureSettings extends JPanel
{
if (e.getSource() == variableColourCB)
{
- men.setVisible(true); // BH 2018 for JavaScript because this is a checkbox
- men.setVisible(false); // BH 2018 for JavaScript because this is a checkbox
+ men.setVisible(true); // BH 2018 for JavaScript because this is a
+ // checkbox
+ men.setVisible(false); // BH 2018 for JavaScript because this is a
+ // checkbox
if (featureColour.isSimpleColour())
{
/*
@@ -509,7 +438,8 @@ public class FeatureSettings extends JPanel
/*
* toggle variable to simple colour - show colour chooser
*/
- String title = MessageManager.formatMessage("label.select_colour_for", type);
+ String title = MessageManager
+ .formatMessage("label.select_colour_for", type);
ColourChooserListener listener = new ColourChooserListener()
{
@Override
@@ -523,11 +453,11 @@ public class FeatureSettings extends JPanel
false);
}
};
- JalviewColourChooser.showColourChooser(FeatureSettings.this, title,
- featureColour.getMaxColour(), listener);
+ JalviewColourChooser.showColourChooser(FeatureSettings.this,
+ title, featureColour.getMaxColour(), listener);
}
}
- else
+ else
{
if (e.getSource() instanceof FeatureTypeSettings)
{
@@ -538,13 +468,42 @@ public class FeatureSettings extends JPanel
FeatureColourI fci = fr.getFeatureColours().get(type);
table.setValueAt(fci, rowSelected, COLOUR_COLUMN);
// BH 2018 setting a table value does not invalidate it.
-// System.out.println("FeatureSettings is valied" + table.isValid());
-// table.validate();
+ // System.out.println("FeatureSettings is valied" +
+ // table.validate();
}
}
}
});
+ men.addSeparator();
+
+ JMenuItem scr = new JMenuItem(
+ MessageManager.getString("label.sort_by_score"));
+ men.add(scr);
+ scr.addActionListener(new ActionListener()
+ {
+
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ af.avc.sortAlignmentByFeatureScore(Arrays.asList(new String[]
+ { type }));
+ }
+ });
+ JMenuItem dens = new JMenuItem(
+ MessageManager.getString("label.sort_by_density"));
+ dens.addActionListener(new ActionListener()
+ {
+
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ af.avc.sortAlignmentByFeatureDensity(Arrays.asList(new String[]
+ { type }));
+ }
+ });
+ men.add(dens);
+
JMenuItem selCols = new JMenuItem(
MessageManager.getString("label.select_columns_containing"));
selCols.addActionListener(new ActionListener()
@@ -804,8 +763,8 @@ public class FeatureSettings extends JPanel
}
/**
- * Updates 'originalData' (used for restore on Cancel) if we detect that changes
- * have been made outwith this dialog
+ * Updates 'originalData' (used for restore on Cancel) if we detect that
+ * changes have been made outwith this dialog
*
* - a new feature type added (and made visible)
* - a feature colour changed (in the Amend Features dialog)
@@ -869,8 +828,8 @@ public class FeatureSettings extends JPanel
/**
* Remove from the groups panel any checkboxes for groups that are not in the
- * foundGroups set. This enables removing a group from the display when the last
- * feature in that group is deleted.
+ * foundGroups set. This enables removing a group from the display when the
+ * last feature in that group is deleted.
*
* @param foundGroups
*/
@@ -927,13 +886,13 @@ public class FeatureSettings extends JPanel
chooser.setToolTipText(MessageManager.getString("action.load"));
chooser.setResponseHandler(0, new Runnable()
{
- @Override
- public void run()
- {
- File file = chooser.getSelectedFile();
- load(file);
- }
- });
+ @Override
+ public void run()
+ {
+ File file = chooser.getSelectedFile();
+ load(file);
+ }
+ });
chooser.showOpenDialog(this);
}
@@ -994,8 +953,7 @@ public class FeatureSettings extends JPanel
if (table != null)
{
resetTable(null);
- Object[][] data = ((FeatureTableModel) table.getModel())
- .getData();
+ Object[][] data = ((FeatureTableModel) table.getModel()).getData();
ensureOrder(data);
updateFeatureRenderer(data, false);
table.repaint();
@@ -1019,11 +977,11 @@ public class FeatureSettings extends JPanel
MessageManager.getString("label.save_feature_colours"));
chooser.setToolTipText(MessageManager.getString("action.save"));
int option = chooser.showSaveDialog(this);
- if (option == JalviewFileChooser.APPROVE_OPTION)
- {
- File file = chooser.getSelectedFile();
- save(file);
- }
+ if (option == JalviewFileChooser.APPROVE_OPTION)
+ {
+ File file = chooser.getSelectedFile();
+ save(file);
+ }
}
/**
@@ -1037,8 +995,8 @@ public class FeatureSettings extends JPanel
ucs.setSchemeName("Sequence Features");
try
{
- PrintWriter out = new PrintWriter(new OutputStreamWriter(
- new FileOutputStream(file), "UTF-8"));
+ PrintWriter out = new PrintWriter(
+ new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
/*
* sort feature types by colour order, from 0 (highest)
@@ -1075,11 +1033,11 @@ public class FeatureSettings extends JPanel
FeatureMatcherSetI filter = fr.getFeatureFilter(featureType);
if (filter != null && !filter.isEmpty())
{
- Iterator iterator = filter.getMatchers().iterator();
+ Iterator iterator = filter.getMatchers()
+ .iterator();
FeatureMatcherI firstMatcher = iterator.next();
jalview.xml.binding.jalview.FeatureMatcherSet ms = jalview.project.Jalview2XML
- .marshalFilter(firstMatcher, iterator,
- filter.isAnded());
+ .marshalFilter(firstMatcher, iterator, filter.isAnded());
Filter filterModel = new Filter();
filterModel.setFeatureType(featureType);
filterModel.setMatcherSet(ms);
@@ -1161,7 +1119,8 @@ public class FeatureSettings extends JPanel
else
{
width[i] /= max; // normalize
- fr.setOrder(data[i][TYPE_COLUMN].toString(), width[i]); // store for later
+ fr.setOrder(data[i][TYPE_COLUMN].toString(), width[i]); // store for
+ // later
}
if (i > 0)
{
@@ -1195,8 +1154,8 @@ public class FeatureSettings extends JPanel
}
/**
- * Update the priority order of features; only repaint if this changed the order
- * of visible features
+ * Update the priority order of features; only repaint if this changed the
+ * order of visible features
*
* @param data
* @param visibleNew
@@ -1305,22 +1264,6 @@ public class FeatureSettings extends JPanel
}
}
});
- help.setFont(JvSwingUtils.getLabelFont());
- help.setText(MessageManager.getString("action.help"));
- help.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- try
- {
- Help.showHelpWindow(HelpId.SequenceFeatureSettings);
- } catch (HelpSetException e1)
- {
- e1.printStackTrace();
- }
- }
- });
JButton cancel = new JButton(MessageManager.getString("action.cancel"));
cancel.setFont(JvSwingUtils.getLabelFont());
@@ -1449,7 +1392,7 @@ public class FeatureSettings extends JPanel
{
boolean thr = false;
StringBuilder tx = new StringBuilder();
-
+
if (gcol.isColourByAttribute())
{
tx.append(FeatureMatcher
@@ -1506,7 +1449,7 @@ public class FeatureSettings extends JPanel
private String[] columnNames = {
MessageManager.getString("label.feature_type"),
MessageManager.getString("action.colour"),
- MessageManager.getString("label.filter"),
+ MessageManager.getString("label.configuration"),
MessageManager.getString("label.show") };
private Object[][] data;
@@ -1707,7 +1650,7 @@ public class FeatureSettings extends JPanel
}
@SuppressWarnings("serial")
-class ColorEditor extends AbstractCellEditor
+ class ColorEditor extends AbstractCellEditor
implements TableCellEditor, ActionListener
{
FeatureColourI currentColor;
@@ -1748,8 +1691,9 @@ class ColorEditor extends AbstractCellEditor
/*
* simple colour chooser
*/
- String ttl = MessageManager.formatMessage("label.select_colour_for", type);
- ColourChooserListener listener = new ColourChooserListener()
+ String ttl = MessageManager
+ .formatMessage("label.select_colour_for", type);
+ ColourChooserListener listener = new ColourChooserListener()
{
@Override
public void colourSelected(Color c)
@@ -1758,13 +1702,15 @@ class ColorEditor extends AbstractCellEditor
table.setValueAt(currentColor, rowSelected, COLOUR_COLUMN);
fireEditingStopped();
}
- @Override
- public void cancel()
- {
- fireEditingStopped();
- }
+
+ @Override
+ public void cancel()
+ {
+ fireEditingStopped();
+ }
};
- JalviewColourChooser.showColourChooser(button, ttl, currentColor.getColour(), listener);
+ JalviewColourChooser.showColourChooser(button, ttl,
+ currentColor.getColour(), listener);
}
else
{
@@ -1772,7 +1718,12 @@ class ColorEditor extends AbstractCellEditor
* variable colour and filters dialog
*/
chooser = new FeatureTypeSettings(fr, type);
- if (!Jalview.isJS())
+ if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
{
chooser.setRequestFocusEnabled(true);
chooser.requestFocus();
@@ -1799,7 +1750,7 @@ class ColorEditor extends AbstractCellEditor
data[COLOUR_COLUMN] = currentColor;
data[FILTER_COLUMN] = currentFilter;
fireEditingStopped();
- // SwingJS needs an explicit repaint() here,
+ // SwingJS needs an explicit repaint() here,
// rather than relying upon no validation having
// occurred since the stopEditing call was made.
// Its laying out has not been stopped by the modal frame
@@ -1809,15 +1760,15 @@ class ColorEditor extends AbstractCellEditor
}
/**
- * Override allows access to this method from anonymous inner classes
+ * Override allows access to this method from anonymous inner classes
*/
@Override
- protected void fireEditingStopped()
+ protected void fireEditingStopped()
{
- super.fireEditingStopped();
- }
+ super.fireEditingStopped();
+ }
- // Implement the one CellEditor method that AbstractCellEditor doesn't.
+ // Implement the one CellEditor method that AbstractCellEditor doesn't.
@Override
public Object getCellEditorValue()
{
@@ -1826,8 +1777,8 @@ class ColorEditor extends AbstractCellEditor
// Implement the one method defined by TableCellEditor.
@Override
- public Component getTableCellEditorComponent(JTable theTable, Object value,
- boolean isSelected, int row, int column)
+ public Component getTableCellEditorComponent(JTable theTable,
+ Object value, boolean isSelected, int row, int column)
{
currentColor = (FeatureColourI) value;
this.rowSelected = row;
@@ -1855,12 +1806,12 @@ class ColorEditor extends AbstractCellEditor
/**
* The cell editor for the Filter column. It displays the text of any filters
- * for the feature type in that row (in full as a tooltip, possible abbreviated
- * as display text). On click in the cell, opens the Feature Display Settings
- * dialog at the Filters tab.
+ * for the feature type in that row (in full as a tooltip, possible
+ * abbreviated as display text). On click in the cell, opens the Feature
+ * Display Settings dialog at the Filters tab.
*/
@SuppressWarnings("serial")
-class FilterEditor extends AbstractCellEditor
+ class FilterEditor extends AbstractCellEditor
implements TableCellEditor, ActionListener
{
@@ -1919,13 +1870,13 @@ class FilterEditor extends AbstractCellEditor
{
currentFilter = new FeatureMatcherSet();
}
-
+
Object[] data = ((FeatureTableModel) table.getModel())
.getData()[rowSelected];
data[COLOUR_COLUMN] = currentColor;
data[FILTER_COLUMN] = currentFilter;
fireEditingStopped();
- // SwingJS needs an explicit repaint() here,
+ // SwingJS needs an explicit repaint() here,
// rather than relying upon no validation having
// occurred since the stopEditing call was made.
// Its laying out has not been stopped by the modal frame
@@ -1941,8 +1892,8 @@ class FilterEditor extends AbstractCellEditor
}
@Override
- public Component getTableCellEditorComponent(JTable theTable, Object value,
- boolean isSelected, int row, int column)
+ public Component getTableCellEditorComponent(JTable theTable,
+ Object value, boolean isSelected, int row, int column)
{
currentFilter = (FeatureMatcherSetI) value;
this.rowSelected = row;
@@ -2033,7 +1984,7 @@ class FeatureIcon implements Icon
g.fillRect(s1, 0, e1 - s1, height);
}
g.setColor(gcol.getMaxColour());
-// g.fillRect(0, e1, width - e1, height); // BH 2018
+ // g.fillRect(0, e1, width - e1, height); // BH 2018
g.fillRect(e1, 0, width - e1, height);
}
}