Package java.awt.image.renderable

Examples of java.awt.image.renderable.RenderableImage


        if (numSources == 0) {
            return null;
        }

        RenderableImage src = paramBlock.getRenderableSource(0);
        Rectangle2D.Float box1 = new Rectangle2D.Float(src.getMinX(),
                                                       src.getMinY(),
                                                       src.getWidth(),
                                                       src.getHeight());

        for (int i = 1; i < numSources; i++) {
            src  = paramBlock.getRenderableSource(i);
            Rectangle2D.Float box2 =
                new Rectangle2D.Float(src.getMinX(), src.getMinY(),
                                      src.getWidth(), src.getHeight());
            box1 = (Rectangle2D.Float)box1.createIntersection(box2);
            if(box1.isEmpty()) {
                break;
            }
        }
View Full Code Here


                 i,
                 renderContext,
                 nodeSupport.getParameterBlock(),
                 this);

      RenderableImage src = (RenderableImage)source;
      rdrdImage = src.createRendering(rcOut);
        else if (source instanceof RenderedOp) {
      rdrdImage = ((RenderedOp)source).getRendering();
        } else if (source instanceof RenderedImage) {
      rdrdImage = (RenderedImage)source;
        }
View Full Code Here

                for (int i = 0; i < sources.size(); i++) {
                    RenderContext rcOut =
                        crif.mapRenderContext(i, rcIn,
                                              renderedPB,
                                              this);
                    RenderableImage src =
                        (RenderableImage)sources.elementAt(i);
                    RenderedImage renderedImage = src.createRendering(rcOut);
                    if (renderedImage == null) {
                        return null;
                    }
                   
                    // Add this rendered image to the ParameterBlock's
View Full Code Here

     * Gets the bounding box for the output of <code>ScaleOpImage</code>.
     * This method satisfies the implementation of CRIF.
     */
    public Rectangle2D getBounds2D(ParameterBlock paramBlock) {       

        RenderableImage source = paramBlock.getRenderableSource(0);

        float scale_x = paramBlock.getFloatParameter(0);
        float scale_y = paramBlock.getFloatParameter(1);
        float trans_x = paramBlock.getFloatParameter(2);
        float trans_y = paramBlock.getFloatParameter(3);
        Interpolation interp = (Interpolation)paramBlock.getObjectParameter(4);

  // Get the source dimensions
  float x0 = (float)source.getMinX();
  float y0 = (float)source.getMinY() ;
  float w = (float)source.getWidth();
  float h = (float)source.getHeight();
 
  // Forward map the source using x0, y0, w and h
  float d_x0 = x0 * scale_x + trans_x;
  float d_y0 = y0 * scale_y + trans_y;
  float d_w = w * scale_x;
 
View Full Code Here

     * Gets the bounding box for the output of <code>ScaleOpImage</code>.
     * This method satisfies the implementation of CRIF.
     */
    public Rectangle2D getBounds2D(ParameterBlock paramBlock) {       

        RenderableImage source = paramBlock.getRenderableSource(0);

        double scaleX = paramBlock.getDoubleParameter(0);
        double scaleY = paramBlock.getDoubleParameter(1);

  // Get the source dimensions
  float x0 = (float)source.getMinX();
  float y0 = (float)source.getMinY() ;
  float w = (float)source.getWidth();
  float h = (float)source.getHeight();
 
  // Forward map the source using x0, y0, w and h
  float d_x0 = (float)(x0 * scaleX);
  float d_y0 = (float)(y0 * scaleY);
  float d_w = (float)(w * scaleX);
 
View Full Code Here

    /**
     * Gets the bounding box for the output of <code>TranslateOpImage</code>.
     * This method satisfies the implementation of CRIF.
     */
    public Rectangle2D getBounds2D(ParameterBlock paramBlock) {
        RenderableImage source = paramBlock.getRenderableSource(0);

        float x_center = paramBlock.getFloatParameter(0);
        float y_center = paramBlock.getFloatParameter(1);
        float angle = paramBlock.getFloatParameter(2);
        Interpolation interp = (Interpolation)paramBlock.getObjectParameter(3);

        //
        // Convert angle to degrees (within some precision) given PI's
        // transcendantal nature. All this, to check if we can call
        // simpler methods like Copy or Transpose for certain angles
        // viz., 0, 90, 180, 270, 360, 450, .....
        //
        int dangle = 0;
        double tmp_angle = 180.0F * angle / Math.PI;
        double rnd_angle = Math.round(tmp_angle);

        if (Math.abs(rnd_angle - tmp_angle) < 0.0001) {
            dangle = (int) rnd_angle;
        } else {
            dangle = (int) tmp_angle;
        }

        //
        // It's a copy if angle is 0 degrees or multiple of 360 degrees
        //
        if (dangle % 360 == 0) {
            return new Rectangle2D.Float(source.getMinX(),
                                         source.getMinY(),
                                         source.getWidth(),
                                         source.getHeight());
        }

        //
        // It's a transpose if angle is mutiple of 270, 180, 90 degrees
        //
        float x0 = (float)source.getMinX();
        float y0 = (float)source.getMinY();
        float s_width = (float)source.getWidth();
        float s_height = (float)source.getHeight();
        float x1 = x0 + s_width - 1;
        float y1 = y0 + s_height - 1;

        float tx0 = 0;
        float ty0 = 0;
        float tx1 = 0;
        float ty1 = 0;

        if (dangle % 270 == 0) {
            if (dangle < 0) {
                // -270 degrees
                tx0 = s_height - y1 - 1;
                ty0 = x0;
                tx1 = s_height - y0 - 1;
                ty1 = x1;
                return new Rectangle2D.Float(tx0,
                                             ty0,
                                             tx1 - tx0 + 1,
                                             ty1 - ty0 + 1);
            } else {
                // 270 degrees
                tx0 = y0;
                ty0 = s_width - x1 - 1;
                tx1 = y1;
                ty1 = s_width - x0 - 1;
                return new Rectangle2D.Float(tx0,
                                             ty0,
                                             tx1 - tx0 + 1,
                                             ty1 - ty0 + 1);
            }
        }

        if (dangle % 180 == 0) {
            tx0 = s_width - x1 - 1;
            ty0 = s_height - y1 - 1;
            tx1 = s_width - x0 - 1;
            ty1 = s_height - y0 - 1;
            // 180 degrees
            return new Rectangle2D.Float(tx0,
                                         ty0,
                                         tx1 - tx0 + 1,
                                         ty1 - ty0 + 1);
        }

        if (dangle % 90 == 0) {
            if (dangle < 0) {
                // -90 degrees
                tx0 = y0;
                ty0 = s_width - x1 - 1;
                tx1 = y1;
                ty1 = s_width - x0 - 1;
                return new Rectangle2D.Float(tx0,
                                             ty0,
                                             tx1 - tx0 + 1,
                                             ty1 - ty0 + 1);
            } else {
                // 90 degrees
                tx0 = s_height - y1 - 1;
                ty0 = x0;
                tx1 = s_height - y0 - 1;
                ty1 = x1;
                return new Rectangle2D.Float(tx0,
                                             ty0,
                                             tx1 - tx0 + 1,
                                             ty1 - ty0 + 1);
            }
        }

        //
        // It's a Affine
        //
        AffineTransform rotate =
            AffineTransform.getRotateInstance(angle, x_center, y_center);

        //
        // Get sx0,sy0 coordinates and width & height of the source
        //
        float sx0 = (float) source.getMinX();
        float sy0 = (float) source.getMinY();
        float sw = (float) source.getWidth();
        float sh = (float) source.getHeight();

        //
        // The 4 points (clockwise order) are
        //      (sx0, sy0),    (sx0+sw, sy0)
        //      (sx0, sy0+sh), (sx0+sw, sy0+sh)
View Full Code Here

        // Check for a SoftReference hashed on a ParameterBlock-derived key.
        Object key = getKey(paramBlock);
        SoftReference ref = (SoftReference)mresTable.get(key);

        // Retrieve the image from the SoftReference if possible.
        RenderableImage mres = null;
        if(ref != null && (mres = (RenderableImage)ref.get()) == null) {
            // null referent: remove the ParameterBlock key from the Hashtable.
            mresTable.remove(key);
        }
View Full Code Here

     * in the renderable layer. This method satisfies the
     * implementation of CRIF.
     */
    public RenderedImage create(RenderContext renderContext,
                                ParameterBlock paramBlock) {
        RenderableImage mres = createRenderable(paramBlock);

        return mres.createRendering(renderContext);
    }
View Full Code Here

     * Gets the bounding box for the output of <code>SubsampleBinaryToGrayOpImage</code>.
     * This method satisfies the implementation of CRIF.
     */
    public Rectangle2D getBounds2D(ParameterBlock paramBlock) {       

        RenderableImage source = paramBlock.getRenderableSource(0);

        float scale_x = paramBlock.getFloatParameter(0);
        float scale_y = paramBlock.getFloatParameter(1);

  // Get the source dimensions
  float x0 = (float)source.getMinX();
  float y0 = (float)source.getMinY() ;
  float w = (float)source.getWidth();
  float h = (float)source.getHeight();
 
  // Forward map the source using x0, y0, w and h
  float d_x0 = x0 * scale_x;
  float d_y0 = y0 * scale_y;
  float d_w = w * scale_x;
 
View Full Code Here

     */
    public RenderedImage create(RenderContext renderContext,
                                ParameterBlock paramBlock) {

  // Get the two renderable alpha images from the parameter block
  RenderableImage alphaImage1 =
      (RenderableImage)paramBlock.getObjectParameter(0);
  RenderableImage alphaImage2 =
      (RenderableImage)paramBlock.getObjectParameter(1);

  // Cause the two renderable alpha images to be rendered
  RenderedImage rAlphaImage1 =
      alphaImage1.createRendering(renderContext);
  RenderedImage rAlphaImage2 =
      alphaImage2.createRendering(renderContext);

  ParameterBlock newPB = (ParameterBlock)paramBlock.clone();

  // Replace the renderable alpha images in the ParameterBlock with
  // their renderings
View Full Code Here

TOP

Related Classes of java.awt.image.renderable.RenderableImage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.