label.consensus_descr = PID
label.complement_consensus_descr = PID for cDNA
label.strucconsensus_descr = PID for base pairs
-label.occupancy_descr = Number of aligned positions
\ No newline at end of file
+label.occupancy_descr = Number of aligned positions
+label.warning_hidden = Warning: {0} {1} is currently hidden
\ No newline at end of file
label.invalid_name = Nombre inválido !
label.output_seq_details = Seleccionar Detalles de la secuencia para ver todas
label.urllinks = Enlaces
+label.warning_hidden = Advertencia: {0} {1} está actualmente oculto
\ No newline at end of file
import java.awt.Choice;
import java.awt.Color;
import java.awt.Dimension;
+import java.awt.FlowLayout;
import java.awt.Font;
+import java.awt.Frame;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
+import java.awt.event.TextEvent;
+import java.awt.event.TextListener;
import java.util.Hashtable;
/**
final SequenceFeature[] features, boolean create,
final AlignmentPanel ap, String featureType)
{
- Panel bigPanel = new Panel(new BorderLayout());
+ final Panel bigPanel = new Panel(new BorderLayout());
final TextField name = new TextField(16);
- final TextField source = new TextField(16);
+ final TextField group = new TextField(16);
final TextArea description = new TextArea(3, 35);
final TextField start = new TextField(8);
final TextField end = new TextField(8);
Button deleteButton = new Button("Delete");
deleteFeature = false;
+ name.addTextListener(new TextListener()
+ {
+ @Override
+ public void textValueChanged(TextEvent e)
+ {
+ warnIfTypeHidden(ap.alignFrame, name.getText());
+ }
+ });
+ group.addTextListener(new TextListener()
+ {
+ @Override
+ public void textValueChanged(TextEvent e)
+ {
+ warnIfGroupHidden(ap.alignFrame, group.getText());
+ }
+ });
colourPanel = new FeatureColourPanel();
colourPanel.setSize(110, 15);
final FeatureRenderer fr = this;
featureIndex = index;
name.setText(features[index].getType());
description.setText(features[index].getDescription());
- source.setText(features[index].getFeatureGroup());
+ group.setText(features[index].getFeatureGroup());
start.setText(features[index].getBegin() + "");
end.setText(features[index].getEnd() + "");
tmp = new Panel();
panel.add(tmp);
tmp.add(new Label(MessageManager.getString("label.group:"), Label.RIGHT));
- tmp.add(source);
+ tmp.add(group);
tmp = new Panel();
panel.add(tmp);
if (create)
{
name.setText(lastFeatureAdded);
- source.setText(lastFeatureGroupAdded);
+ group.setText(lastFeatureGroupAdded);
}
else
{
}
});
name.setText(features[0].getType());
- source.setText(features[0].getFeatureGroup());
+ group.setText(features[0].getFeatureGroup());
}
start.setText(features[0].getBegin() + "");
if (dialog.accept)
{
lastFeatureAdded = name.getText().trim();
- lastFeatureGroupAdded = source.getText().trim();
+ lastFeatureGroupAdded = group.getText().trim();
lastDescriptionAdded = description.getText().replace('\n', ' ');
}
SequenceFeature sf = features[featureIndex];
if (dialog.accept)
{
+ boolean typeOrGroupChanged = (!lastFeatureAdded.equals(sf.type) || !lastFeatureGroupAdded
+ .equals(sf.featureGroup));
sf.type = lastFeatureAdded;
sf.featureGroup = lastFeatureGroupAdded;
sf.description = lastDescriptionAdded;
}
ffile.parseDescriptionHTML(sf, false);
- setVisible(lastFeatureAdded); // if user edited name then make sure new
- // type is visible
+ if (typeOrGroupChanged)
+ {
+ featuresAdded();
+ }
}
if (deleteFeature)
{
sequences[0].deleteFeature(sf);
+ // ensure Feature Settings reflects removal of feature / group
+ featuresAdded();
}
}
else
{
+ /*
+ * adding feature(s)
+ */
if (dialog.accept && name.getText().length() > 0)
{
for (int i = 0; i < sequences.length; i++)
Color newColour = colourPanel.getBackground();
// setColour(lastFeatureAdded, fcol);
- if (lastFeatureGroupAdded != null)
- {
- setGroupVisibility(lastFeatureGroupAdded, true);
- }
setColour(lastFeatureAdded, new FeatureColour(newColour)); // was fcol
- setVisible(lastFeatureAdded);
- findAllFeatures(false); // different to original applet behaviour ?
- // findAllFeatures();
+ featuresAdded();
}
else
{
return true;
}
+
+ protected void warnIfGroupHidden(Frame frame, String group)
+ {
+ if (featureGroups.containsKey(group) && !featureGroups.get(group))
+ {
+ String msg = MessageManager.formatMessage("label.warning_hidden",
+ MessageManager.getString("label.group"), group);
+ showWarning(frame, msg);
+ }
+ }
+
+ protected void warnIfTypeHidden(Frame frame, String type)
+ {
+ if (getRenderOrder().contains(type))
+ {
+ if (!showFeatureOfType(type))
+ {
+ String msg = MessageManager.formatMessage("label.warning_hidden",
+ MessageManager.getString("label.feature_type"), type);
+ showWarning(frame, msg);
+ }
+ }
+ }
+
+ /**
+ * @param frame
+ * @param msg
+ */
+ protected void showWarning(Frame frame, String msg)
+ {
+ JVDialog d = new JVDialog(frame, "", true, 350, 200);
+ Panel mp = new Panel();
+ d.ok.setLabel(MessageManager.getString("action.ok"));
+ d.cancel.setVisible(false);
+ mp.setLayout(new FlowLayout());
+ mp.add(new Label(msg));
+ d.setMainPanel(mp);
+ d.setVisible(true);
+ }
}
import java.awt.event.WindowEvent;
import java.util.Arrays;
import java.util.Enumeration;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.Vector;
public class FeatureSettings extends Panel implements ItemListener,
{
fr.findAllFeatures(true); // was default - now true to make all visible
}
+ groupPanel = new Panel();
discoverAllFeatureData();
add(lowerPanel, BorderLayout.SOUTH);
- if (groupPanel != null)
- {
- groupPanel.setLayout(new GridLayout(
- (fr.getFeatureGroupsSize()) / 4 + 1, 4)); // JBPNote - this was
- // scaled on number of
- // visible groups. seems
- // broken
- groupPanel.validate();
+ 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);
- add(groupPanel, BorderLayout.NORTH);
- }
frame = new Frame();
frame.add(this);
final FeatureSettings me = this;
if (fr.getAllFeatureColours() != null
&& fr.getAllFeatureColours().size() > 0)
{
- rebuildGroups();
+ // rebuildGroups();
}
resetTable(false);
}
/**
- * rebuilds the group panel
+ * Answers the visibility of the given group, and adds a checkbox for it if
+ * there is not one already
*/
- public void rebuildGroups()
+ public boolean checkGroupState(String group)
{
- boolean rdrw = false;
- if (groupPanel == null)
- {
- groupPanel = new Panel();
- }
- else
- {
- rdrw = true;
- groupPanel.removeAll();
- }
- // TODO: JAL-964 - smoothly incorporate new group entries if panel already
- // displayed and new groups present
- for (String group : fr.getFeatureGroups())
- {
- boolean vis = fr.checkGroupVisibility(group, false);
- Checkbox check = new MyCheckbox(group, vis, false);
- check.addMouseListener(this);
- check.setFont(new Font("Serif", Font.BOLD, 12));
- check.addItemListener(groupItemListener);
- // note - visibility seems to correlate with displayed. ???wtf ??
- check.setVisible(vis);
- groupPanel.add(check);
- }
- if (rdrw)
+ boolean visible = fr.checkGroupVisibility(group, true);
+
+ /*
+ * is there already a checkbox for this group?
+ */
+ for (int g = 0; g < groupPanel.getComponentCount(); g++)
{
- groupPanel.validate();
+ if (((Checkbox) groupPanel.getComponent(g)).getLabel().equals(group))
+ {
+ ((Checkbox) groupPanel.getComponent(g)).setState(visible);
+ return visible;
+ }
}
+
+ /*
+ * add a new checkbox
+ */
+ Checkbox check = new MyCheckbox(group, visible, false);
+ check.addMouseListener(this);
+ check.setFont(new Font("Serif", Font.BOLD, 12));
+ check.addItemListener(groupItemListener);
+ groupPanel.add(check);
+
+ groupPanel.validate();
+ return visible;
}
// This routine adds and removes checkboxes depending on
SequenceFeature[] tmpfeatures;
String group = null, type;
Vector<String> visibleChecks = new Vector<String>();
+ Set<String> foundGroups = new HashSet<String>();
AlignmentI alignment = av.getAlignment();
+
for (int i = 0; i < alignment.getHeight(); i++)
{
if (alignment.getSequenceAt(i).getSequenceFeatures() == null)
while (index < tmpfeatures.length)
{
group = tmpfeatures[index].featureGroup;
+ foundGroups.add(group);
- if (group == null || fr.checkGroupVisibility(group, true))
+ if (group == null || checkGroupState(group))
{
type = tmpfeatures[index].getType();
if (!visibleChecks.contains(type))
}
}
+ /*
+ * remove any checkboxes for groups not present
+ */
+ pruneGroups(foundGroups);
+
Component[] comps;
int cSize = featurePanel.getComponentCount();
MyCheckbox check;
}
/**
+ * 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++)
+ {
+ Checkbox checkbox = (Checkbox) groupPanel.getComponent(g);
+ if (!foundGroups.contains(checkbox.getLabel()))
+ {
+ groupPanel.remove(checkbox);
+ }
+ }
+ }
+
+ /**
* update the checklist of feature types with the given type
*
* @param groupsChanged
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
/**
* DOCUMENT ME!
featureIndex = 0;
final JPanel mainPanel = new JPanel(new BorderLayout());
+
final JTextField name = new JTextField(25);
- final JTextField source = new JTextField(25);
+ name.getDocument().addDocumentListener(new DocumentListener()
+ {
+ @Override
+ public void insertUpdate(DocumentEvent e)
+ {
+ warnIfTypeHidden(mainPanel, name.getText());
+ }
+
+ @Override
+ public void removeUpdate(DocumentEvent e)
+ {
+ warnIfTypeHidden(mainPanel, name.getText());
+ }
+
+ @Override
+ public void changedUpdate(DocumentEvent e)
+ {
+ warnIfTypeHidden(mainPanel, name.getText());
+ }
+ });
+
+ final JTextField group = new JTextField(25);
+ group.getDocument().addDocumentListener(new DocumentListener()
+ {
+ @Override
+ public void insertUpdate(DocumentEvent e)
+ {
+ warnIfGroupHidden(mainPanel, group.getText());
+ }
+
+ @Override
+ public void removeUpdate(DocumentEvent e)
+ {
+ warnIfGroupHidden(mainPanel, group.getText());
+ }
+
+ @Override
+ public void changedUpdate(DocumentEvent e)
+ {
+ warnIfGroupHidden(mainPanel, group.getText());
+ }
+ });
+
final JTextArea description = new JTextArea(3, 25);
final JSpinner start = new JSpinner();
final JSpinner end = new JSpinner();
SequenceFeature sf = features.get(index);
name.setText(sf.getType());
description.setText(sf.getDescription());
- source.setText(sf.getFeatureGroup());
+ group.setText(sf.getFeatureGroup());
start.setValue(new Integer(sf.getBegin()));
end.setValue(new Integer(sf.getEnd()));
gridPanel.add(choosePanel);
}
- // ////////
- // ////////////////////////////////////
JPanel namePanel = new JPanel();
gridPanel.add(namePanel);
gridPanel.add(groupPanel);
groupPanel.add(new JLabel(MessageManager.getString("label.group:"),
JLabel.RIGHT));
- groupPanel.add(source);
+ groupPanel.add(group);
JPanel colourPanel = new JPanel();
gridPanel.add(colourPanel);
if (create)
{
name.setText(lastFeatureAdded);
- source.setText(lastFeatureGroupAdded);
+ group.setText(lastFeatureGroupAdded);
}
else
{
name.setText(firstFeature.getType());
- source.setText(firstFeature.getFeatureGroup());
+ group.setText(firstFeature.getFeatureGroup());
}
start.setValue(new Integer(firstFeature.getBegin()));
if (reply == JvOptionPane.OK_OPTION && name.getText().length() > 0)
{
lastFeatureAdded = name.getText().trim();
- lastFeatureGroupAdded = source.getText().trim();
+ lastFeatureGroupAdded = group.getText().trim();
lastDescriptionAdded = description.getText().replaceAll("\n", " ");
// TODO: determine if the null feature group is valid
if (lastFeatureGroupAdded.length() < 1)
* NO_OPTION corresponds to the Delete button
*/
sequences.get(0).getDatasetSequence().deleteFeature(sf);
+ // update Feature Settings for removal of feature / group
+ featuresAdded();
}
else if (reply == JvOptionPane.YES_OPTION)
{
/*
* YES_OPTION corresponds to the Amend button
*/
- boolean typeChanged = !lastFeatureAdded.equals(sf.type);
+ boolean typeOrGroupChanged = (!lastFeatureAdded.equals(sf.type) || !lastFeatureGroupAdded
+ .equals(sf.featureGroup));
sf.type = lastFeatureAdded;
sf.featureGroup = lastFeatureGroupAdded;
sf.description = lastDescriptionAdded;
setColour(sf.type, fcol);
- getFeaturesDisplayed().setVisible(sf.type);
try
{
}
ffile.parseDescriptionHTML(sf, false);
- if (typeChanged)
+ if (typeOrGroupChanged)
{
- findAllFeatures();
+ featuresAdded();
}
}
}
ffile.parseDescriptionHTML(sf, false);
}
- if (lastFeatureGroupAdded != null)
- {
- setGroupVisibility(lastFeatureGroupAdded, true);
- }
setColour(lastFeatureAdded, fcol);
- setVisible(lastFeatureAdded);
- findAllFeatures(false);
+ featuresAdded();
alignPanel.paintAlignment(true);
}
/**
+ * Show a warning message if the entered type is one that is currently hidden
+ *
+ * @param panel
+ * @param type
+ */
+ protected void warnIfTypeHidden(JPanel panel, String type)
+ {
+ if (getRenderOrder().contains(type))
+ {
+ if (!showFeatureOfType(type))
+ {
+ String msg = MessageManager.formatMessage("label.warning_hidden",
+ MessageManager.getString("label.feature_type"), type);
+ JvOptionPane.showMessageDialog(panel, msg, "",
+ JvOptionPane.OK_OPTION);
+ }
+ }
+ }
+
+ /**
+ * Show a warning message if the entered group is one that is currently hidden
+ *
+ * @param panel
+ * @param group
+ */
+ protected void warnIfGroupHidden(JPanel panel, String group)
+ {
+ if (featureGroups.containsKey(group) && !featureGroups.get(group))
+ {
+ String msg = MessageManager.formatMessage("label.warning_hidden",
+ MessageManager.getString("label.group"), group);
+ JvOptionPane.showMessageDialog(panel, msg, "", JvOptionPane.OK_OPTION);
+ }
+ }
+
+ /**
* update the amend feature button dependent on the given style
*
* @param bigPanel
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
private static final int MIN_HEIGHT = 400;
+ /**
+ * Constructor
+ *
+ * @param af
+ */
public FeatureSettings(AlignFrame af)
{
this.af = af;
{
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 visible;
- }
final String grp = group;
final JCheckBox check = new JCheckBox(group, visible);
check.setFont(new Font("Serif", Font.BOLD, 12));
SequenceFeature[] tmpfeatures;
String group = null, type;
Vector<String> visibleChecks = new Vector<String>();
+ Set<String> foundGroups = new HashSet<String>();
// Find out which features should be visible depending on which groups
// are selected / deselected
while (index < tmpfeatures.length)
{
group = tmpfeatures[index].featureGroup;
+ foundGroups.add(group);
if (tmpfeatures[index].begin == 0 && tmpfeatures[index].end == 0)
{
table.setModel(new FeatureTableModel(data));
table.getColumnModel().getColumn(0).setPreferredWidth(200);
- if (groupPanel != null)
- {
- groupPanel.setLayout(new GridLayout(
- fr.getFeatureGroupsSize() / 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;
}
/**
+ * 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
settingsPane.setLayout(borderLayout2);
dasSettingsPane.setLayout(borderLayout3);
bigPanel.setLayout(borderLayout4);
+
+ groupPanel = new JPanel();
+ bigPanel.add(groupPanel, BorderLayout.NORTH);
+
invert.setFont(JvSwingUtils.getLabelFont());
invert.setText(MessageManager.getString("label.invert_selection"));
invert.addActionListener(new ActionListener()
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
{
minmax = new Hashtable<String, float[][]>();
}
+
+ Set<String> oldGroups = new HashSet<String>(featureGroups.keySet());
AlignmentI alignment = av.getAlignment();
for (int i = 0; i < alignment.getHeight(); i++)
{
int index = 0;
while (index < features.length)
{
+ String fgrp = features[index].getFeatureGroup();
+ oldGroups.remove(fgrp);
if (!featuresDisplayed.isRegistered(features[index].getType()))
{
- String fgrp = features[index].getFeatureGroup();
if (fgrp != null)
{
Boolean groupDisplayed = featureGroups.get(fgrp);
index++;
}
}
+
+ /*
+ * oldGroups now consists of groups that no longer
+ * have any feature in them - remove these
+ */
+ for (String grp : oldGroups)
+ {
+ featureGroups.remove(grp);
+ }
+
updateRenderOrder(allfeatures);
findingFeatures = false;
}