import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
+import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.print.PageFormat;
import java.awt.print.PrinterJob;
import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
/**
* Current filename for this alignment
*/
- String fileName = null;
+ private String fileName = null;
- File fileObject;
+ private File fileObject;
/**
* Creates a new AlignFrame object with specific width and height.
viewport = new AlignViewport(al, hiddenColumns, sequenceSetId, viewId);
- alignPanel = new AlignmentPanel(this, viewport);
-
- addAlignmentPanel(alignPanel, true);
init();
}
{
viewport.hideSequence(hiddenSeqs);
}
- alignPanel = new AlignmentPanel(this, viewport);
- addAlignmentPanel(alignPanel, true);
init();
}
{
viewport = ap.av;
alignPanel = ap;
- addAlignmentPanel(ap, false);
init();
}
*/
void init()
{
-// setBackground(Color.white); // BH 2019
+ boolean newPanel = (alignPanel == null);
+ viewport.setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
+ if (newPanel)
+ {
+ if (Platform.isJS())
+ {
+ // need to set this up front if NOANNOTATION is
+ // used in conjunction with SHOWOVERVIEW.
+
+ // I have not determined if this is appropriate for
+ // Jalview/Java, as it means we are setting this flag
+ // for all subsequent AlignFrames. For now, at least,
+ // I am setting it to be JalviewJS-only.
+
+ boolean showAnnotation = Jalview.getInstance().getShowAnnotation();
+ viewport.setShowAnnotation(showAnnotation);
+ }
+ alignPanel = new AlignmentPanel(this, viewport);
+ }
+ addAlignmentPanel(alignPanel, newPanel);
+
+ // setBackground(Color.white); // BH 2019
if (!Jalview.isHeadlessMode())
{
progressBar = new ProgressBar(this.statusPanel, this.statusBar);
+ statusPanel.setVisible(Jalview.getInstance().getShowStatus());
+ alignFrameMenuBar.setVisible(Jalview.getInstance().getAllowMenuBar());
}
avc = new jalview.controller.AlignViewController(this, viewport,
sortPairwiseMenuItem_actionPerformed(null);
}
- this.alignPanel.av
- .setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
-
setMenusFromViewport(viewport);
buildSortByAnnotationScoresMenu();
calculateTree.addActionListener(new ActionListener()
if (Desktop.getDesktopPane() != null)
{
this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
- if (!Platform.isJS())
+ PropertyChangeListener serviceListener = (Platform.isJS() ? null
+ : addServiceListeners());
+ addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
{
- addServiceListeners();
- }
+ @Override
+ public void internalFrameClosed(
+ javax.swing.event.InternalFrameEvent evt)
+ {
+ // System.out.println("deregistering discoverer listener");
+ if (serviceListener != null)
+ {
+ Desktop.getInstance().removeJalviewPropertyChangeListener(
+ "services", serviceListener);
+ }
+ closeMenuItem_actionPerformed(true);
+ }
+ });
+
setGUINucleotide();
}
switch (evt.getKeyCode())
{
- case 27: // escape key
+ case KeyEvent.VK_ESCAPE: // escape key
deselectAllSequenceMenuItem_actionPerformed(null);
break;
{
ap.av.getAlignment().padGaps();
}
- ap.av.updateConservation(ap);
- ap.av.updateConsensus(ap);
- ap.av.updateStrucConsensus(ap);
+ if (Jalview.getInstance().getStartCalculations())
+ {
+ ap.av.updateConservation(ap);
+ ap.av.updateConsensus(ap);
+ ap.av.updateStrucConsensus(ap);
+ }
}
}
}
/* Set up intrinsic listeners for dynamically generated GUI bits. */
- private void addServiceListeners()
+ private PropertyChangeListener addServiceListeners()
{
- final java.beans.PropertyChangeListener thisListener;
- Desktop.getInstance().addJalviewPropertyChangeListener("services",
- thisListener = new java.beans.PropertyChangeListener()
- {
- @Override
- public void propertyChange(PropertyChangeEvent evt)
- {
- // // System.out.println("Discoverer property change.");
- // if (evt.getPropertyName().equals("services"))
- {
- SwingUtilities.invokeLater(new Runnable()
- {
-
- @Override
- public void run()
- {
- System.err.println(
- "Rebuild WS Menu for service change");
- BuildWebServiceMenu();
- }
-
- });
- }
- }
- });
- addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
+ PropertyChangeListener serviceListener = new PropertyChangeListener()
{
@Override
- public void internalFrameClosed(
- javax.swing.event.InternalFrameEvent evt)
+ public void propertyChange(PropertyChangeEvent evt)
{
- // System.out.println("deregistering discoverer listener");
- Desktop.getInstance().removeJalviewPropertyChangeListener("services",
- thisListener);
- closeMenuItem_actionPerformed(true);
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+
+ @Override
+ public void run()
+ {
+ System.err.println("Rebuild WS Menu for service change");
+ BuildWebServiceMenu();
+ }
+ });
+ }
}
- });
+ };
+
+ Desktop.getInstance().addJalviewPropertyChangeListener("services",
+ serviceListener);
// Finally, build the menu once to get current service state
new Thread(new Runnable()
{
BuildWebServiceMenu();
}
}).start();
+ return serviceListener;
}
/**
/*
* Show/hide annotations only enabled if annotation panel is shown
*/
- showAllSeqAnnotations.setEnabled(annotationPanelMenuItem.getState());
- hideAllSeqAnnotations.setEnabled(annotationPanelMenuItem.getState());
- showAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState());
- hideAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState());
+ syncAnnotationMenuItems();
+
viewBoxesMenuItem.setSelected(av.getShowBoxes());
viewTextMenuItem.setSelected(av.getShowText());
showNonconservedMenuItem.setSelected(av.getShowUnconserved());
applyToAllGroups.setState(av.getColourAppliesToAllGroups());
showNpFeatsMenuitem.setSelected(av.isShowNPFeats());
showDbRefsMenuitem.setSelected(av.isShowDBRefs());
- autoCalculate.setSelected(av.autoCalculateConsensus);
+ autoCalculate.setSelected(av.getAutoCalculateConsensusAndConservation());
sortByTree.setSelected(av.sortByTree);
listenToViewSelections.setSelected(av.followSelection);
@Override
public void reload_actionPerformed(ActionEvent e)
{
+ System.out.println("AlignFrame.reload " + fileName);
if (fileName != null)
{
// TODO: JAL-1108 - ensure all associated frames are closed regardless of
DataSourceType protocol = fileName.startsWith("http:")
? DataSourceType.URL
: DataSourceType.FILE;
- loader.loadFile(viewport, fileName, protocol, currentFileFormat);
+ loader.loadFile(viewport,
+ (fileObject == null ? fileName : fileObject), protocol,
+ currentFileFormat);
}
else
{
{
final boolean setVisible = annotationPanelMenuItem.isSelected();
viewport.setShowAnnotation(setVisible);
- this.showAllSeqAnnotations.setEnabled(setVisible);
- this.hideAllSeqAnnotations.setEnabled(setVisible);
- this.showAllAlAnnotations.setEnabled(setVisible);
- this.hideAllAlAnnotations.setEnabled(setVisible);
+ syncAnnotationMenuItems();
alignPanel.updateLayout();
}
+ private void syncAnnotationMenuItems()
+ {
+ final boolean setVisible = annotationPanelMenuItem.isSelected();
+ showAllSeqAnnotations.setEnabled(setVisible);
+ hideAllSeqAnnotations.setEnabled(setVisible);
+ showAllAlAnnotations.setEnabled(setVisible);
+ hideAllAlAnnotations.setEnabled(setVisible);
+ }
+
+
@Override
public void alignmentProperties()
{
}
JInternalFrame frame = new JInternalFrame();
- final OverviewPanel overview = new OverviewPanel(alignPanel);
+
+ // BH 2019.07.26 we allow for an embedded
+ // undecorated overview with defined size
+ frame.setName(Jalview.getAppID("overview"));
+ //
+ Dimension dim = Platform.getDimIfEmbedded(frame, -1, -1);
+ if (dim != null && dim.width == 0)
+ {
+ dim = null; // hidden, not embedded
+ }
+ OverviewPanel overview = new OverviewPanel(alignPanel, dim);
+
frame.setContentPane(overview);
+ if (dim == null)
+ {
+ dim = new Dimension();
+ // was frame.getSize(), but that is 0,0 at this point;
+ }
+ else
+ {
+ // we are imbedding, and so we have an undecorated frame
+ // and we can set the the frame dimensions accordingly.
+ }
+ // allowing for unresizable option using, style="resize:none"
+ boolean resizable = (Platform.getEmbeddedAttribute(frame,
+ "resize") != "none");
Desktop.addInternalFrame(frame, MessageManager
.formatMessage("label.overview_params", new Object[]
- { this.getTitle() }), true, frame.getWidth(), frame.getHeight(),
- true, true);
+ { this.getTitle() }), true, dim.width, dim.height, resizable,
+ true);
frame.pack();
frame.setLayer(JLayeredPane.PALETTE_LAYER);
frame.addInternalFrameListener(
@Override
public void autoCalculate_actionPerformed(ActionEvent e)
{
- viewport.autoCalculateConsensus = autoCalculate.isSelected();
- if (viewport.autoCalculateConsensus)
+ viewport.setAutoCalculateConsensusAndConservation(autoCalculate.isSelected());
+ if (viewport.getAutoCalculateConsensusAndConservation())
{
viewport.firePropertyChange("alignment", null,
viewport.getAlignment().getSequences());
frameTitle += this.title;
- Desktop.addInternalFrame(tp, frameTitle, 600, 500);
+ Dimension dim = Platform.getDimIfEmbedded(tp, 600, 500);
+ Desktop.addInternalFrame(tp, frameTitle, dim.width, dim.height);
}
/**
if (nf.getTree() != null)
{
tp = new TreePanel(alignPanel, nf, treeTitle, input);
-
- tp.setSize(w, h);
+ Dimension dim = Platform.getDimIfEmbedded(tp, -1, -1);
+ if (dim == null)
+ {
+ dim = new Dimension(w, h);
+ }
+ else
+ {
+ // no offset, either
+ x = 0;
+ }
+ tp.setSize(dim.width, dim.height);
if (x > 0 && y > 0)
{
tp.setLocation(x, y);
}
- Desktop.addInternalFrame(tp, treeTitle, w, h);
+ Desktop.addInternalFrame(tp, treeTitle, dim.width, dim.height);
}
} catch (Exception ex)
{