Search in sources :

Example 1 with Coordinate

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());
    }
}
Also used : Coordinate(org.openstreetmap.gui.jmapviewer.Coordinate)

Example 2 with Coordinate

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;
}
Also used : XPath(javax.xml.xpath.XPath) XPathExpression(javax.xml.xpath.XPathExpression) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) XPathExpressionException(javax.xml.xpath.XPathExpressionException) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) Document(org.w3c.dom.Document) SAXException(org.xml.sax.SAXException) XPathFactory(javax.xml.xpath.XPathFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Coordinate(org.openstreetmap.gui.jmapviewer.Coordinate) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 3 with Coordinate

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();
}
Also used : JPanelProfilListener(course_generator.profil.JPanelProfilListener) JPanelMapsListener(course_generator.maps.JPanelMapsListener) JTabbedPane(javax.swing.JTabbedPane) JPanelTrackDataListener(course_generator.trackdata.JPanelTrackDataListener) JPanelTrackData(course_generator.trackdata.JPanelTrackData) JPanelStatistics(course_generator.statistics.JPanelStatistics) JPanelResume(course_generator.resume.JPanelResume) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) JPanelAnalysisSpeedSlope(course_generator.analysis.JPanelAnalysisSpeedSlope) JTabbedPane(javax.swing.JTabbedPane) ImageIcon(javax.swing.ImageIcon) ChangeListener(javax.swing.event.ChangeListener) BorderLayout(java.awt.BorderLayout) JPanelMaps(course_generator.maps.JPanelMaps) JPanelAnalysisSpeed(course_generator.analysis.JPanelAnalysisSpeed) MouseEvent(java.awt.event.MouseEvent) JPanelResumeListener(course_generator.resume.JPanelResumeListener) course_generator.dialogs.frmEditPosition(course_generator.dialogs.frmEditPosition) WindowEvent(java.awt.event.WindowEvent) course_generator.dialogs.frmSearchPoint(course_generator.dialogs.frmSearchPoint) JPanelAnalysisTimeDist(course_generator.analysis.JPanelAnalysisTimeDist) ChangeEvent(javax.swing.event.ChangeEvent) JPanelProfil(course_generator.profil.JPanelProfil) Coordinate(org.openstreetmap.gui.jmapviewer.Coordinate) JPanel(javax.swing.JPanel)

Example 4 with Coordinate

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());
    }
}
Also used : Coordinate(org.openstreetmap.gui.jmapviewer.Coordinate) ICoordinate(org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate) IActor(org.freeplane.core.undo.IActor)

Example 5 with Coordinate

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());
    }
}
Also used : Coordinate(org.openstreetmap.gui.jmapviewer.Coordinate)

Aggregations

Coordinate (org.openstreetmap.gui.jmapviewer.Coordinate)7 ArrayList (java.util.ArrayList)2 CgData (course_generator.CgData)1 JPanelAnalysisSpeed (course_generator.analysis.JPanelAnalysisSpeed)1 JPanelAnalysisSpeedSlope (course_generator.analysis.JPanelAnalysisSpeedSlope)1 JPanelAnalysisTimeDist (course_generator.analysis.JPanelAnalysisTimeDist)1 course_generator.dialogs.frmEditPosition (course_generator.dialogs.frmEditPosition)1 course_generator.dialogs.frmSearchPoint (course_generator.dialogs.frmSearchPoint)1 JPanelMaps (course_generator.maps.JPanelMaps)1 JPanelMapsListener (course_generator.maps.JPanelMapsListener)1 JPanelProfil (course_generator.profil.JPanelProfil)1 JPanelProfilListener (course_generator.profil.JPanelProfilListener)1 JPanelResume (course_generator.resume.JPanelResume)1 JPanelResumeListener (course_generator.resume.JPanelResumeListener)1 JPanelStatistics (course_generator.statistics.JPanelStatistics)1 JPanelTrackData (course_generator.trackdata.JPanelTrackData)1 JPanelTrackDataListener (course_generator.trackdata.JPanelTrackDataListener)1 BasicStroke (java.awt.BasicStroke)1 BorderLayout (java.awt.BorderLayout)1 Container (java.awt.Container)1