01: /*
02: * $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/StripifyWorker.java,v 1.1 2005/04/20 21:04:22 paulby Exp $
03: *
04: * Sun Public License Notice
05: *
06: * The contents of this file are subject to the Sun Public License Version
07: * 1.0 (the "License"). You may not use this file except in compliance with
08: * the License. A copy of the License is available at http://www.sun.com/
09: *
10: * The Original Code is Java 3D(tm) Fly Through.
11: * The Initial Developer of the Original Code is Paul Byrne.
12: * Portions created by Paul Byrne are Copyright (C) 2002.
13: * All Rights Reserved.
14: *
15: * Contributor(s): Paul Byrne.
16: *
17: **/
18: package org.jdesktop.j3dfly;
19:
20: import java.awt.Frame;
21: import javax.swing.SwingUtilities;
22: import javax.media.j3d.BranchGroup;
23: import org.jdesktop.j3dfly.utils.developmenttools.DevelopmentLocale;
24: import org.jdesktop.j3dfly.utils.gui.StatsDialog;
25: import org.jdesktop.j3d.utils.scenegraph.traverser.GeometryArrayStripifier;
26:
27: /**
28: * Thread which manages stripification of TriangleArrays in scene
29: *
30: * @author Paul Byrne
31: * @version $Revision: 1.1 $
32: */
33:
34: class StripifyWorker extends Thread {
35:
36: private DevelopmentLocale locale;
37: private BranchGroup[] roots;
38: private StatsDialog statsDialog;
39: private StripifyWaitDialog waitDialog;
40: private Runnable showWaitDialog;
41: private Runnable hideWaitDialog;
42:
43: public StripifyWorker(Frame parent, DevelopmentLocale locale,
44: BranchGroup[] roots, StatsDialog statsDialog) {
45: this .locale = locale;
46: this .roots = roots;
47: this .statsDialog = statsDialog;
48:
49: waitDialog = new StripifyWaitDialog(parent, true);
50:
51: showWaitDialog = new Runnable() {
52: public void run() {
53: waitDialog.show();
54: }
55: };
56:
57: hideWaitDialog = new Runnable() {
58: public void run() {
59: waitDialog.hide();
60: }
61: };
62: }
63:
64: public void run() {
65: SwingUtilities.invokeLater(showWaitDialog);
66: locale.setLive(false);
67:
68: GeometryArrayStripifier.stripify(roots);
69:
70: if (statsDialog != null)
71: statsDialog.calcGeometryStats(roots);
72:
73: locale.setLive(true);
74: SwingUtilities.invokeLater(hideWaitDialog);
75: }
76: }
|