PathGradientContext( ColorModel cm , Rectangle deviceBounds , Rectangle2D userBounds , AffineTransform xform , RenderingHints hints ) { shape = (Shape)hints.get(Drawable.GRADIENT_SHAPE); if (shape == null) { throw new IllegalPathStateException("PathGradientPaint needs a shape to be set via the rendering hint Drawable.GRADIANT_SHAPE."); } this.deviceBounds = deviceBounds; this.userBounds = userBounds; this.xform = xform; this.hints = hints; gradientSteps = getGradientSteps(shape); Point2D start = new Point2D.Double(0, 0); Point2D end = new Point2D.Double(gradientSteps, 0); LinearGradientPaint gradientPaint = new LinearGradientPaint(start, end, fractions, colors, CycleMethod.NO_CYCLE, ColorSpaceType.SRGB, new AffineTransform()); Rectangle bounds = new Rectangle(0, 0, gradientSteps, 1); pCtx = gradientPaint.createContext(cm, bounds, bounds, new AffineTransform(), hints); }
PathGradientContext( ColorModel cm , Rectangle deviceBounds , Rectangle2D userBounds , AffineTransform xform , RenderingHints hints ) { shape = (Shape)hints.get(Drawable.GRADIENT_SHAPE); if (shape == null) { throw new IllegalPathStateException("PathGradientPaint needs a shape to be set via the rendering hint Drawable.GRADIANT_SHAPE."); } this.deviceBounds = deviceBounds; this.userBounds = userBounds; this.xform = xform; this.hints = hints; gradientSteps = getGradientSteps(shape); Point2D start = new Point2D.Double(0, 0); Point2D end = new Point2D.Double(gradientSteps, 0); LinearGradientPaint gradientPaint = new LinearGradientPaint(start, end, fractions, colors, CycleMethod.NO_CYCLE, ColorSpaceType.SRGB, new AffineTransform()); Rectangle bounds = new Rectangle(0, 0, gradientSteps, 1); pCtx = gradientPaint.createContext(cm, bounds, bounds, new AffineTransform(), hints); }