/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
*/
package jalview.gui;
-import java.io.*;
-import java.util.*;
-import java.util.List;
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.GridLayout;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionAdapter;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.table.*;
-
-import jalview.analysis.AlignmentSorter;
-import jalview.bin.Cache;
-import jalview.commands.OrderCommand;
-import jalview.datamodel.*;
-import jalview.io.*;
-import jalview.schemes.AnnotationColourGradient;
-import jalview.schemes.GraduatedColor;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.help.HelpSetException;
+import javax.swing.AbstractCellEditor;
+import javax.swing.BorderFactory;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
+import javax.swing.JLayeredPane;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
+import javax.swing.JSlider;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.SwingConstants;
+import javax.swing.ToolTipManager;
+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;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Marshaller;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import jalview.api.AlignViewControllerGuiI;
+import jalview.api.AlignViewportI;
+import jalview.api.FeatureColourI;
+import jalview.api.FeatureSettingsControllerI;
+import jalview.api.SplitContainerI;
+import jalview.api.ViewStyleI;
+import jalview.controller.FeatureSettingsControllerGuiI;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SequenceI;
+import jalview.datamodel.features.FeatureMatcher;
+import jalview.datamodel.features.FeatureMatcherI;
+import jalview.datamodel.features.FeatureMatcherSet;
+import jalview.datamodel.features.FeatureMatcherSetI;
+import jalview.gui.Help.HelpId;
+import jalview.gui.JalviewColourChooser.ColourChooserListener;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.schemes.FeatureColour;
import jalview.util.MessageManager;
-import jalview.ws.dbsources.das.api.jalviewSourceI;
+import jalview.util.Platform;
+import jalview.viewmodel.seqfeatures.FeatureRendererModel.FeatureSettingsBean;
+import jalview.viewmodel.styles.ViewStyle;
+import jalview.xml.binding.jalview.JalviewUserColours;
+import jalview.xml.binding.jalview.JalviewUserColours.Colour;
+import jalview.xml.binding.jalview.JalviewUserColours.Filter;
+import jalview.xml.binding.jalview.ObjectFactory;
public class FeatureSettings extends JPanel
+ implements FeatureSettingsControllerI, FeatureSettingsControllerGuiI
{
- DasSourceBrowser dassourceBrowser;
+ private static final String SEQUENCE_FEATURE_COLOURS = MessageManager
+ .getString("label.sequence_feature_colours");
+
+ /*
+ * column indices of fields in Feature Settings table
+ */
+ static final int TYPE_COLUMN = 0;
+
+ static final int COLOUR_COLUMN = 1;
+
+ static final int FILTER_COLUMN = 2;
+
+ static final int SHOW_COLUMN = 3;
- jalview.ws.DasSequenceFeatureFetcher dasFeatureFetcher;
+ private static final int COLUMN_COUNT = 4;
- JPanel settingsPane = new JPanel();
+ private static final int MIN_WIDTH = 400;
- JPanel dasSettingsPane = new JPanel();
+ private static final int MIN_HEIGHT = 400;
+
+ private final static String BASE_TOOLTIP = MessageManager
+ .getString("label.click_to_edit");
final FeatureRenderer fr;
public final AlignFrame af;
+ /*
+ * 'original' fields hold settings to restore on Cancel
+ */
Object[][] originalData;
+ float originalTransparency;
+
+ private ViewStyleI originalViewStyle;
+
+ private Map<String, FeatureMatcherSetI> originalFilters;
+
final JInternalFrame frame;
JScrollPane scrollPane = new JScrollPane();
JSlider transparency = new JSlider();
- JPanel transPanel = new JPanel(new GridLayout(1, 2));
+ private JCheckBox showComplementOnTop;
+
+ private JCheckBox showComplement;
+
+ /*
+ * when true, constructor is still executing - so ignore UI events
+ */
+ protected volatile boolean inConstruction = true;
+
+ int selectedRow = -1;
+
+ boolean resettingTable = false;
+
+ /*
+ * true when Feature Settings are updating from feature renderer
+ */
+ boolean handlingUpdate = false;
+
+ /*
+ * a change listener to ensure the dialog is updated if
+ * FeatureRenderer discovers new features
+ */
+ private PropertyChangeListener change;
+
+ /*
+ * holds {featureCount, totalExtent} for each feature type
+ */
+ Map<String, float[]> typeWidth = null;
+
+ private void storeOriginalSettings()
+ {
+ // save transparency for restore on Cancel
+ originalTransparency = fr.getTransparency();
+
+ updateTransparencySliderFromFR();
+
+ originalFilters = new HashMap<>(fr.getFeatureFilters()); // shallow copy
+ originalViewStyle = new ViewStyle(af.viewport.getViewStyle());
+ }
+
+ private void updateTransparencySliderFromFR()
+ {
+ boolean incon = inConstruction;
+ inConstruction = true;
- public FeatureSettings(AlignFrame af)
+ int transparencyAsPercent = (int) (fr.getTransparency() * 100);
+ transparency.setValue(100 - transparencyAsPercent);
+ inConstruction = incon;
+ }
+ /**
+ * Constructor
+ *
+ * @param af
+ */
+ public FeatureSettings(AlignFrame alignFrame)
{
- this.af = af;
+ this.af = alignFrame;
fr = af.getFeatureRenderer();
- transparency.setMaximum(100 - (int) (fr.transparency * 100));
+ storeOriginalSettings();
try
{
ex.printStackTrace();
}
- table = new JTable();
- table.getTableHeader().setFont(new Font("Verdana", Font.PLAIN, 12));
+ table = new JTable()
+ {
+ @Override
+ public String getToolTipText(MouseEvent e)
+ {
+ String tip = null;
+ int column = table.columnAtPoint(e.getPoint());
+ int row = table.rowAtPoint(e.getPoint());
+
+ switch (column)
+ {
+ case TYPE_COLUMN:
+ tip = JvSwingUtils.wrapTooltip(true, MessageManager
+ .getString("label.feature_settings_click_drag"));
+ break;
+ case COLOUR_COLUMN:
+ FeatureColourI colour = (FeatureColourI) table.getValueAt(row,
+ column);
+ tip = getColorTooltip(colour, true);
+ break;
+ case FILTER_COLUMN:
+ FeatureMatcherSet o = (FeatureMatcherSet) table.getValueAt(row,
+ column);
+ tip = o.isEmpty()
+ ? 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
+ * current cell
+ */
+ @Override
+ public Point getToolTipLocation(MouseEvent e)
+ {
+ Point point = e.getPoint();
+ int column = table.columnAtPoint(point);
+ int row = table.rowAtPoint(point);
+ Rectangle r = getCellRect(row, column, false);
+ Point loc = new Point(r.x + r.width / 2, r.y + r.height - 3);
+ return loc;
+ }
+ };
+ JTableHeader tableHeader = table.getTableHeader();
+ tableHeader.setFont(new Font("Verdana", Font.PLAIN, 12));
+ tableHeader.setReorderingAllowed(false);
table.setFont(new Font("Verdana", Font.PLAIN, 12));
- table.setDefaultRenderer(Color.class, new ColorRenderer());
+ 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());
- table.setDefaultEditor(Color.class, new ColorEditor(this));
+ TableColumn colourColumn = new TableColumn(COLOUR_COLUMN, 75,
+ new ColorRenderer(), new ColorEditor());
+ table.addColumn(colourColumn);
+
+ TableColumn filterColumn = new TableColumn(FILTER_COLUMN, 75,
+ new FilterRenderer(), new FilterEditor());
+ table.addColumn(filterColumn);
- table.setDefaultEditor(GraduatedColor.class, new ColorEditor(this));
- table.setDefaultRenderer(GraduatedColor.class, new ColorRenderer());
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.addMouseListener(new MouseAdapter()
{
+ @Override
public void mousePressed(MouseEvent evt)
{
- selectedRow = table.rowAtPoint(evt.getPoint());
+ Point pt = evt.getPoint();
+ selectedRow = table.rowAtPoint(pt);
+ String type = (String) table.getValueAt(selectedRow, TYPE_COLUMN);
if (evt.isPopupTrigger())
{
- popupSort(selectedRow, (String) table.getValueAt(selectedRow, 0),
- table.getValueAt(selectedRow, 1), fr.minmax, evt.getX(),
- evt.getY());
+ Object colour = table.getValueAt(selectedRow, COLOUR_COLUMN);
+ showPopupMenu(selectedRow, type, colour, evt.getPoint());
}
- else if (evt.getClickCount() == 2)
+ else if (evt.getClickCount() == 2
+ && table.columnAtPoint(pt) == TYPE_COLUMN)
{
+ 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(),
- (String) table.getValueAt(selectedRow, 0));
+ invertSelection, extendSelection, toggleSelection, type);
+ fr.ap.av.sendSelection();
+ }
+ }
+
+ // isPopupTrigger fires on mouseReleased on Windows
+ @Override
+ public void mouseReleased(MouseEvent evt)
+ {
+ selectedRow = table.rowAtPoint(evt.getPoint());
+ if (evt.isPopupTrigger())
+ {
+ String type = (String) table.getValueAt(selectedRow, TYPE_COLUMN);
+ Object colour = table.getValueAt(selectedRow, COLOUR_COLUMN);
+ showPopupMenu(selectedRow, type, colour, evt.getPoint());
}
}
});
table.addMouseMotionListener(new MouseMotionAdapter()
{
+ @Override
public void mouseDragged(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;
}
}
});
- table.setToolTipText("<html>"
- + JvSwingUtils
- .wrapTooltip("Click/drag feature types up or down to change render order.<br/>Double click to select columns containing feature in alignment/current selection<br/>Pressing Alt will select columns outside features rather than inside<br/>Pressing Shift to modify current selection (rather than clear current selection)<br/>Press CTRL or Command/Meta to toggle columns in/outside features<br/>")
- + "</html>");
+ // table.setToolTipText(JvSwingUtils.wrapTooltip(true,
+ // MessageManager.getString("label.feature_settings_click_drag")));
scrollPane.setViewportView(table);
- dassourceBrowser = new DasSourceBrowser(this);
- dasSettingsPane.add(dassourceBrowser, BorderLayout.CENTER);
-
- if (af.getViewport().featuresDisplayed == null
- || fr.renderOrder == null)
+ if (af.getViewport().isShowSequenceFeatures() || !fr.hasRenderOrder())
{
fr.findAllFeatures(true); // display everything!
}
- setTableData();
- final PropertyChangeListener change;
+ discoverAllFeatureData();
final FeatureSettings fs = this;
fr.addPropertyChangeListener(change = new PropertyChangeListener()
{
+ @Override
public void propertyChange(PropertyChangeEvent evt)
{
if (!fs.resettingTable && !fs.handlingUpdate)
{
fs.handlingUpdate = true;
- fs.resetTable(null); // new groups may be added with new seuqence
- // feature types only
+ fs.resetTable(null);
+ // new groups may be added with new sequence feature types only
fs.handlingUpdate = false;
}
}
});
- frame = new JInternalFrame();
- frame.setContentPane(this);
- if (new jalview.util.Platform().isAMac())
+ SplitContainerI splitframe = af.getSplitViewContainer();
+ if (splitframe != null)
{
- Desktop.addInternalFrame(frame,
- MessageManager.getString("label.sequence_feature_settings"),
- 475, 480);
+ frame = null; // keeps eclipse happy
+ splitframe.addFeatureSettingsUI(this);
}
else
{
- Desktop.addInternalFrame(frame,
- MessageManager.getString("label.sequence_feature_settings"),
- 400, 450);
- }
-
- frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
- {
- public void internalFrameClosed(
- javax.swing.event.InternalFrameEvent evt)
+ frame = new JInternalFrame();
+ frame.setContentPane(this);
+ Rectangle bounds = af.getFeatureSettingsGeometry();
+ String title;
+ if (af.getAlignPanels().size() > 1 || Desktop.getAlignmentPanels(
+ af.alignPanel.av.getSequenceSetId()).length > 1)
{
- fr.removePropertyChangeListener(change);
- dassourceBrowser.fs = null;
- };
- });
- frame.setLayer(JLayeredPane.PALETTE_LAYER);
+ title = MessageManager.formatMessage(
+ "label.sequence_feature_settings_for_view",
+ af.alignPanel.getViewName());
+ }
+ else
+ {
+ title = MessageManager.getString("label.sequence_feature_settings");
+ }
+ if (bounds == null)
+ {
+ if (Platform.isAMacAndNotJS())
+ {
+ Desktop.addInternalFrame(frame, title, 600, 480);
+ }
+ else
+ {
+ Desktop.addInternalFrame(frame, title, 600, 450);
+ }
+ }
+ else
+ {
+ Desktop.addInternalFrame(frame, title, Desktop.FRAME_NOT_VISIBLE, bounds.width,
+ bounds.height, Desktop.FRAME_ALLOW_RESIZE, Desktop.FRAME_SET_MIN_SIZE_300);
+ frame.setBounds(bounds);
+ frame.setVisible(true);
+ }
+ frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
+
+ frame.addInternalFrameListener(
+ new javax.swing.event.InternalFrameAdapter()
+ {
+ @Override
+ public void internalFrameClosed(
+ javax.swing.event.InternalFrameEvent evt)
+ {
+ featureSettings_isClosed();
+ };
+ });
+ frame.setLayer(JLayeredPane.PALETTE_LAYER);
+ }
+ inConstruction = false;
+ }
+
+ /**
+ * Sets the state of buttons to show complement features from viewport
+ * settings
+ */
+ private void updateComplementButtons()
+ {
+ showComplement.setSelected(af.getViewport().isShowComplementFeatures());
+ showComplementOnTop
+ .setSelected(af.getViewport().isShowComplementFeaturesOnTop());
+ }
+
+ @Override
+ public AlignViewControllerGuiI getAlignframe()
+ {
+ return af;
+ }
+
+ @Override
+ public void featureSettings_isClosed()
+ {
+ fr.removePropertyChangeListener(change);
+ change = null;
}
- protected void popupSort(final int selectedRow, final String type,
- final Object typeCol, final Hashtable minmax, int x, int y)
+ /**
+ * 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)
{
- JPopupMenu men = new JPopupMenu(MessageManager.formatMessage(
- "label.settings_for_param", new String[]
+ JPopupMenu men = new JPopupMenu(MessageManager
+ .formatMessage("label.settings_for_param", new String[]
{ type }));
+ final FeatureColourI featureColour = (FeatureColourI) typeCol;
+
+ /*
+ * 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
+ */
+ variableColourCB.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getSource() == variableColourCB)
+ {
+ // BH 2018 for JavaScript because this is a checkbox
+ men.setVisible(true);
+ men.setVisible(false);
+ if (featureColour.isSimpleColour())
+ {
+ /*
+ * toggle simple colour to variable colour - show dialog
+ */
+ FeatureTypeSettings fc = new FeatureTypeSettings(fr, type);
+ fc.addActionListener(this);
+ }
+ else
+ {
+ /*
+ * toggle variable to simple colour - show colour chooser
+ */
+ String title = MessageManager
+ .formatMessage("label.select_colour_for", type);
+ ColourChooserListener listener = new ColourChooserListener()
+ {
+ @Override
+ public void colourSelected(Color c)
+ {
+ table.setValueAt(new FeatureColour(c), rowSelected,
+ COLOUR_COLUMN);
+ table.validate();
+ updateFeatureRenderer(
+ ((FeatureTableModel) table.getModel()).getData(),
+ false);
+ }
+ };
+ JalviewColourChooser.showColourChooser(FeatureSettings.this,
+ title, featureColour.getMaxColour(), listener);
+ }
+ }
+ else
+ {
+ if (e.getSource() instanceof FeatureTypeSettings)
+ {
+ /*
+ * update after OK in feature colour dialog; the updated
+ * colour will have already been set in the FeatureRenderer
+ */
+ 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.validate();
+ }
+ }
+ }
+ });
+
+ men.addSeparator();
+
JMenuItem scr = new JMenuItem(
MessageManager.getString("label.sort_by_score"));
men.add(scr);
- final FeatureSettings me = this;
scr.addActionListener(new ActionListener()
{
-
+ @Override
public void actionPerformed(ActionEvent e)
{
- me.sortByScore(new String[]
- { type });
+ sortByScore(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)
{
- me.sortByDens(new String[]
- { type });
+ sortByDensity(Arrays.asList(new String[] { type }));
}
-
});
men.add(dens);
- if (minmax != null)
- {
- final Object typeMinMax = minmax.get(type);
- /*
- * final JCheckBoxMenuItem chb = new JCheckBoxMenuItem("Vary Height"); //
- * this is broken at the moment and isn't that useful anyway!
- * chb.setSelected(minmax.get(type) != null); chb.addActionListener(new
- * ActionListener() {
- *
- * public void actionPerformed(ActionEvent e) {
- * chb.setState(chb.getState()); if (chb.getState()) { minmax.put(type,
- * null); } else { minmax.put(type, typeMinMax); } }
- *
- * });
- *
- * men.add(chb);
- */
- if (typeMinMax != null && ((float[][]) typeMinMax)[0] != null)
- {
- // if (table.getValueAt(row, column));
- // graduated colourschemes for those where minmax exists for the
- // positional features
- final JCheckBoxMenuItem mxcol = new JCheckBoxMenuItem(
- "Graduated Colour");
- mxcol.setSelected(!(typeCol instanceof Color));
- men.add(mxcol);
- mxcol.addActionListener(new ActionListener()
- {
- JColorChooser colorChooser;
-
- public void actionPerformed(ActionEvent e)
- {
- if (e.getSource() == mxcol)
- {
- if (typeCol instanceof Color)
- {
- FeatureColourChooser fc = new FeatureColourChooser(me.fr,
- type);
- fc.addActionListener(this);
- }
- else
- {
- // bring up simple color chooser
- colorChooser = new JColorChooser();
- JDialog dialog = JColorChooser.createDialog(me,
- "Select new Colour", true, // modal
- colorChooser, this, // OK button handler
- null); // no CANCEL button handler
- colorChooser.setColor(((GraduatedColor) typeCol)
- .getMaxColor());
- dialog.setVisible(true);
- }
- }
- else
- {
- if (e.getSource() instanceof FeatureColourChooser)
- {
- FeatureColourChooser fc = (FeatureColourChooser) e
- .getSource();
- table.setValueAt(fc.getLastColour(), selectedRow, 1);
- table.validate();
- }
- else
- {
- // probably the color chooser!
- table.setValueAt(colorChooser.getColor(), selectedRow, 1);
- table.validate();
- me.updateFeatureRenderer(
- ((FeatureTableModel) table.getModel()).getData(),
- false);
- }
- }
- }
- });
- }
- }
JMenuItem selCols = new JMenuItem(
MessageManager.getString("label.select_columns_containing"));
selCols.addActionListener(new ActionListener()
{
-
@Override
public void actionPerformed(ActionEvent arg0)
{
fr.ap.alignFrame.avc.markColumnsContainingFeatures(false, false,
false, type);
+ fr.ap.av.sendSelection();
}
});
- JMenuItem clearCols = new JMenuItem(
- MessageManager.getString("label.select_columns_not_containing"));
+ JMenuItem clearCols = new JMenuItem(MessageManager
+ .getString("label.select_columns_not_containing"));
clearCols.addActionListener(new ActionListener()
{
-
@Override
public void actionPerformed(ActionEvent arg0)
{
fr.ap.alignFrame.avc.markColumnsContainingFeatures(true, false,
false, type);
+ fr.ap.av.sendSelection();
+ }
+ });
+ 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);
+ fr.ap.av.sendSelection();
+ }
+ });
+ 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);
+ fr.ap.av.sendSelection();
}
});
men.add(selCols);
men.add(clearCols);
- men.show(table, x, y);
+ men.add(hideCols);
+ men.add(hideOtherCols);
+ men.show(table, pt.x, pt.y);
}
/**
- * true when Feature Settings are updating from feature renderer
+ * Sort the sequences in the alignment by the number of features for the given
+ * feature types (or all features if null)
+ *
+ * @param featureTypes
*/
- private boolean handlingUpdate = false;
+ protected void sortByDensity(List<String> featureTypes)
+ {
+ af.avc.sortAlignmentByFeatureDensity(featureTypes);
+ }
/**
- * contains a float[3] for each feature type string. created by setTableData
+ * Sort the sequences in the alignment by average score for the given feature
+ * types (or all features if null)
+ *
+ * @param featureTypes
*/
- Hashtable typeWidth = null;
+ protected void sortByScore(List<String> featureTypes)
+ {
+ af.avc.sortAlignmentByFeatureScore(featureTypes);
+ }
- synchronized public void setTableData()
+ /**
+ * Returns true if at least one feature type is visible. Else shows a warning
+ * dialog and returns false.
+ *
+ * @param title
+ * @return
+ */
+ private boolean canSortBy(String title)
{
- if (fr.featureGroups == null)
+ if (fr.getDisplayedFeatureTypes().isEmpty())
{
- fr.featureGroups = new Hashtable();
+ JvOptionPane.showMessageDialog(this,
+ MessageManager.getString("label.no_features_to_sort_by"),
+ title, JvOptionPane.OK_OPTION);
+ return false;
}
- Vector allFeatures = new Vector();
- Vector allGroups = new Vector();
- SequenceFeature[] tmpfeatures;
- String group;
- for (int i = 0; i < af.getViewport().getAlignment().getHeight(); i++)
- {
- if (af.getViewport().getAlignment().getSequenceAt(i)
- .getDatasetSequence().getSequenceFeatures() == null)
- {
- continue;
- }
+ return true;
+ }
- tmpfeatures = af.getViewport().getAlignment().getSequenceAt(i)
- .getDatasetSequence().getSequenceFeatures();
+ @Override
+ synchronized public void discoverAllFeatureData()
+ {
+ Set<String> allGroups = new HashSet<>();
+ AlignmentI alignment = af.getViewport().getAlignment();
- int index = 0;
- while (index < tmpfeatures.length)
+ for (int i = 0; i < alignment.getHeight(); i++)
+ {
+ SequenceI seq = alignment.getSequenceAt(i);
+ for (String group : seq.getFeatures().getFeatureGroups(true))
{
- if (tmpfeatures[index].begin == 0 && tmpfeatures[index].end == 0)
+ if (group != null && !allGroups.contains(group))
{
- index++;
- continue;
- }
-
- if (tmpfeatures[index].getFeatureGroup() != null)
- {
- group = tmpfeatures[index].featureGroup;
- if (!allGroups.contains(group))
- {
- allGroups.addElement(group);
- if (group != null)
- {
- checkGroupState(group);
- }
- }
+ allGroups.add(group);
+ checkGroupState(group);
}
-
- if (!allFeatures.contains(tmpfeatures[index].getType()))
- {
- allFeatures.addElement(tmpfeatures[index].getType());
- }
- index++;
}
}
}
/**
+ * Synchronise gui group list and check visibility of group
*
* @param group
- * @return true if group has been seen before and is already added to set.
+ * @return true if group is visible
*/
private boolean checkGroupState(String group)
{
- boolean visible;
- if (fr.featureGroups.containsKey(group))
- {
- visible = ((Boolean) fr.featureGroups.get(group)).booleanValue();
- }
- else
- {
- visible = true; // new group is always made visible
- }
+ boolean visible = fr.checkGroupVisibility(group, true);
- if (groupPanel == null)
- {
- groupPanel = new JPanel();
- }
-
- boolean alreadyAdded = false;
for (int g = 0; g < groupPanel.getComponentCount(); g++)
{
if (((JCheckBox) groupPanel.getComponent(g)).getText().equals(group))
{
- alreadyAdded = true;
((JCheckBox) groupPanel.getComponent(g)).setSelected(visible);
- break;
+ return visible;
}
}
- if (alreadyAdded)
- {
-
- return true;
- }
-
- fr.featureGroups.put(group, new Boolean(visible));
final String grp = group;
final JCheckBox check = new JCheckBox(group, visible);
check.setFont(new Font("Serif", Font.BOLD, 12));
+ check.setToolTipText(group);
check.addItemListener(new ItemListener()
{
+ @Override
public void itemStateChanged(ItemEvent evt)
{
- fr.featureGroups.put(check.getText(),
- new Boolean(check.isSelected()));
- af.alignPanel.seqPanel.seqCanvas.repaint();
- if (af.alignPanel.overviewPanel != null)
- {
- af.alignPanel.overviewPanel.updateOverviewImage();
- }
-
- resetTable(new String[]
- { grp });
+ fr.setGroupVisibility(check.getText(), check.isSelected());
+ resetTable(new String[] { grp });
+ refreshDisplay();
}
});
groupPanel.add(check);
- return false;
+ return visible;
}
- boolean resettingTable = false;
-
synchronized void resetTable(String[] groupChanged)
{
- if (resettingTable == true)
+ if (resettingTable)
{
return;
}
resettingTable = true;
- typeWidth = new Hashtable();
+ typeWidth = new Hashtable<>();
// TODO: change avWidth calculation to 'per-sequence' average and use long
// rather than float
- float[] avWidth = null;
- SequenceFeature[] tmpfeatures;
- String group = null, type;
- Vector visibleChecks = new Vector();
-
- // Find out which features should be visible depending on which groups
- // are selected / deselected
- // and recompute average width ordering
+
+ Set<String> displayableTypes = new HashSet<>();
+ Set<String> foundGroups = new HashSet<>();
+
+ /*
+ * determine which feature types may be visible depending on
+ * which groups are selected, and recompute average width data
+ */
for (int i = 0; i < af.getViewport().getAlignment().getHeight(); i++)
{
- tmpfeatures = af.getViewport().getAlignment().getSequenceAt(i)
- .getDatasetSequence().getSequenceFeatures();
- if (tmpfeatures == null)
- {
- continue;
- }
+ SequenceI seq = af.getViewport().getAlignment().getSequenceAt(i);
- int index = 0;
- while (index < tmpfeatures.length)
+ /*
+ * get the sequence's groups for positional features
+ * and keep track of which groups are visible
+ */
+ Set<String> groups = seq.getFeatures().getFeatureGroups(true);
+ Set<String> visibleGroups = new HashSet<>();
+ for (String group : groups)
{
- group = tmpfeatures[index].featureGroup;
-
- if (tmpfeatures[index].begin == 0 && tmpfeatures[index].end == 0)
+ if (group == null || checkGroupState(group))
{
- index++;
- continue;
+ visibleGroups.add(group);
}
+ }
+ foundGroups.addAll(groups);
- if (group == null || fr.featureGroups.get(group) == null
- || ((Boolean) fr.featureGroups.get(group)).booleanValue())
- {
- if (group != null)
- checkGroupState(group);
- type = tmpfeatures[index].getType();
- if (!visibleChecks.contains(type))
- {
- visibleChecks.addElement(type);
- }
- }
- if (!typeWidth.containsKey(tmpfeatures[index].getType()))
- {
- typeWidth.put(tmpfeatures[index].getType(),
- avWidth = new float[3]);
- }
- else
- {
- avWidth = (float[]) typeWidth.get(tmpfeatures[index].getType());
- }
- avWidth[0]++;
- if (tmpfeatures[index].getBegin() > tmpfeatures[index].getEnd())
- {
- avWidth[1] += 1 + tmpfeatures[index].getBegin()
- - tmpfeatures[index].getEnd();
- }
- else
+ /*
+ * get distinct feature types for visible groups
+ * record distinct visible types, and their count and total length
+ */
+ Set<String> types = seq.getFeatures().getFeatureTypesForGroups(true,
+ visibleGroups.toArray(new String[visibleGroups.size()]));
+ for (String type : types)
+ {
+ displayableTypes.add(type);
+ float[] avWidth = typeWidth.get(type);
+ if (avWidth == null)
{
- avWidth[1] += 1 + tmpfeatures[index].getEnd()
- - tmpfeatures[index].getBegin();
+ avWidth = new float[2];
+ typeWidth.put(type, avWidth);
}
- index++;
+ // todo this could include features with a non-visible group
+ // - do we greatly care?
+ // todo should we include non-displayable features here, and only
+ // update when features are added?
+ avWidth[0] += seq.getFeatures().getFeatureCount(true, type);
+ avWidth[1] += seq.getFeatures().getTotalFeatureLength(type);
}
}
- int fSize = visibleChecks.size();
- Object[][] data = new Object[fSize][3];
+ Object[][] data = new Object[displayableTypes.size()][COLUMN_COUNT];
int dataIndex = 0;
- if (fr.renderOrder != null)
+ if (fr.hasRenderOrder())
{
if (!handlingUpdate)
+ {
fr.findAllFeatures(groupChanged != null); // prod to update
- // colourschemes. but don't
- // affect display
- // First add the checks in the previous render order,
- // in case the window has been closed and reopened
- for (int ro = fr.renderOrder.length - 1; ro > -1; ro--)
+ // colourschemes. but don't
+ // affect display
+ // First add the checks in the previous render order,
+ // in case the window has been closed and reopened
+ }
+ List<String> frl = fr.getRenderOrder();
+ for (int ro = frl.size() - 1; ro > -1; ro--)
{
- type = fr.renderOrder[ro];
+ String type = frl.get(ro);
- if (!visibleChecks.contains(type))
+ if (!displayableTypes.contains(type))
{
continue;
}
- data[dataIndex][0] = type;
- data[dataIndex][1] = fr.getFeatureStyle(type);
- data[dataIndex][2] = new Boolean(
- af.getViewport().featuresDisplayed.containsKey(type));
+ data[dataIndex][TYPE_COLUMN] = type;
+ data[dataIndex][COLOUR_COLUMN] = fr.getFeatureStyle(type);
+ FeatureMatcherSetI featureFilter = fr.getFeatureFilter(type);
+ data[dataIndex][FILTER_COLUMN] = featureFilter == null
+ ? new FeatureMatcherSet()
+ : featureFilter;
+ data[dataIndex][SHOW_COLUMN] = Boolean.valueOf(
+ af.getViewport().getFeaturesDisplayed().isVisible(type));
dataIndex++;
- visibleChecks.removeElement(type);
+ displayableTypes.remove(type);
}
}
- fSize = visibleChecks.size();
- for (int i = 0; i < fSize; i++)
+ /*
+ * process any extra features belonging only to
+ * a group which was just selected
+ */
+ while (!displayableTypes.isEmpty())
{
- // These must be extra features belonging to the group
- // which was just selected
- type = visibleChecks.elementAt(i).toString();
- data[dataIndex][0] = type;
+ String type = displayableTypes.iterator().next();
+ data[dataIndex][TYPE_COLUMN] = type;
- data[dataIndex][1] = fr.getFeatureStyle(type);
- if (data[dataIndex][1] == null)
+ data[dataIndex][COLOUR_COLUMN] = fr.getFeatureStyle(type);
+ if (data[dataIndex][COLOUR_COLUMN] == null)
{
// "Colour has been updated in another view!!"
- fr.renderOrder = null;
+ fr.clearRenderOrder();
return;
}
-
- data[dataIndex][2] = new Boolean(true);
+ FeatureMatcherSetI featureFilter = fr.getFeatureFilter(type);
+ data[dataIndex][FILTER_COLUMN] = featureFilter == null
+ ? new FeatureMatcherSet()
+ : featureFilter;
+ data[dataIndex][SHOW_COLUMN] = Boolean.valueOf(true);
dataIndex++;
+ displayableTypes.remove(type);
}
if (originalData == null)
{
- originalData = new Object[data.length][3];
+ originalData = new Object[data.length][COLUMN_COUNT];
for (int i = 0; i < data.length; i++)
{
- System.arraycopy(data[i], 0, originalData[i], 0, 3);
+ System.arraycopy(data[i], 0, originalData[i], 0, COLUMN_COUNT);
}
}
+ else
+ {
+ updateOriginalData(data);
+ }
table.setModel(new FeatureTableModel(data));
table.getColumnModel().getColumn(0).setPreferredWidth(200);
- if (groupPanel != null)
- {
- groupPanel.setLayout(new GridLayout(fr.featureGroups.size() / 4 + 1,
- 4));
-
- groupPanel.validate();
- bigPanel.add(groupPanel, BorderLayout.NORTH);
- }
+ groupPanel.setLayout(
+ new GridLayout(fr.getFeatureGroupsSize() / 4 + 1, 4));
+ pruneGroups(foundGroups);
+ groupPanel.validate();
updateFeatureRenderer(data, groupChanged != null);
resettingTable = false;
}
/**
- * reorder data based on the featureRenderers global priority list.
+ * Updates 'originalData' (used for restore on Cancel) if we detect that
+ * changes have been made outwith this dialog
+ * <ul>
+ * <li>a new feature type added (and made visible)</li>
+ * <li>a feature colour changed (in the Amend Features dialog)</li>
+ * </ul>
*
- * @param data
+ * @param foundData
+ */
+ protected void updateOriginalData(Object[][] foundData)
+ {
+ // todo LinkedHashMap instead of Object[][] would be nice
+
+ Object[][] currentData = ((FeatureTableModel) table.getModel())
+ .getData();
+ for (Object[] row : foundData)
+ {
+ String type = (String) row[TYPE_COLUMN];
+ boolean found = false;
+ for (Object[] current : currentData)
+ {
+ if (type.equals(current[TYPE_COLUMN]))
+ {
+ found = true;
+ /*
+ * currently dependent on object equality here;
+ * really need an equals method on FeatureColour
+ */
+ if (!row[COLOUR_COLUMN].equals(current[COLOUR_COLUMN]))
+ {
+ /*
+ * feature colour has changed externally - update originalData
+ */
+ for (Object[] original : originalData)
+ {
+ if (type.equals(original[TYPE_COLUMN]))
+ {
+ original[COLOUR_COLUMN] = row[COLOUR_COLUMN];
+ break;
+ }
+ }
+ }
+ break;
+ }
+ }
+ if (!found)
+ {
+ /*
+ * new feature detected - add to original data (on top)
+ */
+ Object[][] newData = new Object[originalData.length
+ + 1][COLUMN_COUNT];
+ for (int i = 0; i < originalData.length; i++)
+ {
+ System.arraycopy(originalData[i], 0, newData[i + 1], 0,
+ COLUMN_COUNT);
+ }
+ newData[0] = row;
+ originalData = newData;
+ }
+ }
+ }
+
+ /**
+ * 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.
+ *
+ * @param foundGroups
+ */
+ protected void pruneGroups(Set<String> foundGroups)
+ {
+ for (int g = 0; g < groupPanel.getComponentCount(); g++)
+ {
+ JCheckBox checkbox = (JCheckBox) groupPanel.getComponent(g);
+ if (!foundGroups.contains(checkbox.getText()))
+ {
+ groupPanel.remove(checkbox);
+ }
+ }
+ }
+
+ /**
+ * reorder data based on the featureRenderers global priority list.
+ *
+ * @param data
*/
private void ensureOrder(Object[][] data)
{
{
order[i] = fr.getOrder(data[i][0].toString());
if (order[i] < 0)
+ {
order[i] = fr.setOrder(data[i][0].toString(), i / order.length);
+ }
if (i > 1)
+ {
sort = sort || order[i - 1] > order[i];
+ }
}
if (sort)
+ {
jalview.util.QuickSort.sort(order, data);
+ }
}
+ /**
+ * Offers a file chooser dialog, and then loads the feature colours and
+ * filters from file in XML format and unmarshals to Jalview feature settings
+ */
void load()
{
- JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
- { "fc" }, new String[]
- { "Sequence Feature Colours" }, "Sequence Feature Colours");
- chooser.setFileView(new jalview.io.JalviewFileView());
- chooser.setDialogTitle("Load Feature Colours");
+ JalviewFileChooser chooser = new JalviewFileChooser("fc",
+ SEQUENCE_FEATURE_COLOURS);
+ chooser.setFileView(new JalviewFileView());
+ chooser.setDialogTitle(
+ MessageManager.getString("label.load_feature_colours"));
chooser.setToolTipText(MessageManager.getString("action.load"));
+ chooser.setResponseHandler(0, new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ File file = chooser.getSelectedFile();
+ load(file);
+ }
+ });
+ chooser.showOpenDialog(this);
+ }
- int value = chooser.showOpenDialog(this);
-
- if (value == JalviewFileChooser.APPROVE_OPTION)
+ /**
+ * Loads feature colours and filters from XML stored in the given file
+ *
+ * @param file
+ */
+ void load(File file)
+ {
+ try
{
- File file = chooser.getSelectedFile();
+ InputStreamReader in = new InputStreamReader(
+ new FileInputStream(file), "UTF-8");
- try
- {
- InputStreamReader in = new InputStreamReader(new FileInputStream(
- file), "UTF-8");
+ JAXBContext jc = JAXBContext
+ .newInstance("jalview.xml.binding.jalview");
+ javax.xml.bind.Unmarshaller um = jc.createUnmarshaller();
+ XMLStreamReader streamReader = XMLInputFactory.newInstance()
+ .createXMLStreamReader(in);
+ JAXBElement<JalviewUserColours> jbe = um.unmarshal(streamReader,
+ JalviewUserColours.class);
+ JalviewUserColours jucs = jbe.getValue();
- jalview.schemabinding.version2.JalviewUserColours jucs = new jalview.schemabinding.version2.JalviewUserColours();
- jucs = (jalview.schemabinding.version2.JalviewUserColours) jucs
- .unmarshal(in);
+ // JalviewUserColours jucs = JalviewUserColours.unmarshal(in);
- for (int i = jucs.getColourCount() - 1; i >= 0; i--)
- {
- String name;
- jalview.schemabinding.version2.Colour newcol = jucs.getColour(i);
- if (newcol.hasMax())
- {
- Color mincol = null, maxcol = null;
- try
- {
- mincol = new Color(Integer.parseInt(newcol.getMinRGB(), 16));
- maxcol = new Color(Integer.parseInt(newcol.getRGB(), 16));
+ /*
+ * load feature colours
+ */
+ for (int i = jucs.getColour().size() - 1; i >= 0; i--)
+ {
+ Colour newcol = jucs.getColour().get(i);
+ FeatureColourI colour = jalview.project.Jalview2XML
+ .parseColour(newcol);
+ fr.setColour(newcol.getName(), colour);
+ fr.setOrder(newcol.getName(), i / (float) jucs.getColour().size());
+ }
- } catch (Exception e)
- {
- Cache.log.warn("Couldn't parse out graduated feature color.",
- e);
- }
- GraduatedColor gcol = new GraduatedColor(mincol, maxcol,
- newcol.getMin(), newcol.getMax());
- if (newcol.hasAutoScale())
- {
- gcol.setAutoScaled(newcol.getAutoScale());
- }
- if (newcol.hasColourByLabel())
- {
- gcol.setColourByLabel(newcol.getColourByLabel());
- }
- if (newcol.hasThreshold())
- {
- gcol.setThresh(newcol.getThreshold());
- gcol.setThreshType(AnnotationColourGradient.NO_THRESHOLD); // default
- }
- if (newcol.getThreshType().length() > 0)
- {
- String ttyp = newcol.getThreshType();
- if (ttyp.equalsIgnoreCase("NONE"))
- {
- gcol.setThreshType(AnnotationColourGradient.NO_THRESHOLD);
- }
- if (ttyp.equalsIgnoreCase("ABOVE"))
- {
- gcol.setThreshType(AnnotationColourGradient.ABOVE_THRESHOLD);
- }
- if (ttyp.equalsIgnoreCase("BELOW"))
- {
- gcol.setThreshType(AnnotationColourGradient.BELOW_THRESHOLD);
- }
- }
- fr.setColour(name = newcol.getName(), gcol);
- }
- else
- {
- fr.setColour(name = jucs.getColour(i).getName(), new Color(
- Integer.parseInt(jucs.getColour(i).getRGB(), 16)));
- }
- fr.setOrder(name, (i == 0) ? 0 : i / jucs.getColourCount());
- }
- if (table != null)
+ /*
+ * load feature filters; loaded filters will replace any that are
+ * currently defined, other defined filters are left unchanged
+ */
+ for (int i = 0; i < jucs.getFilter().size(); i++)
+ {
+ Filter filterModel = jucs.getFilter().get(i);
+ String featureType = filterModel.getFeatureType();
+ FeatureMatcherSetI filter = jalview.project.Jalview2XML
+ .parseFilter(featureType, filterModel.getMatcherSet());
+ if (!filter.isEmpty())
{
- resetTable(null);
- Object[][] data = ((FeatureTableModel) table.getModel())
- .getData();
- ensureOrder(data);
- updateFeatureRenderer(data, false);
- table.repaint();
+ fr.setFeatureFilter(featureType, filter);
}
- } catch (Exception ex)
+ }
+
+ /*
+ * update feature settings table
+ */
+ if (table != null)
{
- System.out.println("Error loading User Colour File\n" + ex);
+ resetTable(null);
+ Object[][] data = ((FeatureTableModel) table.getModel()).getData();
+ ensureOrder(data);
+ updateFeatureRenderer(data, false);
+ table.repaint();
}
+ } catch (Exception ex)
+ {
+ System.out.println("Error loading User Colour File\n" + ex);
}
}
+ /**
+ * Offers a file chooser dialog, and then saves the current feature colours
+ * and any filters to the selected file in XML format
+ */
void save()
{
- JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
- { "fc" }, new String[]
- { "Sequence Feature Colours" }, "Sequence Feature Colours");
- chooser.setFileView(new jalview.io.JalviewFileView());
- chooser.setDialogTitle("Save Feature Colour Scheme");
+ JalviewFileChooser chooser = new JalviewFileChooser("fc",
+ SEQUENCE_FEATURE_COLOURS);
+ chooser.setFileView(new JalviewFileView());
+ chooser.setDialogTitle(
+ 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);
+ }
+ }
- int value = chooser.showSaveDialog(this);
-
- if (value == JalviewFileChooser.APPROVE_OPTION)
+ /**
+ * Saves feature colours and filters to the given file
+ *
+ * @param file
+ */
+ void save(File file)
+ {
+ JalviewUserColours ucs = new JalviewUserColours();
+ ucs.setSchemeName("Sequence Features");
+ try
{
- String choice = chooser.getSelectedFile().getPath();
- jalview.schemabinding.version2.JalviewUserColours ucs = new jalview.schemabinding.version2.JalviewUserColours();
- ucs.setSchemeName("Sequence Features");
- try
- {
- PrintWriter out = new PrintWriter(new OutputStreamWriter(
- new FileOutputStream(choice), "UTF-8"));
+ PrintWriter out = new PrintWriter(
+ new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
- Iterator e = fr.featureColours.keySet().iterator();
- float[] sortOrder = new float[fr.featureColours.size()];
- String[] sortTypes = new String[fr.featureColours.size()];
- int i = 0;
- while (e.hasNext())
+ /*
+ * sort feature types by colour order, from 0 (highest)
+ * to 1 (lowest)
+ */
+ Set<String> fr_colours = fr.getAllFeatureColours();
+ String[] sortedTypes = fr_colours
+ .toArray(new String[fr_colours.size()]);
+ Arrays.sort(sortedTypes, new Comparator<String>()
+ {
+ @Override
+ public int compare(String type1, String type2)
{
- sortTypes[i] = e.next().toString();
- sortOrder[i] = fr.getOrder(sortTypes[i]);
- i++;
+ return Float.compare(fr.getOrder(type1), fr.getOrder(type2));
}
- jalview.util.QuickSort.sort(sortOrder, sortTypes);
- sortOrder = null;
- Object fcol;
- GraduatedColor gcol;
- for (i = 0; i < sortTypes.length; i++)
+ });
+
+ /*
+ * save feature colours
+ */
+ for (String featureType : sortedTypes)
+ {
+ FeatureColourI fcol = fr.getFeatureStyle(featureType);
+ Colour col = jalview.project.Jalview2XML.marshalColour(featureType,
+ fcol);
+ ucs.getColour().add(col);
+ }
+
+ /*
+ * save any feature filters
+ */
+ for (String featureType : sortedTypes)
+ {
+ FeatureMatcherSetI filter = fr.getFeatureFilter(featureType);
+ if (filter != null && !filter.isEmpty())
{
- jalview.schemabinding.version2.Colour col = new jalview.schemabinding.version2.Colour();
- col.setName(sortTypes[i]);
- col.setRGB(jalview.util.Format.getHexString(fr.getColour(col
- .getName())));
- fcol = fr.getFeatureStyle(sortTypes[i]);
- if (fcol instanceof GraduatedColor)
- {
- gcol = (GraduatedColor) fcol;
- col.setMin(gcol.getMin());
- col.setMax(gcol.getMax());
- col.setMinRGB(jalview.util.Format.getHexString(gcol
- .getMinColor()));
- col.setAutoScale(gcol.isAutoScale());
- col.setThreshold(gcol.getThresh());
- col.setColourByLabel(gcol.isColourByLabel());
- switch (gcol.getThreshType())
- {
- case AnnotationColourGradient.NO_THRESHOLD:
- col.setThreshType("NONE");
- break;
- case AnnotationColourGradient.ABOVE_THRESHOLD:
- col.setThreshType("ABOVE");
- break;
- case AnnotationColourGradient.BELOW_THRESHOLD:
- col.setThreshType("BELOW");
- break;
- }
- }
- ucs.addColour(col);
+ Iterator<FeatureMatcherI> iterator = filter.getMatchers()
+ .iterator();
+ FeatureMatcherI firstMatcher = iterator.next();
+ jalview.xml.binding.jalview.FeatureMatcherSet ms = jalview.project.Jalview2XML
+ .marshalFilter(firstMatcher, iterator, filter.isAnded());
+ Filter filterModel = new Filter();
+ filterModel.setFeatureType(featureType);
+ filterModel.setMatcherSet(ms);
+ ucs.getFilter().add(filterModel);
}
- ucs.marshal(out);
- out.close();
- } catch (Exception ex)
- {
- ex.printStackTrace();
}
+ JAXBContext jaxbContext = JAXBContext
+ .newInstance(JalviewUserColours.class);
+ Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
+ jaxbMarshaller.marshal(
+ new ObjectFactory().createJalviewUserColours(ucs), out);
+
+ // jaxbMarshaller.marshal(object, pout);
+ // marshaller.marshal(object);
+ out.flush();
+
+ // ucs.marshal(out);
+ out.close();
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
}
}
public void invertSelection()
{
- for (int i = 0; i < table.getRowCount(); i++)
+ Object[][] data = ((FeatureTableModel) table.getModel()).getData();
+ for (int i = 0; i < data.length; i++)
{
- Boolean value = (Boolean) table.getValueAt(i, 2);
-
- table.setValueAt(new Boolean(!value.booleanValue()), i, 2);
+ data[i][SHOW_COLUMN] = !(Boolean) data[i][SHOW_COLUMN];
}
+ updateFeatureRenderer(data, true);
+ table.repaint();
}
public void orderByAvWidth()
{
if (table == null || table.getModel() == null)
+ {
return;
+ }
Object[][] data = ((FeatureTableModel) table.getModel()).getData();
float[] width = new float[data.length];
float[] awidth;
float max = 0;
- int num = 0;
+
for (int i = 0; i < data.length; i++)
{
- awidth = (float[]) typeWidth.get(data[i][0]);
+ awidth = typeWidth.get(data[i][TYPE_COLUMN]);
if (awidth[0] > 0)
{
width[i] = awidth[1] / awidth[0];// *awidth[0]*awidth[2]; - better
// weight - but have to make per
// sequence, too (awidth[2])
// if (width[i]==1) // hack to distinguish single width sequences.
- num++;
}
else
{
width[i] = 0;
}
if (max < width[i])
+ {
max = width[i];
+ }
}
boolean sort = false;
for (int i = 0; i < width.length; i++)
// awidth = (float[]) typeWidth.get(data[i][0]);
if (width[i] == 0)
{
- width[i] = fr.getOrder(data[i][0].toString());
+ width[i] = fr.getOrder(data[i][TYPE_COLUMN].toString());
if (width[i] < 0)
{
- width[i] = fr.setOrder(data[i][0].toString(), i / data.length);
+ width[i] = fr.setOrder(data[i][TYPE_COLUMN].toString(),
+ i / data.length);
}
}
else
{
width[i] /= max; // normalize
- fr.setOrder(data[i][0].toString(), width[i]); // store for later
+ fr.setOrder(data[i][TYPE_COLUMN].toString(), width[i]); // store for
+ // later
}
if (i > 0)
+ {
sort = sort || width[i - 1] > width[i];
+ }
}
if (sort)
+ {
jalview.util.QuickSort.sort(width, data);
- // update global priority order
+ // update global priority order
+ }
updateFeatureRenderer(data, false);
table.repaint();
}
+ /**
+ * close ourselves but leave any existing UI handlers (e.g a CDS/Protein tabbed
+ * feature settings dialog) intact
+ */
+ public void closeOldSettings()
+ {
+ closeDialog(false);
+ }
+
+ /**
+ * close the feature settings dialog (and any containing frame)
+ */
public void close()
{
+ closeDialog(true);
+ }
+
+ private void closeDialog(boolean closeContainingFrame)
+ {
try
{
- frame.setClosed(true);
+ if (frame != null)
+ {
+ af.setFeatureSettingsGeometry(frame.getBounds());
+ frame.setClosed(true);
+ }
+ else
+ {
+ SplitContainerI sc = af.getSplitViewContainer();
+ sc.closeFeatureSettings(this, closeContainingFrame);
+ af.featureSettings = null;
+ }
} catch (Exception exe)
{
}
updateFeatureRenderer(data, true);
}
- private void updateFeatureRenderer(Object[][] data, boolean visibleNew)
+ /**
+ * Update the priority order of features; only repaint if this changed the
+ * order of visible features
+ *
+ * @param data
+ * @param visibleNew
+ */
+ void updateFeatureRenderer(Object[][] data, boolean visibleNew)
{
- fr.setFeaturePriority(data, visibleNew);
- af.alignPanel.paintAlignment(true);
- }
-
- int selectedRow = -1;
-
- JTabbedPane tabbedPane = new JTabbedPane();
-
- BorderLayout borderLayout1 = new BorderLayout();
-
- BorderLayout borderLayout2 = new BorderLayout();
-
- BorderLayout borderLayout3 = new BorderLayout();
-
- JPanel bigPanel = new JPanel();
-
- BorderLayout borderLayout4 = new BorderLayout();
-
- JButton invert = new JButton();
-
- JPanel buttonPanel = new JPanel();
-
- JButton cancel = new JButton();
-
- JButton ok = new JButton();
-
- JButton loadColours = new JButton();
-
- JButton saveColours = new JButton();
+ FeatureSettingsBean[] rowData = getTableAsBeans(data);
- JPanel dasButtonPanel = new JPanel();
-
- JButton fetchDAS = new JButton();
+ if (fr.setFeaturePriority(rowData, visibleNew))
+ {
+ refreshDisplay();
+ }
+ }
- JButton saveDAS = new JButton();
+ /**
+ * Converts table data into an array of data beans
+ */
+ private FeatureSettingsBean[] getTableAsBeans(Object[][] data)
+ {
+ FeatureSettingsBean[] rowData = new FeatureSettingsBean[data.length];
+ for (int i = 0; i < data.length; i++)
+ {
+ String type = (String) data[i][TYPE_COLUMN];
+ FeatureColourI colour = (FeatureColourI) data[i][COLOUR_COLUMN];
+ FeatureMatcherSetI theFilter = (FeatureMatcherSetI) data[i][FILTER_COLUMN];
+ Boolean isShown = (Boolean) data[i][SHOW_COLUMN];
+ rowData[i] = new FeatureSettingsBean(type, colour, theFilter,
+ isShown);
+ }
+ return rowData;
+ }
- JButton cancelDAS = new JButton();
+ private void jbInit() throws Exception
+ {
+ this.setLayout(new BorderLayout());
- JButton optimizeOrder = new JButton();
+ final boolean hasComplement = af.getViewport()
+ .getCodingComplement() != null;
- JButton sortByScore = new JButton();
+ JPanel settingsPane = new JPanel();
+ settingsPane.setLayout(new BorderLayout());
- JButton sortByDens = new JButton();
+ JPanel bigPanel = new JPanel();
+ bigPanel.setLayout(new BorderLayout());
- JPanel transbuttons = new JPanel(new GridLayout(4, 1));
+ groupPanel = new JPanel();
+ bigPanel.add(groupPanel, BorderLayout.NORTH);
- private void jbInit() throws Exception
- {
- this.setLayout(borderLayout1);
- settingsPane.setLayout(borderLayout2);
- dasSettingsPane.setLayout(borderLayout3);
- bigPanel.setLayout(borderLayout4);
+ JButton invert = new JButton(
+ MessageManager.getString("label.invert_selection"));
invert.setFont(JvSwingUtils.getLabelFont());
- invert.setText(MessageManager.getString("label.invert_selection"));
invert.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
invertSelection();
}
});
+
+ JButton optimizeOrder = new JButton(
+ MessageManager.getString("label.optimise_order"));
optimizeOrder.setFont(JvSwingUtils.getLabelFont());
- optimizeOrder.setText(MessageManager.getString("label.optimise_order"));
optimizeOrder.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
orderByAvWidth();
}
});
+
+ final String byScoreLabel = MessageManager.getString("label.seq_sort_by_score");
+ JButton sortByScore = new JButton(byScoreLabel);
sortByScore.setFont(JvSwingUtils.getLabelFont());
- sortByScore
- .setText(MessageManager.getString("label.seq_sort_by_score"));
sortByScore.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
- sortByScore(null);
+ if (canSortBy(byScoreLabel))
+ {
+ sortByScore(null);
+ }
}
});
+ final String byDensityLabel = MessageManager.getString("label.sequence_sort_by_density");
+ JButton sortByDens = new JButton(byDensityLabel);
sortByDens.setFont(JvSwingUtils.getLabelFont());
- sortByDens.setText(MessageManager
- .getString("label.sequence_sort_by_density"));
sortByDens.addActionListener(new ActionListener()
{
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ if (canSortBy(byDensityLabel))
+ {
+ sortByDensity(null);
+ }
+ }
+ });
+
+ JButton help = new JButton(MessageManager.getString("action.help"));
+ help.setFont(JvSwingUtils.getLabelFont());
+ help.addActionListener(new ActionListener()
+ {
+ @Override
public void actionPerformed(ActionEvent e)
{
- sortByDens(null);
+ try
+ {
+ Help.showHelpWindow(HelpId.SequenceFeatureSettings);
+ } catch (HelpSetException e1)
+ {
+ e1.printStackTrace();
+ }
}
});
+ // Cancel for a SplitFrame should just revert changes to the currently displayed
+ // settings. May want to do this for either or both - so need a splitview
+ // feature settings cancel/OK.
+ JButton cancel = new JButton(MessageManager
+ .getString(hasComplement ? "action.revert" : "action.cancel"));
+ cancel.setToolTipText(MessageManager.getString(hasComplement
+ ? "action.undo_changes_to_feature_settings"
+ : "action.undo_changes_to_feature_settings_and_close_the_dialog"));
cancel.setFont(JvSwingUtils.getLabelFont());
- cancel.setText(MessageManager.getString("action.cancel"));
+ // TODO: disable cancel (and apply!) until current settings are different
cancel.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
- updateFeatureRenderer(originalData);
- close();
+ revert();
+ refreshDisplay();
+ if (!hasComplement)
+ {
+ close();
+ }
}
});
+ // Cancel for the whole dialog should cancel both CDS and Protein.
+ // OK for an individual feature settings just applies changes, but dialog
+ // remains open
+ JButton ok = new JButton(MessageManager
+ .getString(hasComplement ? "action.apply" : "action.ok"));
ok.setFont(JvSwingUtils.getLabelFont());
- ok.setText(MessageManager.getString("action.ok"));
ok.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
- close();
+ if (!hasComplement)
+ {
+ close();
+ }
+ else
+ {
+ storeOriginalSettings();
+ }
}
});
+
+ JButton loadColours = new JButton(
+ MessageManager.getString("label.load_colours"));
loadColours.setFont(JvSwingUtils.getLabelFont());
- loadColours.setText(MessageManager.getString("label.load_colours"));
+ loadColours.setToolTipText(
+ MessageManager.getString("label.load_colours_tooltip"));
loadColours.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
load();
}
});
+
+ JButton saveColours = new JButton(
+ MessageManager.getString("label.save_colours"));
saveColours.setFont(JvSwingUtils.getLabelFont());
- saveColours.setText(MessageManager.getString("label.save_colours"));
+ saveColours.setToolTipText(
+ MessageManager.getString("label.save_colours_tooltip"));
saveColours.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
save();
});
transparency.addChangeListener(new ChangeListener()
{
+ @Override
public void stateChanged(ChangeEvent evt)
{
- fr.setTransparency((float) (100 - transparency.getValue()) / 100f);
- af.alignPanel.paintAlignment(true);
+ if (!inConstruction)
+ {
+ fr.setTransparency((100 - transparency.getValue()) / 100f);
+ refreshDisplay();
+ }
}
});
transparency.setMaximum(70);
- fetchDAS.setText(MessageManager.getString("label.fetch_das_features"));
- fetchDAS.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- fetchDAS_actionPerformed(e);
- }
- });
- saveDAS.setText(MessageManager.getString("action.save_as_default"));
- saveDAS.addActionListener(new ActionListener()
+ transparency.setToolTipText(
+ MessageManager.getString("label.transparency_tip"));
+
+ boolean nucleotide = af.getViewport().getAlignment().isNucleotide();
+ String text = MessageManager.formatMessage("label.show_linked_features",
+ nucleotide
+ ? MessageManager.getString("label.protein")
+ .toLowerCase()
+ : "CDS");
+ showComplement = new JCheckBox(text);
+ showComplement.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
- saveDAS_actionPerformed(e);
+ af.getViewport()
+ .setShowComplementFeatures(showComplement.isSelected());
+ refreshDisplay();
}
});
- dasButtonPanel.setBorder(BorderFactory.createEtchedBorder());
- dasSettingsPane.setBorder(null);
- cancelDAS.setEnabled(false);
- cancelDAS.setText(MessageManager.getString("action.cancel_fetch"));
- cancelDAS.addActionListener(new ActionListener()
+
+ showComplementOnTop = new JCheckBox(
+ MessageManager.getString("label.on_top"));
+ showComplementOnTop.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
- cancelDAS_actionPerformed(e);
+ af.getViewport().setShowComplementFeaturesOnTop(
+ showComplementOnTop.isSelected());
+ refreshDisplay();
}
});
- this.add(tabbedPane, java.awt.BorderLayout.CENTER);
- tabbedPane.addTab("Feature Settings", settingsPane);
- tabbedPane.addTab("DAS Settings", dasSettingsPane);
- bigPanel.add(transPanel, java.awt.BorderLayout.SOUTH);
+
+ updateComplementButtons();
+
+ JPanel lowerPanel = new JPanel(new GridLayout(1, 2));
+ bigPanel.add(lowerPanel, BorderLayout.SOUTH);
+
+ JPanel transbuttons = new JPanel(new GridLayout(5, 1));
transbuttons.add(optimizeOrder);
transbuttons.add(invert);
transbuttons.add(sortByScore);
transbuttons.add(sortByDens);
- transPanel.add(transparency);
- transPanel.add(transbuttons);
- buttonPanel.add(ok);
- buttonPanel.add(cancel);
- buttonPanel.add(loadColours);
- buttonPanel.add(saveColours);
- bigPanel.add(scrollPane, java.awt.BorderLayout.CENTER);
- dasSettingsPane.add(dasButtonPanel, java.awt.BorderLayout.SOUTH);
- dasButtonPanel.add(fetchDAS);
- dasButtonPanel.add(cancelDAS);
- dasButtonPanel.add(saveDAS);
- settingsPane.add(bigPanel, java.awt.BorderLayout.CENTER);
- settingsPane.add(buttonPanel, java.awt.BorderLayout.SOUTH);
- }
-
- protected void sortByDens(String[] typ)
- {
- sortBy(typ, "Sort by Density", AlignmentSorter.FEATURE_DENSITY);
- }
-
- protected void sortBy(String[] typ, String methodText, final String method)
- {
- if (typ == null)
- {
- typ = getDisplayedFeatureTypes();
- }
- String gps[] = null;
- gps = getDisplayedFeatureGroups();
- if (typ != null)
- {
- ArrayList types = new ArrayList();
- for (int i = 0; i < typ.length; i++)
- {
- if (typ[i] != null)
- {
- types.add(typ[i]);
- }
- typ = new String[types.size()];
- types.toArray(typ);
- }
- }
- if (gps != null)
- {
- ArrayList grps = new ArrayList();
-
- for (int i = 0; i < gps.length; i++)
- {
- if (gps[i] != null)
- {
- grps.add(gps[i]);
- }
- }
- gps = new String[grps.size()];
- grps.toArray(gps);
- }
- AlignmentPanel alignPanel = af.alignPanel;
- AlignmentI al = alignPanel.av.getAlignment();
-
- int start, stop;
- SequenceGroup sg = alignPanel.av.getSelectionGroup();
- if (sg != null)
- {
- start = sg.getStartRes();
- stop = sg.getEndRes();
- }
- else
- {
- start = 0;
- stop = al.getWidth();
- }
- SequenceI[] oldOrder = al.getSequencesArray();
- AlignmentSorter.sortByFeature(typ, gps, start, stop, al, method);
- af.addHistoryItem(new OrderCommand(methodText, oldOrder, alignPanel.av
- .getAlignment()));
- alignPanel.paintAlignment(true);
-
- }
-
- protected void sortByScore(String[] typ)
- {
- sortBy(typ, "Sort by Feature Score", AlignmentSorter.FEATURE_SCORE);
- }
-
- private String[] getDisplayedFeatureTypes()
- {
- String[] typ = null;
- if (fr != null)
- {
- synchronized (fr.renderOrder)
- {
- typ = new String[fr.renderOrder.length];
- System.arraycopy(fr.renderOrder, 0, typ, 0, typ.length);
- for (int i = 0; i < typ.length; i++)
- {
- if (af.viewport.featuresDisplayed.get(typ[i]) == null)
- {
- typ[i] = null;
- }
- }
- }
- }
- return typ;
- }
-
- private String[] getDisplayedFeatureGroups()
- {
- String[] gps = null;
- ArrayList<String> _gps = new ArrayList<String>();
- if (fr != null)
- {
-
- if (fr.featureGroups != null)
- {
- Iterator en = fr.featureGroups.keySet().iterator();
- int g = 0;
- boolean valid = false;
- while (en.hasNext())
- {
- String gp = (String) en.next();
- Boolean on = (Boolean) fr.featureGroups.get(gp);
- if (on != null && on.booleanValue())
- {
- valid = true;
- _gps.add(gp);
- }
- }
- if (!valid)
- {
- return null;
- }
- else
- {
- gps = new String[_gps.size()];
- _gps.toArray(gps);
- }
- }
- }
- return gps;
- }
-
- public void fetchDAS_actionPerformed(ActionEvent e)
- {
- fetchDAS.setEnabled(false);
- cancelDAS.setEnabled(true);
- dassourceBrowser.setGuiEnabled(false);
- Vector selectedSources = dassourceBrowser.getSelectedSources();
- doDasFeatureFetch(selectedSources, true, true);
- }
-
- /**
- * get the features from selectedSources for all or the current selection
- *
- * @param selectedSources
- * @param checkDbRefs
- * @param promptFetchDbRefs
- */
- private void doDasFeatureFetch(List<jalviewSourceI> selectedSources,
- boolean checkDbRefs, boolean promptFetchDbRefs)
- {
- SequenceI[] dataset, seqs;
- int iSize;
- AlignViewport vp = af.getViewport();
- if (vp.getSelectionGroup() != null
- && vp.getSelectionGroup().getSize() > 0)
- {
- iSize = vp.getSelectionGroup().getSize();
- dataset = new SequenceI[iSize];
- seqs = vp.getSelectionGroup().getSequencesInOrder(vp.getAlignment());
- }
- else
- {
- iSize = vp.getAlignment().getHeight();
- seqs = vp.getAlignment().getSequencesArray();
- }
+ transbuttons.add(help);
- dataset = new SequenceI[iSize];
- for (int i = 0; i < iSize; i++)
+ JPanel transPanelLeft = new JPanel(
+ new GridLayout(hasComplement ? 4 : 2, 1));
+ transPanelLeft.add(new JLabel(" Colour transparency" + ":"));
+ transPanelLeft.add(transparency);
+ if (hasComplement)
{
- dataset[i] = seqs[i].getDatasetSequence();
+ JPanel cp = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ cp.add(showComplement);
+ cp.add(showComplementOnTop);
+ transPanelLeft.add(cp);
}
+ lowerPanel.add(transPanelLeft);
+ lowerPanel.add(transbuttons);
- cancelDAS.setEnabled(true);
- dasFeatureFetcher = new jalview.ws.DasSequenceFeatureFetcher(dataset,
- this, selectedSources, checkDbRefs, promptFetchDbRefs);
- af.getViewport().setShowSequenceFeatures(true);
- af.showSeqFeatures.setSelected(true);
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.add(ok);
+ buttonPanel.add(cancel);
+ buttonPanel.add(loadColours);
+ buttonPanel.add(saveColours);
+ bigPanel.add(scrollPane, BorderLayout.CENTER);
+ settingsPane.add(bigPanel, BorderLayout.CENTER);
+ settingsPane.add(buttonPanel, BorderLayout.SOUTH);
+ this.add(settingsPane);
}
/**
- * blocking call to initialise the das source browser
+ * Repaints alignment, structure and overview (if shown). If there is a
+ * complementary view which is showing this view's features, then also
+ * repaints that.
*/
- public void initDasSources()
+ void refreshDisplay()
{
- dassourceBrowser.initDasSources();
+ af.alignPanel.paintAlignment(true, true);
+ AlignViewportI complement = af.getViewport().getCodingComplement();
+ if (complement != null && complement.isShowComplementFeatures())
+ {
+ AlignFrame af2 = Desktop.getAlignFrameFor(complement);
+ af2.alignPanel.paintAlignment(true, true);
+ }
}
/**
- * examine the current list of das sources and return any matching the given
- * nicknames in sources
+ * Answers a suitable tooltip to show on the colour cell of the table
*
- * @param sources
- * Vector of Strings to resolve to DAS source nicknames.
- * @return sources that are present in source list.
+ * @param fcol
+ * @param withHint
+ * if true include 'click to edit' and similar text
+ * @return
*/
- public List<jalviewSourceI> resolveSourceNicknames(Vector sources)
+ public static String getColorTooltip(FeatureColourI fcol,
+ boolean withHint)
{
- return dassourceBrowser.sourceRegistry.resolveSourceNicknames(sources);
+ if (fcol == null)
+ {
+ return null;
+ }
+ if (fcol.isSimpleColour())
+ {
+ return withHint ? BASE_TOOLTIP : null;
+ }
+ String description = fcol.getDescription();
+ description = description.replaceAll("<", "<");
+ description = description.replaceAll(">", ">");
+ StringBuilder tt = new StringBuilder(description);
+ if (withHint)
+ {
+ tt.append("<br>").append(BASE_TOOLTIP).append("</br>");
+ }
+ return JvSwingUtils.wrapTooltip(true, tt.toString());
}
- /**
- * get currently selected das sources. ensure you have called initDasSources
- * before calling this.
- *
- * @return vector of selected das source nicknames
- */
- public Vector getSelectedSources()
+ public static void renderGraduatedColor(JLabel comp, FeatureColourI gcol,
+ int w, int h)
{
- return dassourceBrowser.getSelectedSources();
- }
+ boolean thr = false;
+ StringBuilder tx = new StringBuilder();
- /**
- * properly initialise DAS fetcher and then initiate a new thread to fetch
- * features from the named sources (rather than any turned on by default)
- *
- * @param sources
- * @param block
- * if true then runs in same thread, otherwise passes to the Swing
- * executor
- */
- public void fetchDasFeatures(Vector sources, boolean block)
- {
- initDasSources();
- List<jalviewSourceI> resolved = dassourceBrowser.sourceRegistry
- .resolveSourceNicknames(sources);
- if (resolved.size() == 0)
+ if (gcol.isColourByAttribute())
{
- resolved = dassourceBrowser.getSelectedSources();
+ tx.append(FeatureMatcher
+ .toAttributeDisplayName(gcol.getAttributeName()));
}
- if (resolved.size() > 0)
+ else if (!gcol.isColourByLabel())
{
- final List<jalviewSourceI> dassources = resolved;
- fetchDAS.setEnabled(false);
- // cancelDAS.setEnabled(true); doDasFetch does this.
- Runnable fetcher = new Runnable()
- {
-
- public void run()
- {
- doDasFeatureFetch(dassources, true, false);
-
- }
- };
- if (block)
+ tx.append(MessageManager.getString("label.score"));
+ }
+ tx.append(" ");
+ if (gcol.isAboveThreshold())
+ {
+ thr = true;
+ tx.append(">");
+ }
+ if (gcol.isBelowThreshold())
+ {
+ thr = true;
+ tx.append("<");
+ }
+ if (gcol.isColourByLabel())
+ {
+ if (thr)
{
- fetcher.run();
+ tx.append(" ");
}
- else
+ if (!gcol.isColourByAttribute())
{
- SwingUtilities.invokeLater(fetcher);
+ tx.append("Label");
}
+ comp.setIcon(null);
}
- }
-
- public void saveDAS_actionPerformed(ActionEvent e)
- {
- dassourceBrowser
- .saveProperties(jalview.bin.Cache.applicationProperties);
- }
-
- public void complete()
- {
- fetchDAS.setEnabled(true);
- cancelDAS.setEnabled(false);
- dassourceBrowser.setGuiEnabled(true);
-
- }
-
- public void cancelDAS_actionPerformed(ActionEvent e)
- {
- if (dasFeatureFetcher != null)
+ else
{
- dasFeatureFetcher.cancel();
+ Color newColor = gcol.getMaxColour();
+ comp.setBackground(newColor);
+ // System.err.println("Width is " + w / 2);
+ Icon ficon = new FeatureIcon(gcol, comp.getBackground(), w, h, thr);
+ comp.setIcon(ficon);
+ // tt+="RGB value: Max (" + newColor.getRed() + ", "
+ // + newColor.getGreen() + ", " + newColor.getBlue()
+ // + ")\nMin (" + minCol.getRed() + ", " + minCol.getGreen()
+ // + ", " + minCol.getBlue() + ")");
}
- complete();
- }
-
- public void noDasSourceActive()
- {
- complete();
- JOptionPane
- .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);
+ comp.setHorizontalAlignment(SwingConstants.CENTER);
+ comp.setText(tx.toString());
}
// ///////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////
class FeatureTableModel extends AbstractTableModel
{
+ private String[] columnNames = {
+ MessageManager.getString("label.feature_type"),
+ MessageManager.getString("action.colour"),
+ MessageManager.getString("label.configuration"),
+ MessageManager.getString("label.show") };
+
+ private Object[][] data;
+
FeatureTableModel(Object[][] data)
{
this.data = data;
}
- private String[] columnNames =
- { "Feature Type", "Colour", "Display" };
-
- private Object[][] data;
-
public Object[][] getData()
{
return data;
this.data = data;
}
+ @Override
public int getColumnCount()
{
return columnNames.length;
return data[row];
}
+ @Override
public int getRowCount()
{
return data.length;
}
+ @Override
public String getColumnName(int col)
{
return columnNames[col];
}
+ @Override
public Object getValueAt(int row, int col)
{
return data[row][col];
}
- public Class getColumnClass(int c)
+ /**
+ * Answers the class of column c of the table
+ */
+ @Override
+ public Class<?> getColumnClass(int c)
{
- return getValueAt(0, c).getClass();
+ switch (c)
+ {
+ case TYPE_COLUMN:
+ return String.class;
+ case COLOUR_COLUMN:
+ return FeatureColour.class;
+ case FILTER_COLUMN:
+ return FeatureMatcherSet.class;
+ default:
+ return Boolean.class;
+ }
}
+ @Override
public boolean isCellEditable(int row, int col)
{
return col == 0 ? false : true;
}
+ @Override
public void setValueAt(Object value, int row, int col)
{
data[row][col] = value;
class ColorRenderer extends JLabel implements TableCellRenderer
{
- javax.swing.border.Border unselectedBorder = null;
-
- javax.swing.border.Border selectedBorder = null;
+ Border unselectedBorder = null;
- final String baseTT = "Click to edit, right/apple click for menu.";
+ Border selectedBorder = null;
public ColorRenderer()
{
setVerticalTextPosition(SwingConstants.CENTER);
}
- public Component getTableCellRendererComponent(JTable table,
- Object color, boolean isSelected, boolean hasFocus, int row,
- int column)
+ @Override
+ public Component getTableCellRendererComponent(JTable tbl, Object color,
+ boolean isSelected, boolean hasFocus, int row, int column)
{
- // JLabel comp = new JLabel();
- // comp.
+ FeatureColourI cellColour = (FeatureColourI) color;
setOpaque(true);
- // comp.
- // setBounds(getBounds());
- Color newColor;
- setToolTipText(baseTT);
- setBackground(table.getBackground());
- if (color instanceof GraduatedColor)
- {
- Rectangle cr = table.getCellRect(row, column, false);
- FeatureSettings.renderGraduatedColor(this, (GraduatedColor) color,
+ setBackground(tbl.getBackground());
+ if (!cellColour.isSimpleColour())
+ {
+ Rectangle cr = tbl.getCellRect(row, column, false);
+ FeatureSettings.renderGraduatedColor(this, cellColour,
(int) cr.getWidth(), (int) cr.getHeight());
-
}
else
{
this.setText("");
this.setIcon(null);
- newColor = (Color) color;
- // comp.
- setBackground(newColor);
- // comp.setToolTipText("RGB value: " + newColor.getRed() + ", "
- // + newColor.getGreen() + ", " + newColor.getBlue());
+ setBackground(cellColour.getColour());
+ }
+ if (isSelected)
+ {
+ if (selectedBorder == null)
+ {
+ selectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5,
+ tbl.getSelectionBackground());
+ }
+ setBorder(selectedBorder);
+ }
+ else
+ {
+ if (unselectedBorder == null)
+ {
+ unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5,
+ tbl.getBackground());
+ }
+ setBorder(unselectedBorder);
}
+
+ return this;
+ }
+ }
+
+ class FilterRenderer extends JLabel implements TableCellRenderer
+ {
+ javax.swing.border.Border unselectedBorder = null;
+
+ javax.swing.border.Border selectedBorder = null;
+
+ public FilterRenderer()
+ {
+ setOpaque(true); // MUST do this for background to show up.
+ setHorizontalTextPosition(SwingConstants.CENTER);
+ setVerticalTextPosition(SwingConstants.CENTER);
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable tbl,
+ Object filter, boolean isSelected, boolean hasFocus, int row,
+ int column)
+ {
+ FeatureMatcherSetI theFilter = (FeatureMatcherSetI) filter;
+ setOpaque(true);
+ String asText = theFilter.toString();
+ setBackground(tbl.getBackground());
+ this.setText(asText);
+ this.setIcon(null);
+
if (isSelected)
{
if (selectedBorder == null)
{
selectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5,
- table.getSelectionBackground());
+ tbl.getSelectionBackground());
}
- // comp.
setBorder(selectedBorder);
}
else
if (unselectedBorder == null)
{
unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5,
- table.getBackground());
+ tbl.getBackground());
}
- // comp.
setBorder(unselectedBorder);
}
* @param comp
* @param gcol
*/
- public static void renderGraduatedColor(JLabel comp, GraduatedColor gcol)
+ public static void renderGraduatedColor(JLabel comp, FeatureColourI gcol)
{
int w = comp.getWidth(), h = comp.getHeight();
if (w < 20)
renderGraduatedColor(comp, gcol, w, h);
}
- public static void renderGraduatedColor(JLabel comp, GraduatedColor gcol,
- int w, int h)
+ @SuppressWarnings("serial")
+ class ColorEditor extends AbstractCellEditor
+ implements TableCellEditor, ActionListener
{
- boolean thr = false;
- String tt = "";
- String tx = "";
- if (gcol.getThreshType() == AnnotationColourGradient.ABOVE_THRESHOLD)
+ FeatureColourI currentColor;
+
+ FeatureTypeSettings chooser;
+
+ String type;
+
+ JButton button;
+
+ protected static final String EDIT = "edit";
+
+ int rowSelected = 0;
+
+ public ColorEditor()
{
- thr = true;
- tx += ">";
- tt += "Thresholded (Above " + gcol.getThresh() + ") ";
+ // Set up the editor (from the table's point of view),
+ // which is a button.
+ // This button brings up the color chooser dialog,
+ // which is the editor from the user's point of view.
+ button = new JButton();
+ button.setActionCommand(EDIT);
+ button.addActionListener(this);
+ button.setBorderPainted(false);
}
- if (gcol.getThreshType() == AnnotationColourGradient.BELOW_THRESHOLD)
+
+ /**
+ * Handles events from the editor button, and from the colour/filters
+ * dialog's OK button
+ */
+ @Override
+ public void actionPerformed(ActionEvent e)
{
- thr = true;
- tx += "<";
- tt += "Thresholded (Below " + gcol.getThresh() + ") ";
+ if (button == e.getSource())
+ {
+ if (currentColor.isSimpleColour())
+ {
+ /*
+ * simple colour chooser
+ */
+ String ttl = MessageManager
+ .formatMessage("label.select_colour_for", type);
+ ColourChooserListener listener = new ColourChooserListener()
+ {
+ @Override
+ public void colourSelected(Color c)
+ {
+ currentColor = new FeatureColour(c);
+ table.setValueAt(currentColor, rowSelected, COLOUR_COLUMN);
+ fireEditingStopped();
+ }
+
+ @Override
+ public void cancel()
+ {
+ fireEditingStopped();
+ }
+ };
+ JalviewColourChooser.showColourChooser(button, ttl,
+ currentColor.getColour(), listener);
+ }
+ else
+ {
+ /*
+ * variable colour and filters dialog
+ */
+ chooser = new FeatureTypeSettings(fr, type);
+ if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
+ {
+ chooser.setRequestFocusEnabled(true);
+ chooser.requestFocus();
+ }
+ chooser.addActionListener(this);
+ fireEditingStopped();
+ }
+ }
+ else
+ {
+ /*
+ * after OK in variable colour dialog, any changes to colour
+ * (or filters!) are already set in FeatureRenderer, so just
+ * update table data without triggering updateFeatureRenderer
+ */
+ currentColor = fr.getFeatureColours().get(type);
+ FeatureMatcherSetI currentFilter = fr.getFeatureFilter(type);
+ if (currentFilter == null)
+ {
+ 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,
+ // 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
+ table.validate();
+ table.repaint();
+ }
}
- if (gcol.isColourByLabel())
+
+ /**
+ * Override allows access to this method from anonymous inner classes
+ */
+ @Override
+ protected void fireEditingStopped()
{
- tt = "Coloured by label text. " + tt;
- if (thr)
+ super.fireEditingStopped();
+ }
+
+ // Implement the one CellEditor method that AbstractCellEditor doesn't.
+ @Override
+ public Object getCellEditorValue()
+ {
+ return currentColor;
+ }
+
+ // Implement the one method defined by TableCellEditor.
+ @Override
+ public Component getTableCellEditorComponent(JTable theTable,
+ Object value, boolean isSelected, int row, int column)
+ {
+ currentColor = (FeatureColourI) value;
+ this.rowSelected = row;
+ type = table.getValueAt(row, TYPE_COLUMN).toString();
+ button.setOpaque(true);
+ button.setBackground(FeatureSettings.this.getBackground());
+ if (!currentColor.isSimpleColour())
{
- tx += " ";
+ JLabel btn = new JLabel();
+ btn.setSize(button.getSize());
+ FeatureSettings.renderGraduatedColor(btn, currentColor);
+ button.setBackground(btn.getBackground());
+ button.setIcon(btn.getIcon());
+ button.setText(btn.getText());
}
- tx += "Label";
- comp.setIcon(null);
+ else
+ {
+ button.setText("");
+ button.setIcon(null);
+ button.setBackground(currentColor.getColour());
+ }
+ return button;
}
- else
+ }
+
+ /**
+ * 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.
+ */
+ @SuppressWarnings("serial")
+ class FilterEditor extends AbstractCellEditor
+ implements TableCellEditor, ActionListener
+ {
+
+ FeatureMatcherSetI currentFilter;
+
+ Point lastLocation;
+
+ String type;
+
+ JButton button;
+
+ protected static final String EDIT = "edit";
+
+ int rowSelected = 0;
+
+ public FilterEditor()
{
- Color newColor = gcol.getMaxColor();
- comp.setBackground(newColor);
- // System.err.println("Width is " + w / 2);
- Icon ficon = new FeatureIcon(gcol, comp.getBackground(), w, h, thr);
- comp.setIcon(ficon);
- // tt+="RGB value: Max (" + newColor.getRed() + ", "
- // + newColor.getGreen() + ", " + newColor.getBlue()
- // + ")\nMin (" + minCol.getRed() + ", " + minCol.getGreen()
- // + ", " + minCol.getBlue() + ")");
+ button = new JButton();
+ button.setActionCommand(EDIT);
+ button.addActionListener(this);
+ button.setBorderPainted(false);
}
- comp.setHorizontalAlignment(SwingConstants.CENTER);
- comp.setText(tx);
- if (tt.length() > 0)
+
+ /**
+ * Handles events from the editor button
+ */
+ @Override
+ public void actionPerformed(ActionEvent e)
{
- if (comp.getToolTipText() == null)
+ if (button == e.getSource())
{
- comp.setToolTipText(tt);
+ FeatureTypeSettings chooser = new FeatureTypeSettings(fr, type);
+ chooser.addActionListener(this);
+ chooser.setRequestFocusEnabled(true);
+ chooser.requestFocus();
+ if (lastLocation != null)
+ {
+ // todo open at its last position on screen
+ chooser.setBounds(lastLocation.x, lastLocation.y,
+ chooser.getWidth(), chooser.getHeight());
+ chooser.validate();
+ }
+ fireEditingStopped();
}
- else
+ else if (e.getSource() instanceof Component)
{
- comp.setToolTipText(tt + " " + comp.getToolTipText());
+
+ /*
+ * after OK in variable colour dialog, any changes to filter
+ * (or colours!) are already set in FeatureRenderer, so just
+ * update table data without triggering updateFeatureRenderer
+ */
+ FeatureColourI currentColor = fr.getFeatureColours().get(type);
+ currentFilter = fr.getFeatureFilter(type);
+ if (currentFilter == null)
+ {
+ 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,
+ // 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
+ table.validate();
+ table.repaint();
}
}
+
+ @Override
+ public Object getCellEditorValue()
+ {
+ return currentFilter;
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable theTable,
+ Object value, boolean isSelected, int row, int column)
+ {
+ currentFilter = (FeatureMatcherSetI) value;
+ this.rowSelected = row;
+ type = table.getValueAt(row, TYPE_COLUMN).toString();
+ button.setOpaque(true);
+ button.setBackground(FeatureSettings.this.getBackground());
+ button.setText(currentFilter.toString());
+ button.setIcon(null);
+ return button;
+ }
+ }
+
+ public boolean isOpen()
+ {
+ if (af.getSplitViewContainer() != null)
+ {
+ return af.getSplitViewContainer().isFeatureSettingsOpen();
+ }
+ return frame != null && !frame.isClosed();
+ }
+
+ @Override
+ public void revert()
+ {
+ fr.setTransparency(originalTransparency);
+ fr.setFeatureFilters(originalFilters);
+ updateFeatureRenderer(originalData);
+ af.getViewport().setViewStyle(originalViewStyle);
+ updateTransparencySliderFromFR();
+ updateComplementButtons();
+ refreshDisplay();
}
}
class FeatureIcon implements Icon
{
- GraduatedColor gcol;
+ FeatureColourI gcol;
Color backg;
Color mpcolour = Color.white;
- FeatureIcon(GraduatedColor gfc, Color bg, int w, int h, boolean mspace)
+ FeatureIcon(FeatureColourI gfc, Color bg, int w, int h, boolean mspace)
{
gcol = gfc;
backg = bg;
}
}
+ @Override
public int getIconWidth()
{
return width;
}
+ @Override
public int getIconHeight()
{
return height;
}
+ @Override
public void paintIcon(Component c, Graphics g, int x, int y)
{
g.setColor(backg);
g.fillRect(0, 0, width, height);
// need an icon here.
- g.setColor(gcol.getMaxColor());
+ g.setColor(gcol.getMaxColour());
g.setFont(new Font("Verdana", Font.PLAIN, 9));
}
else
{
- Color minCol = gcol.getMinColor();
+ Color minCol = gcol.getMinColour();
g.setColor(minCol);
g.fillRect(0, 0, s1, height);
if (midspace)
g.setColor(Color.white);
g.fillRect(s1, 0, e1 - s1, height);
}
- g.setColor(gcol.getMaxColor());
- g.fillRect(0, e1, width - e1, height);
- }
- }
-}
-
-class ColorEditor extends AbstractCellEditor implements TableCellEditor,
- ActionListener
-{
- FeatureSettings me;
-
- GraduatedColor currentGColor;
-
- FeatureColourChooser chooser;
-
- String type;
-
- Color currentColor;
-
- JButton button;
-
- JColorChooser colorChooser;
-
- JDialog dialog;
-
- protected static final String EDIT = "edit";
-
- int selectedRow = 0;
-
- public ColorEditor(FeatureSettings me)
- {
- this.me = me;
- // Set up the editor (from the table's point of view),
- // which is a button.
- // This button brings up the color chooser dialog,
- // which is the editor from the user's point of view.
- button = new JButton();
- button.setActionCommand(EDIT);
- button.addActionListener(this);
- button.setBorderPainted(false);
- // Set up the dialog that the button brings up.
- colorChooser = new JColorChooser();
- dialog = JColorChooser.createDialog(button, "Select new Colour", true, // modal
- colorChooser, this, // OK button handler
- null); // no CANCEL button handler
- }
-
- /**
- * Handles events from the editor button and from the dialog's OK button.
- */
- public void actionPerformed(ActionEvent e)
- {
-
- if (EDIT.equals(e.getActionCommand()))
- {
- // The user has clicked the cell, so
- // bring up the dialog.
- if (currentColor != null)
- {
- // bring up simple color chooser
- button.setBackground(currentColor);
- colorChooser.setColor(currentColor);
- dialog.setVisible(true);
- }
- else
- {
- // bring up graduated chooser.
- chooser = new FeatureColourChooser(me.fr, type);
- chooser.setRequestFocusEnabled(true);
- chooser.requestFocus();
- chooser.addActionListener(this);
- }
- // Make the renderer reappear.
- fireEditingStopped();
-
- }
- else
- { // User pressed dialog's "OK" button.
- if (currentColor != null)
- {
- currentColor = colorChooser.getColor();
- }
- else
- {
- // class cast exceptions may be raised if the chooser created on a
- // non-graduated color
- currentGColor = (GraduatedColor) chooser.getLastColour();
- }
- me.table.setValueAt(getCellEditorValue(), selectedRow, 1);
- fireEditingStopped();
- me.table.validate();
- }
- }
-
- // Implement the one CellEditor method that AbstractCellEditor doesn't.
- public Object getCellEditorValue()
- {
- if (currentColor == null)
- {
- return currentGColor;
- }
- return currentColor;
- }
-
- // Implement the one method defined by TableCellEditor.
- public Component getTableCellEditorComponent(JTable table, Object value,
- boolean isSelected, int row, int column)
- {
- currentGColor = null;
- currentColor = null;
- this.selectedRow = row;
- type = me.table.getValueAt(row, 0).toString();
- button.setOpaque(true);
- button.setBackground(me.getBackground());
- if (value instanceof GraduatedColor)
- {
- currentGColor = (GraduatedColor) value;
- JLabel btn = new JLabel();
- btn.setSize(button.getSize());
- FeatureSettings.renderGraduatedColor(btn, currentGColor);
- button.setBackground(btn.getBackground());
- button.setIcon(btn.getIcon());
- button.setText(btn.getText());
- }
- else
- {
- button.setText("");
- button.setIcon(null);
- currentColor = (Color) value;
- button.setBackground(currentColor);
+ g.setColor(gcol.getMaxColour());
+ // g.fillRect(0, e1, width - e1, height); // BH 2018
+ g.fillRect(e1, 0, width - e1, height);
}
- return button;
}
}