/** * Create a library entry from a SMILES string with the coordinates suffixed in binary. The * entry should be created with {@link #encodeEntry(java.util.Map.Entry)} and not created * manually. Note, the entry is not added to the library. * * @param str input string * @return library entry */ static Entry<String, Point2d[]> decodeEntry(String str) { final int i = str.indexOf(' '); if (i < 0) throw new IllegalArgumentException(); return new SimpleEntry<String, Point2d[]>(str.substring(0, i), decodeCoordinates(str.substring(i + 1))); }
/** * Create a library entry from a SMILES string with the coordinates suffixed in binary. The * entry should be created with {@link #encodeEntry(java.util.Map.Entry)} and not created * manually. Note, the entry is not added to the library. * * @param str input string * @return library entry */ static Entry<String, Point2d[]> decodeEntry(String str) { final int i = str.indexOf(' '); if (i < 0) throw new IllegalArgumentException(); return new SimpleEntry<String, Point2d[]>(str.substring(0, i), decodeCoordinates(str.substring(i + 1))); }
@Test public void decodeCoordinates() throws Exception { Point2d[] points = IdentityTemplateLibrary.decodeCoordinates("12.5, 5.5, 4, 2"); assertThat(points.length, is(2)); assertThat(points[0].x, closeTo(12.5, 0.01)); assertThat(points[0].y, closeTo(5.5, 0.01)); assertThat(points[1].x, closeTo(4, 0.01)); assertThat(points[1].y, closeTo(2, 0.01)); }