@Override public JGraphXAdapter getGraph() { return ( JGraphXAdapter ) super.getGraph(); }
mxGraphComponent graphComponent = new mxGraphComponent(jgxAdapter); mxGraphModel graphModel = (mxGraphModel)graphComponent.getGraph().getModel(); Collection<Object> cells = graphModel.getCells().values(); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells.toArray(), mxConstants.STYLE_ENDARROW, mxConstants.NONE); //instead of getContentPane().add(new mxGraphComponent(jgxAdapter)); getContentPane().add(graphComponent);
/** * */ protected void removeCells(mxGraphComponent graphComponent, Object[] cells) { graphComponent.getGraph().removeCells(cells); }
/** * */ public boolean isEnabled() { return graphComponent.getGraph().isDropEnabled(); }
/** * */ public boolean isValidSource(Object cell) { return graphComponent.getGraph().isValidSource(cell); }
/** * */ protected boolean isCellBendable() { return graphComponent.getGraph().isCellBendable(state.getCell()); }
/** * Returns the error message or an empty string if the connection for the * given source target pair is not valid. Otherwise it returns null. */ public String validateConnection(Object source, Object target) { return graphComponent.getGraph().getEdgeValidationError( state.getCell(), source, target); }
/** * */ public Object[] getCells(Object initialCell) { mxGraph graph = graphComponent.getGraph(); return graph.getMovableCells(graph.getSelectionCells()); }
/** * */ public mxGraphTransferable createGraphTransferable( mxGraphComponent graphComponent, Object[] cells, mxRectangle bounds, ImageIcon icon) { return new mxGraphTransferable(graphComponent.getGraph().cloneCells( cells), bounds, icon); }
/** * */ protected mxRectangle getPlaceholderBounds(mxCellState startState) { mxGraph graph = graphComponent.getGraph(); return graph.getView().getBounds(graph.getSelectionCells()); }
/** * Returns true if the label is movable. */ public boolean isLabelMovable() { mxGraph graph = graphComponent.getGraph(); String label = graph.getLabel(state.getCell()); return graph.isLabelMovable(state.getCell()) && label != null && label.length() > 0; }
/** * */ public boolean isStateHandled(mxCellState state) { return graphComponent.getGraph().getModel().isVertex(state.getCell()); }
/** * */ protected mxRectangle getPlaceholderBounds(mxCellState startState) { mxGraph graph = graphComponent.getGraph(); return graph.getView().getBounds(graph.getSelectionCells()); }
/** * Uses getCell, getMarkedState and intersects to return the state for * the given event. */ protected mxCellState getState(MouseEvent e) { Object cell = getCell(e); mxGraphView view = graphComponent.getGraph().getView(); mxCellState state = getStateToMark(view.getState(cell)); return (state != null && intersects(state, e)) ? state : null; }
/** * Uses getCell, getMarkedState and intersects to return the state for * the given event. */ protected mxCellState getState(MouseEvent e) { Object cell = getCell(e); mxGraphView view = graphComponent.getGraph().getView(); mxCellState state = getStateToMark(view.getState(cell)); return (state != null && intersects(state, e)) ? state : null; }
protected Object getCell(MouseEvent e) { mxGraph graph = graphComponent.getGraph(); mxIGraphModel model = graph.getModel(); Object cell = super.getCell(e); if (cell == mxEdgeHandler.this.state.getCell() || (!graph.isConnectableEdges() && model.isEdge(cell))) { cell = null; } return cell; }
/** * */ protected mxPoint transformScreenPoint(double x, double y) { mxGraph graph = graphComponent.getGraph(); mxPoint tr = graph.getView().getTranslate(); double scale = graph.getView().getScale(); return new mxPoint(graph.snap(x / scale - tr.getX()), graph.snap(y / scale - tr.getY())); }