// construct the linear gradient from XML public RadialGradient(XMLUtility XMLUtility, Node root) throws ParseException { // get the transformation matrix Node matrixNode = XMLUtility.findNode(root, "Matrix"); TransformationMatrix m = new TransformationMatrix(XMLUtility, matrixNode); fCenterX = m.getTranslateX(); fCenterY = m.getTranslateY(); double radius1 = 819.2 * m.getMatrix()[0][0]; // a double radius2 = 819.2 * m.getMatrix()[1][1]; // d if (radius1 == radius2) // circle { fRadius = radius1; } else // oval { // this is a stab in the dark at a filthy hack // I think 'a' and 'c' in the transform are modifiers for the radius of the ellipse // can't find any documentation on this, and for the flas I'm working with this // looks acceptable fRadius = 819.2 * m.getMatrix()[1][0]; // c } // get the gradient entries Vector<Node> nodes = XMLUtility.findNodes(root, "GradientEntry"); for (Node node : nodes) { double ratio = XMLUtility.getDoubleAttribute(node, "ratio", 0.0); String colorCode = XMLUtility.getAttribute(node, "color", "#000000"); Color color = Color.parseColor(colorCode); color.setAlpha(XMLUtility.getDoubleAttribute(node, "alpha", 1.0)); fColorStops.add(new ColorStop(ratio, color)); } }