test_class.declarator: rg = new Random(342)
test_class.original_string: Random rg = new Random(342);
test_class.type: Random
test_class.var_name: rg
test_class.file: impl/src/test/java/org/geomajas/internal/layer/tile/TileCodeComparatorTest.java
test_class.identifier: TileCodeComparatorTest
test_case.body: @Test
  	public void testTileCodeComparatorSymmetry() {
  		List<TileCode> list = createTileCodes(0, 0, 3, 3); 
  		TileCodeComparator comp = new TileCodeComparator(1, 1);
  		for (TileCode code1 : list) {
  			for (TileCode code2 : list) {
  				int left = comp.compare(code1, code2);
  				int right = - comp.compare(code2, code1);
  				if (left != right) {
  					System.out.println(code1 + " " + code2);
  				}
  				Assert.assertEquals(left, right);
  			}
  		}
  	}
test_case.class_method_signature: TileCodeComparatorTest.testTileCodeComparatorSymmetry()
test_case.full_signature: @Test public void testTileCodeComparatorSymmetry()
test_case.identifier: testTileCodeComparatorSymmetry
test_case.invocations: createTileCodes compare compare println assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testTileCodeComparatorSymmetry()
focal_class.declarator: offsetX
focal_class.modifier: private
focal_class.original_string: private int offsetX;
focal_class.type: int
focal_class.var_name: offsetX
focal_class.declarator: offsetY
focal_class.modifier: private
focal_class.original_string: private int offsetY;
focal_class.type: int
focal_class.var_name: offsetY
focal_class.file: impl/src/main/java/org/geomajas/internal/layer/tile/TileCodeComparator.java
focal_class.identifier: TileCodeComparator
focal_class.interfaces: implements Comparator<TileCode>
focal_class.class_method_signature: TileCodeComparator.TileCodeComparator(int offsetX, int offsetY)
focal_class.full_signature: public  TileCodeComparator(int offsetX, int offsetY)
focal_class.identifier: TileCodeComparator
focal_class.modifiers: public
focal_class.parameters: (int offsetX, int offsetY)
focal_class.signature:  TileCodeComparator(int offsetX, int offsetY)
focal_class.class_method_signature: TileCodeComparator.compare(TileCode o1, TileCode o2)
focal_class.full_signature: @Override public int compare(TileCode o1, TileCode o2)
focal_class.identifier: compare
focal_class.modifiers: @Override public
focal_class.parameters: (TileCode o1, TileCode o2)
focal_class.return: int
focal_class.signature: int compare(TileCode o1, TileCode o2)
focal_method.body: @Override
  	public int compare(TileCode o1, TileCode o2) {
  		// -1: o1 is closer to center
  		//  0: same distance to center
  		//  1: o2 is closer to center
  		int x1 = o1.getX() - offsetX;
  		int x2 = o2.getX() - offsetX;
  		int y1 = o1.getY() - offsetY;
  		int y2 = o2.getY() - offsetY;
  
  		int o1d = Math.max(Math.abs(x1), Math.abs(y1));
  		int o2d = Math.max(Math.abs(x2), Math.abs(y2));
  
  		if (x1 == x2 && y1 == y2) { // points same position
  			return 0;
  		} else if (o1d != o2d) { // points on different sphere
  			return (o1d < o2d) ? -1 : 1;
  		} else { // points on same sphere
  			if (y1 == o1d) { // Case: o1 on top row
  				if (y1 == y2) {
  					return (x1 < x2) ? -1 : 1;
  				} else {
  					return -1;
  				}
  			} else if (x1 == o1d) { // Case: o1 on right column
  				if (y2 == o1d) {
  					return 1;
  				} else if (x1 == x2) {
  					return (y1 > y2) ? -1 : 1;
  				} else {
  					return -1;
  				}
  			} else if (y1 == -1 * o1d) { // Case: o1 on bottom row
  				if (y2 == o1d || x2 == o1d) {
  					return 1;
  				} else if (y1 == y2) {
  					return (x1 > x2) ? -1 : 1;
  				} else {
  					return -1;
  				}
  			} else if (x1 == -1 * o1d) { // Case: o1 on left column
  				if (y2 == o1d || x2 == o1d || y2 == -1 * o1d) {
  					return 1;
  				} else {
  					return (y1 < y2) ? -1 : 1;
  				}
  			}
  			return 0; // Should not reach this
  		}
  	}
focal_method.class_method_signature: TileCodeComparator.compare(TileCode o1, TileCode o2)
focal_method.full_signature: @Override public int compare(TileCode o1, TileCode o2)
focal_method.identifier: compare
focal_method.invocations: getX getX getY getY max abs abs max abs abs
focal_method.modifiers: @Override public
focal_method.parameters: (TileCode o1, TileCode o2)
focal_method.return: int
focal_method.signature: int compare(TileCode o1, TileCode o2)