@Override public String toString () { return _tile.toString()+":"+_bin.toString(); }
static public JSONObject tileToJSON( AnnotationTile tile ) { JSONObject tileJSON = new JSONObject(); try { tileJSON.put("level", tile.getDefinition().getLevel() ); tileJSON.put("x", tile.getDefinition().getX() ); tileJSON.put("y", tile.getDefinition().getY() ); for (int i=0; i<tile.getDefinition().getXBins(); i++ ) { for (int j=0; j<tile.getDefinition().getYBins(); j++ ) { AnnotationBin bin = tile.getBin(i, j); if ( bin != null) { // add bin object to tile tileJSON.put( new BinIndex(i, j).toString(), binToJSON( bin ) ); } } } } catch ( Exception e ) { e.printStackTrace(); } return tileJSON; }
@Test public void testBinStringification () { BinIndex b = new BinIndex(23, 41); String bs = b.toString(); Assert.assertEquals("[23, 41]", bs); BinIndex b2 = BinIndex.fromString(bs); Assert.assertEquals(b, b2); }