2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2012 - Marcos CARDINOT
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
12 package org.scilab.modules.gui.plotbrowser;
14 import javax.swing.SwingUtilities;
15 import org.scilab.modules.gui.bridge.tab.SwingScilabTab;
16 import org.scilab.modules.gui.bridge.window.SwingScilabWindow;
17 import org.scilab.modules.gui.textbox.ScilabTextBox;
18 import org.scilab.modules.gui.textbox.TextBox;
19 import org.scilab.modules.gui.utils.ClosingOperationsManager;
20 import org.scilab.modules.gui.utils.WindowsConfigurationManager;
21 import org.scilab.modules.gui.window.ScilabWindow;
25 * shows all objects plotted.
27 * @author Marcos CARDINOT <mcardinot@gmail.com>
29 public class PlotBrowser {
30 private static PlotBrowser instance;
31 public static SwingPlotBrowser plotBrowserTab;
32 public static Integer currentObjectID;
37 * @param objectID Enters the identification of object.
39 public PlotBrowser(Integer objectID) {
40 TextBox infobar = ScilabTextBox.createTextBox();
41 plotBrowserTab = new SwingPlotBrowser(objectID);
42 plotBrowserTab.addInfoBar(infobar);
46 * Create the plot browser (as tab) instance.
48 * @param objectID Enters the identification of object.
49 * @return the instance.
51 public static SwingPlotBrowser createPlotBrowserTab(Integer objectID) {
52 if (instance == null) {
53 instance = new PlotBrowser(objectID);
56 return plotBrowserTab;
60 * Checks if the plot browser is open.
62 * @return true if an instance of PlotBrowser already exists.
64 public static boolean isPlotBrowserOpened() {
65 return instance != null;
69 * Get the plot browser singleton
70 * @return the plot browser
72 public static PlotBrowser getPlotBrowser() {
77 * Initializes the PlotBrowser with the docking system.
79 * @param objectID Enters the identification of object.
80 * @return Shows the PlotBrowser was generated.
82 public static PlotBrowser getPlotBrowser(Integer objectID) {
83 currentObjectID = objectID;
84 if (instance == null) {
85 boolean success = WindowsConfigurationManager.restoreUUID(SwingPlotBrowser.PLOTBROWSERUUID);
87 PlotBrowserTab.getPlotBrowserInstance(objectID);
88 SwingScilabWindow window = (SwingScilabWindow) ScilabWindow.createWindow().getAsSimpleWindow();
89 window.addTab(plotBrowserTab);
90 window.setLocation(0, 0);
91 window.setSize(300, 700);
92 window.setVisible(true);
95 SwingScilabWindow window = (SwingScilabWindow) SwingUtilities.getAncestorOfClass
96 (SwingScilabWindow.class, plotBrowserTab);
97 window.setVisible(true);
99 new SwapFigure(objectID);
107 public static void closePlotBrowser() {
108 if (instance != null) {
116 public void close() {
117 ClosingOperationsManager.startClosingOperationWithoutSave((SwingScilabTab) plotBrowserTab);
123 public void setVisible(boolean status) {
124 plotBrowserTab.setVisible(status);