y0 = g.getY();
public int compare(Object o1, Object o2) { if (o1 instanceof VLane || o2 instanceof VLane) { if (!(o1 instanceof VLane)) { return 1; } if (!(o2 instanceof VLane)) { return -1; } VLane v1 = (VLane) o1; VLane v2 = (VLane) o2; if (v1.getGeometry().getY() > v2.getGeometry().getY()) { return -1; } return 1; } return 0; } };
public class Parallelogram extends mxBasicShape { public Shape createShape(mxGraphics2DCanvas canvas, mxCellState state){ mxCell cell = (mxCell)state.getCell(); Polygon polygon = new Polygon(); if(cell != null && cell.getGeometry() != null) { mxGeometry g = cell.getGeometry(); int dx = (int) (cell.getGeometry().getHeight()/4.0); polygon.addPoint((int)(g.getX()+dx), (int)g.getY()); polygon.addPoint((int)(g.getX()+g.getWidth()+dx), (int)g.getY()); polygon.addPoint((int)(g.getX()+g.getWidth()-dx), (int)(g.getY()+g.getHeight())); polygon.addPoint((int)((int)g.getX()-dx), (int)(g.getY()+g.getHeight())); } return polygon; }
/** * Resizes the parents recursively so that they contain the complete area * of the resized child cell. * * @param cell <mxCell> that has been resized. */ public void extendParent(Object cell) { if (cell != null) { Object parent = model.getParent(cell); mxGeometry p = model.getGeometry(parent); if (parent != null && p != null && !isCellCollapsed(parent)) { mxGeometry geo = model.getGeometry(cell); if (geo != null && (p.getWidth() < geo.getX() + geo.getWidth() || p .getHeight() < geo.getY() + geo.getHeight())) { p = (mxGeometry) p.clone(); p.setWidth(Math.max(p.getWidth(), geo.getX() + geo.getWidth())); p.setHeight(Math.max(p.getHeight(), geo.getY() + geo.getHeight())); cellsResized(new Object[] { parent }, new mxRectangle[] { p }); } } } }
/** * Resizes the parents recursively so that they contain the complete area * of the resized child cell. * * @param cell <mxCell> that has been resized. */ public void extendParent(Object cell) { if (cell != null) { Object parent = model.getParent(cell); mxGeometry p = model.getGeometry(parent); if (parent != null && p != null && !isCellCollapsed(parent)) { mxGeometry geo = model.getGeometry(cell); if (geo != null && (p.getWidth() < geo.getX() + geo.getWidth() || p .getHeight() < geo.getY() + geo.getHeight())) { p = (mxGeometry) p.clone(); p.setWidth(Math.max(p.getWidth(), geo.getX() + geo.getWidth())); p.setHeight(Math.max(p.getHeight(), geo.getY() + geo.getHeight())); cellsResized(new Object[] { parent }, new mxRectangle[] { p }); } } } }
/** * Swaps the x, y, width and height with the values stored in * alternateBounds and puts the previous values into alternateBounds as * a rectangle. This operation is carried-out in-place, that is, using the * existing geometry instance. If this operation is called during a graph * model transactional change, then the geometry should be cloned before * calling this method and setting the geometry of the cell using * mxGraphModel.setGeometry. */ public void swap() { if (alternateBounds != null) { mxRectangle old = new mxRectangle(getX(), getY(), getWidth(), getHeight()); x = alternateBounds.getX(); y = alternateBounds.getY(); width = alternateBounds.getWidth(); height = alternateBounds.getHeight(); alternateBounds = old; } }
/** * Swaps the x, y, width and height with the values stored in * alternateBounds and puts the previous values into alternateBounds as * a rectangle. This operation is carried-out in-place, that is, using the * existing geometry instance. If this operation is called during a graph * model transactional change, then the geometry should be cloned before * calling this method and setting the geometry of the cell using * mxGraphModel.setGeometry. */ public void swap() { if (alternateBounds != null) { mxRectangle old = new mxRectangle(getX(), getY(), getWidth(), getHeight()); x = alternateBounds.getX(); y = alternateBounds.getY(); width = alternateBounds.getWidth(); height = alternateBounds.getHeight(); alternateBounds = old; } }
/** * Returns the top, left corner of the given cell. */ protected mxPoint getOriginForCell(Object cell) { mxPoint result = origins.get(cell); if (result == null) { mxGraph graph = graphComponent.getGraph(); if (cell != null) { result = new mxPoint(getOriginForCell(graph.getModel() .getParent(cell))); mxGeometry geo = graph.getCellGeometry(cell); // TODO: Handle offset, relative geometries etc if (geo != null) { result.setX(result.getX() + geo.getX()); result.setY(result.getY() + geo.getY()); } } if (result == null) { mxPoint t = graph.getView().getTranslate(); result = new mxPoint(-t.getX(), -t.getY()); } origins.put(cell, result); } return result; }
clone.setY(getY()); clone.setWidth(getWidth()); clone.setHeight(getHeight());
/** * Returns the top, left corner of the given cell. */ protected mxPoint getOriginForCell(Object cell) { mxPoint result = origins.get(cell); if (result == null) { mxGraph graph = graphComponent.getGraph(); if (cell != null) { result = new mxPoint(getOriginForCell(graph.getModel() .getParent(cell))); mxGeometry geo = graph.getCellGeometry(cell); // TODO: Handle offset, relative geometries etc if (geo != null) { result.setX(result.getX() + geo.getX()); result.setY(result.getY() + geo.getY()); } } if (result == null) { mxPoint t = graph.getView().getTranslate(); result = new mxPoint(-t.getX(), -t.getY()); } origins.put(cell, result); } return result; }
public mxPoint getParentOffset(Object parent) { mxPoint result = new mxPoint(); if (parent != null && parent != this.parent) { mxIGraphModel model = graph.getModel(); if (model.isAncestor(this.parent, parent)) { mxGeometry parentGeo = model.getGeometry(parent); while (parent != this.parent) { result.setX(result.getX() + parentGeo.getX()); result.setY(result.getY() + parentGeo.getY()); parent = model.getParent(parent);; parentGeo = model.getGeometry(parent); } } } return result; }
public mxPoint getParentOffset(Object parent) { mxPoint result = new mxPoint(); if (parent != null && parent != this.parent) { mxIGraphModel model = graph.getModel(); if (model.isAncestor(this.parent, parent)) { mxGeometry parentGeo = model.getGeometry(parent); while (parent != this.parent) { result.setX(result.getX() + parentGeo.getX()); result.setY(result.getY() + parentGeo.getY()); parent = model.getParent(parent);; parentGeo = model.getGeometry(parent); } } } return result; }
/** * Returns the absolute, accumulated origin for the children inside the * given parent. */ public mxPoint getOrigin(Object cell) { mxPoint result = null; if (cell != null) { result = getOrigin(getParent(cell)); if (!isEdge(cell)) { mxGeometry geo = getGeometry(cell); if (geo != null) { result.setX(result.getX() + geo.getX()); result.setY(result.getY() + geo.getY()); } } } else { result = new mxPoint(); } return result; }
/** * Returns the absolute, accumulated origin for the children inside the * given parent. */ public mxPoint getOrigin(Object cell) { mxPoint result = null; if (cell != null) { result = getOrigin(getParent(cell)); if (!isEdge(cell)) { mxGeometry geo = getGeometry(cell); if (geo != null) { result.setX(result.getX() + geo.getX()); result.setY(result.getY() + geo.getY()); } } } else { result = new mxPoint(); } return result; }
geo.setY(Math.max(0, geo.getY()));
geo.setY(Math.max(0, geo.getY()));
+ bounds.getWidth() / 2 : bounds.getY() + bounds.getHeight() / 2;
+ bounds.getWidth() / 2 : bounds.getY() + bounds.getHeight() / 2;