diff --git a/uk/ac/sanger/artemis/editor/BigPane.java b/uk/ac/sanger/artemis/editor/BigPane.java index 118f27f5b91ab206c61a5bf949738c3704d0f58c..02f34155d0763f2c06b2d08af9133ef8510b2f40 100644 --- a/uk/ac/sanger/artemis/editor/BigPane.java +++ b/uk/ac/sanger/artemis/editor/BigPane.java @@ -106,7 +106,7 @@ public class BigPane extends JFrame Box evidenceBox = dataView.getEvidenceBox(); if(overlapFeature != null) - evidenceBox.add(getOverlapFeatures(overlapFeature),0); + evidenceBox.add(getOverlapFeatures(overlapFeature,desktop),0); evidenceBox.add(Box.createVerticalGlue()); ScrollPanel scroller = new ScrollPanel(); @@ -135,10 +135,11 @@ public class BigPane extends JFrame * Display for overlapping Pfam features. * */ - private Box getOverlapFeatures(FeatureVector overlapFeature) + private Box getOverlapFeatures(FeatureVector overlapFeature, + JDesktopPane desktop) { Box bdown = Box.createVerticalBox(); - bdown.add(new EvidenceViewer(edit_feature,overlapFeature)); + bdown.add(new EvidenceViewer(edit_feature,overlapFeature,desktop)); return bdown; } diff --git a/uk/ac/sanger/artemis/editor/DataCollectionPane.java b/uk/ac/sanger/artemis/editor/DataCollectionPane.java index e736b10487cf68f7d613a23687be9350763be158..c48bcd753429244bb04397d106a88dcbb0d9c690 100644 --- a/uk/ac/sanger/artemis/editor/DataCollectionPane.java +++ b/uk/ac/sanger/artemis/editor/DataCollectionPane.java @@ -430,7 +430,7 @@ public class DataCollectionPane extends JScrollPane * @param desktop desktop pane. * */ - protected void setUpSRSFrame(URL url, String name, JDesktopPane desktop) + protected static void setUpSRSFrame(URL url, String name, JDesktopPane desktop) throws IOException { if(BigPane.srsFrame == null) diff --git a/uk/ac/sanger/artemis/editor/EvidenceViewer.java b/uk/ac/sanger/artemis/editor/EvidenceViewer.java index 370f8fee4b995bf0704942542f6d256d532d6c2f..fef4bca5c0b00ef6537ce3b33846dafc8a635658 100644 --- a/uk/ac/sanger/artemis/editor/EvidenceViewer.java +++ b/uk/ac/sanger/artemis/editor/EvidenceViewer.java @@ -25,7 +25,10 @@ package uk.ac.sanger.artemis.editor; import javax.swing.JPanel; +import javax.swing.JOptionPane; +import javax.swing.JDesktopPane; import java.awt.*; +import java.awt.event.*; import java.awt.geom.AffineTransform; import java.util.StringTokenizer; @@ -45,9 +48,13 @@ public class EvidenceViewer extends JPanel private int bound = 35; private Feature edit_feature; private FeatureVector overlapFeature; + private float unitLength; + private int YDISPLACEMENT = 20; + private JDesktopPane desktop; + public EvidenceViewer(Feature edit_feature, - FeatureVector overlapFeature) + FeatureVector overlapFeature, JDesktopPane desktop) { this.edit_feature = edit_feature; this.overlapFeature = overlapFeature; @@ -55,6 +62,7 @@ public class EvidenceViewer extends JPanel featStart = this_loc.getFirstBase(); featEnd = this_loc.getLastBase(); + this.desktop = desktop; this.evidenceStart = evidenceStart; this.evidenceEnd = evidenceEnd; @@ -62,6 +70,8 @@ public class EvidenceViewer extends JPanel final Dimension dim = new Dimension(500,hgt); setPreferredSize(dim); setMaximumSize(dim); + + addMouseListener(new MouseClickListener()); } /** @@ -87,8 +97,7 @@ public class EvidenceViewer extends JPanel int unit = (int)(resultwidth/npoints); int featUnit = (featEnd-featStart)/npoints; - float unitLength = (float)resultwidth/(float)(featEnd-featStart); - + unitLength = (float)resultwidth/(float)(featEnd-featStart); // feature segments final FeatureSegmentVector this_feature_segments = edit_feature.getSegments(); @@ -174,9 +183,8 @@ public class EvidenceViewer extends JPanel g2.setStroke(new BasicStroke(3.f)); g2.drawString(pfamID, bound+start+(end-start-strwid)/2, bound2+ydisp+5); - ydisp += 20; + ydisp += YDISPLACEMENT; } - } @@ -201,5 +209,84 @@ public class EvidenceViewer extends JPanel g2.drawLine(bound+start, bound+hgtNumber+6, bound+stop, bound+hgtNumber+6); } + + public class MouseClickListener implements MouseListener + { + public void mousePressed(MouseEvent e) + { + } + + public void mouseReleased(MouseEvent e) + { + } + + public void mouseEntered(MouseEvent e) + { + } + + public void mouseExited(MouseEvent e) + { + } + + public void mouseClicked(MouseEvent e) + { + int ydisp = 0; + int bound2 = bound*2; + int ydisp2 = YDISPLACEMENT/2; + Point loc = e.getPoint(); + for(int i = 0; i<overlapFeature.size(); ++i) + { + Feature this_feature = overlapFeature.elementAt(i); + Location this_loc = this_feature.getLocation(); + int start = this_loc.getFirstBase(); + int end = this_loc.getLastBase(); + + start = (int)((start-featStart)*unitLength)+bound; + end = (int)((end-featStart)*unitLength)+bound; + + if(loc.x < end && + loc.x > start && + loc.y < ydisp+ydisp2+bound2 && + loc.y > ydisp-ydisp2+bound2) + { + String note = this_feature.getNote(); + + int indPF = note.indexOf("PF"); // Pfam ID + if(indPF == -1) + continue; + + StringTokenizer tok = new StringTokenizer(note.substring(indPF)," ,;"); + String pfamID = tok.nextToken(); + + + String pfam_cmd = "http://www.sanger.ac.uk/cgi-bin/Pfam/getacc?"+pfamID; + BrowserControl.displayURL(pfam_cmd); + + if(BigPane.srsTabPane.isSelected()) + { + try + { + DataCollectionPane.setUpSRSFrame(new java.net.URL(pfam_cmd), + pfamID,desktop); + } + catch(java.net.ConnectException connect) + { + JOptionPane.showMessageDialog(EvidenceViewer.this, + "Cannot retrieve "+pfamID+ + "\nConnection failed to:\n"+pfamID, + "Connection Error", + JOptionPane.WARNING_MESSAGE); + } + catch(Exception exp) + { + exp.printStackTrace(); + } + } + } + ydisp += YDISPLACEMENT; + } + } + } + }