/** * Returns the value for key in dictionary as a float 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 float value for key in dict. */ public static float getFloat(Map<String, Object> dict, String key) { return getFloat(dict, key, 0); }
/** * */ public Stroke createStroke(Map<String, Object> style) { double width = mxUtils .getFloat(style, mxConstants.STYLE_STROKEWIDTH, 1) * scale; boolean dashed = mxUtils.isTrue(style, mxConstants.STYLE_DASHED); if (dashed) { float[] dashPattern = mxUtils.getFloatArray(style, mxConstants.STYLE_DASH_PATTERN, mxConstants.DEFAULT_DASHED_PATTERN, " "); float[] scaledDashPattern = new float[dashPattern.length]; for (int i = 0; i < dashPattern.length; i++) { scaledDashPattern[i] = (float) (dashPattern[i] * scale * width); } return new BasicStroke((float) width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, scaledDashPattern, 0.0f); } else { return new BasicStroke((float) width); } }
/** * Returns the value for key in dictionary as a float 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 float value for key in dict. */ public static float getFloat(Map<String, Object> dict, String key) { return getFloat(dict, key, 0); }
/** * */ public Stroke createStroke(Map<String, Object> style) { double width = mxUtils .getFloat(style, mxConstants.STYLE_STROKEWIDTH, 1) * scale; boolean dashed = mxUtils.isTrue(style, mxConstants.STYLE_DASHED); if (dashed) { float[] dashPattern = mxUtils.getFloatArray(style, mxConstants.STYLE_DASH_PATTERN, mxConstants.DEFAULT_DASHED_PATTERN, " "); float[] scaledDashPattern = new float[dashPattern.length]; for (int i = 0; i < dashPattern.length; i++) { scaledDashPattern[i] = (float) (dashPattern[i] * scale * width); } return new BasicStroke((float) width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, scaledDashPattern, 0.0f); } else { return new BasicStroke((float) width); } }
/** * Returns the bounding box for the gradient box for this shape. */ protected double getTitleSize(mxGraphics2DCanvas canvas, mxCellState state) { return Math.max( 0, mxUtils.getFloat(state.getStyle(), mxConstants.STYLE_STARTSIZE, mxConstants.DEFAULT_STARTSIZE) * canvas.getScale()); };
/** * Returns the bounding box for the gradient box for this shape. */ protected double getTitleSize(mxGraphics2DCanvas canvas, mxCellState state) { return Math.max( 0, mxUtils.getFloat(state.getStyle(), mxConstants.STYLE_STARTSIZE, mxConstants.DEFAULT_STARTSIZE) * canvas.getScale()); };
/** * */ public void paintShape(mxGraphics2DCanvas canvas, mxCellState state) { super.paintShape(canvas, state); int inset = (int) Math.round((mxUtils.getFloat(state.getStyle(), mxConstants.STYLE_STROKEWIDTH, 1) + 3) * canvas.getScale()); Rectangle rect = state.getRectangle(); int x = rect.x + inset; int y = rect.y + inset; int w = rect.width - 2 * inset; int h = rect.height - 2 * inset; canvas.getGraphics().drawOval(x, y, w, h); }
/** * */ public void paintShape(mxGraphics2DCanvas canvas, mxCellState state) { super.paintShape(canvas, state); int inset = (int) Math.round((mxUtils.getFloat(state.getStyle(), mxConstants.STYLE_STROKEWIDTH, 1) + 3) * canvas.getScale()); Rectangle rect = state.getRectangle(); int x = rect.x + inset; int y = rect.y + inset; int w = rect.width - 2 * inset; int h = rect.height - 2 * inset; canvas.getGraphics().drawOval(x, y, w, h); }
/** * */ public void paintShape(mxGraphics2DCanvas canvas, mxCellState state) { super.paintShape(canvas, state); int inset = (int) Math.round((mxUtils.getFloat(state.getStyle(), mxConstants.STYLE_STROKEWIDTH, 1) + 3) * canvas.getScale()); Rectangle rect = state.getRectangle(); int x = rect.x + inset; int y = rect.y + inset; int w = rect.width - 2 * inset; int h = rect.height - 2 * inset; canvas.getGraphics().drawRect(x, y, w, h); }
/** * */ public void paintShape(mxGraphics2DCanvas canvas, mxCellState state) { super.paintShape(canvas, state); int inset = (int) Math.round((mxUtils.getFloat(state.getStyle(), mxConstants.STYLE_STROKEWIDTH, 1) + 3) * canvas.getScale()); Rectangle rect = state.getRectangle(); int x = rect.x + inset; int y = rect.y + inset; int w = rect.width - 2 * inset; int h = rect.height - 2 * inset; canvas.getGraphics().drawRect(x, y, w, h); }
public Object drawCell(mxCellState state) { Map<String, Object> style = state.getStyle(); mxIShape shape = getShape(style); if (g != null && shape != null) { // Creates a temporary graphics instance for drawing this shape float opacity = mxUtils.getFloat(style, mxConstants.STYLE_OPACITY, 100); Graphics2D previousGraphics = g; g = createTemporaryGraphics(style, opacity, state); // Paints the shape and restores the graphics object shape.paintShape(this, state); g.dispose(); g = previousGraphics; } return shape; }
public Object drawCell(mxCellState state) { Map<String, Object> style = state.getStyle(); mxIShape shape = getShape(style); if (g != null && shape != null) { // Creates a temporary graphics instance for drawing this shape float opacity = mxUtils.getFloat(style, mxConstants.STYLE_OPACITY, 100); Graphics2D previousGraphics = g; g = createTemporaryGraphics(style, opacity, state); // Paints the shape and restores the graphics object shape.paintShape(this, state); g.dispose(); g = previousGraphics; } return shape; }
/** * Returns the x-coordinate of the center point for automatic routing. * * @return Returns the x-coordinate of the routing center point. */ public double getRoutingCenterX(mxCellState state) { float f = (state.getStyle() != null) ? mxUtils.getFloat( state.getStyle(), mxConstants.STYLE_ROUTING_CENTER_X) : 0; return state.getCenterX() + f * state.getWidth(); }
/** * Returns the x-coordinate of the center point for automatic routing. * * @return Returns the x-coordinate of the routing center point. */ public double getRoutingCenterX(mxCellState state) { float f = (state.getStyle() != null) ? mxUtils.getFloat( state.getStyle(), mxConstants.STYLE_ROUTING_CENTER_X) : 0; return state.getCenterX() + f * state.getWidth(); }
/** * Returns the y-coordinate of the center point for automatic routing. * * @return Returns the y-coordinate of the routing center point. */ public double getRoutingCenterY(mxCellState state) { float f = (state.getStyle() != null) ? mxUtils.getFloat( state.getStyle(), mxConstants.STYLE_ROUTING_CENTER_Y) : 0; return state.getCenterY() + f * state.getHeight(); }
/** * Returns the y-coordinate of the center point for automatic routing. * * @return Returns the y-coordinate of the routing center point. */ public double getRoutingCenterY(mxCellState state) { float f = (state.getStyle() != null) ? mxUtils.getFloat( state.getStyle(), mxConstants.STYLE_ROUTING_CENTER_Y) : 0; return state.getCenterY() + f * state.getHeight(); }
/** * Draws the glass effect */ public static void drawGlassEffect(mxGraphics2DCanvas canvas, mxCellState state) { double size = 0.4; canvas.getGraphics().setPaint( new GradientPaint((float) state.getX(), (float) state.getY(), new Color(1, 1, 1, 0.9f), (float) (state.getX()), (float) (state.getY() + state.getHeight() * size), new Color(1, 1, 1, 0.3f))); float sw = (float) (mxUtils.getFloat(state.getStyle(), mxConstants.STYLE_STROKEWIDTH, 1) * canvas.getScale() / 2); GeneralPath path = new GeneralPath(); path.moveTo((float) state.getX() - sw, (float) state.getY() - sw); path.lineTo((float) state.getX() - sw, (float) (state.getY() + state.getHeight() * size)); path.quadTo((float) (state.getX() + state.getWidth() * 0.5), (float) (state.getY() + state.getHeight() * 0.7), (float) (state.getX() + state.getWidth() + sw), (float) (state.getY() + state.getHeight() * size)); path.lineTo((float) (state.getX() + state.getWidth() + sw), (float) state.getY() - sw); path.closePath(); canvas.getGraphics().fill(path); }
/** * Draws the glass effect */ public static void drawGlassEffect(mxGraphics2DCanvas canvas, mxCellState state) { double size = 0.4; canvas.getGraphics().setPaint( new GradientPaint((float) state.getX(), (float) state.getY(), new Color(1, 1, 1, 0.9f), (float) (state.getX()), (float) (state.getY() + state.getHeight() * size), new Color(1, 1, 1, 0.3f))); float sw = (float) (mxUtils.getFloat(state.getStyle(), mxConstants.STYLE_STROKEWIDTH, 1) * canvas.getScale() / 2); GeneralPath path = new GeneralPath(); path.moveTo((float) state.getX() - sw, (float) state.getY() - sw); path.lineTo((float) state.getX() - sw, (float) (state.getY() + state.getHeight() * size)); path.quadTo((float) (state.getX() + state.getWidth() * 0.5), (float) (state.getY() + state.getHeight() * 0.7), (float) (state.getX() + state.getWidth() + sw), (float) (state.getY() + state.getHeight() * size)); path.lineTo((float) (state.getX() + state.getWidth() + sw), (float) state.getY() - sw); path.closePath(); canvas.getGraphics().fill(path); }
public Object drawLabel(String text, mxCellState state, boolean html) { Map<String, Object> style = state.getStyle(); mxITextShape shape = getTextShape(style, html); if (g != null && shape != null && drawLabels && text != null && text.length() > 0) { // Creates a temporary graphics instance for drawing this shape float opacity = mxUtils.getFloat(style, mxConstants.STYLE_TEXT_OPACITY, 100); Graphics2D previousGraphics = g; g = createTemporaryGraphics(style, opacity, null); // Draws the label background and border Color bg = mxUtils.getColor(style, mxConstants.STYLE_LABEL_BACKGROUNDCOLOR); Color border = mxUtils.getColor(style, mxConstants.STYLE_LABEL_BORDERCOLOR); paintRectangle(state.getLabelBounds().getRectangle(), bg, border); // Paints the label and restores the graphics object shape.paintShape(this, text, state, style); g.dispose(); g = previousGraphics; } return shape; }
public Object drawLabel(String text, mxCellState state, boolean html) { Map<String, Object> style = state.getStyle(); mxITextShape shape = getTextShape(style, html); if (g != null && shape != null && drawLabels && text != null && text.length() > 0) { // Creates a temporary graphics instance for drawing this shape float opacity = mxUtils.getFloat(style, mxConstants.STYLE_TEXT_OPACITY, 100); Graphics2D previousGraphics = g; g = createTemporaryGraphics(style, opacity, null); // Draws the label background and border Color bg = mxUtils.getColor(style, mxConstants.STYLE_LABEL_BACKGROUNDCOLOR); Color border = mxUtils.getColor(style, mxConstants.STYLE_LABEL_BORDERCOLOR); paintRectangle(state.getLabelBounds().getRectangle(), bg, border); // Paints the label and restores the graphics object shape.paintShape(this, text, state, style); g.dispose(); g = previousGraphics; } return shape; }