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; 011import org.openstreetmap.josm.tools.I18n; 012 013/** 014 * Toggle dialog that shows an image and some buttons. 015 * 016 * @author nokutu 017 */ 018 019public final class StreetsideViewerDialog extends ToggleDialog 020 { 021 022 private static final long serialVersionUID = -8983900297628236197L; 023 024 private static final String BASE_TITLE = I18n.marktr("360° Streetside Viewer"); 025 026 private static StreetsideViewerDialog instance; 027 028 /** 029 * Object containing the shown image and that handles zoom and drag 030 */ 031 private StreetsideViewerPanel streetsideViewerPanel; 032 033 private StreetsideViewerDialog() { 034 super(I18n.tr(StreetsideViewerDialog.BASE_TITLE), "streetside-viewer", I18n.tr("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}