Package java.awt.geom

Examples of java.awt.geom.Area$Intersection


                    baseColors));
        }
        //new Color[]{new Color(0xfdad11), new Color(0xf69c18), new Color(0xf7a427), new Color(0xf0a85c)}));
        gfx.fillRect(x + 1, y + 1, width - 2, height - 2);
        // inner background
        Area base = new Area(new Rectangle(x + 2, y + 1, width - 4, height - 3));
        base.subtract(new Area(new Rectangle(x + 2, y + height - 3, 1, 1)));
        base.subtract(new Area(new Rectangle(x + width - 3, y + height - 3, 1, 1)));
        if (2 != height - 4) {
            gfx.setPaint(JideSwingUtilities.getLinearGradientPaint(x + 2, y + 2, x + 2, y + height - 4,
                    new float[]{.39f, .4f, 1f},
                    innerBackgroundColors));
        }
View Full Code Here


    private Collection contours;
    private Area outerArea;

    ContourRegion(Collection contours) {
        this.contours = contours;
        outerArea = new Area();
        for (Iterator i=contours.iterator(); i.hasNext(); ) {
            Contour contour = (Contour) i.next();
            Shape outerShape = contour.getOuterShape();
            outerArea.add(new Area(outerShape));
        }
    }
View Full Code Here

        maxHeight *= 1.3;   // extra vertical space is nice

        // Pad with empty space above and below
        double inset = (size.height - count * maxHeight) / 2.;

        Area area = new Area();
        for (int n=0; n<count; n++) {
            // Distribute vertically:
            double h = inset + n * maxHeight;
            // Center horizontally:
            double w = (size.width - widths[n]) / 2.;
            AffineTransform xform = AffineTransform.getTranslateInstance(w, h);
            shapes[n] = xform.createTransformedShape(shapes[n]);
            area.add(new Area(shapes[n]));
        }
        ShapeRegion region = new ShapeRegion(area);
        return region;
    }
View Full Code Here

    double      angDeg, angRad, dx, dy;
    double      speakerWidth  = Math.max( 4, Math.min( 10, deltaAngle / 2 ));
    Arc2D      arc1 = new Arc2D.Double( -1.15, -1.15, 2.3, 2.3, 0, speakerWidth, Arc2D.PIE );
    Arc2D      arc2 = new Arc2D.Double( -1.05, -1.05, 2.1, 2.1, 0, speakerWidth, Arc2D.PIE );
//    GeneralPath    gen;
    Area      area;
   
    for( int i = 0; i < numSpots; i++ ) {
      angDeg  = startAngle + i * deltaAngle;
      angRad  = (-angDeg + 90) * Math.PI / 180;
      dx    = Math.cos( angRad );
      dy    = Math.sin( angRad );
      outlines.add( new Line2D.Double( 0.0, 0.0, dx, dy ));
      outlinePaints.add( pntCtrlOut );
      arc1.setAngleStart( angDeg - 90 - speakerWidth/2 );
      arc2.setAngleStart( angDeg - 90 - speakerWidth/2 );
      area  = new Area( arc1 );
      area.subtract( new Area( arc2 ));
      areas.add( area );
      areaPaints.add( pntCtrlIn );
    }
   
    setMinimumSize( new Dimension( 64, 64 ));
View Full Code Here

    public void clip(Shape s) {
        if(clip == null) {
            clip = s;
        } else {
            Area clipArea = (clip instanceof Area ?
                             (Area)clip : new Area(clip));
            clipArea.intersect(s instanceof Area ? (Area)s : new Area(s));
            clip = clipArea;
        }

        queueOpArg("clip",
                   new Class[] {java.awt.Shape.class},
View Full Code Here

                        int h = oldOpImage.getNumYTiles()*
                            oldOpImage.getTileHeight();
                        Rectangle tileBounds = new Rectangle(x, y, w, h);
                        Rectangle imageBounds = oldOpImage.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 =
                            oldOpImage.mapSourceRect(srcInvalidBounds,
                                                     idx);

                        if(dstRegionBounds == null) {
                            dstRegionBounds = oldOpImage.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 =
                                oldOpImage.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);
                    }

                    // Clear the current rendering.
                    theImage = null;

                    // Retrieve the old TileCache.
                    TileCache oldCache = oldOpImage.getTileCache();

                    // Only perform further processing if there is a cache
                    // and there are tiles to save.
                    if(oldCache != null &&
                       (saveAllTiles || validTiles != null)) {
                        // Re-render the node.
                        createRendering();

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

                            if(saveAllTiles) {
                                Raster[] tiles =
                                    oldCache.getTiles(oldOpImage);
                                int numTiles = tiles == null ?
                                    0 : tiles.length;
                                for(int i = 0; i < numTiles; i++) {
                                    Raster tile = tiles[i];
                                    int tx =
                                        newOpImage.XToTileX(tile.getMinX());
                                    int ty =
                                        newOpImage.YToTileY(tile.getMinY());
                                    newCache.add(newOpImage,
                                                 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(oldOpImage,
                                                         tileIndex.x,
                                                         tileIndex.y);
                                    if(tile != null) {
                                        newCache.add(newOpImage,
                                                     tileIndex.x,
                                                     tileIndex.y,
                                                     tile,
                                                     tileCacheMetric);
                                    }
                                }
                            }
                        }
                    }
                }
            } else { // not op name or registry change nor RenderingChangeEvent
                ParameterBlock oldPB = null;
                ParameterBlock newPB = null;

                boolean checkInvalidRegion = false;
                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(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.
                    fireEvent = true;

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

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

                    // Determine the invalid region.
                    invalidRegion = (Shape)
                        odesc.getInvalidRegion(RenderedRegistryMode.MODE_NAME,
                                               oldPB,
                                               oldHints,
                                               newPB,
                                               nodeSupport.getRenderingHints(),
                                               this);

                    if(invalidRegion == null ||
                       !(theImage instanceof OpImage)) {

                        // Can't save any tiles; clear the rendering.
                        theImage = null;

                    } else {
                        // Create a new rendering.
                        OpImage oldRendering = (OpImage)theImage;
                        theImage = null;
                        createRendering();

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

                            // Save some values.
                            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()) {
View Full Code Here

    public void clip(Shape s) {
        if(clip == null) {
            clip = s;
        } else {
            Area clipArea = (clip instanceof Area ?
                             (Area)clip : new Area(clip));
            clipArea.intersect(s instanceof Area ? (Area)s : new Area(s));
            clip = clipArea;
        }
    }
View Full Code Here

        int tyMin = YToTileY(overlap.y);
        int txMax = XToTileX(overlap.x + overlap.width - 1);
        int tyMax = YToTileY(overlap.y + overlap.height - 1);

        Shape roiShape = roi.getAsShape();
        Area roiArea = null;
        if (roiShape != null) {
            roiArea = new Area(roiShape);
        }

        // Loop over all in-bound tiles, find ones that have been computed
        for (int j = tyMin; j <= tyMax; j++) {
            for (int i = txMin; i <= txMax; i++) {
                WritableRaster t;
                if ((t = tiles[i - minTileX][j - minTileY]) != null &&
                    !isTileLocked(i, j)) {
                    Rectangle rect = getTileRect(i, j).intersection(overlap);
                    if(!rect.isEmpty()) {
                        if (roiShape != null) {
                            Area a = new Area(rect);
                            a.intersect(roiArea);

                            if(!a.isEmpty()) {
                                overlayPixels(t, im, a);
                            }
                        } else {
                            int[][] bitmask =
                                roi.getAsBitmask(rect.x, rect.y,
View Full Code Here

                        // Attempt to get the ROI as a Shape.
                        Shape roiShape = srcROI.getAsShape();

                        if (roiShape != null) {
                            // Determine the area of overlap.
                            Area a = new Area(rect);
                            a.intersect(new Area(roiShape));

                            if(!a.isEmpty()) {
                                // If the area is non-empty overlay the pixels.
                                overlayPixels(tile, src, a);
                            }
                        } else {
                            int[][] bitmask =
View Full Code Here

                        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()) {
View Full Code Here

TOP

Related Classes of java.awt.geom.Area$Intersection

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.