Package com.lightcrafts.mediax.jai

Examples of com.lightcrafts.mediax.jai.RenderedOp


                              Object opNode) {
        validate(name, opNode);

        if(opNode instanceof RenderedOp &&
           name.equalsIgnoreCase("roi")) {
            RenderedOp op = (RenderedOp)opNode;

            ParameterBlock pb = op.getParameterBlock();

            // Retrieve the rendered source image and its ROI.
            RenderedImage src = pb.getRenderedSource(0);

            Object property = src.getProperty("ROI");
            if (property == null ||
                property.equals(java.awt.Image.UndefinedProperty) ||
                !(property instanceof ROI)) {
                return java.awt.Image.UndefinedProperty;
            }
            ROI srcROI = (ROI)property;

            // Determine the effective source bounds.
            Rectangle srcBounds = new Rectangle(src.getMinX(),
            src.getMinY(),
            src.getWidth(),
            src.getHeight());

            // If necessary, clip the ROI to the effective source bounds.
            if(!srcBounds.contains(srcROI.getBounds())) {
                srcROI = srcROI.intersect(new ROIShape(srcBounds));
            }

            // Retrieve the scale factors and translation values.
            float sx = pb.getFloatParameter(0);
            float sy = pb.getFloatParameter(1);

            // Create an equivalent transform.
            AffineTransform transform =
                new AffineTransform(sx, 0.0, 0.0, sy, 0.0, 0.0);

            // Create the scaled ROI.
            ROI dstROI = srcROI.transform(transform);

            // Retrieve the destination bounds.
            Rectangle dstBounds = op.getBounds();

            // If necessary, clip the warped ROI to the destination bounds.
            if(!dstBounds.contains(dstROI.getBounds())) {
                dstROI = dstROI.intersect(new ROIShape(dstBounds));
            }
View Full Code Here


            Object source = getNodeSource(i);
            Object ai = null;
      if (source instanceof RenderedOp) {

                RenderedOp src = (RenderedOp)source;
    ai = isNodeRendered ?
                    src.getRendering() :
                    src.createInstance();

            } else if ((source instanceof RenderedImage) ||
                       (source instanceof Collection)) {

                ai = source;
View Full Code Here

            throw new IllegalArgumentException(formatter.format(msgArg0));
        }

  // Find the id that refers to the corresponding RenderedOp on the
  // server
  RenderedOp op = (RenderedOp)node;
  Object rendering = op.getRendering();
  Long id = null;
  if (rendering instanceof RMIServerProxy) {
      id = ((RMIServerProxy)rendering).getRMIID();
  } else {
      throw new RuntimeException(
View Full Code Here

                // Construct a Collection of the RenderedOp nodes that
                // will be retained in the new CollectionImage.
                ArrayList commonNodes = new ArrayList(commonSources.size());
                it = oldRendering.iterator();
                while(it.hasNext()) {
                    RenderedOp node = (RenderedOp)it.next();
                    PlanarImage source = (PlanarImage)node.getSourceImage(0);
                    if(commonSources.contains(source)) {
                        commonNodes.add(node);
                    }
                }

                // Create a new CollectionImage.
                updatedCollection =
                    new AddConstToCollectionOpImage(newSource, newHints,
                                                    constants);

                // Remove from the new CollectionImage all nodes that
                // are common with the old CollectionImage.
                ArrayList newNodes = new ArrayList(oldRendering.size() -
                                                   commonSources.size());
                it = updatedCollection.iterator();
                while(it.hasNext()) {
                    RenderedOp node = (RenderedOp)it.next();
                    PlanarImage source = (PlanarImage)node.getSourceImage(0);
                    if(commonSources.contains(source)) {
                        it.remove();
                    }
                }
View Full Code Here

        // Derive the image if necessary.
        if(mres == null) {
            // Retrieve the source and parameters.
            RenderedImage source = paramBlock.getRenderedSource(0);
            RenderedOp downSampler =
                (RenderedOp)paramBlock.getObjectParameter(0);
            int maxLowResDim = paramBlock.getIntParameter(1);
            float minX = paramBlock.getFloatParameter(2);
            float minY = paramBlock.getFloatParameter(3);
            float height = paramBlock.getFloatParameter(4);
View Full Code Here

                              Object opNode) {
        validate(name, opNode);

        if(opNode instanceof RenderedOp &&
           name.equalsIgnoreCase("roi")) {
            RenderedOp op = (RenderedOp)opNode;

      ParameterBlock pb = op.getParameterBlock();

      // Retrieve the rendered source image and its ROI.
      RenderedImage src = pb.getRenderedSource(0);
      Object property = src.getProperty("ROI");
      if (property == null ||
    property.equals(java.awt.Image.UndefinedProperty) ||
    !(property instanceof ROI)) {
    return null;
      }
      ROI srcROI = (ROI)property;

      // Determine the effective source bounds.
      Rectangle srcBounds = null;
      PlanarImage dst = op.getRendering();
      if(dst instanceof WarpOpImage && !((OpImage)dst).hasExtender(0)) {
    WarpOpImage warpIm = (WarpOpImage)dst;
    srcBounds =
        new Rectangle(src.getMinX() + warpIm.getLeftPadding(),
          src.getMinY() + warpIm.getTopPadding(),
          src.getWidth() - warpIm.getWidth() + 1,
          src.getHeight() - warpIm.getHeight() + 1);
      } else {
    srcBounds = new Rectangle(src.getMinX(),
            src.getMinY(),
            src.getWidth(),
            src.getHeight());
      }

      // If necessary, clip the ROI to the effective source bounds.
      if(!srcBounds.contains(srcROI.getBounds())) {
    srcROI = srcROI.intersect(new ROIShape(srcBounds));
      }

      // Retrieve the scale factors
      float sx = 1.0F/pb.getIntParameter(1);
      float sy = 1.0F/pb.getIntParameter(2);

      // Create an equivalent transform.
      AffineTransform transform =
    new AffineTransform(sx, 0.0, 0.0, sy, 0, 0);

      // Create the scaled ROI.
      ROI dstROI = srcROI.transform(transform);

      // Retrieve the destination bounds.
      Rectangle dstBounds = op.getBounds();

      // If necessary, clip the warped ROI to the destination bounds.
      if(!dstBounds.contains(dstROI.getBounds())) {
    dstROI = dstROI.intersect(new ROIShape(dstBounds));
      }
View Full Code Here

                              Object opNode) {
        validate(name, opNode);

        if(opNode instanceof RenderedOp &&
           name.equalsIgnoreCase("roi")) {
            RenderedOp op = (RenderedOp)opNode;

            ParameterBlock pb = op.getParameterBlock();

            // Retrieve the rendered source image and its ROI.
            RenderedImage src = (RenderedImage)pb.getRenderedSource(0);
            Object property = src.getProperty("ROI");
            if (property == null ||
                property.equals(java.awt.Image.UndefinedProperty) ||
                !(property instanceof ROI)) {
                return java.awt.Image.UndefinedProperty;
            }

            // Return undefined also if source ROI is empty.
            ROI srcROI = (ROI)property;
            if (srcROI.getBounds().isEmpty()) {
                return java.awt.Image.UndefinedProperty;
            }

            // Retrieve the Interpolation object.
            Interpolation interp = (Interpolation)pb.getObjectParameter(1);

            // Determine the effective source bounds.
            Rectangle srcBounds = null;
            PlanarImage dst = op.getRendering();
            if (dst instanceof GeometricOpImage &&
                ((GeometricOpImage)dst).getBorderExtender() == null) {
                srcBounds =
                    new Rectangle(src.getMinX() + interp.getLeftPadding(),
                                  src.getMinY() + interp.getTopPadding(),
                                  src.getWidth() - interp.getWidth() + 1,
                                  src.getHeight() - interp.getHeight() + 1);
            } else {
                srcBounds = new Rectangle(src.getMinX(),
            src.getMinY(),
            src.getWidth(),
            src.getHeight());
            }

            // If necessary, clip the ROI to the effective source bounds.
            if(!srcBounds.contains(srcROI.getBounds())) {
                srcROI = srcROI.intersect(new ROIShape(srcBounds));
            }

            // Set the nearest neighbor interpolation object.
            Interpolation interpNN = interp instanceof InterpolationNearest ?
                interp :
                Interpolation.getInstance(Interpolation.INTERP_NEAREST);

            // Retrieve the Warp object.
            Warp warp = (Warp)pb.getObjectParameter(0);

            // Create the warped ROI.
            ROI dstROI = new ROI(JAI.create("warp", srcROI.getAsImage(),
                                            warp, interpNN));

            // Retrieve the destination bounds.
            Rectangle dstBounds = op.getBounds();

            // If necessary, clip the warped ROI to the destination bounds.
            if(!dstBounds.contains(dstROI.getBounds())) {
                dstROI = dstROI.intersect(new ROIShape(dstBounds));
            }
View Full Code Here

TOP

Related Classes of com.lightcrafts.mediax.jai.RenderedOp

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.