protected void build() throws SVGException { super.build(); StyleAttribute sty = new StyleAttribute(); if (getPres(sty.setName("offset"))) { offset = sty.getFloatValue(); String units = sty.getUnits(); if (units != null && units.equals("%")) offset /= 100f; if (offset > 1) offset = 1; if (offset < 0) offset = 0; } if (getStyle(sty.setName("stop-color"))) color = sty.getColorValue(); if (getStyle(sty.setName("stop-opacity"))) opacity = sty.getRatioValue(); }
public boolean getStyle(StyleAttribute attrib, String tagName, String cssClass) StyleSheetRule rule = new StyleSheetRule(attrib.getName(), tagName, cssClass); String value = (String)ruleMap.get(rule); attrib.setStringValue(value); return true; rule = new StyleSheetRule(attrib.getName(), null, cssClass); value = (String)ruleMap.get(rule); attrib.setStringValue(value); return true; rule = new StyleSheetRule(attrib.getName(), tagName, null); value = (String)ruleMap.get(rule); attrib.setStringValue(value); return true;
public float getFloatValueWithUnits() { NumberWithUnits number = getNumberWithUnits(); return convertUnitsToPixels(number.getUnits(), number.getValue()); }
protected void build() throws SVGException { super.build(); StyleAttribute sty = new StyleAttribute(); if (getPres(sty.setName("horiz-origin-x"))) horizOriginX = sty.getIntValue(); if (getPres(sty.setName("horiz-origin-y"))) horizOriginY = sty.getIntValue(); if (getPres(sty.setName("horiz-adv-x"))) horizAdvX = sty.getIntValue(); if (getPres(sty.setName("vert-origin-x"))) vertOriginX = sty.getIntValue(); if (getPres(sty.setName("vert-origin-y"))) vertOriginY = sty.getIntValue(); if (getPres(sty.setName("vert-adv-y"))) vertAdvY = sty.getIntValue(); }
private Paint handleCurrentColor(StyleAttribute styleAttrib) throws SVGException { if (styleAttrib.getStringValue().equals("currentColor")) { StyleAttribute currentColorAttrib = new StyleAttribute(); if (getStyle(currentColorAttrib.setName("color"))) { if (!currentColorAttrib.getStringValue().equals("none")) { return currentColorAttrib.getColorValue(); } } return null; } else { return styleAttrib.getColorValue(); } }
protected void build() throws SVGException { super.build(); StyleAttribute sty = new StyleAttribute(); if (getPres(sty.setName("x1"))) x1 = sty.getFloatValueWithUnits(); if (getPres(sty.setName("y1"))) y1 = sty.getFloatValueWithUnits(); if (getPres(sty.setName("x2"))) x2 = sty.getFloatValueWithUnits(); if (getPres(sty.setName("y2"))) y2 = sty.getFloatValueWithUnits(); }
protected void build() throws SVGException { super.build(); StyleAttribute sty = new StyleAttribute(); //Read glyph spacing info if (getPres(sty.setName("u1"))) u1 = sty.getStringValue(); if (getPres(sty.setName("u2"))) u2 = sty.getStringValue(); if (getPres(sty.setName("k"))) k = sty.getIntValue(); }
StyleAttribute sty = new StyleAttribute(); if (getPres(sty.setName("refX"))) refX = sty.getFloatValueWithUnits(); if (getPres(sty.setName("refY"))) refY = sty.getFloatValueWithUnits(); if (getPres(sty.setName("markerWidth"))) markerWidth = sty.getFloatValueWithUnits(); if (getPres(sty.setName("markerHeight"))) markerHeight = sty.getFloatValueWithUnits(); if (getPres(sty.setName("orient"))) if ("auto".equals(sty.getStringValue())) orient = sty.getFloatValue(); if (getPres(sty.setName("viewBox"))) float[] dim = sty.getFloatList(); viewBox = new Rectangle2D.Float(dim[0], dim[1], dim[2], dim[3]); if (getPres(sty.setName("markerUnits"))) String markerUnits = sty.getStringValue(); if (markerUnits != null && markerUnits.equals("userSpaceOnUse"))
StyleAttribute sty = new StyleAttribute(); boolean shapeChange = false; if (getPres(sty.setName("offset"))) float newVal = sty.getFloatValue(); if (newVal != offset) if (getPres(sty.setName("stop-color"))) Color newVal = sty.getColorValue(); if (newVal != color) if (getPres(sty.setName("stop-opacity"))) float newVal = sty.getFloatValue(); if (newVal != opacity)
protected void build() throws SVGException { super.build(); StyleAttribute sty = new StyleAttribute(); if (getPres(sty.setName("x"))) x = sty.getFloatList(); if (getPres(sty.setName("y"))) y = sty.getFloatList(); if (getPres(sty.setName("dx"))) dx = sty.getFloatList(); if (getPres(sty.setName("dy"))) dy = sty.getFloatList(); if (getPres(sty.setName("rotate"))) { rotate = sty.getFloatList(); for (int i = 0; i < this.rotate.length; i++) { rotate[i] = (float)Math.toRadians(this.rotate[i]); } } }
protected void build() throws SVGException { super.build(); StyleAttribute sty = new StyleAttribute(); if (getPres(sty.setName("unicode"))) { unicode = sty.getStringValue(); } }
/** * Copies the presentation attribute into the passed one. * @return - True if attribute was read successfully */ public boolean getPres(StyleAttribute attrib) throws SVGException { String presName = attrib.getName(); //Make sure we have a coresponding presentation attribute StyleAttribute presAttr = (StyleAttribute)presAttribs.get(presName); //Copy presentation value directly attrib.setStringValue(presAttr == null ? "" : presAttr.getStringValue()); //Evalutate coresponding track, if one exists TrackBase track = trackManager.getTrack(presName, AnimationElement.AT_XML); if (track != null) { track.getValue(attrib, diagram.getUniverse().getCurTime()); return true; } //Return if we found presentation attribute if (presAttr != null) return true; return false; }
StyleAttribute sty = new StyleAttribute(); if (getPres(sty.setName("x"))) x = sty.getNumberWithUnits(); if (getPres(sty.setName("y"))) y = sty.getNumberWithUnits(); if (getPres(sty.setName("width"))) width = sty.getNumberWithUnits(); if (getPres(sty.setName("height"))) height = sty.getNumberWithUnits(); if (getPres(sty.setName("viewBox"))) float[] coords = sty.getFloatList(); viewBox = new Rectangle2D.Float(coords[0], coords[1], coords[2], coords[3]); if (getPres(sty.setName("preserveAspectRatio"))) String preserve = sty.getStringValue();
protected Rectangle2D includeStrokeInBounds(Rectangle2D rect) throws SVGException { StyleAttribute styleAttrib = new StyleAttribute(); if (!getStyle(styleAttrib.setName("stroke"))) return rect; double strokeWidth = 1; if (getStyle(styleAttrib.setName("stroke-width"))) strokeWidth = styleAttrib.getDoubleValue(); rect.setRect( rect.getX() - strokeWidth / 2, rect.getY() - strokeWidth / 2, rect.getWidth() + strokeWidth, rect.getHeight() + strokeWidth); return rect; }
StyleAttribute sty = new StyleAttribute(); if (getPres(sty.setName("d"))) commandList = sty.getStringValue(); String fillRule = getStyle(sty.setName("fill-rule")) ? sty.getStringValue() : "nonzero"; if (getPres(sty.setName("horiz-adv-x"))) horizAdvX = sty.getFloatValue(); if (getPres(sty.setName("vert-origin-x"))) vertOriginX = sty.getFloatValue(); if (getPres(sty.setName("vert-origin-y"))) vertOriginY = sty.getFloatValue(); if (getPres(sty.setName("vert-adv-y"))) vertAdvY = sty.getFloatValue();
public boolean getValue(StyleAttribute attrib, double curTime) { double val = getValue(curTime); if (Double.isNaN(val)) return false; attrib.setStringValue("" + val); return true; }
private void setStroke(Color fromColor, String toColor, SVGElement node) throws SVGException { if (node.hasAttribute("stroke", AnimationElement.AT_CSS)) { StyleAttribute abs = node.getStyleAbsolute("stroke"); Color was = abs.getColorValue(); if (was.equals(fromColor)) { abs.setStringValue(toColor); } } for (int i = 0; i < node.getNumChildren(); ++i) { setStroke(fromColor, toColor, node.getChild(i)); } } private String getHexString(Color color) { return String.format("#%06x", (0xFFFFFF & color.getRGB())); }
StyleAttribute style = new StyleAttribute(getAttribName()); try "Could not get from value", ex); double from = style.getDoubleValue(); return toValue * interp + from * (1.0 - interp);
xx = (x == null) ? 0 : StyleAttribute.convertUnitsToPixels(x.getUnits(), x.getValue()); if (width.getUnits() == NumberWithUnits.UT_PERCENT) ww = StyleAttribute.convertUnitsToPixels(width.getUnits(), width.getValue()); yy = (y == null) ? 0 : StyleAttribute.convertUnitsToPixels(y.getUnits(), y.getValue()); if (height.getUnits() == NumberWithUnits.UT_PERCENT) hh = StyleAttribute.convertUnitsToPixels(height.getUnits(), height.getValue());
retVal = attr.getDoubleValue(); break; case AnimationElement.AT_XML: attr = parent.getPresAbsolute(attribName); retVal = attr.getDoubleValue(); break; case AnimationElement.AT_AUTO: attr = parent.getStyleAbsolute(attribName); if (attr == null) attr = parent.getPresAbsolute(attribName); retVal = attr.getDoubleValue(); break;