本文整理汇总了Java中prefuse.controls.PanControl类的典型用法代码示例。如果您正苦于以下问题:Java PanControl类的具体用法?Java PanControl怎么用?Java PanControl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PanControl类属于prefuse.controls包,在下文中一共展示了PanControl类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PlotSTPTemporalModule
import prefuse.controls.PanControl; //导入依赖的package包/类
public PlotSTPTemporalModule(APSPSolver tm, int xSize, int ySize) {
super();
this.tm = tm;
vis = getNodesAndEdges();
setVisualization(vis);
setSize(xSize, ySize); // set display size
dc = new DragControl();
addControlListener(dc); // drag items around
addControlListener(new PanControl()); // pan with background left-drag
addControlListener(new ZoomControl()); // zoom with vertical right-drag
vis.run("color"); // assign the colors
vis.run("layout"); // start up the animated layout
//touchLBUBNodes();
}
示例2: main
import prefuse.controls.PanControl; //导入依赖的package包/类
/**
* @param args NONE
* @WARNING ONLY CALL PURPOSELY
* static main for testing this class without protege.
* will probably stop working of a interaction with protege is needed
*/
public static void main(String[] args) {
// GraphDataModifier new (Prefuse)display
Display innerDisplay = new Display();
innerDisplay.setDamageRedraw(false);
innerDisplay.setSize(DISPLAY_SIZE_W, DISPLAY_SIZE_H);
innerDisplay.setHighQuality(true);
Graph graph;
// GraphDataModifier new GraphDataModifier with random Data
CreateRandomGraphData crgd = new CreateRandomGraphData();
graph = crgd.create();
String rndViewID = "1";
GraphAddVOWLExample example = new GraphAddVOWLExample();
graph = GraphStorage.getGraph(rndViewID);
/* GraphDataModifier JFrame and JPanel
* needed later do add the display from above.
* Why? Because a JPanel is needed to add it within protege */
JFrame jFrame = new JFrame(JFRAME_NAME);
JPanel jPanel = new JPanel();
jFrame.add(jPanel);
jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
jFrame.add(innerDisplay);
jFrame.pack();
RenderPrefuseGraph rpg = new RenderPrefuseGraph(innerDisplay, graph, "1");
innerDisplay.addControlListener(new DragControl());
innerDisplay.addControlListener(new PanControl());
innerDisplay.addControlListener(new ZoomControl());
innerDisplay.addControlListener(new VOWLWheelZoomControl());
/* show the jFrame
* in this method within a own windows, everywhere als within protege */
jFrame.setVisible(true);
}
示例3: DLGVisualizer
import prefuse.controls.PanControl; //导入依赖的package包/类
public DLGVisualizer(int dx,int dy,DLG g) throws Exception {
// initialize display and data
super(new Visualization());
initDataGroups(g);
// set up the renderers
// draw the nodes as basic shapes
// Renderer nodeR = new ShapeRenderer(20);
LabelRenderer nodeR = new LabelRenderer("name");
nodeR.setHorizontalPadding(4);
nodeR.setVerticalPadding(2);
nodeR.setRoundedCorner(8, 8); // round the corners
EdgeRenderer edgeR = new LabelEdgeRenderer(Constants.EDGE_TYPE_LINE,Constants.EDGE_ARROW_FORWARD);
edgeR.setArrowHeadSize(6,6);
// draw aggregates as polygons with curved edges
PolygonRenderer polyR = new PolygonRenderer(Constants.POLY_TYPE_CURVE);
polyR.setCurveSlack(0.15f);
DefaultRendererFactory drf = new DefaultRendererFactory(nodeR,edgeR);
drf.add("ingroup('aggregates')", polyR);
m_vis.setRendererFactory(drf);
// set up the visual operators
// first set up all the color actions
ColorAction nFill = new ColorAction(NODES, VisualItem.FILLCOLOR);
nFill.setDefaultColor(ColorLib.gray(255));
nFill.add("_hover", ColorLib.gray(200));
ColorAction nEdges = new ColorAction(EDGES, VisualItem.STROKECOLOR);
nEdges.setDefaultColor(ColorLib.gray(100));
// bundle the color actions
ActionList colors = new ActionList();
colors.add(nFill);
colors.add(nEdges);
// now create the main layout routine
ActionList layout = new ActionList(Activity.INFINITY);
ForceDirectedLayout fdl = new ForceDirectedLayout(GRAPH, true);
ForceSimulator m_fsim = new ForceSimulator();
m_fsim.addForce(new NBodyForce());
if (g instanceof TreeDLG) {
m_fsim.addForce(new SpringForce(1E-4f,100));
} else {
m_fsim.addForce(new SpringForce(1E-4f,200));
}
m_fsim.addForce(new DragForce());
fdl.setForceSimulator(m_fsim);
layout.add(colors);
layout.add(fdl);
layout.add(new RepaintAction());
m_vis.putAction("layout", layout);
// set up the display
setSize(dx,dy);
pan(250, 250);
setHighQuality(true);
addControlListener(new AggregateDragControl());
addControlListener(new ZoomControl());
addControlListener(new PanControl());
// ActionList draw = new ActionList();
// draw.add(new GraphDistanceFilter(GRAPH, 50));
// m_vis.putAction("draw", draw);
// set things running
m_vis.run("layout");
}
示例4: initialiseOWLView
import prefuse.controls.PanControl; //导入依赖的package包/类
@Override
protected void initialiseOWLView() throws Exception {
/* TableLayout as layout manager, VOWLViewComponent fills the size of the view component in both directions.
* Useful if the layout is changed later! This LayoutManager is similar to the C# WPF Grid Layout,
* {0.8, TableLayout.FILL} for 80% of the size for view 1 and the rest for view 2.
*/
TableLayout pluginGraphViewComponentLayout = new TableLayout(new double[][]{{TableLayout.FILL},
{TableLayout.FILL}});
setLayout(pluginGraphViewComponentLayout);
/* The viewManagerID is an String extracted from the ViewManager of the current OWLWorkspace.
* It is used to identify the data which belongs to the current Protégé window.
* Within Protégé the user can open different ontologies, which can be shown within the same window or
* within different windows. If the are shown within different windows, they are the same protege instance.
* So an identifier is needed which is different for each protege instance but ontology independent. */
String viewManagerID = getOWLWorkspace().getViewManager().toString();
// create new display if it doesn't exist yet
if (prefuseGraphDisplay == null) {
prefuseGraphDisplay = new Display();
prefuseGraphDisplay.setDamageRedraw(false);
prefuseGraphDisplay.setHighQuality(true);
}
// add listenere here to avoid adding more then one listener later (while the ontology is reloaded)
prefuseGraphDisplay.addControlListener(new DragControl());
prefuseGraphDisplay.addControlListener(new PanControl());
prefuseGraphDisplay.addControlListener(new ZoomControl());
// like WheelZoomControl except the zooming direction is inverted, mouse wheel up to get closer to the object
prefuseGraphDisplay.addControlListener(new VOWLWheelZoomControl());
// add tooltip support
prefuseGraphDisplay.addControlListener(new ControlListener(viewManagerID));
GraphStorage.newGraph(viewManagerID);
// save the current OWLManager for later use (needed to reload the ontology later)
OWLModelManagerStorage.setOWLManager(getOWLModelManager(), viewManagerID);
// save the current display used from prefuse (needed to reload the ontology later)
DisplayStorage.addPrefuseDisplay(prefuseGraphDisplay, viewManagerID);
OWLOntology onto = getOWLModelManager().getActiveOntology();
TransformOWLtoGraph twtg = new TransformOWLtoGraph();
twtg.transformOWLtoGraph(onto, viewManagerID);
// GraphDataModifier prefuse GraphDataModifier view
@SuppressWarnings("unused")
RenderPrefuseGraph p = new RenderPrefuseGraph(prefuseGraphDisplay, GraphStorage.getGraph(viewManagerID), viewManagerID);
// Try to center the graph. Why *-1? Seems the offset between the view and the visualization can be balanced
// this way
if (!prefuseGraphDisplay.isTranformInProgress()) {
int x = (int) prefuseGraphDisplay.getBounds().getCenterX() * -1;
int y = (int) prefuseGraphDisplay.getBounds().getCenterY() * -1;
final Point center = new Point(x, y);
prefuseGraphDisplay.animatePanToAbs(center, 100);
}
add(prefuseGraphDisplay, "0,0");
}
示例5: StackedGraphDisplay
import prefuse.controls.PanControl; //导入依赖的package包/类
StackedGraphDisplay()
{
super( new Visualization() );
setBackground( ColorLib.getColor( 0, 51, 88 ) );
LabelRenderer labelRenderer = new LabelRenderer( NAME_LABEL );
labelRenderer.setVerticalAlignment( Constants.BOTTOM );
labelRenderer.setHorizontalAlignment( Constants.LEFT );
EdgeRenderer usesRenderer = new EdgeRenderer( Constants.EDGE_TYPE_CURVE, Constants.EDGE_ARROW_FORWARD );
usesRenderer.setHorizontalAlignment1( Constants.CENTER );
usesRenderer.setHorizontalAlignment2( Constants.CENTER );
usesRenderer.setVerticalAlignment1( Constants.BOTTOM );
usesRenderer.setVerticalAlignment2( Constants.TOP );
Predicate usesPredicate = (Predicate) ExpressionParser.parse( "ingroup('graph.edges') AND [" + USES_EDGES + "]==true", true );
// set up the renderers - one for nodes and one for LABELS
DefaultRendererFactory rf = new DefaultRendererFactory();
rf.add( new InGroupPredicate( GRAPH_NODES ), new NodeRenderer() );
rf.add( new InGroupPredicate( LABELS ), labelRenderer );
rf.add( usesPredicate, usesRenderer );
m_vis.setRendererFactory( rf );
// border colors
ColorAction borderColor = new BorderColorAction( GRAPH_NODES );
ColorAction fillColor = new FillColorAction( GRAPH_NODES );
// uses edge colors
ItemAction usesColor = new ColorAction( GRAPH_EDGES, usesPredicate, VisualItem.STROKECOLOR, ColorLib.rgb( 50, 50, 50 ) );
ItemAction usesArrow = new ColorAction( GRAPH_EDGES, usesPredicate, VisualItem.FILLCOLOR, ColorLib.rgb( 50, 50, 50 ) );
// color settings
ActionList colors = new ActionList();
colors.add( fillColor );
colors.add( borderColor );
colors.add( usesColor );
colors.add( usesArrow );
m_vis.putAction( COLORS_ACTION, colors );
ActionList autoPan = new ActionList();
autoPan.add( colors );
autoPan.add( new AutoPanAction() );
autoPan.add( new RepaintAction() );
m_vis.putAction( AUTO_PAN_ACTION, autoPan );
// create the layout action list
stackedLayout = new StackedLayout( GRAPH );
ActionList layout = new ActionList();
layout.add( stackedLayout );
layout.add( new LabelLayout( LABELS ) );
layout.add( autoPan );
m_vis.putAction( LAYOUT_ACTION, layout );
// initialize our display
Dimension size = new Dimension( 400, 400 );
setSize( size );
setPreferredSize( size );
setItemSorter( new ExtendedTreeDepthItemSorter( true ) );
addControlListener( new HoverControl() );
addControlListener( new FocusControl( 1, COLORS_ACTION ) );
addControlListener( new WheelMouseControl() );
addControlListener( new PanControl( true ) );
addControlListener( new ItemSelectionControl() );
setDamageRedraw( true );
}
示例6: AggregateDemo
import prefuse.controls.PanControl; //导入依赖的package包/类
public AggregateDemo() {
// initialize display and data
super(new Visualization());
//initDataGroups();
// set up the renderers
// draw the nodes as basic shapes
LabelRenderer nodeR = new LabelRenderer();
nodeR.setImageField("image");
nodeR.setTextField(null);
// draw aggregates as polygons with curved edges
Renderer polyR = new PolygonRenderer(Constants.POLY_TYPE_CURVE);
((PolygonRenderer)polyR).setCurveSlack(0.15f);
DefaultRendererFactory drf = new DefaultRendererFactory();
drf.setDefaultRenderer(nodeR);
drf.add("ingroup('aggregates')", polyR);
m_vis.setRendererFactory(drf);
// set up the visual operators
// first set up all the color actions
ColorAction nStroke = new ColorAction(NODES, VisualItem.STROKECOLOR);
nStroke.setDefaultColor(ColorLib.gray(100));
nStroke.add("_hover", ColorLib.gray(50));
ColorAction nFill = new ColorAction(NODES, VisualItem.FILLCOLOR);
nFill.setDefaultColor(ColorLib.gray(255));
nFill.add("_hover", ColorLib.gray(200));
ColorAction nEdges = new ColorAction(EDGES, VisualItem.STROKECOLOR);
nEdges.setDefaultColor(ColorLib.gray(100));
ColorAction aStroke = new ColorAction(AGGR, VisualItem.STROKECOLOR);
aStroke.setDefaultColor(ColorLib.gray(200));
aStroke.add("_hover", ColorLib.rgb(255,100,100));
int[] palette = new int[] {
ColorLib.rgba(255,200,200,150),
ColorLib.rgba(200,255,200,150),
ColorLib.rgba(200,200,255,150)
};
ColorAction aFill = new DataColorAction(AGGR, "id",
Constants.NOMINAL, VisualItem.FILLCOLOR, palette);
// bundle the color actions
ActionList colors = new ActionList();
colors.add(nStroke);
colors.add(nFill);
colors.add(nEdges);
colors.add(aStroke);
colors.add(aFill);
// now create the main layout routine
ActionList layout = new ActionList(Activity.INFINITY);
layout.add(colors);
layout.add(new MyForcedDirectedLayout(GRAPH));
layout.add(new AggregateLayout(AGGR));
layout.add(new RepaintAction());
m_vis.putAction("layout", layout);
// set up the display
setSize(500,500);
pan(250, 250);
setHighQuality(false);
addControlListener(new AggregateDragControl());
addControlListener(new ZoomControl());
addControlListener(new PanControl());
// set things running
//m_vis.run("layout");
}
示例7: AggregateDemo
import prefuse.controls.PanControl; //导入依赖的package包/类
public AggregateDemo() {
// initialize display and data
super(new Visualization());
initDataGroups();
// set up the renderers
// draw the nodes as basic shapes
Renderer nodeR = new ShapeRenderer(20);
// draw aggregates as polygons with curved edges
Renderer polyR = new PolygonRenderer(Constants.POLY_TYPE_CURVE);
((PolygonRenderer)polyR).setCurveSlack(0.15f);
DefaultRendererFactory drf = new DefaultRendererFactory();
drf.setDefaultRenderer(nodeR);
drf.add("ingroup('aggregates')", polyR);
m_vis.setRendererFactory(drf);
// set up the visual operators
// first set up all the color actions
ColorAction nStroke = new ColorAction(NODES, VisualItem.STROKECOLOR);
nStroke.setDefaultColor(ColorLib.gray(100));
nStroke.add("_hover", ColorLib.gray(50));
ColorAction nFill = new ColorAction(NODES, VisualItem.FILLCOLOR);
nFill.setDefaultColor(ColorLib.gray(255));
nFill.add("_hover", ColorLib.gray(200));
ColorAction nEdges = new ColorAction(EDGES, VisualItem.STROKECOLOR);
nEdges.setDefaultColor(ColorLib.gray(100));
ColorAction aStroke = new ColorAction(AGGR, VisualItem.STROKECOLOR);
aStroke.setDefaultColor(ColorLib.gray(200));
aStroke.add("_hover", ColorLib.rgb(255,100,100));
int[] palette = new int[] {
ColorLib.rgba(255,200,200,150),
ColorLib.rgba(200,255,200,150),
ColorLib.rgba(200,200,255,150)
};
ColorAction aFill = new DataColorAction(AGGR, "id",
Constants.NOMINAL, VisualItem.FILLCOLOR, palette);
// bundle the color actions
ActionList colors = new ActionList();
colors.add(nStroke);
colors.add(nFill);
colors.add(nEdges);
colors.add(aStroke);
colors.add(aFill);
// now create the main layout routine
ActionList layout = new ActionList(Activity.INFINITY);
layout.add(colors);
layout.add(new ForceDirectedLayout(GRAPH, true));
layout.add(new AggregateLayout(AGGR));
layout.add(new RepaintAction());
m_vis.putAction("layout", layout);
// set up the display
setSize(500,500);
pan(250, 250);
setHighQuality(true);
addControlListener(new AggregateDragControl());
addControlListener(new ZoomControl());
addControlListener(new PanControl());
// set things running
m_vis.run("layout");
}
示例8: CodyTestWindow
import prefuse.controls.PanControl; //导入依赖的package包/类
public CodyTestWindow() {
// initialize display and data
super(new Visualization());
initDataGroups();
// set up the renderers
// draw the nodes as basic shapes
Renderer nodeR = new ShapeRenderer(20);
// draw aggregates as polygons with curved edges
Renderer polyR = new PolygonRenderer(Constants.POLY_TYPE_CURVE);
((PolygonRenderer)polyR).setCurveSlack(0.15f);
DefaultRendererFactory drf = new DefaultRendererFactory();
drf.setDefaultRenderer(nodeR);
drf.add("ingroup('aggregates')", polyR);
m_vis.setRendererFactory(drf);
// set up the visual operators
// first set up all the color actions
ColorAction nStroke = new ColorAction(NODES, VisualItem.STROKECOLOR);
nStroke.setDefaultColor(ColorLib.gray(100));
nStroke.add("_hover", ColorLib.gray(50));
ColorAction nFill = new ColorAction(NODES, VisualItem.FILLCOLOR);
nFill.setDefaultColor(ColorLib.gray(255));
nFill.add("_hover", ColorLib.gray(200));
ColorAction nEdges = new ColorAction(EDGES, VisualItem.STROKECOLOR);
nEdges.setDefaultColor(ColorLib.gray(100));
ColorAction aStroke = new ColorAction(AGGR, VisualItem.STROKECOLOR);
aStroke.setDefaultColor(ColorLib.gray(200));
aStroke.add("_hover", ColorLib.rgb(255,100,100));
int[] palette = new int[] {
ColorLib.rgba(255,200,200,150),
ColorLib.rgba(200,255,200,150),
ColorLib.rgba(200,200,255,150)
};
ColorAction aFill = new DataColorAction(AGGR, "id",
Constants.NOMINAL, VisualItem.FILLCOLOR, palette);
// bundle the color actions
ActionList colors = new ActionList();
colors.add(nStroke);
colors.add(nFill);
colors.add(nEdges);
colors.add(aStroke);
colors.add(aFill);
// now create the main layout routine
ActionList layout = new ActionList(Activity.INFINITY);
layout.add(colors);
layout.add(new ForceDirectedLayout(GRAPH, true));
layout.add(new AggregateLayout(AGGR));
layout.add(new RepaintAction());
m_vis.putAction("layout", layout);
// set up the display
setSize(500,500);
pan(250, 250);
setHighQuality(true);
addControlListener(new AggregateDragControl());
addControlListener(new ZoomControl());
addControlListener(new PanControl());
// set things running
m_vis.run("layout");
}
示例9: initVisualization
import prefuse.controls.PanControl; //导入依赖的package包/类
private void initVisualization() {
/*try
{
graph = new GraphMLReader().readGraph("/socialnet.xml");
} catch ( DataIOException e ) {
e.printStackTrace();
System.err.println("Error loading graph. Exiting...");
System.exit(1);
}*/
Graph graph = data.getIPGraph();
vis = new Visualization();
vis.add(GRAPH, graph);
LabelRenderer r = new LabelRenderer(data.ADDRESS);
r.setRoundedCorner(8,8);
r.setRenderType(LabelRenderer.RENDER_TYPE_DRAW_AND_FILL);
vis.setRendererFactory(new DefaultRendererFactory(r));
/*int [] palette = new int[] {
ColorLib.rgb(255,180,180), ColorLib.rgb(190,190,255)
};
DataColorAction fill = new DataColorAction("graph.nodes","gender",
Constants.NOMINAL,VisualItem.FILLCOLOR,palette);*/
ColorAction draw = new ColorAction(NODES,VisualItem.STROKECOLOR,ColorLib.gray(0));
ColorAction fill = new ColorAction(NODES,VisualItem.FILLCOLOR,ColorLib.rgb(210, 210, 255));
ColorAction text = new ColorAction(NODES,VisualItem.TEXTCOLOR,ColorLib.gray(0));
ColorAction edges = new ColorAction(EDGES,VisualItem.STROKECOLOR,ColorLib.gray(200));
ActionList color = new ActionList(Activity.INFINITY,1000);
color.add(data.getLockAction());
color.add(draw);
color.add(fill);
color.add(text);
color.add(edges);
color.add(data.getUnlockAction());
//ActionList layout = new ActionList(Activity.INFINITY,100);
ActionList layout = new ActionList(Activity.INFINITY,1000);
layout.add(data.getLockAction());
layout.add(new GridMinusCircle(150,10,NODES));
layout.add(data.getUnlockAction());
layout.add(new RepaintAction());
vis.putAction(COLOR, color);
vis.putAction(LAYOUT,layout);
display = new Display(vis);
display.setSize(720,500);
display.addControlListener(new ZoomControl());
display.addControlListener(new DragControl());
display.addControlListener(new PanControl());
TupleTableModel ttm = new TupleTableModel(graph.getEdgeTable());
node_table = new JTable(ttm);
node_table.getTableHeader().addMouseListener(ttm);
//ttm.addTableModelListener(node_table);
//node_table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
node_table.addMouseListener(new JTableMouseListener());
}
示例10: AggregateDecoratorDemo
import prefuse.controls.PanControl; //导入依赖的package包/类
public AggregateDecoratorDemo() {
// initialize display and data
super(new Visualization());
initDataGroups();
// set up the renderers
// draw the nodes as basic shapes
Renderer nodeR = new ShapeRenderer(20);
// draw aggregates as polygons with curved edges
Renderer polyR = new PolygonRenderer(Constants.POLY_TYPE_CURVE);
((PolygonRenderer)polyR).setCurveSlack(0.15f);
DefaultRendererFactory drf = new DefaultRendererFactory();
drf.setDefaultRenderer(nodeR);
drf.add("ingroup('aggregates')", polyR);
drf.add(new InGroupPredicate(EDGE_DECORATORS), new LabelRenderer(VisualItem.LABEL));
drf.add(new InGroupPredicate(NODE_DECORATORS), new LabelRenderer(VisualItem.LABEL));
drf.add(new InGroupPredicate(AGGR_DECORATORS), new LabelRenderer("id"));
m_vis.setRendererFactory(drf);
// adding decorators, one group for the nodes, one for the edges and one
// for the aggregates
DECORATOR_SCHEMA.setDefault(VisualItem.TEXTCOLOR, ColorLib.gray(0));
m_vis.addDecorators(EDGE_DECORATORS, EDGES, DECORATOR_SCHEMA);
DECORATOR_SCHEMA.setDefault(VisualItem.TEXTCOLOR, ColorLib.gray(128));
m_vis.addDecorators(NODE_DECORATORS, NODES, DECORATOR_SCHEMA);
// the HoverPredicate makes this group of decorators to appear only on mouseOver
DECORATOR_SCHEMA.setDefault(VisualItem.TEXTCOLOR, ColorLib.gray(255, 128));
DECORATOR_SCHEMA.setDefault(VisualItem.FONT, FontLib.getFont("Tahoma", Font.BOLD, 48));
m_vis.addDecorators(AGGR_DECORATORS, AGGR, new HoverPredicate(), DECORATOR_SCHEMA);
// set up the visual operators
// first set up all the color actions
ColorAction nStroke = new ColorAction(NODES, VisualItem.STROKECOLOR);
nStroke.setDefaultColor(ColorLib.gray(100));
nStroke.add("_hover", ColorLib.gray(50));
ColorAction nFill = new ColorAction(NODES, VisualItem.FILLCOLOR);
nFill.setDefaultColor(ColorLib.gray(255));
nFill.add("_hover", ColorLib.gray(200));
ColorAction nEdges = new ColorAction(EDGES, VisualItem.STROKECOLOR);
nEdges.setDefaultColor(ColorLib.gray(100));
ColorAction aStroke = new ColorAction(AGGR, VisualItem.STROKECOLOR);
aStroke.setDefaultColor(ColorLib.gray(200));
aStroke.add("_hover", ColorLib.rgb(255,100,100));
int[] palette = new int[] {
ColorLib.rgba(255,200,200,150),
ColorLib.rgba(200,255,200,150),
ColorLib.rgba(200,200,255,150)
};
ColorAction aFill = new DataColorAction(AGGR, "id",
Constants.NOMINAL, VisualItem.FILLCOLOR, palette);
// bundle the color actions
ActionList colors = new ActionList();
colors.add(nStroke);
colors.add(nFill);
colors.add(nEdges);
colors.add(aStroke);
colors.add(aFill);
// now create the main layout routine
ActionList layout = new ActionList(Activity.INFINITY);
layout.add(colors);
layout.add(new ForceDirectedLayout(GRAPH, true));
layout.add(new AggregateLayout2(AGGR));
layout.add(new LabelLayout2(EDGE_DECORATORS));
layout.add(new LabelLayout2(NODE_DECORATORS));
layout.add(new LabelLayout2(AGGR_DECORATORS));
layout.add(new RepaintAction());
m_vis.putAction("layout", layout);
// set up the display
setSize(500,500);
pan(250, 250);
setHighQuality(true);
addControlListener(new AggregateDragControl2());
addControlListener(new ZoomControl());
addControlListener(new PanControl());
// set things running
m_vis.run("layout");
}
示例11: AggregateDecoratorDemo
import prefuse.controls.PanControl; //导入依赖的package包/类
public AggregateDecoratorDemo() {
// initialize display and data
super(new Visualization());
initDataGroups();
// set up the renderers
// draw the nodes as basic shapes
Renderer nodeR = new ShapeRenderer(20);
// draw aggregates as polygons with curved edges
Renderer polyR = new PolygonRenderer(Constants.POLY_TYPE_CURVE);
((PolygonRenderer)polyR).setCurveSlack(0.15f);
DefaultRendererFactory drf = new DefaultRendererFactory();
drf.setDefaultRenderer(nodeR);
drf.add("ingroup('aggregates')", polyR);
drf.add(new InGroupPredicate(EDGE_DECORATORS), new LabelRenderer(VisualItem.LABEL));
drf.add(new InGroupPredicate(NODE_DECORATORS), new LabelRenderer(VisualItem.LABEL));
drf.add(new InGroupPredicate(AGGR_DECORATORS), new LabelRenderer("id"));
m_vis.setRendererFactory(drf);
// adding decorators, one group for the nodes, one for the edges and one
// for the aggregates
DECORATOR_SCHEMA.setDefault(VisualItem.TEXTCOLOR, ColorLib.gray(0));
m_vis.addDecorators(EDGE_DECORATORS, EDGES, DECORATOR_SCHEMA);
DECORATOR_SCHEMA.setDefault(VisualItem.TEXTCOLOR, ColorLib.gray(128));
m_vis.addDecorators(NODE_DECORATORS, NODES, DECORATOR_SCHEMA);
// the HoverPredicate makes this group of decorators to appear only on mouseOver
DECORATOR_SCHEMA.setDefault(VisualItem.TEXTCOLOR, ColorLib.gray(255, 128));
DECORATOR_SCHEMA.setDefault(VisualItem.FONT, FontLib.getFont("Tahoma", Font.BOLD, 48));
m_vis.addDecorators(AGGR_DECORATORS, AGGR, new HoverPredicate(), DECORATOR_SCHEMA);
// set up the visual operators
// first set up all the color actions
ColorAction nStroke = new ColorAction(NODES, VisualItem.STROKECOLOR);
nStroke.setDefaultColor(ColorLib.gray(100));
nStroke.add("_hover", ColorLib.gray(50));
ColorAction nFill = new ColorAction(NODES, VisualItem.FILLCOLOR);
nFill.setDefaultColor(ColorLib.gray(255));
nFill.add("_hover", ColorLib.gray(200));
ColorAction nEdges = new ColorAction(EDGES, VisualItem.STROKECOLOR);
nEdges.setDefaultColor(ColorLib.gray(100));
ColorAction aStroke = new ColorAction(AGGR, VisualItem.STROKECOLOR);
aStroke.setDefaultColor(ColorLib.gray(200));
aStroke.add("_hover", ColorLib.rgb(255,100,100));
int[] palette = new int[] {
ColorLib.rgba(255,200,200,150),
ColorLib.rgba(200,255,200,150),
ColorLib.rgba(200,200,255,150)
};
ColorAction aFill = new DataColorAction(AGGR, "id",
Constants.NOMINAL, VisualItem.FILLCOLOR, palette);
// bundle the color actions
ActionList colors = new ActionList();
colors.add(nStroke);
colors.add(nFill);
colors.add(nEdges);
colors.add(aStroke);
colors.add(aFill);
// now create the main layout routine
ActionList layout = new ActionList(Activity.INFINITY);
layout.add(colors);
layout.add(new ForceDirectedLayout(GRAPH, true));
layout.add(new AggregateLayout(AGGR));
layout.add(new LabelLayout2(EDGE_DECORATORS));
layout.add(new LabelLayout2(NODE_DECORATORS));
layout.add(new LabelLayout2(AGGR_DECORATORS));
layout.add(new RepaintAction());
m_vis.putAction("layout", layout);
// set up the display
setSize(500,500);
pan(250, 250);
setHighQuality(true);
addControlListener(new AggregateDragControl());
addControlListener(new ZoomControl());
addControlListener(new PanControl());
// set things running
m_vis.run("layout");
}
示例12: ArgumentationGraphVisualizer
import prefuse.controls.PanControl; //导入依赖的package包/类
/**
* Instantiates a new argumentation graph visualizer.
*
* @param dx
* the dx
* @param dy
* the dy
* @param ag
* the ag
* @param dm
* the dm
* @throws FeatureTermException
* the feature term exception
*/
public ArgumentationGraphVisualizer(int dx, int dy, WArgumentationFramework ag, FTKBase dm) throws FeatureTermException {
// initialize display and data
super(new Visualization());
initDataGroups(ag);
// set up the renderers
// draw the nodes as basic shapes
// Renderer nodeR = new ShapeRenderer(20);
LabelRenderer nodeR = new LabelRenderer("name");
nodeR.setHorizontalPadding(4);
nodeR.setVerticalPadding(2);
nodeR.setRoundedCorner(8, 8); // round the corners
EdgeRenderer edgeR = new LabelEdgeRenderer(Constants.EDGE_TYPE_LINE, Constants.EDGE_ARROW_FORWARD);
edgeR.setArrowHeadSize(6, 6);
DefaultRendererFactory drf = new DefaultRendererFactory(nodeR, edgeR);
m_vis.setRendererFactory(drf);
// set up the visual operators
// first set up all the color actions
ColorAction nFill = new ColorAction(NODES, VisualItem.FILLCOLOR);
nFill.setDefaultColor(ColorLib.gray(255));
nFill.add("_hover", ColorLib.gray(200));
ColorAction nEdges = new ColorAction(EDGES, VisualItem.STROKECOLOR);
nEdges.setDefaultColor(ColorLib.gray(100));
int[] palette = new int[] { ColorLib.rgba(255, 200, 200, 150), ColorLib.rgba(200, 255, 200, 150), ColorLib.rgba(200, 200, 255, 150) };
// bundle the color actions
ActionList colors = new ActionList();
colors.add(nFill);
colors.add(nEdges);
// now create the main layout routine
ActionList layout = new ActionList(Activity.INFINITY);
ForceDirectedLayout fdl = new ForceDirectedLayout(GRAPH, true);
ForceSimulator m_fsim = new ForceSimulator();
m_fsim.addForce(new NBodyForce());
m_fsim.addForce(new SpringForce(1E-4f, 200));
m_fsim.addForce(new DragForce());
fdl.setForceSimulator(m_fsim);
layout.add(colors);
layout.add(fdl);
layout.add(new RepaintAction());
m_vis.putAction("layout", layout);
// set up the display
setSize(dx, dy);
pan(250, 250);
setHighQuality(true);
addControlListener(new DragControl());
addControlListener(new ZoomControl());
addControlListener(new PanControl());
addControlListener(new ArgumentSelectControl(ag.getArguments(), dm, this));
// ActionList draw = new ActionList();
// draw.add(new GraphDistanceFilter(GRAPH, 50));
// m_vis.putAction("draw", draw);
// set things running
m_vis.run("layout");
}
示例13: initialiseGraphView
import prefuse.controls.PanControl; //导入依赖的package包/类
private void initialiseGraphView(Graph g, String label, int orientation, Dimension size) {
setSize(size);
m_vis = new Visualization();
m_vis.addFocusGroup("selected");
m_vis.addFocusGroup("highlighted");
MultiScaleLabelRenderer tr = new MultiScaleLabelRenderer("value", label.contains("image") ? label : null);
tr.setImagePosition(Constants.TOP);
m_vis.setRendererFactory(new DefaultRendererFactory(tr));
// adds graph to visualization and sets renderer label field
setGraph(g);
int hops = Integer.MAX_VALUE;
final GraphDistanceFilter filter = new GraphDistanceFilter(graph, hops);
FontAction font = new FontAction(nodes, UIHelper.VER_8_PLAIN);
ColorAction fill = new ColorAction(nodes, VisualItem.FILLCOLOR, ColorLib.rgb(255, 255, 255));
fill.add("ingroup('highlighted')", ColorLib.rgb(241, 242, 242));
fill.add("ingroup('selected')", ColorLib.rgb(241, 242, 242));
ColorAction stroke = new ColorAction(nodes, VisualItem.STROKECOLOR, backgroundColor);
StrokeAction strokeWeight = new StrokeAction(nodes, StrokeLib.getStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
stroke.add("ingroup('highlighted')", ColorLib.rgb(224, 228, 204));
stroke.add("ingroup('selected')", ColorLib.rgb(202, 106, 33));
ActionList draw = new ActionList(500);
draw.add(font);
draw.add(filter);
draw.add(fill);
draw.add(stroke);
draw.add(strokeWeight);
draw.add(new ColorAction(nodes, VisualItem.TEXTCOLOR, ColorLib.rgb(109, 110, 113)));
draw.add(new ColorAction(edges, VisualItem.FILLCOLOR, ColorLib.gray(200)));
draw.add(new ColorAction(edges, VisualItem.STROKECOLOR, ColorLib.gray(200)));
draw.add(new RepaintAction());
ActionList animate = new ActionList();
NodeLinkTreeLayout layout = new NodeLinkTreeLayout(graph);
layout.setDepthSpacing(80);
layout.setBreadthSpacing(70);
layout.setOrientation(orientation);
animate.add(new QualityControlAnimator());
animate.add(new LocationAnimator(nodes));
animate.add(layout);
m_vis.putAction("draw", draw);
m_vis.putAction("layout", animate);
// set up a display to show the visualization
display = new Display(m_vis);
display.setSize(size);
// main display controls
display.addControlListener(new PanControl());
display.addControlListener(new ZoomControl());
display.addControlListener(new WheelZoomControl());
display.addControlListener(new ZoomToFitControl());
// now we run our action list
m_vis.run("draw");
m_vis.run("layout");
add(display);
}