public PaintContext createContext(ColorModel colorModel, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) { Point2D transformedCenter = xform.transform(m_center, null); Point2D transformedRadius1 = xform.deltaTransform(m_radius1, null); Point2D transformedRadius2 = xform.deltaTransform(m_radius2, null); if (m_cachedContext != null && transformedCenter.equals(m_transformedCenter) && transformedRadius1.equals(m_transformedRadius1) && transformedRadius2.equals(m_transformedRadius2)) return m_cachedContext; m_transformedCenter = (Point2D)transformedCenter.clone(); m_transformedRadius1 = (Point2D)transformedRadius1.clone(); m_transformedRadius2 = (Point2D)transformedRadius2.clone(); m_cachedContext = new RadialGradientContext(transformedCenter, transformedRadius1, transformedRadius2, m_focus, m_color1, m_color2); return m_cachedContext; }
@Override public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) { if(QUALITY_HINTS==null) { QUALITY_HINTS = new RenderingHints(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); QUALITY_HINTS.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); QUALITY_HINTS.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); } PaintContext context = super.createContext(cm, deviceBounds, userBounds, xform, QUALITY_HINTS); if(cycle) { return context; } AffineTransform newCopy = new AffineTransform(); if(xform!=null) newCopy.concatenate(xform); context = new CoveredContext(context,x1,y1,color1,x2,y2,color2,newCopy); return context; }
@Override public PaintContext createContext( ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints ) { AffineTransform T = getTextureTransform(); try { T.invert(); } catch (NoninvertibleTransformException e) { } if (xform == null) { xform = T; } else { xform = (AffineTransform) xform.clone(); xform.concatenate(T); } return super.createContext(cm, deviceBounds, userBounds, xform, hints); }
/** create a paint context */ public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) { ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); ColorModel model = new ComponentColorModel(cs, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); Point2D devStart = xform.transform(getAxisStart(), null); Point2D devEnd = xform.transform(getAxisEnd(), null); return new Type2PaintContext(model, devStart, devEnd); }
public PaintContext createContext(ColorModel colorModel, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) { Point2D transformedPoint = xform.transform(m_point, null); Point2D transformedRadius = xform.deltaTransform(m_radius, null); if (m_cachedContext != null && transformedPoint.equals(m_transformedPoint) && transformedRadius.equals(m_transformedRadius)) return m_cachedContext; m_transformedPoint = (Point2D)transformedPoint.clone(); m_transformedRadius = (Point2D)transformedRadius.clone(); m_cachedContext = new RadialGradientContext(transformedPoint, m_pointColor, transformedRadius, m_backgroundColor); return m_cachedContext; }
/** * This method fills the given MultiRectArea with any paint. * @param mra MultiRectArea to fill */ protected void fillMultiRectAreaPaint(MultiRectArea mra) { Rectangle rec = mra.getBounds(); int x = rec.x; int y = rec.y; int w = rec.width; int h = rec.height; if(w <= 0 || h <= 0) { return; } PaintContext pc = paint.createContext(null, rec, rec, transform, hints); Raster r = pc.getRaster(x, y, w, h); WritableRaster wr; if(r instanceof WritableRaster){ wr = (WritableRaster) r; }else{ wr = r.createCompatibleWritableRaster(); wr.setRect(r); } Surface srcSurf = new ImageSurface(pc.getColorModel(), wr); blitter.blit(0, 0, srcSurf, x, y, dstSurf, w, h, composite, null, mra); srcSurf.dispose(); }
@Override public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR, int[] abox) { // warning: clone map: RenderingHints hints = sg.getRenderingHints(); ColorModel model = sg.getDeviceColorModel(); PaintContext paintContext = sg.paint.createContext(model, devR, s.getBounds2D(), sg.cloneTransform(), hints); CompositeContext compositeContext = sg.composite.createContext(paintContext.getColorModel(), model, hints); // BlendComposite matcher: classpath independent so use String.equals() boolean blendComposite = "sun.java2d.pipe.BlendComposite".equals(sg.composite.getClass().getName()); // use ThreadLocal (to reduce memory footprint): final TileContext tc = tileContextThreadLocal.get(); tc.init(sg, paintContext, compositeContext, model, blendComposite); return tc; }
/** * {@inheritDoc} */ @Override public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform transform, RenderingHints hints) { // avoid modifying the user's transform... transform = new AffineTransform(transform); // incorporate the gradient transform transform.concatenate(gradientTransform); return new ParamGradientMapPaintContext(this, cm, deviceBounds, userBounds, transform, hints, origin, majorAxis, minorAxis, startParam, endParam, fractions, colors, cycleMethod, colorSpace); }
public TileContext(SunGraphics2D sg, PaintContext pc) { sunG2D = sg; paintCtxt = pc; paintModel = pc.getColorModel(); dstData = sg.getSurfaceData(); synchronized (AlphaPaintPipe.class) { if (cachedLastColorModel != null && cachedLastColorModel.get() == paintModel) { this.lastRaster = cachedLastRaster; this.lastData = cachedLastData; } } }
public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR, int[] abox) { PaintContext paintContext = sg.paint.createContext(sg.getDeviceColorModel(), devR, s.getBounds2D(), sg.cloneTransform(), sg.getRenderingHints()); return new TileContext(sg, paintContext); }
public TileContext(SunGraphics2D sg, PaintContext pCtx, CompositeContext cCtx, ColorModel cModel) { sunG2D = sg; paintCtxt = pCtx; compCtxt = cCtx; compModel = cModel; }
public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR, int[] abox) { RenderingHints hints = sg.getRenderingHints(); ColorModel model = sg.getDeviceColorModel(); PaintContext paintContext = sg.paint.createContext(model, devR, s.getBounds2D(), sg.cloneTransform(), hints); CompositeContext compositeContext = sg.composite.createContext(paintContext.getColorModel(), model, hints); return new TileContext(sg, paintContext, compositeContext, model); }
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) { System.out.println("user bounds = "+userBounds); if (!userBounds.equals(expectedBounds)) { throw new RuntimeException("bounds fail to match"); } return c.createContext(cm, deviceBounds, userBounds, xform, hints); }
@Override public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform at, RenderingHints hints) { // Fill bufferedImage using final Graphics2D g2d = (Graphics2D) getImage().getGraphics(); try { g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setBackground(Color.PINK); g2d.clearRect(0, 0, size, size); g2d.setColor(Color.BLUE); g2d.drawRect(0, 0, size, size); g2d.fillOval(size / 10, size / 10, size * 8 / 10, size * 8 / 10); } finally { g2d.dispose(); } return super.createContext(cm, deviceBounds, userBounds, at, hints); }
/** * See Paint.createContext */ public PaintContext createContext( ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints ) { Point2D transformedCenter = xform.transform( center, null ); //Transform from user space to device space and create the gradient context double transformedInnerMiddleSpan = xform.deltaTransform( new Point2D.Double( innerMiddleSpan, 0 ), null ).getX(); double transformedMiddleOuterSpan = xform.deltaTransform( new Point2D.Double( middleOuterSpan, 0 ), null ).getX(); return new TriColorRoundGradientContext( innerColor, middleColor, outerColor, transformedCenter, transformedInnerMiddleSpan, transformedMiddleOuterSpan ); }
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) { AffineTransform newTransform = new AffineTransform(xform); newTransform.concatenate(transform); //this is necessary on Java 1.4 toa void a NullPointerException //from: java.awt.TexturePaintContext.getContext(TexturePaintContext.java:57) if(hints==null) hints = new RenderingHints(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_DEFAULT); return texturePaint.createContext(cm, deviceBounds, userBounds, newTransform, hints); }
public CoveredContext(PaintContext context,double x1,double y1,int color1,double x2,double y2,int color2,AffineTransform transform) { this.context = context; this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2; this.color1 = color1; this.color2 = color2; this.transform = transform; }
/** * Creates and returns a context used to generate the pattern. */ public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) { // Concatenate the patternTransform to xform if (patternTransform != null) { xform = new AffineTransform(xform); xform.concatenate(patternTransform); } if ((lastContext!= null) && lastContext.getColorModel().equals(cm)) { double[] p = new double[6]; double[] q = new double[6]; xform.getMatrix(p); lastContext.getUsr2Dev().getMatrix(q); if ((p[0] == q[0]) && (p[1] == q[1]) && (p[2] == q[2]) && (p[3] == q[3])) { if ((p[4] == q[4]) && (p[5] == q[5])) return lastContext; else return new PatternPaintContextWrapper (lastContext, (int)(q[4]-p[4]+0.5), (int)(q[5]-p[5]+0.5)); } } // System.out.println("CreateContext Called: " + this); // System.out.println("CM : " + cm); // System.out.println("xForm : " + xform); lastContext = new PatternPaintContext(cm, xform, hints, tile, patternRegion, overflow); return lastContext; }
/** * Creates and returns a PaintContext used to generate the color pattern, * for use by the internal rendering engine. * * @param cm {@link ColorModel} that receives * the <code>Paint</code> data. This is used only as a hint. * * @param deviceBounds the device space bounding box of the * graphics primitive being rendered * * @param userBounds the user space bounding box of the * graphics primitive being rendered * * @param transform the {@link AffineTransform} from user * space into device space * * @param hints the hints that the context object uses to choose * between rendering alternatives * * @return the {@link PaintContext} that generates color patterns. * * @see PaintContext */ public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform transform, RenderingHints hints) { // Can't modify the transform passed in... transform = new AffineTransform(transform); //incorporate the gradient transform transform.concatenate(gradientTransform); try { return new LinearGradientPaintContext(cm, deviceBounds, userBounds, transform, hints, start, end, fractions, this.getColors(), cycleMethod, colorSpace); } catch(NoninvertibleTransformException e) { e.printStackTrace(); throw new IllegalArgumentException("transform should be" + "invertible"); } }