public static Matrix radialGradientMatrix(ScalableGradientNode gradient,Rect pathBounds){
  MatrixNode mtxNode=gradient.getMatrixNode();
  if (mtxNode != null) {
    double tx=mtxNode.tx;
    double ty=mtxNode.ty;
    FXGMatrix fxgMtx=new FXGMatrix(mtxNode.a,mtxNode.b,mtxNode.c,mtxNode.d,0,0);
    fxgMtx.scale(SwfConstants.TWIPS_PER_PIXEL / (float)SwfConstants.GRADIENT_SQUARE,SwfConstants.TWIPS_PER_PIXEL / (float)SwfConstants.GRADIENT_SQUARE);
    fxgMtx.translate(tx,ty);
    return fxgMtx.toSWFMatrix();
  }
  double w=!Double.isNaN(gradient.getScaleX()) ? gradient.getScaleX() * SwfConstants.TWIPS_PER_PIXEL : pathBounds.getWidth();
  double h=!Double.isNaN(gradient.getScaleY()) ? gradient.getScaleY() * SwfConstants.TWIPS_PER_PIXEL : pathBounds.getHeight();
  double tx=(!Double.isNaN(gradient.getX()) ? gradient.getX() : (pathBounds.xMax + pathBounds.xMin) / (2.0 * SwfConstants.TWIPS_PER_PIXEL));
  double ty=(!Double.isNaN(gradient.getY()) ? gradient.getY() : (pathBounds.yMax + pathBounds.yMin) / (2.0 * SwfConstants.TWIPS_PER_PIXEL));
  FXGMatrix matrix=new FXGMatrix();
  matrix.scale(w / SwfConstants.GRADIENT_SQUARE,h / SwfConstants.GRADIENT_SQUARE);
  if (!Double.isNaN(gradient.getRotation()) && (gradient.getRotation() != 0))   matrix.rotate(gradient.getRotation());
  matrix.translate(tx,ty);
  return matrix.toSWFMatrix();
}

public static Matrix radialGradientMatrix ( ScalableGradientNode gradient , Rect pathBounds ) { MatrixNode mtxNode = gradient . getMatrixNode ( ) ; if ( mtxNode != null ) { double tx = mtxNode . tx ; double ty = mtxNode . ty ; FXGMatrix fxgMtx = new FXGMatrix ( mtxNode . a , mtxNode . b , mtxNode . c , mtxNode . d , 0 , 0 ) ; fxgMtx . scale ( SwfConstants . TWIPS_PER_PIXEL / ( float ) SwfConstants . GRADIENT_SQUARE , SwfConstants . TWIPS_PER_PIXEL / ( float ) SwfConstants . GRADIENT_SQUARE ) ; fxgMtx . translate ( tx , ty ) ; return fxgMtx . toSWFMatrix ( ) ; } double w = ! Double . isNaN ( gradient . getScaleX ( ) ) ? gradient . getScaleX ( ) * SwfConstants . TWIPS_PER_PIXEL : pathBounds . getWidth ( ) ; double h = ! Double . isNaN ( gradient . getScaleY ( ) ) ? gradient . getScaleY ( ) * SwfConstants . TWIPS_PER_PIXEL : pathBounds . getHeight ( ) ; double tx = ( ! Double . isNaN ( gradient . getX ( ) ) ? gradient . getX ( ) : ( pathBounds . xMax + pathBounds . xMin ) / ( 2.0 * SwfConstants . TWIPS_PER_PIXEL ) ) ; double ty = ( ! Double . isNaN ( gradient . getY ( ) ) ? gradient . getY ( ) : ( pathBounds . yMax + pathBounds . yMin ) / ( 2.0 * SwfConstants . TWIPS_PER_PIXEL ) ) ; FXGMatrix matrix = new FXGMatrix ( ) ; matrix . scale ( w / SwfConstants . GRADIENT_SQUARE , h / SwfConstants . GRADIENT_SQUARE ) ; if ( ! Double . isNaN ( gradient . getRotation ( ) ) && ( gradient . getRotation ( ) != 0 ) ) matrix . rotate ( gradient . getRotation ( ) ) ; matrix . translate ( tx , ty ) ; return matrix . toSWFMatrix ( ) ; }
method to generate a transform matrix for the radial gradient strokes and fills . first the translation and scaling is applied and later the rotation is applied . the scaling applied is the user specified value or in its absence the dimensions of the geometry . this is multiplied by the quotient of the number or twips per pixel and the number of twips on the screen in a given orientation to get the correct scale fraction .
