@Override public mxPoint paintMarker( mxGraphics2DCanvas canvas, mxCellState state, String type, mxPoint pe, double nx, double ny, double size, boolean source) { // Polygon poly = new Polygon(); // poly.addPoint((int) Math.round(pe.getX()), (int) Math.round(pe.getY())); // poly.addPoint((int) Math.round(pe.getX() - nx - ny / 2), (int) Math.round(pe.getY() - // ny + nx / 2)); // poly.addPoint((int) Math.round(pe.getX() + ny / 2 - nx), (int) Math.round(pe.getY() - // ny - nx / 2)); // canvas.getGraphics().draw(poly); // Color prev = canvas.getGraphics().getColor(); // canvas.getGraphics().setColor(Color.white); // canvas.getGraphics().fillOval( (int)(pe.getX() -nx - RADIUS), (int)(pe.getY() -ny - RADIUS), // RADIUS * 2 , RADIUS * 2); // canvas.getGraphics().setColor(prev); System.out.println("RENDERING !!!"); canvas .getGraphics() .drawOval( (int) (pe.getX() - nx - RADIUS), (int) (pe.getY() - ny - RADIUS), RADIUS * 2, RADIUS * 2); return new mxPoint(-nx, -ny); }
/** * Returns a clone of this state where all members are deeply cloned except the view and cell * references, which are copied with no cloning to the new instance. */ public Object clone() { mxCellState clone = new mxCellState(view, cell, style); if (absolutePoints != null) { clone.absolutePoints = new ArrayList<mxPoint>(); for (int i = 0; i < absolutePoints.size(); i++) { clone.absolutePoints.add((mxPoint) absolutePoints.get(i).clone()); } } if (origin != null) { clone.origin = (mxPoint) origin.clone(); } if (absoluteOffset != null) { clone.absoluteOffset = (mxPoint) absoluteOffset.clone(); } if (boundingBox != null) { clone.boundingBox = (mxRectangle) boundingBox.clone(); } clone.terminalDistance = terminalDistance; clone.segments = segments; clone.length = length; clone.x = x; clone.y = y; clone.width = width; clone.height = height; return clone; }
public int getIndexOfEdgePointAt(int x, int y, int tol) { Rectangle rect = new Rectangle(x - tol / 2, y - tol / 2, tol, tol); List<mxPoint> pts = getAbsolutePoints(); int i = 0; for (mxPoint p : pts) { // System.out.println("point="+p.getX()+" "+p.getY()); if (rect.contains(p.getPoint())) return i; i++; } return -1; }
public int getIndexOfNewPoint(int x, int y, int tol) { Rectangle rect = new Rectangle(x - tol / 2, y - tol / 2, tol, tol); List<mxPoint> pts = getAbsolutePoints(); int length = pts.size(); mxPoint start, end; start = pts.get(0); for (int i = 1; i < length; i++) { end = pts.get(i); if (rect.intersectsLine(start.getX(), start.getY(), end.getX(), end.getY())) return i; start = end; } return -1; }
/** * Draws the given lines as segments between all points of the given list of mxPoints. * * @param pts List of points that define the line. * @param style Style to be used for painting the line. */ public void drawLine(List<mxPoint> pts, Map<String, Object> style) { String strokeColor = mxUtils.getString(style, mxConstants.STYLE_STROKECOLOR); int strokeWidth = (int) (mxUtils.getInt(style, mxConstants.STYLE_STROKEWIDTH, 1) * scale); if (strokeColor != null && strokeWidth > 0) { mxPoint last = pts.get(0); for (int i = 1; i < pts.size(); i++) { mxPoint pt = pts.get(i); drawSegment( (int) last.getX(), (int) last.getY(), (int) pt.getX(), (int) pt.getY(), strokeColor, strokeWidth); last = pt; } } }