/** * Implements {@link Value#getStringValue()}. */ public String getStringValue() throws DOMException { return computedValue.getStringValue(); }
/** * Called when the green value text has changed. */ public void greenTextChanged(String text) throws DOMException { final Value val = getValue(); text = "rgb(" + val.getRed().getCssText() + ", " + text + ", " + val.getBlue().getCssText() + ')'; textChanged(text); }
/** * Converts the 'stroke-dasharray' property to a list of float * number in user units. * * @param v the CSS value describing the dasharray property */ public static float [] convertStrokeDasharray(Value v) { float [] dasharray = null; if (v.getCssValueType() == CSSValue.CSS_VALUE_LIST) { int length = v.getLength(); dasharray = new float[length]; float sum = 0; for (int i = 0; i < dasharray.length; ++i) { dasharray[i] = v.item(i).getFloatValue(); sum += dasharray[i]; } if (sum == 0) { /* 11.4 - If the sum of the <length>'s is zero, then * the stroke is rendered as if a value of none were specified. */ dasharray = null; } } return dasharray; }
/** * Called when the left value text has changed. */ public void leftTextChanged(String text) throws DOMException { final Value val = getValue(); text = "rect(" + val.getTop().getCssText() + ", " + val.getRight().getCssText() + ", " + val.getBottom().getCssText() + ", " + text + ')'; textChanged(text); }
/** * Called when the right value text has changed. */ public void rightTextChanged(String text) throws DOMException { final Value val = getValue(); text = "rect(" + val.getTop().getCssText() + ", " + text + ", " + val.getBottom().getCssText() + ", " + val.getLeft().getCssText() + ')'; textChanged(text); }
/** * Called when the top value text has changed. */ public void topTextChanged(String text) throws DOMException { final Value val = getValue(); text = "rect(" + text + ", " + val.getRight().getCssText() + ", " + val.getBottom().getCssText() + ", " + val.getLeft().getCssText() + ')'; textChanged(text); }
/** * Called when the red value text has changed. */ public void redTextChanged(String text) throws DOMException { final Value val = getValue(); text = "rgb(" + text + ", " + val.getGreen().getCssText() + ", " + val.getBlue().getCssText() + ')'; textChanged(text); }
/** * Called when the blue value text has changed. */ public void blueTextChanged(String text) throws DOMException { final Value val = getValue(); text = "rgb(" + val.getRed().getCssText() + ", " + val.getGreen().getCssText() + ", " + text + ')'; textChanged(text); }
/** * Converts the given Value and opacity to a Color object. * @param c The CSS color to convert. * @param opacity The opacity value (0 <= o <= 1). */ public static Color convertColor(Value c, float opacity) { int r = resolveColorComponent(c.getRed()); int g = resolveColorComponent(c.getGreen()); int b = resolveColorComponent(c.getBlue()); return new Color(r, g, b, Math.round(opacity * 255f)); }
public static float getFloatProp(StyleMap sm, CSSEngine eng, int pidx) { Value v = sm.getValue(pidx); ValueManager [] vms = eng.getValueManagers(); if (v == null) { ValueManager vm = vms[pidx]; v = vm.getDefaultValue(); } while (v.getCssValueType() == CSSValue.CSS_VALUE_LIST) { v = v.item(0); } return v.getFloatValue(); }
public static String getStringProp(StyleMap sm, CSSEngine eng, int pidx) { Value v = sm.getValue(pidx); ValueManager [] vms = eng.getValueManagers(); if (v == null) { ValueManager vm = vms[pidx]; v = vm.getDefaultValue(); } while (v.getCssValueType() == CSSValue.CSS_VALUE_LIST) { v = v.item(0); } return v.getStringValue(); }
private String[] getFontFamilyNames(Value list) { if ((list == null) || (list.getLength() == 0)) { return new String[] {JAVA_FONT_FAMILY_NAME_SANS_SERIF}; } List<String> fontFamilyNames = new ArrayList<String>(); Map validNames = getValidFontNameMapping(); for (int i = 0, len = list.getLength(); i < len; i++) { Value it = list.item(i); String fontName = it.getStringValue(); String family = (String)validNames.get(mapCssFontFamilyNameToJavaFontFamilyName(fontName)); if (family == null) { family = (String)validNames.get(fontName.toLowerCase()); } if (family != null) { // return family; fontFamilyNames.add(family); } } if (fontFamilyNames.isEmpty()) { // Fallback. fontFamilyNames.add(JAVA_FONT_FAMILY_NAME_SANS_SERIF); } return fontFamilyNames.toArray(new String[fontFamilyNames.size()]); }
/** * Implements {@link Value#getPrimitiveType()}. */ public short getPrimitiveType() { return computedValue.getPrimitiveType(); }
/** * Implements {@link Value#getFloatValue()}. */ public float getFloatValue() throws DOMException { return computedValue.getFloatValue(); }
/** * Implements {@link Value#getLength()}. */ public int getLength() throws DOMException { return computedValue.getLength(); }
/** * Converts a kerning CSS value to a value usable as a text * attribute, or null. * @param e the element */ public static Float convertKerning(Element e) { Value v = CSSUtilities.getComputedStyle (e, SVGCSSEngine.KERNING_INDEX); if (v.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) { return null; } return v.getFloatValue(); }
/** * Implements {@link Value#item(int)}. */ public Value item(int index) throws DOMException { return computedValue.item(index); }
/** * Implements {@link Value#getBottom()}. */ public Value getBottom() throws DOMException { return computedValue.getBottom(); }
/** * Implements {@link Value#getGreen()}. */ public Value getGreen() throws DOMException { return computedValue.getGreen(); }