Issue #2312 Add ability to export gif and image export dialog.
Change-Id: I10aaeba20a4acc7888cd566107ffff3e6a4fad05 Former-commit-id: e2159c422ca93aa76c6ba7a30a09234e8f9da4ce
This commit is contained in:
parent
86b8322391
commit
fc1c56f9cb
24 changed files with 1205 additions and 362 deletions
|
@ -85,6 +85,12 @@
|
|||
install-size="0"
|
||||
version="0.0.0"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.viz.image.export"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.viz.ui.tools.looping"
|
||||
download-size="0"
|
||||
|
|
|
@ -1,30 +1,27 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Nsharp
|
||||
Bundle-Name: D2D Nsharp
|
||||
Bundle-SymbolicName: com.raytheon.uf.viz.d2d.nsharp;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Activator: com.raytheon.uf.viz.d2d.nsharp.Activator
|
||||
Bundle-Version: 1.14.0.qualifier
|
||||
Bundle-Vendor: RAYTHEON
|
||||
Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
|
||||
gov.noaa.nws.ncep.ui.nsharp;bundle-version="1.0.0",
|
||||
com.raytheon.uf.viz.core;bundle-version="1.12.1174",
|
||||
com.raytheon.viz.ui;bundle-version="1.12.1174",
|
||||
org.eclipse.ui;bundle-version="3.6.1",
|
||||
gov.noaa.nws.ncep.viz.common;bundle-version="1.0.0",
|
||||
gov.noaa.nws.ncep.edex.common;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.time;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.topo;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.geospatial;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.pointdata;bundle-version="1.12.1174",
|
||||
com.raytheon.viz.pointdata;bundle-version="1.12.1174",
|
||||
javax.measure;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.sounding;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.wxmath;bundle-version="1.0.0"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Require-Bundle: com.raytheon.uf.viz.core;bundle-version="1.14.0",
|
||||
com.raytheon.viz.ui;bundle-version="1.14.0",
|
||||
gov.noaa.nws.ncep.ui.nsharp,
|
||||
com.raytheon.uf.common.sounding,
|
||||
gov.noaa.nws.ncep.viz.common,
|
||||
gov.noaa.nws.ncep.edex.common,
|
||||
com.raytheon.uf.common.wxmath,
|
||||
javax.measure,
|
||||
com.raytheon.uf.common.dataplugin,
|
||||
com.raytheon.uf.common.pointdata;bundle-version="1.13.0",
|
||||
com.raytheon.uf.common.geospatial,
|
||||
com.raytheon.uf.common.time,
|
||||
com.raytheon.uf.common.topo,
|
||||
com.raytheon.viz.pointdata,
|
||||
com.raytheon.uf.viz.image.export;bundle-version="1.14.0",
|
||||
org.eclipse.core.runtime;bundle-version="3.8.0"
|
||||
Export-Package: com.raytheon.uf.viz.d2d.nsharp,
|
||||
com.raytheon.uf.viz.d2d.nsharp.display,
|
||||
com.raytheon.uf.viz.d2d.nsharp.rsc
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
point="org.eclipse.ui.handlers">
|
||||
<handler
|
||||
class="com.raytheon.uf.viz.d2d.nsharp.rsc.action.NSharpSaveScreenAction"
|
||||
commandId="com.raytheon.viz.ui.actions.saveScreen">
|
||||
commandId="com.raytheon.uf.viz.image.export.save">
|
||||
<activeWhen>
|
||||
<with variable="activeEditorId">
|
||||
<equals value="gov.noaa.nws.ncep.ui.nsharp.display.NsharpEditor"/>
|
||||
|
@ -45,7 +45,7 @@
|
|||
</handler>
|
||||
<handler
|
||||
class="com.raytheon.uf.viz.d2d.nsharp.rsc.action.NSharpPrintScreenAction"
|
||||
commandId="com.raytheon.viz.ui.actions.printScreenAction">
|
||||
commandId="com.raytheon.uf.viz.image.export.print">
|
||||
<activeWhen>
|
||||
<with variable="activeEditorId">
|
||||
<equals value="gov.noaa.nws.ncep.ui.nsharp.display.NsharpEditor"/>
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.d2d.nsharp;
|
||||
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
*
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 12, 2011 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Activator implements BundleActivator {
|
||||
|
||||
private static BundleContext context;
|
||||
|
||||
static BundleContext getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext
|
||||
* )
|
||||
*/
|
||||
public void start(BundleContext bundleContext) throws Exception {
|
||||
Activator.context = bundleContext;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void stop(BundleContext bundleContext) throws Exception {
|
||||
Activator.context = null;
|
||||
}
|
||||
|
||||
}
|
|
@ -36,8 +36,8 @@ import org.eclipse.ui.PlatformUI;
|
|||
import com.raytheon.uf.viz.core.IDisplayPane;
|
||||
import com.raytheon.uf.viz.core.datastructure.LoopProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.image.export.handler.PrintImageCaptureHandler;
|
||||
import com.raytheon.viz.ui.EditorUtil;
|
||||
import com.raytheon.viz.ui.actions.PrintScreenAction;
|
||||
import com.raytheon.viz.ui.editor.AbstractEditor;
|
||||
|
||||
/**
|
||||
|
@ -56,7 +56,7 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
|
|||
* @author chammack
|
||||
* @version 1
|
||||
*/
|
||||
public class NSharpPrintScreenAction extends PrintScreenAction {
|
||||
public class NSharpPrintScreenAction extends PrintImageCaptureHandler {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.util.List;
|
|||
import com.raytheon.uf.viz.core.IDisplayPane;
|
||||
import com.raytheon.uf.viz.core.datastructure.LoopProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.ui.actions.SaveScreenAction;
|
||||
import com.raytheon.uf.viz.image.export.handler.ExportImageHandler;
|
||||
import com.raytheon.viz.ui.editor.AbstractEditor;
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,7 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
|
|||
* @author chammack
|
||||
* @version 1
|
||||
*/
|
||||
public class NSharpSaveScreenAction extends SaveScreenAction {
|
||||
public class NSharpSaveScreenAction extends ExportImageHandler {
|
||||
|
||||
@Override
|
||||
protected BufferedImage captureCurrentFrames(AbstractEditor editor) {
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
style="push">
|
||||
</command>
|
||||
<command
|
||||
commandId="com.raytheon.viz.ui.actions.saveScreen"
|
||||
commandId="com.raytheon.uf.viz.image.export.save"
|
||||
label="Capture Window..."
|
||||
style="push">
|
||||
</command>
|
||||
|
|
7
cave/com.raytheon.uf.viz.image.export/.classpath
Normal file
7
cave/com.raytheon.uf.viz.image.export/.classpath
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
28
cave/com.raytheon.uf.viz.image.export/.project
Normal file
28
cave/com.raytheon.uf.viz.image.export/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.raytheon.uf.viz.image.export</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,7 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
15
cave/com.raytheon.uf.viz.image.export/META-INF/MANIFEST.MF
Normal file
15
cave/com.raytheon.uf.viz.image.export/META-INF/MANIFEST.MF
Normal file
|
@ -0,0 +1,15 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Image Export
|
||||
Bundle-SymbolicName: com.raytheon.uf.viz.image.export;singleton:=true
|
||||
Bundle-Version: 1.14.0.qualifier
|
||||
Bundle-Vendor: RAYTHEON
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Require-Bundle: com.raytheon.viz.ui;bundle-version="1.14.0",
|
||||
com.raytheon.uf.viz.core;bundle-version="1.14.0",
|
||||
org.eclipse.core.runtime;bundle-version="3.8.0",
|
||||
com.raytheon.uf.common.time
|
||||
Export-Package: com.raytheon.uf.viz.image.export.dialog,
|
||||
com.raytheon.uf.viz.image.export.handler,
|
||||
com.raytheon.uf.viz.image.export.options
|
6
cave/com.raytheon.uf.viz.image.export/build.properties
Normal file
6
cave/com.raytheon.uf.viz.image.export/build.properties
Normal file
|
@ -0,0 +1,6 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
plugin.xml,\
|
||||
.
|
||||
|
85
cave/com.raytheon.uf.viz.image.export/plugin.xml
Normal file
85
cave/com.raytheon.uf.viz.image.export/plugin.xml
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
This_software_was_developed_and_/_or_modified_by_Raytheon_Company,
|
||||
pursuant_to_Contract_DG133W-05-CQ-1067_with_the_US_Government.
|
||||
|
||||
U.S._EXPORT_CONTROLLED_TECHNICAL_DATA
|
||||
This_software_product_contains_export-restricted_data_whose
|
||||
export/transfer/disclosure_is_restricted_by_U.S._law._Dissemination
|
||||
to_non-U.S._persons_whether_in_the_United_States_or_abroad_requires
|
||||
an_export_license_or_other_authorization.
|
||||
|
||||
Contractor_Name:________Raytheon_Company
|
||||
Contractor_Address:_____6825_Pine_Street,_Suite_340
|
||||
________________________Mail_Stop_B8
|
||||
________________________Omaha,_NE_68106
|
||||
________________________402.291.0100
|
||||
|
||||
See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for
|
||||
further_licensing_information.
|
||||
-->
|
||||
|
||||
<?eclipse version="3.2"?>
|
||||
<plugin>
|
||||
<extension
|
||||
point="org.eclipse.ui.commands">
|
||||
<command
|
||||
id="com.raytheon.uf.viz.image.export.print"
|
||||
categoryId="com.raytheon.uf.viz.core.commandCategory"
|
||||
description="Print the currently active editor"
|
||||
name="Print Screen">
|
||||
<commandParameter
|
||||
id="frameSelection"
|
||||
name="Frame Selection"
|
||||
optional="true">
|
||||
</commandParameter>
|
||||
</command>
|
||||
<command
|
||||
id="com.raytheon.uf.viz.image.export.save"
|
||||
categoryId="com.raytheon.uf.viz.core.commandCategory"
|
||||
description="Save the active editor to an image file"
|
||||
name="Save Screen">
|
||||
<commandParameter
|
||||
id="frameSelection"
|
||||
name="Frame Selection"
|
||||
optional="true">
|
||||
</commandParameter>
|
||||
<commandParameter
|
||||
id="dialogType"
|
||||
name="Type of Dialog"
|
||||
optional="true">
|
||||
</commandParameter>
|
||||
</command>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.handlers">
|
||||
<handler
|
||||
class="com.raytheon.uf.viz.image.export.handler.PrintImageCaptureHandler"
|
||||
commandId="com.raytheon.uf.viz.image.export.print">
|
||||
</handler>
|
||||
<handler
|
||||
class="com.raytheon.uf.viz.image.export.handler.ExportImageHandler"
|
||||
commandId="com.raytheon.uf.viz.image.export.save">
|
||||
</handler>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.menus">
|
||||
<menuContribution
|
||||
locationURI="menu:export">
|
||||
<command
|
||||
commandId="com.raytheon.uf.viz.image.export.save"
|
||||
label="Image"
|
||||
style="push">
|
||||
</command>
|
||||
<command
|
||||
commandId="com.raytheon.uf.viz.image.export.print"
|
||||
label="Print Screen"
|
||||
style="push">
|
||||
<parameter
|
||||
name="frameSelection"
|
||||
value="current">
|
||||
</parameter>
|
||||
</command>
|
||||
</menuContribution>
|
||||
</extension>
|
||||
</plugin>
|
|
@ -0,0 +1,441 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.image.export.dialog;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.layout.RowData;
|
||||
import org.eclipse.swt.layout.RowLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.FileDialog;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.viz.image.export.options.ImageExportOptions;
|
||||
import com.raytheon.uf.viz.image.export.options.ImageExportOptions.FrameSelection;
|
||||
import com.raytheon.uf.viz.image.export.options.ImageExportOptions.ImageFormat;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
||||
/**
|
||||
* Dialog to configure {@link ImageExportOptions} for exporting an image.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 20, 2014 2312 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ImageExportDialog extends CaveSWTDialog {
|
||||
|
||||
protected ImageExportOptions options;
|
||||
|
||||
protected Text locationText;
|
||||
|
||||
protected Button selectedFramesButton;
|
||||
|
||||
protected Button currentFramesButton;
|
||||
|
||||
protected Button allFramesButton;
|
||||
|
||||
protected Text framesFromText;
|
||||
|
||||
protected Text framesToText;
|
||||
|
||||
protected Button animatedButton;
|
||||
|
||||
protected Text frameDelayText;
|
||||
|
||||
protected Text firstFrameDwellText;
|
||||
|
||||
protected Text lastFrameDwellText;
|
||||
|
||||
public ImageExportDialog(Shell parentShell, ImageExportOptions options) {
|
||||
super(parentShell, SWT.RESIZE | SWT.DIALOG_TRIM);
|
||||
this.setText("Export Image");
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, true);
|
||||
Group locationGroup = new Group(shell, SWT.NONE);
|
||||
locationGroup.setLayoutData(gridData);
|
||||
initializeLocationGroup(locationGroup);
|
||||
|
||||
gridData = new GridData(SWT.FILL, SWT.TOP, true, true);
|
||||
Group framesGroup = new Group(shell, SWT.NONE);
|
||||
framesGroup.setLayoutData(gridData);
|
||||
initializeFramesGroup(framesGroup);
|
||||
|
||||
gridData = new GridData(SWT.FILL, SWT.TOP, true, true);
|
||||
Group optionsGroup = new Group(shell, SWT.NONE);
|
||||
optionsGroup.setLayoutData(gridData);
|
||||
initializeAnimationGroup(optionsGroup);
|
||||
|
||||
Composite buttonComposite = new Composite(shell, SWT.NONE);
|
||||
gridData = new GridData(SWT.CENTER, SWT.BOTTOM, true, false);
|
||||
buttonComposite.setLayoutData(gridData);
|
||||
initializeButtons(buttonComposite);
|
||||
|
||||
shell.pack();
|
||||
shell.setMinimumSize(shell.getSize());
|
||||
}
|
||||
|
||||
protected void initializeLocationGroup(Group group) {
|
||||
group.setLayout(new GridLayout(2, false));
|
||||
group.setText("Export Location");
|
||||
locationText = new Text(group, SWT.BORDER);
|
||||
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
gridData.widthHint = 250;
|
||||
locationText.setLayoutData(gridData);
|
||||
locationText.setText(options.getFileLocation().getAbsolutePath());
|
||||
Button button = new Button(group, SWT.PUSH);
|
||||
button.setText("Browse ...");
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
selectDestinationFile();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void initializeFramesGroup(Group group) {
|
||||
group.setLayout(new GridLayout(5, false));
|
||||
group.setText("Frame Selection");
|
||||
|
||||
allFramesButton = new Button(group, SWT.RADIO);
|
||||
allFramesButton.setText("All Frames");
|
||||
GridData gridData = new GridData();
|
||||
gridData.horizontalSpan = 5;
|
||||
allFramesButton.setLayoutData(gridData);
|
||||
|
||||
currentFramesButton = new Button(group, SWT.RADIO);
|
||||
currentFramesButton.setText("Current Frame");
|
||||
gridData = new GridData();
|
||||
gridData.horizontalSpan = 5;
|
||||
currentFramesButton.setLayoutData(gridData);
|
||||
|
||||
selectedFramesButton = new Button(group, SWT.RADIO);
|
||||
selectedFramesButton.setText("Frames");
|
||||
|
||||
switch (options.getFrameSelection()) {
|
||||
case ALL:
|
||||
allFramesButton.setSelection(true);
|
||||
break;
|
||||
case CURRENT:
|
||||
currentFramesButton.setSelection(true);
|
||||
break;
|
||||
case USER:
|
||||
selectedFramesButton.setSelection(true);
|
||||
}
|
||||
|
||||
new Label(group, SWT.NONE).setText("from:");
|
||||
framesFromText = new Text(group, SWT.BORDER);
|
||||
gridData = new GridData();
|
||||
gridData.widthHint = 24;
|
||||
framesFromText.setLayoutData(gridData);
|
||||
framesFromText.setEnabled(selectedFramesButton.getSelection());
|
||||
framesFromText.setText(String.valueOf(options.getFirstFrameIndex() + 1));
|
||||
new Label(group, SWT.NONE).setText("to:");
|
||||
framesToText = new Text(group, SWT.BORDER);
|
||||
gridData = new GridData();
|
||||
gridData.widthHint = 24;
|
||||
framesToText.setLayoutData(gridData);
|
||||
framesToText.setEnabled(selectedFramesButton.getSelection());
|
||||
framesToText.setText(String.valueOf(options.getLastFrameIndex() + 1));
|
||||
selectedFramesButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
framesToText.setEnabled(selectedFramesButton.getSelection());
|
||||
framesFromText.setEnabled(selectedFramesButton.getSelection());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
protected void initializeAnimationGroup(Group group) {
|
||||
group.setLayout(new GridLayout(3, false));
|
||||
group.setText("Animation Options");
|
||||
animatedButton = new Button(group, SWT.CHECK);
|
||||
GridData gridData = new GridData();
|
||||
gridData.horizontalSpan = 3;
|
||||
animatedButton.setLayoutData(gridData);
|
||||
animatedButton.setText("Animate");
|
||||
animatedButton
|
||||
.setSelection(options.getImageFormat() == ImageFormat.ANIMATION);
|
||||
animatedButton
|
||||
.setToolTipText("Generate an animated gif, without this a new file is generated for each frame.");
|
||||
animatedButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
frameDelayText.setEnabled(animatedButton.getSelection());
|
||||
firstFrameDwellText.setEnabled(animatedButton.getSelection());
|
||||
lastFrameDwellText.setEnabled(animatedButton.getSelection());
|
||||
}
|
||||
});
|
||||
gridData = new GridData();
|
||||
gridData.widthHint = 36;
|
||||
new Label(group, SWT.NONE).setText("Frame Delay:");
|
||||
frameDelayText = new Text(group, SWT.BORDER);
|
||||
frameDelayText.setLayoutData(gridData);
|
||||
frameDelayText.setEnabled(animatedButton.getSelection());
|
||||
frameDelayText.setText(millisToText(options.getFrameDelay()));
|
||||
new Label(group, SWT.NONE).setText("seconds");
|
||||
new Label(group, SWT.NONE).setText("First Frame Dwell:");
|
||||
firstFrameDwellText = new Text(group, SWT.BORDER);
|
||||
firstFrameDwellText.setLayoutData(gridData);
|
||||
firstFrameDwellText.setEnabled(animatedButton.getSelection());
|
||||
firstFrameDwellText.setText(millisToText(options.getFirstFrameDwell()));
|
||||
new Label(group, SWT.NONE).setText("seconds");
|
||||
new Label(group, SWT.NONE).setText("Last Frame Dwell:");
|
||||
lastFrameDwellText = new Text(group, SWT.BORDER);
|
||||
lastFrameDwellText.setLayoutData(gridData);
|
||||
lastFrameDwellText.setEnabled(animatedButton.getSelection());
|
||||
lastFrameDwellText.setText(millisToText(options.getLastFrameDwell()));
|
||||
new Label(group, SWT.NONE).setText("seconds");
|
||||
}
|
||||
|
||||
protected void initializeButtons(Composite comp) {
|
||||
comp.setLayout(new RowLayout(SWT.HORIZONTAL));
|
||||
Button okButton = new Button(comp, SWT.PUSH);
|
||||
okButton.setText("OK");
|
||||
okButton.setLayoutData(new RowData(100, SWT.DEFAULT));
|
||||
okButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
okPressed();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Button cancelButton = new Button(comp, SWT.PUSH);
|
||||
cancelButton.setText("Cancel");
|
||||
cancelButton.setLayoutData(new RowData(100, SWT.DEFAULT));
|
||||
cancelButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
close();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
protected String millisToText(int millis) {
|
||||
return Double.toString((double) millis / TimeUtil.MILLIS_PER_SECOND);
|
||||
}
|
||||
|
||||
protected void selectDestinationFile() {
|
||||
FileDialog fileDialog = new FileDialog(this.shell, SWT.SAVE);
|
||||
File file = new File(locationText.getText());
|
||||
fileDialog.setFileName(file.getName());
|
||||
if (file.getParentFile() != null && file.getParentFile().isDirectory()) {
|
||||
fileDialog.setFilterPath(file.getParent());
|
||||
}
|
||||
int index = 0;
|
||||
String[] ext = new String[ImageFormat.values().length];
|
||||
String[] names = new String[ImageFormat.values().length];
|
||||
for (ImageFormat format : ImageFormat.values()) {
|
||||
String[] exts = format.getExtensions();
|
||||
StringBuilder filter = new StringBuilder(exts.length * 7);
|
||||
for (String suffix : exts) {
|
||||
if (!suffix.isEmpty()) {
|
||||
if (filter.length() != 0) {
|
||||
filter.append(';');
|
||||
}
|
||||
filter.append("*.").append(suffix);
|
||||
}
|
||||
}
|
||||
ext[index] = filter.toString();
|
||||
names[index] = format.getDescription();
|
||||
if (animatedButton.getSelection()
|
||||
&& format == ImageFormat.ANIMATION) {
|
||||
fileDialog.setFilterIndex(index);
|
||||
} else if (format != ImageFormat.ANIMATION) {
|
||||
fileDialog.setFilterIndex(index);
|
||||
}
|
||||
index += 1;
|
||||
}
|
||||
fileDialog.setFilterExtensions(ext);
|
||||
fileDialog.setFilterNames(names);
|
||||
String path = fileDialog.open();
|
||||
if (path == null) {
|
||||
this.locationText.setText(path);
|
||||
}
|
||||
}
|
||||
|
||||
protected void okPressed() {
|
||||
options.setFileLocation(new File(locationText.getText()));
|
||||
|
||||
if (allFramesButton.getSelection()) {
|
||||
options.setFrameSelection(FrameSelection.ALL);
|
||||
} else if (currentFramesButton.getSelection()) {
|
||||
options.setFrameSelection(FrameSelection.CURRENT);
|
||||
} else {
|
||||
options.setFrameSelection(FrameSelection.USER);
|
||||
try {
|
||||
int from = Integer.parseInt(framesFromText.getText()) - 1;
|
||||
options.setFirstFrameIndex(from);
|
||||
} catch (NumberFormatException e) {
|
||||
invalidNumberMessage(framesFromText, "starting frame");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
int to = Integer.parseInt(framesToText.getText());
|
||||
options.setLastFrameIndex(to);
|
||||
} catch (NumberFormatException e) {
|
||||
invalidNumberMessage(framesToText, "ending frame");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (animatedButton.getSelection()) {
|
||||
options.setImageFormat(ImageFormat.ANIMATION);
|
||||
try {
|
||||
double delayS = Double.parseDouble(frameDelayText.getText());
|
||||
int delay = (int) (delayS * TimeUtil.MILLIS_PER_SECOND);
|
||||
options.setFrameDelay(delay);
|
||||
} catch (NumberFormatException e) {
|
||||
invalidNumberMessage(frameDelayText, "frame delay");
|
||||
|
||||
return;
|
||||
}
|
||||
try {
|
||||
double delayS = Double.parseDouble(firstFrameDwellText
|
||||
.getText());
|
||||
int delay = (int) (delayS * TimeUtil.MILLIS_PER_SECOND);
|
||||
options.setFirstFrameDwell(delay);
|
||||
} catch (NumberFormatException e) {
|
||||
invalidNumberMessage(firstFrameDwellText, "first frame dwell");
|
||||
|
||||
return;
|
||||
}
|
||||
try {
|
||||
double delayS = Double
|
||||
.parseDouble(lastFrameDwellText.getText());
|
||||
int delay = (int) (delayS / TimeUtil.MILLIS_PER_SECOND);
|
||||
options.setLastFrameDwell(delay);
|
||||
} catch (NumberFormatException e) {
|
||||
invalidNumberMessage(lastFrameDwellText, "last frame dwell");
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
options.setImageFormat(ImageFormat.SEQUENCE);
|
||||
}
|
||||
if (validate()) {
|
||||
setReturnValue(options);
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
protected void invalidNumberMessage(Text text, String description) {
|
||||
MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
|
||||
mb.setText("Invalid Number");
|
||||
mb.setMessage(text.getText()
|
||||
+ " is not a valid number, please enter a valid number for the "
|
||||
+ description + ".");
|
||||
mb.open();
|
||||
}
|
||||
|
||||
protected boolean validate() {
|
||||
if (options.getFrameSelection() == FrameSelection.USER
|
||||
&& (options.getFirstFrameIndex() > options.getLastFrameIndex() || options
|
||||
.getLastFrameIndex() < 0)) {
|
||||
MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
|
||||
mb.setText("Invalid Range");
|
||||
mb.setMessage("The frame range is invalid, please enter a valid range");
|
||||
mb.open();
|
||||
return false;
|
||||
}
|
||||
|
||||
String path = options.getFileLocation().getAbsolutePath();
|
||||
String suffix = path.substring(path.lastIndexOf('.') + 1);
|
||||
|
||||
boolean goodSuffix = false;
|
||||
for (String ext : options.getImageFormat().getExtensions()) {
|
||||
if (suffix.equals(ext)) {
|
||||
goodSuffix = true;
|
||||
}
|
||||
}
|
||||
if (!goodSuffix) {
|
||||
MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
|
||||
mb.setText("Invalid Suffix");
|
||||
mb.setMessage("The file extension(" + suffix
|
||||
+ ") of the selected file is not valid for "
|
||||
+ options.getImageFormat().getDescription());
|
||||
mb.open();
|
||||
return false;
|
||||
}
|
||||
|
||||
File file = options.getFileLocation();
|
||||
if (!file.getParentFile().exists()) {
|
||||
MessageBox mb = new MessageBox(getShell(), SWT.ICON_QUESTION
|
||||
| SWT.YES | SWT.NO);
|
||||
mb.setText("Create Directory");
|
||||
mb.setMessage("The directory " + file.getParent()
|
||||
+ " does not exist, would you like to create it.");
|
||||
int result = mb.open();
|
||||
if (result == SWT.YES) {
|
||||
if (!file.getParentFile().mkdirs()) {
|
||||
mb = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
|
||||
mb.setText("Error Creating Directory");
|
||||
mb.setMessage("An unspecified error has occurred creating the directory, please select a new file location.");
|
||||
mb.open();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (file.exists()) {
|
||||
MessageBox mb = new MessageBox(getShell(), SWT.ICON_WARNING
|
||||
| SWT.YES | SWT.NO);
|
||||
mb.setText("Overwrite file");
|
||||
mb.setMessage("The specified file already exists. Would you like to overwrite it?");
|
||||
int result = mb.open();
|
||||
if (result == SWT.NO) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,23 @@
|
|||
package com.raytheon.viz.ui.actions;
|
||||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.image.export.handler;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
|
@ -20,7 +39,27 @@ import com.raytheon.uf.viz.core.exception.VizException;
|
|||
import com.raytheon.viz.ui.EditorUtil;
|
||||
import com.raytheon.viz.ui.editor.AbstractEditor;
|
||||
|
||||
public abstract class AbstractScreenCaptureAction extends AbstractHandler {
|
||||
/**
|
||||
*
|
||||
* Abstract handler that provides the ability to grab frame(s) as buffered
|
||||
* iamges from the active editor. Subclasses are expected to implement
|
||||
* {@link #execute(org.eclipse.core.commands.ExecutionEvent)} and use the
|
||||
* capture...Frames methods to implement export capability.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 20, 2014 2312 bsteffen Move to image export plugin.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public abstract class AbstractImageCaptureHandler extends AbstractHandler {
|
||||
|
||||
protected BufferedImage captureCurrentFrames(AbstractEditor editor) {
|
||||
return editor.screenshot();
|
|
@ -0,0 +1,330 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
|
||||
package com.raytheon.uf.viz.image.export.handler;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.imageio.IIOImage;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.ImageTypeSpecifier;
|
||||
import javax.imageio.ImageWriteParam;
|
||||
import javax.imageio.ImageWriter;
|
||||
import javax.imageio.metadata.IIOInvalidTreeException;
|
||||
import javax.imageio.metadata.IIOMetadata;
|
||||
import javax.imageio.metadata.IIOMetadataNode;
|
||||
import javax.imageio.stream.FileImageOutputStream;
|
||||
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.FileDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.image.export.dialog.ImageExportDialog;
|
||||
import com.raytheon.uf.viz.image.export.options.ImageExportOptions;
|
||||
import com.raytheon.uf.viz.image.export.options.ImageExportOptions.FrameSelection;
|
||||
import com.raytheon.uf.viz.image.export.options.ImageExportOptions.ImageFormat;
|
||||
import com.raytheon.viz.ui.EditorUtil;
|
||||
import com.raytheon.viz.ui.editor.AbstractEditor;
|
||||
|
||||
/**
|
||||
* Save the current screen to an image file
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 26, 2006 chammack Initial Creation.
|
||||
* Jan 20, 2014 2312 bsteffen Move to image export plugin, animation.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
* @version 1
|
||||
*/
|
||||
public class ExportImageHandler extends AbstractImageCaptureHandler {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ExportImageHandler.class);
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
IEditorPart part = EditorUtil.getActiveEditor();
|
||||
AbstractEditor editor = null;
|
||||
if (part instanceof AbstractEditor) {
|
||||
editor = (AbstractEditor) part;
|
||||
}
|
||||
|
||||
if (editor == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Shell shell = HandlerUtil.getActiveShell(event);
|
||||
|
||||
ImageExportOptions options = new ImageExportOptions();
|
||||
options.populate(editor);
|
||||
String frameSelection = event.getParameter("frameSelection");
|
||||
if ("current".equalsIgnoreCase(frameSelection)) {
|
||||
options.setFrameSelection(FrameSelection.CURRENT);
|
||||
} else if ("all".equalsIgnoreCase(frameSelection)) {
|
||||
options.setFrameSelection(FrameSelection.ALL);
|
||||
}
|
||||
|
||||
String dialogType = event.getParameter("dialogType");
|
||||
if ("file".equalsIgnoreCase(dialogType)) {
|
||||
FileDialog fileDialog = new FileDialog(shell, SWT.SAVE);
|
||||
File file = options.getFileLocation();
|
||||
fileDialog.setFileName(file.getName());
|
||||
if (file.getParentFile() != null
|
||||
&& file.getParentFile().isDirectory()) {
|
||||
fileDialog.setFilterPath(file.getParent());
|
||||
}
|
||||
ImageFormat format = options.getImageFormat();
|
||||
String[] exts = format.getExtensions();
|
||||
StringBuilder filter = new StringBuilder(exts.length * 7);
|
||||
for (String suffix : exts) {
|
||||
if (!suffix.isEmpty()) {
|
||||
if (filter.length() != 0) {
|
||||
filter.append(';');
|
||||
}
|
||||
filter.append("*.").append(suffix);
|
||||
}
|
||||
}
|
||||
fileDialog.setFilterExtensions(new String[] { filter.toString() });
|
||||
fileDialog.setFilterNames(new String[] { format.getDescription() });
|
||||
String path = fileDialog.open();
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
options.setFileLocation(new File(path));
|
||||
|
||||
} else {
|
||||
/* Advanced dialog */
|
||||
ImageExportDialog dialog = new ImageExportDialog(shell, options);
|
||||
if (dialog.open() == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
List<BufferedImage> images = null;
|
||||
try {
|
||||
switch (options.getFrameSelection()) {
|
||||
case CURRENT:
|
||||
images = Arrays.asList(captureCurrentFrames(editor));
|
||||
break;
|
||||
case ALL:
|
||||
images = captureAllFrames(editor);
|
||||
break;
|
||||
case USER:
|
||||
images = captureFrames(editor, options.getFirstFrameIndex(),
|
||||
options.getLastFrameIndex());
|
||||
break;
|
||||
}
|
||||
} catch (VizException e) {
|
||||
String reason = "Error occurred while capturing images";
|
||||
statusHandler.handle(Priority.PROBLEM, reason, e);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!images.isEmpty()) {
|
||||
new SaveImageJob(options, images);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void saveImages(IProgressMonitor monitor,
|
||||
ImageExportOptions options, List<BufferedImage> images) {
|
||||
monitor.beginTask("Saving Images", images.size());
|
||||
|
||||
String path = options.getFileLocation().getAbsolutePath();
|
||||
|
||||
String suffix = path.substring(path.lastIndexOf('.') + 1);
|
||||
String basePath = path.substring(0, path.lastIndexOf('.'));
|
||||
Iterator<ImageWriter> iter = ImageIO.getImageWritersBySuffix(suffix);
|
||||
if (!iter.hasNext()) {
|
||||
String reason = "Unsupported filetype: \"" + suffix + "\"";
|
||||
statusHandler.handle(Priority.PROBLEM, reason);
|
||||
return;
|
||||
}
|
||||
ImageWriter writer = iter.next();
|
||||
|
||||
Closeable stream = null;
|
||||
try {
|
||||
if (images.size() == 1) {
|
||||
stream = new FileImageOutputStream(options.getFileLocation());
|
||||
writer.setOutput(stream);
|
||||
writer.write(images.get(0));
|
||||
stream.close();
|
||||
stream = null;
|
||||
monitor.worked(1);
|
||||
} else if (options.getImageFormat() == ImageFormat.SEQUENCE) {
|
||||
for (int i = 0; i < images.size(); i++) {
|
||||
BufferedImage bi = images.get(i);
|
||||
/* Allow GC to collect image after write. */
|
||||
images.set(i, null);
|
||||
path = basePath + "-" + (i + 1) + "." + suffix;
|
||||
stream = new FileImageOutputStream(new File(path));
|
||||
writer.setOutput(stream);
|
||||
writer.write(bi);
|
||||
stream.close();
|
||||
stream = null;
|
||||
if (monitor.isCanceled()) {
|
||||
break;
|
||||
}
|
||||
monitor.worked(1);
|
||||
}
|
||||
} else if (options.getImageFormat() == ImageFormat.ANIMATION) {
|
||||
stream = new FileImageOutputStream(options.getFileLocation());
|
||||
writer.setOutput(stream);
|
||||
writer.prepareWriteSequence(null);
|
||||
for (int i = 0; i < images.size(); i++) {
|
||||
BufferedImage bi = images.get(i);
|
||||
/* Allow GC to collect image after write. */
|
||||
images.set(i, null);
|
||||
ImageWriteParam iwp = writer.getDefaultWriteParam();
|
||||
IIOMetadata metadata = writer.getDefaultImageMetadata(
|
||||
new ImageTypeSpecifier(bi), iwp);
|
||||
if (i == 0) {
|
||||
configureAnimation(metadata,
|
||||
options.getFirstFrameDwell(), true);
|
||||
|
||||
} else if (i == images.size() - 1) {
|
||||
configureAnimation(metadata,
|
||||
options.getLastFrameDwell(), false);
|
||||
} else {
|
||||
configureAnimation(metadata, options.getFrameDelay(),
|
||||
false);
|
||||
|
||||
}
|
||||
IIOImage ii = new IIOImage(bi, null, metadata);
|
||||
writer.writeToSequence(ii, null);
|
||||
monitor.worked(1);
|
||||
if (monitor.isCanceled()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
writer.endWriteSequence();
|
||||
stream.close();
|
||||
stream = null;
|
||||
} else {
|
||||
String reason = "Unrecognized format "
|
||||
+ String.valueOf(options.getImageFormat());
|
||||
statusHandler.handle(Priority.PROBLEM, reason);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
String reason = "Error occurred while writing image";
|
||||
statusHandler.handle(Priority.PROBLEM, reason, e);
|
||||
} finally {
|
||||
if (stream != null) {
|
||||
try {
|
||||
stream.close();
|
||||
} catch (IOException e) {
|
||||
/* Don't mask existing exception. */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void configureAnimation(IIOMetadata metadata, int delayMillis,
|
||||
boolean first) throws IIOInvalidTreeException {
|
||||
int delayCentis = delayMillis / 10;
|
||||
String metaFormat = metadata.getNativeMetadataFormatName();
|
||||
|
||||
if (!"javax_imageio_gif_image_1.0".equals(metaFormat)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unfamiliar gif metadata format: " + metaFormat);
|
||||
}
|
||||
|
||||
Node root = metadata.getAsTree(metaFormat);
|
||||
|
||||
/* find the GraphicControlExtension node */
|
||||
Node child = root.getFirstChild();
|
||||
while (child != null) {
|
||||
if ("GraphicControlExtension".equals(child.getNodeName())) {
|
||||
break;
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
|
||||
IIOMetadataNode gce = (IIOMetadataNode) child;
|
||||
gce.setAttribute("userDelay", "FALSE");
|
||||
gce.setAttribute("delayTime", String.valueOf(delayCentis));
|
||||
|
||||
/* only the first node needs the ApplicationExtensions node */
|
||||
if (first) {
|
||||
IIOMetadataNode aes = new IIOMetadataNode("ApplicationExtensions");
|
||||
IIOMetadataNode ae = new IIOMetadataNode("ApplicationExtension");
|
||||
ae.setAttribute("applicationID", "NETSCAPE");
|
||||
ae.setAttribute("authenticationCode", "2.0");
|
||||
/*
|
||||
* last two bytes is an unsigned short (little endian) that
|
||||
* indicates the the number of times to loop. 0 means loop forever.
|
||||
*/
|
||||
byte[] uo = new byte[] { 0x1, 0x0, 0x0 };
|
||||
ae.setUserObject(uo);
|
||||
aes.appendChild(ae);
|
||||
root.appendChild(aes);
|
||||
}
|
||||
|
||||
metadata.setFromTree(metaFormat, root);
|
||||
|
||||
}
|
||||
|
||||
protected class SaveImageJob extends Job {
|
||||
|
||||
protected final ImageExportOptions options;
|
||||
|
||||
protected final List<BufferedImage> images;
|
||||
|
||||
protected SaveImageJob(ImageExportOptions options,
|
||||
List<BufferedImage> images) {
|
||||
super("Saving image");
|
||||
this.options = options;
|
||||
this.images = images;
|
||||
this.schedule();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
saveImages(monitor, options, images);
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@
|
|||
* further licensing information.
|
||||
**/
|
||||
|
||||
package com.raytheon.viz.ui.actions;
|
||||
package com.raytheon.uf.viz.image.export.handler;
|
||||
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.AffineTransformOp;
|
||||
|
@ -51,22 +51,23 @@ import com.raytheon.viz.ui.EditorUtil;
|
|||
import com.raytheon.viz.ui.editor.AbstractEditor;
|
||||
|
||||
/**
|
||||
* Print the current map
|
||||
* Print the current editor
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 26, 2006 chammack Initial Creation.
|
||||
* Aug 08, 2008 #703 randerso fixed bug, changed to scale to fit
|
||||
* paper and rotate if necessary
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 26, 2006 chammack Initial Creation.
|
||||
* Aug 08, 2008 703 randerso fixed bug, changed to scale to fit paper
|
||||
* and rotate if necessary
|
||||
* Jan 20, 2014 2312 bsteffen Move to image export plugin.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
* @version 1
|
||||
*/
|
||||
public class PrintScreenAction extends AbstractScreenCaptureAction {
|
||||
public class PrintImageCaptureHandler extends AbstractImageCaptureHandler {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
|
@ -0,0 +1,176 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.image.export.options;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
||||
import com.raytheon.uf.viz.core.datastructure.LoopProperties;
|
||||
|
||||
/**
|
||||
* Configuration options taht control how an image is exported.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 20, 2014 2312 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ImageExportOptions {
|
||||
|
||||
public static enum FrameSelection {
|
||||
ALL, CURRENT, USER;
|
||||
}
|
||||
|
||||
public static enum ImageFormat {
|
||||
|
||||
SEQUENCE("All Images") {
|
||||
@Override
|
||||
public String[] getExtensions() {
|
||||
return ImageIO.getWriterFileSuffixes();
|
||||
}
|
||||
},
|
||||
ANIMATION("Animated Images(*.gif)") {
|
||||
@Override
|
||||
public String[] getExtensions() {
|
||||
return new String[] { "gif" };
|
||||
}
|
||||
};
|
||||
|
||||
private final String description;
|
||||
|
||||
private ImageFormat(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public abstract String[] getExtensions();
|
||||
|
||||
}
|
||||
|
||||
private File fileLocation = new File("screenCapture.gif");
|
||||
|
||||
private ImageFormat imageFormat = ImageFormat.SEQUENCE;
|
||||
|
||||
private FrameSelection frameSelection = FrameSelection.CURRENT;
|
||||
|
||||
private int firstFrameIndex = 0;
|
||||
|
||||
private int lastFrameIndex = 0;
|
||||
|
||||
/** first frame dwell time in ms */
|
||||
private int firstFrameDwell = 700;
|
||||
|
||||
/** last frame dwell time in ms */
|
||||
private int lastFrameDwell = 1500;
|
||||
|
||||
/** frame time for animation in ms */
|
||||
private int frameDelay = LoopProperties.DEFAULT_FRAME_TIME;
|
||||
|
||||
public File getFileLocation() {
|
||||
return fileLocation;
|
||||
}
|
||||
|
||||
public void setFileLocation(File fileLocation) {
|
||||
this.fileLocation = fileLocation;
|
||||
}
|
||||
|
||||
public ImageFormat getImageFormat() {
|
||||
return imageFormat;
|
||||
}
|
||||
|
||||
public void setImageFormat(ImageFormat imageFormat) {
|
||||
this.imageFormat = imageFormat;
|
||||
}
|
||||
|
||||
public FrameSelection getFrameSelection() {
|
||||
return frameSelection;
|
||||
}
|
||||
|
||||
public void setFrameSelection(FrameSelection frameSelection) {
|
||||
this.frameSelection = frameSelection;
|
||||
}
|
||||
|
||||
public int getFirstFrameIndex() {
|
||||
return firstFrameIndex;
|
||||
}
|
||||
|
||||
public void setFirstFrameIndex(int firstFrameIndex) {
|
||||
this.firstFrameIndex = firstFrameIndex;
|
||||
}
|
||||
|
||||
public int getLastFrameIndex() {
|
||||
return lastFrameIndex;
|
||||
}
|
||||
|
||||
public void setLastFrameIndex(int lastFrameIndex) {
|
||||
this.lastFrameIndex = lastFrameIndex;
|
||||
}
|
||||
|
||||
public int getFirstFrameDwell() {
|
||||
return firstFrameDwell;
|
||||
}
|
||||
|
||||
public void setFirstFrameDwell(int firstFrameDwell) {
|
||||
this.firstFrameDwell = firstFrameDwell;
|
||||
}
|
||||
|
||||
public int getLastFrameDwell() {
|
||||
return lastFrameDwell;
|
||||
}
|
||||
|
||||
public void setLastFrameDwell(int lastFrameDwell) {
|
||||
this.lastFrameDwell = lastFrameDwell;
|
||||
}
|
||||
|
||||
public int getFrameDelay() {
|
||||
return frameDelay;
|
||||
}
|
||||
|
||||
public void setFrameDelay(int frameDelay) {
|
||||
this.frameDelay = frameDelay;
|
||||
}
|
||||
|
||||
public void populate(IDisplayPaneContainer container) {
|
||||
populate(container.getLoopProperties());
|
||||
int frameCount = container.getActiveDisplayPane().getDescriptor()
|
||||
.getFramesInfo().getFrameCount();
|
||||
lastFrameIndex = Math.max(frameCount - 1, 0);
|
||||
}
|
||||
|
||||
public void populate(LoopProperties loopProperties) {
|
||||
this.firstFrameDwell = loopProperties.getFirstFrameDwell();
|
||||
this.lastFrameDwell = loopProperties.getLastFrameDwell();
|
||||
this.frameDelay = loopProperties.getFwdFrameTime();
|
||||
}
|
||||
}
|
|
@ -52,11 +52,15 @@
|
|||
</reference>
|
||||
</visibleWhen>
|
||||
<command
|
||||
commandId="com.raytheon.viz.ui.actions.saveScreen"
|
||||
commandId="com.raytheon.uf.viz.image.export.save"
|
||||
label="Save Image as...">
|
||||
<parameter
|
||||
name="frameSelection" value="current" />
|
||||
<parameter
|
||||
name="dialogType" value="file" />
|
||||
</command>
|
||||
<command
|
||||
commandId="com.raytheon.viz.ui.actions.printScreenAction"
|
||||
commandId="com.raytheon.uf.viz.image.export.print"
|
||||
label="Print Image...">
|
||||
</command>
|
||||
<command
|
||||
|
|
|
@ -1617,7 +1617,7 @@
|
|||
</parameter>
|
||||
</key>
|
||||
<key
|
||||
commandId="com.raytheon.viz.ui.actions.saveScreen"
|
||||
commandId="com.raytheon.uf.viz.image.export.save"
|
||||
contextId="com.raytheon.viz.mpe.ui.MPE"
|
||||
schemeId="com.raytheon.viz.ui.awips.scheme"
|
||||
sequence="M3+S">
|
||||
|
|
|
@ -2,22 +2,24 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Viz UI
|
||||
Bundle-SymbolicName: com.raytheon.viz.ui; singleton:=true
|
||||
Bundle-Version: 1.12.1174.qualifier
|
||||
Eclipse-BuddyPolicy: ext, registered
|
||||
Bundle-Version: 1.14.0.qualifier
|
||||
Bundle-Activator: com.raytheon.viz.ui.UiPlugin
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Require-Bundle: com.raytheon.viz.core,
|
||||
org.eclipse.ui;visibility:=reexport,
|
||||
org.eclipse.core.runtime,
|
||||
org.geotools,
|
||||
javax.measure,
|
||||
org.apache.commons.lang,
|
||||
com.raytheon.uf.viz.core,
|
||||
org.eclipse.core.expressions,
|
||||
com.raytheon.uf.common.colormap;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.message;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.time;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.util;bundle-version="1.12.1174"
|
||||
Bundle-Vendor: Raytheon
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Require-Bundle: org.eclipse.ui;bundle-version="3.8.0";visibility:=reexport,
|
||||
com.raytheon.uf.viz.core;bundle-version="1.14.0",
|
||||
org.eclipse.core.runtime;bundle-version="3.8.0",
|
||||
org.eclipse.core.expressions;bundle-version="3.4.0",
|
||||
com.raytheon.uf.common.colormap,
|
||||
com.raytheon.uf.common.time,
|
||||
com.raytheon.uf.common.util,
|
||||
org.apache.commons.lang;bundle-version="2.3.0",
|
||||
org.geotools;bundle-version="2.6.4",
|
||||
javax.measure
|
||||
Import-Package: com.raytheon.viz.core,
|
||||
com.raytheon.viz.core.imagery,
|
||||
com.raytheon.viz.core.mode
|
||||
Export-Package: com.raytheon.viz.ui,
|
||||
com.raytheon.viz.ui.actions,
|
||||
com.raytheon.viz.ui.cmenu,
|
||||
|
@ -38,5 +40,3 @@ Export-Package: com.raytheon.viz.ui,
|
|||
com.raytheon.viz.ui.views,
|
||||
com.raytheon.viz.ui.widgets,
|
||||
com.raytheon.viz.ui.widgets.duallist
|
||||
Bundle-Vendor: Raytheon
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
|
|
|
@ -235,32 +235,10 @@
|
|||
description="Toggles the visibility of the tool/perspective bar"
|
||||
name="Toogle Toolbar">
|
||||
</command>
|
||||
<command
|
||||
id="com.raytheon.viz.ui.actions.printScreenAction"
|
||||
categoryId="com.raytheon.uf.viz.core.commandCategory"
|
||||
description="Print the currently active editor"
|
||||
name="Print Screen">
|
||||
<commandParameter
|
||||
id="frameSelection"
|
||||
name="Frame Selection"
|
||||
optional="true">
|
||||
</commandParameter>
|
||||
</command>
|
||||
<command
|
||||
id="com.raytheon.viz.ui.newPage"
|
||||
name="New Window">
|
||||
</command>
|
||||
<command
|
||||
id="com.raytheon.viz.ui.actions.saveScreen"
|
||||
categoryId="com.raytheon.uf.viz.core.commandCategory"
|
||||
description="Save the current screen"
|
||||
name="Save Screen">
|
||||
<commandParameter
|
||||
id="frameSelection"
|
||||
name="Frame Selection"
|
||||
optional="true">
|
||||
</commandParameter>
|
||||
</command>
|
||||
<command
|
||||
id="com.raytheon.viz.ui.actions.notImplemented"
|
||||
name="Not Implemented">
|
||||
|
@ -416,18 +394,10 @@
|
|||
class="com.raytheon.viz.ui.actions.ToggleToolbarHandler"
|
||||
commandId="com.raytheon.uf.viz.ui.actions.toggleToolbarHandler">
|
||||
</handler>
|
||||
<handler
|
||||
class="com.raytheon.viz.ui.actions.PrintScreenAction"
|
||||
commandId="com.raytheon.viz.ui.actions.printScreenAction">
|
||||
</handler>
|
||||
<handler
|
||||
class="com.raytheon.viz.ui.actions.NewPageAction"
|
||||
commandId="com.raytheon.viz.ui.newPage">
|
||||
</handler>
|
||||
<handler
|
||||
class="com.raytheon.viz.ui.actions.SaveScreenAction"
|
||||
commandId="com.raytheon.viz.ui.actions.saveScreen">
|
||||
</handler>
|
||||
<handler
|
||||
class="com.raytheon.viz.ui.actions.NotImplementedAction"
|
||||
commandId="com.raytheon.viz.ui.actions.notImplemented">
|
||||
|
@ -509,33 +479,6 @@
|
|||
label="Perspective Displays..."
|
||||
style="push">
|
||||
</command>
|
||||
<command
|
||||
commandId="com.raytheon.viz.ui.actions.saveScreen"
|
||||
label="Capture Current Frame"
|
||||
style="push">
|
||||
<parameter
|
||||
name="frameSelection"
|
||||
value="current">
|
||||
</parameter>
|
||||
</command>
|
||||
<command
|
||||
commandId="com.raytheon.viz.ui.actions.saveScreen"
|
||||
label="Capture All Frames"
|
||||
style="push">
|
||||
<parameter
|
||||
name="frameSelection"
|
||||
value="all">
|
||||
</parameter>
|
||||
</command>
|
||||
<command
|
||||
commandId="com.raytheon.viz.ui.actions.printScreenAction"
|
||||
label="Print Screen"
|
||||
style="push">
|
||||
<parameter
|
||||
name="frameSelection"
|
||||
value="current">
|
||||
</parameter>
|
||||
</command>
|
||||
</menuContribution>
|
||||
</extension>
|
||||
<extension
|
||||
|
|
|
@ -1,175 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
|
||||
package com.raytheon.viz.ui.actions;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.ImageWriter;
|
||||
import javax.imageio.stream.FileImageOutputStream;
|
||||
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.FileDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.ui.EditorUtil;
|
||||
import com.raytheon.viz.ui.editor.AbstractEditor;
|
||||
|
||||
/**
|
||||
* Save the current screen to a file
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 26, 2006 chammack Initial Creation.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
* @version 1
|
||||
*/
|
||||
public class SaveScreenAction extends AbstractScreenCaptureAction {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(SaveScreenAction.class);
|
||||
|
||||
private static final String ERROR_MESSAGE = "Unable to save image";
|
||||
|
||||
private static final String DEFAULT_FILENAME = "*.png";
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
|
||||
* .ExecutionEvent)
|
||||
*/
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
IEditorPart part = EditorUtil.getActiveEditor();
|
||||
AbstractEditor editor = null;
|
||||
if (part instanceof AbstractEditor) {
|
||||
editor = (AbstractEditor) part;
|
||||
}
|
||||
|
||||
if (editor == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
|
||||
String[] suffixList = ImageIO.getWriterFileSuffixes();
|
||||
ArrayList<String> filters = new ArrayList<String>();
|
||||
for (String suffix : suffixList) {
|
||||
if (!suffix.isEmpty()) {
|
||||
filters.add("*." + suffix);
|
||||
}
|
||||
}
|
||||
Collections.sort(filters);
|
||||
|
||||
FileDialog fd = new FileDialog(shell, SWT.SAVE);
|
||||
fd.setFileName(DEFAULT_FILENAME);
|
||||
fd.setFilterExtensions(filters.toArray(new String[filters.size()]));
|
||||
String path = fd.open();
|
||||
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
int pos = path.lastIndexOf('.');
|
||||
if (pos < 0) {
|
||||
String reason = "Missing filename extension";
|
||||
|
||||
statusHandler.handle(Priority.PROBLEM, reason);
|
||||
return null;
|
||||
}
|
||||
|
||||
String suffix = path.substring(path.lastIndexOf('.') + 1);
|
||||
String basePath = path.substring(0, path.lastIndexOf('.'));
|
||||
Iterator<ImageWriter> iter = ImageIO.getImageWritersBySuffix(suffix);
|
||||
if (!iter.hasNext()) {
|
||||
String reason = "Unsupported filetype: \"" + suffix + "\"";
|
||||
statusHandler.handle(Priority.PROBLEM, reason);
|
||||
|
||||
return null;
|
||||
}
|
||||
ImageWriter writer = iter.next();
|
||||
|
||||
String frameMode = arg0.getParameter("frameSelection");
|
||||
|
||||
if (frameMode == null || frameMode.equalsIgnoreCase("current")) {
|
||||
BufferedImage bi = captureCurrentFrames(editor);
|
||||
|
||||
try {
|
||||
writer.setOutput(new FileImageOutputStream(new File(path)));
|
||||
writer.write(bi);
|
||||
} catch (IOException e) {
|
||||
String reason = "Error occurred while writing image";
|
||||
statusHandler.handle(Priority.PROBLEM, reason, e);
|
||||
throw new ExecutionException(reason, e);
|
||||
}
|
||||
} else if (frameMode.equalsIgnoreCase("all")) {
|
||||
List<BufferedImage> images = null;
|
||||
try {
|
||||
images = captureAllFrames(editor);
|
||||
} catch (VizException e) {
|
||||
String reason = "Error occurred while writing image";
|
||||
statusHandler.handle(Priority.PROBLEM, reason, e);
|
||||
throw new ExecutionException(reason, e);
|
||||
}
|
||||
|
||||
for (int i = 0; i < images.size(); i++) {
|
||||
|
||||
BufferedImage bi = images.get(i);
|
||||
|
||||
path = basePath + "-" + (i + 1) + "." + suffix;
|
||||
|
||||
try {
|
||||
writer.setOutput(new FileImageOutputStream(new File(path)));
|
||||
writer.write(bi);
|
||||
} catch (IOException e) {
|
||||
String reason = "Error occurred while writing image";
|
||||
statusHandler.handle(Priority.PROBLEM, reason, e);
|
||||
throw new ExecutionException(reason, e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String reason = "Invalid frameMode: " + frameMode;
|
||||
statusHandler.handle(Priority.PROBLEM, reason);
|
||||
throw new ExecutionException(reason);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -99,10 +99,14 @@
|
|||
</separator>
|
||||
<menu label="Save">
|
||||
|
||||
<command commandId="com.raytheon.viz.ui.actions.saveScreen"
|
||||
<command commandId="com.raytheon.uf.viz.image.export.save"
|
||||
label="Screen..."
|
||||
style="push"
|
||||
mnemonic="S">
|
||||
<parameter
|
||||
name="frameSelection" value="current" />
|
||||
<parameter
|
||||
name="dialogType" value="file" />
|
||||
</command>
|
||||
<command
|
||||
commandId="gov.noaa.nws.ncep.viz.ui.actions.saveArea"
|
||||
|
@ -126,7 +130,7 @@
|
|||
visible="true">
|
||||
</separator>
|
||||
<command
|
||||
commandId="com.raytheon.viz.ui.actions.printScreenAction"
|
||||
commandId="com.raytheon.uf.viz.image.export.print"
|
||||
label="Print"
|
||||
style="push"
|
||||
mnemonic="P">
|
||||
|
|
Loading…
Add table
Reference in a new issue