UrlProviderI urlProvider = null;
-- public IdPanel(AlignViewport av, AlignmentPanel parent)
++ public IdPanel(AlignViewport viewport, AlignmentPanel parent)
{
-- this.av = av;
++ this.av = viewport;
alignPanel = parent;
-- idCanvas = new IdCanvas(av);
++ idCanvas = new IdCanvas(viewport);
setLayout(new BorderLayout());
add(idCanvas, BorderLayout.CENTER);
idCanvas.addMouseListener(this);
// make a list of label,url pairs
HashMap<String, String> urlList = new HashMap<String, String>();
-- if (av.applet != null)
++ if (viewport.applet != null)
{
for (int i = 1; i < 10; i++)
{
-- label = av.applet.getParameter("linkLabel_" + i);
-- url = av.applet.getParameter("linkURL_" + i);
++ label = viewport.applet.getParameter("linkLabel_" + i);
++ url = viewport.applet.getParameter("linkURL_" + i);
// only add non-null parameters
if (label != null)
if (!urlList.isEmpty())
{
// set default as first entry in list
-- String defaultUrl = av.applet.getParameter("linkLabel_1");
++ String defaultUrl = viewport.applet.getParameter("linkLabel_1");
UrlProviderFactoryI factory = new AppletUrlProviderFactory(
defaultUrl, urlList);
urlProvider = factory.createUrlProvider();
if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
{
- Sequence sq = (Sequence) av.getAlignment().getSequenceAt(seq);
+ SequenceI sq = av.getAlignment().getSequenceAt(seq);
- // build a new links menu based on the current links + any non-positional
- // features
+ /*
+ * build a new links menu based on the current links
+ * and any non-positional features
+ */
- List<String> nlinks = urlProvider.getLinksForMenu();
+ List<String> nlinks;
+ if (urlProvider != null)
+ {
+ nlinks = urlProvider.getLinksForMenu();
+ }
+ else
+ {
+ nlinks = new ArrayList<String>();
+ }
- SequenceFeature sf[] = sq == null ? null : sq.getSequenceFeatures();
- for (int sl = 0; sf != null && sl < sf.length; sl++)
+
+ for (SequenceFeature sf : sq.getFeatures().getNonPositionalFeatures())
{
- if (sf[sl].begin == sf[sl].end && sf[sl].begin == 0)
+ if (sf.links != null)
{
- if (sf[sl].links != null && sf[sl].links.size() > 0)
+ for (String link : sf.links)
{
- for (int l = 0, lSize = sf[sl].links.size(); l < lSize; l++)
- {
- nlinks.add(sf[sl].links.elementAt(l));
- }
+ nlinks.add(link);
}
}
}
boolean up = true;
-- public ScrollThread(boolean up)
++ public ScrollThread(boolean isUp)
{
-- this.up = up;
++ this.up = isUp;
start();
}
import java.awt.event.MouseEvent;
import java.util.Arrays;
import java.util.Comparator;
+import java.util.HashMap;
+ import java.util.List;
import javax.swing.JColorChooser;
import javax.swing.JComboBox;
}
else if (reply == JvOptionPane.YES_OPTION)
{
+ /*
+ * YES_OPTION corresponds to the Amend button
+ */
+ boolean typeChanged = !lastFeatureAdded.equals(sf.type);
- sf.type = lastFeatureAdded;
- sf.featureGroup = lastFeatureGroupAdded;
- sf.description = lastDescriptionAdded;
-
- setColour(sf.type, fcol);
- getFeaturesDisplayed().setVisible(sf.type);
-
+ String newType = lastFeatureAdded;
+ String newFeatureGroup = lastFeatureGroupAdded;
+ String newDescription = lastDescriptionAdded;
+
+ setColour(newType, fcol);
+ getFeaturesDisplayed().setVisible(newType);
+ int newBegin = sf.begin;
+ int newEnd = sf.end;
try
{
- sf.begin = ((Integer) start.getValue()).intValue();
- sf.end = ((Integer) end.getValue()).intValue();
+ newBegin = ((Integer) start.getValue()).intValue();
+ newEnd = ((Integer) end.getValue()).intValue();
} catch (NumberFormatException ex)
{
+ // JSpinner doesn't accept invalid format data :-)
+ }
+
+ /*
+ * replace the feature by deleting it and adding a new one
+ * (to ensure integrity of SequenceFeatures data store)
+ */
- sequences[0].deleteFeature(sf);
++ sequences.get(0).deleteFeature(sf);
+ SequenceFeature newSf = new SequenceFeature(newType,
+ newDescription, newBegin, newEnd, sf.getScore(),
+ newFeatureGroup);
+ // ensure any additional properties are copied
+ if (sf.otherDetails != null)
+ {
+ newSf.otherDetails = new HashMap<String, Object>(sf.otherDetails);
+ }
+ ffile.parseDescriptionHTML(newSf, false);
+ // add any additional links not parsed from description
+ if (sf.links != null)
+ {
+ for (String link : sf.links)
+ {
+ newSf.addLink(link);
+ }
}
+ // amend features only gets one sequence to act on
- sequences[0].addSequenceFeature(newSf);
++ sequences.get(0).addSequenceFeature(newSf);
+
- ffile.parseDescriptionHTML(sf, false);
+ if (typeChanged)
+ {
+ findAllFeatures();
+ }
}
}
else