prefuse.util
Class PrefuseLib

java.lang.Object
  extended by prefuse.util.PrefuseLib

public class PrefuseLib
extends java.lang.Object

General library routines used by the prefuse toolkit.

Author:
jeffrey heer

Field Summary
static java.lang.String FIELD_PREFIX
          Prefix for visualization-specific data fields, such as those used by VisualItem; the default is a single underscore (_).
 
Method Summary
static double distance(VisualItem vi1, VisualItem vi2)
          Get the distance between the x,y points of two VisualItems.
static Schema getAxisLabelSchema()
          Get the VisualItem Schema used for axis tick marks and labels.
static java.lang.String getChildGroup(java.lang.String group)
          Get the tail group name of a child group, stripping all but the bottom-level group from the group name (e.g., graph.nodes --> nodes).
static java.lang.String getDisplayStats(Display d)
          Returns a string showing debugging info such as number of visualized items and the current frame rate.
static java.lang.String getEndField(java.lang.String field)
          For a given interpolated field name, get the name of the end field.
static java.lang.String getGroupName(java.lang.String parent, java.lang.String child)
          Get the group name for the given parent and child group, simply concatenating them together with a group delimiter in between.
static java.lang.String getMemoryUsageInKB()
          Get a String showing current JVM memory usage in kilobytes.
static java.lang.String getMemoryUsageInMB()
          Get a String showing current JVM memory usage in megabytes.
static Schema getMinimalVisualSchema()
          Get the minimal Schema needed for a unique VisualItem.
static java.lang.String getParentGroup(java.lang.String group)
          Get the parent group string of a child group, stripping off the bottom-level group from the group name (e.g., graph.nodes --> graph).
static double getSize2D(double size)
          Returns a scale factor by which to scale a 2D shape to grow the area by the desired input size value.
static java.lang.String getStartField(java.lang.String field)
          For a given interpolated field name, get the name of the start field.
static Schema getVisualItemSchema()
          Get an instance of the default Schema used for VisualItem instances.
static boolean isChildGroup(java.lang.String group)
          Indicates if a group is a child group, a non-top-level data group in a set of nested data groups (e.g., the node or edge table of a graph or tree).
static void setX(VisualItem item, VisualItem referrer, double x)
          Update the x-coordinate of an item.
static void setY(VisualItem item, VisualItem referrer, double y)
          Update the y-coordinate of an item.
static void update(VisualItem item, java.lang.String field, java.lang.Object val)
          Update the values in an interpolated column (a set of three columns representing a current value along with starting and ending values).
static void updateBoolean(VisualItem item, java.lang.String field, boolean b)
          Update the values in an interpolated column (a set of three columns representing a current value along with starting and ending values).
static void updateDouble(VisualItem item, java.lang.String field, double val)
          Update the values in an interpolated column (a set of three columns representing a current value along with starting and ending values).
static void updateFloat(VisualItem item, java.lang.String field, float val)
          Update the values in an interpolated column (a set of three columns representing a current value along with starting and ending values).
static void updateInt(VisualItem item, java.lang.String field, int val)
          Update the values in an interpolated column (a set of three columns representing a current value along with starting and ending values).
static void updateLong(VisualItem item, java.lang.String field, long val)
          Update the values in an interpolated column (a set of three columns representing a current value along with starting and ending values).
static void updateVisible(VisualItem item, boolean val)
          Update the visibility of an item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIELD_PREFIX

public static final java.lang.String FIELD_PREFIX
Prefix for visualization-specific data fields, such as those used by VisualItem; the default is a single underscore (_).

Method Detail

getMemoryUsageInKB

public static java.lang.String getMemoryUsageInKB()
Get a String showing current JVM memory usage in kilobytes.

Returns:
the memory usage String in KB

getMemoryUsageInMB

public static java.lang.String getMemoryUsageInMB()
Get a String showing current JVM memory usage in megabytes.

Returns:
the memory usage String in MB

getDisplayStats

public static java.lang.String getDisplayStats(Display d)
Returns a string showing debugging info such as number of visualized items and the current frame rate.

Returns:
the debug string

getSize2D

public static double getSize2D(double size)
Returns a scale factor by which to scale a 2D shape to grow the area by the desired input size value. This is used to scale shapes by total pixel area, rather than scaling each dimension by the size value itself, which grows the pixel area quadratically rather than linearly.


distance

public static double distance(VisualItem vi1,
                              VisualItem vi2)
Get the distance between the x,y points of two VisualItems.

Parameters:
vi1 - the first VisualItem
vi2 - the second VisualItem
Returns:
the distance between the items' x,y coordinates

update

public static void update(VisualItem item,
                          java.lang.String field,
                          java.lang.Object val)
Update the values in an interpolated column (a set of three columns representing a current value along with starting and ending values). The current value will become the new starting value, while the given value will become the new current and ending values.

Parameters:
item - the VisualItem to update
field - the base field to update, start and ending fields will also be updated, too.
val - the value to set

updateInt

public static void updateInt(VisualItem item,
                             java.lang.String field,
                             int val)
Update the values in an interpolated column (a set of three columns representing a current value along with starting and ending values). The current value will become the new starting value, while the given value will become the new current and ending values.

Parameters:
item - the VisualItem to update
field - the base field to update, start and ending fields will also be updated, too.
val - the value to set

updateLong

public static void updateLong(VisualItem item,
                              java.lang.String field,
                              long val)
Update the values in an interpolated column (a set of three columns representing a current value along with starting and ending values). The current value will become the new starting value, while the given value will become the new current and ending values.

Parameters:
item - the VisualItem to update
field - the base field to update, start and ending fields will also be updated, too.
val - the value to set

updateFloat

public static void updateFloat(VisualItem item,
                               java.lang.String field,
                               float val)
Update the values in an interpolated column (a set of three columns representing a current value along with starting and ending values). The current value will become the new starting value, while the given value will become the new current and ending values.

Parameters:
item - the VisualItem to update
field - the base field to update, start and ending fields will also be updated, too.
val - the value to set

updateDouble

public static void updateDouble(VisualItem item,
                                java.lang.String field,
                                double val)
Update the values in an interpolated column (a set of three columns representing a current value along with starting and ending values). The current value will become the new starting value, while the given value will become the new current and ending values.

Parameters:
item - the VisualItem to update
field - the base field to update, start and ending fields will also be updated, too.
val - the value to set

updateBoolean

public static void updateBoolean(VisualItem item,
                                 java.lang.String field,
                                 boolean b)
Update the values in an interpolated column (a set of three columns representing a current value along with starting and ending values). The current value will become the new starting value, while the given value will become the new current and ending values.

Parameters:
item - the VisualItem to update
field - the base field to update, start and ending fields will also be updated, too.
b - the value to set

updateVisible

public static void updateVisible(VisualItem item,
                                 boolean val)
Update the visibility of an item. The current visibility will become the new starting visibility, while the given visibility value will become the new current and ending visibility.

Parameters:
item - the VisualItem to update
val - the visibility value to set

setX

public static void setX(VisualItem item,
                        VisualItem referrer,
                        double x)
Update the x-coordinate of an item. The current x value will become the new starting x value, while the given value will become the new current x and ending x values. This method also supports an optional referrer item, whose x coordinate will become the new starting x coordinate of item if item's current x value is NaN.

Parameters:
item - the VisualItem to update
referrer - an optional referrer VisualItem
x - the x value to set

setY

public static void setY(VisualItem item,
                        VisualItem referrer,
                        double y)
Update the y-coordinate of an item. The current y value will become the new starting y value, while the given value will become the new current x and ending y values. This method also supports an optional referrer item, whose y coordinate will become the new starting y coordinate of item if item's current x value is NaN.

Parameters:
item - the VisualItem to update
referrer - an optional referrer VisualItem
y - the y value to set

isChildGroup

public static boolean isChildGroup(java.lang.String group)
Indicates if a group is a child group, a non-top-level data group in a set of nested data groups (e.g., the node or edge table of a graph or tree).

Returns:
true if the group is a nested, or child, group

getParentGroup

public static java.lang.String getParentGroup(java.lang.String group)
Get the parent group string of a child group, stripping off the bottom-level group from the group name (e.g., graph.nodes --> graph).

Parameters:
group - the group name
Returns:
the stripped parent group name

getChildGroup

public static java.lang.String getChildGroup(java.lang.String group)
Get the tail group name of a child group, stripping all but the bottom-level group from the group name (e.g., graph.nodes --> nodes).

Parameters:
group - the group name
Returns:
the stripped child group name

getGroupName

public static java.lang.String getGroupName(java.lang.String parent,
                                            java.lang.String child)
Get the group name for the given parent and child group, simply concatenating them together with a group delimiter in between.

Parameters:
parent - the parent group name
child - the child group name
Returns:
the combined group name

getStartField

public static java.lang.String getStartField(java.lang.String field)
For a given interpolated field name, get the name of the start field.

Parameters:
field - the data field
Returns:
the starting field for the interpolated column

getEndField

public static java.lang.String getEndField(java.lang.String field)
For a given interpolated field name, get the name of the end field.

Parameters:
field - the data field
Returns:
the ending field for the interpolated column

getVisualItemSchema

public static Schema getVisualItemSchema()
Get an instance of the default Schema used for VisualItem instances. Contains all the data members commonly used to model a visual element, such as x,y position, stroke, fill, and text, colors, size, font, and validated, visibility, interactive, fixed, highlight, and mouse hover fields.

Returns:
the VisualItem data Schema

getMinimalVisualSchema

public static Schema getMinimalVisualSchema()
Get the minimal Schema needed for a unique VisualItem. Can be useful for derived groups that inherit other visual properties from a another visual data group.

Returns:
the minimal VisualItem data Schema

getAxisLabelSchema

public static Schema getAxisLabelSchema()
Get the VisualItem Schema used for axis tick marks and labels. Extends the VisualItem Schema with an additional end-point coordinate, a String label field, and numeric value field for storing the value which the axis label corresponds to.

Returns:
the Schema for axis tick marks and labels.


Copyright © 2007 Regents of the University of California