import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
+import java.util.List;
import java.util.Vector;
public class SeqPanel extends Panel implements MouseMotionListener,
av.setSelectionGroup(null);
}
- SequenceFeature[] features = findFeaturesAtRes(sequence,
+ List<SequenceFeature> features = findFeaturesAtRes(sequence,
sequence.findPosition(findRes(evt)));
- if (features != null && features.length > 0)
+ if (!features.isEmpty())
{
SearchResultsI highlight = new SearchResults();
- highlight.addResult(sequence, features[0].getBegin(),
- features[0].getEnd());
+ highlight.addResult(sequence, features.get(0).getBegin(), features
+ .get(0).getEnd());
seqCanvas.highlightSearchResults(highlight);
- }
- if (features != null && features.length > 0)
- {
+ SequenceFeature[] featuresArray = features
+ .toArray(new SequenceFeature[features.size()]);
seqCanvas.getFeatureRenderer().amendFeatures(
- new SequenceI[] { sequence }, features, false, ap, null);
+ new SequenceI[] { sequence }, featuresArray, false, ap,
+ null);
seqCanvas.highlightSearchResults(null);
}
}
// use aa to see if the mouse pointer is on a
- SequenceFeature[] allFeatures = findFeaturesAtRes(sequence,
+ List<SequenceFeature> allFeatures = findFeaturesAtRes(sequence,
sequence.findPosition(res));
int index = 0;
- while (index < allFeatures.length)
+ while (index < allFeatures.size())
{
- SequenceFeature sf = allFeatures[index];
+ SequenceFeature sf = allFeatures.get(index);
tooltipText.append(sf.getType() + " " + sf.begin + ":" + sf.end);
}
}
- SequenceFeature[] findFeaturesAtRes(SequenceI sequence, int res)
+ List<SequenceFeature> findFeaturesAtRes(SequenceI sequence, int res)
{
- Vector tmp = new Vector();
- SequenceFeature[] features = sequence.getSequenceFeatures();
- if (features != null)
- {
- for (int i = 0; i < features.length; i++)
- {
- if (av.getFeaturesDisplayed() == null
- || !av.getFeaturesDisplayed().isVisible(
- features[i].getType()))
- {
- continue;
- }
-
- if (features[i].featureGroup != null
- && !seqCanvas.fr.checkGroupVisibility(
- features[i].featureGroup, false))
- {
- continue;
- }
-
- if ((features[i].getBegin() <= res)
- && (features[i].getEnd() >= res))
- {
- tmp.addElement(features[i]);
- }
- }
- }
-
- features = new SequenceFeature[tmp.size()];
- tmp.copyInto(features);
-
- return features;
+ return seqCanvas.getFeatureRenderer().findFeaturesAtRes(sequence, res);
}
Tooltip tooltip;
// DETECT RIGHT MOUSE BUTTON IN AWT
if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
{
- SequenceFeature[] allFeatures = findFeaturesAtRes(sequence,
+ List<SequenceFeature> allFeatures = findFeaturesAtRes(sequence,
sequence.findPosition(res));
Vector<String> links = null;
- if (allFeatures != null)
+ for (int i = 0; i < allFeatures.size(); i++)
{
- for (int i = 0; i < allFeatures.length; i++)
+ SequenceFeature sf = allFeatures.get(i);
+ if (sf.links != null)
{
- if (allFeatures[i].links != null)
+ if (links == null)
{
- if (links == null)
- {
- links = new Vector<String>();
- }
- for (int j = 0; j < allFeatures[i].links.size(); j++)
- {
- links.addElement(allFeatures[i].links.elementAt(j));
- }
+ links = new Vector<String>();
}
+ links.addAll(sf.links);
}
}
APopupMenu popup = new APopupMenu(ap, null, links);