public static LineageData loadNucFiles(final ProductionInfo productionInfo) { final TableLineageData tableLineageData = new TableLineageData( allCellNames, productionInfo.getXScale(), productionInfo.getYScale(), productionInfo.getZScale()); try { // accounts for first tld.addFrame() added when reading from JAR --> from dir name first entry // match tableLineageData.addTimeFrame(); URL url; for (int i = 1; i <= productionInfo.getTotalTimePoints(); i++) { if (i < 10) { url = AceTreeTableLineageLoader.class.getResource( ENTRY_PREFIX + T + TWO_ZERO_PAD + i + ENTRY_EXT); if (url != null) { process(tableLineageData, i, url.openStream()); } else { System.out.println( "Could not process file: " + ENTRY_PREFIX + T + TWO_ZERO_PAD + i + ENTRY_EXT); } } else if (i >= 10 && i < 100) { url = AceTreeTableLineageLoader.class.getResource( ENTRY_PREFIX + T + ONE_ZERO_PAD + i + ENTRY_EXT); if (url != null) { process(tableLineageData, i, url.openStream()); } else { System.out.println( "Could not process file: " + ENTRY_PREFIX + T + ONE_ZERO_PAD + i + ENTRY_EXT); } } else if (i >= 100) { url = AceTreeTableLineageLoader.class.getResource(ENTRY_PREFIX + T + i + ENTRY_EXT); if (url != null) { process(tableLineageData, i, url.openStream()); } else { System.out.println("Could not process file: " + ENTRY_PREFIX + T + i + ENTRY_EXT); } } } } catch (IOException ioe) { ioe.printStackTrace(); } // translate all cells to center around (0,0,0) setOriginToZero(tableLineageData, true); return tableLineageData; }
private static void makeNucleus( final TableLineageData tableLineageData, final int time, final String[] tokens) { try { tableLineageData.addNucleus( time, tokens[ID], parseInt(tokens[XCOR]), parseInt(tokens[YCOR]), round(parseDouble(tokens[ZCOR])), parseInt(tokens[DIAMETER])); } catch (NumberFormatException nfe) { System.out.println("Incorrect format in nucleus file for time " + time + "."); } }
private static void process( final TableLineageData tableLineageData, final int time, final InputStream input) { tableLineageData.addTimeFrame(); try (InputStreamReader isr = new InputStreamReader(input); BufferedReader reader = new BufferedReader(isr)) { String line; while ((line = reader.readLine()) != null) { String[] tokens = new String[TOKEN_ARRAY_SIZE]; StringTokenizer tokenizer = new StringTokenizer(line, ","); int k = 0; while (tokenizer.hasMoreTokens()) { tokens[k++] = tokenizer.nextToken().trim(); } if (parseInt(tokens[VALID]) == 1) { makeNucleus(tableLineageData, time, tokens); } } } catch (IOException e) { System.out.println("Error in processing input stream"); } }