/** * */ protected Rectangle[] createHandles() { p = createPoints(state); Rectangle[] h = new Rectangle[p.length + 1]; for (int i = 0; i < h.length - 1; i++) { h[i] = createHandle(p[i]); } h[p.length] = createHandle(state.getAbsoluteOffset().getPoint(), mxConstants.LABEL_HANDLE_SIZE); return h; }
/** * Returns true if the current index is the last index. */ public boolean isTarget(int index) { return index == getHandleCount() - 2; }
/** * Hides the middle handle if the edge is not bendable. */ protected boolean isHandleVisible(int index) { return super.isHandleVisible(index) && (isSource(index) || isTarget(index) || isCellBendable()); }
else if (isLabel(index)) moveLabelTo(state, pt.getX() + dx, pt.getY() + dy); && (isSource(index) || isTarget(index))) connect(state.getCell(), marker.getValidState().getCell(), isSource(index), graphComponent.isCloneEvent(e) && isCloneEnabled()); else if ((!isSource(index) && !isTarget(index)) || graphComponent.getGraph().isAllowDanglingEdges()) movePoint( state.getCell(), index, convertPoint(new mxPoint(e.getPoint()), gridEnabledEvent)); if (!e.isConsumed() && isFlipEvent(e))
constrainedEvent = graphComponent.isConstrainedEvent(e); boolean isSource = isSource(index); boolean isTarget = isTarget(index); if (isLabel(index)) Rectangle rect = getPreviewBounds(); rect.translate((int) Math.round(pt.getX() - first.x), (int) Math.round(pt.getY() - first.y)); mxPoint point = convertPoint(new mxPoint(e.getPoint()), gridEnabledEvent); p = createPoints(clone); preview.setBounds(getPreviewBounds());
/** * */ 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); }
/** * */ protected Rectangle createHandle(Point center) { return createHandle(center, mxConstants.HANDLE_SIZE); }
/** * * @param state * Cell state for which a handler should be created. * @return Returns the handler to be used for the given cell state. */ public mxCellHandler createHandler(mxCellState state) { if (graph.getModel().isVertex(state.getCell())) { return new mxVertexHandler(this, state); } else if (graph.getModel().isEdge(state.getCell())) { mxEdgeStyleFunction style = graph.getView().getEdgeStyle(state, null, null, null); if (graph.isLoop(state) || style == mxEdgeStyle.ElbowConnector || style == mxEdgeStyle.SideToSide || style == mxEdgeStyle.TopToBottom) { return new mxElbowEdgeHandler(this, state); } return new mxEdgeHandler(this, state); } return new mxCellHandler(this, state); }
else if (isLabel(index)) moveLabelTo(state, pt.getX() + dx, pt.getY() + dy); && (isSource(index) || isTarget(index))) connect(state.getCell(), marker.getValidState().getCell(), isSource(index), graphComponent.isCloneEvent(e) && isCloneEnabled()); else if ((!isSource(index) && !isTarget(index)) || graphComponent.getGraph().isAllowDanglingEdges()) movePoint( state.getCell(), index, convertPoint(new mxPoint(e.getPoint()), gridEnabledEvent)); if (!e.isConsumed() && isFlipEvent(e))
constrainedEvent = graphComponent.isConstrainedEvent(e); boolean isSource = isSource(index); boolean isTarget = isTarget(index); if (isLabel(index)) Rectangle rect = getPreviewBounds(); rect.translate((int) Math.round(pt.getX() - first.x), (int) Math.round(pt.getY() - first.y)); mxPoint point = convertPoint(new mxPoint(e.getPoint()), gridEnabledEvent); p = createPoints(clone); preview.setBounds(getPreviewBounds());
/** * */ 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); }
/** * */ protected Rectangle createHandle(Point center) { return createHandle(center, mxConstants.HANDLE_SIZE); }
/** * * @param state * Cell state for which a handler should be created. * @return Returns the handler to be used for the given cell state. */ public mxCellHandler createHandler(mxCellState state) { if (graph.getModel().isVertex(state.getCell())) { return new mxVertexHandler(this, state); } else if (graph.getModel().isEdge(state.getCell())) { mxEdgeStyleFunction style = graph.getView().getEdgeStyle(state, null, null, null); if (graph.isLoop(state) || style == mxEdgeStyle.ElbowConnector || style == mxEdgeStyle.SideToSide || style == mxEdgeStyle.TopToBottom) { return new mxElbowEdgeHandler(this, state); } return new mxEdgeHandler(this, state); } return new mxCellHandler(this, state); }
/** * Hides the middle handle if the edge is not bendable. */ protected boolean isHandleVisible(int index) { return super.isHandleVisible(index) && (isSource(index) || isTarget(index) || isCellBendable()); }
/** * */ protected Rectangle[] createHandles() { p = createPoints(state); Rectangle[] h = new Rectangle[p.length + 1]; for (int i = 0; i < h.length - 1; i++) { h[i] = createHandle(p[i]); } h[p.length] = createHandle(state.getAbsoluteOffset().getPoint(), mxConstants.LABEL_HANDLE_SIZE); return h; }
/** * Returns true if the current index is the last index. */ public boolean isTarget(int index) { return index == getHandleCount() - 2; }