use of org.openstreetmap.gui.jmapviewer.Coordinate in project Course_Generator by patrovite.
the class JPanelMaps method RefreshCurrentPosMarker.
/**
* Refresh the position of the marker on the map
* @param lat
* latitude of the position of the marker
* @param lon
* longitude of the position of the marker
*/
public void RefreshCurrentPosMarker(double lat, double lon) {
if (CurrentPosMarker == null) {
// -- Define the current position marker
CurrentPosMarker = new MapMarkerImg(new Coordinate(lat, lon), createImageIcon("/course_generator/images/current_marker.png", "").getImage());
MapViewer.addMapMarker(CurrentPosMarker);
} else {
CurrentPosMarker.setLat(lat);
CurrentPosMarker.setLon(lon);
MapViewer.setDisplayPosition(new Coordinate(lat, lon), MapViewer.getZoom());
}
}
use of org.openstreetmap.gui.jmapviewer.Coordinate in project Course_Generator by patrovite.
the class BingAerialTileSource method parseAttributionText.
protected List<Attribution> parseAttributionText(InputSource xml) throws IOException {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(xml);
XPathFactory xPathFactory = XPathFactory.newInstance();
XPath xpath = xPathFactory.newXPath();
imageUrlTemplate = xpath.compile("//ImageryMetadata/ImageUrl/text()").evaluate(document);
imageUrlTemplate = culturePattern.matcher(imageUrlTemplate).replaceAll(Locale.getDefault().toString());
imageryZoomMax = Integer.parseInt(xpath.compile("//ImageryMetadata/ZoomMax/text()").evaluate(document));
NodeList subdomainTxt = (NodeList) xpath.compile("//ImageryMetadata/ImageUrlSubdomains/string/text()").evaluate(document, XPathConstants.NODESET);
subdomains = new String[subdomainTxt.getLength()];
for (int i = 0; i < subdomainTxt.getLength(); i++) {
subdomains[i] = subdomainTxt.item(i).getNodeValue();
}
XPathExpression attributionXpath = xpath.compile("Attribution/text()");
XPathExpression coverageAreaXpath = xpath.compile("CoverageArea");
XPathExpression zoomMinXpath = xpath.compile("ZoomMin/text()");
XPathExpression zoomMaxXpath = xpath.compile("ZoomMax/text()");
XPathExpression southLatXpath = xpath.compile("BoundingBox/SouthLatitude/text()");
XPathExpression westLonXpath = xpath.compile("BoundingBox/WestLongitude/text()");
XPathExpression northLatXpath = xpath.compile("BoundingBox/NorthLatitude/text()");
XPathExpression eastLonXpath = xpath.compile("BoundingBox/EastLongitude/text()");
NodeList imageryProviderNodes = (NodeList) xpath.compile("//ImageryMetadata/ImageryProvider").evaluate(document, XPathConstants.NODESET);
List<Attribution> attributions = new ArrayList<>(imageryProviderNodes.getLength());
for (int i = 0; i < imageryProviderNodes.getLength(); i++) {
Node providerNode = imageryProviderNodes.item(i);
String attribution = attributionXpath.evaluate(providerNode);
NodeList coverageAreaNodes = (NodeList) coverageAreaXpath.evaluate(providerNode, XPathConstants.NODESET);
for (int j = 0; j < coverageAreaNodes.getLength(); j++) {
Node areaNode = coverageAreaNodes.item(j);
Attribution attr = new Attribution();
attr.attribution = attribution;
attr.maxZoom = Integer.parseInt(zoomMaxXpath.evaluate(areaNode));
attr.minZoom = Integer.parseInt(zoomMinXpath.evaluate(areaNode));
Double southLat = Double.parseDouble(southLatXpath.evaluate(areaNode));
Double northLat = Double.parseDouble(northLatXpath.evaluate(areaNode));
Double westLon = Double.parseDouble(westLonXpath.evaluate(areaNode));
Double eastLon = Double.parseDouble(eastLonXpath.evaluate(areaNode));
attr.min = new Coordinate(southLat, westLon);
attr.max = new Coordinate(northLat, eastLon);
attributions.add(attr);
}
}
return attributions;
} catch (SAXException e) {
System.err.println("Could not parse Bing aerials attribution metadata.");
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (XPathExpressionException e) {
e.printStackTrace();
}
return null;
}
use of org.openstreetmap.gui.jmapviewer.Coordinate 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();
}
use of org.openstreetmap.gui.jmapviewer.Coordinate in project freeplane by freeplane.
the class OpenMapsNodeHook method setLocationChoiceUndoable.
private void setLocationChoiceUndoable(final OpenMapsExtension extension, final ICoordinate locationChoosen, final int zoomChoosen) {
final Coordinate currentLocation = extension.getLocation();
final int currentZoom = extension.getZoom();
if (!currentLocation.equals(locationChoosen)) {
final IActor actor = createUndoActor(extension, locationChoosen, currentLocation, zoomChoosen, currentZoom);
Controller.getCurrentModeController().execute(actor, Controller.getCurrentModeController().getController().getMap());
}
}
use of org.openstreetmap.gui.jmapviewer.Coordinate in project Course_Generator by patrovite.
the class JPanelMaps method RefreshMapMarker.
/**
* Refresh the marker on the map
* @param lat
* latitude of the position of the marker
* @param lon
* longitude of the position of the marker
*/
public void RefreshMapMarker(double lat, double lon) {
if (MapMarker == null) {
// -- Define the current position marker
MapMarker = new MapMarkerImg(new Coordinate(lat, lon), createImageIcon("/course_generator/images/marker1.png", "").getImage());
MapViewer.addMapMarker(MapMarker);
} else {
MapMarker.setLat(lat);
MapMarker.setLon(lon);
MapViewer.setDisplayPosition(new Coordinate(lat, lon), MapViewer.getZoom());
}
}
Aggregations