Thread: [graphl-cvs] graphl/src/org/mediavirus/util ParseUtils.java
Status: Pre-Alpha
Brought to you by:
flo1
From: Flo L. <fl...@us...> - 2004-10-04 10:21:16
|
Update of /cvsroot/graphl/graphl/src/org/mediavirus/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18139/src/org/mediavirus/util Added Files: ParseUtils.java Log Message: * added width and height properties to the Node interface, to allow layouters to define a bounding box for nodes. * AbsoluteNodeLayouter will also use bounding box information for maps etc. This is currently only used in imageNodePainter * added DirectedEdgeLayouter for laying out hierarchical and directed graphs like trees. this works nice for rdf schemas et al. * Added ShapeNodePainter to draw labels as java2d shapes (currently predefined: circle, square, cross and X). No label yet. * using JavaBeans/property pages for facet configuration. added a dependency to com.l2fprod package, implementing paroperty sheets - i want to get rid of this again in the future, but i don't have time currently to implement such bullshit that should be in the jdk anyhow * Added a StrokeChooser for defining strokes for node and edgepainters * added a ParseUtils class for parsing colors and strokes from literals * greatly extended default configuration for facets * some documentation updates (javadoc runs without warnings now) --- NEW FILE: ParseUtils.java --- /* * Created on 01.10.2004 by Flo Ledermann <led...@im...> */ package org.mediavirus.util; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Stroke; import java.util.StringTokenizer; /** * @author Flo Ledermann <led...@im...> * created: 01.10.2004 21:56:43 */ public class ParseUtils { public static Color parseColor(String colstr) { Color col = null; if (colstr != null) { colstr = colstr.substring(1); int colval = Integer.parseInt(colstr, 16); col = new Color(colval); } return col; } /** * @param str A String that contains a Stroke definition in the following format: * a float value indicating the line width, followed by 0-6 int values, defining * the stroke pattern. @see java.awt.BasicStroke * @return A Stroke that matches the definition in str, or null if the definition * could not be parsed. */ public static Stroke parseStroke(String str) { if (str != null) { float width; StringTokenizer tok = new StringTokenizer(str); try { width = Float.parseFloat(tok.nextToken()); } catch (NumberFormatException ex){ return null; } int i=0; int[] p = new int[6]; while (i<6 && tok.hasMoreTokens()) { try { p[i] = Integer.parseInt(tok.nextToken()); i++; } catch (NumberFormatException e) { } } float[] pattern; if (i == 6) pattern = new float[] { p[0],p[1],p[2],p[3],p[4],p[5] }; else if (i > 3) pattern = new float[] { p[0],p[1],p[2],p[3] }; else if (i > 1) pattern = new float[] { p[0],p[1] }; else if (i == 1) pattern = new float[] { p[0] }; else return new BasicStroke(width); return new BasicStroke(width,BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f, pattern, 0.0f); } return null; } } |
From: Flo L. <fl...@us...> - 2004-10-14 13:03:14
|
Update of /cvsroot/graphl/graphl/src/org/mediavirus/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12051/src/org/mediavirus/util Modified Files: ParseUtils.java Log Message: - FEATURE: added z-index support for painting nodes & edges - FEATURE: BoxNodePainter draws rounded rectangles - FEATURE: Font for boxnodepainter is configurable - FEATURE: labelcolor of edgepainter is configurable - FEATURE: added utility functions for namespace compression/expansion - REFACTOR: moved layouter to graphpane - BUG: removed value property from graphelements - BUG: stopping layouter when displaying contextmenus etc. - BUG: fixed panning after startup - removed obsolete commented-out code Index: ParseUtils.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/util/ParseUtils.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ParseUtils.java 4 Oct 2004 10:21:04 -0000 1.1 --- ParseUtils.java 14 Oct 2004 13:03:04 -0000 1.2 *************** *** 7,10 **** --- 7,11 ---- import java.awt.BasicStroke; import java.awt.Color; + import java.awt.Font; import java.awt.Stroke; import java.util.StringTokenizer; *************** *** 71,73 **** --- 72,83 ---- } + /** + * @param property + * @return + */ + public static Font parseFont(String spec) { + if (spec == null) return null; + return Font.decode(spec); + } + } |
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; + } + } |
From: Flo L. <fl...@us...> - 2004-10-27 10:55:51
|
Update of /cvsroot/graphl/graphl/src/org/mediavirus/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18264/src/org/mediavirus/util Modified Files: ParseUtils.java Log Message: - FEATURE: finally implemented sortgedNodeLayouter with proportional layout - AbstractFacet.assignedElements is now a list, to be able to sort it - BUG: block graph update events during loading - FEATURE: nodes are placed at deterministic locations initially (loading the same file twice will result in the same layout) - FEATURE: minor performance enhancements for repulsionnodelayouter - renamed "controls" command line option to "toolbar" Index: ParseUtils.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/util/ParseUtils.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ParseUtils.java 19 Oct 2004 16:17:09 -0000 1.3 --- ParseUtils.java 27 Oct 2004 10:55:41 -0000 1.4 *************** *** 73,78 **** /** ! * @param property ! * @return */ public static Font parseFont(String spec) { --- 73,79 ---- /** ! * @param spec A String containing the specification of the font to use, in the ! * format <familyname>-<variant>-<size>. @see java.awt.Font.decode(String). ! * @return The Font described by the specification String, or <code>null</code> if spec == null. */ public static Font parseFont(String spec) { *************** *** 109,114 **** /** ! * @param str ! * @return */ public static float[] parseMatrix(String str) { --- 110,115 ---- /** ! * @param str A String containing the matrix in space-separated form. ! * @return A float[] containing the 3x3 matrix. */ public static float[] parseMatrix(String str) { |
From: Flo L. <fl...@us...> - 2006-06-30 14:32:12
|
Update of /cvsroot/graphl/graphl/src/org/mediavirus/util In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv11488/src/org/mediavirus/util Modified Files: ParseUtils.java Log Message: - migrated from jxpath to jaxen, which gives a much cleaner implementation of custom axes Index: ParseUtils.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/util/ParseUtils.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ParseUtils.java 27 Oct 2004 10:55:41 -0000 1.4 --- ParseUtils.java 30 Jun 2006 14:31:37 -0000 1.5 *************** *** 20,26 **** Color col = null; if (colstr != null) { ! colstr = colstr.substring(1); ! int colval = Integer.parseInt(colstr, 16); ! col = new Color(colval); } return col; --- 20,44 ---- Color col = null; if (colstr != null) { ! // web notation ! if (colstr.startsWith("#")) { ! colstr = colstr.substring(1); ! int colval = Integer.parseInt(colstr, 16); ! col = new Color(colval); ! } ! // rgb notation ! else { ! StringTokenizer coltok = new StringTokenizer(colstr,","); ! int i=0; ! int[] rgb = {0,0,0}; ! while (coltok.hasMoreTokens()) { ! String val = coltok.nextToken(); ! rgb[i] = Integer.parseInt(val); ! // clamp color values ! if (rgb[i] > 255) rgb[i] = 255; ! if (rgb[i] < 0) rgb[i] = 0; ! if (i++ == 3) break; ! } ! col = new Color(rgb[0],rgb[1],rgb[2]); ! } } return col; |