From: gmungoc Date: Fri, 1 May 2015 08:11:29 +0000 (+0100) Subject: JAL-1690 refining 'copy format from' as applied to splitframe panels X-Git-Tag: Jalview_2_9~37 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8c6722b27ff92e3610376295e2b4363f942d9969;p=jalview.git JAL-1690 refining 'copy format from' as applied to splitframe panels --- diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 42dfca9..e25fb93 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -534,7 +534,10 @@ label.dark_colour = Dark Colour label.light_colour = Light Colour label.highlightnode = Left click to select leaves.
Double-click to invert leaves.
Right click to change colour. label.load_colour_scheme = Load colour scheme +label.copy_format_from = Copy format from label.toggle_enabled_views = When enabled, allows many views to be selected. +label.select_all_views = Select all views +label.select_many_views = Select many views label.edit_notes_parameter_set = Click to edit the notes for this parameter set. label.open_local_file = Open local file label.enable_automatically_sort_alignment_when_open_new_tree = Enable this to automatically sort
the alignment when you open
a new tree. @@ -740,7 +743,6 @@ label.fetch_all_param = Fetch all {0} label.paste_new_window = Paste To New Window label.settings_for_param = Settings for {0} label.view_params = View {0} -label.select_all_views = Select all views label.all_views = All Views label.align_sequences_to_existing_alignment = Align sequences to an existing alignment label.realign_with_params = Realign with {0} diff --git a/src/jalview/appletgui/AlignmentPanel.java b/src/jalview/appletgui/AlignmentPanel.java index 5a2c5ef..0516533 100644 --- a/src/jalview/appletgui/AlignmentPanel.java +++ b/src/jalview/appletgui/AlignmentPanel.java @@ -983,7 +983,11 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, { invalidate(); Dimension d = idPanel.idCanvas.getSize(); - idPanel.idCanvas.setSize(d.width, seqPanel.seqCanvas.getSize().height); + final int canvasHeight = seqPanel.seqCanvas.getSize().height; + if (canvasHeight != d.height) + { + idPanel.idCanvas.setSize(d.width, canvasHeight); + } if (av.getWrapAlignment()) { diff --git a/src/jalview/appletgui/IdwidthAdjuster.java b/src/jalview/appletgui/IdwidthAdjuster.java index f5530d5..b537112 100755 --- a/src/jalview/appletgui/IdwidthAdjuster.java +++ b/src/jalview/appletgui/IdwidthAdjuster.java @@ -20,8 +20,14 @@ */ package jalview.appletgui; -import java.awt.*; -import java.awt.event.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Panel; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; public class IdwidthAdjuster extends Panel implements MouseListener, MouseMotionListener @@ -57,6 +63,26 @@ public class IdwidthAdjuster extends Panel implements MouseListener, { active = false; repaint(); + + /* + * If in a SplitFrame with co-scaled alignments, set the other's id width to + * match; note applet does not (yet) store this in ViewStyle + */ + /* + * Code disabled for now as it doesn't work, don't know why; idCanvas width + * keeps resetting to a previous value (actually two alternating values!) + */ + // final AlignViewportI viewport = ap.getAlignViewport(); + // if (viewport.getCodingComplement() != null + // && viewport.isScaleProteinAsCdna()) + // { + // Dimension d = ap.idPanel.idCanvas.getSize(); + // SplitFrame sf = ap.alignFrame.getSplitFrame(); + // final AlignmentPanel otherPanel = + // sf.getComplement(ap.alignFrame).alignPanel; + // otherPanel.setIdWidth(d.width, d.height); + // otherPanel.repaint(); + // } } public void mouseEntered(MouseEvent evt) @@ -77,13 +103,13 @@ public class IdwidthAdjuster extends Panel implements MouseListener, Dimension d = ap.idPanel.idCanvas.getSize(); int dif = evt.getX() - oldX; - if (d.width + dif > 20 || dif > 0) + final int newWidth = d.width + dif; + if (newWidth > 20 || dif > 0) { - ap.setIdWidth(d.width + dif, d.height); - this.setSize(d.width + dif, getSize().height); + ap.setIdWidth(newWidth, d.height); + this.setSize(newWidth, getSize().height); oldX = evt.getX(); } - } public void mouseMoved(MouseEvent evt) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index fcf4301..80838e2 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -364,7 +364,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, final List selviews = new ArrayList(); final List origview = new ArrayList(); - ViewSelectionMenu vsel = new ViewSelectionMenu("Transfer colours from", + final String menuLabel = MessageManager + .getString("label.copy_format_from"); + ViewSelectionMenu vsel = new ViewSelectionMenu(menuLabel, new ViewSetProvider() { @@ -373,7 +375,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { origview.clear(); origview.add(alignPanel); - return Desktop.getAlignmentPanels(null); + // make an array of all alignment panels except for this one + List aps = new ArrayList( + Arrays.asList(Desktop.getAlignmentPanels(null))); + aps.remove(AlignFrame.this.alignPanel); + return aps.toArray(new AlignmentPanel[aps.size()]); } }, selviews, new ItemListener() { @@ -383,32 +389,43 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { if (origview.size() > 0) { + final AlignmentPanel ap = origview.get(0); + + /* + * Copy the ViewStyle of the selected panel to 'this one'. + * Don't change value of 'scaleProteinAsCdna' unless copying + * from a SplitFrame. + */ ViewStyleI vs = selviews.get(0).getAlignViewport() .getViewStyle(); - origview.get(0).getAlignViewport().setViewStyle(vs); - AlignViewportI complement = origview.get(0) - .getAlignViewport().getCodingComplement(); - if (complement != null) + boolean fromSplitFrame = selviews.get(0) + .getAlignViewport().getCodingComplement() != null; + if (!fromSplitFrame) + { + vs.setScaleProteinAsCdna(ap.getAlignViewport() + .getViewStyle().isScaleProteinAsCdna()); + } + ap.getAlignViewport().setViewStyle(vs); + + /* + * Also rescale ViewStyle of SplitFrame complement if there is + * one _and_ it is set to 'scaledProteinAsCdna'; we don't copy + * the whole ViewStyle (allow cDNA protein to have different + * fonts) + */ + AlignViewportI complement = ap.getAlignViewport() + .getCodingComplement(); + if (complement != null && vs.isScaleProteinAsCdna()) { AlignFrame af = Desktop.getAlignFrameFor(complement); - if (complement.isNucleotide()) - { - complement.setViewStyle(vs); - vs.setCharWidth(vs.getCharWidth() / 3); - } - else - { - int rw = vs.getCharWidth(); - vs.setCharWidth(rw * 3); - complement.setViewStyle(vs); - vs.setCharWidth(rw); - } - af.alignPanel.updateLayout(); + ((SplitFrame) af.getSplitViewContainer()) + .adjustLayout(); af.setMenusForViewport(); } - origview.get(0).updateLayout(); - origview.get(0).setSelected(true); - origview.get(0).alignFrame.setMenusForViewport(); + + ap.updateLayout(); + ap.setSelected(true); + ap.alignFrame.setMenusForViewport(); } } diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 80f568d..5bc46f4 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -1616,11 +1616,17 @@ public class AlignmentPanel extends GAlignmentPanel implements { try { + if (alignFrame.getSplitViewContainer() != null) + { + /* + * bring enclosing SplitFrame to front first if there is one + */ + ((SplitFrame) alignFrame.getSplitViewContainer()).setSelected(b); + } alignFrame.setSelected(b); } catch (Exception ex) { } - ; if (b) { diff --git a/src/jalview/gui/ViewSelectionMenu.java b/src/jalview/gui/ViewSelectionMenu.java index 5a16e2e..e12fb5b 100644 --- a/src/jalview/gui/ViewSelectionMenu.java +++ b/src/jalview/gui/ViewSelectionMenu.java @@ -20,15 +20,13 @@ */ package jalview.gui; -import jalview.util.MessageManager; - import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; import java.util.List; import javax.swing.JCheckBoxMenuItem; @@ -37,6 +35,8 @@ import javax.swing.JMenuItem; import javax.swing.event.MenuEvent; import javax.swing.event.MenuListener; +import jalview.util.MessageManager; + /** * this is an implementation of an abstract Jalview GUI class that provides a * dialog/menu which allows the user to select/deselect specific views from a @@ -150,7 +150,8 @@ public class ViewSelectionMenu extends JMenu { // ensure we update menu state to reflect external selection list state append = append || _selectedviews.size() > 1; - toggleview = new JCheckBoxMenuItem("Select many views", append); + toggleview = new JCheckBoxMenuItem( + MessageManager.getString("label.select_many_views"), append); toggleview.setToolTipText(MessageManager .getString("label.toggle_enabled_views")); toggleview.addItemListener(new ItemListener() @@ -216,15 +217,14 @@ public class ViewSelectionMenu extends JMenu invertSel.setEnabled(append); selectAll.setEnabled(append); } - for (AlignmentPanel ap : allviews) + for (final AlignmentPanel ap : allviews) { String nm = ((ap.getViewName() == null || ap.getViewName().length() == 0) ? "" : ap.getViewName() + " for ") + ap.alignFrame.getTitle(); - final JCheckBoxMenuItem a = new JCheckBoxMenuItem(nm, + final JCheckBoxMenuItem checkBox = new JCheckBoxMenuItem(nm, _selectedviews.contains(ap)); - final AlignmentPanel p = ap; - a.addItemListener(new ItemListener() + checkBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) @@ -235,15 +235,15 @@ public class ViewSelectionMenu extends JMenu { enabled = false; // toggle the inclusion state - if (_selectedviews.indexOf(p) == -1) + if (_selectedviews.indexOf(ap) == -1) { - _selectedviews.add(p); - a.setSelected(true); + _selectedviews.add(ap); + checkBox.setSelected(true); } else { - _selectedviews.remove(p); - a.setSelected(false); + _selectedviews.remove(ap); + checkBox.setSelected(false); } enabled = true; _handler.itemStateChanged(e); @@ -252,13 +252,13 @@ public class ViewSelectionMenu extends JMenu { // Deselect everything and select this item only _selectedviews.clear(); - _selectedviews.add(p); + _selectedviews.add(ap); enabled = false; for (Component c : getMenuComponents()) { if (c instanceof JCheckBoxMenuItem) { - ((JCheckBoxMenuItem) c).setSelected(a == c); + ((JCheckBoxMenuItem) c).setSelected(checkBox == c); } } enabled = true; @@ -268,54 +268,31 @@ public class ViewSelectionMenu extends JMenu } } }); - a.addMouseListener(new MouseListener() + checkBox.addMouseListener(new MouseAdapter() { - - @Override - public void mouseReleased(MouseEvent e) - { - // TODO Auto-generated method stub - - } - - @Override - public void mousePressed(MouseEvent e) - { - // TODO Auto-generated method stub - - } - @Override public void mouseExited(MouseEvent e) { try { - p.setSelected(false); + ap.setSelected(false); } catch (Exception ex) { } - ; } @Override public void mouseEntered(MouseEvent e) { - try { - p.setSelected(true); + ap.setSelected(true); } catch (Exception ex) { } - ; - } - - @Override - public void mouseClicked(MouseEvent e) - { } }); - add(a); + add(checkBox); } }