forked from jgraph/mxgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerformanceTest.java
More file actions
94 lines (76 loc) · 2.16 KB
/
PerformanceTest.java
File metadata and controls
94 lines (76 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package com.mxgraph.test;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.util.Random;
import javax.swing.JFrame;
import com.mxgraph.model.mxCell;
import com.mxgraph.model.mxGeometry;
import com.mxgraph.model.mxICell;
import com.mxgraph.swing.mxGraphComponent;
import com.mxgraph.util.mxPoint;
import com.mxgraph.util.mxRectangle;
import com.mxgraph.view.mxGraph;
public class PerformanceTest extends JFrame
{
/**
*
*/
private static final long serialVersionUID = 6383140264262860886L;
final mxGraph graph;
public PerformanceTest()
{
super("JGraphX");
setSize(640, 480);
setDefaultCloseOperation(EXIT_ON_CLOSE);
graph = new mxGraph();
graph.setMinimumGraphSize(new mxRectangle(0, 0, 20000, 10000));
final mxGraphComponent graphComponent = new mxGraphComponent(graph);
// Use if no folding icons are needed
graphComponent.setFoldingEnabled(false);
// Use if no drop into cells or edge splitting are needed
graphComponent.getGraphHandler().setMarkerEnabled(false);
graphComponent.addMouseWheelListener(new MouseWheelListener()
{
public void mouseWheelMoved(MouseWheelEvent event)
{
if (event.getWheelRotation() < 0)
graphComponent.zoomIn();
else
graphComponent.zoomOut();
}
});
getContentPane().add(graphComponent);
Random random = new Random();
graph.getModel().beginUpdate();
try
{
for (int i = 0; i < 5000; i++)
{
insertPart(random.nextInt(20000), random.nextInt(10000));
}
}
finally
{
graph.getModel().endUpdate();
}
}
void insertPart(float x, float y)
{
mxICell part = (mxICell) graph.insertVertex(graph.getDefaultParent(),
null, "NAME", x, y, 50, 30);
mxPoint offset = new mxPoint(-2.5, -2.5);
mxICell port = (mxICell) graph.insertVertex(part, null, null, 0.0, 0.5,
5, 5);
mxGeometry geometry = port.getGeometry();
geometry.setRelative(true);
geometry.setOffset(offset);
port = (mxCell) graph.insertVertex(part, null, null, 1.0, 0.5, 5, 5);
geometry = port.getGeometry();
geometry.setRelative(true);
geometry.setOffset(offset);
}
public static void main(String[] args)
{
(new PerformanceTest()).show();
}
}