private final void setCellGeometry( final mxICell cell, final int row, final int targetColumn ) { final double x = ( targetColumn ) * X_COLUMN_SIZE - DEFAULT_CELL_WIDTH / 2; final double y = ( 0.5 + row ) * Y_COLUMN_SIZE - DEFAULT_CELL_HEIGHT / 2; final mxGeometry geometry = cell.getGeometry(); geometry.setX( x ); geometry.setY( y ); }
private final void setCellGeometry( final mxICell cell, final int row, final int targetColumn ) { final double x = ( targetColumn ) * X_COLUMN_SIZE - DEFAULT_CELL_WIDTH / 2; final double y = ( 0.5 + row ) * Y_COLUMN_SIZE - DEFAULT_CELL_HEIGHT / 2; final mxGeometry geometry = cell.getGeometry(); geometry.setX( x ); geometry.setY( y ); }
/** * Sets the physical spacing between vertices in a path graph. This works for now only for a graph generated with mxGraphCreator.getPathGraph() * only after creating the graph * @param aGraph * @param spacing */ public void setPathGraphSpacing(mxAnalysisGraph aGraph, double spacing) { if (spacing < 0) { throw new IllegalArgumentException(); } mxGraph graph = aGraph.getGraph(); Object parent = graph.getDefaultParent(); Object[] vertices = aGraph.getChildVertices(parent); mxIGraphModel model = graph.getModel(); for (int i = 0; i < vertices.length; i++) { Object currVertex = vertices[i]; mxGeometry geometry = model.getGeometry(currVertex); geometry.setX(0); geometry.setY(i * spacing); } };
/** * Sets the physical spacing between vertices in a path graph. This works for now only for a graph generated with mxGraphCreator.getPathGraph() * only after creating the graph * @param aGraph * @param spacing */ public void setPathGraphSpacing(mxAnalysisGraph aGraph, double spacing) { if (spacing < 0) { throw new IllegalArgumentException(); } mxGraph graph = aGraph.getGraph(); Object parent = graph.getDefaultParent(); Object[] vertices = aGraph.getChildVertices(parent); mxIGraphModel model = graph.getModel(); for (int i = 0; i < vertices.length; i++) { Object currVertex = vertices[i]; mxGeometry geometry = model.getGeometry(currVertex); geometry.setX(0); geometry.setY(i * spacing); } };
/** * Sets the physical spacing between vertices in a grid graph. This works for now only for a graph generated with mxGraphCreator.getGridGraph() only after creating the graph * @param aGraph * @param xSpacing - horizontal spacing between vertices * @param ySpacing - vertical spacing between vertices * @param numRows - number of rows in the grid graph * @param numColumns - number of columns in the grid graph */ public void setGridGraphSpacing(mxAnalysisGraph aGraph, double xSpacing, double ySpacing, int numColumns, int numRows) { mxGraph graph = aGraph.getGraph(); if (xSpacing < 0 || ySpacing < 0 || numColumns < 1 || numRows < 1) { throw new IllegalArgumentException(); } Object parent = graph.getDefaultParent(); Object[] vertices = aGraph.getChildVertices(parent); mxIGraphModel model = graph.getModel(); for (int i = 0; i < numRows; i++) { for (int j = 0; j < numColumns; j++) { Object currVertex = vertices[i * numColumns + j]; mxGeometry geometry = model.getGeometry(currVertex); geometry.setX(j * xSpacing); geometry.setY(i * ySpacing); } } };
/** * Sets the physical spacing between vertices in a grid graph. This works for now only for a graph generated with mxGraphCreator.getGridGraph() only after creating the graph * @param aGraph * @param xSpacing - horizontal spacing between vertices * @param ySpacing - vertical spacing between vertices * @param numRows - number of rows in the grid graph * @param numColumns - number of columns in the grid graph */ public void setGridGraphSpacing(mxAnalysisGraph aGraph, double xSpacing, double ySpacing, int numColumns, int numRows) { mxGraph graph = aGraph.getGraph(); if (xSpacing < 0 || ySpacing < 0 || numColumns < 1 || numRows < 1) { throw new IllegalArgumentException(); } Object parent = graph.getDefaultParent(); Object[] vertices = aGraph.getChildVertices(parent); mxIGraphModel model = graph.getModel(); for (int i = 0; i < numRows; i++) { for (int j = 0; j < numColumns; j++) { Object currVertex = vertices[i * numColumns + j]; mxGeometry geometry = model.getGeometry(currVertex); geometry.setX(j * xSpacing); geometry.setY(i * ySpacing); } } };
clone.setY(getY()); clone.setWidth(getWidth()); clone.setHeight(getHeight());
clone.setY(getY()); clone.setWidth(getWidth()); clone.setHeight(getHeight());
/** * */ public Object createTargetVertex(MouseEvent e, Object source) { mxGraph graph = graphComponent.getGraph(); Object clone = graph.cloneCells(new Object[] { source })[0]; mxIGraphModel model = graph.getModel(); mxGeometry geo = model.getGeometry(clone); if (geo != null) { mxPoint point = graphComponent.getPointForEvent(e); geo.setX(graph.snap(point.getX() - geo.getWidth() / 2)); geo.setY(graph.snap(point.getY() - geo.getHeight() / 2)); } return clone; }
/** * */ public Object createTargetVertex(MouseEvent e, Object source) { mxGraph graph = graphComponent.getGraph(); Object clone = graph.cloneCells(new Object[] { source })[0]; mxIGraphModel model = graph.getModel(); mxGeometry geo = model.getGeometry(clone); if (geo != null) { mxPoint point = graphComponent.getPointForEvent(e); geo.setX(graph.snap(point.getX() - geo.getWidth() / 2)); geo.setY(graph.snap(point.getY() - geo.getHeight() / 2)); } return clone; }
geo.setY(Math.max(0, geo.getY()));
/** * Moves the label to the given position. */ protected void moveLabelTo(mxCellState edgeState, double x, double y) { mxGraph graph = graphComponent.getGraph(); mxIGraphModel model = graph.getModel(); mxGeometry geometry = model.getGeometry(state.getCell()); if (geometry != null) { geometry = (mxGeometry) geometry.clone(); // Resets the relative location stored inside the geometry mxPoint pt = graph.getView().getRelativePoint(edgeState, x, y); geometry.setX(pt.getX()); geometry.setY(pt.getY()); // Resets the offset inside the geometry to find the offset // from the resulting point double scale = graph.getView().getScale(); geometry.setOffset(new mxPoint(0, 0)); pt = graph.getView().getPoint(edgeState, geometry); geometry.setOffset(new mxPoint(Math.round((x - pt.getX()) / scale), Math.round((y - pt.getY()) / scale))); model.setGeometry(edgeState.getCell(), geometry); } }
/** * Moves the label to the given position. */ protected void moveLabelTo(mxCellState edgeState, double x, double y) { mxGraph graph = graphComponent.getGraph(); mxIGraphModel model = graph.getModel(); mxGeometry geometry = model.getGeometry(state.getCell()); if (geometry != null) { geometry = (mxGeometry) geometry.clone(); // Resets the relative location stored inside the geometry mxPoint pt = graph.getView().getRelativePoint(edgeState, x, y); geometry.setX(pt.getX()); geometry.setY(pt.getY()); // Resets the offset inside the geometry to find the offset // from the resulting point double scale = graph.getView().getScale(); geometry.setOffset(new mxPoint(0, 0)); pt = graph.getView().getPoint(edgeState, geometry); geometry.setOffset(new mxPoint(Math.round((x - pt.getX()) / scale), Math.round((y - pt.getY()) / scale))); model.setGeometry(edgeState.getCell(), geometry); } }
geo.setY(Math.max(0, geo.getY()));
geometry.setY(geometry.getY() + bounds.getY() - border - top); geometry.setWidth(bounds.getWidth() + 2 * border + left); geometry.setHeight(bounds.getHeight() + 2 * border + top);
geometry.setY(y);