}
tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
- /*
- * finally if new view has acquired an Overview window (because
- * Preferences option to open Overview is selected), set its title
- */
- OverviewPanel ov = newap.overviewPanel;
- if (ov != null)
- {
- String ttl = getOverviewTitle();
- ((JInternalFrame) SwingUtilities
- .getAncestorOfClass(JInternalFrame.class, ov))
- .setTitle(ttl);
- }
-
return newap;
}
return alignPanel.overviewPanel;
}
JInternalFrame frame = new JInternalFrame();
- final OverviewPanel overview = new OverviewPanel(alignPanel, showHidden);
+ final OverviewPanel overview = new OverviewPanel(alignPanel, frame, showHidden);
frame.setContentPane(overview);
- String overviewTitle = getOverviewTitle();
- Desktop.addInternalFrame(frame, overviewTitle, true, frame.getWidth(), frame.getHeight(),
+ Desktop.addInternalFrame(frame, "", true, frame.getWidth(), frame.getHeight(),
true, true);
frame.pack();
frame.setLayer(JLayeredPane.PALETTE_LAYER);
}
alignPanel.setOverviewPanel(overview);
+ alignPanel.setOverviewTitle(this);
return overview;
}
- /**
- * Constructs a title for the Overview window including the alignment window's
- * title, and view name (if applicable)
- *
- * @return
- */
- public String getOverviewTitle()
- {
- String overviewTitle = MessageManager
- .formatMessage("label.overview_params", new Object[]
- { this.getTitle() });
- String viewName = alignPanel.getViewName();
- if (viewName != null)
- {
- overviewTitle += (" " + viewName);
- }
- return overviewTitle;
- }
-
@Override
public void textColour_actionPerformed()
{
{
if (index > -1)
{
+ /*
+ * update current Overview window title (if there is one)
+ * to add view name "Original" if necessary
+ */
+ alignPanel.setOverviewTitle(this);
+
+ /*
+ * switch panels and set Overview title (if there is one
+ * because it was opened automatically)
+ */
alignPanel = alignPanels.get(index);
+ alignPanel.setOverviewTitle(this);
+
viewport = alignPanel.av;
avc.setViewportAndAlignmentPanel(viewport, alignPanel);
setMenusFromViewport(viewport);
*/
package jalview.gui;
-import jalview.analysis.AnnotationSorter;
-import jalview.api.AlignViewportI;
-import jalview.api.AlignmentViewPanel;
-import jalview.bin.Cache;
-import jalview.bin.Jalview;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.HiddenColumns;
-import jalview.datamodel.SearchResultsI;
-import jalview.datamodel.SequenceFeature;
-import jalview.datamodel.SequenceGroup;
-import jalview.datamodel.SequenceI;
-import jalview.gui.ImageExporter.ImageWriterI;
-import jalview.io.HTMLOutput;
-import jalview.jbgui.GAlignmentPanel;
-import jalview.math.AlignmentDimension;
-import jalview.schemes.ResidueProperties;
-import jalview.structure.StructureSelectionManager;
-import jalview.util.Comparison;
-import jalview.util.ImageMaker;
-import jalview.util.MessageManager;
-import jalview.viewmodel.ViewportListenerI;
-import jalview.viewmodel.ViewportRanges;
-
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import javax.swing.SwingUtilities;
+import jalview.analysis.AnnotationSorter;
+import jalview.api.AlignViewportI;
+import jalview.api.AlignmentViewPanel;
+import jalview.bin.Cache;
+import jalview.bin.Jalview;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.SearchResultsI;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.gui.ImageExporter.ImageWriterI;
+import jalview.io.HTMLOutput;
+import jalview.jbgui.GAlignmentPanel;
+import jalview.math.AlignmentDimension;
+import jalview.schemes.ResidueProperties;
+import jalview.structure.StructureSelectionManager;
+import jalview.util.Comparison;
+import jalview.util.ImageMaker;
+import jalview.util.MessageManager;
+import jalview.viewmodel.ViewportListenerI;
+import jalview.viewmodel.ViewportRanges;
+
/**
* DOCUMENT ME!
*
*/
public AlignmentPanel(AlignFrame af, final AlignViewport av)
{
-// setBackground(Color.white); // BH 2019
+ // setBackground(Color.white); // BH 2019
alignFrame = af;
this.av = av;
setSeqPanel(new SeqPanel(av, this));
/*
* Scroll down to make end of search results visible
*/
- setScrollValues(ranges.getStartRes(), starts + seqIndex - ends
- + 1);
+ setScrollValues(ranges.getStartRes(), starts + seqIndex - ends + 1);
}
/*
* Else results are already visible - no need to scroll
Dimension e = idPanel.getSize();
alabels.setSize(new Dimension(e.width, annotationHeight));
-
annotationSpaceFillerHolder.setPreferredSize(new Dimension(
annotationSpaceFillerHolder.getWidth(), annotationHeight));
annotationScroller.validate();
* single graphics context), then reset to (0, scale height)
*/
alignmentGraphics.translate(alignmentGraphicsOffset, scaleHeight);
- getSeqPanel().seqCanvas.drawPanelForPrinting(alignmentGraphics, startRes,
- endRes, startSeq, endSeq - 1);
+ getSeqPanel().seqCanvas.drawPanelForPrinting(alignmentGraphics,
+ startRes, endRes, startSeq, endSeq - 1);
alignmentGraphics.translate(-alignmentGraphicsOffset, 0);
if (av.isShowAnnotation() && (endSeq == alignmentHeight))
*
* @throws PrinterException
*/
- public int printWrappedAlignment(int pageWidth, int pageHeight, int pageNumber,
- Graphics g) throws PrinterException
+ public int printWrappedAlignment(int pageWidth, int pageHeight,
+ int pageNumber, Graphics g) throws PrinterException
{
getSeqPanel().seqCanvas.calculateWrappedGeometry(getWidth(),
getHeight());
g.translate(idWidth, 0);
- getSeqPanel().seqCanvas.drawWrappedPanelForPrinting(g, pageWidth - idWidth,
- totalHeight, 0);
+ getSeqPanel().seqCanvas.drawWrappedPanelForPrinting(g,
+ pageWidth - idWidth, totalHeight, 0);
if ((pageNumber * pageHeight) < totalHeight)
{
String triplet = null;
if (av.getAlignment().isNucleotide())
{
- triplet = ResidueProperties.nucleotideName.get(seq
- .getCharAt(column) + "");
+ triplet = ResidueProperties.nucleotideName
+ .get(seq.getCharAt(column) + "");
}
else
{
- triplet = ResidueProperties.aa2Triplet.get(seq.getCharAt(column)
- + "");
+ triplet = ResidueProperties.aa2Triplet
+ .get(seq.getCharAt(column) + "");
}
if (triplet == null)
text.append("<area shape=\"rect\" coords=\"")
.append((idWidth + column * av.getCharWidth()))
.append(",").append(sy).append(",")
- .append((idWidth + (column + 1) * av.getCharWidth()))
+ .append((idWidth
+ + (column + 1) * av.getCharWidth()))
.append(",").append((av.getCharHeight() + sy))
.append("\"").append(" onMouseOver=\"toolTip('")
.append(seqPos).append(" ").append(triplet);
}
if (!Comparison.isGap(seq.getCharAt(column)))
{
- List<SequenceFeature> features = seq.findFeatures(column, column);
+ List<SequenceFeature> features = seq.findFeatures(column,
+ column);
for (SequenceFeature sf : features)
{
if (sf.isContactFeature())
return calculationDialog;
}
+ /**
+ * Constructs and sets the title for the Overview window (if there is one),
+ * including the align frame's title, and view name (if applicable). Returns
+ * the title, or null if this panel has no Overview window open.
+ *
+ * @param alignFrame
+ * @return
+ */
+ public String setOverviewTitle(AlignFrame alignFrame)
+ {
+ if (this.overviewPanel == null)
+ {
+ return null;
+ }
+ String overviewTitle = MessageManager
+ .formatMessage("label.overview_params", new Object[]
+ { alignFrame.getTitle() });
+ String viewName = getViewName();
+ if (viewName != null)
+ {
+ overviewTitle += (" " + viewName);
+ }
+ overviewPanel.setTitle(overviewTitle);
+ return overviewTitle;
+ }
+
}
import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.Dimension;
+import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
private AlignmentPanel ap;
+ private JInternalFrame internalFrame;
+
protected JCheckBoxMenuItem displayToggle;
protected boolean showHidden = true;
*
* @param alPanel
* The alignment panel which is shown in the overview panel
- * @param isShowHidden TODO
+ * @param frame
+ * @param isShowHidden
+ * TODO
*/
- public OverviewPanel(AlignmentPanel alPanel, boolean isShowHidden)
+ public OverviewPanel(AlignmentPanel alPanel, JInternalFrame frame,
+ boolean isShowHidden)
{
this.av = alPanel.av;
this.ap = alPanel;
+ this.internalFrame = frame;
showHidden = isShowHidden;
if (showHidden)
{
od = new OverviewDimensionsShowHidden(av.getRanges(),
- (av.isShowAnnotation()
- && av.getAlignmentConservationAnnotation() != null));
+ (av.isShowAnnotation()
+ && av.getAlignmentConservationAnnotation() != null));
}
else
{
// without this the overview window does not size to fit the overview canvas
setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
-
+
addComponentListener(new ComponentAdapter()
{
@Override
@Override
public void mousePressed(MouseEvent evt)
{
-
- if (Platform.isWinRightButton(evt)) {
- showPopupMenu(evt);
- return;
- }
- if (SwingUtilities.isRightMouseButton(evt)) {
- return;
+
+ if (Platform.isWinRightButton(evt))
+ {
+ showPopupMenu(evt);
+ return;
}
- // don't do anything if the mouse press is in the overview's box
- // (wait to see if it's a drag instead)
- // otherwise update the viewport
- if (!od.isPositionInBox(evt.getX(), evt.getY()))
- {
- draggingBox = false;
+ if (SwingUtilities.isRightMouseButton(evt))
+ {
+ return;
+ }
+ // don't do anything if the mouse press is in the overview's box
+ // (wait to see if it's a drag instead)
+ // otherwise update the viewport
+ if (!od.isPositionInBox(evt.getX(), evt.getY()))
+ {
+ draggingBox = false;
- // display drag cursor at mouse position
- setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
+ // display drag cursor at mouse position
+ setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
- od.updateViewportFromMouse(evt.getX(), evt.getY(),
- av.getAlignment().getHiddenSequences(),
- av.getAlignment().getHiddenColumns());
- getParent().setCursor(
- Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
- }
- else
- {
- draggingBox = true;
- od.setDragPoint(evt.getX(), evt.getY(),
- av.getAlignment().getHiddenSequences(),
- av.getAlignment().getHiddenColumns());
- }
+ od.updateViewportFromMouse(evt.getX(), evt.getY(),
+ av.getAlignment().getHiddenSequences(),
+ av.getAlignment().getHiddenColumns());
+ getParent().setCursor(
+ Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+ }
+ else
+ {
+ draggingBox = true;
+ od.setDragPoint(evt.getX(), evt.getY(),
+ av.getAlignment().getHiddenSequences(),
+ av.getAlignment().getHiddenColumns());
+ }
}
@Override
od.setWidth(getWidth());
od.setHeight(getHeight() - progressPanel.getHeight());
}
-
+
setPreferredSize(new Dimension(od.getWidth(),
od.getHeight() + progressPanel.getHeight()));
thread.start();
repaint();
-
}
@Override
* close the parent frame (which also removes it from the
* Desktop Windows menu)
*/
- ((JInternalFrame) SwingUtilities.getAncestorOfClass(
- JInternalFrame.class, (this))).setClosed(true);
+ internalFrame.setClosed(true);
} catch (PropertyVetoException e)
{
// ignore
oviewCanvas = null;
ap = null;
od = null;
+ internalFrame = null;
}
}
-
+
public boolean isShowHiddenRegions()
{
return showHidden;
{
return oviewCanvas;
}
+
+ /**
+ * Sets the title of the enclosing frame
+ *
+ * @param title
+ */
+ public void setTitle(String title)
+ {
+ internalFrame.setTitle(title);
+ }
+
+ /**
+ * Returns the title of the enclosing frame
+ *
+ * @return title
+ */
+ public String getTitle()
+ {
+ return internalFrame.getTitle();
+ }
+
+ /**
+ * Overridden to set the bounds of the frame holding the Overview panel
+ *
+ * @param xpos
+ * @param ypos
+ * @param width
+ * @param height
+ */
+ @Override
+ public void setBounds(int xpos, int ypos, int width, int height)
+ {
+ internalFrame.setBounds(xpos, ypos, width, height);
+ }
+
+ /**
+ * Overridden to return the bounds of the enclosing frame
+ *
+ * @return
+ */
+ @Override
+ public Rectangle getBounds()
+ {
+ return internalFrame.getBounds();
+ }
}
import java.util.StringTokenizer;
import java.util.Vector;
-import javax.swing.JInternalFrame;
import javax.swing.SwingUtilities;
import jalview.api.ComplexAlignFile;
import jalview.gui.AlignViewport;
import jalview.gui.Desktop;
import jalview.gui.JvOptionPane;
-import jalview.gui.OverviewPanel;
import jalview.json.binding.biojson.v1.ColourSchemeMapper;
import jalview.project.Jalview2XML;
import jalview.schemes.ColourSchemeI;
// that perform queries to find the 'current working alignment'
Desktop.addInternalFrame(alignFrame, title,
AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
-
- OverviewPanel ov = alignFrame.alignPanel.getOverviewPanel();
- if (ov != null)
- {
- /*
- * Overview automatically opened with alignment
- * - set its title now alignFrame title has been set
- */
- String ttl = alignFrame.getOverviewTitle();
- ((JInternalFrame) SwingUtilities
- .getAncestorOfClass(JInternalFrame.class, ov))
- .setTitle(ttl);
- }
+ /*
+ * for an Overview automatically opened with alignment,
+ * set its title now alignFrame title has been set
+ */
+ alignFrame.alignPanel.setOverviewTitle(alignFrame);
}
try
if (ov != null)
{
Overview overview = new Overview();
- JInternalFrame frame = (JInternalFrame) SwingUtilities
- .getAncestorOfClass(JInternalFrame.class, ov);
- overview.setTitle(frame.getTitle());
- Rectangle bounds = frame.getBounds();
+ overview.setTitle(ov.getTitle());
+ Rectangle bounds = ov.getBounds();
overview.setXpos(bounds.x);
overview.setYpos(bounds.y);
overview.setWidth(bounds.width);
{
OverviewPanel overviewPanel = af
.openOverviewPanel(overview.isShowHidden());
- JInternalFrame frame = (JInternalFrame) SwingUtilities
- .getAncestorOfClass(JInternalFrame.class, overviewPanel);
- frame.setTitle(overview.getTitle());
- frame.setBounds(overview.getXpos(), overview.getYpos(),
+ overviewPanel.setTitle(overview.getTitle());
+ overviewPanel.setBounds(overview.getXpos(), overview.getYpos(),
overview.getWidth(), overview.getHeight());
Color gap = new Color(overview.getGapColour());
Color residue = new Color(overview.getResidueColour());
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertNotNull;
import java.awt.Dimension;
import java.awt.Font;
Cache.setProperty("FIGURE_AUTOIDWIDTH", Boolean.TRUE.toString());
assertEquals(115, af.alignPanel.getVisibleIdWidth(false));
}
-}
+
+ @Test(groups = "Functional")
+ public void testSetOverviewTitle()
+ {
+ OverviewPanel ov1 = this.af.openOverviewPanel(true);
+ String alignFrameTitle = af.getTitle();
+ assertEquals(ov1.getTitle(), "Overview " + alignFrameTitle);
+
+ /*
+ * on New View, existing overview should get " Original" added to title
+ * and new view's overview should get " View 1" added
+ */
+ af.newView_actionPerformed(null);
+ assertEquals(ov1.getTitle(), "Overview " + alignFrameTitle + " Original");
+ OverviewPanel ov2 = this.af.openOverviewPanel(true);
+ assertEquals(ov2.getTitle(), "Overview " + alignFrameTitle + " View 1");
+ }
+
+ @Test(groups = "Functional")
+ public void testSetOverviewTitle_automaticOverview()
+ {
+ Cache.setProperty("SHOW_OVERVIEW", "true");
+ AlignFrame alignFrame = new FileLoader().LoadFileWaitTillLoaded(
+ "examples/uniref50.fa", DataSourceType.FILE);
+ OverviewPanel ov1 = alignFrame.alignPanel.getOverviewPanel();
+ assertNotNull(ov1);
+ String alignFrameTitle = alignFrame.getTitle();
+ assertEquals(ov1.getTitle(), "Overview " + alignFrameTitle);
+
+ /*
+ * on New View, existing overview should get " Original" added to title
+ * and new view's automatic overview should have " View 1" added
+ */
+ alignFrame.newView_actionPerformed(null);
+ assertEquals(ov1.getTitle(), "Overview " + alignFrameTitle + " Original");
+ OverviewPanel ov2 = alignFrame.alignPanel.getOverviewPanel();
+ assertNotNull(ov2);
+ assertEquals(ov2.getTitle(), "Overview " + alignFrameTitle + " View 1");
+ }
+}
\ No newline at end of file