Package com.lightcrafts.mediax.jai

Examples of com.lightcrafts.mediax.jai.TileComputationListener


                    // Notify listeners.
                    if(exception == null) {
                        // Tile computation successful.
                        while(iter.hasNext()) {
                            TileComputationListener listener =
                                (TileComputationListener)iter.next();
                            listener.tileComputed(scheduler, requests,
                                                  owner, tileX, tileY,
                                                  tiles[offset]);
                        }
                    } else {
                        // Tile computation unsuccessful.
                        while(iter.hasNext()) {
                            TileComputationListener listener =
                                (TileComputationListener)iter.next();
                            listener.tileComputationFailure(scheduler, requests,
                                                            owner, tileX, tileY,
                                                            exception);
                        }
                    }
                }
View Full Code Here


                    // Notify listeners.
                    if(exception == null) {
                        // Tile computation successful.
                        while(iter.hasNext()) {
                            TileComputationListener listener =
                                (TileComputationListener)iter.next();
                            listener.tileComputed(scheduler, requests,
                                                  owner, tileX, tileY,
                                                  tiles[offset]);
                        }
                    } else {
                        // Tile computation unsuccessful.
                        while(iter.hasNext()) {
                            TileComputationListener listener =
                                (TileComputationListener)iter.next();
                            listener.tileComputationFailure(scheduler, requests,
                                                            owner, tileX, tileY,
                                                            exception);
                        }
                    }
                }
View Full Code Here

                        // Update tile status to "computed".
                        tileStatus =
                            new Integer(TileRequest.TILE_STATUS_COMPUTED);
                        request.tileStatus.put(p, tileStatus);

                        TileComputationListener listener =
                            (TileComputationListener)iter.next();
                        listener.tileComputed(this,
                                              reqs,
                                              owner,
                                              p.x, p.y,
                                              tiles[j]);
                    }
                } catch (Exception e) {
                    exception = e;

                    // Abort the remaining tiles in the job.
                    break;
                }
                /* XXX
                try {
                    List reqList;
                    synchronized(tileRequests) {
                        Long tileID = tileKey(owner, p.x, p.y);
                        reqList = (List)tileRequests.remove(tileID);
                        tileJobs.remove(tileID);
                    }
                    if(reqList != null) {
                        tiles[j] = owner.getTile(p.x, p.y);
                        TileRequest[] reqs =
                            (TileRequest[])reqList.toArray(new TileRequest[0]);
                        Set listeners = getListeners(reqList);
                        if(listeners != null) {
                            Iterator iter = listeners.iterator();
                            while(iter.hasNext()) {
                                TileComputationListener listener =
                                    (TileComputationListener)iter.next();
                                listener.tileComputed(this,
                                                      reqs,
                                                      owner,
                                                      p.x, p.y,
                                                      tiles[j]);
                            }
                        }
                    }
                } catch (Exception e) {
                    exception = e;

                    // Abort the remaining tiles in the job.
                    break;
                }
                */
            }
        }

        // If an exception occured, notify listeners that all remaining
        // tiles in the job have failed.
        if(exception != null && request != null && request.listeners != null) {
            int lastOffset = j;
            int numFailed = numTiles - (lastOffset - offset);

            // Mark all tiles starting with the one which generated the
            // Exception as "failed".
            for(int i = 0, k = lastOffset; i < numFailed; i++) {
                Integer tileStatus =
                    new Integer(TileRequest.TILE_STATUS_FAILED);
                request.tileStatus.put(tileIndices[k++], tileStatus);
            }

            // Notify listeners.
            Request[] reqs = new Request[] {request};
            for(int i = 0, k = lastOffset; i < numFailed; i++) {
                Point p = tileIndices[k++];
                Iterator iter = request.listeners.iterator();
                while(iter.hasNext()) {
                    TileComputationListener listener =
                        (TileComputationListener)iter.next();
                    listener.tileComputationFailure(this, reqs,
                                                    owner, p.x, p.y,
                                                    exception);
                }
            }
        }
View Full Code Here

                // Notify any listeners.
                if(req.listeners != null) {
                    TileRequest[] reqArray = new TileRequest[] {req};
                    Iterator iter = req.listeners.iterator();
                    while(iter.hasNext()) {
                        TileComputationListener listener =
                            (TileComputationListener)iter.next();
                        listener.tileCancelled(this, reqArray,
                                               req.image, p.x, p.y);
                    }
                }
            }
        }
View Full Code Here

                        // Update tile status to "computed".
                        tileStatus =
                            new Integer(TileRequest.TILE_STATUS_COMPUTED);
                        request.tileStatus.put(p, tileStatus);

                        TileComputationListener listener =
                            (TileComputationListener)iter.next();
                        listener.tileComputed(this,
                                              reqs,
                                              owner,
                                              p.x, p.y,
                                              tiles[j]);
                    }
                } catch (Exception e) {
                    exception = e;

                    // Abort the remaining tiles in the job.
                    break;
                }
                /* XXX
                try {
                    List reqList;
                    synchronized(tileRequests) {
                        Long tileID = tileKey(owner, p.x, p.y);
                        reqList = (List)tileRequests.remove(tileID);
                        tileJobs.remove(tileID);
                    }
                    if(reqList != null) {
                        tiles[j] = owner.getTile(p.x, p.y);
                        TileRequest[] reqs =
                            (TileRequest[])reqList.toArray(new TileRequest[0]);
                        Set listeners = getListeners(reqList);
                        if(listeners != null) {
                            Iterator iter = listeners.iterator();
                            while(iter.hasNext()) {
                                TileComputationListener listener =
                                    (TileComputationListener)iter.next();
                                listener.tileComputed(this,
                                                      reqs,
                                                      owner,
                                                      p.x, p.y,
                                                      tiles[j]);
                            }
                        }
                    }
                } catch (Exception e) {
                    exception = e;

                    // Abort the remaining tiles in the job.
                    break;
                }
                */
            }
        }

        // If an exception occured, notify listeners that all remaining
        // tiles in the job have failed.
        if(exception != null && request != null && request.listeners != null) {
            int lastOffset = j;
            int numFailed = numTiles - (lastOffset - offset);

            // Mark all tiles starting with the one which generated the
            // Exception as "failed".
            for(int i = 0, k = lastOffset; i < numFailed; i++) {
                Integer tileStatus =
                    new Integer(TileRequest.TILE_STATUS_FAILED);
                request.tileStatus.put(tileIndices[k++], tileStatus);
            }

            // Notify listeners.
            Request[] reqs = new Request[] {request};
            for(int i = 0, k = lastOffset; i < numFailed; i++) {
                Point p = tileIndices[k++];
                Iterator iter = request.listeners.iterator();
                while(iter.hasNext()) {
                    TileComputationListener listener =
                        (TileComputationListener)iter.next();
                    listener.tileComputationFailure(this, reqs,
                                                    owner, p.x, p.y,
                                                    exception);
                }
            }
        }
View Full Code Here

                // Notify any listeners.
                if(req.listeners != null) {
                    TileRequest[] reqArray = new TileRequest[] {req};
                    Iterator iter = req.listeners.iterator();
                    while(iter.hasNext()) {
                        TileComputationListener listener =
                            (TileComputationListener)iter.next();
                        listener.tileCancelled(this, reqArray,
                                               req.image, p.x, p.y);
                    }
                }
            }
        }
View Full Code Here

TOP

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

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.