MCPcopy Create free account
hub / github.com/Kitware/VTK / Demo

Method Demo

Wrapping/Java/vtk/sample/Demo.java:130–182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

128 // -----------------------------------------------------------------
129
130 public Demo() {
131 super(new BorderLayout());
132 panel3d = new vtkPanel();
133 gcStatus = new JLabel("");
134 runGC = new JCheckBox("Enable GC", false);
135 debugMode = new JCheckBox("Debug mode", false);
136 exec = new ExecutorCompletionService<vtkActor>(Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()));
137
138 // Setup UI
139 JPanel statusBar = new JPanel();
140 statusBar.setLayout(new BoxLayout(statusBar, BoxLayout.X_AXIS));
141 statusBar.add(runGC);
142 statusBar.add(debugMode);
143 statusBar.add(Box.createHorizontalGlue());
144 statusBar.add(gcStatus);
145 add(panel3d, BorderLayout.CENTER);
146 add(statusBar, BorderLayout.SOUTH);
147
148 // Init app
149 // this.setupGC(); // We use a Swing timer that show the result in UI
150 // instead..
151 this.setupWorkers();
152
153 // Update GC info into the UI every seconds
154 // Reset camera each seconds the first 10 ones
155 this.nbSeconds = 0;
156 new Timer(1000, new ActionListener() {
157
158 public void actionPerformed(ActionEvent e) {
159 if (nbSeconds++ < 10) {
160 panel3d.resetCamera();
161 }
162 vtkRenderer renderer = panel3d.GetRenderer();
163 if (renderer.GetNumberOfPropsRendered() > 1) {
164 renderer.RemoveActor(renderer.GetActors().GetLastProp());
165 }
166
167 // Run GC in local thread (EDT)
168 if (runGC.isSelected()) {
169 vtkReferenceInformation info = vtkObject.JAVA_OBJECT_MANAGER.gc(debugMode.isSelected());
170 if (debugMode.isSelected()) {
171 System.out.println(info.listKeptReferenceToString());
172 System.out.println(info.listRemovedReferenceToString());
173 }
174 gcStatus.setText(info.toString());
175 } else {
176 gcStatus.setText("");
177 }
178
179 panel3d.Render();
180 }
181 }).start();
182 }
183
184 private void setupGC() {
185 // Setup GC to run every 1 second in EDT

Callers

nothing calls this directly

Calls 3

setupWorkersMethod · 0.95
addMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected