當前位置: 首頁>>代碼示例>>Java>>正文


Java PaintContext類代碼示例

本文整理匯總了Java中java.awt.PaintContext的典型用法代碼示例。如果您正苦於以下問題:Java PaintContext類的具體用法?Java PaintContext怎麽用?Java PaintContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PaintContext類屬於java.awt包,在下文中一共展示了PaintContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createContext

import java.awt.PaintContext; //導入依賴的package包/類
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;
}
 
開發者ID:havkarl,項目名稱:gogui2,代碼行數:24,代碼來源:RadialGradientPaint.java

示例2: createContext

import java.awt.PaintContext; //導入依賴的package包/類
@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;
}
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:23,代碼來源:HalftoneGradient.java

示例3: createContext

import java.awt.PaintContext; //導入依賴的package包/類
@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);
}
 
開發者ID:sechel,項目名稱:jtem-halfedgetools,代碼行數:21,代碼來源:AffineTexturePaint.java

示例4: createContext

import java.awt.PaintContext; //導入依賴的package包/類
/** 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);
}
 
開發者ID:jhkst,項目名稱:pdf-renderer-noawt,代碼行數:20,代碼來源:ShaderType2.java

示例5: createContext

import java.awt.PaintContext; //導入依賴的package包/類
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;
}
 
開發者ID:ryanbhayward,項目名稱:hexgui,代碼行數:20,代碼來源:RadialGradientPaint.java

示例6: fillMultiRectAreaPaint

import java.awt.PaintContext; //導入依賴的package包/類
/**
 * 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();
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:28,代碼來源:CommonGraphics2D.java

示例7: startSequence

import java.awt.PaintContext; //導入依賴的package包/類
@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;
}
 
開發者ID:bourgesl,項目名稱:marlin-renderer,代碼行數:23,代碼來源:GeneralCompositePipe.java

示例8: createContext

import java.awt.PaintContext; //導入依賴的package包/類
/**
 * {@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);
}
 
開發者ID:jedwards1211,項目名稱:breakout,代碼行數:22,代碼來源:ParamGradientMapPaint.java

示例9: TileContext

import java.awt.PaintContext; //導入依賴的package包/類
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;
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:AlphaPaintPipe.java

示例10: startSequence

import java.awt.PaintContext; //導入依賴的package包/類
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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:11,代碼來源:AlphaPaintPipe.java

示例11: TileContext

import java.awt.PaintContext; //導入依賴的package包/類
public TileContext(SunGraphics2D sg, PaintContext pCtx,
                   CompositeContext cCtx, ColorModel cModel) {
    sunG2D = sg;
    paintCtxt = pCtx;
    compCtxt = cCtx;
    compModel = cModel;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:8,代碼來源:GeneralCompositePipe.java

示例12: startSequence

import java.awt.PaintContext; //導入依賴的package包/類
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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:14,代碼來源:GeneralCompositePipe.java

示例13: createContext

import java.awt.PaintContext; //導入依賴的package包/類
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);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:13,代碼來源:PgramUserBoundsTest.java

示例14: createContext

import java.awt.PaintContext; //導入依賴的package包/類
@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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:CrashPaintTest.java

示例15: createContext

import java.awt.PaintContext; //導入依賴的package包/類
/**
 * 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 );
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:12,代碼來源:TriColorRoundGradientPaint.java


注:本文中的java.awt.PaintContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。