From f5eee3d7cc1dc571e54b81da6a3544dabb3fcfe0 Mon Sep 17 00:00:00 2001 From: Matt Nash Date: Wed, 28 Mar 2012 15:09:18 -0500 Subject: [PATCH] Issue #429 telestrator merging Change-Id: I18f8f283db617d0865b274dcf6003a24e2cf2028 Former-commit-id: 39670f67556dd09e7483b5977346a53ea597541d [formerly d55dab5c3464fc3c5cbb624073352f4dec79b880 [formerly b1a679a2e37bdd7a887fffe82a3d735cdb60f7f9]] Former-commit-id: d55dab5c3464fc3c5cbb624073352f4dec79b880 Former-commit-id: b86ee8584f6b5e29e9dfef1f09bb6d13238f359d --- .../feature.xml | 7 + .../plugin.xml | 8 + cave/com.raytheon.uf.viz.drawing/.classpath | 7 + cave/com.raytheon.uf.viz.drawing/.project | 28 ++ .../.settings/org.eclipse.jdt.core.prefs | 8 + .../META-INF/MANIFEST.MF | 21 ++ .../build.properties | 4 + .../icons/eraser.gif | Bin 0 -> 88 bytes .../icons/redo.gif | Bin 0 -> 356 bytes .../icons/remove.gif | Bin 0 -> 351 bytes .../icons/undo.gif | Bin 0 -> 355 bytes cave/com.raytheon.uf.viz.drawing/plugin.xml | 72 ++++ .../uf/viz/drawing/AbstractDrawingTool.java | 113 +++++++ .../raytheon/uf/viz/drawing/Activator.java | 50 +++ .../raytheon/uf/viz/drawing/DrawingLayer.java | 316 ++++++++++++++++++ .../viz/drawing/PathDrawingResourceData.java | 85 +++++ .../raytheon/uf/viz/drawing/PathToolbar.java | 73 ++++ .../drawing/actions/ClearDrawingAction.java | 74 ++++ .../drawing/actions/EraseObjectsAction.java | 75 +++++ .../uf/viz/drawing/actions/RedoAddAction.java | 81 +++++ .../uf/viz/drawing/actions/UndoAddAction.java | 81 +++++ .../uf/viz/drawing/objects/TransferLine.java | 60 ++++ .../viz/drawing/objects/TransferObject.java | 41 +++ .../uf/viz/drawing/tools/PathDrawingTool.java | 186 +++++++++++ .../uf/viz/drawing/tools/ToolsUtils.java | 60 ++++ 25 files changed, 1450 insertions(+) create mode 100644 cave/com.raytheon.uf.viz.drawing/.classpath create mode 100644 cave/com.raytheon.uf.viz.drawing/.project create mode 100644 cave/com.raytheon.uf.viz.drawing/.settings/org.eclipse.jdt.core.prefs create mode 100644 cave/com.raytheon.uf.viz.drawing/META-INF/MANIFEST.MF create mode 100644 cave/com.raytheon.uf.viz.drawing/build.properties create mode 100644 cave/com.raytheon.uf.viz.drawing/icons/eraser.gif create mode 100644 cave/com.raytheon.uf.viz.drawing/icons/redo.gif create mode 100644 cave/com.raytheon.uf.viz.drawing/icons/remove.gif create mode 100644 cave/com.raytheon.uf.viz.drawing/icons/undo.gif create mode 100644 cave/com.raytheon.uf.viz.drawing/plugin.xml create mode 100644 cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/AbstractDrawingTool.java create mode 100644 cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/Activator.java create mode 100644 cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/DrawingLayer.java create mode 100644 cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathDrawingResourceData.java create mode 100644 cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathToolbar.java create mode 100644 cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/ClearDrawingAction.java create mode 100644 cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/EraseObjectsAction.java create mode 100644 cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/RedoAddAction.java create mode 100644 cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/UndoAddAction.java create mode 100644 cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/objects/TransferLine.java create mode 100644 cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/objects/TransferObject.java create mode 100644 cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/tools/PathDrawingTool.java create mode 100644 cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/tools/ToolsUtils.java diff --git a/cave/com.raytheon.uf.viz.collaboration.feature/feature.xml b/cave/com.raytheon.uf.viz.collaboration.feature/feature.xml index 26b6531cca..b0c50de749 100755 --- a/cave/com.raytheon.uf.viz.collaboration.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.collaboration.feature/feature.xml @@ -107,4 +107,11 @@ install-size="0" version="0.0.0"/> + + diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml b/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml index e98e8735e8..b122fb377d 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml +++ b/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml @@ -130,6 +130,14 @@ style="push"> + + + + diff --git a/cave/com.raytheon.uf.viz.drawing/.classpath b/cave/com.raytheon.uf.viz.drawing/.classpath new file mode 100644 index 0000000000..ad32c83a78 --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/cave/com.raytheon.uf.viz.drawing/.project b/cave/com.raytheon.uf.viz.drawing/.project new file mode 100644 index 0000000000..53c7e67a4a --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/.project @@ -0,0 +1,28 @@ + + + com.raytheon.uf.viz.drawing + + + + + + 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.drawing/.settings/org.eclipse.jdt.core.prefs b/cave/com.raytheon.uf.viz.drawing/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..0f72a13b05 --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Mon Mar 26 17:37:45 CDT 2012 +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.drawing/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.drawing/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..45742dc817 --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/META-INF/MANIFEST.MF @@ -0,0 +1,21 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Drawing +Bundle-SymbolicName: com.raytheon.uf.viz.drawing;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: com.raytheon.uf.viz.drawing.Activator +Bundle-Vendor: RAYTHEON +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + com.raytheon.uf.viz.core;bundle-version="1.12.1174", + com.raytheon.uf.viz.core.rsc;bundle-version="1.0.0", + com.raytheon.uf.common.geospatial;bundle-version="1.12.1174", + com.raytheon.viz.awipstools;bundle-version="1.12.1174", + com.raytheon.viz.ui;bundle-version="1.12.1174" +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Import-Package: com.raytheon.uf.common.time, + com.raytheon.viz.ui.cmenu, + com.vividsolutions.jts.geom +Export-Package: com.raytheon.uf.viz.drawing, + com.raytheon.uf.viz.drawing.objects diff --git a/cave/com.raytheon.uf.viz.drawing/build.properties b/cave/com.raytheon.uf.viz.drawing/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/cave/com.raytheon.uf.viz.drawing/icons/eraser.gif b/cave/com.raytheon.uf.viz.drawing/icons/eraser.gif new file mode 100644 index 0000000000000000000000000000000000000000..48b0dcccc9e933ee797ba633858235bb720ba090 GIT binary patch literal 88 zcmZ?wbhEHb6krfwXkcUjg8%>jEB+I8E=o--Nlj5G&n(GM2+2rQaQE~LV9)_604Zf) nl56Q-x%wf$Y?sLyF8yig_In#=L`<9_xiIp14H63wkP8b6ju0wB zA14l*n-8824?9F3I2;V83>q2?H%lWRIx-g*7&%KsG!_*zw?sA+HN8YUJi^93K>#~X CfuU3Y literal 0 HcmV?d00001 diff --git a/cave/com.raytheon.uf.viz.drawing/icons/remove.gif b/cave/com.raytheon.uf.viz.drawing/icons/remove.gif new file mode 100644 index 0000000000000000000000000000000000000000..b6922ac11cf64e16a15cf2976cdaa1e40118abed GIT binary patch literal 351 zcmZ?wbhEHb6krfwxXQqA+}QL>Vab=`lFvmYpNmUxXz4%DF}bf}d|cDunVH>FGrOY- z+D{EEKZPcINzVS9ob?$uHn=&y~n$8D`1 z2l;<(sQc1T_xQ+>|Ns9p5DgT6vM@3*7&7R9bb$QCz*ci$MuCTpRKNR-^bncK1eb^v zqDfrti^MpzbSB1VUt0b}aql73M;xvKD|}WtK1fk5iV!?;_@hVR1O_f%UNKGv4?_+f zX(=fl4i6boi78XK>s@7pr?3jKN=S;#aFP{YATA>-vrJN4*4aRuZH4n{cJUaejfOH%o^!MXQ z_pa`|vMv75%Ct-S+pZsEV{QvY)`Y;=1SpR4WhdmMYq<7>}e9) zQ75{(P;h0Q;M!uL)rCSE%7m9?3#`Z$T%IHN|NnmmLO}5+3nK%A34;zuA;?b*Yz+>x z3OsbA`nT|&ELNG=G56$V4=JD4tE&r4B&M`2KI!1hK7fZIWkxS0HZON`v3p{ literal 0 HcmV?d00001 diff --git a/cave/com.raytheon.uf.viz.drawing/plugin.xml b/cave/com.raytheon.uf.viz.drawing/plugin.xml new file mode 100644 index 0000000000..dfc18c8dc5 --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/plugin.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/AbstractDrawingTool.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/AbstractDrawingTool.java new file mode 100644 index 0000000000..7e170cbcd8 --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/AbstractDrawingTool.java @@ -0,0 +1,113 @@ +/** + * 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.drawing; + +import com.raytheon.uf.viz.core.drawables.IDescriptor; +import com.raytheon.uf.viz.core.drawables.ResourcePair; +import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.rsc.AbstractVizResource; +import com.raytheon.uf.viz.core.rsc.IInputHandler; +import com.raytheon.uf.viz.core.rsc.LoadProperties; +import com.raytheon.uf.viz.core.rsc.ResourceList; +import com.raytheon.viz.ui.tools.AbstractModalTool; + +/** + * Describes a basic drawing tool. + * + * All subclasses implement abstract method getMouseHandler() which returns how + * the drawing is handled + * + * + * @author chammack + * + */ +public abstract class AbstractDrawingTool extends AbstractModalTool { + + /** The drawing layer */ + protected DrawingLayer theDrawingLayer; + + /** The handler (if any) that has been registered */ + protected IInputHandler handlerRegistered; + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.tools.AbstractModalTool#deactivateTool() + */ + @Override + protected void deactivateTool() { + editor.unregisterMouseHandler(this.handlerRegistered); + } + + @Override + protected void activateTool() { + theDrawingLayer = null; + IDescriptor desc = getActiveDescriptor(); + ResourceList rscList = desc.getResourceList(); + for (ResourcePair rp : rscList) { + AbstractVizResource rsc = rp.getResource(); + // find a drawable layer + if (rsc instanceof DrawingLayer) { + theDrawingLayer = (DrawingLayer) rsc; + break; + } + } + + if (theDrawingLayer == null) { + PathDrawingResourceData resourceData = new PathDrawingResourceData(); + try { + theDrawingLayer = resourceData.construct(new LoadProperties(), + desc); + } catch (VizException e1) { + e1.printStackTrace(); + } + try { + desc.getResourceList().add(theDrawingLayer); + + // TODO probably need to make this so that it can't be the time + // match basis + theDrawingLayer.initInternal(editor.getActiveDisplayPane() + .getTarget()); + } catch (Exception e) { + // ignore + } + } + + if (this.handlerRegistered != null) { + editor.unregisterMouseHandler(this.handlerRegistered); + } + + this.handlerRegistered = getMouseHandler(); + editor.registerMouseHandler(this.handlerRegistered); + } + + /** + * This method returns a mousehandler that will be registered/unregistered + * on the editor when appropriate. + * + * The handler should interact with the drawing layer to implement drawing + * functions. + * + * @return the handler + */ + public abstract IInputHandler getMouseHandler(); + +} diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/Activator.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/Activator.java new file mode 100644 index 0000000000..688297645f --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/Activator.java @@ -0,0 +1,50 @@ +package com.raytheon.uf.viz.drawing; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.raytheon.uf.viz.drawing"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/DrawingLayer.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/DrawingLayer.java new file mode 100644 index 0000000000..ad335d131b --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/DrawingLayer.java @@ -0,0 +1,316 @@ +/** + * 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.drawing; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.swt.graphics.RGB; + +import com.raytheon.uf.viz.core.IGraphicsTarget; +import com.raytheon.uf.viz.core.drawables.IWireframeShape; +import com.raytheon.uf.viz.core.drawables.PaintProperties; +import com.raytheon.uf.viz.core.drawables.ResourcePair; +import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.map.MapDescriptor; +import com.raytheon.uf.viz.core.rsc.AbstractResourceData; +import com.raytheon.uf.viz.core.rsc.AbstractVizResource; +import com.raytheon.uf.viz.core.rsc.LoadProperties; +import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability; +import com.raytheon.uf.viz.core.rsc.capabilities.EditableCapability; +import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability; +import com.raytheon.uf.viz.drawing.actions.ClearDrawingAction; +import com.raytheon.uf.viz.drawing.actions.EraseObjectsAction; +import com.raytheon.uf.viz.drawing.actions.RedoAddAction; +import com.raytheon.uf.viz.drawing.actions.UndoAddAction; +import com.raytheon.uf.viz.drawing.tools.ToolsUtils; +import com.raytheon.viz.ui.cmenu.IContextMenuContributor; +import com.vividsolutions.jts.geom.Geometry; +import com.vividsolutions.jts.geom.GeometryFactory; +import com.vividsolutions.jts.geom.LineString; +import com.vividsolutions.jts.geom.Point; + +/** + * Implements a basic drawing layer + * + * @author chammack + * + */ +public class DrawingLayer extends + AbstractVizResource implements + IContextMenuContributor { + + protected List tempGeometries; + + protected Map wireframeShapes; + + protected Map deletedShapes; + + protected IWireframeShape tempWireframeShape; + + protected IGraphicsTarget target; + + protected boolean needsRefresh = true; + + protected boolean erase = false; + + private EraseObjectsAction eAction = null; + + public DrawingLayer(PathDrawingResourceData data, LoadProperties props) { + super(data, props); + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.core.rsc.IVizResource#getName() + */ + public String getName() { + return "Telestrator Drawing Tool"; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.core.rsc.AbstractVizResource#init(com.raytheon.uf + * .viz.core.IGraphicsTarget) + */ + @Override + protected void initInternal(IGraphicsTarget target) throws VizException { + this.tempGeometries = new ArrayList(); + this.wireframeShapes = new LinkedHashMap(); + this.deletedShapes = new LinkedHashMap(); + this.target = target; + + getCapability(OutlineCapability.class); + getCapability(ColorableCapability.class); + getCapability(EditableCapability.class); + } + + /* + * (non-Javadoc) + * + * @seecom.raytheon.viz.core.rsc.IVizResource#paint(com.raytheon.viz.core. + * IGraphicsTarget, com.raytheon.viz.core.PixelExtent, double, float) + */ + protected void paintInternal(IGraphicsTarget target, + PaintProperties paintProps) throws VizException { + if (tempWireframeShape == null || needsRefresh) { + tempWireframeShape = target.createWireframeShape(true, + getDescriptor()); + needsRefresh = false; + } + + RGB rgb = getCapability(ColorableCapability.class).getColor(); + + OutlineCapability outline = getCapability(OutlineCapability.class); + ColorableCapability colorable = getCapability(ColorableCapability.class); + for (IWireframeShape sh : wireframeShapes.values()) { + target.drawWireframeShape(sh, colorable.getColor(), + (float) outline.getOutlineWidth()); + } + + for (Geometry g : this.tempGeometries) { + drawTempLinePrimitive(g, target, rgb); + } + target.drawWireframeShape(tempWireframeShape, colorable.getColor(), + outline.getOutlineWidth(), outline.getLineStyle()); + } + + private void drawTempLinePrimitive(Geometry shape, IGraphicsTarget target, + RGB color) throws VizException { + LineString line = (LineString) shape; + + int pts = line.getNumPoints(); + for (int i = 1; i < pts; i++) { + double[] p1 = this.descriptor + .worldToPixel(new double[] { line.getPointN(i - 1).getX(), + line.getPointN(i - 1).getY() }); + double[] p2 = this.descriptor.worldToPixel(new double[] { + line.getPointN(i).getX(), line.getPointN(i).getY() }); + double[][] coords = new double[2][2]; + coords[0][0] = p1[0]; + coords[0][1] = p1[1]; + coords[1][0] = p2[0]; + coords[1][1] = p2[1]; + tempWireframeShape.addLineSegment(coords); + } + } + + /** + * Draw a line using pixel coordinates + * + * UUID is optional, and generally should be null + * + * @param line + * @param isFinal + * @param uuid + */ + public void addLine(LineString line, String uuid) { + tempWireframeShape.compile(); + wireframeShapes.put(line, tempWireframeShape); + } + + public void addTempLine(LineString line) { + if (!erase) { + this.tempGeometries.add(line); + } else { + Map shapes = new HashMap(); + shapes.putAll(wireframeShapes); + GeometryFactory factory = new GeometryFactory(); + for (Geometry geom : shapes.keySet()) { + if (line.intersects(geom)) { + Point point = factory + .createPoint(line.getCoordinates()[line + .getNumPoints() - 1]); + if (point.buffer(8).intersects(geom)) { + Geometry intersection = point.intersection(geom); + Geometry finalGeom = geom.difference(intersection); + deletedShapes.put(geom, wireframeShapes.remove(geom)); + this.tempGeometries.add(finalGeom); + System.out.println("removing things"); + } + } + } + } + } + + public void reset() { + resetTemp(); + disposeInternal(); + } + + public void resetTemp() { + this.tempGeometries.clear(); + needsRefresh = true; + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.core.rsc.IVizResource#dispose() + */ + @Override + protected void disposeInternal() { + for (IWireframeShape shape : this.wireframeShapes.values()) { + shape.dispose(); + } + for (IWireframeShape shape : this.deletedShapes.values()) { + shape.dispose(); + } + this.wireframeShapes.clear(); + this.deletedShapes.clear(); + } + + public void undoAdd() { + if (!this.wireframeShapes.isEmpty()) { + Geometry geom = this.wireframeShapes.keySet().toArray( + new Geometry[0])[this.wireframeShapes.size() - 1]; + deletedShapes.put(geom, this.wireframeShapes.remove(geom)); + issueRefresh(); + } + } + + /** + * Add the ability to remove and redo + */ + public void redoAdd() { + if (!deletedShapes.isEmpty()) { + Geometry geom = this.deletedShapes.keySet() + .toArray(new Geometry[0])[this.deletedShapes.size() - 1]; + this.wireframeShapes.put(geom, this.deletedShapes.remove(geom)); + issueRefresh(); + } + } + + /** + * @return the wireframeShapes + */ + public IWireframeShape getTempWireframeShape() { + return tempWireframeShape; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.ui.cmenu.IContextMenuContributor#addContextMenuItems + * (org.eclipse.jface.action.IMenuManager, int, int) + */ + @Override + public void addContextMenuItems(IMenuManager menuManager, int x, int y) { + ResourcePair pair = new ResourcePair(); + pair.setResource(this); + if (eAction == null) { + eAction = new EraseObjectsAction(); + eAction.setSelectedRsc(pair); + } else { + eAction.setSelectedRsc(pair); + } + ClearDrawingAction cAction = new ClearDrawingAction(); + cAction.setSelectedRsc(pair); + cAction.setImageDescriptor(ToolsUtils.getImageDescriptor("remove.gif")); + UndoAddAction uAction = new UndoAddAction(); + uAction.setSelectedRsc(pair); + uAction.setImageDescriptor(ToolsUtils.getImageDescriptor("undo.gif")); + RedoAddAction rAction = new RedoAddAction(); + rAction.setSelectedRsc(pair); + rAction.setImageDescriptor(ToolsUtils.getImageDescriptor("redo.gif")); + menuManager.add(eAction); + menuManager.add(cAction); + menuManager.add(uAction); + menuManager.add(rAction); + } + + /** + * @return the erase + */ + public boolean isErase() { + return erase; + } + + /** + * @param erase + * the erase to set + */ + public void setErase(boolean erase) { + this.erase = erase; + } + + /** + * @return the deletedShapes + */ + public Map getDeletedShapes() { + return deletedShapes; + } + + /** + * @return the wireframeShapes + */ + public Map getWireframeShapes() { + return wireframeShapes; + } +} diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathDrawingResourceData.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathDrawingResourceData.java new file mode 100644 index 0000000000..e79bc7a423 --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathDrawingResourceData.java @@ -0,0 +1,85 @@ +/** + * 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.drawing; + +import com.raytheon.uf.viz.core.drawables.IDescriptor; +import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.rsc.LoadProperties; +import com.raytheon.viz.awipstools.ui.display.AwipsToolsResourceData; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 22, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class PathDrawingResourceData extends + AwipsToolsResourceData { + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.awipstools.ui.display.AwipsToolsResourceData#construct + * (com.raytheon.uf.viz.core.rsc.LoadProperties, + * com.raytheon.uf.viz.core.drawables.IDescriptor) + */ + @Override + public DrawingLayer construct(LoadProperties loadProperties, + IDescriptor descriptor) throws VizException { + DrawingLayer layer = new DrawingLayer(this, loadProperties); + return layer; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.awipstools.ui.display.AwipsToolsResourceData#update( + * java.lang.Object) + */ + @Override + public void update(Object updateData) { + // TODO Auto-generated method stub + super.update(updateData); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.awipstools.ui.display.AwipsToolsResourceData#getClassT() + */ + @Override + public String getClassT() { + return this.getClass().getCanonicalName(); + } +} diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathToolbar.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathToolbar.java new file mode 100644 index 0000000000..fe2fab5943 --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathToolbar.java @@ -0,0 +1,73 @@ +/** + * 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.drawing; + +import org.eclipse.swt.widgets.Shell; + +import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 28, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class PathToolbar extends CaveSWTDialogBase { + + /** + * @param parentShell + * @param swtStyle + */ + protected PathToolbar(Shell parentShell, int swtStyle) { + super(parentShell, swtStyle); + // TODO Auto-generated constructor stub + } + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org + * .eclipse.swt.widgets.Shell) + */ + @Override + protected void initializeComponents(Shell shell) { + } + +} diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/ClearDrawingAction.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/ClearDrawingAction.java new file mode 100644 index 0000000000..3748235e58 --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/ClearDrawingAction.java @@ -0,0 +1,74 @@ +/** + * 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.drawing.actions; + +import com.raytheon.uf.viz.drawing.DrawingLayer; +import com.raytheon.viz.ui.cmenu.AbstractRightClickAction; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 22, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class ClearDrawingAction extends AbstractRightClickAction { + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.action.Action#run() + */ + @Override + public void run() { + if (getSelectedRsc() != null) { + ((DrawingLayer) getSelectedRsc()).reset(); + } + } + + @Override + public String getText() { + return "Clear Drawing"; + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.cmenu.AbstractRightClickAction#isHidden() + */ + @Override + public boolean isHidden() { + if (getSelectedRsc() instanceof DrawingLayer) { + return false; + } else { + return true; + } + } +} diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/EraseObjectsAction.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/EraseObjectsAction.java new file mode 100644 index 0000000000..ac8226df48 --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/EraseObjectsAction.java @@ -0,0 +1,75 @@ +/** + * 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.drawing.actions; + +import org.eclipse.jface.action.IAction; + +import com.raytheon.uf.viz.drawing.DrawingLayer; +import com.raytheon.viz.ui.cmenu.AbstractRightClickAction; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 23, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class EraseObjectsAction extends AbstractRightClickAction { + + /** + * + */ + public EraseObjectsAction() { + super("Eraser", IAction.AS_CHECK_BOX); + } + + @Override + public void run() { + ((DrawingLayer) getSelectedRsc()) + .setErase(!((DrawingLayer) getSelectedRsc()).isErase()); + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.cmenu.AbstractRightClickAction#isHidden() + */ + @Override + public boolean isHidden() { + if (true) { + return true; + } + if (getSelectedRsc() instanceof DrawingLayer) { + return false; + } else { + return true; + } + } +} diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/RedoAddAction.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/RedoAddAction.java new file mode 100644 index 0000000000..ee087cda34 --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/RedoAddAction.java @@ -0,0 +1,81 @@ +/** + * 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.drawing.actions; + +import com.raytheon.uf.viz.drawing.DrawingLayer; +import com.raytheon.viz.ui.cmenu.AbstractRightClickAction; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 28, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class RedoAddAction extends AbstractRightClickAction { + + @Override + public void run() { + ((DrawingLayer) getSelectedRsc()).redoAdd(); + } + + @Override + public boolean isHidden() { + if (getSelectedRsc() instanceof DrawingLayer) { + return false; + } else { + return true; + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.action.Action#isEnabled() + */ + @Override + public boolean isEnabled() { + if (!((DrawingLayer) getSelectedRsc()).getDeletedShapes().isEmpty()) { + return true; + } else { + return false; + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.action.Action#getText() + */ + @Override + public String getText() { + return "Redo Draw"; + } +} diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/UndoAddAction.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/UndoAddAction.java new file mode 100644 index 0000000000..1f2493677d --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/actions/UndoAddAction.java @@ -0,0 +1,81 @@ +/** + * 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.drawing.actions; + +import com.raytheon.uf.viz.drawing.DrawingLayer; +import com.raytheon.viz.ui.cmenu.AbstractRightClickAction; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 23, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class UndoAddAction extends AbstractRightClickAction { + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.action.Action#run() + */ + @Override + public void run() { + ((DrawingLayer) getSelectedRsc()).undoAdd(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.action.Action#isEnabled() + */ + @Override + public boolean isEnabled() { + if (!((DrawingLayer) getSelectedRsc()).getWireframeShapes().isEmpty()) { + return true; + } else { + return false; + } + } + + @Override + public String getText() { + return "Undo Draw"; + } + + @Override + public boolean isHidden() { + if (getSelectedRsc() instanceof DrawingLayer) { + return false; + } else { + return true; + } + } +} diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/objects/TransferLine.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/objects/TransferLine.java new file mode 100644 index 0000000000..480a91c053 --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/objects/TransferLine.java @@ -0,0 +1,60 @@ +/** + * 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.drawing.objects; + +import java.util.List; + +import com.vividsolutions.jts.geom.Coordinate; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 26, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class TransferLine { + private List coordinates; + + /** + * @param coordinates + * the coordinates to set + */ + public void setCoordinates(List coordinates) { + this.coordinates = coordinates; + } + + /** + * @return the coordinates + */ + public List getCoordinates() { + return coordinates; + } +} diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/objects/TransferObject.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/objects/TransferObject.java new file mode 100644 index 0000000000..96d8fb5013 --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/objects/TransferObject.java @@ -0,0 +1,41 @@ +/** + * 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.drawing.objects; + +/** + * TODO Add Description + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 26, 2012            mnash     Initial creation
+ *
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class TransferObject { + +} diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/tools/PathDrawingTool.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/tools/PathDrawingTool.java new file mode 100644 index 0000000000..f645bdaec7 --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/tools/PathDrawingTool.java @@ -0,0 +1,186 @@ +/** + * 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.drawing.tools; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.widgets.Display; + +import com.raytheon.uf.viz.core.rsc.IInputHandler; +import com.raytheon.uf.viz.drawing.AbstractDrawingTool; +import com.raytheon.viz.ui.input.InputAdapter; +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.GeometryFactory; +import com.vividsolutions.jts.geom.LineString; + +/** + * Draw unmodified path shapes (i.e. "pencil tool") + * + * @author chammack + * + */ +public class PathDrawingTool extends AbstractDrawingTool { + + /** The mouse handler */ + protected IInputHandler theHandler; + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.drawing.AbstractDrawingTool#getMouseHandler() + */ + @Override + public IInputHandler getMouseHandler() { + if (theHandler == null) { + theHandler = new PathDrawingHandler(); + } + return theHandler; + } + + public class PathDrawingHandler extends InputAdapter { + + private List pathList; + + private int theLastMouseX; + + private int theLastMouseY; + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.input.IInputHandler#handleMouseDown(int, + * int, int) + */ + @Override + public boolean handleMouseDown(int anX, int aY, int button) { + if (button != 1) + return false; + + Cursor cursor = null; + if (theDrawingLayer.isErase()) { + ImageData data = ToolsUtils.getImageDescriptor("eraser.gif") + .getImageData(); + data.alpha = 255; + cursor = new Cursor(Display.getCurrent(), data, 8, 8); + } else { + cursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND); + } + + Display.getCurrent().getActiveShell().setCursor(cursor); + cursor.dispose(); + + if (pathList != null) + pathList.clear(); + else + pathList = new ArrayList(); + + theLastMouseX = anX; + theLastMouseY = aY; + Coordinate p1 = editor.translateClick(theLastMouseX, theLastMouseY); + pathList.add(p1); + return true; + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.input.IInputHandler#handleMouseDownMove(int, + * int, int) + */ + @Override + public boolean handleMouseDownMove(int x, int y, int button) { + if (button != 1) + return false; + Coordinate p1 = editor.translateClick(theLastMouseX, theLastMouseY); + Coordinate p2 = editor.translateClick(x, y); + + if (p1 == null || p2 == null) + return true; + + pathList.add(p2); + + GeometryFactory gf = new GeometryFactory(); + LineString ls = gf.createLineString(new Coordinate[] { p1, p2 }); + + theDrawingLayer.addTempLine(ls); + + theLastMouseX = x; + theLastMouseY = y; + editor.refresh(); + return true; + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.input.IInputHandler#handleMouseUp(int, int, + * int) + */ + @Override + public boolean handleMouseUp(int anX, int aY, int button) { + // change the cursor back on up + Cursor cursor = new Cursor(Display.getCurrent(), SWT.CURSOR_ARROW); + Display.getCurrent().getActiveShell().setCursor(cursor); + cursor.dispose(); + + if (button != 1) { + return false; + } + + theDrawingLayer.resetTemp(); + Coordinate[] coords = (Coordinate[]) pathList + .toArray(new Coordinate[pathList.size()]); + GeometryFactory gf = new GeometryFactory(); + if (coords.length > 1) { + LineString ls = gf.createLineString(coords); + if (!theDrawingLayer.isErase()) { + theDrawingLayer.addLine(ls, null); + } + + // TODO take this and send the coordinates + // TransferLine object = new TransferLine(); + // object.setCoordinates(ls.getCoordinates()); + // object.setShape(theDrawingLayer.getTempWireframeShape()); + // object.setColor(theDrawingLayer.getCapability( + // ColorableCapability.class).getColorAsString()); + // try { + // // test writing out to a file for object size + // UUID temp = UUID.randomUUID(); + // JAXBContext context = SerializationUtil.getJaxbContext(); + // Marshaller marshaller = context.createMarshaller(); + // marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, + // false); + // marshaller.marshal(object, new File( + // "/home/mnash/Desktop/temp/jaxb" + temp)); + // // SerializationUtil.jaxbMarshalToXmlFile(object, + // // "/home/mnash/Desktop/temp/jaxb" + temp); + // } catch (JAXBException e) { + // e.printStackTrace(); + // } + } + return true; + } + } +} diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/tools/ToolsUtils.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/tools/ToolsUtils.java new file mode 100644 index 0000000000..688146f78e --- /dev/null +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/tools/ToolsUtils.java @@ -0,0 +1,60 @@ +/** + * 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.drawing.tools; + +import java.io.File; +import java.net.URL; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.resource.ImageDescriptor; + +import com.raytheon.uf.viz.drawing.Activator; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 26, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class ToolsUtils { + + public static ImageDescriptor getImageDescriptor(String string) { + String iconPath = "icons" + File.separator; + URL url = FileLocator.find(Activator.getDefault().getBundle(), + new Path(iconPath + string), null); + if (url != null && url.getFile() == null) { + url = FileLocator.find(Activator.getDefault().getBundle(), + new Path(".." + File.separator + iconPath + string), null); + } + return ImageDescriptor.createFromURL(url); + } +}