private void drag(WebPlotView pv, ScreenPt spt) { WebPlot plot = pv.getPrimaryPlot(); _mouseInfo.setEnableAllPersistent(true); _mouseInfo.setEnableAllExclusive(false); _currentPt = plot.getImageWorkSpaceCoords(spt); _dataConnect.setData(makeSelectedObj(plot)); _drawMan.redraw(); }
@Override public void onSuccess(WebPlotResult result) { if (result.isSuccess()) { plot.setPlotState((PlotState) result.getResult(WebPlotResult.PLOT_STATE)); plot.refreshWidget((PlotImages) result.getResult(WebPlotResult.PLOT_IMAGES)); plot.getPlotView().getMiniPlotWidget().forcePlotPrefUpdate(); } else { PopupUtil.showError("Server Error", "Could not change color: " + result.getUserFailReason()); } }
private void begin(WebPlotView pv, ScreenPt spt) { WebPlot plot = pv.getPrimaryPlot(); pv.fixScrollPosition(); _mouseInfo.setEnableAllPersistent(true); _mouseInfo.setEnableAllExclusive(false); switch (_mode) { case SELECT: _firstPt = plot.getImageWorkSpaceCoords(spt); _currentPt = _firstPt; break; case EDIT: LineSelection sel = (LineSelection) pv.getAttribute(WebPlot.ACTIVE_DISTANCE); if (sel == null) { WebAssert.tst(false, "no RecSelection found in plot"); } ImageWorkSpacePt ptAry[] = new ImageWorkSpacePt[] {sel.getPt1(), sel.getPt2()}; int idx = findClosestPtIdx(plot, ptAry, spt); if (idx < 0) return; ScreenPt testPt = plot.getScreenCoords(ptAry[idx]); double dist = distance(testPt, spt); if (dist < EDIT_DISTANCE && dist > -1) { int oppoIdx = idx == 0 ? 1 : 0; _firstPt = ptAry[oppoIdx]; _currentPt = ptAry[idx]; } else { _firstPt = plot.getImageWorkSpaceCoords(spt); _currentPt = _firstPt; } break; case OFF: releaseMouse(); break; default: WebAssert.argTst(false, "only support for SelectType of SELECT EDIT, OFF"); break; } }
private int findClosestPtIdx(WebPlot plot, Pt inPtAry[], ScreenPt spt) { int idx = -1; ScreenPt ptAry[] = new ScreenPt[inPtAry.length]; for (int i = 0; (i < ptAry.length); i++) { ptAry[i] = plot.getScreenCoords(inPtAry[i]); } double dist = Double.MAX_VALUE; double testDist; for (int i = 0; (i < ptAry.length); i++) { if (ptAry[i] != null) { testDist = distance(ptAry[i], spt); if (testDist < dist && testDist > -1) { dist = testDist; idx = i; } } } return idx; }
@Override public void doTask(AsyncCallback<WebPlotResult> passAlong) { PlotServiceAsync pserv = PlotService.App.getInstance(); pserv.changeColor(plot.getPlotState(), colorIdx, passAlong); }
public ColorTaskRPC(WebPlot plot, int colorIdx) { super(plot.getPlotView().getMaskWidget(), "changing color...", true); super.setMaskingDelaySec(1); this.plot = plot; this.colorIdx = colorIdx; }
private List<DrawObj> makeSelectedObj(WebPlot plot) { List<DrawObj> retval; _ptAry[0] = _firstPt; _ptAry[1] = _currentPt; Projection proj = plot.getProjection(); Pt anyPt1; Pt anyPt2; double dist; boolean world; if (proj.isSpecified()) { anyPt1 = plot.getWorldCoords(_ptAry[0]); anyPt2 = plot.getWorldCoords(_ptAry[1]); dist = VisUtil.computeDistance((WorldPt) anyPt1, (WorldPt) anyPt2); world = true; } else { anyPt1 = _ptAry[0]; anyPt2 = _ptAry[1]; dist = VisUtil.computeDistance(anyPt1, anyPt2); world = false; } if (anyPt1 == null || anyPt2 == null) return null; ShapeDataObj obj = ShapeDataObj.makeLine(anyPt1, anyPt2); obj.setStyle(ShapeDataObj.Style.HANDLED); setDistOnShape(obj, dist, ShapeDataObj.TextLocation.LINE_MID_POINT, world); obj.setTextOffset(new OffsetScreenPt(-15, 0)); OffsetScreenPt angleOffPt; if (_posAngle) { Pt eastPt; Pt westPt; if (anyPt1.getX() > anyPt2.getX()) { eastPt = anyPt1; westPt = anyPt2; } else { eastPt = anyPt2; westPt = anyPt1; } ShapeDataObj adj; ShapeDataObj op; double adjDist; double opDist; Pt lonDelta1TextPt; if (world) { WorldPt lonDelta1 = new WorldPt(eastPt.getX(), eastPt.getY()); WorldPt lonDelta2 = new WorldPt(westPt.getX(), eastPt.getY()); adjDist = VisUtil.computeDistance(lonDelta1, lonDelta2); WorldPt latDelta1 = new WorldPt(westPt.getX(), eastPt.getY()); WorldPt latDelta2 = new WorldPt(westPt.getX(), westPt.getY()); opDist = VisUtil.computeDistance(latDelta1, latDelta2); adj = ShapeDataObj.makeLine(lonDelta1, lonDelta2); op = ShapeDataObj.makeLine(latDelta1, latDelta2); lonDelta1TextPt = lonDelta1; } else { ImageWorkSpacePt lonDelta1 = new ImageWorkSpacePt(eastPt.getX(), eastPt.getY()); ImageWorkSpacePt lonDelta2 = new ImageWorkSpacePt(westPt.getX(), eastPt.getY()); adjDist = VisUtil.computeDistance(lonDelta1, lonDelta2); ImageWorkSpacePt latDelta1 = new ImageWorkSpacePt(westPt.getX(), eastPt.getY()); ImageWorkSpacePt latDelta2 = new ImageWorkSpacePt(westPt.getX(), westPt.getY()); opDist = VisUtil.computeDistance(latDelta1, latDelta2); adj = ShapeDataObj.makeLine(lonDelta1, lonDelta2); op = ShapeDataObj.makeLine(latDelta1, latDelta2); lonDelta1TextPt = lonDelta1; } setDistOnShape(adj, adjDist, ShapeDataObj.TextLocation.LINE_MID_POINT_OR_BOTTOM, world); setDistOnShape(op, opDist, ShapeDataObj.TextLocation.LINE_MID_POINT_OR_TOP, world); op.setTextOffset(new OffsetScreenPt(0, 15)); double sinX = opDist / dist; double angle = Math.toDegrees(Math.asin(sinX)); String aStr = _nf.format(angle) + HTML_DEG; ShapeDataObj angleShape = ShapeDataObj.makeText(new OffsetScreenPt(8, -8), lonDelta1TextPt, aStr); retval = Arrays.asList((DrawObj) obj, adj, op, angleShape); } else { retval = Arrays.asList((DrawObj) obj); } return retval; }