~ubuntu-branches/ubuntu/precise/triplea/precise

« back to all changes in this revision

Viewing changes to src/games/strategy/ui/ImageIoCompletionWatcher.java

  • Committer: Package Import Robot
  • Author(s): Scott Howard
  • Date: 2011-11-11 21:40:11 UTC
  • Revision ID: package-import@ubuntu.com-20111111214011-sehf2rwat36o2xqf
Tags: upstream-1.3.2.2
ImportĀ upstreamĀ versionĀ 1.3.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package games.strategy.ui;
 
2
 
 
3
/*
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 * You should have received a copy of the GNU General Public License
 
13
 * along with this program; if not, write to the Free Software
 
14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
 */
 
16
 
 
17
import java.awt.image.*;
 
18
import java.awt.*;
 
19
import java.util.concurrent.CountDownLatch;
 
20
 
 
21
/**
 
22
 * Code originally contributed by "Thomas Carvin"
 
23
 */
 
24
 
 
25
public class ImageIoCompletionWatcher implements ImageObserver
 
26
{
 
27
    //we countdown when we are done
 
28
    private final CountDownLatch m_countDownLatch = new CountDownLatch(1);
 
29
 
 
30
    public ImageIoCompletionWatcher()
 
31
    {
 
32
    }
 
33
    
 
34
    public void waitForCompletion()
 
35
    {
 
36
        try
 
37
        {
 
38
            m_countDownLatch.await();
 
39
        } catch (InterruptedException e)
 
40
        {
 
41
            e.printStackTrace();
 
42
        }
 
43
    }
 
44
 
 
45
    public boolean imageUpdate(Image image, int flags, int x, int y, int width, int height)
 
46
    {
 
47
        // wait for complete or error/abort
 
48
        if (((flags & ALLBITS) != 0) || ((flags & ABORT) != 0))
 
49
        {
 
50
            m_countDownLatch.countDown();
 
51
            return false;
 
52
        }
 
53
 
 
54
        return true;
 
55
 
 
56
    }
 
57
}
 
 
b'\\ No newline at end of file'