/** * 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; }
/** * 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; }
/** * Returns the vector between the current rendered state and the future * location of the state after the display will be updated. */ protected mxPoint getDelta(mxCellState state) { mxGraph graph = graphComponent.getGraph(); mxPoint origin = getOriginForCell(state.getCell()); mxPoint translate = graph.getView().getTranslate(); double scale = graph.getView().getScale(); mxPoint current = new mxPoint(state.getX() / scale - translate.getX(), state.getY() / scale - translate.getY()); return new mxPoint((origin.getX() - current.getX()) * scale, (origin .getY() - current.getY()) * scale); }
/** * Returns the vector between the current rendered state and the future * location of the state after the display will be updated. */ protected mxPoint getDelta(mxCellState state) { mxGraph graph = graphComponent.getGraph(); mxPoint origin = getOriginForCell(state.getCell()); mxPoint translate = graph.getView().getTranslate(); double scale = graph.getView().getScale(); mxPoint current = new mxPoint(state.getX() / scale - translate.getX(), state.getY() / scale - translate.getY()); return new mxPoint((origin.getX() - current.getX()) * scale, (origin .getY() - current.getY()) * scale); }