本文整理汇总了Java中edu.uci.ics.jung.algorithms.util.IterativeContext类的典型用法代码示例。如果您正苦于以下问题:Java IterativeContext类的具体用法?Java IterativeContext怎么用?Java IterativeContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IterativeContext类属于edu.uci.ics.jung.algorithms.util包,在下文中一共展示了IterativeContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import edu.uci.ics.jung.algorithms.util.IterativeContext; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
if (!animate) {
return;
}
if (layout instanceof IterativeContext) {
IterativeContext c = (IterativeContext) layout;
try {
c.step();
} catch (Exception ex) {
// e.g. IllegalArgumentException: Unexpected mathematical result in FRLayout:calcPositions
// Some layouts are buggy.
// Logger.getLogger(JungScene.class.getName()).log(Level.INFO, null, ex);
ex.printStackTrace();
// timer.stop();
}
if (c.done()) {
timer.stop();
}
getSceneLayout().invokeLayout();
validate();
repaint();
}
}
示例2: doGraphLayout
import edu.uci.ics.jung.algorithms.util.IterativeContext; //导入依赖的package包/类
@Override
public void doGraphLayout() {
layout.setSize(vv.getSize());
layout.initialize();
Relaxer relaxer = new VisRunner((IterativeContext) layout);
relaxer.stop();
relaxer.prerelax();
StaticLayout<Node, Edge> staticLayout = new StaticLayout<Node,Edge>(graph, layout, vv.getSize());
LayoutTransition<Node,Edge> lt = new LayoutTransition<Node,Edge>(vv, vv.getGraphLayout(),
staticLayout);
Animator animator = new Animator(lt);
animator.start();
vv.repaint();
FeatureMask mask = new FeatureMask(FeatureMask.TRANSLATE_SUPPORT | FeatureMask.SCALING_SUPPORT);
GraphEditorEventHandler eventHandler = new GraphEditorEventHandler(vv.getRenderContext(),
null, null, mask);
vv.setGraphMouse(eventHandler);
}
示例3: animate
import edu.uci.ics.jung.algorithms.util.IterativeContext; //导入依赖的package包/类
private void animate()
{
// while we are animating, the task scheduler is not allowed to modify the graph
// otherwise we will have a ConcurrentModificationException, because this animation iterates
// over the vertices and edges, while the task scheduler thread modifies them.
layout.initialize();
if (GeneralMDPSettings.ANIMATE) {
Relaxer relaxer = new VisRunner((IterativeContext)layout);
relaxer.stop();
relaxer.prerelax();
StaticLayout<Vertex<?>,Edge<?,?>> staticLayout =
new StaticLayout<Vertex<?>,Edge<?,?>>(g, layout);
LayoutTransition<Vertex<?>,Edge<?,?>> lt =
new LayoutTransition<Vertex<?>,Edge<?,?>>(vv, vv.getGraphLayout(),
staticLayout);
Animator animator = new Animator(lt);
animator.start();
}
vv.repaint();
repaint();
// resume scheduling after 200ms, give the visualization some time to draw before editing the graph again
resumeTaskScheduler(GeneralMDPSettings.REPAINT_DELAY-100);
}
示例4: Iterative
import edu.uci.ics.jung.algorithms.util.IterativeContext; //导入依赖的package包/类
protected Iterative(
Rectangle2D region,
Layout<GraphNode, GraphEdge> jungLayout,
int layoutCost) {
super(region, jungLayout);
this.layoutCost = layoutCost;
this.runner = (IterativeContext) jungLayout;
}
示例5: done
import edu.uci.ics.jung.algorithms.util.IterativeContext; //导入依赖的package包/类
@Override
public boolean done() {
if (delegate instanceof IterativeContext) {
return ((IterativeContext) delegate).done();
}
return true;
}
示例6: LayoutTransition
import edu.uci.ics.jung.algorithms.util.IterativeContext; //导入依赖的package包/类
/**
* @param startLayout
* @param endLayout
*/
public LayoutTransition(VisualizationViewer<V,E> vv, Layout<V, E> startLayout, Layout<V, E> endLayout) {
this.vv = vv;
this.startLayout = startLayout;
this.endLayout = endLayout;
if(endLayout instanceof IterativeContext) {
Relaxer relaxer = new VisRunner((IterativeContext)endLayout);
relaxer.prerelax();
}
this.transitionLayout =
new StaticLayout<V,E>(startLayout.getGraph(), startLayout);
vv.setGraphLayout(transitionLayout);
}
示例7: done
import edu.uci.ics.jung.algorithms.util.IterativeContext; //导入依赖的package包/类
/**
* @see edu.uci.ics.jung.algorithms.util.IterativeContext#done()
*/
@Override
public boolean done() {
if(delegate instanceof IterativeContext) {
return ((IterativeContext)delegate).done();
}
return true;
}
示例8: done
import edu.uci.ics.jung.algorithms.util.IterativeContext; //导入依赖的package包/类
/**
* @see edu.uci.ics.jung.algorithms.util.IterativeContext#done()
*/
public boolean done() {
if(delegate instanceof IterativeContext) {
return ((IterativeContext)delegate).done();
}
return true;
}
示例9: createView
import edu.uci.ics.jung.algorithms.util.IterativeContext; //导入依赖的package包/类
/**
* Overridden to inform the layout of the view's size
*
* @return The view
*/
@Override
public JComponent createView() {
boolean was = initialized;
if (!initialized) {
initialized = true;
sync();
sceneLayout.performLayout();
}
JComponent view = super.createView();
if (!was && layout instanceof IterativeContext && animate) {
startAnimation();
}
return view;
}
示例10: setAnimateIterativeLayouts
import edu.uci.ics.jung.algorithms.util.IterativeContext; //导入依赖的package包/类
/**
* Some JUNG layouts support iteratively evolving toward an optimal layout
* (where precomputing this is too expensive). If true, setting one of these
* layouts will trigger a timer that re-layouts the scene until the layout
* says it has reached an optimal state or this property is set to false.
*
* @param val to animate or not
*/
public final void setAnimateIterativeLayouts(boolean val) {
boolean old = this.animate;
if (old != val) {
this.animate = val;
if (val && this.layout instanceof IterativeContext && getView() != null) {
startAnimation();
} else if (!val) {
timer.stop();
}
}
}
示例11: process
import edu.uci.ics.jung.algorithms.util.IterativeContext; //导入依赖的package包/类
public void process() {
vv.getRenderContext().getPickedVertexState().clear();
vv.getRenderContext().getPickedEdgeState().clear();
try {
if (g.getVertexCount() < 100) {
//add a vertex
Integer v1 = new Integer(g.getVertexCount());
g.addVertex(v1);
vv.getRenderContext().getPickedVertexState().pick(v1, true);
// wire it to some edges
if (v_prev != null) {
Integer edge = g.getEdgeCount();
vv.getRenderContext().getPickedEdgeState().pick(edge, true);
g.addEdge(edge, v_prev, v1);
// let's connect to a random vertex, too!
int rand = (int) (Math.random() * g.getVertexCount());
edge = g.getEdgeCount();
vv.getRenderContext().getPickedEdgeState().pick(edge, true);
g.addEdge(edge, v1, rand);
}
v_prev = v1;
layout.initialize();
Relaxer relaxer = new VisRunner((IterativeContext)layout);
relaxer.stop();
relaxer.prerelax();
StaticLayout<Number,Number> staticLayout =
new StaticLayout<Number,Number>(g, layout);
LayoutTransition<Number,Number> lt =
new LayoutTransition<Number,Number>(vv, vv.getGraphLayout(),
staticLayout);
Animator animator = new Animator(lt);
animator.start();
// vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
vv.repaint();
} else {
done = true;
}
} catch (Exception e) {
System.out.println(e);
}
}
示例12: Animator
import edu.uci.ics.jung.algorithms.util.IterativeContext; //导入依赖的package包/类
public Animator(IterativeContext process) {
this(process, 10L);
}
示例13: step
import edu.uci.ics.jung.algorithms.util.IterativeContext; //导入依赖的package包/类
/**
* @see edu.uci.ics.jung.algorithms.util.IterativeContext#done()
*/
public void step() {
if(delegate instanceof IterativeContext) {
((IterativeContext)delegate).step();
}
}
示例14: VisRunner
import edu.uci.ics.jung.algorithms.util.IterativeContext; //导入依赖的package包/类
/**
* Creates an instance for the specified process.
*/
public VisRunner(IterativeContext process) {
this.process = process;
}
示例15: refreshLayout
import edu.uci.ics.jung.algorithms.util.IterativeContext; //导入依赖的package包/类
private void refreshLayout() {
if (active) {
taskManager.cancelAllWaitingTasks();
taskManager.addTask(new ICTask() {
public void doTask() {
StaticLayout<V, E> toLayout;
Layout<V, E> currentLayout;
synchronized (getTreeLock()) {
currentLayout = viewer.getGraphLayout(); // StaticLayout
layout.setSize(viewer.getSize());
if (layout instanceof IterativeContext) { // 最後まで進める
// layout.setInitializer(currentLayout);
Relaxer relaxer = new VisRunner(
(IterativeContext) layout);
relaxer.prerelax();
} else {// CircleLayoutの場合
layout.initialize();
}
toLayout = new StaticLayout<V, E>(getGraph(), layout);
}
if (isAnimation()) {
LayoutTransition<V, E> layoutTransition = new LayoutTransition<V, E>(
viewer, currentLayout, toLayout);
Animator animator = new Animator(layoutTransition);
// animator.setSleepTime(100);
animator.run(); // animator.start();
// while (!layoutTransition.done()) {
// viewer.requestRefresh();
// layoutTransition.step();
// CThread.sleep(10L);
// }
} else {
viewer.setGraphLayout(toLayout);
// while (!layoutTransition.done()) {
// layoutTransition.step();
// }
}
// viewer.getRenderContext().getMultiLayerTransformer()
// .setToIdentity();
viewer.requestRefresh();
viewer.repaint();
}
});
}
}