1 /* 2 * This file is part of libbluray 3 * Copyright (C) 2010 William Hahne 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library. If not, see 17 * <http://www.gnu.org/licenses/>. 18 */ 19 20 package org.videolan; 21 22 import java.awt.BDRootWindow; 23 import java.awt.Component; 24 25 import org.havi.ui.HScene; 26 27 public class GUIManager extends BDRootWindow { GUIManager()28 private GUIManager() { 29 } 30 31 private static final Object instanceLock = new Object(); 32 createInstance()33 public static GUIManager createInstance() { 34 synchronized (instanceLock) { 35 if (instance == null) { 36 instance = new GUIManager(); 37 } else { 38 instance.clearOverlay(); 39 instance.setDefaultFont(null); 40 } 41 return instance; 42 } 43 } 44 getInstance()45 public static GUIManager getInstance() { 46 synchronized (instanceLock) { 47 if (instance == null) { 48 Logger.getLogger("GUIManager").error("getInstance(): no instance !"); 49 throw new Error("no GUIManager instance"); 50 } 51 return instance; 52 } 53 } 54 getFocusHSceneContext()55 BDJXletContext getFocusHSceneContext() { 56 Component component = getFocusOwner(); 57 while (component != null) { 58 if (component instanceof HScene) 59 return ((HScene)component).getXletContext(); 60 component = component.getParent(); 61 } 62 return null; 63 } 64 shutdown()65 protected static void shutdown() throws Throwable { 66 synchronized (instanceLock) { 67 if (instance != null) { 68 instance.setVisible(false); 69 instance.removeAll(); 70 instance.dispose(); 71 //instance.finalize(); 72 instance = null; 73 } 74 } 75 } 76 dispose()77 public void dispose() { 78 try { 79 super.dispose(); 80 } finally { 81 instance = null; 82 } 83 } 84 85 private static GUIManager instance = null; 86 private static final long serialVersionUID = 8670041014494973439L; 87 } 88