本文整理汇总了Java中prefuse.activity.Activity类的典型用法代码示例。如果您正苦于以下问题:Java Activity类的具体用法?Java Activity怎么用?Java Activity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Activity类属于prefuse.activity包,在下文中一共展示了Activity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: basePan
import prefuse.activity.Activity; //导入依赖的package包/类
public synchronized void basePan(double dx, double dy,ArrayList<Integer> axes) {
ArrayList<ValuedRangeModel> rangeModels = new ArrayList<ValuedRangeModel>();
ArrayList<Integer> axisTypes = new ArrayList<Integer>();
ArrayList<Double> minPositions = new ArrayList<Double>();
ArrayList<Double> maxPositions = new ArrayList<Double>();
findRelevantParameters(axes,rangeModels,axisTypes,minPositions,maxPositions);
for(int i=0; i<rangeModels.size(); i++) {
ValuedRangeModel iModel = rangeModels.get(i);
double factor = axisTypes.get(i) == Constants.X_AXIS ? dx : dy;
factor /= (maxPositions.get(i) - minPositions.get(i));
int newValue = Math.max(0,Math.min(10000-iModel.getExtent(),(int)Math.round(iModel.getValue()-factor*10000.0)));
iModel.setValue(newValue);
}
m_clip.invalidate();
for(String iKey : relevantActionLists) {
Activity iAc = m_vis.getAction(iKey);
iAc.run();
}
}
示例2: findRelevantParameters
import prefuse.activity.Activity; //导入依赖的package包/类
public synchronized void findRelevantParameters(ArrayList<Integer> axes,ArrayList<ValuedRangeModel> rangeModels,
ArrayList<Integer> axisTypes,ArrayList<Double> minPositions,ArrayList<Double> maxPositions) {
for(String iKey : relevantActionLists) {
Activity iAc = m_vis.getAction(iKey);
if (iAc instanceof ActionList) {
for (int i=0; i<((ActionList)iAc).size(); i++) {
Action iAc2 = ((ActionList)iAc).get(i);
if(iAc2 instanceof AxisLayout && axes.contains(((AxisLayout)iAc2).getAxis())) {
if (!rangeModels.contains(((AxisLayout)iAc2).getRangeModel())) {
rangeModels.add(((AxisLayout)iAc2).getRangeModel());
axisTypes.add(((AxisLayout)iAc2).getAxis());
minPositions.add(((AxisLayout)iAc2).getAxis() == Constants.X_AXIS ? ((AxisLayout)iAc2).getLayoutBounds().getMinX() : ((AxisLayout)iAc2).getLayoutBounds().getMinY());
maxPositions.add(((AxisLayout)iAc2).getAxis() == Constants.X_AXIS ? ((AxisLayout)iAc2).getLayoutBounds().getMaxX() : ((AxisLayout)iAc2).getLayoutBounds().getMaxY());
}
} else if(iAc2 instanceof RangeModelTransformationProvider) {
for(int iAx : ((RangeModelTransformationProvider)iAc2).getAxes()) {
if (!rangeModels.contains(((RangeModelTransformationProvider)iAc2).getRangeModel(iAx))) {
rangeModels.add(((RangeModelTransformationProvider)iAc2).getRangeModel(iAx));
axisTypes.add(iAx);
minPositions.add(((RangeModelTransformationProvider)iAc2).getMinPosition(iAx));
maxPositions.add(((RangeModelTransformationProvider)iAc2).getMaxPosition(iAx));
}
}
}
}
}
}
}
示例3: baseZoom
import prefuse.activity.Activity; //导入依赖的package包/类
public synchronized void baseZoom(final Point2D p, double scale,ArrayList<Integer> axes,boolean absolute) {
ArrayList<ValuedRangeModel> rangeModels = new ArrayList<ValuedRangeModel>();
ArrayList<Integer> axisTypes = new ArrayList<Integer>();
ArrayList<Double> minPositions = new ArrayList<Double>();
ArrayList<Double> maxPositions = new ArrayList<Double>();
findRelevantParameters(axes,rangeModels,axisTypes,minPositions,maxPositions);
for(int i=0; i<rangeModels.size(); i++) {
ValuedRangeModel iModel = rangeModels.get(i);
double zoomFocus = axisTypes.get(i) == Constants.X_AXIS ? p.getX() : p.getY();
zoomFocus -= minPositions.get(i);
zoomFocus /= (maxPositions.get(i)-minPositions.get(i));
zoomFocus *= iModel.getExtent();
zoomFocus += iModel.getValue();
int newValue = (int)Math.round(zoomFocus - iModel.getExtent() * 0.5 / scale);
int newExtent = (int)Math.round(iModel.getExtent() / scale);
if(newValue + iModel.getExtent() < 10000 ) {
iModel.setValue(newValue);
iModel.setExtent(newExtent);
} else {
iModel.setExtent(newExtent);
iModel.setValue(newValue);
}
}
for(int i=0; i<axes.size(); i++) {
if (absolute)
this.scale[axes.get(i)] = scale;
else
this.scale[axes.get(i)] *= scale;
}
m_clip.invalidate();
for(String iKey : relevantActionLists) {
Activity iAc = m_vis.getAction(iKey);
iAc.run();
}
}
示例4: DLGVisualizer
import prefuse.activity.Activity; //导入依赖的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");
}
示例5: RenderPrefuseGraph
import prefuse.activity.Activity; //导入依赖的package包/类
/**
* @param prefuseDisplay
* @param graph
* @param id
*/
public RenderPrefuseGraph(Display prefuseDisplay, Graph graph, String id) {
/* default color for nodes and edges
* both is overwritten later (NodeRenderer and TextLayoutDecorator) */
ColorAction fill = new ColorAction("GraphDataModifier.nodes", VisualItem.FILLCOLOR, ColorLib.rgb(0, 200, 0));
ColorAction edges = new ColorAction("GraphDataModifier.edges", VisualItem.STROKECOLOR, ColorLib.rgb(0, 0, 0));
ColorAction arrow = new ColorAction("GraphDataModifier.edges", VisualItem.FILLCOLOR, ColorLib.rgb(0, 0, 0));
fill.add(VisualItem.FIXED, ColorLib.rgb(0, 250, 0));
fill.add(VisualItem.HIGHLIGHT, ColorLib.rgb(0, 250, 0));
ActionList layout = new ActionList(Activity.INFINITY);
layout.add(fill); // add default node color
layout.add(edges); // add default edge color
layout.add(arrow); // add default edge color
// set layout as force directed layout without (all objects must be displayed)
ForceDirectedLayoutExtended fdle = new ForceDirectedLayoutExtended("GraphDataModifier", false);
PrefuseForceAbstractLayoutStorage.addForceDirectedLayout(fdle, id);
layout.add(fdle);
layout.add(new TextLayoutDecorator("nodedec"));
layout.add(new TextLayoutDecorator("NodeExtraData"));
layout.add(new TextLayoutDecorator("EdgeExtraData"));
layout.add(new RepaintAction());
layout.add(new TextLayoutDecorator("edgeDeco"));
final Visualization vis = new Visualization();
vis.add("GraphDataModifier", graph);
vis.putAction("layout", layout);
NodeRenderer nodeRender = new NodeRenderer();
EdgeRender edgeRender = new EdgeRender(prefuse.Constants.EDGE_TYPE_LINE, prefuse.Constants.EDGE_ARROW_FORWARD);
edgeRender.setArrowHeadSize(10, 10);
DefaultRendererFactory drf = new DefaultRendererFactory();
drf.setDefaultRenderer(nodeRender);
drf.setDefaultEdgeRenderer(edgeRender);
drf.add(new InGroupPredicate("edgeDeco"), new LabelRenderer(ColumnNames.NAME));
drf.add(new InGroupPredicate("nodedec"), new LabelRenderer(ColumnNames.NAME));
final Schema DECATOR_SCHEMA = PrefuseLib.getVisualItemSchema();
DECATOR_SCHEMA.setDefault(VisualItem.INTERACTIVE, false);
DECATOR_SCHEMA.setDefault(VisualItem.TEXTCOLOR, ColorLib.rgb(255, 255, 255));
final Schema DECATOR_SCHEMA_EDGES = PrefuseLib.getVisualItemSchema();
DECATOR_SCHEMA_EDGES.setDefault(VisualItem.INTERACTIVE, true);
DECATOR_SCHEMA_EDGES.setDefault(VisualItem.TEXTCOLOR, ColorLib.rgb(255, 255, 255));
DECATOR_SCHEMA.setDefault(VisualItem.FONT, FontUsed.getFont());
DECATOR_SCHEMA.setDefault(VisualItem.TEXTCOLOR, ColorLib.gray(0));
// add extra name field (should be done before the normal name field [for edges], otherwise normal field is covered with extra name background)
final Schema DECATOR_SCHEMA_NAME_EXTRA = PrefuseLib.getVisualItemSchema();
DECATOR_SCHEMA_NAME_EXTRA.setDefault(VisualItem.SIZE, NameExtraDataSize);
DECATOR_SCHEMA_NAME_EXTRA.setDefault(VisualItem.INTERACTIVE, false);
drf.add(new InGroupPredicate("NodeExtraData"), new LabelRenderer(ColumnNames.NAME_DATA));
vis.addDecorators("NodeExtraData", "GraphDataModifier.nodes", DECATOR_SCHEMA_NAME_EXTRA);
drf.add(new InGroupPredicate("EdgeExtraData"), new LabelRenderer(ColumnNames.NAME_DATA));
// disabled because unhappy with the optical result
// vis.addDecorators("EdgeExtraData", "GraphDataModifier.edges", DECATOR_SCHEMA_NAME_EXTRA);
// add short name decorators
vis.addDecorators("edgeDeco", "GraphDataModifier.edges", DECATOR_SCHEMA_EDGES);
vis.addDecorators("nodedec", "GraphDataModifier.nodes", DECATOR_SCHEMA);
vis.setRendererFactory(drf);
prefuseDisplay.setVisualization(vis);
vis.run("layout");
}
示例6: AggregateDemo
import prefuse.activity.Activity; //导入依赖的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.activity.Activity; //导入依赖的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.activity.Activity; //导入依赖的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.activity.Activity; //导入依赖的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.activity.Activity; //导入依赖的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.activity.Activity; //导入依赖的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.activity.Activity; //导入依赖的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: setActions
import prefuse.activity.Activity; //导入依赖的package包/类
/**
* Initializes colors, force, ... Actions.
*/
protected void setActions(){
// DRAW_ACTIONS: node and edge color actions
ColorAction nodeStroke = new ColorAction(NODES, VisualItem.STROKECOLOR);
nodeStroke.setDefaultColor(ColorLib.gray(0));
nodeStroke.add(VisualItem.HOVER, ColorLib.gray(0));
ColorAction edgeStroke = new ColorAction(EDGES, VisualItem.STROKECOLOR);
edgeStroke.setDefaultColor(ColorLib.gray(0));
ColorAction edgeFill = new ColorAction(EDGES, VisualItem.FILLCOLOR);
edgeFill.setDefaultColor(ColorLib.gray(0));
// DataSizeAction edgeWidth = new DataSizeAction(EDGES, EDGE_WEIGHT);
// bundle the node and edge color actions
ActionList nodeEdgeList = new ActionList();
nodeEdgeList.add(new NodeColorAction(NODES));
nodeEdgeList.add(new ColorAction(NODES, VisualItem.TEXTCOLOR, ColorLib.gray(0)));
nodeEdgeList.add(nodeStroke);
nodeEdgeList.add(edgeStroke);
nodeEdgeList.add(edgeFill);
//nodeEdgeList.add(edgeWidth); //paint edges width depends on weight
nodeEdgeList.add(new RepaintAction());
// we register our actions
m_vis.putAction(Actions.DRAW.name(), nodeEdgeList);
// now create the main layout routine
ActionList layoutList = new ActionList(Activity.INFINITY);
// ActionList layoutList = new ActionList(Activity.DEFAULT_STEP_TIME);
distanceFilter = new GraphDistanceFilter(GRAPH, MAX_HOPS);
layoutList.add(distanceFilter);
m_forceLayout = new ForceDirectedLayout(GRAPH, false);
// m_forceLayout = new FruchtermanReingoldLayout(GRAPH);
layoutList.add(m_forceLayout);
layoutList.add(new RepaintAction());
// we register
m_vis.putAction(Actions.LAYOUT.name(), layoutList);
m_vis.runAfter(Actions.DRAW.name(), Actions.LAYOUT.name());
// Actions aggregate color and layout
ActionList aggrList = new ActionList(Activity.INFINITY);
aggrList.add(m_aggregateLayout);
aggrList.add(new LabelLayout(AGGR_DECORATORS));
ColorAction aggrStroke = new ColorAction(AGGRS, VisualItem.STROKECOLOR);
aggrStroke.setDefaultColor(ColorLib.gray(0));
aggrStroke.add(VisualItem.HOVER, ColorLib.rgb(255,100,100));
aggrList.add(aggrStroke);
m_aggrs_color = new DataColorAction(AGGRS, AGGRS_ID, Constants.ORDINAL, VisualItem.FILLCOLOR);
aggrList.add(m_aggrs_color);
aggrList.add(new RepaintAction());
// we register
m_vis.putAction(Actions.AGGR.name(), aggrList);
}
示例14: ActivityList
import prefuse.activity.Activity; //导入依赖的package包/类
/**
* Creates a new ActivityList of specified duration and default
* step time of 20 milliseconds.
* @param duration the duration of this Activity, in milliseconds
*/
public ActivityList(long duration) {
super(duration, Activity.DEFAULT_STEP_TIME);
}
示例15: add
import prefuse.activity.Activity; //导入依赖的package包/类
/**
* Adds an Activity to the end of the composite list.
* @param a the Action instance to add
*/
public void add(Activity a) {
m_activities.add(a);
}