From cd295e417230e481c6f69235d93c8d817b151bbc Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Tue, 21 Jan 2014 12:19:30 -0600 Subject: [PATCH] Issue #2312 Add ability to export gif and image export dialog. Change-Id: I10aaeba20a4acc7888cd566107ffff3e6a4fad05 Former-commit-id: b70faf1f7d9ca0f9b70edb108f49c88ac3150563 [formerly fc1c56f9cb4500c616b85e98e32235d71d53440e] [formerly 4ad4b4a859eea56bc76a3ae23461b384091e2aa4 [formerly e2159c422ca93aa76c6ba7a30a09234e8f9da4ce]] Former-commit-id: 4ad4b4a859eea56bc76a3ae23461b384091e2aa4 Former-commit-id: 8b2e5a06bc6e5ed201d889e68e0e47281979f9bd --- .../feature.xml | 6 + .../META-INF/MANIFEST.MF | 39 +- .../com.raytheon.uf.viz.d2d.nsharp/plugin.xml | 4 +- .../raytheon/uf/viz/d2d/nsharp/Activator.java | 71 --- .../rsc/action/NSharpPrintScreenAction.java | 4 +- .../rsc/action/NSharpSaveScreenAction.java | 4 +- cave/com.raytheon.uf.viz.d2d.ui/plugin.xml | 2 +- .../.classpath | 7 + .../com.raytheon.uf.viz.image.export/.project | 28 ++ .../.settings/org.eclipse.jdt.core.prefs | 7 + .../META-INF/MANIFEST.MF | 15 + .../build.properties | 6 + .../plugin.xml | 85 ++++ .../export/dialog/ImageExportDialog.java | 441 ++++++++++++++++++ .../handler/AbstractImageCaptureHandler.java} | 43 +- .../export/handler/ExportImageHandler.java | 330 +++++++++++++ .../handler/PrintImageCaptureHandler.java} | 17 +- .../export/options/ImageExportOptions.java | 176 +++++++ cave/com.raytheon.viz.hydrocommon/plugin.xml | 8 +- cave/com.raytheon.viz.mpe.ui/plugin.xml | 2 +- cave/com.raytheon.viz.ui/META-INF/MANIFEST.MF | 32 +- cave/com.raytheon.viz.ui/plugin.xml | 57 --- .../viz/ui/actions/SaveScreenAction.java | 175 ------- .../plugin.xml | 8 +- 24 files changed, 1205 insertions(+), 362 deletions(-) delete mode 100644 cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/Activator.java create mode 100644 cave/com.raytheon.uf.viz.image.export/.classpath create mode 100644 cave/com.raytheon.uf.viz.image.export/.project create mode 100644 cave/com.raytheon.uf.viz.image.export/.settings/org.eclipse.jdt.core.prefs create mode 100644 cave/com.raytheon.uf.viz.image.export/META-INF/MANIFEST.MF create mode 100644 cave/com.raytheon.uf.viz.image.export/build.properties create mode 100644 cave/com.raytheon.uf.viz.image.export/plugin.xml create mode 100644 cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/dialog/ImageExportDialog.java rename cave/{com.raytheon.viz.ui/src/com/raytheon/viz/ui/actions/AbstractScreenCaptureAction.java => com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/handler/AbstractImageCaptureHandler.java} (73%) create mode 100644 cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/handler/ExportImageHandler.java rename cave/{com.raytheon.viz.ui/src/com/raytheon/viz/ui/actions/PrintScreenAction.java => com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/handler/PrintImageCaptureHandler.java} (95%) create mode 100644 cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/options/ImageExportOptions.java delete mode 100644 cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/actions/SaveScreenAction.java diff --git a/cave/com.raytheon.uf.viz.core.feature/feature.xml b/cave/com.raytheon.uf.viz.core.feature/feature.xml index 525f4aca46..84cec8a7a2 100644 --- a/cave/com.raytheon.uf.viz.core.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.core.feature/feature.xml @@ -85,6 +85,12 @@ install-size="0" version="0.0.0"/> + + + commandId="com.raytheon.uf.viz.image.export.save"> @@ -45,7 +45,7 @@ + commandId="com.raytheon.uf.viz.image.export.print"> diff --git a/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/Activator.java b/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/Activator.java deleted file mode 100644 index ec48fb947a..0000000000 --- a/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/Activator.java +++ /dev/null @@ -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 - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Apr 12, 2011            bsteffen     Initial creation
- * 
- * 
- * - * @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; - } - -} diff --git a/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/rsc/action/NSharpPrintScreenAction.java b/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/rsc/action/NSharpPrintScreenAction.java index e88303e4e2..44c51d0dac 100644 --- a/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/rsc/action/NSharpPrintScreenAction.java +++ b/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/rsc/action/NSharpPrintScreenAction.java @@ -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) diff --git a/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/rsc/action/NSharpSaveScreenAction.java b/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/rsc/action/NSharpSaveScreenAction.java index 276ac8a175..352c3f3b19 100644 --- a/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/rsc/action/NSharpSaveScreenAction.java +++ b/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/rsc/action/NSharpSaveScreenAction.java @@ -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) { diff --git a/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml b/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml index dd72ae08eb..acc15232ab 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml +++ b/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml @@ -108,7 +108,7 @@ style="push"> diff --git a/cave/com.raytheon.uf.viz.image.export/.classpath b/cave/com.raytheon.uf.viz.image.export/.classpath new file mode 100644 index 0000000000..ad32c83a78 --- /dev/null +++ b/cave/com.raytheon.uf.viz.image.export/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/cave/com.raytheon.uf.viz.image.export/.project b/cave/com.raytheon.uf.viz.image.export/.project new file mode 100644 index 0000000000..1041dea2ff --- /dev/null +++ b/cave/com.raytheon.uf.viz.image.export/.project @@ -0,0 +1,28 @@ + + + com.raytheon.uf.viz.image.export + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/cave/com.raytheon.uf.viz.image.export/.settings/org.eclipse.jdt.core.prefs b/cave/com.raytheon.uf.viz.image.export/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..c537b63063 --- /dev/null +++ b/cave/com.raytheon.uf.viz.image.export/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/cave/com.raytheon.uf.viz.image.export/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.image.export/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..67984c3e8b --- /dev/null +++ b/cave/com.raytheon.uf.viz.image.export/META-INF/MANIFEST.MF @@ -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 diff --git a/cave/com.raytheon.uf.viz.image.export/build.properties b/cave/com.raytheon.uf.viz.image.export/build.properties new file mode 100644 index 0000000000..ac9f5c5f74 --- /dev/null +++ b/cave/com.raytheon.uf.viz.image.export/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + plugin.xml,\ + . + \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.image.export/plugin.xml b/cave/com.raytheon.uf.viz.image.export/plugin.xml new file mode 100644 index 0000000000..5a61ba6c89 --- /dev/null +++ b/cave/com.raytheon.uf.viz.image.export/plugin.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/dialog/ImageExportDialog.java b/cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/dialog/ImageExportDialog.java new file mode 100644 index 0000000000..316ab933d5 --- /dev/null +++ b/cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/dialog/ImageExportDialog.java @@ -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. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Jan 20, 2014  2312     bsteffen    Initial creation
+ * 
+ * 
+ * + * @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; + } +} diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/actions/AbstractScreenCaptureAction.java b/cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/handler/AbstractImageCaptureHandler.java similarity index 73% rename from cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/actions/AbstractScreenCaptureAction.java rename to cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/handler/AbstractImageCaptureHandler.java index 447d670343..1596313217 100644 --- a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/actions/AbstractScreenCaptureAction.java +++ b/cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/handler/AbstractImageCaptureHandler.java @@ -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. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Jan 20, 2014  2312     bsteffen    Move to image export plugin.
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ +public abstract class AbstractImageCaptureHandler extends AbstractHandler { protected BufferedImage captureCurrentFrames(AbstractEditor editor) { return editor.screenshot(); diff --git a/cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/handler/ExportImageHandler.java b/cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/handler/ExportImageHandler.java new file mode 100644 index 0000000000..72dd60c367 --- /dev/null +++ b/cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/handler/ExportImageHandler.java @@ -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 + * + *
+ * SOFTWARE HISTORY
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Jul 26, 2006           chammack    Initial Creation.
+ * Jan 20, 2014  2312     bsteffen    Move to image export plugin, animation.
+ * 
+ * 
+ * + * @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 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 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 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 images; + + protected SaveImageJob(ImageExportOptions options, + List 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; + } + + } +} diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/actions/PrintScreenAction.java b/cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/handler/PrintImageCaptureHandler.java similarity index 95% rename from cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/actions/PrintScreenAction.java rename to cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/handler/PrintImageCaptureHandler.java index 8558af6d1d..838253db42 100644 --- a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/actions/PrintScreenAction.java +++ b/cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/handler/PrintImageCaptureHandler.java @@ -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 * *
  * 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.
  * 
  * 
* * @author chammack * @version 1 */ -public class PrintScreenAction extends AbstractScreenCaptureAction { +public class PrintImageCaptureHandler extends AbstractImageCaptureHandler { /* * (non-Javadoc) diff --git a/cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/options/ImageExportOptions.java b/cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/options/ImageExportOptions.java new file mode 100644 index 0000000000..eff8ed31bf --- /dev/null +++ b/cave/com.raytheon.uf.viz.image.export/src/com/raytheon/uf/viz/image/export/options/ImageExportOptions.java @@ -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. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Jan 20, 2014  2312     bsteffen    Initial creation
+ * 
+ * 
+ * + * @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(); + } +} diff --git a/cave/com.raytheon.viz.hydrocommon/plugin.xml b/cave/com.raytheon.viz.hydrocommon/plugin.xml index d61d22aac6..ceef898bc3 100644 --- a/cave/com.raytheon.viz.hydrocommon/plugin.xml +++ b/cave/com.raytheon.viz.hydrocommon/plugin.xml @@ -52,11 +52,15 @@ + + diff --git a/cave/com.raytheon.viz.ui/META-INF/MANIFEST.MF b/cave/com.raytheon.viz.ui/META-INF/MANIFEST.MF index 3ad5977d46..3a8d021d9a 100644 --- a/cave/com.raytheon.viz.ui/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.viz.ui/META-INF/MANIFEST.MF @@ -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 diff --git a/cave/com.raytheon.viz.ui/plugin.xml b/cave/com.raytheon.viz.ui/plugin.xml index ade2ec8cca..b8a2b1e5c4 100644 --- a/cave/com.raytheon.viz.ui/plugin.xml +++ b/cave/com.raytheon.viz.ui/plugin.xml @@ -235,32 +235,10 @@ description="Toggles the visibility of the tool/perspective bar" name="Toogle Toolbar"> - - - - - - - - @@ -416,18 +394,10 @@ class="com.raytheon.viz.ui.actions.ToggleToolbarHandler" commandId="com.raytheon.uf.viz.ui.actions.toggleToolbarHandler">
- - - - @@ -509,33 +479,6 @@ label="Perspective Displays..." style="push"> - - - - - - - - - - - - - * SOFTWARE HISTORY - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Jul 26, 2006 chammack Initial Creation. - * - * - * - * @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 filters = new ArrayList(); - 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 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 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; - } -} diff --git a/ncep/gov.noaa.nws.ncep.viz.ui.perspectives/plugin.xml b/ncep/gov.noaa.nws.ncep.viz.ui.perspectives/plugin.xml index b90d6ccbe1..507f4fa71c 100644 --- a/ncep/gov.noaa.nws.ncep.viz.ui.perspectives/plugin.xml +++ b/ncep/gov.noaa.nws.ncep.viz.ui.perspectives/plugin.xml @@ -99,10 +99,14 @@ - + +