[graphl-cvs] graphl/src/org/mediavirus/util ParseUtils.java
Status: Pre-Alpha
Brought to you by:
flo1
From: Flo L. <fl...@us...> - 2004-10-19 16:17:37
|
Update of /cvsroot/graphl/graphl/src/org/mediavirus/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17517/src/org/mediavirus/util Modified Files: ParseUtils.java Log Message: - FEATURE further commandline options to remove controls and menubar - FEATURE load url from commandline - FEATURE refresh every n seconds commandline option - FEATURE affine coordinate transformation for geo positioning on a map - FEATURE removed length property of edge, replaced by generic length calculation from any property in springEdgeLayouter - FEATURE configurable stroke for BoxNodePainter, ShapeNodePainter - FEATURE replaced rdfutils function by own implementation in ParseUtils Index: ParseUtils.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/util/ParseUtils.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ParseUtils.java 14 Oct 2004 13:03:04 -0000 1.2 --- ParseUtils.java 19 Oct 2004 16:17:09 -0000 1.3 *************** *** 80,83 **** --- 80,128 ---- return Font.decode(spec); } + + public static String guessName(String uri) { + int l = getNamespaceEnd(uri); + return l > 0 ? uri.substring(getNamespaceEnd(uri)) : uri; + } + + public static String guessNamespace(String uri){ + int l = getNamespaceEnd(uri); + return l > 1 ? uri.substring(0, l) : ""; + + } + + /** + * Position of the namespace end + */ + static int getNamespaceEnd(String uri) { + int l = uri.length()-1; + if (l<0) return -1; + do { + char c = uri.charAt(l); + if(c == '#' || c == ':' || c == '/') + break; + l--; + } while (l >= 0); + l++; + return l; + } + + /** + * @param str + * @return + */ + public static float[] parseMatrix(String str) { + StringTokenizer tok = new StringTokenizer(str); + float[] mat = {1, 0, 0, 0, 1, 0, 0, 0, 1}; + int i = 0; + while (tok.hasMoreTokens()) { + String t = tok.nextToken(); + mat[i] = Float.parseFloat(t); + if (i==9) break; + i++; + } + return mat; + } + } |