X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignmentPanel.java;h=3dfb5105fcaf77d7c3312e8b0468d3bc5af44d09;hb=bf478b2e1087fb03bf6b9fb07f14a9e4f096892c;hp=065872fbd43182094b94b2526804c33f0d0ef9a4;hpb=a1984b1c8c273ed33c7ce9283039f4027dcae2de;p=jalview.git
diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java
index 065872f..3dfb510 100644
--- a/src/jalview/gui/AlignmentPanel.java
+++ b/src/jalview/gui/AlignmentPanel.java
@@ -20,29 +20,6 @@
*/
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;
@@ -67,6 +44,32 @@ import java.util.List;
import javax.swing.SwingUtilities;
+import jalview.analysis.AnnotationSorter;
+import jalview.api.AlignViewportI;
+import jalview.api.AlignmentViewPanel;
+import jalview.bin.Cache;
+import jalview.bin.Console;
+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.io.exceptions.ImageOutputException;
+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.util.imagemaker.BitmapImageSizing;
+import jalview.viewmodel.ViewportListenerI;
+import jalview.viewmodel.ViewportRanges;
+
/**
* DOCUMENT ME!
*
@@ -122,7 +125,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
*/
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));
@@ -229,6 +232,10 @@ public class AlignmentPanel extends GAlignmentPanel implements
// to prevent drawing old image
FontMetrics fm = getFontMetrics(av.getFont());
+ // update the flag controlling whether the grid is too small to render the
+ // font
+ av.validCharWidth = fm.charWidth('M') <= av.getCharWidth();
+
scalePanelHolder.setPreferredSize(
new Dimension(10, av.getCharHeight() + fm.getDescent()));
idSpaceFillerPanel1.setPreferredSize(
@@ -471,8 +478,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
/*
* 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
@@ -572,7 +578,6 @@ public class AlignmentPanel extends GAlignmentPanel implements
Dimension e = idPanel.getSize();
alabels.setSize(new Dimension(e.width, annotationHeight));
-
annotationSpaceFillerHolder.setPreferredSize(new Dimension(
annotationSpaceFillerHolder.getWidth(), annotationHeight));
annotationScroller.validate();
@@ -806,7 +811,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
// could not be validated and it is not clear if it is now being
// called. Log warning here in case it is called and unforeseen
// problems occur
- Cache.warn(
+ Console.warn(
"Unexpected path through code: Wrapped jar file opened with wrap alignment set in preferences");
// scroll to start of panel
@@ -1020,8 +1025,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
* 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))
@@ -1043,6 +1048,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
*/
alignmentGraphics.translate(alignmentGraphicsOffset,
alignmentDrawnHeight);
+ updateLayout();
getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(), av,
alignmentGraphics, -1, startRes, endRes + 1);
}
@@ -1065,8 +1071,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
*
* @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());
@@ -1118,8 +1124,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
g.translate(idWidth, 0);
- getSeqPanel().seqCanvas.drawWrappedPanelForPrinting(g, pageWidth - idWidth,
- totalHeight, 0);
+ getSeqPanel().seqCanvas.drawWrappedPanelForPrinting(g,
+ pageWidth - idWidth, totalHeight, 0);
if ((pageNumber * pageHeight) < totalHeight)
{
@@ -1169,14 +1175,23 @@ public class AlignmentPanel extends GAlignmentPanel implements
return (w > 0 ? w : calculateIdWidth().width);
}
+ void makeAlignmentImage(ImageMaker.TYPE type, File file, String renderer) throws ImageOutputException
+ {
+ makeAlignmentImage(type, file, renderer,
+ BitmapImageSizing.nullBitmapImageSizing());
+ }
+
/**
* Builds an image of the alignment of the specified type (EPS/PNG/SVG) and
* writes it to the specified file
*
* @param type
* @param file
+ * @param textrenderer
+ * @param bitmapscale
*/
- void makeAlignmentImage(ImageMaker.TYPE type, File file)
+ void makeAlignmentImage(ImageMaker.TYPE type, File file, String renderer,
+ BitmapImageSizing userBis) throws ImageOutputException
{
final int borderBottomOffset = 5;
@@ -1206,7 +1221,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
int imageWidth = aDimension.getWidth();
int imageHeight = aDimension.getHeight() + borderBottomOffset;
String of = MessageManager.getString("label.alignment");
- exporter.doExport(file, this, imageWidth, imageHeight, of);
+ exporter.doExport(file, this, imageWidth, imageHeight, of, renderer,
+ userBis);
}
/**
@@ -1250,7 +1266,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
}
- public void makePNGImageMap(File imgMapFile, String imageName)
+ public void makePNGImageMap(File imgMapFile, String imageName) throws ImageOutputException
{
// /////ONLY WORKS WITH NON WRAPPED ALIGNMENTS
// ////////////////////////////////////////////
@@ -1284,13 +1300,13 @@ public class AlignmentPanel extends GAlignmentPanel implements
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)
@@ -1307,7 +1323,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
text.append(" features = seq.findFeatures(column, column);
+ List features = seq.findFeatures(column,
+ column);
for (SequenceFeature sf : features)
{
if (sf.isContactFeature())
@@ -1373,7 +1391,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
} catch (Exception ex)
{
- ex.printStackTrace();
+ throw new ImageOutputException("couldn't write ImageMap due to unexpected error",ex);
}
} // /////////END OF IMAGE MAP
@@ -1464,9 +1482,9 @@ public class AlignmentPanel extends GAlignmentPanel implements
}
else
{
- if (Cache.isDebugEnabled())
+ if (Console.isDebugEnabled())
{
- Cache.warn("Closing alignment panel which is already closed.");
+ Console.warn("Closing alignment panel which is already closed.");
}
}
}
@@ -1546,11 +1564,12 @@ public class AlignmentPanel extends GAlignmentPanel implements
setAlignFrameView();
}
}
+
public void setAlignFrameView()
{
alignFrame.setDisplayedView(this);
}
-
+
@Override
public StructureSelectionManager getStructureSelectionManager()
{
@@ -1740,4 +1759,42 @@ public class AlignmentPanel extends GAlignmentPanel implements
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;
+ }
+
+ /**
+ * If this alignment panel has an Overview panel open, closes it
+ */
+ public void closeOverviewPanel()
+ {
+ if (overviewPanel != null)
+ {
+ overviewPanel.close();
+ overviewPanel = null;
+ }
+ }
+
}