Prefuse Tutorial
Prefuse Tutorial
a visualization toolkit
prefuse
a user interface toolkit for interactive
information visualization
built in Java using Java2D graphics library
data structures and algorithms
pipeline architecture featuring reusable,
composable modules
animation and rendering support
architectural techniques for scalability
here is a graph
At this point it is purely abstract (i.e.
assume we havent given it any visual
appearance yet)
The graph could be a
file system
computer network
web site
biological taxonomy
social network
abstract data
(Node, Edge)
visual analogues
(NodeItem, EdgeItem)
visual analogues
Filtered graph data is mapped to VisualItems
visual analogues of abstract data.
EdgeItems
AggregateItems
ItemRegistry
Comparator
NodeItems
EdgeItems
rendering
Renderers are responsible for drawing items and computing bounding boxes. It is
the responsibility of the RendererFactory to return the desired Renderer for a
given VisualItem. These live in the package edu.berkeley.guir.prefuse.render.
RendererFactory
getRenderer(VisualItem)
Renderer
render(Graphics2D, VisualItem)
getBounds(VisualItem)
locatePoint(Point2D, VisualItem)
EdgeRenderer
TextRenderer
TextImageRenderer
SubtreeAggregateRenderer
display
Display
ControlListener
itemClicked(VisualItem, MouseEvent)
itemDragged(VisualItem, MouseEvent)
itemKeyPressed(VisualItem, KeyEvent)
Activity
long duration, stepTime, startTime
isScheduled()
cancel()
run(long elapsedTime)
addActivityListener(ActivityListener)
ActivityListener
activityScheduled(Activity)
activityStarted(Activity)
activityStepped(Activity)
activityFinished(Activity)
activityCancelled(Activity)
Action
run(ItemRegistry, double f)
isEnabled()
setEnabled(boolean)
customizing actions
The Action interface is designed to let developers easily create custom Actions to
accomplish their goals. In addition, many actions are very easily customized to a
particular application. For example, the ColorFunction includes two methods
getColor(VisualItem item) and getFillColor(VisualItem item) that subclasses can
override to perform application specific code. The FontFunction and SizeFunction
actions are similar.
public class MyColorFunction extends ColorFunction {
public Paint getColor(VisualItem item) {
// custom code here, just return the desired color
}
public Paint getFillColor(VisualItem item) {
// custom code here, just return the desired color
}
}
writing applications
So how do you build an app with prefuse?
before touching any code: design visual appearance,
layout, interactive behaviors
determine input/output of graph data
initialize ItemRegistry and Display(s)
select (or implement custom) Renderers and
RendererFactory
construct the various ActionLists necessary
using existing library of Actions, or with custom-built
modules (or sub-components like Force functions)
write user interface callbacks to orchestrate the
ActionLists