/** * */ protected Point[] createPoints(mxCellState s) { Point[] pts = new Point[s.getAbsolutePointCount()]; for (int i = 0; i < pts.length; i++) { pts[i] = s.getAbsolutePoint(i).getPoint(); } return pts; }
/** * */ protected Point[] createPoints(mxCellState s) { Point[] pts = new Point[s.getAbsolutePointCount()]; for (int i = 0; i < pts.length; i++) { pts[i] = s.getAbsolutePoint(i).getPoint(); } return pts; }
/** * Finds the index of the nearest segment on the given cell state for the * specified coordinate pair. */ public static int findNearestSegment(mxCellState state, double x, double y) { int index = -1; if (state.getAbsolutePointCount() > 0) { mxPoint last = state.getAbsolutePoint(0); double min = Double.MAX_VALUE; for (int i = 1; i < state.getAbsolutePointCount(); i++) { mxPoint current = state.getAbsolutePoint(i); double dist = new Line2D.Double(last.x, last.y, current.x, current.y).ptSegDistSq(x, y); if (dist < min) { min = dist; index = i - 1; } last = current; } } return index; }
/** * Finds the index of the nearest segment on the given cell state for the * specified coordinate pair. */ public static int findNearestSegment(mxCellState state, double x, double y) { int index = -1; if (state.getAbsolutePointCount() > 0) { mxPoint last = state.getAbsolutePoint(0); double min = Double.MAX_VALUE; for (int i = 1; i < state.getAbsolutePointCount(); i++) { mxPoint current = state.getAbsolutePoint(i); double dist = new Line2D.Double(last.x, last.y, current.x, current.y).ptSegDistSq(x, y); if (dist < min) { min = dist; index = i - 1; } last = current; } } return index; }
/** * */ public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Stroke stroke = g2.getStroke(); g2.setStroke(getSelectionStroke()); g.setColor(getSelectionColor()); Point last = state.getAbsolutePoint(0).getPoint(); for (int i = 1; i < state.getAbsolutePointCount(); i++) { Point current = state.getAbsolutePoint(i).getPoint(); Line2D line = new Line2D.Float(last.x, last.y, current.x, current.y); Rectangle bounds = g2.getStroke().createStrokedShape(line) .getBounds(); if (g.hitClip(bounds.x, bounds.y, bounds.width, bounds.height)) { g2.draw(line); } last = current; } g2.setStroke(stroke); super.paint(g); }
/** * Paints the outline of the markedState with the currentColor. */ public void paint(Graphics g) { if (markedState != null && currentColor != null) { ((Graphics2D) g).setStroke(DEFAULT_STROKE); g.setColor(currentColor); if (markedState.getAbsolutePointCount() > 0) { Point last = markedState.getAbsolutePoint(0).getPoint(); for (int i = 1; i < markedState.getAbsolutePointCount(); i++) { Point current = markedState.getAbsolutePoint(i).getPoint(); g.drawLine(last.x - getX(), last.y - getY(), current.x - getX(), current.y - getY()); last = current; } } else { g.drawRect(1, 1, getWidth() - 3, getHeight() - 3); } } }
/** * */ public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Stroke stroke = g2.getStroke(); g2.setStroke(getSelectionStroke()); g.setColor(getSelectionColor()); Point last = state.getAbsolutePoint(0).getPoint(); for (int i = 1; i < state.getAbsolutePointCount(); i++) { Point current = state.getAbsolutePoint(i).getPoint(); Line2D line = new Line2D.Float(last.x, last.y, current.x, current.y); Rectangle bounds = g2.getStroke().createStrokedShape(line) .getBounds(); if (g.hitClip(bounds.x, bounds.y, bounds.width, bounds.height)) { g2.draw(line); } last = current; } g2.setStroke(stroke); super.paint(g); }
/** * Paints the outline of the markedState with the currentColor. */ public void paint(Graphics g) { if (markedState != null && currentColor != null) { ((Graphics2D) g).setStroke(DEFAULT_STROKE); g.setColor(currentColor); if (markedState.getAbsolutePointCount() > 0) { Point last = markedState.getAbsolutePoint(0).getPoint(); for (int i = 1; i < markedState.getAbsolutePointCount(); i++) { Point current = markedState.getAbsolutePoint(i).getPoint(); g.drawLine(last.x - getX(), last.y - getY(), current.x - getX(), current.y - getY()); last = current; } } else { g.drawRect(1, 1, getWidth() - 3, getHeight() - 3); } } }
pts.add(edge.getAbsolutePoint(edge.getAbsolutePointCount() - 1)); edge.setAbsolutePoints(pts);
pts.add(edge.getAbsolutePoint(edge.getAbsolutePointCount() - 1)); edge.setAbsolutePoints(pts);
/** * Updates the terminal points in the given state after the edge style was * computed for the edge. * * @param state * Cell state whose terminal points should be updated. * @param source * Cell state that represents the source terminal. * @param target * Cell state that represents the target terminal. */ public void updateFloatingTerminalPoints(mxCellState state, mxCellState source, mxCellState target) { mxPoint p0 = state.getAbsolutePoint(0); mxPoint pe = state.getAbsolutePoint(state.getAbsolutePointCount() - 1); if (pe == null && target != null) { updateFloatingTerminalPoint(state, target, source, false); } if (p0 == null && source != null) { updateFloatingTerminalPoint(state, source, target, true); } }
/** * Updates the terminal points in the given state after the edge style was * computed for the edge. * * @param state * Cell state whose terminal points should be updated. * @param source * Cell state that represents the source terminal. * @param target * Cell state that represents the target terminal. */ public void updateFloatingTerminalPoints(mxCellState state, mxCellState source, mxCellState target) { mxPoint p0 = state.getAbsolutePoint(0); mxPoint pe = state.getAbsolutePoint(state.getAbsolutePointCount() - 1); if (pe == null && target != null) { updateFloatingTerminalPoint(state, target, source, false); } if (p0 == null && source != null) { updateFloatingTerminalPoint(state, source, target, true); } }
if (state.getAbsolutePointCount() > 1 && configureGraphics(canvas, state, false))
if (state.getAbsolutePointCount() > 1 && configureGraphics(canvas, state, false))
if (state.getAbsolutePointCount() > 1 && configureGraphics(canvas, state, false))
/** * Returns the Euclidean length of the edge defined by the absolute * points in the given state or 0 if no points are defined. */ public double getCost(mxCellState state) { double cost = 0; int pointCount = state.getAbsolutePointCount(); if (pointCount > 0) { mxPoint last = state.getAbsolutePoint(0); for (int i = 1; i < pointCount; i++) { mxPoint point = state.getAbsolutePoint(i); cost += point.getPoint().distance(last.getPoint()); last = point; } } return cost; } }
/** * Returns the Euclidean length of the edge defined by the absolute * points in the given state or 0 if no points are defined. */ public double getCost(mxCellState state) { double cost = 0; int pointCount = state.getAbsolutePointCount(); if (pointCount > 0) { mxPoint last = state.getAbsolutePoint(0); for (int i = 1; i < pointCount; i++) { mxPoint point = state.getAbsolutePoint(i); cost += point.getPoint().distance(last.getPoint()); last = point; } } return cost; } }
mxPoint pe = state.getAbsolutePoint(state.getAbsolutePointCount() - 1);
mxPoint pe = state.getAbsolutePoint(state.getAbsolutePointCount() - 1);
&& (state.getAbsolutePointCount() < 2 || state.getAbsolutePoint(0) == null || state .getAbsolutePoint(state.getAbsolutePointCount() - 1) == null))