File: SvgFragment.java

package info (click to toggle)
gpsprune 17-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,984 kB
  • ctags: 5,218
  • sloc: java: 39,403; sh: 25; makefile: 17; python: 15
file content (56 lines) | stat: -rw-r--r-- 1,185 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package tim.prune.save;

/**
 * Class to enable the sorting of Svg fragments
 */
public class SvgFragment implements Comparable<SvgFragment>
{
	private String _fragment = null;
	private int _yCoord = 0;

	/**
	 * Constructor
	 * @param inFragment fragment of svg source
	 * @param inYCoord y coordinate of point, for sorting
	 */
	public SvgFragment(String inFragment, int inYCoord)
	{
		_fragment = inFragment;
		_yCoord = inYCoord;
	}

	/**
	 * @return svg fragment
	 */
	public String getFragment()
	{
		return _fragment;
	}

	/**
	 * Compare method
	 */
	public int compareTo(SvgFragment inOther)
	{
		int ycompare = _yCoord - inOther._yCoord;
		if (ycompare != 0) {return ycompare;}
		return _fragment.compareTo(inOther._fragment);
	}

	/**
	 * @param inOther other fragment to compare this one with
	 * @return true if the fragments are equal
	 */
	public boolean equals(SvgFragment inOther)
	{
		return _fragment.equals(inOther._fragment);
	}

	/**
	 * @param inOther other object to compare this one with
	 * @return true if the objects are equal
	 */
	public boolean equals(Object inOther) {
		return (inOther instanceof SvgFragment?equals((SvgFragment) inOther):false);
	}
}