package views;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Rectangle;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
import javax.swing.Action;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JToggleButton;
import javax.swing.ScrollPaneConstants;
import javax.swing.SpinnerDateModel;
import javax.swing.SwingConstants;
/**
* @author francois
* @version 23 avr. 2013
*/
public class Ui extends javax.swing.JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private JSpinner spinnerDate;
private JButton btnUpdate;
private JPanel skyMap;
private JToggleButton tglbtnPlay;
private JSpinner spnRatio;
private JButton btnScreenshot;
private JMenu mnLocations;
private JMenu mnApplication;
private JSpinner spinnerLatitude;
private JSpinner spinnerLong;
private JLabel labLocation;
private JLabel lblBaseDeDonnes;
private JPanel pnlDatabases;
private JLabel lblLocalisation;
private JLabel lblClusters;
private JPanel pnlClusters;
private JCheckBox chckbxActivateClustering;
private JLabel lblMaximalMagnitude;
private JSpinner spnMagnitude;
/**
*
*/
public Ui() {
setSize(new Dimension(658, 458));
setMinimumSize(new Dimension(300, 200));
setBounds(new Rectangle(0, 0, 800, 600));
setTitle("StarCommand");
JMenuBar mainMenu = new JMenuBar();
getContentPane().add(mainMenu, BorderLayout.NORTH);
mnApplication = new JMenu("Application");
mainMenu.add(mnApplication);
mnLocations = ControlsFactory.createJMenuLocation();
mnLocations.setText("Locations");
mainMenu.add(mnLocations);
JPanel pnlSkyMap = new JPanel();
getContentPane().add(pnlSkyMap, BorderLayout.CENTER);
GridBagLayout gbl_pnlSkyMap = new GridBagLayout();
gbl_pnlSkyMap.columnWidths = new int[] { 282, 317 };
gbl_pnlSkyMap.rowHeights = new int[] { 387, 0 };
gbl_pnlSkyMap.columnWeights = new double[] { 0.0, 1.0 };
gbl_pnlSkyMap.rowWeights = new double[] { 1.0, Double.MIN_VALUE };
pnlSkyMap.setLayout(gbl_pnlSkyMap);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
gbc_scrollPane.fill = GridBagConstraints.BOTH;
gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
gbc_scrollPane.gridx = 0;
gbc_scrollPane.gridy = 0;
pnlSkyMap.add(scrollPane, gbc_scrollPane);
JPanel controlSkyMap = new JPanel();
scrollPane.setViewportView(controlSkyMap);
GridBagLayout gbl_controlSkyMap = new GridBagLayout();
gbl_controlSkyMap.columnWidths = new int[] { 61, 25 };
gbl_controlSkyMap.rowHeights = new int[] { 16, 29, 0, 0, 30, 30, 0, 0, 0, 0, 0, 0 };
gbl_controlSkyMap.columnWeights = new double[] { 0.0, 1.0 };
gbl_controlSkyMap.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0 };
controlSkyMap.setLayout(gbl_controlSkyMap);
JLabel lblDat = new JLabel("Date (UTC)");
lblDat.setHorizontalAlignment(SwingConstants.CENTER);
GridBagConstraints gbc_lblDat = new GridBagConstraints();
gbc_lblDat.insets = new Insets(0, 0, 5, 5);
gbc_lblDat.gridx = 0;
gbc_lblDat.gridy = 0;
controlSkyMap.add(lblDat, gbc_lblDat);
spinnerDate = new JSpinner();
spinnerDate.setToolTipText("Entrez la date désirée");
SpinnerDateModel spnDateModel = new SpinnerDateModel();
spinnerDate.setModel(spnDateModel);
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
spinnerDate.setEditor(new JSpinner.DateEditor(spinnerDate, dateFormat.toPattern()));
GridBagConstraints gbc_spinnerDate = new GridBagConstraints();
gbc_spinnerDate.insets = new Insets(0, 0, 5, 0);
gbc_spinnerDate.gridx = 1;
gbc_spinnerDate.gridy = 0;
controlSkyMap.add(spinnerDate, gbc_spinnerDate);
lblLocalisation = new JLabel("Location");
GridBagConstraints gbc_lblLocalisation = new GridBagConstraints();
gbc_lblLocalisation.insets = new Insets(0, 0, 5, 5);
gbc_lblLocalisation.gridx = 0;
gbc_lblLocalisation.gridy = 2;
controlSkyMap.add(lblLocalisation, gbc_lblLocalisation);
labLocation = new JLabel("");
labLocation.setFont(new Font("Lucida Grande", Font.BOLD, 13));
GridBagConstraints gbc_labLocation = new GridBagConstraints();
gbc_labLocation.insets = new Insets(0, 0, 5, 0);
gbc_labLocation.gridx = 1;
gbc_labLocation.gridy = 2;
controlSkyMap.add(labLocation, gbc_labLocation);
JLabel labelLat = new JLabel("Latitude");
labelLat.setHorizontalAlignment(SwingConstants.CENTER);
GridBagConstraints gbc_labelLat = new GridBagConstraints();
gbc_labelLat.insets = new Insets(0, 0, 5, 5);
gbc_labelLat.gridx = 0;
gbc_labelLat.gridy = 3;
controlSkyMap.add(labelLat, gbc_labelLat);
spinnerLatitude = ControlsFactory.createJSpinnerLatitude();
GridBagConstraints gbc_spinnerLatitude = new GridBagConstraints();
gbc_spinnerLatitude.insets = new Insets(0, 0, 5, 0);
gbc_spinnerLatitude.gridx = 1;
gbc_spinnerLatitude.gridy = 3;
controlSkyMap.add(spinnerLatitude, gbc_spinnerLatitude);
JLabel labelLong = new JLabel("Longitude");
labelLong.setHorizontalAlignment(SwingConstants.CENTER);
GridBagConstraints gbc_labelLong = new GridBagConstraints();
gbc_labelLong.insets = new Insets(0, 0, 5, 5);
gbc_labelLong.gridx = 0;
gbc_labelLong.gridy = 4;
controlSkyMap.add(labelLong, gbc_labelLong);
spinnerLong = ControlsFactory.createJSpinnerLongitude();
GridBagConstraints gbc_spinnerLong = new GridBagConstraints();
gbc_spinnerLong.insets = new Insets(0, 0, 5, 0);
gbc_spinnerLong.gridx = 1;
gbc_spinnerLong.gridy = 4;
controlSkyMap.add(spinnerLong, gbc_spinnerLong);
JLabel lblRatioDfilement = new JLabel("Spin Ratio");
lblRatioDfilement.setEnabled(false);
lblRatioDfilement.setFont(new Font("Lucida Grande", Font.PLAIN, 14));
GridBagConstraints gbc_lblRatioDfilement = new GridBagConstraints();
gbc_lblRatioDfilement.gridwidth = 2;
gbc_lblRatioDfilement.insets = new Insets(0, 0, 5, 0);
gbc_lblRatioDfilement.gridx = 0;
gbc_lblRatioDfilement.gridy = 5;
controlSkyMap.add(lblRatioDfilement, gbc_lblRatioDfilement);
spnRatio = ControlsFactory.createJSpinnerRatio();
spnRatio.setEnabled(false);
GridBagConstraints gbc_spnRatio = new GridBagConstraints();
gbc_spnRatio.fill = GridBagConstraints.HORIZONTAL;
gbc_spnRatio.insets = new Insets(0, 0, 5, 5);
gbc_spnRatio.gridx = 0;
gbc_spnRatio.gridy = 6;
controlSkyMap.add(spnRatio, gbc_spnRatio);
tglbtnPlay = ControlsFactory.createPlayButton();
tglbtnPlay.setEnabled(false);
GridBagConstraints gbc_tglbtnPlay = new GridBagConstraints();
gbc_tglbtnPlay.insets = new Insets(0, 0, 5, 0);
gbc_tglbtnPlay.gridx = 1;
gbc_tglbtnPlay.gridy = 6;
controlSkyMap.add(tglbtnPlay, gbc_tglbtnPlay);
lblMaximalMagnitude = new JLabel("Maximal magnitude");
GridBagConstraints gbc_lblMinimalMagnitude = new GridBagConstraints();
gbc_lblMinimalMagnitude.insets = new Insets(0, 0, 5, 5);
gbc_lblMinimalMagnitude.gridx = 0;
gbc_lblMinimalMagnitude.gridy = 8;
controlSkyMap.add(lblMaximalMagnitude, gbc_lblMinimalMagnitude);
spnMagnitude = ControlsFactory.createJSpinnerMagnitude();
GridBagConstraints gbc_spnMagnitude = new GridBagConstraints();
gbc_spnMagnitude.fill = GridBagConstraints.HORIZONTAL;
gbc_spnMagnitude.insets = new Insets(0, 0, 5, 0);
gbc_spnMagnitude.gridx = 1;
gbc_spnMagnitude.gridy = 8;
controlSkyMap.add(spnMagnitude, gbc_spnMagnitude);
lblBaseDeDonnes = new JLabel("Database selection");
GridBagConstraints gbc_lblBaseDeDonnes = new GridBagConstraints();
gbc_lblBaseDeDonnes.anchor = GridBagConstraints.NORTH;
gbc_lblBaseDeDonnes.insets = new Insets(0, 0, 5, 5);
gbc_lblBaseDeDonnes.gridx = 0;
gbc_lblBaseDeDonnes.gridy = 9;
controlSkyMap.add(lblBaseDeDonnes, gbc_lblBaseDeDonnes);
pnlDatabases = new JPanel();
GridBagConstraints gbc_pnlDatabases = new GridBagConstraints();
gbc_pnlDatabases.insets = new Insets(0, 0, 5, 0);
gbc_pnlDatabases.fill = GridBagConstraints.BOTH;
gbc_pnlDatabases.gridx = 1;
gbc_pnlDatabases.gridy = 9;
controlSkyMap.add(pnlDatabases, gbc_pnlDatabases);
pnlDatabases.setLayout(new BoxLayout(pnlDatabases, BoxLayout.Y_AXIS));
lblClusters = new JLabel("Clusters");
GridBagConstraints gbc_lblClusters = new GridBagConstraints();
gbc_lblClusters.anchor = GridBagConstraints.NORTH;
gbc_lblClusters.insets = new Insets(0, 0, 5, 5);
gbc_lblClusters.gridx = 0;
gbc_lblClusters.gridy = 10;
controlSkyMap.add(lblClusters, gbc_lblClusters);
pnlClusters = new JPanel();
GridBagConstraints gbc_pnlClusters = new GridBagConstraints();
gbc_pnlClusters.insets = new Insets(0, 0, 5, 0);
gbc_pnlClusters.fill = GridBagConstraints.BOTH;
gbc_pnlClusters.gridx = 1;
gbc_pnlClusters.gridy = 10;
controlSkyMap.add(pnlClusters, gbc_pnlClusters);
pnlClusters.setLayout(new BoxLayout(pnlClusters, BoxLayout.Y_AXIS));
chckbxActivateClustering = new JCheckBox("Enable clustering");
pnlClusters.add(chckbxActivateClustering);
btnScreenshot = new JButton("Screenshot");
GridBagConstraints gbc_btnScreenshot = new GridBagConstraints();
gbc_btnScreenshot.insets = new Insets(0, 0, 0, 5);
gbc_btnScreenshot.gridx = 0;
gbc_btnScreenshot.gridy = 11;
controlSkyMap.add(btnScreenshot, gbc_btnScreenshot);
btnUpdate = new JButton("Force update");
GridBagConstraints gbc_btnUpdate = new GridBagConstraints();
gbc_btnUpdate.gridx = 1;
gbc_btnUpdate.gridy = 11;
controlSkyMap.add(btnUpdate, gbc_btnUpdate);
skyMap = PanelsFactory.createSkyMap();
GridBagConstraints gbc_skyMap = new GridBagConstraints();
gbc_skyMap.fill = GridBagConstraints.BOTH;
gbc_skyMap.gridx = 1;
gbc_skyMap.gridy = 0;
pnlSkyMap.add(skyMap, gbc_skyMap);
ImageIcon img = new ImageIcon("data/img/icon.png");
this.setIconImage(img.getImage());
// this.setI
}
/**
* @return the spinner for the date
*/
public JSpinner getSpnUserDate() {
return spinnerDate;
}
/**
*
* @return the update button
*/
public JButton getBtnUpdateDate() {
return btnUpdate;
}
/**
*
* @return the skyMap panel object
*/
public JPanel getSkyMap() {
return skyMap;
}
/**
*
* @return the play button
*/
public JToggleButton getTglbtnPlay() {
return tglbtnPlay;
}
/**
*
* @return the spinner for the ratio
*/
public JSpinner getSpnRatio() {
return spnRatio;
}
/**
*
* @return the screenShot button
*/
public JButton getBtnScreenshot() {
return btnScreenshot;
}
/**
* @return the spinner for the latitude
*/
public JSpinner getSpnLatitude() {
return spinnerLatitude;
}
/**
* @return the spinner for the longitude
*/
public JSpinner getSpnLongitude() {
return spinnerLong;
}
/**
*
* @return the menu for the locations
*/
public JMenu getMnLocations() {
return mnLocations;
}
/**
* sets the locations in the location menu
*
* @param locationsAction
*/
public void setLocations(Iterable<Action> locationsAction) {
for (Action a : locationsAction)
this.getMnLocations().add(a);
}
/**
* @return the app menu
*/
public JMenu getMnApplication() {
return mnApplication;
}
public JLabel getLabLocation() {
return labLocation;
}
public void setDatabases(Iterable<Component> databases) {
for (Component box : databases) {
pnlDatabases.add(box);
}
}
public JLabel getLabLabLocation() {
return lblLocalisation;
}
public JCheckBox getChckbxActivateClustering() {
return chckbxActivateClustering;
}
public JSpinner getSpnMagnitude() {
return spnMagnitude;
}
}