public static void main(String[] args) { for (int i = 0; i < args.length; i++) { System.out.println("file: " + args[i]); try { System.out.println(new AmiraParameters(args[i])); } catch (Exception e) { e.printStackTrace(); } } } }
protected String readQuotedString() throws FormatException, IOException { int quote = c; if (quote == '(') { quote = ')'; } else if (quote != '"' && quote != '\'') { syntaxError("Invalid quote: " + c); } StringBuilder result = new StringBuilder(); for (;;) { readByte(); if (c == quote) { readByte(); return result.toString(); } if (quote == '"' && c == '\\') { readByte(); } result.append(c); } }
public AmiraParameters(RandomAccessInputStream inputStream) throws FormatException, IOException { readFile(inputStream); }
protected Map readMap() throws FormatException, IOException { if (c != '{') { syntaxError("Illegal block: " + c); readByte(); Map subMap = new LinkedHashMap(); for (;;) { skipWhiteSpace(); if (c == '#') { skipComment(); continue; readByte(); return subMap; String key = readKey(); if (key.equals("")) syntaxError("Invalid key"); skipWhiteSpace(); Object value; if (c == '{') value = readMap(); else { if (key.equals("BoundingBox")) { value = readDoubleArray(6); value = readDoubleArray(2); value = readKey(); value = readQuotedString();
map = new LinkedHashMap(); for (;;) { skipWhiteSpace(); if (c == '#') { skipComment(); continue; readByte(); firstDataStream = readNumber().intValue(); skipComment(); return; String key = readKey(); skipWhiteSpace(); Object value = null; if (key.equals("define")) { key = "n" + readKey(); skipWhiteSpace(); Integer[] dimensions = readIntArray(); width = dimensions[0].intValue(); if(dimensions.length > 1) height = dimensions[1].intValue(); value = readMap(); list.add(readMap()); skipWhiteSpace();
protected void readFile(RandomAccessInputStream inputStream) throws FormatException, IOException { String firstLine = inputStream.readLine(); Matcher amiraMeshDef = Pattern.compile("#\\s+(AmiraMesh|Avizo).*?" + "(BINARY|ASCII)(-LITTLE-ENDIAN)*").matcher(firstLine); if (amiraMeshDef.find()) { if (amiraMeshDef.group(2).equals("BINARY")) { littleEndian = amiraMeshDef.group(3) != null; } else if (amiraMeshDef.group(2).equals("ASCII")) { ascii = true; } else { syntaxError("Can't recognise this Amira file type"); } } else { syntaxError("Doesn't seem to be an Amira file"); } column = 0; row = 1; in = inputStream; readByte(); readTopLevel(); extractCoreMetaData(); }
in = new RandomAccessInputStream(id); AmiraParameters parameters = new AmiraParameters(in); offsetOfFirstStream = in.getFilePointer(); while (parameters.getStreams().get("@" + channelIndex) != null) { channelIndex++; ArrayList streamData = (ArrayList) parameters.getStreams().get("@1"); if (streamData.size() > 2) { compression = (String) streamData.get(2); Map params = (Map) parameters.getMap().get("Parameters"); if (params != null) { Map materials = (Map) params.get("Materials");
protected void skipComment() throws IOException { while (c != '\n') readByte(); }
public static String toString(Map map, String indent) throws FormatException { String result = "", separator = indent; Iterator iter = map.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); result += separator + entry.getKey() + " " + entryToString(entry.getValue(), indent); if (result.endsWith("}")) { separator = "\n" + indent; } else { separator = ",\n" + indent; } } return result + "\n"; }
protected Map readMap() throws FormatException, IOException { if (c != '{') { syntaxError("Illegal block: " + c); readByte(); Map subMap = new LinkedHashMap(); for (;;) { skipWhiteSpace(); if (c == '#') { skipComment(); continue; readByte(); return subMap; String key = readKey(); if (key.equals("")) syntaxError("Invalid key"); skipWhiteSpace(); Object value; if (c == '{') value = readMap(); else { if (key.equals("BoundingBox")) { value = readDoubleArray(6); value = readDoubleArray(2); value = readKey(); value = readQuotedString();
map = new LinkedHashMap(); for (;;) { skipWhiteSpace(); if (c == '#') { skipComment(); continue; readByte(); firstDataStream = readNumber().intValue(); skipComment(); return; String key = readKey(); skipWhiteSpace(); Object value = null; if (key.equals("define")) { key = "n" + readKey(); skipWhiteSpace(); Integer[] dimensions = readIntArray(); width = dimensions[0].intValue(); if(dimensions.length > 1) height = dimensions[1].intValue(); value = readMap(); list.add(readMap()); skipWhiteSpace();
protected void readFile(RandomAccessInputStream inputStream) throws FormatException, IOException { String firstLine = inputStream.readLine(); Matcher amiraMeshDef = Pattern.compile("#\\s+(AmiraMesh|Avizo).*?" + "(BINARY|ASCII)(-LITTLE-ENDIAN)*").matcher(firstLine); if (amiraMeshDef.find()) { if (amiraMeshDef.group(2).equals("BINARY")) { littleEndian = amiraMeshDef.group(3) != null; } else if (amiraMeshDef.group(2).equals("ASCII")) { ascii = true; } else { syntaxError("Can't recognise this Amira file type"); } } else { syntaxError("Doesn't seem to be an Amira file"); } column = 0; row = 1; in = inputStream; readByte(); readTopLevel(); extractCoreMetaData(); }
in = new RandomAccessInputStream(id); AmiraParameters parameters = new AmiraParameters(in); offsetOfFirstStream = in.getFilePointer(); while (parameters.getStreams().get("@" + channelIndex) != null) { channelIndex++; ArrayList streamData = (ArrayList) parameters.getStreams().get("@1"); if (streamData.size() > 2) { compression = (String) streamData.get(2); Map params = (Map) parameters.getMap().get("Parameters"); if (params != null) { Map materials = (Map) params.get("Materials");
protected void skipWhiteSpace() throws IOException { while (c == ' ' || c == '\t' || c == '\n') readByte(); }
public static String toString(Map map, String indent) throws FormatException { String result = "", separator = indent; Iterator iter = map.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); result += separator + entry.getKey() + " " + entryToString(entry.getValue(), indent); if (result.endsWith("}")) { separator = "\n" + indent; } else { separator = ",\n" + indent; } } return result + "\n"; }
protected String readQuotedString() throws FormatException, IOException { int quote = c; if (quote == '(') { quote = ')'; } else if (quote != '"' && quote != '\'') { syntaxError("Invalid quote: " + c); } StringBuilder result = new StringBuilder(); for (;;) { readByte(); if (c == quote) { readByte(); return result.toString(); } if (quote == '"' && c == '\\') { readByte(); } result.append(c); } }
public static void main(String[] args) { for (int i = 0; i < args.length; i++) { System.out.println("file: " + args[i]); try { System.out.println(new AmiraParameters(args[i])); } catch (Exception e) { e.printStackTrace(); } } } }
public AmiraParameters(RandomAccessInputStream inputStream) throws FormatException, IOException { readFile(inputStream); }
protected void skipWhiteSpace() throws IOException { while (c == ' ' || c == '\t' || c == '\n') readByte(); }
StringBuilder result = new StringBuilder("{\n"); for (Object item : (ArrayList) object) { result.append(entryToString(item, indent + "\t")); result.append("\n");