本文整理汇总了Java中prefuse.visual.VisualGraph类的典型用法代码示例。如果您正苦于以下问题:Java VisualGraph类的具体用法?Java VisualGraph怎么用?Java VisualGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VisualGraph类属于prefuse.visual包,在下文中一共展示了VisualGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initDataGroups
import prefuse.visual.VisualGraph; //导入依赖的package包/类
private void initDataGroups() {
// create sample graph
// 9 nodes broken up into 3 interconnected cliques
Graph g = new Graph();
for ( int i=0; i<3; ++i ) {
Node n1 = g.addNode();
Node n2 = g.addNode();
Node n3 = g.addNode();
}
// add visual data groups
VisualGraph vg = m_vis.addGraph(GRAPH, g);
m_vis.setInteractive(EDGES, null, false);
m_vis.setValue(NODES, null, VisualItem.SHAPE,
new Integer(Constants.SHAPE_ELLIPSE));
AggregateTable at = m_vis.addAggregates(AGGR);
at.addColumn(VisualItem.POLYGON, float[].class);
at.addColumn("id", int.class);
}
示例2: run
import prefuse.visual.VisualGraph; //导入依赖的package包/类
@Override
public void run(double frac) {
// get a visual table for line segments
VisualTable lines = getTable();
// get all nodes at depth-1
VisualGraph graph = (VisualGraph) m_vis.getGroup(m_src);
@SuppressWarnings("rawtypes")
Iterator nodeIterator = graph.getNodeTable().tuples(
new ComparisonPredicate(ComparisonPredicate.EQ,
new ColumnExpression(ParentChildNode.DEPTH),
new NumericLiteral(depth - 1)));
// connect children of these nodes
while (nodeIterator.hasNext()) {
NodeItem node = (NodeItem) nodeIterator.next();
// TODO assumption that children are ordered or reversely ordered
super.connectPoints(lines, node.inNeighbors());
}
}
示例3: run
import prefuse.visual.VisualGraph; //导入依赖的package包/类
@Override
public void run(double frac) {
TupleSet ts = m_vis.getGroup(m_group);
if(!(ts instanceof VisualGraph))
throw new UnsupportedOperationException();
setMinMax();
switch ( getDataType(((VisualGraph)ts).getNodes()) ) {
case Constants.NUMERICAL:
numericalLayout((VisualGraph)ts);
break;
default:
ordinalLayout((VisualGraph)ts);
}
}
示例4: initDataGroups
import prefuse.visual.VisualGraph; //导入依赖的package包/类
private void initDataGroups() {
// create sample graph
// 9 nodes broken up into 3 interconnected cliques
Graph g = new Graph();
for ( int i=0; i<3; ++i ) {
Node n1 = g.addNode();
Node n2 = g.addNode();
Node n3 = g.addNode();
g.addEdge(n1, n2);
g.addEdge(n1, n3);
g.addEdge(n2, n3);
}
g.addEdge(0, 3);
g.addEdge(3, 6);
g.addEdge(6, 0);
// add visual data groups
VisualGraph vg = m_vis.addGraph(GRAPH, g);
m_vis.setInteractive(EDGES, null, false);
m_vis.setValue(NODES, null, VisualItem.SHAPE,
new Integer(Constants.SHAPE_ELLIPSE));
AggregateTable at = m_vis.addAggregates(AGGR);
at.addColumn(VisualItem.POLYGON, float[].class);
at.addColumn("id", int.class);
// add nodes to aggregates
// create an aggregate for each 3-clique of nodes
Iterator nodes = vg.nodes();
for ( int i=0; i<3; ++i ) {
AggregateItem aitem = (AggregateItem)at.addItem();
aitem.setInt("id", i);
for ( int j=0; j<3; ++j ) {
aitem.addItem((VisualItem)nodes.next());
}
}
}
示例5: setGraph
import prefuse.visual.VisualGraph; //导入依赖的package包/类
public void setGraph(Graph g, String label) {
// update labeling
DefaultRendererFactory drf = (DefaultRendererFactory)
m_vis.getRendererFactory();
((LabelRenderer)drf.getDefaultRenderer()).setTextField(label);
// update graph
m_vis.removeGroup(graph);
VisualGraph vg = m_vis.addGraph(graph, g);
m_vis.setValue(edges, null, VisualItem.INTERACTIVE, Boolean.FALSE);
VisualItem f = (VisualItem)vg.getNode(0);
m_vis.getGroup(Visualization.FOCUS_ITEMS).setTuple(f);
f.setFixed(false);
}
示例6: initDataGroups
import prefuse.visual.VisualGraph; //导入依赖的package包/类
private void initDataGroups() {
// create sample graph
// 9 nodes broken up into 3 interconnected cliques
Graph g = new Graph();
for ( int i=0; i<3; ++i ) {
Node n1 = g.addNode();
Node n2 = g.addNode();
Node n3 = g.addNode();
g.addEdge(n1, n2);
g.addEdge(n1, n3);
g.addEdge(n2, n3);
}
g.addEdge(0, 3);
g.addEdge(3, 6);
g.addEdge(6, 0);
// add visual data groups
VisualGraph vg = m_vis.addGraph(GRAPH, g);
m_vis.setInteractive(EDGES, null, false);
m_vis.setValue(NODES, null, VisualItem.SHAPE,
new Integer(Constants.SHAPE_ELLIPSE));
AggregateTable at = m_vis.addAggregates(AGGR);
at.addColumn(VisualItem.POLYGON, float[].class);
at.addColumn("id", int.class);
// add nodes to aggregates
// create an aggregate for each 3-clique of nodes
Iterator<?> nodes = vg.nodes();
for ( int i=0; i<3; ++i ) {
AggregateItem aitem = (AggregateItem)at.addItem();
aitem.setInt("id", i);
for ( int j=0; j<3; ++j ) {
aitem.addItem((VisualItem)nodes.next());
}
}
}
示例7: initDataGroups
import prefuse.visual.VisualGraph; //导入依赖的package包/类
private void initDataGroups() {
// create sample graph
// 9 nodes broken up into 3 interconnected cliques
Graph g = new Graph();
for ( int i=0; i<3; ++i ) {
Node n1 = g.addNode();
Node n2 = g.addNode();
Node n3 = g.addNode();
g.addEdge(n1, n2);
g.addEdge(n1, n3);
g.addEdge(n2, n3);
}
g.addEdge(0, 3);
g.addEdge(3, 6);
g.addEdge(6, 0);
// add labels for nodes and edges
g.addColumn(VisualItem.LABEL, String.class);
for (int i = 0; i < 9; i++) {
g.getNode(i).setString(VisualItem.LABEL, ""+i);
g.getEdge(i).setString(VisualItem.LABEL, ""+i);
}
// add visual data groups
VisualGraph vg = m_vis.addGraph(GRAPH, g);
m_vis.setInteractive(EDGES, null, false);
m_vis.setValue(NODES, null, VisualItem.SHAPE,
new Integer(Constants.SHAPE_ELLIPSE));
AggregateTable at = m_vis.addAggregates(AGGR);
at.addColumn(VisualItem.POLYGON, float[].class);
at.addColumn("id", int.class);
// add nodes to aggregates
// create an aggregate for each 3-clique of nodes
Iterator nodes = vg.nodes();
for ( int i=0; i<3; ++i ) {
AggregateItem aitem = (AggregateItem)at.addItem();
aitem.setInt("id", i);
for ( int j=0; j<3; ++j ) {
aitem.addItem((VisualItem)nodes.next());
}
}
}
示例8: addGraph
import prefuse.visual.VisualGraph; //导入依赖的package包/类
/**
* Adds a graph to this visualization, using the given data group
* name. A visual abstraction of the data will be created and registered
* with the visualization. An exception will be thrown if the group name
* is already in use.
* @param group the data group name for the visualized graph. The nodes
* and edges will be available in the "group.nodes" and "group.edges"
* subgroups.
* @param graph the graph to visualize
* @param filter a filter Predicate determining which data Tuples in the
* input graph are visualized
* @param nodeSchema the data schema to use for the visual node table
* @param edgeSchema the data schema to use for the visual edge table
*/
public synchronized VisualGraph addGraph(String group, Graph graph,
Predicate filter, Schema nodeSchema, Schema edgeSchema)
{
checkGroupExists(group); // check before adding sub-tables
String ngroup = PrefuseLib.getGroupName(group, Graph.NODES);
String egroup = PrefuseLib.getGroupName(group, Graph.EDGES);
VisualTable nt, et;
nt = addTable(ngroup, graph.getNodeTable(), filter, nodeSchema);
et = addTable(egroup, graph.getEdgeTable(), filter, edgeSchema);
VisualGraph vg = new VisualGraph(nt, et,
graph.isDirected(), graph.getNodeKeyField(),
graph.getEdgeSourceField(), graph.getEdgeTargetField());
vg.setVisualization(this);
vg.setGroup(group);
addDataGroup(group, vg, graph);
TupleManager ntm = new TupleManager(nt, vg, TableNodeItem.class);
TupleManager etm = new TupleManager(et, vg, TableEdgeItem.class);
nt.setTupleManager(ntm);
et.setTupleManager(etm);
vg.setTupleManagers(ntm, etm);
return vg;
}
示例9: run
import prefuse.visual.VisualGraph; //导入依赖的package包/类
@Override
public void run(double frac) {
Display display = m_vis.getDisplay(0);
Rectangle position = new Rectangle(vDepth*60+30,hDepth*20+10,display.getWidth()-vDepth*60-30,display.getHeight()-hDepth*20-10);
m_vis.removeGroup(group);
m_vis.removeGroup(labelGroup);
VisualGraph vg = m_vis.addGraph(group, dataProvider.getGranularityAggregationTree());
Schema labelNodeSchema = PrefuseLib.getVisualItemSchema();
labelNodeSchema.addColumn(VisualItem.LABEL, String.class);
Integer defColor = new Integer(ColorLib.gray(150));
labelNodeSchema.setInterpolatedDefault(VisualItem.TEXTCOLOR, defColor);
VisualTree vgl = m_vis.addTree(labelGroup, labelNodeSchema);
Node root = vgl.addRoot();
vgl.addChild(root);
vgl.addChild(root);
try {
ArrayList<Float> relativeSize = new ArrayList<Float>();
ArrayList<Long> minIdentifiers = new ArrayList<Long>();
ArrayList<Long> maxIdentifiers = new ArrayList<Long>();
buildSizeChart(dataProvider.getGranularityAggregationTree().roots().iterator().next(),
relativeSize,minIdentifiers,maxIdentifiers,0);
layoutGranularity(vg,vgl,vgl.getRoot().getChild(0),vgl.getRoot().getChild(1),
(NodeItem)m_vis.getVisualItem(group, dataProvider.getGranularityAggregationTree().roots().iterator().next()),
position,0,minIdentifiers,maxIdentifiers);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例10: run
import prefuse.visual.VisualGraph; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes" })
@Override
public void run(double frac) {
if (timeScale == null) {
// setMinMax(); TODO get layout bounds
// get Inf / Sup of TemporalDataset (only temporal objects)
log.debug("cannot layout without timescale");
return;
}
TupleSet items = m_vis.getGroup(m_group);
if (items == null) {
log.debug("nothing to layout");
return;
}
// consider only nodes = temporal objects
if (items instanceof VisualGraph) {
items = ((VisualGraph) items).getNodes();
}
// TODO consider only: anchored (visible) objects --> index
Iterator tuples = items.tuples(m_filter);
while (tuples.hasNext()) {
VisualItem item = (VisualItem) tuples.next();
layoutItem(item);
}
}
示例11: useWith
import prefuse.visual.VisualGraph; //导入依赖的package包/类
/**
* Warning: Invalidates existing tuples.
* @param vg
*/
public static void useWith(VisualGraph vg) {
TupleManager ntm = new TupleManager(vg.getNodeTable(), vg, VisualParentChildNode.class);
TupleManager etm = new TupleManager(vg.getEdgeTable(), vg, TableEdgeItem.class);
vg.setTupleManagers(ntm, etm);
vg.getNodeTable().setTupleManager(ntm);
vg.getEdgeTable().setTupleManager(etm);
}
示例12: getVisaulGraph
import prefuse.visual.VisualGraph; //导入依赖的package包/类
public VisualGraph getVisaulGraph() {
return(vg);
}
示例13: addGraph
import prefuse.visual.VisualGraph; //导入依赖的package包/类
/**
* Adds a Graph, refreshes search items and removes aggregates.
*
* @param graph
*/
protected void addGraph(Graph graph){
if(graph == null) return;
// stop visualization
m_vis.cancel(Actions.DRAW.name()).setEnabled(false);
m_vis.cancel(Actions.AGGR.name()).setEnabled(false);
// wait till layout calculations finished.
while(m_aggregateLayout.runs);
// remove all rows
m_aTable.clear();
// remove old groups
m_vis.removeGroup(AGGR_DECORATORS);
m_vis.removeGroup(Visualization.SEARCH_ITEMS);
m_vis.removeGroup(GRAPH);
// add new graph
VisualGraph vg = m_vis.addGraph(GRAPH, graph);
// set focus group
VisualItem f = (VisualItem)vg.getNode(0);
m_vis.getGroup(Visualization.FOCUS_ITEMS).setTuple(f);
//f.setFixed(true);
m_vis.setValue(EDGES, null, VisualItem.INTERACTIVE, Boolean.FALSE);
// refresh search group
SearchTupleSet searchTup = new KeywordSearchTupleSet();
m_vis.addFocusGroup(Visualization.SEARCH_ITEMS, searchTup);
searchTup.addTupleSetListener(new TupleSetListener() {
@Override
public void tupleSetChanged(TupleSet t, Tuple[] add, Tuple[] rem) {
m_vis.run(Actions.DRAW.name() );
}
});
//
SearchQueryBinding sq = new SearchQueryBinding( vg.getNodeTable(), NODE_NAME,
(SearchTupleSet)m_vis.getGroup(Visualization.SEARCH_ITEMS));
// refresh search gui
search = sq.createSearchPanel();
search.setShowResultCount(true);
search.setBorder(BorderFactory.createEmptyBorder(5,5,4,0));
search.setFont(FontLib.getFont("Tahoma", Font.PLAIN, 11));
// refresh box
m_searchBox.removeAll();
m_searchBox.add(Box.createHorizontalStrut(10));
m_searchBox.add(m_searchLabel);
m_searchBox.add(Box.createHorizontalGlue());
m_searchBox.add(search);
m_searchBox.add(Box.createHorizontalStrut(3));
// run
m_vis.run(Actions.DRAW.name()).setEnabled(true);
m_vis.run(Actions.DRAW.name());
//
revalidate();
repaint();
}
示例14: setGraph
import prefuse.visual.VisualGraph; //导入依赖的package包/类
public void setGraph(Graph g) {
VisualGraph vg = m_vis.addGraph(graph, g);
m_vis.setValue(edges, null, VisualItem.INTERACTIVE, Boolean.TRUE);
VisualItem f = (VisualItem) vg.getNode(0);
m_vis.getGroup(Visualization.FOCUS_ITEMS).setTuple(f);
}
示例15: run
import prefuse.visual.VisualGraph; //导入依赖的package包/类
@Override
public void run(double frac) {
TupleSet items = m_vis.getGroup(m_group);
if (items instanceof VisualGraph) {
items = ((VisualGraph) items).getNodes();
}
double ybase = m_vis.getDisplay(0).getBounds().getCenterY()-m_vis.getDisplay(0).getBounds().getY();
double minx = m_vis.getDisplay(0).getBounds().getMinX();
double maxx = m_vis.getDisplay(0).getBounds().getMaxX();
ArrayList<Double> lastOnLane = new ArrayList<Double>();
Iterator tuples = items.tuples();
while (tuples.hasNext()) {
VisualItem item = (VisualItem) tuples.next();
if (item.getX() >= minx && item.getDouble(VisualItem.X2) <= maxx) {
int takeLane = -1;
for(int i=0; i<lastOnLane.size(); i++) {
if(lastOnLane.get(i) < item.getX()) {
takeLane = i;
lastOnLane.set(i, item.getDouble(VisualItem.X2));
break;
}
}
if (takeLane == -1) {
if (lastOnLane.size() >= maxLanes) {
switchToReplacementGroup();
break;
}
lastOnLane.add(item.getDouble(VisualItem.X2));
takeLane = lastOnLane.size()-1;
}
if (takeLane % 2 == 0) {
item.setY(ybase + (takeLane+1) * 8);
} else {
item.setY(ybase - takeLane * 8);
}
item.setSize(1.2);
}
}
if (lastOnLane.size() < maxLanes)
switchToMainGroup();
}