use of course_generator.profil.JPanelProfilListener in project Course_Generator by patrovite.
the class frmMain method initComponents.
/**
* This method is called to initialize the form.
*/
private void initComponents() {
// -- Main windows
// ------------------------------------------------------
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle(bundle.getString("frmMain.title"));
setIconImages(null);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
// -- Layout
// ------------------------------------------------------------
Container paneGlobal = getContentPane();
paneGlobal.setLayout(new BorderLayout());
// -- Menu bar
// ----------------------------------------------------------
Create_MenuBarMain();
// -- Main toolbar
// ------------------------------------------------------
Create_MainToolbar();
paneGlobal.add(ToolBarMain, BorderLayout.NORTH);
// -- Status bar
// ------------------------------------------------------
Create_Statusbar();
paneGlobal.add(StatusBar, BorderLayout.SOUTH);
// -- Main split bar (vertical)
// -----------------------------------------
SplitPaneMain = new javax.swing.JSplitPane();
// -- Disable the default management of F6
SplitPaneMain.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0), "none");
paneGlobal.add(SplitPaneMain, BorderLayout.CENTER);
// -- Left side of the split bar
// ----------------------------------------
jPanelLeft = new javax.swing.JPanel();
jPanelLeft.setLayout(new java.awt.BorderLayout());
// -- Add the left panel to the main split panel
// ------------------------
SplitPaneMain.setLeftComponent(jPanelLeft);
SplitPaneMain.setDividerLocation(0);
// // -- Content of the tree
// javax.swing.tree.DefaultMutableTreeNode treeNode1 = new
// javax.swing.tree.DefaultMutableTreeNode(
// "Course Generator");
// javax.swing.tree.DefaultMutableTreeNode treeNode2 = new
// javax.swing.tree.DefaultMutableTreeNode("Parcours");
// javax.swing.tree.DefaultMutableTreeNode treeNode3 = new
// javax.swing.tree.DefaultMutableTreeNode("Utmb 2011");
// javax.swing.tree.DefaultMutableTreeNode treeNode4 = new
// javax.swing.tree.DefaultMutableTreeNode("Prévu");
// treeNode3.add(treeNode4);
// treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
// treeNode3.add(treeNode4);
// treeNode2.add(treeNode3);
// treeNode3 = new
// javax.swing.tree.DefaultMutableTreeNode("Montagnard");
// treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prévu");
// treeNode3.add(treeNode4);
// treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
// treeNode3.add(treeNode4);
// treeNode2.add(treeNode3);
// treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2008");
// treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prévu");
// treeNode3.add(treeNode4);
// treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
// treeNode3.add(treeNode4);
// treeNode2.add(treeNode3);
// treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2009");
// treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prévu");
// treeNode3.add(treeNode4);
// treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
// treeNode3.add(treeNode4);
// treeNode2.add(treeNode3);
// treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2010");
// treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prévu");
// treeNode3.add(treeNode4);
// treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
// treeNode3.add(treeNode4);
// treeNode2.add(treeNode3);
// treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2011");
// treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prévu");
// treeNode3.add(treeNode4);
// treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
// treeNode3.add(treeNode4);
// treeNode2.add(treeNode3);
// treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2012");
// treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prévu");
// treeNode3.add(treeNode4);
// treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
// treeNode3.add(treeNode4);
// treeNode2.add(treeNode3);
// treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2013");
// treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prévu");
// treeNode3.add(treeNode4);
// treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
// treeNode3.add(treeNode4);
// treeNode2.add(treeNode3);
// treeNode1.add(treeNode2);
// treeNode2 = new
// javax.swing.tree.DefaultMutableTreeNode("Configuration");
// treeNode1.add(treeNode2);
//
// // -- Tree
// // --------------------------------------------------------------
// jTreeMain = new javax.swing.JTree();
// jTreeMain.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
// jTreeMain.setPreferredSize(new java.awt.Dimension(109, 25));
//
// // -- Add the tree to a scroll panel
// // ------------------------------------
// jScrollPaneTree = new javax.swing.JScrollPane();
// jScrollPaneTree.setBorder(javax.swing.BorderFactory.createEtchedBorder());
// jScrollPaneTree.setViewportView(jTreeMain);
// jScrollPaneTree.setMaximumSize(new Dimension(0,0));
//
// // -- Add the scroll panel to the left panel
// // ----------------------------
// jPanelLeft.add(jScrollPaneTree, java.awt.BorderLayout.CENTER);
// -- Right split pane
// --------------------------------------------------
SplitPaneMainRight = new javax.swing.JSplitPane();
SplitPaneMainRight.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
// -- Disable the default management of F6
SplitPaneMainRight.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0), "none");
SplitPaneMain.setRightComponent(SplitPaneMainRight);
// -- Tabbed panel
// ------------------------------------------------------
TabbedPaneMain = new javax.swing.JTabbedPane();
// -- Create the listener
ChangeListener changeListener = new ChangeListener() {
public void stateChanged(ChangeEvent changeEvent) {
JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource();
int index = sourceTabbedPane.getSelectedIndex();
if (// Tab Resume
index == 4)
PanelResume.refresh();
}
};
TabbedPaneMain.addChangeListener(changeListener);
SplitPaneMainRight.setTopComponent(TabbedPaneMain);
// -- Tab - data (grid)
// -------------------------------------------------
panelTrackData = new JPanelTrackData(ModelTableMain, Settings);
panelTrackData.addListener(new JPanelTrackDataListener() {
@Override
public void doubleClickEvent() {
BackupInCGX();
frmEditPosition frm = new frmEditPosition();
if (frm.showDialog(Settings, Track, panelTrackData.getSelectedRow())) {
Track.isModified = true;
panelTrackData.refresh();
panelProfil.RefreshProfilChart();
Track.CheckTimeLimit();
RefreshStatusbar(Track);
}
}
@Override
public void simpleClickEvent() {
if (Track.data.size() > 0) {
int row = panelTrackData.getSelectedRow();
// -- Refresh marker position on the map
panelMap.RefreshCurrentPosMarker(Track.data.get(row).getLatitude(), Track.data.get(row).getLongitude());
// -- Refresh profil crooshair position and profil info
panelProfil.RefreshProfilInfo(row);
panelProfil.setCrosshairPosition(Track.data.get(row).getTotal(Settings.Unit) / 1000.0, Track.data.get(row).getElevation(Settings.Unit));
}
}
@Override
public void keyRealeasedEvent() {
if (Track.data.size() > 0) {
int row = panelTrackData.getSelectedRow();
panelMap.RefreshCurrentPosMarker(Track.data.get(row).getLatitude(), Track.data.get(row).getLongitude());
}
}
});
addTab(TabbedPaneMain, panelTrackData, bundle.getString("frmMain.TabData.tabTitle"), new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/satellite16.png")));
// -- Tab - Profil
// ------------------------------------------------------
panelProfil = new JPanelProfil(Settings);
panelProfil.addListener(new JPanelProfilListener() {
@Override
public void profilSelectionEvent() {
int i = panelProfil.getIndex();
// Refresh the position on the data grid
panelTrackData.setSelectedRow(i);
// Refresh the marker position on the map
panelMap.RefreshCurrentPosMarker(Track.data.get(i).getLatitude(), Track.data.get(i).getLongitude());
}
});
addTab(TabbedPaneMain, panelProfil, bundle.getString("frmMain.TabProfil.tabTitle"), new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/profil.png")));
// -- Tab - Statistic
// ---------------------------------------------------
panelStatistics = new JPanelStatistics(Settings);
addTab(TabbedPaneMain, panelStatistics, bundle.getString("frmMain.TabStatistic.tabTitle"), new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/stat.png")));
// -- Tab - Analysis
// ----------------------------------------------------
jPanelAnalyze = new javax.swing.JPanel();
jPanelAnalyze.setLayout(new java.awt.BorderLayout());
addTab(TabbedPaneMain, jPanelAnalyze, bundle.getString("frmMain.TabAnalyze.tabTitle"), new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/search.png")));
// -- Create the tab bar
TabbedPaneAnalysis = new javax.swing.JTabbedPane(JTabbedPane.LEFT);
jPanelAnalyze.add(TabbedPaneAnalysis, java.awt.BorderLayout.CENTER);
// -- Tab Analysis : Time/Dist
jPanelTimeDist = new JPanelAnalysisTimeDist();
addTab(TabbedPaneAnalysis, jPanelTimeDist, bundle.getString("frmMain.TabTimeDist.tabTitle"), null);
// -- Tab Analysis : Speed
jPanelSpeed = new JPanelAnalysisSpeed();
addTab(TabbedPaneAnalysis, jPanelSpeed, bundle.getString("frmMain.TabSpeed.tabTitle"), null);
// -- Tab Analysis : Speed/slope
jPanelSpeedSlope = new JPanelAnalysisSpeedSlope();
addTab(TabbedPaneAnalysis, jPanelSpeedSlope, bundle.getString("frmMain.TabSpeedSlope.tabTitle"), null);
// -- Tab - Resume
// ------------------------------------------------------
PanelResume = new JPanelResume(Resume, Settings);
PanelResume.addListener(new JPanelResumeListener() {
@Override
public void lineChangeEvent() {
SelectPositionFromResume(PanelResume.getSelectedLine());
}
});
addTab(TabbedPaneMain, PanelResume, bundle.getString("frmMain.TabResume.tabTitle"), new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/grid.png")));
// -- Map panel
// ---------------------------------------------------------
panelMap = new JPanelMaps(Settings);
panelMap.addListener(new JPanelMapsListener() {
@Override
public void requestPositionIndexEvent() {
panelMap.setRow(panelTrackData.getSelectedRow());
}
@Override
public void changeEvent() {
panelTrackData.refresh();
}
@Override
public void mouseClicked(MouseEvent evt) {
Coordinate c = panelMap.getSelectedPosition();
int i = Track.FindNearestPoint(c.getLat(), c.getLon());
// Selection the position on the data grid
panelTrackData.setSelectedRow(i);
// Refresh profil position
panelProfil.RefreshProfilInfo(i);
panelProfil.setCrosshairPosition(Track.data.get(i).getTotal(Settings.Unit) / 1000.0, Track.data.get(i).getElevation(Settings.Unit));
}
});
SplitPaneMainRight.setRightComponent(panelMap);
// -- Finished - Pack
// ---------------------------------------------------
pack();
}
Aggregations