]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/save/SvgFragment.java
Version 18.6, December 2016
[GpsPrune.git] / tim / prune / save / SvgFragment.java
1 package tim.prune.save;
2
3 /**
4  * Class to enable the sorting of Svg fragments
5  */
6 public class SvgFragment implements Comparable<SvgFragment>
7 {
8         private String _fragment = null;
9         private int _yCoord = 0;
10
11         /**
12          * Constructor
13          * @param inFragment fragment of svg source
14          * @param inYCoord y coordinate of point, for sorting
15          */
16         public SvgFragment(String inFragment, int inYCoord)
17         {
18                 _fragment = inFragment;
19                 _yCoord = inYCoord;
20         }
21
22         /**
23          * @return svg fragment
24          */
25         public String getFragment()
26         {
27                 return _fragment;
28         }
29
30         /**
31          * Compare method
32          */
33         public int compareTo(SvgFragment inOther)
34         {
35                 int ycompare = _yCoord - inOther._yCoord;
36                 if (ycompare != 0) {return ycompare;}
37                 return _fragment.compareTo(inOther._fragment);
38         }
39
40         /**
41          * @param inOther other fragment to compare this one with
42          * @return true if the fragments are equal
43          */
44         public boolean equals(SvgFragment inOther)
45         {
46                 return _fragment.equals(inOther._fragment);
47         }
48
49         /**
50          * @param inOther other object to compare this one with
51          * @return true if the objects are equal
52          */
53         public boolean equals(Object inOther) {
54                 return (inOther instanceof SvgFragment?equals((SvgFragment) inOther):false);
55         }
56 }