*/
package jalview.appletgui;
-import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
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);
// TODO: add in group link parameter
// make a list of label,url pairs
- HashMap<String, String> urlList = new HashMap<String, String>();
- if (av.applet != null)
+ HashMap<String, String> urlList = new HashMap<>();
+ 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();
SequenceI sequence = av.getAlignment().getSequenceAt(seq);
- // look for non-pos features
StringBuffer tooltiptext = new StringBuffer();
- if (sequence != null)
+ if (sequence == null)
{
- if (sequence.getDescription() != null)
+ return;
+ }
+ if (sequence.getDescription() != null)
+ {
+ tooltiptext.append(sequence.getDescription());
+ tooltiptext.append("\n");
+ }
+
+ for (SequenceFeature sf : sequence.getFeatures()
+ .getNonPositionalFeatures())
+ {
+ boolean nl = false;
+ if (sf.getFeatureGroup() != null)
{
- tooltiptext.append(sequence.getDescription());
- tooltiptext.append("\n");
+ tooltiptext.append(sf.getFeatureGroup());
+ nl = true;
}
-
- SequenceFeature sf[] = sequence.getSequenceFeatures();
- for (int sl = 0; sf != null && sl < sf.length; sl++)
+ if (sf.getType() != null)
{
- if (sf[sl].begin == sf[sl].end && sf[sl].begin == 0)
- {
- boolean nl = false;
- if (sf[sl].getFeatureGroup() != null)
- {
- tooltiptext.append(sf[sl].getFeatureGroup());
- nl = true;
- }
- ;
- if (sf[sl].getType() != null)
- {
- tooltiptext.append(" ");
- tooltiptext.append(sf[sl].getType());
- nl = true;
- }
- ;
- if (sf[sl].getDescription() != null)
- {
- tooltiptext.append(" ");
- tooltiptext.append(sf[sl].getDescription());
- nl = true;
- }
- ;
- if (!Float.isNaN(sf[sl].getScore()) && sf[sl].getScore() != 0f)
- {
- tooltiptext.append(" Score = ");
- tooltiptext.append(sf[sl].getScore());
- nl = true;
- }
- ;
- if (sf[sl].getStatus() != null && sf[sl].getStatus().length() > 0)
- {
- tooltiptext.append(" (");
- tooltiptext.append(sf[sl].getStatus());
- tooltiptext.append(")");
- nl = true;
- }
- ;
- if (nl)
- {
- tooltiptext.append("\n");
- }
- }
+ tooltiptext.append(" ");
+ tooltiptext.append(sf.getType());
+ nl = true;
+ }
+ if (sf.getDescription() != null)
+ {
+ tooltiptext.append(" ");
+ tooltiptext.append(sf.getDescription());
+ nl = true;
+ }
+ if (!Float.isNaN(sf.getScore()) && sf.getScore() != 0f)
+ {
+ tooltiptext.append(" Score = ");
+ tooltiptext.append(sf.getScore());
+ nl = true;
+ }
+ if (sf.getStatus() != null && sf.getStatus().length() > 0)
+ {
+ tooltiptext.append(" (");
+ tooltiptext.append(sf.getStatus());
+ tooltiptext.append(")");
+ nl = true;
+ }
+ if (nl)
+ {
+ tooltiptext.append("\n");
}
}
+
if (tooltiptext.length() == 0)
{
// nothing to display - so clear tooltip if one is visible
}
lastid = seq;
- alignPanel.paintAlignment(false);
+ alignPanel.paintAlignment(false, false);
}
@Override
int seq = alignPanel.seqPanel.findSeq(e);
- if ((e.getModifiers()
- & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
+ if ((e.getModifiersEx()
+ & InputEvent.BUTTON3_DOWN_MASK) == InputEvent.BUTTON3_DOWN_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;
if (urlProvider != null)
{
}
else
{
- nlinks = new ArrayList<String>();
+ nlinks = new ArrayList<>();
}
- 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);
}
}
}
selectSeq(seq);
}
- alignPanel.paintAlignment(false);
+ alignPanel.paintAlignment(false, false);
}
void selectSeq(int seq)
{
idCanvas.setHighlighted(list);
- if (list == null)
+ if (list == null || list.isEmpty())
{
return;
}
boolean up = true;
- public ScrollThread(boolean up)
+ public ScrollThread(boolean isUp)
{
- this.up = up;
+ this.up = isUp;
start();
}
running = false;
}
- alignPanel.paintAlignment(true);
+ alignPanel.paintAlignment(true, false);
try
{
Thread.sleep(100);