*/
package jalview.gui;
+import java.util.Locale;
+
import jalview.analysis.AlignSeq;
import jalview.analysis.AlignmentUtils;
import jalview.datamodel.Alignment;
import jalview.util.Comparison;
import jalview.util.MessageManager;
import jalview.util.Platform;
+import jalview.workers.InformationThread;
import java.awt.Color;
import java.awt.Cursor;
*/
public AnnotationLabels(AlignmentPanel ap)
{
+
this.ap = ap;
av = ap.av;
ToolTipManager.sharedInstance().registerComponent(this);
AlignmentAnnotation[] aa = ap.av.getAlignment()
.getAlignmentAnnotation();
- boolean fullRepaint = false;
- if (evt.getActionCommand().equals(ADDNEW))
+ String action = evt.getActionCommand();
+ if (ADDNEW.equals(action))
{
+ /*
+ * non-returning dialog
+ */
AlignmentAnnotation newAnnotation = new AlignmentAnnotation(null,
null, new Annotation[ap.av.getAlignment().getWidth()]);
-
- if (!editLabelDescription(newAnnotation))
- {
- return;
- }
-
- ap.av.getAlignment().addAnnotation(newAnnotation);
- ap.av.getAlignment().setAnnotationIndex(newAnnotation, 0);
- fullRepaint = true;
+ editLabelDescription(newAnnotation, true);
}
- else if (evt.getActionCommand().equals(EDITNAME))
+ else if (EDITNAME.equals(action))
{
- String name = aa[selectedRow].label;
- editLabelDescription(aa[selectedRow]);
- if (!name.equalsIgnoreCase(aa[selectedRow].label))
- {
- fullRepaint = true;
- }
+ /*
+ * non-returning dialog
+ */
+ editLabelDescription(aa[selectedRow], false);
}
- else if (evt.getActionCommand().equals(HIDE))
+ else if (HIDE.equals(action))
{
aa[selectedRow].visible = false;
}
- else if (evt.getActionCommand().equals(DELETE))
+ else if (DELETE.equals(action))
{
ap.av.getAlignment().deleteAnnotation(aa[selectedRow]);
ap.av.getCalcManager().removeWorkerForAnnotation(aa[selectedRow]);
- fullRepaint = true;
}
- else if (evt.getActionCommand().equals(SHOWALL))
+ else if (SHOWALL.equals(action))
{
for (int i = 0; i < aa.length; i++)
{
aa[i].visible = true;
}
}
- fullRepaint = true;
}
- else if (evt.getActionCommand().equals(OUTPUT_TEXT))
+ else if (OUTPUT_TEXT.equals(action))
{
new AnnotationExporter(ap).exportAnnotation(aa[selectedRow]);
}
- else if (evt.getActionCommand().equals(COPYCONS_SEQ))
+ else if (COPYCONS_SEQ.equals(action))
{
SequenceI cons = null;
if (aa[selectedRow].groupRef != null)
{
copy_annotseqtoclipboard(cons);
}
-
}
- else if (evt.getActionCommand().equals(TOGGLE_LABELSCALE))
+ else if (TOGGLE_LABELSCALE.equals(action))
{
aa[selectedRow].scaleColLabel = !aa[selectedRow].scaleColLabel;
}
- ap.refresh(fullRepaint);
-
+ ap.refresh(true);
}
/**
- * DOCUMENT ME!
+ * Shows a dialog where the annotation name and description may be edited. If
+ * parameter addNew is true, then on confirmation, a new AlignmentAnnotation
+ * is added, else an existing annotation is updated.
*
- * @param e
- * DOCUMENT ME!
+ * @param annotation
+ * @param addNew
*/
- boolean editLabelDescription(AlignmentAnnotation annotation)
+ void editLabelDescription(AlignmentAnnotation annotation, boolean addNew)
{
- // TODO i18n
+ String name = MessageManager.getString("label.annotation_name");
+ String description = MessageManager
+ .getString("label.annotation_description");
+ String title = MessageManager
+ .getString("label.edit_annotation_name_description");
EditNameDialog dialog = new EditNameDialog(annotation.label,
- annotation.description, " Annotation Name ",
- "Annotation Description ", "Edit Annotation Name/Description",
- ap.alignFrame);
+ annotation.description, name, description);
- if (!dialog.accept)
+ dialog.showDialog(ap.alignFrame, title, new Runnable()
{
- return false;
- }
-
- annotation.label = dialog.getName();
-
- String text = dialog.getDescription();
- if (text != null && text.length() == 0)
- {
- text = null;
- }
- annotation.description = text;
-
- return true;
+ @Override
+ public void run()
+ {
+ annotation.label = dialog.getName();
+ String text = dialog.getDescription();
+ if (text != null && text.length() == 0)
+ {
+ text = null;
+ }
+ annotation.description = text;
+ if (addNew)
+ {
+ ap.av.getAlignment().addAnnotation(annotation);
+ ap.av.getAlignment().setAnnotationIndex(annotation, 0);
+ }
+ ap.refresh(true);
+ }
+ });
}
@Override
pop.show(this, evt.getX(), evt.getY());
return;
}
+ final AlignmentAnnotation ann = aa[selectedRow];
+ final boolean isSequenceAnnotation = ann.sequenceRef != null;
item = new JMenuItem(EDITNAME);
item.addActionListener(this);
pop.add(item);
if (selectedRow < aa.length)
{
final String label = aa[selectedRow].label;
- if (!aa[selectedRow].autoCalculated)
+ if (!(aa[selectedRow].autoCalculated)
+ && !(InformationThread.HMM_CALC_ID.equals(ann.getCalcId())))
{
if (aa[selectedRow].graph == AlignmentAnnotation.NO_GRAPH)
{
pop.addSeparator();
// av and sequencegroup need to implement same interface for
item = new JCheckBoxMenuItem(TOGGLE_LABELSCALE,
- aa[selectedRow].scaleColLabel);
+ aa[selectedRow].scaleColLabel);
item.addActionListener(this);
pop.add(item);
}
consclipbrd.addActionListener(this);
pop.add(consclipbrd);
}
+ else if (InformationThread.HMM_CALC_ID.equals(ann.getCalcId()))
+ {
+ addHmmerMenu(pop, ann);
+ }
}
pop.show(this, evt.getX(), evt.getY());
}
/**
+ * Adds context menu options for (alignment or group) Hmmer annotation
+ *
+ * @param pop
+ * @param ann
+ */
+ protected void addHmmerMenu(JPopupMenu pop, final AlignmentAnnotation ann)
+ {
+ final boolean isGroupAnnotation = ann.groupRef != null;
+ pop.addSeparator();
+ final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(
+ MessageManager.getString(
+ "label.ignore_below_background_frequency"),
+ isGroupAnnotation
+ ? ann.groupRef
+ .isIgnoreBelowBackground()
+ : ap.av.isIgnoreBelowBackground());
+ cbmi.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ if (isGroupAnnotation)
+ {
+ if (!ann.groupRef.isUseInfoLetterHeight())
+ {
+ ann.groupRef.setIgnoreBelowBackground(cbmi.getState());
+ // todo and recompute group annotation
+ }
+ }
+ else if (!ap.av.isInfoLetterHeight())
+ {
+ ap.av.setIgnoreBelowBackground(cbmi.getState(), ap);
+ // todo and recompute annotation
+ }
+ ap.alignmentChanged(); // todo not like this
+ }
+ });
+ pop.add(cbmi);
+ final JCheckBoxMenuItem letterHeight = new JCheckBoxMenuItem(
+ MessageManager.getString("label.use_info_for_height"),
+ isGroupAnnotation ? ann.groupRef.isUseInfoLetterHeight()
+ : ap.av.isInfoLetterHeight());
+ letterHeight.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ if (isGroupAnnotation)
+ {
+ ann.groupRef.setInfoLetterHeight((letterHeight.getState()));
+ ann.groupRef.setIgnoreBelowBackground(true);
+ // todo and recompute group annotation
+ }
+ else
+ {
+ ap.av.setInfoLetterHeight(letterHeight.getState(), ap);
+ ap.av.setIgnoreBelowBackground(true, ap);
+ // todo and recompute annotation
+ }
+ ap.alignmentChanged();
+ }
+ });
+ pop.add(letterHeight);
+ if (isGroupAnnotation)
+ {
+ final JCheckBoxMenuItem chist = new JCheckBoxMenuItem(
+ MessageManager.getString("label.show_group_histogram"),
+ ann.groupRef.isShowInformationHistogram());
+ chist.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ ann.groupRef.setShowInformationHistogram(chist.getState());
+ ap.repaint();
+ }
+ });
+ pop.add(chist);
+ final JCheckBoxMenuItem cprofl = new JCheckBoxMenuItem(
+ MessageManager.getString("label.show_group_logo"),
+ ann.groupRef.isShowHMMSequenceLogo());
+ cprofl.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ ann.groupRef.setShowHMMSequenceLogo(cprofl.getState());
+ ap.repaint();
+ }
+ });
+ pop.add(cprofl);
+ final JCheckBoxMenuItem cproflnorm = new JCheckBoxMenuItem(
+ MessageManager.getString("label.normalise_group_logo"),
+ ann.groupRef.isNormaliseHMMSequenceLogo());
+ cproflnorm.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ ann.groupRef
+ .setNormaliseHMMSequenceLogo(cproflnorm.getState());
+ // automatically enable logo display if we're clicked
+ ann.groupRef.setShowHMMSequenceLogo(true);
+ ap.repaint();
+ }
+ });
+ pop.add(cproflnorm);
+ }
+ else
+ {
+ final JCheckBoxMenuItem chist = new JCheckBoxMenuItem(
+ MessageManager.getString("label.show_histogram"),
+ av.isShowInformationHistogram());
+ chist.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ av.setShowInformationHistogram(chist.getState());
+ ap.repaint();
+ }
+ });
+ pop.add(chist);
+ final JCheckBoxMenuItem cprof = new JCheckBoxMenuItem(
+ MessageManager.getString("label.show_logo"),
+ av.isShowHMMSequenceLogo());
+ cprof.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ av.setShowHMMSequenceLogo(cprof.getState());
+ ap.repaint();
+ }
+ });
+ pop.add(cprof);
+ final JCheckBoxMenuItem cprofnorm = new JCheckBoxMenuItem(
+ MessageManager.getString("label.normalise_logo"),
+ av.isNormaliseHMMSequenceLogo());
+ cprofnorm.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ av.setShowHMMSequenceLogo(true);
+ av.setNormaliseHMMSequenceLogo(cprofnorm.getState());
+ ap.repaint();
+ }
+ });
+ pop.add(cprofnorm);
+ }
+ }
+
+ /**
* A helper method that adds menu options for calculation and visualisation of
* group and/or alignment consensus annotation to a popup menu. This is
* designed to be reusable for either unwrapped mode (popup menu is shown on
* @param pop
*/
static void addConsensusMenuOptions(AlignmentPanel ap,
- AlignmentAnnotation ann,
- JPopupMenu pop)
+ AlignmentAnnotation ann, JPopupMenu pop)
{
pop.addSeparator();
// jalview.gui.SeqPanel.mouseMoved(..) that formats sequence feature
// tooltips
String desc = aa.getDescription(true).trim();
- if (!desc.toLowerCase().startsWith(HTML_START_TAG))
+ if (!desc.toLowerCase(Locale.ROOT).startsWith(HTML_START_TAG))
{
tooltip.append(HTML_START_TAG);
desc = desc.replace("<", "<");
}
- else if (desc.toLowerCase().endsWith(HTML_END_TAG))
+ else if (desc.toLowerCase(Locale.ROOT).endsWith(HTML_END_TAG))
{
desc = desc.substring(0, desc.length() - HTML_END_TAG.length());
}
protected void showOrHideAdjuster(MouseEvent evt)
{
boolean was = resizePanel;
- resizePanel = evt.getY() < HEIGHT_ADJUSTER_HEIGHT && evt.getX() < HEIGHT_ADJUSTER_WIDTH;
+ resizePanel = evt.getY() < HEIGHT_ADJUSTER_HEIGHT
+ && evt.getX() < HEIGHT_ADJUSTER_WIDTH;
if (resizePanel != was)
{
- setCursor(Cursor.getPredefinedCursor(
- resizePanel ? Cursor.S_RESIZE_CURSOR
+ setCursor(Cursor
+ .getPredefinedCursor(resizePanel ? Cursor.S_RESIZE_CURSOR
: Cursor.DEFAULT_CURSOR));
repaint();
}
seqs, omitHidden, alignmentStartEnd);
Toolkit.getDefaultToolkit().getSystemClipboard()
- .setContents(new StringSelection(output), Desktop.instance);
+ .setContents(new StringSelection(output), Desktop.getInstance());
HiddenColumns hiddenColumns = null;
av.getAlignment().getHiddenColumns());
}
- Desktop.jalviewClipboard = new Object[] { seqs, ds, // what is the dataset
- // of a consensus
- // sequence ? need to
- // flag
- // sequence as special.
+ // what is the dataset of a consensus sequence?
+ // need to flag sequence as special.
+ Desktop.getInstance().jalviewClipboard = new Object[] { seqs, ds,
hiddenColumns };
}
- /**
- * DOCUMENT ME!
- *
- * @param g1
- * DOCUMENT ME!
- */
@Override
public void paintComponent(Graphics g)
{
int width = getWidth();
if (width == 0)
{
- width = ap.calculateIdWidth().width + 4;
+ width = ap.calculateIdWidth().width;
}
Graphics2D g2 = (Graphics2D) g;