/** * Returns the value for key in dictionary as a color or null 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 color value for key in dict. */ public static Color getColor(Map<String, Object> dict, String key) { return getColor(dict, key, null); }
/** * */ 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 size for the given label. If isHtml is true then any HTML * markup in the label is computed as HTML and all newlines inside the HTML * body are converted into linebreaks. */ public static mxRectangle getLabelSize(String label, Map<String, Object> style, boolean isHtml, double scale, double htmlWrapWidth) { mxRectangle size; if (isHtml) { size = getSizeForHtml(getBodyMarkup(label, true), style, scale, htmlWrapWidth); } else { size = getSizeForString(label, getFont(style), scale); } return size; }
/** * */ public static Font getFont(Map<String, Object> style, double scale) { String fontFamily = getString(style, mxConstants.STYLE_FONTFAMILY, mxConstants.DEFAULT_FONTFAMILY); int fontSize = getInt(style, mxConstants.STYLE_FONTSIZE, mxConstants.DEFAULT_FONTSIZE); int fontStyle = getInt(style, mxConstants.STYLE_FONTSTYLE); int swingFontStyle = ((fontStyle & mxConstants.FONT_BOLD) == mxConstants.FONT_BOLD) ? Font.BOLD : Font.PLAIN; swingFontStyle += ((fontStyle & mxConstants.FONT_ITALIC) == mxConstants.FONT_ITALIC) ? Font.ITALIC : Font.PLAIN; return new Font(fontFamily, swingFontStyle, (int) (fontSize * scale)); }
/** * */ protected String createHtmlDocument(Map<String, Object> style, String text, int w, int h) { String overflow = mxUtils.getString(style, mxConstants.STYLE_OVERFLOW, ""); if (overflow.equals("fill")) { return mxUtils.createHtmlDocument(style, text, 1, w, null, "height:" + h + "pt;"); } else if (overflow.equals("width")) { return mxUtils.createHtmlDocument(style, text, 1, w); } else { return mxUtils.createHtmlDocument(style, text); } }
&& !graph.isHtmlLabel(state.getCell()) && !graph.getModel().isEdge(state.getCell()) && mxUtils.getString(style, mxConstants.STYLE_WHITE_SPACE, "nowrap").equals("wrap")) String[] lines = mxUtils.wordWrap(label, mxUtils.getFontMetrics(mxUtils.getFont(state.getStyle())), w * mxConstants.LABEL_SCALE_BUFFER);
value = mxUtils.getBodyMarkup(value, isReplaceHtmlLinefeeds()); editorPane.setDocument(mxUtils.createHtmlDocumentObject( state.getStyle(), scale)); editorPane.setText(value); textArea.setFont(mxUtils.getFont(state.getStyle(), scale)); Color fontColor = mxUtils.getColor(state.getStyle(), mxConstants.STYLE_FONTCOLOR, Color.black); textArea.setForeground(fontColor);
/** * 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 boolean isRounded(Map<String, Object> style) { return mxUtils.isTrue(style, mxConstants.STYLE_ROUNDED, false); }
float opacity = mxUtils.getFloat(style, mxConstants.STYLE_OPACITY, 100); Graphics2D previousGraphics = g; g = canvas.createTemporaryGraphics(style, opacity, state); Font font = mxUtils.getFont(style, canvas.getScale()); g.setFont(font); Color fontColor = mxUtils.getColor(style, mxConstants.STYLE_FONTCOLOR, Color.black); g.setColor(fontColor);
/** * Returns the value for key in dictionary as a string or null 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 string value for key in dict. */ public static String getString(Map<String, Object> dict, String key) { return getString(dict, key, null); }
textRenderer.setText(createHtmlDocument(style, markup)); Dimension size = textRenderer.getPreferredSize(); textRenderer.setText(createHtmlDocument( style, markup, return getSizeForString(markup, getFont(style), scale);
int h = rect.height; if (!mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL, true)) (int) Math.round(w / state.getView().getScale()), (int) Math.round(h / state.getView().getScale()))); textRenderer.setFont(mxUtils.getFont(style, canvas.getScale())); g.scale(scale, scale); rendererPane.paintComponent(g, textRenderer, rendererPane,
/** * 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 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 value for key in dictionary as an int 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 integer value for key in dict. */ public static int getInt(Map<String, Object> dict, String key) { return getInt(dict, key, 0); }
if (mxUtils.contains(cells, parent))
/** * */ public static Font getFont(Map<String, Object> style) { return getFont(style, 1); }