/** * Returns the value for key in dictionary as a double or 0 if no value is * defined for the key. * * @param dict * Dictionary that contains the key, value pairs. * @param key * Key whose value should be returned. * @return Returns the double value for key in dict. */ public static double getDouble(Map<String, Object> dict, String key) { return getDouble(dict, key, 0); }
/** * Returns the value for key in dictionary as a double or 0 if no value is * defined for the key. * * @param dict * Dictionary that contains the key, value pairs. * @param key * Key whose value should be returned. * @return Returns the double value for key in dict. */ public static double getDouble(Map<String, Object> dict, String key) { return getDouble(dict, key, 0); }
/** * Helper method to configure the given wrapper canvas. */ protected int getArcSize(mxCellState state, double w, double h) { double f = mxUtils.getDouble(state.getStyle(), mxConstants.STYLE_ARCSIZE, mxConstants.RECTANGLE_ROUNDING_FACTOR * 100) / 100; return (int) (Math.min(w, h) * f * 2); }
/** * Helper method to configure the given wrapper canvas. */ protected double getArcSize(mxCellState state, double start) { double f = mxUtils.getDouble(state.getStyle(), mxConstants.STYLE_ARCSIZE, mxConstants.RECTANGLE_ROUNDING_FACTOR * 100) / 100; return start * f * 3; }
/** * Helper method to configure the given wrapper canvas. */ protected double getArcSize(mxCellState state, double start) { double f = mxUtils.getDouble(state.getStyle(), mxConstants.STYLE_ARCSIZE, mxConstants.RECTANGLE_ROUNDING_FACTOR * 100) / 100; return start * f * 3; }
/** * Returns the width for wrapping the label of the given state at scale 1. */ public double getWordWrapWidth(mxCellState state) { Map<String, Object> style = state.getStyle(); boolean horizontal = mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL, true); double w = 0; // Computes the available width for the wrapped label if (horizontal) { w = (state.getWidth() / scale) - 2 * mxConstants.LABEL_INSET - 2 * mxUtils.getDouble(style, mxConstants.STYLE_SPACING) - mxUtils.getDouble(style, mxConstants.STYLE_SPACING_LEFT) - mxUtils.getDouble(style, mxConstants.STYLE_SPACING_RIGHT); } else { w = (state.getHeight() / scale) - 2 * mxConstants.LABEL_INSET - 2 * mxUtils.getDouble(style, mxConstants.STYLE_SPACING) - mxUtils.getDouble(style, mxConstants.STYLE_SPACING_TOP) + mxUtils .getDouble(style, mxConstants.STYLE_SPACING_BOTTOM); } return w; }
/** * Returns the width for wrapping the label of the given state at scale 1. */ public double getWordWrapWidth(mxCellState state) { Map<String, Object> style = state.getStyle(); boolean horizontal = mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL, true); double w = 0; // Computes the available width for the wrapped label if (horizontal) { w = (state.getWidth() / scale) - 2 * mxConstants.LABEL_INSET - 2 * mxUtils.getDouble(style, mxConstants.STYLE_SPACING) - mxUtils.getDouble(style, mxConstants.STYLE_SPACING_LEFT) - mxUtils.getDouble(style, mxConstants.STYLE_SPACING_RIGHT); } else { w = (state.getHeight() / scale) - 2 * mxConstants.LABEL_INSET - 2 * mxUtils.getDouble(style, mxConstants.STYLE_SPACING) - mxUtils.getDouble(style, mxConstants.STYLE_SPACING_TOP) + mxUtils .getDouble(style, mxConstants.STYLE_SPACING_BOTTOM); } return w; }
/** * Returns the perimeter bounds for the given terminal, edge pair. */ public mxRectangle getPerimeterBounds(mxCellState terminal, double border) { if (terminal != null) { border += mxUtils.getDouble(terminal.getStyle(), mxConstants.STYLE_PERIMETER_SPACING); } return terminal.getPerimeterBounds(border * scale); }
/** * Returns the perimeter bounds for the given terminal, edge pair. */ public mxRectangle getPerimeterBounds(mxCellState terminal, double border) { if (terminal != null) { border += mxUtils.getDouble(terminal.getStyle(), mxConstants.STYLE_PERIMETER_SPACING); } return terminal.getPerimeterBounds(border * scale); }
/** * */ public Graphics2D createTemporaryGraphics(Map<String, Object> style, float opacity, mxRectangle bounds) { Graphics2D temporaryGraphics = (Graphics2D) g.create(); // Applies the default translate temporaryGraphics.translate(translate.x, translate.y); // Applies the rotation on the graphics object if (bounds != null) { double rotation = mxUtils.getDouble(style, mxConstants.STYLE_ROTATION, 0); if (rotation != 0) { temporaryGraphics.rotate(Math.toRadians(rotation), bounds.getCenterX(), bounds.getCenterY()); } } // Applies the opacity to the graphics object if (opacity != 100) { temporaryGraphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, opacity / 100)); } return temporaryGraphics; }
/** * */ public Graphics2D createTemporaryGraphics(Map<String, Object> style, float opacity, mxRectangle bounds) { Graphics2D temporaryGraphics = (Graphics2D) g.create(); // Applies the default translate temporaryGraphics.translate(translate.getX(), translate.getY()); // Applies the rotation on the graphics object if (bounds != null) { double rotation = mxUtils.getDouble(style, mxConstants.STYLE_ROTATION, 0); if (rotation != 0) { temporaryGraphics.rotate(Math.toRadians(rotation), bounds.getCenterX(), bounds.getCenterY()); } } // Applies the opacity to the graphics object if (opacity != 100) { temporaryGraphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, opacity / 100)); } return temporaryGraphics; }
/** * */ public void start(MouseEvent e) { initialAngle = mxUtils.getDouble(currentState.getStyle(), mxConstants.STYLE_ROTATION) * mxConstants.RAD_PER_DEG; currentAngle = initialAngle; first = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), graphComponent.getGraphControl()); if (!graphComponent.getGraph().isCellSelected(currentState.getCell())) { graphComponent.selectCellForEvent(currentState.getCell(), e); } }
/** * */ public void start(MouseEvent e) { initialAngle = mxUtils.getDouble(currentState.getStyle(), mxConstants.STYLE_ROTATION) * mxConstants.RAD_PER_DEG; currentAngle = initialAngle; first = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), graphComponent.getGraphControl()); if (!graphComponent.getGraph().isCellSelected(currentState.getCell())) { graphComponent.selectCellForEvent(currentState.getCell(), e); } }
/** * Updates the absolute terminal point in the given state for the given * start and end state, where start is the source if source is true. * * @param edge * Cell state whose terminal point should be updated. * @param start * Cell state for the terminal on "this" side of the edge. * @param end * Cell state for the terminal on the other side of the edge. * @param source * Boolean indicating if start is the source terminal state. */ public void updateFloatingTerminalPoint(mxCellState edge, mxCellState start, mxCellState end, boolean source) { start = getTerminalPort(edge, start, source); mxPoint next = getNextPoint(edge, end, source); double border = mxUtils.getDouble(edge.getStyle(), mxConstants.STYLE_PERIMETER_SPACING); border += mxUtils.getDouble(edge.getStyle(), (source) ? mxConstants.STYLE_SOURCE_PERIMETER_SPACING : mxConstants.STYLE_TARGET_PERIMETER_SPACING); mxPoint pt = getPerimeterPoint(start, next, graph.isOrthogonal(edge), border); edge.setAbsoluteTerminalPoint(pt, source); }
mxRectangle aspect = computeAspect(state, bounds, direction); double minScale = Math.min(aspect.getWidth(), aspect.getHeight()); double sw = strokewidth.equals("inherit") ? mxUtils.getDouble( state.getStyle(), mxConstants.STYLE_STROKEWIDTH, 1)
/** * Updates the absolute terminal point in the given state for the given * start and end state, where start is the source if source is true. * * @param edge * Cell state whose terminal point should be updated. * @param start * Cell state for the terminal on "this" side of the edge. * @param end * Cell state for the terminal on the other side of the edge. * @param source * Boolean indicating if start is the source terminal state. */ public void updateFloatingTerminalPoint(mxCellState edge, mxCellState start, mxCellState end, boolean source) { start = getTerminalPort(edge, start, source); mxPoint next = getNextPoint(edge, end, source); double border = mxUtils.getDouble(edge.getStyle(), mxConstants.STYLE_PERIMETER_SPACING); border += mxUtils.getDouble(edge.getStyle(), (source) ? mxConstants.STYLE_SOURCE_PERIMETER_SPACING : mxConstants.STYLE_TARGET_PERIMETER_SPACING); mxPoint pt = getPerimeterPoint(start, next, graph.isOrthogonal(edge), border); edge.setAbsoluteTerminalPoint(pt, source); }
/** * Returns the start size of the given swimlane, that is, the width or * height of the part that contains the title, depending on the * horizontal style. The return value is an <mxRectangle> with either * width or height set as appropriate. * * @param swimlane <mxCell> whose start size should be returned. * @return Returns the startsize for the given swimlane. */ public mxRectangle getStartSize(Object swimlane) { mxRectangle result = new mxRectangle(); mxCellState state = view.getState(swimlane); Map<String, Object> style = (state != null) ? state.getStyle() : getCellStyle(swimlane); if (style != null) { double size = mxUtils.getDouble(style, mxConstants.STYLE_STARTSIZE, mxConstants.DEFAULT_STARTSIZE); if (mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL, true)) { result.setHeight(size); } else { result.setWidth(size); } } return result; }
/** * Returns the start size of the given swimlane, that is, the width or * height of the part that contains the title, depending on the * horizontal style. The return value is an <mxRectangle> with either * width or height set as appropriate. * * @param swimlane <mxCell> whose start size should be returned. * @return Returns the startsize for the given swimlane. */ public mxRectangle getStartSize(Object swimlane) { mxRectangle result = new mxRectangle(); mxCellState state = view.getState(swimlane); Map<String, Object> style = (state != null) ? state.getStyle() : getCellStyle(swimlane); if (style != null) { double size = mxUtils.getDouble(style, mxConstants.STYLE_STARTSIZE, mxConstants.DEFAULT_STARTSIZE); if (mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL, true)) { result.setHeight(size); } else { result.setWidth(size); } } return result; }