Package com.lightcrafts.mediax.jai

Examples of com.lightcrafts.mediax.jai.RenderedOp$TCL


  throws RemoteException {

  Object obj = nodes.get(id);

  if (obj instanceof RenderedOp) {
      RenderedOp node = (RenderedOp)obj;
      node.setSource(new RMIServerProxy((serverName+"::"+sourceId),
                opName,
                null),
         index);
      ((PlanarImage)node.getSourceObject(index)).removeSinks();
  } else if (obj instanceof RenderableOp) {
      ((RenderableOp)obj).setSource(new RMIServerProxy((serverName +
                    "::" + sourceId),
                   opName,
                   null),
View Full Code Here


  throws RemoteException {

  RenderingHints oldHints = (RenderingHints)oldRHints.getObject();
  RenderingHints newHints = (RenderingHints)newRHints.getObject();

  RenderedOp op = (RenderedOp)nodes.get(id);

  OperationDescriptor od = (OperationDescriptor)
      JAI.getDefaultInstance().getOperationRegistry().
      getDescriptor("rendered", op.getOperationName());

  boolean samePBs = false;
  if (oldParamBlock == newParamBlock)
      samePBs = true;

  Vector oldSources = oldParamBlock.getSources();
  oldParamBlock.removeSources();
  Vector oldReplacedSources =
      JAIRMIUtil.replaceIdWithSources(oldSources,
              nodes,
              op.getOperationName(),
              op.getRenderingHints());
  oldParamBlock.setSources(oldReplacedSources);

  if (samePBs) {
      newParamBlock = oldParamBlock;
  } else {
      Vector newSources = newParamBlock.getSources();
      newParamBlock.removeSources();
      Vector newReplacedSources =
    JAIRMIUtil.replaceIdWithSources(newSources,
            nodes,
            op.getOperationName(),
            op.getRenderingHints());

      newParamBlock.setSources(newReplacedSources);
  }

  Object invalidRegion = od.getInvalidRegion("rendered",
View Full Code Here

     */
    public Rectangle mapSourceRect(Long id,
           Rectangle sourceRect,
           int sourceIndex) throws RemoteException {

  RenderedOp op = (RenderedOp)nodes.get(id);
  OpImage rendering = (OpImage)(op.getRendering());
  return rendering.mapSourceRect(sourceRect, sourceIndex);
    }
View Full Code Here

     * @return A <code>Rectangle</code> indicating the required source region.
     */
    public Rectangle mapDestRect(Long id, Rectangle destRect, int sourceIndex)
  throws RemoteException {

  RenderedOp op = (RenderedOp)nodes.get(id);
  OpImage rendering = (OpImage)(op.getRendering());
  return rendering.mapDestRect(destRect, sourceIndex);
    }
View Full Code Here

     */
    public synchronized Long handleEvent(Long renderedOpID, String propName,
           Object oldValue, Object newValue)
  throws RemoteException {

  RenderedOp op = (RenderedOp)nodes.get(renderedOpID);
  PlanarImage rendering = op.getRendering();

  // Get a new unique ID
  Long id = getRemoteID();
  // Cache the old rendering against the new id
  nodes.put(id, rendering);

  // Put the op's negotiated result values for its rendering too.
  setServerNegotiatedValues(id, (NegotiableCapabilitySet)
          negotiated.get(renderedOpID));

  // A PropertyChangeEventJAI with name "operationregistry",
  // "protocolname", "protocolandservername" or "servername" should
  // never be received here, since it is handled entirely on the
  // client side, so we don't handle those here.

  if (propName.equals("operationname")) {

      op.setOperationName((String)newValue);

  } else if (propName.equals("parameterblock")) {

      ParameterBlock newPB = (ParameterBlock)newValue;
      Vector newSrcs = newPB.getSources();
      newPB.removeSources();

      JAIRMIUtil.checkServerParameters(newPB, nodes);

      Vector replacedSources =
    JAIRMIUtil.replaceIdWithSources(newSrcs,
            nodes,
            op.getOperationName(),
            op.getRenderingHints());
      newPB.setSources(replacedSources);

      op.setParameterBlock(newPB);

      // Remove the newly created sinks of the srcs in the newPB
      Vector newSources = newPB.getSources();
            if(newSources != null && newSources.size() > 0) {
                Iterator it = newSources.iterator();
                while(it.hasNext()) {
                    Object src = it.next();
                    if(src instanceof PlanarImage) {
                        ((PlanarImage)src).removeSinks();
                    } else if(src instanceof CollectionImage) {
                        ((CollectionImage)src).removeSinks();
                    }
                }
            }

  } else if (propName.equals("sources")) {

      Vector replacedSources =
    JAIRMIUtil.replaceIdWithSources((Vector)newValue,
            nodes,
            op.getOperationName(),
            op.getRenderingHints());
      op.setSources(replacedSources);

      // Remove the newly created sinks for the replacedSources
      if(replacedSources != null && replacedSources.size() > 0) {
                Iterator it = replacedSources.iterator();
                while(it.hasNext()) {
                    Object src = it.next();
                    if(src instanceof PlanarImage) {
                        ((PlanarImage)src).removeSinks();
                    } else if(src instanceof CollectionImage) {
                        ((CollectionImage)src).removeSinks();
                    }
                }
            }


  } else if (propName.equals("parameters")) {

      Vector parameters = (Vector)newValue;
      JAIRMIUtil.checkServerParameters(parameters, nodes);
      op.setParameters(parameters);

  } else if (propName.equals("renderinghints")) {

      SerializableState newState = (SerializableState)newValue;
      op.setRenderingHints((RenderingHints)newState.getObject());
  }

  return id;
    }
View Full Code Here

                              Object opNode) {
        validate(name, opNode);

        if (name.equalsIgnoreCase("complex")) {
            if(opNode instanceof RenderedOp) {
                RenderedOp op = (RenderedOp)opNode;
                ParameterBlock pb = op.getParameterBlock();
                ImageFunction imFunc = (ImageFunction)pb.getObjectParameter(0);
                return imFunc.isComplex() ? Boolean.TRUE : Boolean.FALSE;
            } else if(opNode instanceof RenderableOp) {
                RenderableOp op = (RenderableOp)opNode;
                ParameterBlock pb = op.getParameterBlock();
                ImageFunction imFunc = (ImageFunction)pb.getObjectParameter(0);
                return imFunc.isComplex() ? Boolean.TRUE : Boolean.FALSE;
            }
        }
View Full Code Here

           int srcIndex,
           SerializableState srcInvalidRegion,
           Object oldRendering)
  throws RemoteException {

  RenderedOp op = (RenderedOp)nodes.get(renderedOpID);
  PlanarImage rendering = op.getRendering();

  // Get a new unique ID
  Long id = getRemoteID();
  // Cache the old rendering against the new id
  nodes.put(id, rendering);

  // Put the op's negotiated result values for its rendering too.
  setServerNegotiatedValues(id, (NegotiableCapabilitySet)
          negotiated.get(renderedOpID));

  PlanarImage oldSrcRendering = null, newSrcRendering = null;
  String serverNodeDesc = null;
  Object src = null;

  if (oldRendering instanceof String) {

      serverNodeDesc = (String)oldRendering;
      int index = serverNodeDesc.indexOf("::");
      boolean diffServer = index != -1;

      if (diffServer) {
    // Create an RMIServerProxy to access the node on a
    // different server
    oldSrcRendering = new RMIServerProxy(serverNodeDesc,
                 op.getOperationName(),
                 op.getRenderingHints());
      } else {

    src = nodes.get(Long.valueOf(serverNodeDesc));

    if (src instanceof RenderedOp) {
        oldSrcRendering = ((RenderedOp)src).getRendering();
    } else {
        oldSrcRendering =
      PlanarImage.wrapRenderedImage((RenderedImage)src);
    }
      }

  } else {
      oldSrcRendering =
    PlanarImage.wrapRenderedImage((RenderedImage)oldRendering);
  }

  Object srcObj = op.getSource(srcIndex);
  if (srcObj instanceof RenderedOp) {
      newSrcRendering = ((RenderedOp)srcObj).getRendering();
  } else if (srcObj instanceof RenderedImage) {
      newSrcRendering =
    PlanarImage.wrapRenderedImage((RenderedImage)srcObj);
  }

  Shape invalidRegion = (Shape)srcInvalidRegion.getObject();

  RenderingChangeEvent rcEvent =
      new RenderingChangeEvent((RenderedOp)op.getSource(srcIndex),
             oldSrcRendering,
             newSrcRendering,
             invalidRegion);
  op.propertyChange(rcEvent);

  return id;
    }
View Full Code Here

            Interpolation interp = Interpolation.getInstance(Interpolation.INTERP_BILINEAR);
            ParameterBlock params = new ParameterBlock();
            params.addSource(image);
            params.add(transform);
            params.add(interp);
            RenderedOp scaled = JAI.create("Affine", params, formatHints);

            g.drawRenderedImage(scaled, new AffineTransform());

            scaled.dispose();
        }

        g.setClip(oldClip);
    }
View Full Code Here

    public Object getProperty(String name, 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.
            PlanarImage src = (PlanarImage)pb.getRenderedSource(0);
            Object roiProperty = src.getProperty("ROI");
            if(roiProperty == null ||
               roiProperty == java.awt.Image.UndefinedProperty ||
               !(roiProperty instanceof ROI)) {
                return java.awt.Image.UndefinedProperty;
            }
            ROI roi = (ROI)roiProperty;

            // Determine the effective destination bounds.
            Rectangle dstBounds = null;
            PlanarImage dst = op.getRendering();
            if(dst instanceof AreaOpImage &&
               ((AreaOpImage)dst).getBorderExtender() == null) {
                AreaOpImage aoi = (AreaOpImage)dst;
                dstBounds =
                    new Rectangle(aoi.getMinX() + aoi.getLeftPadding(),
View Full Code Here

    // Invert the color channels of the given BufferedImage but not the
    // alpha channel.  This works by assuming that band 3 is the alpha,
    // which appears to be true for BufferedImages read from resources by
    // ImageIO.read() and constructed above in invertIcon().
    private static BufferedImage invertImageWithAlpha(BufferedImage image) {
        RenderedOp alpha =
            BandSelectDescriptor.create(image, new int[] { 3 }, null);
        RenderedOp colors =
            BandSelectDescriptor.create(image, new int[] { 0, 1, 2 }, null);
        colors = InvertDescriptor.create(colors, null);
        RenderedOp op = BandMergeDescriptor.create(colors, alpha, null);
        return op.getAsBufferedImage();
    }
View Full Code Here

TOP

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

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.