X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FIdPanel.java;h=15e269c5a91b64c2269103088d6b8a8cf68b1060;hb=106a3890f956e2aa7780b2985f4326655912a558;hp=4cc4a3a5d5e1fa4961532d1a75fb8cb4e47aee4f;hpb=5078a67d8357697791d2e71f9df95a46e762aa2e;p=jalview.git diff --git a/src/jalview/appletgui/IdPanel.java b/src/jalview/appletgui/IdPanel.java index 4cc4a3a..15e269c 100755 --- a/src/jalview/appletgui/IdPanel.java +++ b/src/jalview/appletgui/IdPanel.java @@ -20,7 +20,6 @@ */ package jalview.appletgui; -import jalview.datamodel.Sequence; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; @@ -39,8 +38,8 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -public class IdPanel extends Panel implements MouseListener, - MouseMotionListener +public class IdPanel extends Panel + implements MouseListener, MouseMotionListener { protected IdCanvas idCanvas; @@ -57,11 +56,11 @@ public class IdPanel extends Panel implements MouseListener, 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); @@ -71,13 +70,13 @@ public class IdPanel extends Panel implements MouseListener, // TODO: add in group link parameter // make a list of label,url pairs - HashMap urlList = new HashMap(); - if (av.applet != null) + HashMap 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) @@ -89,7 +88,7 @@ public class IdPanel extends Panel implements MouseListener, 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(); @@ -106,64 +105,57 @@ public class IdPanel extends Panel implements MouseListener, 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 @@ -177,13 +169,14 @@ public class IdPanel extends Panel implements MouseListener, } if (tooltip == null) { - tooltip = new Tooltip(sequence.getDisplayId(true) + "\n" - + tooltiptext.toString(), idCanvas); + tooltip = new Tooltip( + sequence.getDisplayId(true) + "\n" + tooltiptext.toString(), + idCanvas); } else { - tooltip.setTip(sequence.getDisplayId(true) + "\n" - + tooltiptext.toString()); + tooltip.setTip( + sequence.getDisplayId(true) + "\n" + tooltiptext.toString()); } tooltiptext = null; } @@ -205,7 +198,7 @@ public class IdPanel extends Panel implements MouseListener, } lastid = seq; - alignPanel.paintAlignment(false); + alignPanel.paintAlignment(false, false); } @Override @@ -286,12 +279,15 @@ public class IdPanel extends Panel implements MouseListener, int seq = alignPanel.seqPanel.findSeq(e); - if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) + 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 nlinks; if (urlProvider != null) { @@ -299,19 +295,16 @@ public class IdPanel extends Panel implements MouseListener, } else { - nlinks = new ArrayList(); + 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); } } } @@ -323,8 +316,8 @@ public class IdPanel extends Panel implements MouseListener, } if ((av.getSelectionGroup() == null) - || ((!jalview.util.Platform.isControlDown(e) && !e - .isShiftDown()) && av.getSelectionGroup() != null)) + || ((!jalview.util.Platform.isControlDown(e) + && !e.isShiftDown()) && av.getSelectionGroup() != null)) { av.setSelectionGroup(new SequenceGroup()); av.getSelectionGroup().setStartRes(0); @@ -340,7 +333,7 @@ public class IdPanel extends Panel implements MouseListener, selectSeq(seq); } - alignPanel.paintAlignment(false); + alignPanel.paintAlignment(false, false); } void selectSeq(int seq) @@ -373,8 +366,8 @@ public class IdPanel extends Panel implements MouseListener, } for (int i = start; i <= end; i++) { - av.getSelectionGroup().addSequence( - av.getAlignment().getSequenceAt(i), i == end); + av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i), + i == end); } } @@ -413,7 +406,7 @@ public class IdPanel extends Panel implements MouseListener, if (av.getRanges().getStartSeq() > index || av.getRanges().getEndSeq() < index) { - alignPanel.setScrollValues(av.getRanges().getStartRes(), index); + av.getRanges().setStartSeq(index); } } @@ -424,9 +417,9 @@ public class IdPanel extends Panel implements MouseListener, boolean up = true; - public ScrollThread(boolean up) + public ScrollThread(boolean isUp) { - this.up = up; + this.up = isUp; start(); } @@ -441,7 +434,7 @@ public class IdPanel extends Panel implements MouseListener, running = true; while (running) { - if (alignPanel.scrollUp(up)) + if (av.getRanges().scrollUp(up)) { // scroll was ok, so add new sequence to selection int seq = av.getRanges().getStartSeq(); @@ -466,7 +459,7 @@ public class IdPanel extends Panel implements MouseListener, running = false; } - alignPanel.paintAlignment(true); + alignPanel.paintAlignment(true, false); try { Thread.sleep(100);