Merge "Issue #429 telestrator merging" into 11-Collaboration

Former-commit-id: aaba32c4c1 [formerly cf880ddd0d] [formerly 676746126c [formerly eda16f8aa5a9aa88a8e947070d8e9df32c36c114]]
Former-commit-id: 676746126c
Former-commit-id: ec0896c28d
This commit is contained in:
Nate Jensen 2012-03-28 15:10:34 -05:00 committed by Gerrit Code Review
commit 7d5d70bf55
25 changed files with 1450 additions and 0 deletions

View file

@ -107,4 +107,11 @@
install-size="0"
version="0.0.0"/>
<plugin
id="com.raytheon.uf.viz.drawing"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>

View file

@ -130,6 +130,14 @@
style="push">
</command>
</menuContribution>
<menuContribution
locationURI="toolbar:d2d-2?after=tools.toolbar">
<command
commandId="com.raytheon.uf.viz.drawing.pathdrawingtool"
style="push"
label="Draw">
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.editors">

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.viz.drawing</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

View file

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This_software_was_developed_and_/_or_modified_by_Raytheon_Company,
pursuant_to_Contract_DG133W-05-CQ-1067_with_the_US_Government.
U.S._EXPORT_CONTROLLED_TECHNICAL_DATA
This_software_product_contains_export-restricted_data_whose
export/transfer/disclosure_is_restricted_by_U.S._law._Dissemination
to_non-U.S._persons_whether_in_the_United_States_or_abroad_requires
an_export_license_or_other_authorization.
Contractor_Name:________Raytheon_Company
Contractor_Address:_____6825_Pine_Street,_Suite_340
________________________Mail_Stop_B8
________________________Omaha,_NE_68106
________________________402.291.0100
See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for
further_licensing_information.
-->
<?eclipse version="3.2"?>
<plugin>
<extension
point="org.eclipse.ui.commands">
<command
id="com.raytheon.uf.viz.drawing.pathdrawingtool"
name="Draw Path...">
</command>
<command
id="com.raytheon.uf.viz.drawing.undoadd"
name="Undo Add">
</command>
<command
id="com.raytheon.uf.viz.drawing.redoadd"
name="Redo Add">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.raytheon.uf.viz.drawing.tools.PathDrawingTool"
commandId="com.raytheon.uf.viz.drawing.pathdrawingtool">
</handler>
<handler
class="com.raytheon.uf.viz.drawing.actions.UndoAddAction"
commandId="com.raytheon.uf.viz.drawing.undoadd">
</handler>
<handler
class="com.raytheon.uf.viz.drawing.actions.RedoAddAction"
commandId="com.raytheon.uf.viz.drawing.redoadd">
</handler>
</extension>
<extension
point="org.eclipse.ui.bindings">
<scheme
id="com.raytheon.uf.viz.drawing.scheme"
name="Drawing Scheme">
</scheme>
<key
commandId="com.raytheon.uf.viz.drawing.undoadd"
contextId="com.raytheon.viz.ui.mapContext"
schemeId="com.raytheon.uf.viz.drawing.scheme"
sequence="M1+Z">
</key>
<key
commandId="com.raytheon.uf.viz.drawing.redoadd"
contextId="com.raytheon.viz.ui.mapContext"
schemeId="com.raytheon.uf.viz.drawing.scheme"
sequence="M1+Y">
</key>
</extension>
</plugin>

View file

@ -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();
}

View file

@ -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;
}
}

View file

@ -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<AbstractResourceData, MapDescriptor> implements
IContextMenuContributor {
protected List<Geometry> tempGeometries;
protected Map<Geometry, IWireframeShape> wireframeShapes;
protected Map<Geometry, IWireframeShape> 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<Geometry>();
this.wireframeShapes = new LinkedHashMap<Geometry, IWireframeShape>();
this.deletedShapes = new LinkedHashMap<Geometry, IWireframeShape>();
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<Geometry, IWireframeShape> shapes = new HashMap<Geometry, IWireframeShape>();
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<Geometry, IWireframeShape> getDeletedShapes() {
return deletedShapes;
}
/**
* @return the wireframeShapes
*/
public Map<Geometry, IWireframeShape> getWireframeShapes() {
return wireframeShapes;
}
}

View file

@ -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
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 22, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class PathDrawingResourceData extends
AwipsToolsResourceData<DrawingLayer> {
/*
* (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();
}
}

View file

@ -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
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 28, 2012 mnash Initial creation
*
* </pre>
*
* @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) {
}
}

View file

@ -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
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 22, 2012 mnash Initial creation
*
* </pre>
*
* @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;
}
}
}

View file

@ -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
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 23, 2012 mnash Initial creation
*
* </pre>
*
* @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;
}
}
}

View file

@ -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
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 28, 2012 mnash Initial creation
*
* </pre>
*
* @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";
}
}

View file

@ -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
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 23, 2012 mnash Initial creation
*
* </pre>
*
* @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;
}
}
}

View file

@ -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
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 26, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class TransferLine {
private List<Coordinate> coordinates;
/**
* @param coordinates
* the coordinates to set
*/
public void setCoordinates(List<Coordinate> coordinates) {
this.coordinates = coordinates;
}
/**
* @return the coordinates
*/
public List<Coordinate> getCoordinates() {
return coordinates;
}
}

View file

@ -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
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 26, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class TransferObject {
}

View file

@ -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<Coordinate> 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<Coordinate>();
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;
}
}
}

View file

@ -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
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 26, 2012 mnash Initial creation
*
* </pre>
*
* @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);
}
}