001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.plugins.streetside.gui; 003 004import java.awt.BorderLayout; 005import java.awt.Component; 006import java.util.List; 007 008import org.openstreetmap.josm.gui.SideButton; 009import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 010import org.openstreetmap.josm.plugins.streetside.gui.imageinfo.StreetsideViewerPanel; 011 012/** 013 * Toggle dialog that shows an image and some buttons. 014 * 015 * @author nokutu 016 */ 017 018public final class StreetsideViewerDialog extends ToggleDialog 019 { 020 021 private static final long serialVersionUID = -8983900297628236197L; 022 023 private static final String BASE_TITLE = "360° Streetside Viewer"; 024 025 private static StreetsideViewerDialog instance; 026 027 /** 028 * Object containing the shown image and that handles zoom and drag 029 */ 030 private StreetsideViewerPanel streetsideViewerPanel; 031 032 private StreetsideViewerDialog() { 033 // TODO: I18n support in all languages? 034 super(StreetsideViewerDialog.BASE_TITLE, "streetside-viewer", "Open Streetside Viewer window", 035 null, 200, true, StreetsidePreferenceSetting.class); 036 streetsideViewerPanel = new StreetsideViewerPanel(); 037 createLayout(streetsideViewerPanel, true, null); 038 } 039 040 /** 041 * Returns the unique instance of the class. 042 * 043 * @return The unique instance of the class. 044 */ 045 public static synchronized StreetsideViewerDialog getInstance() { 046 if (StreetsideViewerDialog.instance == null) { 047 StreetsideViewerDialog.instance = new StreetsideViewerDialog(); 048 } 049 return StreetsideViewerDialog.instance; 050 } 051 052 /** 053 * @return true, iff the singleton instance is present 054 */ 055 public static boolean hasInstance() { 056 return StreetsideViewerDialog.instance != null; 057 } 058 059 /** 060 * Destroys the unique instance of the class. 061 */ 062 public static synchronized void destroyInstance() { 063 StreetsideViewerDialog.instance = null; 064 } 065 066 /** 067 * Creates the layout of the dialog. 068 * 069 * @param data 070 * The content of the dialog 071 * @param buttons 072 * The buttons where you can click 073 */ 074 public void createLayout(Component data, List<SideButton> buttons) { 075 removeAll(); 076 createLayout(data, true, buttons); 077 add(titleBar, BorderLayout.NORTH); 078 } 079 080 public StreetsideViewerPanel getStreetsideViewerPanel() { 081 return streetsideViewerPanel; 082 } 083 084}