]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/save/GroutedImage.java
Version 16, February 2014
[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 the pixel dimensions of the result image
42          */
43         public int getImageSize()
44         {
45                 if (_image == null) {return -1;}
46                 return _image.getWidth();
47         }
48
49         /**
50          * @return the image object
51          */
52         public BufferedImage getImage() {
53                 return _image;
54         }
55
56         /**
57          * @return the number of tiles used in the image
58          */
59         public int getNumTilesUsed() {
60                 return _numTilesFound;
61         }
62
63         /**
64          * @return the number of tiles which could not be found, leaving gaps in the image
65          */
66         public int getNumTilesMissing() {
67                 return _numTilesMissing;
68         }
69
70         /**
71          * @return the total number of tiles
72          */
73         public int getNumTilesTotal() {
74                 return _numTilesFound + _numTilesMissing;
75         }
76
77         /**
78          * @param inRange x range of data
79          */
80         public void setXRange(DoubleRange inRange) {
81                 _xRange = inRange;
82         }
83
84         /**
85          * @return x range of data
86          */
87         public DoubleRange getXRange() {
88                 return _xRange;
89         }
90
91         /**
92          * @param inRange y range of data
93          */
94         public void setYRange(DoubleRange inRange) {
95                 _yRange = inRange;
96         }
97
98         /**
99          * @return y range of data
100          */
101         public DoubleRange getYRange() {
102                 return _yRange;
103         }
104 }