import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceI;
import jalview.util.MessageManager;
+import jalview.viewmodel.seqfeatures.FeatureRendererModel.FeatureSettingsBean;
import java.awt.BorderLayout;
import java.awt.Button;
import java.util.Map;
import java.util.Set;
-public class FeatureSettings extends Panel implements ItemListener,
- MouseListener, MouseMotionListener, ActionListener,
+public class FeatureSettings extends Panel
+ implements ItemListener, MouseListener, MouseMotionListener,
AdjustmentListener, FeatureSettingsControllerI
{
FeatureRenderer fr;
add(scrollPane, BorderLayout.CENTER);
}
- Button invert = new Button("Invert Selection");
- invert.addActionListener(this);
+ Button invert = new Button(
+ MessageManager.getString("label.invert_selection"));
+ invert.addActionListener(new ActionListener()
+ {
+
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ invertSelection();
+ }
+ });
Panel lowerPanel = new Panel(new GridLayout(2, 1, 5, 10));
lowerPanel.add(invert);
add(lowerPanel, BorderLayout.SOUTH);
- groupPanel.setLayout(new GridLayout(
- (fr.getFeatureGroupsSize()) / 4 + 1, 4)); // JBPNote - this was
- // scaled on number of
- // visible groups. seems
- // broken
+ groupPanel.setLayout(
+ new GridLayout((fr.getFeatureGroupsSize()) / 4 + 1, 4)); // JBPNote
+ // - this
+ // was
+ // scaled
+ // on
+ // number
+ // of
+ // visible
+ // groups.
+ // seems
+ // broken
groupPanel.validate();
add(groupPanel, BorderLayout.NORTH);
public void paint(Graphics g)
{
g.setColor(Color.black);
- g.drawString(MessageManager
- .getString("label.no_features_added_to_this_alignment"), 10, 20);
- g.drawString(MessageManager
- .getString("label.features_can_be_added_from_searches_1"), 10,
- 40);
- g.drawString(MessageManager
- .getString("label.features_can_be_added_from_searches_2"), 10,
- 60);
+ g.drawString(MessageManager.getString(
+ "label.no_features_added_to_this_alignment"), 10, 20);
+ g.drawString(MessageManager.getString(
+ "label.features_can_be_added_from_searches_1"), 10, 40);
+ g.drawString(MessageManager.getString(
+ "label.features_can_be_added_from_searches_2"), 10, 60);
}
protected void popupSort(final MyCheckbox check,
{
final String type = check.type;
final FeatureColourI typeCol = fr.getFeatureStyle(type);
- PopupMenu men = new PopupMenu(MessageManager.formatMessage(
- "label.settings_for_type", new String[] { type }));
+ PopupMenu men = new PopupMenu(MessageManager
+ .formatMessage("label.settings_for_type", new String[]
+ { type }));
java.awt.MenuItem scr = new MenuItem(
MessageManager.getString("label.sort_by_score"));
men.add(scr);
@Override
public void actionPerformed(ActionEvent e)
{
- me.ap.alignFrame.avc.sortAlignmentByFeatureScore(Arrays
- .asList(new String[] { type }));
+ me.ap.alignFrame.avc
+ .sortAlignmentByFeatureScore(Arrays.asList(new String[]
+ { type }));
}
});
@Override
public void actionPerformed(ActionEvent e)
{
- me.ap.alignFrame.avc.sortAlignmentByFeatureDensity(Arrays
- .asList(new String[] { type }));
+ me.ap.alignFrame.avc
+ .sortAlignmentByFeatureDensity(Arrays.asList(new String[]
+ { type }));
}
});
});
men.add(selectContaining);
- MenuItem selectNotContaining = new MenuItem(
- MessageManager.getString("label.select_columns_not_containing"));
+ MenuItem selectNotContaining = new MenuItem(MessageManager
+ .getString("label.select_columns_not_containing"));
selectNotContaining.addActionListener(new ActionListener()
{
@Override
// Group selection states
void resetTable(boolean groupsChanged)
{
- List<String> displayableTypes = new ArrayList<String>();
- Set<String> foundGroups = new HashSet<String>();
+ List<String> displayableTypes = new ArrayList<>();
+ Set<String> foundGroups = new HashSet<>();
AlignmentI alignment = av.getAlignment();
* and keep track of which groups are visible
*/
Set<String> groups = seq.getFeatures().getFeatureGroups(true);
- Set<String> visibleGroups = new HashSet<String>();
+ Set<String> visibleGroups = new HashSet<>();
for (String group : groups)
{
// if (group == null || fr.checkGroupVisibility(group, true))
addCheck(groupsChanged, type);
}
- featurePanel.setLayout(new GridLayout(featurePanel.getComponentCount(),
- 1, 10, 5));
+ featurePanel.setLayout(
+ new GridLayout(featurePanel.getComponentCount(), 1, 10, 5));
featurePanel.validate();
if (scrollPane != null)
}
}
- @Override
- public void actionPerformed(ActionEvent evt)
+ protected void invertSelection()
{
for (int i = 0; i < featurePanel.getComponentCount(); i++)
{
Checkbox check = (Checkbox) featurePanel.getComponent(i);
check.setState(!check.getState());
}
- selectionChanged();
+ selectionChanged(true);
}
private ItemListener groupItemListener = new ItemListener()
@Override
public void itemStateChanged(ItemEvent evt)
{
- selectionChanged();
+ selectionChanged(true);
}
- void selectionChanged()
+ void selectionChanged(boolean updateOverview)
{
Component[] comps = featurePanel.getComponents();
int cSize = comps.length;
-
- Object[][] tmp = new Object[cSize][3];
- int tmpSize = 0;
- for (int i = 0; i < cSize; i++)
- {
- MyCheckbox check = (MyCheckbox) comps[i];
- tmp[tmpSize][0] = check.type;
- tmp[tmpSize][1] = fr.getFeatureStyle(check.type);
- tmp[tmpSize][2] = new Boolean(check.getState());
- tmpSize++;
+ FeatureSettingsBean[] rowData = new FeatureSettingsBean[cSize];
+ int i = 0;
+ for (Component comp : comps)
+ {
+ MyCheckbox check = (MyCheckbox) comp;
+ // feature filter set to null as not (yet) offered in applet
+ FeatureColourI colour = fr.getFeatureStyle(check.type);
+ rowData[i] = new FeatureSettingsBean(check.type, colour, null,
+ check.getState());
+ i++;
}
- Object[][] data = new Object[tmpSize][3];
- System.arraycopy(tmp, 0, data, 0, tmpSize);
-
- fr.setFeaturePriority(data);
+ fr.setFeaturePriority(rowData);
- ap.paintAlignment(true);
+ ap.paintAlignment(updateOverview, updateOverview);
}
MyCheckbox selectedCheck;
}
else
{
- comp = featurePanel.getComponentAt(evt.getX(), evt.getY()
- + evt.getComponent().getLocation().y);
+ comp = featurePanel.getComponentAt(evt.getX(),
+ evt.getY() + evt.getComponent().getLocation().y);
}
if (comp != null && comp instanceof Checkbox)
{
featurePanel.removeAll();
resetTable(false);
- ap.paintAlignment(true);
+ ap.paintAlignment(true, true);
}
@Override
public void adjustmentValueChanged(AdjustmentEvent evt)
{
fr.setTransparency((100 - transparency.getValue()) / 100f);
- ap.paintAlignment(true);
+ ap.paintAlignment(true, true);
}
class MyCheckbox extends Checkbox