Issue #429 fix null pointers and make erase first pass possible

Former-commit-id: 67a87efe19292a279d42a0104d902afc59e3dd84
This commit is contained in:
Matt Nash 2012-04-13 10:46:53 -05:00
parent c6c0483cee
commit b133b57c6d
4 changed files with 43 additions and 12 deletions

View file

@ -106,8 +106,10 @@ public abstract class AbstractRoleEventController implements
protected void deactivateTelestrator() {
// TODO this must be handled better
PathToolbar.getToolbar().close();
if (tool != null) {
tool.deactivate();
session.unRegisterEventHandler(tool);
}
}
}

View file

@ -25,6 +25,7 @@ import java.util.Map;
import org.eclipse.swt.graphics.RGB;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
@ -53,8 +54,10 @@ import com.raytheon.uf.viz.remote.graphics.DispatchGraphicsTarget;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.editor.AbstractEditor;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LineString;
import com.vividsolutions.jts.geom.MultiLineString;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.TopologyException;
/**
@ -226,15 +229,15 @@ public class CollaborationDrawingLayer extends DrawingLayer {
}
break;
case ERASE:
if (true) {
return;
}
// TODO need to functionize this as it is mostly the same as
// DrawingLayer
userName = event.getUserName();
double extentPercentageX = paintProps.getView().getExtent()
.getWidth()
/ (double) paintProps.getCanvasBounds().width;
double cursorSize = 16;
double size = extentPercentageX * cursorSize;
Multimap<String, ShapeContainer> containers = HashMultimap.create();
synchronized (collaboratorShapes) {
for (ShapeContainer cont : collaboratorShapes.get(userName)) {
Geometry line = event.getContainer().getGeom();
@ -247,22 +250,45 @@ public class CollaborationDrawingLayer extends DrawingLayer {
} catch (TopologyException e) {
continue;
}
Geometry lString = null;
if (finalGeom instanceof MultiLineString) {
Geometry lString = (MultiLineString) finalGeom;
lString = (MultiLineString) finalGeom;
for (int j = 0; j < lString.getNumGeometries(); j++) {
LineString lineString = (LineString) lString
.getGeometryN(j);
eraseWireframeShape = target
.createWireframeShape(true, descriptor);
drawTempLinePrimitive(lineString,
eraseWireframeShape);
ShapeContainer shCont = new ShapeContainer();
shCont.setGeom(lString);
shCont.setShape(eraseWireframeShape);
collaboratorShapes.get(userName).add(shCont);
}
}
containers.put(userName, shCont);
}
} else if (finalGeom instanceof LineString) {
GeometryFactory factory = new GeometryFactory();
lString = (LineString) finalGeom;
Point point = factory.createPoint(lString
.getCoordinates()[0]);
intersection = point.buffer(size / 2).intersection(
cont.getGeom());
finalGeom = cont.getGeom().difference(intersection);
eraseWireframeShape = target.createWireframeShape(
true, descriptor);
drawTempLinePrimitive(lString, eraseWireframeShape);
ShapeContainer shCont = new ShapeContainer();
shCont.setGeom(lString);
shCont.setShape(eraseWireframeShape);
containers.put(userName, shCont);
} else {
containers.put(userName, cont);
}
} else {
containers.put(userName, cont);
}
}
}
collaboratorShapes = containers;
break;
}
issueRefresh();
@ -302,7 +328,7 @@ public class CollaborationDrawingLayer extends DrawingLayer {
@Override
public void addTempEraseLine(LineString line) {
super.addTempEraseLine(line);
sendEraseEvent(line);
// sendEraseEvent(line);
}
/*

View file

@ -26,6 +26,7 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolItem;
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.ui.Activator;
@ -118,9 +119,10 @@ public class CollaborationPathToolbar extends PathToolbar {
if (resource.getResourceData() instanceof CollaborationPathDrawingResourceData) {
String sessionId = ((CollaborationPathDrawingResourceData) resource
.getResourceData()).getSessionId();
if (!CollaborationDataManager.getInstance().getSession(sessionId)
.hasRole(ParticipantRole.SESSION_LEADER)
IVenueSession session = CollaborationDataManager.getInstance()
.getSession(sessionId);
if (session != null
&& !session.hasRole(ParticipantRole.SESSION_LEADER)
&& leaderOnly != null) {
leaderOnly.setEnabled(false);
}

View file

@ -184,7 +184,8 @@ public class PathDrawingTool extends AbstractDrawingTool {
if (coords.length > 1) {
LineString ls = gf.createLineString(coords);
ls = theDrawingLayer.convertPixels(ls);
if (theDrawingLayer.getState() == LayerState.DRAWING) {
if (theDrawingLayer.getState() == LayerState.DRAWING
|| theDrawingLayer.getState() == LayerState.ERASING) {
theDrawingLayer.finalizeLine(ls, null);
}
}