Package javax.media.jai

Examples of javax.media.jai.RenderingChangeEvent


  Long opID = oldRMISP.getRMIID();

  String propName = event.getPropertyName();
  if (event instanceof RenderingChangeEvent) {
      // Event is a RenderingChangeEvent
      RenderingChangeEvent rce = (RenderingChangeEvent)event;

      // Get index of source which changed.
      int idx = ((RenderedOp)node).getSources().indexOf(rce.getSource());

      PlanarImage oldSrcRendering = (PlanarImage)event.getOldValue();

      Object oldSrc = null;
      String serverNodeDesc = null;
      if (oldSrcRendering instanceof RMIServerProxy) {

    RMIServerProxy oldSrcRMISP = (RMIServerProxy)oldSrcRendering;

    if (oldSrcRMISP.getServerName().equalsIgnoreCase(
             this.serverName) == false) {
        serverNodeDesc = oldSrcRMISP.getServerName() + "::" +
      oldSrcRMISP.getRMIID();
    } else {
        serverNodeDesc = oldSrcRMISP.getRMIID().toString();
    }
    oldSrc = serverNodeDesc;
      } else if (oldSrcRendering instanceof Serializable) {
    oldSrc = oldSrcRendering;
      } else {
    oldSrc = new SerializableRenderedImage(oldSrcRendering);
      }

      Object srcInvalidRegion = rce.getInvalidRegion();
      SerializableState shapeState =
    SerializerFactory.getState((Shape)srcInvalidRegion, null);

      Long oldRenderingID = null;
      try {
View Full Code Here


    PlanarImage.wrapRenderedImage((RenderedImage)srcObj);
  }

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

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

                if (evt instanceof RenderingChangeEvent) {

                    // RenderingChangeEvent presumably from a source
        // RenderedOp.
                    RenderingChangeEvent rcEvent = (RenderingChangeEvent)evt;

                    // Get the invalidated region of the source.
                    srcInvalidRegion = rcEvent.getInvalidRegion();

                    // If entire source is invalid replace with source bounds.
                    if (srcInvalidRegion == null) {
                        srcInvalidRegion =
                            ((PlanarImage)rcEvent.getOldValue()).getBounds();
                    }
                } else {

                    // Get the invalidated region of the source.
                    srcInvalidRegion = (Shape)evt.getNewValue();

                    // If entire source is invalid replace with source bounds.
                    if (srcInvalidRegion == null) {
                        RenderedImage rSrc = (RenderedImage)evtSrc;
                        srcInvalidRegion =
                            new Rectangle(rSrc.getMinX(), rSrc.getMinY(),
                                          rSrc.getWidth(), rSrc.getHeight());
                    }
                }

                // Only process further if the rendering is a
    // PlanarImageServerProxy.
                if (!(theImage instanceof PlanarImageServerProxy)) {

                    // Clear the current rendering.
                    theImage = null;

                } else {

                    // Save the previous rendering as a PlanarImageServerProxy.
                    PlanarImageServerProxy oldPISP =
      (PlanarImageServerProxy)theImage;

                    // Cache source invalid bounds.
                    Rectangle srcInvalidBounds = srcInvalidRegion.getBounds();

                    // If bounds are empty, replace srcInvalidRegion with
                    // the complement of the image bounds within the
                    // bounds of all tiles.
                    if (srcInvalidBounds.isEmpty()) {
                        int x = oldPISP.tileXToX(oldPISP.getMinTileX());
                        int y = oldPISP.tileYToY(oldPISP.getMinTileY());
                        int w =
          oldPISP.getNumXTiles() * oldPISP.getTileWidth();
                        int h =
          oldPISP.getNumYTiles() * oldPISP.getTileHeight();
                        Rectangle tileBounds = new Rectangle(x, y, w, h);
                        Rectangle imageBounds = oldPISP.getBounds();
                        if (!tileBounds.equals(imageBounds)) {
                            Area tmpArea = new Area(tileBounds);
                            tmpArea.subtract(new Area(imageBounds));
                            srcInvalidRegion = tmpArea;
                            srcInvalidBounds = srcInvalidRegion.getBounds();
                        }
                    }

                    // ----- Determine invalid destination region. -----

                    boolean saveAllTiles = false;
                    ArrayList validTiles = null;
                    if (srcInvalidBounds.isEmpty()) {
                        invalidRegion = srcInvalidRegion;
                        saveAllTiles = true;

                    } else {

                        // Get index of source which changed.
                        int idx = nodeSources.indexOf(evtSrc);

                        // Determine bounds of invalid destination region.
                        Rectangle dstRegionBounds =
                            oldPISP.mapSourceRect(srcInvalidBounds, idx);

                        if (dstRegionBounds == null) {
                            dstRegionBounds = oldPISP.getBounds();
                        }

                        // Determine invalid destination region.
                        Point[] indices = getTileIndices(dstRegionBounds);
                        int numIndices = indices != null ? indices.length : 0;
                        GeneralPath gp = null;

                        for(int i = 0; i < numIndices; i++) {
                            if (i % 1000 == 0 && gp != null)
                                gp = new GeneralPath(new Area(gp));

                            Rectangle dstRect =
                                getTileRect(indices[i].x, indices[i].y);
                            Rectangle srcRect =
                                oldPISP.mapDestRect(dstRect, idx);
                            if(srcRect == null) {
                                gp = null;
                                break;
                            }
                            if(srcInvalidRegion.intersects(srcRect)) {
                                if(gp == null) {
                                    gp = new GeneralPath(dstRect);
                                } else {
                                    gp.append(dstRect, false);
                                }
                            } else {
                                if(validTiles == null) {
                                    validTiles = new ArrayList();
                                }
                                validTiles.add(indices[i]);
                            }
                        }

                        invalidRegion = (gp == null) ? null : new Area(gp);
                    }

                    // Retrieve the old TileCache.
                    TileCache oldCache = oldPISP.getTileCache();
        theImage = null;

                    // Only perform further processing if there is a cache
                    // and there are tiles to save.
                    if (oldCache != null &&
      (saveAllTiles || validTiles != null)) {

      // Create new rendering
      newEventRendering(protocolName,
            oldPISP,
            (PropertyChangeEventJAI)evt);

                        // Only perform further processing if the new
                        // rendering is an OpImage with a non-null TileCache.
                        if (theImage instanceof PlanarImageServerProxy &&
                           ((PlanarImageServerProxy)theImage).getTileCache() !=
         null) {
                            PlanarImageServerProxy newPISP =
        (PlanarImageServerProxy)theImage;
                            TileCache newCache = newPISP.getTileCache();

                            Object tileCacheMetric =
                                newPISP.getTileCacheMetric();

                            if (saveAllTiles) {
                                Raster[] tiles = oldCache.getTiles(oldPISP);
                                int numTiles = tiles == null ?
            0 : tiles.length;
                                for(int i = 0; i < numTiles; i++) {
                                    Raster tile = tiles[i];
                                    int tx = newPISP.XToTileX(tile.getMinX());
                                    int ty = newPISP.YToTileY(tile.getMinY());
                                    newCache.add(newPISP,
                                                 tx, ty, tile,
                   tileCacheMetric);
                                }
                            } else { // save some, but not all, tiles
                                int numValidTiles = validTiles.size();
                                for(int i = 0; i < numValidTiles; i++) {
                                    Point tileIndex = (Point)validTiles.get(i);
                                    Raster tile =
                                        oldCache.getTile(oldPISP,
                                                         tileIndex.x,
                                                         tileIndex.y);
                                    if (tile != null) {
                                        newCache.add(newPISP,
                                                     tileIndex.x,
                                                     tileIndex.y,
                                                     tile,
                 tileCacheMetric);
                                    }
                                }
                            }
                        }
                    }
                }
            } else { // not op name or registry change nor RenderingChangeEvent
                ParameterBlock oldPB = null;
                ParameterBlock newPB = null;
    String oldServerName = serverName;
    String newServerName = serverName;

                boolean checkInvalidRegion = false;

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

        if (theImage instanceof PlanarImageServerProxy) {
      newEventRendering(protocolName,
            (PlanarImageServerProxy)theImage,
            (PropertyChangeEventJAI)evt);
        } else {
      theImage = null;
      createRendering();
        }

        // Do not set checkInvalidRegion to true, since there
        // are no tiles to save for this case.

        shouldFireEvent = true;

        // XXX Do we need to do any evaluation of any
        // DeferredData parameters.

    } else if (propName.equals("parameterblock")) {
                    oldPB = (ParameterBlock)evt.getOldValue();
                    newPB = (ParameterBlock)evt.getNewValue();
                    checkInvalidRegion = true;
                } else if (propName.equals("sources")) {
                    // Replace source(s)
                    Vector params =
      nodeSupport.getParameterBlock().getParameters();
                    oldPB = new ParameterBlock((Vector)evt.getOldValue(),
                                               params);
                    newPB = new ParameterBlock((Vector)evt.getNewValue(),
                                               params);
                    checkInvalidRegion = true;
                } else if (propName.equals("parameters")) {
                    // Replace parameter(s)
                    oldPB = new ParameterBlock(nodeSources,
                                               (Vector)evt.getOldValue());
                    newPB = new ParameterBlock(nodeSources,
                                               (Vector)evt.getNewValue());
                    checkInvalidRegion = true;
                } else if (propName.equals("renderinghints")) {
                    oldPB = newPB = nodeSupport.getParameterBlock();
                    checkInvalidRegion = true;
                } else if (propName.equals("servername")) {
        oldPB = newPB = nodeSupport.getParameterBlock();
        oldServerName = (String)evt.getOldValue();
        newServerName = (String)evt.getNewValue();
        checkInvalidRegion = true;
    } else if (evt instanceof CollectionChangeEvent) {
        // Event from a CollectionOp source.
                    // Replace appropriate source.
                    int collectionIndex = nodeSources.indexOf(evtSrc);
                    Vector oldSources = (Vector)nodeSources.clone();
                    Vector newSources = (Vector)nodeSources.clone();
                    oldSources.set(collectionIndex, evt.getOldValue());
                    newSources.set(collectionIndex, evt.getNewValue());

                    Vector params =
                        nodeSupport.getParameterBlock().getParameters();

                    oldPB = new ParameterBlock(oldSources, params);
                    newPB = new ParameterBlock(newSources, params);

                    checkInvalidRegion = true;
                }

                if (checkInvalidRegion) {
                    // Set event flag.
                    shouldFireEvent = true;

                    // Get the associated RemoteDescriptor.
                    OperationRegistry registry = nodeSupport.getRegistry();
                    RemoteDescriptor odesc = (RemoteDescriptor)
                        registry.getDescriptor(RemoteDescriptor.class,
                                               protocolName);

        // XXX
                    // Evaluate any DeferredData parameters.
                    oldPB = ImageUtil.evaluateParameters(oldPB);
                    newPB = ImageUtil.evaluateParameters(newPB);

                    // Determine the invalid region.
                    invalidRegion = (Shape)
                        odesc.getInvalidRegion("rendered",
                 oldServerName,
                                               oldPB,
                                               oldHints,
                 newServerName,
                                               newPB,
                                               nodeSupport.getRenderingHints(),
                                               this);

                    if (invalidRegion == null ||
                       !(theImage instanceof PlanarImageServerProxy)) {
                        // Can't save any tiles; clear the rendering.
                        theImage = null;

                    } else {

                        // Create a new rendering.
                        PlanarImageServerProxy oldRendering =
          (PlanarImageServerProxy)theImage;

      newEventRendering(protocolName, oldRendering,
            (PropertyChangeEventJAI)evt);

                        // If the new rendering is also a
      // PlanarImageServerProxy, save some tiles.
                        if (theImage instanceof PlanarImageServerProxy &&
          oldRendering.getTileCache() != null &&
          ((PlanarImageServerProxy)theImage).getTileCache()
          != null) {
                            PlanarImageServerProxy newRendering =
        (PlanarImageServerProxy)theImage;

                            TileCache oldCache = oldRendering.getTileCache();
                            TileCache newCache = newRendering.getTileCache();

                            Object tileCacheMetric =
                                newRendering.getTileCacheMetric();

                            // If bounds are empty, replace invalidRegion with
                            // the complement of the image bounds within the
                            // bounds of all tiles.
                            if (invalidRegion.getBounds().isEmpty()) {
                                int x = oldRendering.tileXToX(
                                            oldRendering.getMinTileX());
                                int y = oldRendering.tileYToY(
                                            oldRendering.getMinTileY());
                                int w = oldRendering.getNumXTiles() *
                                    oldRendering.getTileWidth();
                                int h = oldRendering.getNumYTiles() *
                                    oldRendering.getTileHeight();
                                Rectangle tileBounds =
            new Rectangle(x, y, w, h);
                                Rectangle imageBounds =
                                    oldRendering.getBounds();
                                if (!tileBounds.equals(imageBounds)) {
                                    Area tmpArea = new Area(tileBounds);
                                    tmpArea.subtract(new Area(imageBounds));
                                    invalidRegion = tmpArea;
                                }
                            }

                            if (invalidRegion.getBounds().isEmpty()) {

                                // Save all tiles.
                                Raster[] tiles =
                                    oldCache.getTiles(oldRendering);
                                int numTiles = tiles == null ?
                                    0 : tiles.length;
                                for(int i = 0; i < numTiles; i++) {
                                    Raster tile = tiles[i];
                                    int tx =
                                        newRendering.XToTileX(tile.getMinX());
                                    int ty =
                                        newRendering.YToTileY(tile.getMinY());
                                    newCache.add(newRendering,
                                                 tx, ty, tile,
             tileCacheMetric);
                                }
                            } else {
                                // Copy tiles not in invalid region from old
                                // TileCache to new TileCache.
                                Raster[] tiles =
                                    oldCache.getTiles(oldRendering);
                                int numTiles = tiles == null ?
                                    0 : tiles.length;
                                for(int i = 0; i < numTiles; i++) {
                                    Raster tile = tiles[i];
                                    Rectangle bounds = tile.getBounds();
                                    if (!invalidRegion.intersects(bounds)) {
                                        newCache.add(
                newRendering,
                newRendering.XToTileX(bounds.x),
                newRendering.YToTileY(bounds.y),
                tile,
                tileCacheMetric);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Re-render the node. This will only occur if theImage
            // has been set to null above.
      if (theOldImage instanceof PlanarImageServerProxy &&
    theImage == null) {
    newEventRendering(protocolName,
          (PlanarImageServerProxy)theOldImage,
          (PropertyChangeEventJAI)evt);
      } else {
    createRendering();
      }

            // Fire an event if the flag was set.
            if (shouldFireEvent) {

                // Clear the synthetic and cached properties and reset the
                // property source.
    resetProperties(true);

                // Create the event object.
                RenderingChangeEvent rcEvent =
                    new RenderingChangeEvent(this, theOldImage, theImage,
                                             invalidRegion);

                // Fire to all registered listeners.
                eventManager.firePropertyChange(rcEvent);

View Full Code Here

/*  362 */     Long opID = oldRMISP.getRMIID();
/*      */
/*  364 */     String propName = event.getPropertyName();
/*  365 */     if ((event instanceof RenderingChangeEvent))
/*      */     {
/*  367 */       RenderingChangeEvent rce = (RenderingChangeEvent)event;
/*      */
/*  370 */       int idx = ((RenderedOp)node).getSources().indexOf(rce.getSource());
/*      */
/*  372 */       PlanarImage oldSrcRendering = (PlanarImage)event.getOldValue();
/*      */
/*  374 */       Object oldSrc = null;
/*  375 */       String serverNodeDesc = null;
/*  376 */       if ((oldSrcRendering instanceof RMIServerProxy))
/*      */       {
/*  378 */         RMIServerProxy oldSrcRMISP = (RMIServerProxy)oldSrcRendering;
/*      */
/*  380 */         if (!oldSrcRMISP.getServerName().equalsIgnoreCase(this.serverName))
/*      */         {
/*  382 */           serverNodeDesc = oldSrcRMISP.getServerName() + "::" + oldSrcRMISP.getRMIID();
/*      */         }
/*      */         else {
/*  385 */           serverNodeDesc = oldSrcRMISP.getRMIID().toString();
/*      */         }
/*  387 */         oldSrc = serverNodeDesc;
/*  388 */       } else if ((oldSrcRendering instanceof Serializable)) {
/*  389 */         oldSrc = oldSrcRendering;
/*      */       } else {
/*  391 */         oldSrc = new SerializableRenderedImage(oldSrcRendering);
/*      */       }
/*      */
/*  394 */       Object srcInvalidRegion = rce.getInvalidRegion();
/*  395 */       SerializableState shapeState = SerializerFactory.getState((Shape)srcInvalidRegion, null);
/*      */
/*  398 */       Long oldRenderingID = null;
/*      */       try {
/*  400 */         oldRenderingID = this.remoteImage.handleEvent(opID, idx, shapeState, oldSrc);
View Full Code Here

/*  570 */         shouldFireEvent = true;
/*  571 */         Shape srcInvalidRegion = null;
/*      */
/*  573 */         if ((evt instanceof RenderingChangeEvent))
/*      */         {
/*  577 */           RenderingChangeEvent rcEvent = (RenderingChangeEvent)evt;
/*      */
/*  580 */           srcInvalidRegion = rcEvent.getInvalidRegion();
/*      */
/*  583 */           if (srcInvalidRegion == null) {
/*  584 */             srcInvalidRegion = ((PlanarImage)rcEvent.getOldValue()).getBounds();
/*      */           }
/*      */
/*      */         }
/*      */         else
/*      */         {
/*  590 */           srcInvalidRegion = (Shape)evt.getNewValue();
/*      */
/*  593 */           if (srcInvalidRegion == null) {
/*  594 */             RenderedImage rSrc = (RenderedImage)evtSrc;
/*  595 */             srcInvalidRegion = new Rectangle(rSrc.getMinX(), rSrc.getMinY(), rSrc.getWidth(), rSrc.getHeight());
/*      */           }
/*      */
/*      */         }
/*      */
/*  603 */         if (!(this.theImage instanceof PlanarImageServerProxy))
/*      */         {
/*  606 */           this.theImage = null;
/*      */         }
/*      */         else
/*      */         {
/*  611 */           PlanarImageServerProxy oldPISP = (PlanarImageServerProxy)this.theImage;
/*      */
/*  615 */           Rectangle srcInvalidBounds = srcInvalidRegion.getBounds();
/*      */
/*  620 */           if (srcInvalidBounds.isEmpty()) {
/*  621 */             int x = oldPISP.tileXToX(oldPISP.getMinTileX());
/*  622 */             int y = oldPISP.tileYToY(oldPISP.getMinTileY());
/*  623 */             int w = oldPISP.getNumXTiles() * oldPISP.getTileWidth();
/*      */
/*  625 */             int h = oldPISP.getNumYTiles() * oldPISP.getTileHeight();
/*      */
/*  627 */             Rectangle tileBounds = new Rectangle(x, y, w, h);
/*  628 */             Rectangle imageBounds = oldPISP.getBounds();
/*  629 */             if (!tileBounds.equals(imageBounds)) {
/*  630 */               Area tmpArea = new Area(tileBounds);
/*  631 */               tmpArea.subtract(new Area(imageBounds));
/*  632 */               srcInvalidRegion = tmpArea;
/*  633 */               srcInvalidBounds = srcInvalidRegion.getBounds();
/*      */             }
/*      */
/*      */           }
/*      */
/*  639 */           boolean saveAllTiles = false;
/*  640 */           ArrayList validTiles = null;
/*  641 */           if (srcInvalidBounds.isEmpty()) {
/*  642 */             invalidRegion = srcInvalidRegion;
/*  643 */             saveAllTiles = true;
/*      */           }
/*      */           else
/*      */           {
/*  648 */             int idx = nodeSources.indexOf(evtSrc);
/*      */
/*  651 */             Rectangle dstRegionBounds = oldPISP.mapSourceRect(srcInvalidBounds, idx);
/*      */
/*  654 */             if (dstRegionBounds == null) {
/*  655 */               dstRegionBounds = oldPISP.getBounds();
/*      */             }
/*      */
/*  659 */             Point[] indices = getTileIndices(dstRegionBounds);
/*  660 */             int numIndices = indices != null ? indices.length : 0;
/*  661 */             GeneralPath gp = null;
/*      */
/*  663 */             for (int i = 0; i < numIndices; i++) {
/*  664 */               if ((i % 1000 == 0) && (gp != null)) {
/*  665 */                 gp = new GeneralPath(new Area(gp));
/*      */               }
/*  667 */               Rectangle dstRect = getTileRect(indices[i].x, indices[i].y);
/*      */
/*  669 */               Rectangle srcRect = oldPISP.mapDestRect(dstRect, idx);
/*      */
/*  671 */               if (srcRect == null) {
/*  672 */                 gp = null;
/*  673 */                 break;
/*      */               }
/*  675 */               if (srcInvalidRegion.intersects(srcRect)) {
/*  676 */                 if (gp == null)
/*  677 */                   gp = new GeneralPath(dstRect);
/*      */                 else
/*  679 */                   gp.append(dstRect, false);
/*      */               }
/*      */               else {
/*  682 */                 if (validTiles == null) {
/*  683 */                   validTiles = new ArrayList();
/*      */                 }
/*  685 */                 validTiles.add(indices[i]);
/*      */               }
/*      */             }
/*      */
/*  689 */             invalidRegion = gp == null ? null : new Area(gp);
/*      */           }
/*      */
/*  693 */           TileCache oldCache = oldPISP.getTileCache();
/*  694 */           this.theImage = null;
/*      */
/*  698 */           if ((oldCache != null) && ((saveAllTiles) || (validTiles != null)))
/*      */           {
/*  702 */             newEventRendering(this.protocolName, oldPISP, (PropertyChangeEventJAI)evt);
/*      */
/*  708 */             if (((this.theImage instanceof PlanarImageServerProxy)) && (((PlanarImageServerProxy)this.theImage).getTileCache() != null))
/*      */             {
/*  711 */               PlanarImageServerProxy newPISP = (PlanarImageServerProxy)this.theImage;
/*      */
/*  713 */               TileCache newCache = newPISP.getTileCache();
/*      */
/*  715 */               Object tileCacheMetric = newPISP.getTileCacheMetric();
/*      */
/*  718 */               if (saveAllTiles) {
/*  719 */                 Raster[] tiles = oldCache.getTiles(oldPISP);
/*  720 */                 int numTiles = tiles == null ? 0 : tiles.length;
/*      */
/*  722 */                 for (int i = 0; i < numTiles; i++) {
/*  723 */                   Raster tile = tiles[i];
/*  724 */                   int tx = newPISP.XToTileX(tile.getMinX());
/*  725 */                   int ty = newPISP.YToTileY(tile.getMinY());
/*  726 */                   newCache.add(newPISP, tx, ty, tile, tileCacheMetric);
/*      */                 }
/*      */               }
/*      */               else
/*      */               {
/*  731 */                 int numValidTiles = validTiles.size();
/*  732 */                 for (int i = 0; i < numValidTiles; i++) {
/*  733 */                   Point tileIndex = (Point)validTiles.get(i);
/*  734 */                   Raster tile = oldCache.getTile(oldPISP, tileIndex.x, tileIndex.y);
/*      */
/*  738 */                   if (tile != null) {
/*  739 */                     newCache.add(newPISP, tileIndex.x, tileIndex.y, tile, tileCacheMetric);
/*      */                   }
/*      */                 }
/*      */               }
/*      */             }
/*      */           }
/*      */
/*      */         }
/*      */
/*      */       }
/*      */       else
/*      */       {
/*  751 */         ParameterBlock oldPB = null;
/*  752 */         ParameterBlock newPB = null;
/*  753 */         String oldServerName = this.serverName;
/*  754 */         String newServerName = this.serverName;
/*      */
/*  756 */         boolean checkInvalidRegion = false;
/*      */
/*  758 */         if (propName.equals("operationname"))
/*      */         {
/*  760 */           if ((this.theImage instanceof PlanarImageServerProxy)) {
/*  761 */             newEventRendering(this.protocolName, (PlanarImageServerProxy)this.theImage, (PropertyChangeEventJAI)evt);
/*      */           }
/*      */           else
/*      */           {
/*  765 */             this.theImage = null;
/*  766 */             createRendering();
/*      */           }
/*      */
/*  772 */           shouldFireEvent = true;
/*      */         }
/*  777 */         else if (propName.equals("parameterblock")) {
/*  778 */           oldPB = (ParameterBlock)evt.getOldValue();
/*  779 */           newPB = (ParameterBlock)evt.getNewValue();
/*  780 */           checkInvalidRegion = true;
/*  781 */         } else if (propName.equals("sources"))
/*      */         {
/*  783 */           Vector params = this.nodeSupport.getParameterBlock().getParameters();
/*      */
/*  785 */           oldPB = new ParameterBlock((Vector)evt.getOldValue(), params);
/*      */
/*  787 */           newPB = new ParameterBlock((Vector)evt.getNewValue(), params);
/*      */
/*  789 */           checkInvalidRegion = true;
/*  790 */         } else if (propName.equals("parameters"))
/*      */         {
/*  792 */           oldPB = new ParameterBlock(nodeSources, (Vector)evt.getOldValue());
/*      */
/*  794 */           newPB = new ParameterBlock(nodeSources, (Vector)evt.getNewValue());
/*      */
/*  796 */           checkInvalidRegion = true;
/*  797 */         } else if (propName.equals("renderinghints")) {
/*  798 */           oldPB = newPB = this.nodeSupport.getParameterBlock();
/*  799 */           checkInvalidRegion = true;
/*  800 */         } else if (propName.equals("servername")) {
/*  801 */           oldPB = newPB = this.nodeSupport.getParameterBlock();
/*  802 */           oldServerName = (String)evt.getOldValue();
/*  803 */           newServerName = (String)evt.getNewValue();
/*  804 */           checkInvalidRegion = true;
/*  805 */         } else if ((evt instanceof CollectionChangeEvent))
/*      */         {
/*  808 */           int collectionIndex = nodeSources.indexOf(evtSrc);
/*  809 */           Vector oldSources = (Vector)nodeSources.clone();
/*  810 */           Vector newSources = (Vector)nodeSources.clone();
/*  811 */           oldSources.set(collectionIndex, evt.getOldValue());
/*  812 */           newSources.set(collectionIndex, evt.getNewValue());
/*      */
/*  814 */           Vector params = this.nodeSupport.getParameterBlock().getParameters();
/*      */
/*  817 */           oldPB = new ParameterBlock(oldSources, params);
/*  818 */           newPB = new ParameterBlock(newSources, params);
/*      */
/*  820 */           checkInvalidRegion = true;
/*      */         }
/*      */
/*  823 */         if (checkInvalidRegion)
/*      */         {
/*  825 */           shouldFireEvent = true;
/*      */
/*  828 */           OperationRegistry registry = this.nodeSupport.getRegistry();
/*  829 */           RemoteDescriptor odesc = (RemoteDescriptor)registry.getDescriptor(RemoteDescriptor.class, this.protocolName);
/*      */
/*  835 */           oldPB = ImageUtil.evaluateParameters(oldPB);
/*  836 */           newPB = ImageUtil.evaluateParameters(newPB);
/*      */
/*  839 */           invalidRegion = (Shape)odesc.getInvalidRegion("rendered", oldServerName, oldPB, this.oldHints, newServerName, newPB, this.nodeSupport.getRenderingHints(), this);
/*      */
/*  849 */           if ((invalidRegion == null) || (!(this.theImage instanceof PlanarImageServerProxy)))
/*      */           {
/*  852 */             this.theImage = null;
/*      */           }
/*      */           else
/*      */           {
/*  857 */             PlanarImageServerProxy oldRendering = (PlanarImageServerProxy)this.theImage;
/*      */
/*  860 */             newEventRendering(this.protocolName, oldRendering, (PropertyChangeEventJAI)evt);
/*      */
/*  865 */             if (((this.theImage instanceof PlanarImageServerProxy)) && (oldRendering.getTileCache() != null) && (((PlanarImageServerProxy)this.theImage).getTileCache() != null))
/*      */             {
/*  869 */               PlanarImageServerProxy newRendering = (PlanarImageServerProxy)this.theImage;
/*      */
/*  872 */               TileCache oldCache = oldRendering.getTileCache();
/*  873 */               TileCache newCache = newRendering.getTileCache();
/*      */
/*  875 */               Object tileCacheMetric = newRendering.getTileCacheMetric();
/*      */
/*  881 */               if (invalidRegion.getBounds().isEmpty()) {
/*  882 */                 int x = oldRendering.tileXToX(oldRendering.getMinTileX());
/*      */
/*  884 */                 int y = oldRendering.tileYToY(oldRendering.getMinTileY());
/*      */
/*  886 */                 int w = oldRendering.getNumXTiles() * oldRendering.getTileWidth();
/*      */
/*  888 */                 int h = oldRendering.getNumYTiles() * oldRendering.getTileHeight();
/*      */
/*  890 */                 Rectangle tileBounds = new Rectangle(x, y, w, h);
/*      */
/*  892 */                 Rectangle imageBounds = oldRendering.getBounds();
/*      */
/*  894 */                 if (!tileBounds.equals(imageBounds)) {
/*  895 */                   Area tmpArea = new Area(tileBounds);
/*  896 */                   tmpArea.subtract(new Area(imageBounds));
/*  897 */                   invalidRegion = tmpArea;
/*      */                 }
/*      */               }
/*      */
/*  901 */               if (invalidRegion.getBounds().isEmpty())
/*      */               {
/*  904 */                 Raster[] tiles = oldCache.getTiles(oldRendering);
/*      */
/*  906 */                 int numTiles = tiles == null ? 0 : tiles.length;
/*      */
/*  908 */                 for (int i = 0; i < numTiles; i++) {
/*  909 */                   Raster tile = tiles[i];
/*  910 */                   int tx = newRendering.XToTileX(tile.getMinX());
/*      */
/*  912 */                   int ty = newRendering.YToTileY(tile.getMinY());
/*      */
/*  914 */                   newCache.add(newRendering, tx, ty, tile, tileCacheMetric);
/*      */                 }
/*      */
/*      */               }
/*      */               else
/*      */               {
/*  921 */                 Raster[] tiles = oldCache.getTiles(oldRendering);
/*      */
/*  923 */                 int numTiles = tiles == null ? 0 : tiles.length;
/*      */
/*  925 */                 for (int i = 0; i < numTiles; i++) {
/*  926 */                   Raster tile = tiles[i];
/*  927 */                   Rectangle bounds = tile.getBounds();
/*  928 */                   if (!invalidRegion.intersects(bounds)) {
/*  929 */                     newCache.add(newRendering, newRendering.XToTileX(bounds.x), newRendering.YToTileY(bounds.y), tile, tileCacheMetric);
/*      */                   }
/*      */
/*      */                 }
/*      */
/*      */               }
/*      */
/*      */             }
/*      */
/*      */           }
/*      */
/*      */         }
/*      */
/*      */       }
/*      */
/*  945 */       if (((theOldImage instanceof PlanarImageServerProxy)) && (this.theImage == null))
/*      */       {
/*  947 */         newEventRendering(this.protocolName, (PlanarImageServerProxy)theOldImage, (PropertyChangeEventJAI)evt);
/*      */       }
/*      */       else
/*      */       {
/*  951 */         createRendering();
/*      */       }
/*      */
/*  955 */       if (shouldFireEvent)
/*      */       {
/*  959 */         resetProperties(true);
/*      */
/*  962 */         RenderingChangeEvent rcEvent = new RenderingChangeEvent(this, theOldImage, this.theImage, invalidRegion);
/*      */
/*  967 */         this.eventManager.firePropertyChange(rcEvent);
/*      */
/*  970 */         Vector sinks = getSinks();
/*  971 */         if (sinks != null) {
View Full Code Here

TOP

Related Classes of javax.media.jai.RenderingChangeEvent

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.