/examples/advanced/mtShell/MTShellScene.java

http://mt4j.googlecode.com/ · Java · 583 lines · 341 code · 75 blank · 167 comment · 14 complexity · 04a5e63925bfb6abc8cf97e4c9b90476 MD5 · raw file

  1. /***********************************************************************
  2. * mt4j Copyright (c) 2008 - 2010 Christopher Ruff, Fraunhofer-Gesellschaft All rights reserved.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. ***********************************************************************/
  18. package advanced.mtShell;
  19. import java.awt.event.KeyEvent;
  20. import org.mt4j.MTApplication;
  21. import org.mt4j.components.TransformSpace;
  22. import org.mt4j.components.visibleComponents.font.FontManager;
  23. import org.mt4j.components.visibleComponents.font.IFont;
  24. import org.mt4j.components.visibleComponents.shapes.MTPolygon;
  25. import org.mt4j.components.visibleComponents.widgets.MTList;
  26. import org.mt4j.components.visibleComponents.widgets.MTListCell;
  27. import org.mt4j.components.visibleComponents.widgets.MTSceneMenu;
  28. import org.mt4j.components.visibleComponents.widgets.MTSceneWindow;
  29. import org.mt4j.components.visibleComponents.widgets.MTTextArea;
  30. import org.mt4j.input.gestureAction.InertiaDragAction;
  31. import org.mt4j.input.inputProcessors.IGestureEventListener;
  32. import org.mt4j.input.inputProcessors.MTGestureEvent;
  33. import org.mt4j.input.inputProcessors.componentProcessors.dragProcessor.DragProcessor;
  34. import org.mt4j.input.inputProcessors.componentProcessors.tapProcessor.TapEvent;
  35. import org.mt4j.input.inputProcessors.componentProcessors.tapProcessor.TapProcessor;
  36. import org.mt4j.input.inputProcessors.globalProcessors.CursorTracer;
  37. import org.mt4j.sceneManagement.AbstractScene;
  38. import org.mt4j.sceneManagement.Iscene;
  39. import org.mt4j.sceneManagement.transition.BlendTransition;
  40. import org.mt4j.sceneManagement.transition.FadeTransition;
  41. import org.mt4j.util.MTColor;
  42. import org.mt4j.util.logging.ILogger;
  43. import org.mt4j.util.logging.MTLoggerFactory;
  44. import org.mt4j.util.math.Vector3D;
  45. import org.mt4j.util.math.Vertex;
  46. import org.mt4j.util.opengl.GLFBO;
  47. import processing.core.PApplet;
  48. import processing.core.PImage;
  49. import scenes.WaterSceneExportObf;
  50. import sun.misc.GC;
  51. import advanced.drawing.MainDrawingScene;
  52. import advanced.flickrMT.FlickrScene;
  53. import advanced.fluidSimulator.FluidSimulationScene;
  54. import advanced.models3D.Models3DScene;
  55. import advanced.modestMapsMT.MapsScene;
  56. import advanced.physics.scenes.AirHockeyScene;
  57. import advanced.physics.scenes.PhysicsScene;
  58. import advanced.puzzle.PuzzleScene;
  59. import advanced.space3D.Space3DScene;
  60. import advanced.touchTail.TouchTailScene;
  61. /**
  62. * The Class MTShellScene. A scene which displays other scenes icons and loads them.
  63. *
  64. * @author Christopher Ruff
  65. */
  66. public class MTShellScene extends AbstractScene {
  67. /** The Constant logger. */
  68. private static final ILogger logger = MTLoggerFactory.getLogger(MTShellScene.class.getName());
  69. static{
  70. // logger.setLevel(ILogger.WARN);
  71. // logger.setLevel(ILogger.DEBUG);
  72. logger.setLevel(ILogger.INFO);
  73. }
  74. /** The app. */
  75. private MTApplication app;
  76. /** The has fbo. */
  77. private boolean hasFBO;
  78. /** The list. */
  79. private MTList list;
  80. /** The font. */
  81. private IFont font;
  82. /** The preferred icon height. */
  83. private int preferredIconHeight;
  84. /** The gap between icon and reflection. */
  85. private int gapBetweenIconAndReflection;
  86. /** The display height of reflection. */
  87. private float displayHeightOfReflection;
  88. /** The list width. */
  89. private float listWidth;
  90. /** The list height. */
  91. private int listHeight;
  92. /** The preferred icon width. */
  93. private int preferredIconWidth;
  94. /** The switch directly to scene. */
  95. private boolean switchDirectlyToScene = false;
  96. private boolean useBackgroundGradient = true;
  97. //TODO (dont allow throwing stuff out of the screen) or destroy it then
  98. //TODO loading screen
  99. /**
  100. * Instantiates a new mT shell scene.
  101. *
  102. * @param mtApplication the mt application
  103. * @param name the name
  104. */
  105. public MTShellScene(MTApplication mtApplication, String name) {
  106. super(mtApplication, name);
  107. this.app = mtApplication;
  108. this.hasFBO = GLFBO.isSupported(app);
  109. // this.hasFBO = false; // TEST
  110. //IF we have no FBO directly switch to scene and ignore setting
  111. this.switchDirectlyToScene = !this.hasFBO || switchDirectlyToScene;
  112. this.registerGlobalInputProcessor(new CursorTracer(app, this));
  113. // this.setClearColor(new MTColor(230,230,230,255));
  114. // this.setClearColor(new MTColor(30,30,30,255));
  115. this.setClearColor(new MTColor(0,0,0,255));
  116. //BACKGROUND GRADIENT
  117. if (this.useBackgroundGradient){
  118. Vertex[] vertices = new Vertex[]{
  119. new Vertex(0, app.height/3f, 0, 0,0,0,255),
  120. new Vertex(app.width, app.height/3, 0, 0,0,0,255),
  121. new Vertex(app.width, app.height/1.7f,0, 170,170,140,255),
  122. new Vertex(0, app.height/1.7f,0, 170,170,140,255),
  123. new Vertex(0, app.height/3, 0, 0,0,0,255),
  124. };
  125. MTPolygon p = new MTPolygon(getMTApplication(), vertices);
  126. p.setName("upper gradient");
  127. p.setNoStroke(true);
  128. p.generateAndUseDisplayLists();
  129. p.setPickable(false);
  130. this.getCanvas().addChild(p);
  131. Vertex[] vertices2 = new Vertex[]{
  132. new Vertex(0, app.height/1.7f, 0, 170,170,140,255),
  133. new Vertex(app.width, app.height/1.7f, 0, 170,170,140,255),
  134. new Vertex(app.width, app.height, 0, 0,0,0,255),
  135. new Vertex(0, app.height, 0, 0,0,0,255),
  136. new Vertex(0, app.height/1.7f, 0, 170,170,140,255),
  137. };
  138. MTPolygon p2 = new MTPolygon(getMTApplication(), vertices2);
  139. p2.setNoStroke(true);
  140. p2.generateAndUseDisplayLists();
  141. p2.setPickable(false);
  142. this.getCanvas().addChild(p2);
  143. }
  144. //BACKGROUND
  145. preferredIconWidth = 256;
  146. preferredIconHeight = 192;
  147. gapBetweenIconAndReflection = 9;
  148. displayHeightOfReflection = preferredIconHeight * 0.6f;
  149. //CREATE LIST
  150. listWidth = preferredIconHeight + displayHeightOfReflection + gapBetweenIconAndReflection;
  151. // listHeight = app.width - 50;
  152. listHeight = app.width;
  153. list = new MTList(mtApplication,0, 0, listWidth, listHeight, 40);
  154. list.setFillColor(new MTColor(150,150,150,200));
  155. list.setNoFill(true);
  156. list.setNoStroke(true);
  157. /*
  158. //List ends fade images //Background gradient has to be set to false!
  159. PImage gradImage = app.loadImage(this.getPathToIcons() + "gradx3.png");
  160. MTRectangle grad1 = new MTRectangle(gradImage, app);
  161. grad1.setUseDirectGL(true);
  162. grad1.setNoStroke(true);
  163. grad1.setPickable(false);
  164. list.addChild(grad1);
  165. grad1.setFillColor(this.getClearColor());
  166. MTRectangle grad2 = new MTRectangle(0, listHeight-gradImage.height , gradImage.width, gradImage.height, app);
  167. grad2.rotateZ(grad2.getCenterPointLocal(), 180, TransformSpace.LOCAL);
  168. grad2.setTexture(gradImage);
  169. grad2.setNoStroke(true);
  170. grad2.setPickable(false);
  171. list.addChild(grad2);
  172. grad2.setFillColor(this.getClearColor());
  173. */
  174. font = FontManager.getInstance().createFont(app, "SansSerif", 18, MTColor.WHITE);
  175. this.addScene(new ICreateScene() {
  176. public Iscene getNewScene() {
  177. return new TouchTailScene(app, "Touch Tails");
  178. }
  179. public String getTitle() {
  180. return "Touch Tails";
  181. }
  182. }, app.loadImage(this.getPathToIcons() + "touchtails_s.png"));
  183. this.addScene(new ICreateScene() {
  184. public Iscene getNewScene() {
  185. return new MapsScene(app, "Maps");
  186. }
  187. public String getTitle() {
  188. return "Maps";
  189. }
  190. }, app.loadImage(this.getPathToIcons() + "maps_ss.png"));
  191. this.addScene(new ICreateScene() {
  192. public Iscene getNewScene() {
  193. return new AirHockeyScene(app, "Air Hockey");
  194. }
  195. public String getTitle() {
  196. return "Air Hockey";
  197. }
  198. }, app.loadImage(this.getPathToIcons() + "airhockey_s.png"));
  199. this.addScene(new ICreateScene() {
  200. public Iscene getNewScene() {
  201. return new PuzzleScene(app, "Puzzle");
  202. }
  203. public String getTitle() {
  204. return "Puzzle";
  205. }
  206. }, app.loadImage(this.getPathToIcons() + "puzz.png"));
  207. if (this.hasFBO){
  208. this.addScene(new ICreateScene() {
  209. public Iscene getNewScene() {
  210. return new MainDrawingScene(app, "MT Paint");
  211. }
  212. public String getTitle() {
  213. return "MT Paint";
  214. }
  215. }, app.loadImage(this.getPathToIcons() + "drawing_s.png"));
  216. }
  217. this.addScene(new ICreateScene() {
  218. public Iscene getNewScene() {
  219. return new FlickrScene(app, "Flickr");
  220. }
  221. public String getTitle() {
  222. return "Photo Search";
  223. }
  224. }, app.loadImage(this.getPathToIcons() + "flickr_s.png"));
  225. this.addScene(new ICreateScene() {
  226. public Iscene getNewScene() {
  227. return new WaterSceneExportObf(app, "Interactive Water");
  228. }
  229. public String getTitle() {
  230. return "Interactive Water";
  231. }
  232. }, app.loadImage(this.getPathToIcons() + "water_s.png"));
  233. this.addScene(new ICreateScene() {
  234. public Iscene getNewScene() {
  235. return new FluidSimulationScene(app, "Fluid Particles");
  236. }
  237. public String getTitle() {
  238. return "Fluid Particles";
  239. }
  240. }, app.loadImage(this.getPathToIcons() + "fluidparticles_s.png"));
  241. this.addScene(new ICreateScene() {
  242. public Iscene getNewScene() {
  243. return new Models3DScene(app, "3D Models");
  244. }
  245. public String getTitle() {
  246. return "3D Models";
  247. }
  248. }, app.loadImage(this.getPathToIcons() + "teapot.jpg"));
  249. this.addScene(new ICreateScene() {
  250. public Iscene getNewScene() {
  251. return new PhysicsScene(app, "Physics Playground");
  252. }
  253. public String getTitle() {
  254. return "Physics Playground";
  255. }
  256. }, app.loadImage(this.getPathToIcons() + "pyhsics_s.png"));
  257. this.addScene(new ICreateScene() {
  258. public Iscene getNewScene() {
  259. return new Space3DScene(app, "Earth 3D");
  260. }
  261. public String getTitle() {
  262. return "Earth 3D";
  263. }
  264. }, app.loadImage(this.getPathToIcons() + "earth_s.png"));
  265. getCanvas().addChild(list);
  266. list.rotateZ(list.getCenterPointLocal(), -90, TransformSpace.LOCAL);
  267. // list.setPositionGlobal(new Vector3D(app.width/2f, app.height - list.getHeightXY(TransformSpace.GLOBAL) - 1));
  268. list.setPositionGlobal(new Vector3D(app.width/2f, app.height/2f));
  269. // list.setAnchor(PositionAnchor.UPPER_LEFT);
  270. // list.setPositionGlobal(new Vector3D(app.width/2f - list.getWidthXY(TransformSpace.GLOBAL)/2f, app.height - 20));
  271. getCanvas().setFrustumCulling(true);
  272. //Scene transition effect
  273. if (this.hasFBO){
  274. this.setTransition(new BlendTransition(app, 730));
  275. }else{
  276. this.setTransition(new FadeTransition(app, 730));
  277. }
  278. }
  279. /**
  280. * Gets the path to icons.
  281. *
  282. * @return the path to icons
  283. */
  284. private String getPathToIcons(){
  285. // return System.getProperty("user.dir")+File.separator+"examples"+File.separator+"advanced"+File.separator+"mtShell"+ File.separator +"data"+ File.separator+"images"+File.separator;
  286. //Load from classpath
  287. return "advanced" + MTApplication.separator + "mtShell" + MTApplication.separator + "data"+ MTApplication.separator + "images" + MTApplication.separator;
  288. }
  289. /**
  290. * Adds the tap processor.
  291. *
  292. * @param cell the cell
  293. * @param createScene the create scene
  294. */
  295. private void addTapProcessor(MTListCell cell, final ICreateScene createScene){
  296. cell.registerInputProcessor(new TapProcessor(app, 15));
  297. cell.addGestureListener(TapProcessor.class, new IGestureEventListener() {
  298. public boolean processGestureEvent(MTGestureEvent ge) {
  299. TapEvent te = (TapEvent)ge;
  300. if (te.isTapped()){
  301. //System.out.println("Clicked cell: " + te.getTargetComponent());
  302. final Iscene scene = createScene.getNewScene();
  303. if (!switchDirectlyToScene){//We have FBO support -> show scene in a window first
  304. if (hasFBO && scene instanceof AbstractScene){
  305. ((AbstractScene) scene).setTransition(new BlendTransition(app, 300));
  306. }
  307. final MTSceneWindow sceneWindow = new MTSceneWindow(app, scene,100, 50);
  308. sceneWindow.setFillColor(new MTColor(50,50,50,200));
  309. sceneWindow.scaleGlobal(0.5f, 0.5f, 0.5f, sceneWindow.getCenterPointGlobal());
  310. sceneWindow.addGestureListener(DragProcessor.class, new InertiaDragAction());
  311. getCanvas().addChild(sceneWindow);
  312. }else{
  313. //No FBO available -> change to the new scene fullscreen directly
  314. float menuWidth = 64;
  315. float menuHeight = 64;
  316. MTSceneMenu sceneMenu =
  317. //new MTSceneMenu(this, app.width-menuWidth/2f, 0-menuHeight/2f, menuWidth, menuHeight, app);
  318. new MTSceneMenu(app, scene, app.width-menuWidth, app.height-menuHeight, menuWidth, menuHeight);
  319. sceneMenu.addToScene();
  320. app.addScene(scene);
  321. app.pushScene();
  322. app.changeScene(scene);
  323. }
  324. }
  325. return false;
  326. }
  327. });
  328. }
  329. /**
  330. * Adds the scene.
  331. *
  332. * @param sceneToCreate the scene to create
  333. * @param icon the icon
  334. */
  335. public void addScene(ICreateScene sceneToCreate, PImage icon){
  336. // System.out.println("Width: " + width + " Height:" + height);
  337. //Create reflection image
  338. PImage reflection = this.getReflection(getMTApplication(), icon);
  339. float border = 1;
  340. float bothBorders = 2*border;
  341. float topShift = 30;
  342. float reflectionDistanceFromImage = topShift + gapBetweenIconAndReflection; //Gap width between image and reflection
  343. float listCellWidth = listWidth;
  344. float realListCellWidth = listCellWidth - bothBorders;
  345. // float listCellHeight = preferredIconWidth - border;
  346. float listCellHeight = preferredIconWidth ;
  347. MTListCell cell = new MTListCell(app , realListCellWidth, listCellHeight);
  348. cell.setNoFill(true);
  349. cell.setNoStroke(true);
  350. // /*
  351. Vertex[] vertices = new Vertex[]{
  352. new Vertex(realListCellWidth-topShift, border, 0, 0,0),
  353. new Vertex(realListCellWidth-topShift, listCellHeight -border, 0, 1,0),
  354. new Vertex(realListCellWidth-topShift - icon.height, listCellHeight -border, 0, 1,1),
  355. new Vertex(realListCellWidth-topShift - icon.height, border, 0, 0,1),
  356. new Vertex(realListCellWidth-topShift, border, 0, 0,0),
  357. };
  358. MTPolygon p = new MTPolygon(getMTApplication(), vertices);
  359. p.setTexture(icon);
  360. // p.setNoStroke(true);
  361. // p.setStrokeColor(new MTColor(150,150,150, 255));
  362. p.setStrokeColor(new MTColor(80,80,80, 255));
  363. Vertex[] verticesRef = new Vertex[]{
  364. new Vertex(listCellWidth - icon.height - reflectionDistanceFromImage, border, 0, 0,0),
  365. new Vertex(listCellWidth - icon.height - reflectionDistanceFromImage, listCellHeight -border, 0, 1,0),
  366. new Vertex(listCellWidth - icon.height - reflection.height - reflectionDistanceFromImage, listCellHeight -border, 0, 1,1),
  367. new Vertex(listCellWidth - icon.height - reflection.height - reflectionDistanceFromImage, border, 0, 0,1),
  368. new Vertex(listCellWidth - icon.height - reflectionDistanceFromImage, border, 0, 0,0),
  369. };
  370. MTPolygon pRef = new MTPolygon(getMTApplication(), verticesRef);
  371. pRef.setTexture(reflection);
  372. pRef.setNoStroke(true);
  373. cell.addChild(p);
  374. cell.addChild(pRef);
  375. list.addListElement(cell);
  376. addTapProcessor(cell, sceneToCreate);
  377. // */
  378. /*
  379. MTRectangle rect = new MTRectangle(icon, getMTApplication());
  380. rect.setUseDirectGL(true);
  381. // rect.setNoStroke(true);
  382. rect.rotateZ(rect.getCenterPointLocal(), 90, TransformSpace.LOCAL);
  383. MTRectangle reflectionRect = new MTRectangle(0, height, width, height, getMTApplication());
  384. reflectionRect.setTexture(reflection);
  385. reflectionRect.setUseDirectGL(true);
  386. // reflectionRect.setNoStroke(true);
  387. reflectionRect.rotateZ(rect.getCenterPointLocal(), 90, TransformSpace.LOCAL);
  388. cell.addChild(rect);
  389. cell.addChild(reflectionRect);
  390. list.addListElement(cell);
  391. addTapProcessor(cell, sceneToCreate);
  392. rect.setAnchor(PositionAnchor.UPPER_LEFT);
  393. reflectionRect.setAnchor(PositionAnchor.UPPER_LEFT);
  394. PositionAnchor oldCellAnchor = cell.getAnchor();
  395. cell.setAnchor(PositionAnchor.UPPER_LEFT);
  396. rect.setPositionRelativeToParent(cell.getPosition(TransformSpace.LOCAL));
  397. rect.translate(new Vector3D(realListCellWidth - topShift, 0));
  398. reflectionRect.setPositionRelativeToParent(cell.getPosition(TransformSpace.LOCAL));
  399. reflectionRect.translate(new Vector3D(realListCellWidth - topShift - icon.height - gapBetweenIconAndReflection, 0));
  400. cell.setAnchor(oldCellAnchor);
  401. // rect.setPositionRelativeToParent(cell.getCenterPointLocal());
  402. // MTRoundRectangle r = new MTRoundRectangle(0, 0, 0, listCellWidth, listCellHeight, 30, 30, getMTApplication());
  403. // cell.addChild(r);
  404. // getCanvas().addChild(rect);
  405. */
  406. ///Add scene title
  407. MTTextArea text = new MTTextArea(app, font);
  408. text.setFillColor(new MTColor(150,150,250,200));
  409. text.setNoFill(true);
  410. text.setNoStroke(true);
  411. text.setText(sceneToCreate.getTitle());
  412. text.rotateZ(text.getCenterPointLocal(), 90, TransformSpace.LOCAL);
  413. cell.addChild(text);
  414. // text.setAnchor(PositionAnchor.CENTER);
  415. // PositionAnchor oldCellAnchor = cell.getAnchor();
  416. // cell.setAnchor(PositionAnchor.CENTER);
  417. // text.setPositionRelativeToParent(cell.getPosition(TransformSpace.LOCAL));
  418. // text.translate(new Vector3D(realListCellWidth - topShift, 0));
  419. // cell.setAnchor(oldCellAnchor);
  420. text.setPositionRelativeToParent(cell.getCenterPointLocal());
  421. text.translate(new Vector3D(realListCellWidth*0.5f - text.getHeightXY(TransformSpace.LOCAL)*0.5f, 0));
  422. ///
  423. }
  424. /**
  425. * Creates the reflection image.
  426. *
  427. * @param pa the pa
  428. * @param image the image
  429. * @return the reflection image
  430. */
  431. private PImage getReflection(PApplet pa, PImage image) {
  432. int width = image.width;
  433. int height = image.height;
  434. PImage copyOfImage = pa.createImage(image.width, image.height, PApplet.ARGB);
  435. image.loadPixels();
  436. copyOfImage.loadPixels();
  437. for (int y = 0; y < height; y++) {
  438. for (int x = 0; x < width; x++) {
  439. int imageIndex = y*image.width+x;
  440. // int currA = (image.pixels[imageIndex] >> 32) & 0xFF;
  441. int currR = (image.pixels[imageIndex] >> 16) & 0xFF;
  442. int currG = (image.pixels[imageIndex] >> 8) & 0xFF;
  443. int currB = image.pixels[imageIndex] & 0xFF;
  444. int col = image.pixels[imageIndex];
  445. float alpha = pa.alpha(col);
  446. int reflectImageIndex = (image.height-y-1) * image.width+x;
  447. //TOD clamp 0-255, map 0-255, 255- y*y * x
  448. // copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , Math.round(y*0.8));
  449. // copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , Math.round(y * (0.005f*y) * 0.5));
  450. // copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , Math.round(Tools3D.clamp(255 - y*y , 0, 255)));
  451. // copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , Math.round(y*y*y * (0.00003f) - 20)); //WORKS
  452. if (alpha <= 0.0f){
  453. copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , 0.0f);
  454. }else{
  455. copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , Math.round(y*y*y * (0.00003f) - 60)); //WORKS
  456. }
  457. }
  458. }
  459. copyOfImage.updatePixels();
  460. return copyOfImage;
  461. }
  462. public void onEnter() {
  463. getMTApplication().registerKeyEvent(this);
  464. }
  465. public void onLeave() {
  466. getMTApplication().unregisterKeyEvent(this);
  467. }
  468. /**
  469. * Key event.
  470. *
  471. * @param e the e
  472. */
  473. public void keyEvent(KeyEvent e){
  474. int evtID = e.getID();
  475. if (evtID != KeyEvent.KEY_PRESSED)
  476. return;
  477. switch (e.getKeyCode()){
  478. case KeyEvent.VK_F:
  479. System.out.println("FPS: " + getMTApplication().frameRate);
  480. break;
  481. case KeyEvent.VK_M:
  482. System.out.println("Max memory: " + Runtime.getRuntime().maxMemory() + " <-> Free memory: " + Runtime.getRuntime().freeMemory());
  483. break;
  484. case KeyEvent.VK_C:
  485. getMTApplication().invokeLater(new Runnable() {
  486. public void run() {
  487. System.gc();
  488. GC.maxObjectInspectionAge();
  489. System.runFinalization();
  490. }
  491. });
  492. break;
  493. default:
  494. break;
  495. }
  496. }
  497. }