X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationLabels.java;h=445ee11e675f90e28f11df608866c9507070161d;hb=ad48d68e5790a0fa55e947b9ab9bb4eb5ca716ca;hp=d497488c6579101c1736cceb9d15cb4f04af5b2f;hpb=8b27085fa7fc5f2877e078421284c2636b85b8c6;p=jalview.git diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index d497488..445ee11 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -74,6 +74,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, private static final Pattern LEFT_ANGLE_BRACKET_PATTERN = Pattern .compile("<"); + String TOGGLE_LABELSCALE = MessageManager .getString("label.scale_label_to_column"); @@ -220,6 +221,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, AlignmentAnnotation[] aa = ap.av.getAlignment() .getAlignmentAnnotation(); + boolean fullRepaint = false; if (evt.getActionCommand().equals(ADDNEW)) { AlignmentAnnotation newAnnotation = new AlignmentAnnotation(null, @@ -232,11 +234,16 @@ public class AnnotationLabels extends JPanel implements MouseListener, ap.av.getAlignment().addAnnotation(newAnnotation); ap.av.getAlignment().setAnnotationIndex(newAnnotation, 0); + fullRepaint = true; } else if (evt.getActionCommand().equals(EDITNAME)) { + String name = aa[selectedRow].label; editLabelDescription(aa[selectedRow]); - repaint(); + if (!name.equalsIgnoreCase(aa[selectedRow].label)) + { + fullRepaint = true; + } } else if (evt.getActionCommand().equals(HIDE)) { @@ -246,6 +253,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, { ap.av.getAlignment().deleteAnnotation(aa[selectedRow]); ap.av.getCalcManager().removeWorkerForAnnotation(aa[selectedRow]); + fullRepaint = true; } else if (evt.getActionCommand().equals(SHOWALL)) { @@ -256,6 +264,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, aa[i].visible = true; } } + fullRepaint = true; } else if (evt.getActionCommand().equals(OUTPUT_TEXT)) { @@ -284,21 +293,11 @@ public class AnnotationLabels extends JPanel implements MouseListener, aa[selectedRow].scaleColLabel = !aa[selectedRow].scaleColLabel; } - refresh(); + ap.refresh(fullRepaint); } /** - * Redraw sensibly. - */ - protected void refresh() - { - ap.validateAnnotationDimensions(false); - ap.addNotify(); - ap.repaint(); - } - - /** * DOCUMENT ME! * * @param e @@ -306,6 +305,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, */ boolean editLabelDescription(AlignmentAnnotation annotation) { + // TODO i18n EditNameDialog dialog = new EditNameDialog(annotation.label, annotation.description, " Annotation Name ", "Annotation Description ", "Edit Annotation Name/Description", @@ -333,12 +333,20 @@ public class AnnotationLabels extends JPanel implements MouseListener, { getSelectedRow(evt.getY() - getScrollOffset()); oldY = evt.getY(); - if (!evt.isPopupTrigger()) + if (evt.isPopupTrigger()) { - return; + showPopupMenu(evt); } + } + + /** + * Build and show the Pop-up menu at the right-click mouse position + * + * @param evt + */ + void showPopupMenu(MouseEvent evt) + { evt.consume(); - // handle popup menu event final AlignmentAnnotation[] aa = ap.av.getAlignment() .getAlignmentAnnotation(); @@ -391,7 +399,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, // ann.visible = false; // } // } - refresh(); + ap.refresh(true); } }); pop.add(hideType); @@ -414,7 +422,8 @@ public class AnnotationLabels extends JPanel implements MouseListener, if (selectedRow < aa.length) { final String label = aa[selectedRow].label; - if (!aa[selectedRow].autoCalculated) + if (!(aa[selectedRow].autoCalculated + || label.indexOf("Information Content") > -1)) { if (aa[selectedRow].graph == AlignmentAnnotation.NO_GRAPH) { @@ -429,14 +438,18 @@ public class AnnotationLabels extends JPanel implements MouseListener, } else if (label.indexOf("Consensus") > -1) { + + pop.addSeparator(); // av and sequencegroup need to implement same interface for + final AlignmentAnnotation aaa = aa[selectedRow]; + final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem( - MessageManager.getString("label.ignore_gaps_consensus"), + MessageManager.getString("label.ignore_gaps_consensus"), (aa[selectedRow].groupRef != null) ? aa[selectedRow].groupRef .getIgnoreGapsConsensus() : ap.av .isIgnoreGapsConsensus()); - final AlignmentAnnotation aaa = aa[selectedRow]; + cbmi.addActionListener(new ActionListener() { @Override @@ -453,6 +466,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, { ap.av.setIgnoreGapsConsensus(cbmi.getState(), ap); } + ap.alignmentChanged(); } }); pop.add(cbmi); @@ -594,9 +608,180 @@ public class AnnotationLabels extends JPanel implements MouseListener, consclipbrd.addActionListener(this); pop.add(consclipbrd); } + else if (label.indexOf("Information Content") > -1) // TODO create labels + // in message resource + // for these + { + pop.addSeparator(); + final AlignmentAnnotation aaa = aa[selectedRow]; + + final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem( + "Ignore Below Background Frequency", + (aa[selectedRow].groupRef != null) + ? aa[selectedRow].groupRef + .getIgnoreBelowBackground() + : ap.av.isIgnoreBelowBackground()); + + cbmi.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + if (aaa.groupRef != null) + { + // TODO: pass on reference to ap so the view can be updated. + aaa.groupRef.setIgnoreBelowBackground(cbmi.getState()); + ap.getAnnotationPanel() + .paint(ap.getAnnotationPanel().getGraphics()); + } + else + { + ap.av.setIgnoreBelowBackground(cbmi.getState(), ap); + } + ap.alignmentChanged(); + } + }); + pop.add(cbmi); + if (aaa.groupRef != null) + { + final JCheckBoxMenuItem chist = new JCheckBoxMenuItem( + MessageManager.getString("label.show_group_histogram"), + aa[selectedRow].groupRef.isShowInformationHistogram()); + chist.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + // TODO: pass on reference + // to ap + // so the + // view + // can be + // updated. + aaa.groupRef.setShowInformationHistogram(chist.getState()); + ap.repaint(); + // ap.annotationPanel.paint(ap.annotationPanel.getGraphics()); + } + }); + pop.add(chist); + final JCheckBoxMenuItem cprofl = new JCheckBoxMenuItem( + MessageManager.getString("label.show_group_logo"), + aa[selectedRow].groupRef.isShowHMMSequenceLogo()); + cprofl.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + // TODO: pass on reference + // to ap + // so the + // view + // can be + // updated. + aaa.groupRef.setshowHMMSequenceLogo(cprofl.getState()); + ap.repaint(); + // ap.annotationPanel.paint(ap.annotationPanel.getGraphics()); + } + }); + pop.add(cprofl); + final JCheckBoxMenuItem cproflnorm = new JCheckBoxMenuItem( + MessageManager.getString("label.normalise_group_logo"), + aa[selectedRow].groupRef.isNormaliseHMMSequenceLogo()); + cproflnorm.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + + // TODO: pass on reference + // to ap + // so the + // view + // can be + // updated. + aaa.groupRef + .setNormaliseHMMSequenceLogo(cproflnorm.getState()); + // automatically enable logo display if we're clicked + aaa.groupRef.setshowHMMSequenceLogo(true); + ap.repaint(); + // ap.annotationPanel.paint(ap.annotationPanel.getGraphics()); + } + }); + 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) + { + // TODO: pass on reference + // to ap + // so the + // view + // can be + // updated. + av.setShowInformationHistogram(chist.getState()); + ap.alignFrame.setMenusForViewport(); + ap.repaint(); + // ap.annotationPanel.paint(ap.annotationPanel.getGraphics()); + } + }); + 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) + { + // TODO: pass on reference + // to ap + // so the + // view + // can be + // updated. + av.setShowHMMSequenceLogo(cprof.getState()); + ap.alignFrame.setMenusForViewport(); + ap.repaint(); + // ap.annotationPanel.paint(ap.annotationPanel.getGraphics()); + } + }); + 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) + { + // TODO: pass on reference + // to ap + // so the + // view + // can be + // updated. + av.setShowHMMSequenceLogo(true); + av.setNormaliseHMMSequenceLogo(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); + pop.add(consclipbrd); + } } pop.show(this, evt.getX(), evt.getY()); - } /** @@ -608,6 +793,12 @@ public class AnnotationLabels extends JPanel implements MouseListener, @Override public void mouseReleased(MouseEvent evt) { + if (evt.isPopupTrigger()) + { + showPopupMenu(evt); + return; + } + int start = selectedRow; getSelectedRow(evt.getY() - getScrollOffset()); int end = selectedRow; @@ -934,12 +1125,14 @@ public class AnnotationLabels extends JPanel implements MouseListener, Alignment ds = new Alignment(dseqs); if (av.hasHiddenColumns()) { - omitHidden = av.getColumnSelection().getVisibleSequenceStrings(0, + omitHidden = av.getAlignment().getHiddenColumns() + .getVisibleSequenceStrings(0, sq.getLength(), seqs); } int[] alignmentStartEnd = new int[] { 0, ds.getWidth() - 1 }; - List hiddenCols = av.getColumnSelection().getHiddenColumns(); + List hiddenCols = av.getAlignment().getHiddenColumns() + .getHiddenRegions(); if (hiddenCols != null) { alignmentStartEnd = av.getAlignment().getVisibleStartAndEndIndex( @@ -954,8 +1147,9 @@ public class AnnotationLabels extends JPanel implements MouseListener, ArrayList hiddenColumns = null; if (av.hasHiddenColumns()) { - hiddenColumns = new ArrayList(); - for (int[] region : av.getColumnSelection().getHiddenColumns()) + hiddenColumns = new ArrayList<>(); + for (int[] region : av.getAlignment().getHiddenColumns() + .getHiddenRegions()) { hiddenColumns.add(new int[] { region[0], region[1] }); }