{
// todo splitFrame a parameter (optional menu item choice)
boolean splitFrame = av.getCodingComplement() != null;
- AlignmentDimension aDimension = getAlignmentDimension(splitFrame);
- try
+ AlignmentDimension dim1 = getAlignmentDimension();
+ AlignmentDimension dim2 = new AlignmentDimension(0, 0);
+ if (splitFrame)
{
- jalview.util.ImageMaker im;
- final String imageAction, imageTitle;
- if (type == jalview.util.ImageMaker.TYPE.PNG)
- {
- imageAction = "Create PNG image from alignment";
- imageTitle = null;
- }
- else if (type == jalview.util.ImageMaker.TYPE.EPS)
- {
- imageAction = "Create EPS file from alignment";
- imageTitle = alignFrame.getTitle();
- }
- else
- {
- imageAction = "Create SVG file from alignment";
- imageTitle = alignFrame.getTitle();
- }
-
- im = new jalview.util.ImageMaker(this, type, imageAction,
- aDimension.width, aDimension.height + borderBottomOffset,
- file,
- imageTitle, alignFrame, pSessionId, headless);
- Graphics graphics = im.getGraphics();
- if (graphics != null)
- {
- if (av.getWrapAlignment())
- {
- printWrappedAlignment(aDimension.width,
- aDimension.height + borderBottomOffset, 0,
- graphics);
- }
- else
- {
- printUnwrapped(aDimension.width, aDimension.height, 0,
- graphics, graphics);
- }
+ AlignmentPanel comp = ((AlignViewport) av.getCodingComplement())
+ .getAlignPanel();
+ dim2 = comp.getAlignmentDimension();
+ }
+ final int graphicsHeight = dim1.height + dim2.height;
+ final int graphicsWidth = Math.max(dim1.width, dim2.width);
- if (splitFrame)
- {
- /*
- * append coding complement image
- * todo: always top frame first!
- */
- int h = getAlignmentDimension(false).height;
- graphics.translate(0, h);
- AlignmentPanel comp = ((AlignViewport) av.getCodingComplement())
- .getAlignPanel();
- if (av.getCodingComplement().getWrapAlignment())
- {
- comp.printWrappedAlignment(aDimension.width,
- aDimension.height + borderBottomOffset, 0, graphics);
- }
- else
- {
- comp.printUnwrapped(aDimension.width, aDimension.height, 0,
- graphics, graphics);
- }
- }
+ jalview.util.ImageMaker im;
+ final String imageAction, imageTitle;
+ if (type == jalview.util.ImageMaker.TYPE.PNG)
+ {
+ imageAction = "Create PNG image from alignment";
+ imageTitle = null;
+ }
+ else if (type == jalview.util.ImageMaker.TYPE.EPS)
+ {
+ imageAction = "Create EPS file from alignment";
+ imageTitle = alignFrame.getTitle();
+ }
+ else
+ {
+ imageAction = "Create SVG file from alignment";
+ imageTitle = alignFrame.getTitle();
+ }
- im.writeImage();
- }
- } catch (OutOfMemoryError err)
+ im = new jalview.util.ImageMaker(this, type, imageAction,
+ graphicsWidth, graphicsHeight + borderBottomOffset, file,
+ imageTitle, alignFrame, pSessionId, headless);
+ Graphics graphics = im.getGraphics();
+ if (graphics == null)
{
- // Be noisy here.
- System.out.println("########################\n" + "OUT OF MEMORY "
- + file + "\n" + "########################");
- new OOMWarning("Creating Image for " + file, err);
- // System.out.println("Create IMAGE: " + err);
- } catch (Exception ex)
+ return;
+ }
+ graphics.setColor(Color.white);
+ graphics.fillRect(0, 0, graphicsWidth, graphicsHeight);
+ if (av.getWrapAlignment())
{
- ex.printStackTrace();
+ printWrappedAlignment(dim1.width, dim1.height + borderBottomOffset,
+ 0, graphics);
+ }
+ else
+ {
+ printUnwrapped(dim1.width, dim1.height, 0, graphics, graphics);
}
- } finally
- {
- }
- }
+ if (splitFrame)
+ {
+ /*
+ * append coding complement image
+ * todo: always write top frame first!
+ */
+ graphics.translate(0, dim1.height);
+ AlignmentPanel comp = ((AlignViewport) av.getCodingComplement())
+ .getAlignPanel();
+ if (av.getCodingComplement().getWrapAlignment())
+ {
+ comp.printWrappedAlignment(dim2.width,
+ dim2.height + borderBottomOffset, 0, graphics);
+ }
+ else
+ {
+ comp.printUnwrapped(dim2.width, dim2.height, 0, graphics,
+ graphics);
+ }
+ }
- /**
- * Computes and answers the width and height of the alignment in pixels,
- * including
- * <ul>
- * <li>sequence ids</li>
- * <li>scale above, left or right if shown</li>
- * <li>sequences</li>
- * <li>annotations, if shown</li> The alignment may be in wrapped or unwrapped
- * mode.
- * <ul>
- *
- * @param splitFrame
- * if true, the combined dimensions of a split frame view
- * are computed: the sum of the two alignments' heights, and
- * the larger of their widths. Any additional height (e.g.
- * for frame titles) should be added separately.
- * @return
- */
- public AlignmentDimension getAlignmentDimension(boolean splitFrame)
- {
- AlignmentDimension d1 = getAlignmentDimension();
- if (!splitFrame)
+ im.writeImage();
+ } catch (OutOfMemoryError err)
{
- return d1;
+ // Be noisy here.
+ System.out.println("########################\n" + "OUT OF MEMORY "
+ + file + "\n" + "########################");
+ new OOMWarning("Creating Image for " + file, err);
+ // System.out.println("Create IMAGE: " + err);
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
}
- AlignmentPanel comp = ((AlignViewport) av.getCodingComplement())
- .getAlignPanel();
- AlignmentDimension d2 = comp.getAlignmentDimension();
-
- int h = d1.height + d2.height;
- int w = Math.max(d1.width, d2.width);
-
- return new AlignmentDimension(w, h);
}
/**
*
* @return
*/
- AlignmentDimension getAlignmentDimension()
+ public AlignmentDimension getAlignmentDimension()
{
int maxwidth = av.getAlignment().getVisibleWidth();