]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/save/GroutedImage.java
44000678ea420e73eed834029a8e1d569dbe1817
[GpsPrune.git] / tim / prune / save / GroutedImage.java
1 package tim.prune.save;
2
3 import java.awt.image.BufferedImage;
4
5 import tim.prune.data.DoubleRange;
6
7
8 /**
9  * Class to represent the result of the MapGrouter's assembly of map tiles
10  * into a single image.  Includes information about how complete the result is.
11  */
12 public class GroutedImage
13 {
14         private BufferedImage _image = null;
15         private int   _numTilesFound = 0;
16         private int   _numTilesMissing = 0;
17         private DoubleRange _xRange = null;
18         private DoubleRange _yRange = null;
19
20         /**
21          * Constructor
22          * @param inImage image, or null if no image possible
23          * @param inTilesUsed number of tiles used
24          * @param inTilesMissing number of tiles which could not be found
25          */
26         public GroutedImage(BufferedImage inImage, int inTilesUsed, int inTilesMissing)
27         {
28                 _image = inImage;
29                 _numTilesFound = inTilesUsed;
30                 _numTilesMissing = inTilesMissing;
31         }
32
33         /**
34          * @return true if any content at all was found
35          */
36         public boolean isValid() {
37                 return _image != null && _numTilesFound > 0;
38         }
39
40         /**
41          * @return true if all the required tiles were found
42          */
43         public boolean isComplete() {
44                 return _numTilesMissing == 0;
45         }
46
47         /**
48          * @return the pixel dimensions of the result image
49          */
50         public int getImageSize()
51         {
52                 if (_image == null) {return -1;}
53                 return _image.getWidth();
54         }
55
56         /**
57          * @return the image object
58          */
59         public BufferedImage getImage() {
60                 return _image;
61         }
62
63         /**
64          * @return the number of tiles used in the image
65          */
66         public int getNumTilesUsed() {
67                 return _numTilesFound;
68         }
69
70         /**
71          * @return the number of tiles which could not be found, leaving gaps in the image
72          */
73         public int getNumTilesMissing() {
74                 return _numTilesMissing;
75         }
76
77         /**
78          * @return the total number of tiles
79          */
80         public int getNumTilesTotal() {
81                 return _numTilesFound + _numTilesMissing;
82         }
83
84         /**
85          * @param inRange x range of data
86          */
87         public void setXRange(DoubleRange inRange) {
88                 _xRange = inRange;
89         }
90
91         /**
92          * @return x range of data
93          */
94         public DoubleRange getXRange() {
95                 return _xRange;
96         }
97
98         /**
99          * @param inRange y range of data
100          */
101         public void setYRange(DoubleRange inRange) {
102                 _yRange = inRange;
103         }
104
105         /**
106          * @return y range of data
107          */
108         public DoubleRange getYRange() {
109                 return _yRange;
110         }
111 }