*/
package jalview.gui;
-import java.util.*;
-import java.util.regex.Pattern;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.Annotation;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.io.FormatAdapter;
+import jalview.util.MessageManager;
-import java.awt.*;
-import java.awt.datatransfer.*;
-import java.awt.event.*;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.MediaTracker;
+import java.awt.RenderingHints;
+import java.awt.Toolkit;
+import java.awt.datatransfer.StringSelection;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
import java.awt.geom.AffineTransform;
-import java.awt.image.*;
-import javax.swing.*;
+import java.awt.image.BufferedImage;
+import java.util.Arrays;
+import java.util.Vector;
+import java.util.regex.Pattern;
-import jalview.datamodel.*;
-import jalview.io.*;
-import jalview.util.MessageManager;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.SwingUtilities;
+import javax.swing.ToolTipManager;
/**
* DOCUMENT ME!
Graphics2D g = (Graphics2D) bi.getGraphics();
g.rotate(Math.toRadians(90));
g.drawImage(temp, 0, -bi.getWidth(this), this);
- image = (Image) bi;
+ image = bi;
addMouseListener(this);
addMouseMotionListener(this);
aa[selectedRow].scaleColLabel = !aa[selectedRow].scaleColLabel;
}
+ refresh();
+
+ }
+
+ /**
+ * Redraw sensibly.
+ */
+ protected void refresh()
+ {
ap.validateAnnotationDimensions(false);
ap.addNotify();
ap.repaint();
- // validate();
- // ap.paintAlignment(true);
}
/**
{
desc.append("<br/>");
}
-
+ // if (aa.hasProperties())
+ // {
+ // desc.append("<table>");
+ // for (String prop : aa.getProperties())
+ // {
+ // desc.append("<tr><td>" + prop + "</td><td>"
+ // + aa.getProperty(prop) + "</td><tr>");
+ // }
+ // desc.append("</table>");
+ // }
}
else
{
// begin the tooltip's html fragment
desc.append("<html>");
+ if (aa.hasScore())
+ {
+ // 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 (aa.hasScore())
- {
- // 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)
{
desc.append("</html>");
this.setToolTipText(desc.toString());
}
else
+ {
this.setToolTipText(null);
+ }
}
-
}
/**
*/
public void mouseClicked(MouseEvent evt)
{
- AlignmentAnnotation[] aa = ap.av.getAlignment()
+ final AlignmentAnnotation[] aa = ap.av.getAlignment()
.getAlignmentAnnotation();
if (SwingUtilities.isLeftMouseButton(evt))
{
item = new JMenuItem(HIDE);
item.addActionListener(this);
pop.add(item);
+ // JAL-1264 hide all sequence-specific annotations of this type
+ final String label = aa[selectedRow].label;
+ if (selectedRow < aa.length)
+ {
+ if (aa[selectedRow].sequenceRef != null)
+ {
+ JMenuItem hideType = new JMenuItem();
+ String text = MessageManager.getString("label.hide_all") + " " + label;
+ hideType.setText(text);
+ hideType.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ for (AlignmentAnnotation ann : ap.av.getAlignment()
+ .getAlignmentAnnotation())
+ {
+ if (ann.sequenceRef != null && ann.label != null
+ && ann.label.equals(label))
+ {
+ ann.visible = false;
+ }
+ }
+ refresh();
+ }
+ });
+ pop.add(hideType);
+ }
+ }
item = new JMenuItem(DELETE);
item.addActionListener(this);
pop.add(item);
pop.add(item);
}
}
- else if (aa[selectedRow].label.indexOf("Consensus") > -1)
+ else if (label.indexOf("Consensus") > -1)
{
pop.addSeparator();
// av and sequencegroup need to implement same interface for
offset -= fm.getDescent();
}
else
+ {
offset += fm.getDescent();
+ }
x = width - fm.stringWidth(aa[i].label) - 3;