Image renderStatic() { size = new org.eclipse.swt.graphics.Point((int) (m * viewRect.width), (int) (m * viewRect.height)); final Image img = new Image(getDisplay(), size.x, size.y); final GC gc = new GC(img); for (final CanvasRenderer r : canvasRenderers) { r.renderStatic(gc, new ViewPort(new Point(0, 0), viewRect, m)); } gc.dispose(); return img; }
void drawArrow(Point from, Point to, int width, int height) { final double w = vp.get().invScale(width); final double h = vp.get().invScale(height); final Point left = PointUtil.perp(to, from, h, w / 2d); final Point right = PointUtil.perp(to, from, h, -w / 2d); drawLine(from, PointUtil.on(from, to, h)); fillPolygon(left, right, to); }
renderer.renderDynamic(gc, new ViewPort(new Point(center.x, center.y), viewRect, m),
final int xpx = vp.toCoordX(p.x); final int ypx = vp.toCoordY(p.y); gc.setForeground(c); gc.setLineStyle(SWT.LINE_DOT); gc.drawLine(vp.toCoordX(dest.x), vp.toCoordY(dest.y), xpx, ypx); gc.setLineStyle(SWT.LINE_SOLID); xpx - vp.scale(r), ypx - vp.scale(r), 2 * vp.scale(r), 2 * vp.scale(r)); xpx - vp.scale(r), ypx - vp.scale(r), 2 * vp.scale(r), 2 * vp.scale(r));
final int xpx = vp.toCoordX(p.x); final int ypx = vp.toCoordY(p.y); gc.setForeground(c); gc.setLineStyle(SWT.LINE_DOT); gc.drawLine(vp.toCoordX(dest.x), vp.toCoordY(dest.y), xpx, ypx); gc.setLineStyle(SWT.LINE_SOLID); xpx - vp.scale(r), ypx - vp.scale(r), 2 * vp.scale(r), 2 * vp.scale(r)); xpx - vp.scale(r), ypx - vp.scale(r), 2 * vp.scale(r), 2 * vp.scale(r));
void fillRect(Point corner, double radius) { final int x1 = vp.get().toCoordX(corner.x - radius); final int y1 = vp.get().toCoordY(corner.y - radius); final int x2 = vp.get().toCoordX(corner.x + radius); final int y2 = vp.get().toCoordY(corner.y + radius); gc.get().fillPolygon(new int[] {x1, y1, x2, y1, x2, y2, x1, y2}); }
void drawCurve(Point p1, Point p2, Point control) { final Path path = new Path(gc.get().getDevice()); path.moveTo(vp.get().toCoordX(p1.x), vp.get().toCoordY(p1.y)); path.quadTo( vp.get().toCoordX(control.x), vp.get().toCoordY(control.y), vp.get().toCoordX(p2.x), vp.get().toCoordY(p2.y)); gc.get().drawPath(path); path.dispose(); }
@Override public void renderStatic(GC gc, ViewPort vp) { final int xMin = vp.toCoordX(bounds.get(0).x); final int yMin = vp.toCoordY(bounds.get(0).y); final int xMax = vp.toCoordX(bounds.get(1).x); final int yMax = vp.toCoordY(bounds.get(1).y); final int outerXmin = vp.toCoordX(vp.rect.min.x); final int outerYmin = vp.toCoordY(vp.rect.min.y); final int outerXmax = vp.toCoordX(vp.rect.max.x); final int outerYmax = vp.toCoordY(vp.rect.max.y); gc.setBackground( gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); gc.fillRectangle(outerXmin, outerYmin, outerXmax, outerYmax); gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WHITE)); gc.fillRectangle(xMin, yMin, xMax - xMin, yMax - yMin); gc.drawRectangle(xMin, yMin, xMax - xMin, yMax - yMin); }
@Override public void renderDynamic(GC gc, ViewPort vp, long time) { final List<Point> bounds = roadModel.getBounds(); gc.drawLine(vp.toCoordX(bounds.get(0).x), vp.toCoordY(bounds.get(0).y), vp.toCoordX(bounds.get(1).x), vp.toCoordY(bounds.get(1).y)); gc.drawText("fancy pancy", vp.toCoordX(bounds.get(0).x), vp.toCoordY(bounds.get(0).y) + 100, true); }