X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationLabels.java;h=7967ae63cd2e4a34fdec448120ef0f67ee0ed049;hb=bbfdb203ce3a889600caa52478478b75ab03809f;hp=8605f74729a526b1c0695aa44b0952c2f1ac756f;hpb=153dd62dc91da13ae732600e6ea55ddbe15eab39;p=jalview.git diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 8605f74..7967ae6 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6) - * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) + * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle * * This file is part of Jalview. * @@ -18,6 +18,7 @@ package jalview.gui; import java.util.*; +import java.util.regex.Pattern; import java.awt.*; import java.awt.datatransfer.*; @@ -104,8 +105,8 @@ public class AnnotationLabels extends JPanel implements MouseListener, { } - BufferedImage bi = new BufferedImage(temp.getHeight(this), temp - .getWidth(this), BufferedImage.TYPE_INT_RGB); + BufferedImage bi = new BufferedImage(temp.getHeight(this), + temp.getWidth(this), BufferedImage.TYPE_INT_RGB); Graphics2D g = (Graphics2D) bi.getGraphics(); g.rotate(Math.toRadians(90)); g.drawImage(temp, 0, -bi.getWidth(this), this); @@ -197,11 +198,6 @@ public class AnnotationLabels extends JPanel implements MouseListener, else if (evt.getActionCommand().equals(HIDE)) { aa[selectedRow].visible = false; - - if (aa[selectedRow].label.equals("Quality")) - { - ap.av.quality = null; - } } else if (evt.getActionCommand().equals(DELETE)) { @@ -245,9 +241,11 @@ public class AnnotationLabels extends JPanel implements MouseListener, aa[selectedRow].scaleColLabel = !aa[selectedRow].scaleColLabel; } - ap.annotationPanel.adjustPanelHeight(); - ap.annotationScroller.validate(); - ap.paintAlignment(true); + ap.validateAnnotationDimensions(false); + ap.addNotify(); + ap.repaint(); + //validate(); + //ap.paintAlignment(true); } /** @@ -407,22 +405,43 @@ public class AnnotationLabels extends JPanel implements MouseListener, && ap.av.alignment.getAlignmentAnnotation().length > selectedRow) { AlignmentAnnotation aa = ap.av.alignment.getAlignmentAnnotation()[selectedRow]; - - StringBuffer desc = new StringBuffer(""); - + + StringBuffer desc = new StringBuffer(); if (aa.description != null && !aa.description.equals("New description")) { - desc.append(aa.getDescription(true)); - if (aa.hasScore) - desc.append("
"); + // TODO: we could refactor and merge this code with the code in jalview.gui.SeqPanel.mouseMoved(..) that formats sequence feature tooltips + desc.append(aa.getDescription(true).trim()); + // check to see if the description is an html fragment. + if (desc.length()<6 || (desc.substring(0,6).toLowerCase().indexOf("")<0)) + { + // clean the description ready for embedding in html + desc = new StringBuffer(Pattern.compile("<").matcher(desc).replaceAll("<")); + desc.insert(0, ""); + } else { + // remove terminating html if any + int i=desc.substring(desc.length()-7).toLowerCase().lastIndexOf(""); + if (i>-1) { + desc.setLength(desc.length()-7+i); + } + } + if (aa.hasScore()) + { + desc.append("
"); + } + + + } else { + // begin the tooltip's html fragment + desc.append(""); } if (aa.hasScore()) { - desc.append("Score: " + aa.score); + // TODO: limit precision of score to avoid noise from imprecise doubles (64.7 becomes 64.7+/some tiny value). + desc.append(" Score: " + aa.score); } - if (desc.length() != 6) + if (desc.length() > 6) { desc.append(""); this.setToolTipText(desc.toString()); @@ -450,13 +469,13 @@ public class AnnotationLabels extends JPanel implements MouseListener, { if (evt.getClickCount() >= 2) { - // todo: make the ap scroll to the selection + // todo: make the ap scroll to the selection - not necessary, first click highlights/scrolls, second selects ap.seqPanel.ap.idPanel.highlightSearchResults(null); ap.av.setSelectionGroup(// new SequenceGroup( - aa[selectedRow].groupRef); // ); - ap.av.sendSelection(); + aa[selectedRow].groupRef); // ); ap.paintAlignment(false); PaintRefresher.Refresh(ap, ap.av.getSequenceSetId()); + ap.av.sendSelection(); } else { @@ -550,8 +569,8 @@ public class AnnotationLabels extends JPanel implements MouseListener, final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem( "Ignore Gaps In Consensus", (aa[selectedRow].groupRef != null) ? aa[selectedRow].groupRef - .getIgnoreGapsConsensus() - : ap.av.getIgnoreGapsConsensus()); + .getIgnoreGapsConsensus() : ap.av + .getIgnoreGapsConsensus()); final AlignmentAnnotation aaa = aa[selectedRow]; cbmi.addActionListener(new ActionListener() { @@ -574,8 +593,8 @@ public class AnnotationLabels extends JPanel implements MouseListener, if (aaa.groupRef != null) { final JCheckBoxMenuItem chist = new JCheckBoxMenuItem( - "Show Group Histogram", aa[selectedRow].groupRef - .isShowConsensusHistogram()); + "Show Group Histogram", + aa[selectedRow].groupRef.isShowConsensusHistogram()); chist.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -593,8 +612,8 @@ public class AnnotationLabels extends JPanel implements MouseListener, }); pop.add(chist); final JCheckBoxMenuItem cprofl = new JCheckBoxMenuItem( - "Show Group Logo", aa[selectedRow].groupRef - .isShowSequenceLogo()); + "Show Group Logo", + aa[selectedRow].groupRef.isShowSequenceLogo()); cprofl.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -611,6 +630,28 @@ public class AnnotationLabels extends JPanel implements MouseListener, } }); pop.add(cprofl); + final JCheckBoxMenuItem cproflnorm = new JCheckBoxMenuItem( + "Normalise Group Logo", + aa[selectedRow].groupRef.isNormaliseSequenceLogo()); + cproflnorm.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + + // TODO: pass on reference + // to ap + // so the + // view + // can be + // updated. + aaa.groupRef.setNormaliseSequenceLogo(cproflnorm.getState()); + // automatically enable logo display if we're clicked + aaa.groupRef.setshowSequenceLogo(true); + ap.repaint(); + // ap.annotationPanel.paint(ap.annotationPanel.getGraphics()); + } + }); + pop.add(cproflnorm); } else { @@ -627,6 +668,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, // can be // updated. av.setShowConsensusHistogram(chist.getState()); + ap.alignFrame.setMenusForViewport(); ap.repaint(); // ap.annotationPanel.paint(ap.annotationPanel.getGraphics()); } @@ -645,11 +687,32 @@ public class AnnotationLabels extends JPanel implements MouseListener, // can be // updated. av.setShowSequenceLogo(cprof.getState()); + ap.alignFrame.setMenusForViewport(); ap.repaint(); // ap.annotationPanel.paint(ap.annotationPanel.getGraphics()); } }); pop.add(cprof); + final JCheckBoxMenuItem cprofnorm = new JCheckBoxMenuItem( + "Normalise Logo", av.isNormaliseSequenceLogo()); + cprofnorm.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + // TODO: pass on reference + // to ap + // so the + // view + // can be + // updated. + av.setShowSequenceLogo(true); + av.setNormaliseSequenceLogo(cprofnorm.getState()); + ap.alignFrame.setMenusForViewport(); + ap.repaint(); + // ap.annotationPanel.paint(ap.annotationPanel.getGraphics()); + } + }); + pop.add(cprofnorm); } final JMenuItem consclipbrd = new JMenuItem(COPYCONS_SEQ); consclipbrd.addActionListener(this); @@ -690,8 +753,8 @@ public class AnnotationLabels extends JPanel implements MouseListener, String output = new FormatAdapter().formatSequences("Fasta", seqs, omitHidden); - Toolkit.getDefaultToolkit().getSystemClipboard().setContents( - new StringSelection(output), Desktop.instance); + Toolkit.getDefaultToolkit().getSystemClipboard() + .setContents(new StringSelection(output), Desktop.instance); Vector hiddenColumns = null; if (av.hasHiddenColumns) @@ -824,8 +887,8 @@ public class AnnotationLabels extends JPanel implements MouseListener, g.setColor(aa[gg].annotations[0].colour); } - g.drawLine(x, y - graphExtras - 3, x - + fm.stringWidth(aa[gg].label), y - graphExtras - 3); + g.drawLine(x, y - graphExtras - 3, + x + fm.stringWidth(aa[gg].label), y - graphExtras - 3); g.setColor(Color.black); graphExtras += fontHeight + 8; @@ -846,9 +909,8 @@ public class AnnotationLabels extends JPanel implements MouseListener, else if (dragEvent != null && aa != null) { g.setColor(Color.lightGray); - g.drawString(aa[selectedRow].label, dragEvent.getX(), dragEvent - .getY() - - scrollOffset); + g.drawString(aa[selectedRow].label, dragEvent.getX(), + dragEvent.getY() - scrollOffset); } if ((aa == null) || (aa.length < 1))