├── .gitignore ├── LICENSE ├── README.md └── src └── com └── teamdev └── jxmaps ├── demo ├── AboutDialog.java ├── AboutPanel.java ├── ContentView.java ├── CustomListCellRenderer.java ├── JxMapsDemo.java ├── MenuHeader.java ├── MenuListener.java ├── MenuScrollbarUI.java ├── PopupMenu.java ├── SampleDescriptor.java ├── SampleIcon.java ├── Shadow.java └── res │ ├── Roboto-Bold.ttf │ ├── Roboto-Light.ttf │ ├── Roboto-Medium.ttf │ ├── Roboto-Regular.ttf │ ├── Roboto-Thin.ttf │ ├── close.png │ ├── close_black.png │ ├── close_black_retina.png │ ├── close_retina.png │ ├── ic_chat_bubble_outline_black_24dp_1x.png │ ├── ic_directions_black_24dp_1x.png │ ├── ic_directions_sample.png │ ├── ic_directions_sample_retina.png │ ├── ic_elevation_sample.png │ ├── ic_elevation_sample_retina.png │ ├── ic_events_sample.png │ ├── ic_events_sample_retina.png │ ├── ic_geocoding_sample.png │ ├── ic_geocoding_sample_retina.png │ ├── ic_infowindow_sample.png │ ├── ic_infowindow_sample_retina.png │ ├── ic_language_black_24dp_1x.png │ ├── ic_location_on_black_24dp_1x.png │ ├── ic_markers_sample.png │ ├── ic_markers_sample_retina.png │ ├── ic_options_sample.png │ ├── ic_options_sample_retina.png │ ├── ic_places_sample.png │ ├── ic_places_sample_retina.png │ ├── ic_polygon_sample.png │ ├── ic_polygon_sample_retina.png │ ├── ic_polyline_sample.png │ ├── ic_polyline_sample_retina.png │ ├── ic_settings_black_24dp_1x.png │ ├── ic_simple_sample.png │ ├── ic_simple_sample_retina.png │ ├── ic_streetview_black_24dp_1x.png │ ├── ic_streetview_sample.png │ ├── ic_streetview_sample_retina.png │ ├── ic_styled_sample.png │ ├── ic_styled_sample_retina.png │ ├── ic_traffic_sample.png │ ├── ic_traffic_sample_retina.png │ ├── jxmaps16x16.png │ ├── jxmaps256x256.png │ ├── jxmaps32x32.png │ ├── menu-background.png │ ├── menu-background_retina.png │ ├── menu.png │ └── menu_retina.png └── examples ├── ControlPanel.java ├── DirectionsExample.java ├── EditableTextControlPanel.java ├── ElevationExample.java ├── EventsExample.java ├── FXMLExample.java ├── GeocoderExample.java ├── InfoWindowExample.java ├── JavaFXExample.java ├── LightweightMapExample.java ├── MapExample.java ├── MapOptionsExample.java ├── MapViewFXControl.java ├── MarkersExample.java ├── OptionsWindow.java ├── PlacesSearchExample.java ├── PolygonExample.java ├── PolylineExample.java ├── SaveImageExample.java ├── StreetViewExample.java ├── StreetViewLayoutExample.java ├── StyledMapExample.java ├── TrafficLayerExample.java └── res ├── Paris.png ├── Roboto-Bold.ttf ├── Roboto-Light.ttf ├── Roboto-Medium.ttf ├── Roboto-Regular.ttf ├── Roboto-Thin.ttf ├── bars_and_pubs.png ├── bars_and_pubs_for_map.png ├── change.png ├── checkbox_0.png ├── checkbox_1.png ├── dots.png ├── from.png ├── hotels.png ├── hotels_for_map.png ├── main.fxml ├── restaurants.png ├── restaurants_for_map.png ├── search.png ├── search_hover.png └── to.png /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JxMaps-Examples 2 | This repository contains the source code of examples that demonstrate features you can implement using JxMaps library, created by TeamDev (www.teamdev.com) 3 | 4 | JxMaps allows to embed Google Maps into Java application. 5 | 6 | Find out more about JxMaps: www.teamdev.com/jxmaps 7 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/AboutDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.demo; 6 | 7 | import javax.swing.*; 8 | import java.awt.*; 9 | 10 | class AboutDialog extends JDialog{ 11 | private static Component parentFrame; 12 | 13 | public AboutDialog() { 14 | AboutPanel panel = new AboutPanel(); 15 | setModal(true); 16 | setResizable(false); 17 | setTitle("About JxMaps Demo"); 18 | setSize(new Dimension(400,panel.getPreferredHeight() - 60)); 19 | 20 | setLayout(new BorderLayout()); 21 | add(panel); 22 | } 23 | 24 | public static void initHandler(Component frame) { 25 | parentFrame = frame; 26 | com.apple.eawt.Application.getApplication().setDockIconImage(Toolkit.getDefaultToolkit().getImage(SampleDescriptor.class.getResource("res/jxmaps256x256.png"))); 27 | com.apple.eawt.Application.getApplication().setAboutHandler(new com.apple.eawt.AboutHandler() { 28 | @Override 29 | public void handleAbout(com.apple.eawt.AppEvent.AboutEvent aboutEvent) { 30 | AboutDialog dlg = new AboutDialog(); 31 | dlg.setLocationRelativeTo(parentFrame); 32 | dlg.setVisible(true); 33 | } 34 | }); 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/AboutPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.demo; 6 | 7 | import com.teamdev.jxmaps.examples.ControlPanel; 8 | 9 | import javax.swing.*; 10 | import javax.swing.event.HyperlinkEvent; 11 | import javax.swing.event.HyperlinkListener; 12 | import java.awt.*; 13 | import java.net.URL; 14 | 15 | class AboutPanel extends JPanel implements ControlPanel { 16 | 17 | public AboutPanel() { 18 | setBackground(Color.white); 19 | setLayout(new BorderLayout()); 20 | JTextPane aboutText = new JTextPane(); 21 | aboutText.setContentType("text/html"); 22 | aboutText.setText("\">" + 23 | "JxMaps Demo

" + 24 | "@VERSION@

" + 25 | "This application is created for demonstration purposes only.
" + 26 | "© 2017 TeamDev Ltd. All rights reserved.

" + 27 | "Powered by JxMaps. See terms of use.
" + 28 | "Created using Google Maps JavaScript API.
" + 29 | "Based on Chromium project. See full list of Chromium
components, used in the current JxMaps version.
"+ 30 | "This demo uses WebKit project under LGPL.
See licence text LGPL v.2 and LGPL v.2.1
" + 31 | "This demo uses Roboto font, distributed under Apache 2.0
licence, and Material icons.
" + 32 | "
<"); 33 | 34 | Font robotoPlain13 = new Font("Roboto", 0, 12); 35 | aboutText.setFont(robotoPlain13); 36 | aboutText.setBorder(BorderFactory.createEmptyBorder(20, 20, 0, 20)); 37 | aboutText.setEditable(false); 38 | aboutText.addHyperlinkListener(new HyperlinkListener() { 39 | @Override 40 | public void hyperlinkUpdate(HyperlinkEvent e) { 41 | if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { 42 | URL url = e.getURL(); 43 | try { 44 | Desktop desktop = java.awt.Desktop.getDesktop(); 45 | desktop.browse(url.toURI()); 46 | } catch (Exception e1) { 47 | throw new RuntimeException(e1); 48 | } 49 | } 50 | } 51 | }); 52 | 53 | add(aboutText, BorderLayout.CENTER); 54 | } 55 | 56 | @Override 57 | public JComponent getControlPanel() { 58 | return this; 59 | } 60 | 61 | @Override 62 | public void configureControlPanel() { 63 | } 64 | 65 | @Override 66 | public int getPreferredHeight() { 67 | return 340; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/ContentView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.demo; 6 | 7 | import com.teamdev.jxmaps.examples.ControlPanel; 8 | 9 | import javax.swing.*; 10 | import java.awt.*; 11 | 12 | class ContentView extends JPanel implements MenuListener { 13 | private JComponent sampleView; 14 | 15 | public ContentView() { 16 | setLayout(new GridLayout()); 17 | } 18 | 19 | @Override 20 | public void sampleSelected(SampleDescriptor descriptor) { 21 | if (sampleView != null) { 22 | remove(sampleView); 23 | validate(); 24 | } 25 | 26 | Dimension size = getSize(); 27 | sampleView = descriptor.createInstance(size); 28 | 29 | add(sampleView, BorderLayout.CENTER); 30 | validate(); 31 | } 32 | 33 | public ControlPanel getControlPanel() { 34 | if (sampleView instanceof ControlPanel) { 35 | return (ControlPanel) sampleView; 36 | } else { 37 | return null; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/CustomListCellRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.demo; 6 | 7 | import javax.swing.*; 8 | import java.awt.*; 9 | import java.beans.PropertyChangeEvent; 10 | import java.beans.PropertyChangeListener; 11 | 12 | 13 | class CustomListCellRenderer extends JPanel implements ListCellRenderer { 14 | private final Color SELECTION_BACKGROUND = new Color(0xFA, 0xFA, 0xFA); 15 | 16 | private JLabel image = new JLabel(); 17 | private JLabel title = new JLabel(); 18 | private JTextArea description = new JTextArea(); 19 | 20 | private int highlightedIndex = -1; 21 | 22 | public CustomListCellRenderer(final JList list) { 23 | list.addPropertyChangeListener(PopupMenu.HIGHLIGHTED_INDEX, new PropertyChangeListener() { 24 | @Override 25 | public void propertyChange(PropertyChangeEvent evt) { 26 | highlightedIndex = (Integer) evt.getNewValue(); 27 | list.repaint(); 28 | } 29 | }); 30 | 31 | setAutoscrolls(true); 32 | setLayout(new GridBagLayout()); 33 | 34 | Font robotoPlain15 = new Font("Roboto", 0, 15); 35 | Font robotoPlain13 = new Font("Roboto", 0, 13); 36 | 37 | title.setFont(robotoPlain15); 38 | title.setForeground(new Color(0x21, 0x21, 0x21)); 39 | 40 | description.setFont(robotoPlain13); 41 | description.setForeground(new Color(0x75, 0x75, 0x75)); 42 | 43 | description.setLineWrap(true); 44 | description.setWrapStyleWord(true); 45 | description.setPreferredSize(new Dimension(1, 34)); 46 | description.setBorder(null); 47 | description.setOpaque(false); 48 | 49 | add(image, new GridBagConstraints(0, 0, 1, 3, 0.0, 0.0 50 | , GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(10, 14, 5, 10), 0, 0)); 51 | 52 | add(title, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0 53 | , GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(10, 22, 0, 0), 0, 0)); 54 | 55 | add(description, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0 56 | , GridBagConstraints.NORTHEAST, GridBagConstraints.BOTH, new Insets(5, 22, 5, 0), 0, 0)); 57 | 58 | } 59 | 60 | public Component getListCellRendererComponent(JList list, 61 | Object value, 62 | int index, 63 | boolean isSelected, 64 | boolean cellHasFocus) { 65 | if (isSelected || index == highlightedIndex) { 66 | setBackground(SELECTION_BACKGROUND); 67 | } else { 68 | setBackground(list.getBackground()); 69 | } 70 | SampleDescriptor sample = (SampleDescriptor) value; 71 | 72 | image.setIcon(sample.getIcon()); 73 | title.setText(sample.getTitle()); 74 | description.setText(sample.getDescription()); 75 | return this; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/JxMapsDemo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.demo; 6 | import com.teamdev.jxmaps.examples.*; 7 | 8 | import javax.swing.*; 9 | import java.awt.*; 10 | 11 | public class JxMapsDemo implements MenuListener { 12 | private JFrame frame; 13 | private ContentView contentView; 14 | private PopupMenu menu; 15 | 16 | private static void initEnvironment() throws Exception { 17 | System.setProperty("apple.laf.useScreenMenuBar", "true"); 18 | System.setProperty("com.apple.mrj.application.apple.menu.about.name", "JxMaps Demo"); 19 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 20 | JPopupMenu.setDefaultLightWeightPopupEnabled(false); 21 | } 22 | 23 | private static void loadAndRegisterCustomFonts() { 24 | try { 25 | GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); 26 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, JxMapsDemo.class.getResourceAsStream("res/Roboto-Bold.ttf"))); 27 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, JxMapsDemo.class.getResourceAsStream("res/Roboto-Medium.ttf"))); 28 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, JxMapsDemo.class.getResourceAsStream("res/Roboto-Regular.ttf"))); 29 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, JxMapsDemo.class.getResourceAsStream("res/Roboto-Thin.ttf"))); 30 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, JxMapsDemo.class.getResourceAsStream("res/Roboto-Light.ttf"))); 31 | } catch (Exception e) { 32 | throw new RuntimeException(e); 33 | } 34 | } 35 | 36 | private void initAndDisplayUI() { 37 | contentView = new ContentView(); 38 | 39 | frame = new JFrame("JxMaps Demo"); 40 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 41 | frame.add(contentView, BorderLayout.CENTER); 42 | frame.setSize(1024, 768); 43 | frame.setLocationRelativeTo(null); 44 | frame.setIconImage(new ImageIcon(JxMapsDemo.class.getResource("res/jxmaps32x32.png")).getImage()); 45 | frame.setVisible(true); 46 | 47 | String osName = System.getProperty("os.name"); 48 | if (osName.startsWith("Mac OS")) { 49 | AboutDialog.initHandler(frame); 50 | } 51 | 52 | SampleDescriptor samples[] = new SampleDescriptor[]{ 53 | new SampleDescriptor("ic_simple_sample", "Simple Map", "Adding a map to a Java application is easy.", MapExample.class), 54 | new SampleDescriptor("ic_styled_sample", "Styled Map", "Define colour and visibility of roads, parks, bodies of water etc.", StyledMapExample.class), 55 | new SampleDescriptor("ic_markers_sample", "Markers", "Add markers to a map on click.", MarkersExample.class), 56 | new SampleDescriptor("ic_directions_sample", "Directions", "Calculate and display the route between two points.", DirectionsExample.class), 57 | new SampleDescriptor("ic_options_sample", "Map Options", "Customize the map view.", MapOptionsExample.class), 58 | new SampleDescriptor("ic_infowindow_sample", "Info Window", "Display information about the marked location.", InfoWindowExample.class), 59 | new SampleDescriptor("ic_geocoding_sample", "Geocoding", "Define coordinates based on the address and vice versa.", GeocoderExample.class), 60 | new SampleDescriptor("ic_streetview_sample", "Street View", "Display panoramas.", StreetViewExample.class), 61 | new SampleDescriptor("ic_elevation_sample", "Elevation", "Calculate and display elevation value at a given point.", ElevationExample.class), 62 | new SampleDescriptor("ic_places_sample", "Places Search", "Find places near a given point.", PlacesSearchExample.class), 63 | new SampleDescriptor("ic_polygon_sample", "Polygon", "Draw polygons on the map.", PolygonExample.class), 64 | new SampleDescriptor("ic_polyline_sample", "Polyline", "Draw a custom route on the map.", PolylineExample.class), 65 | new SampleDescriptor("ic_traffic_sample", "Traffic Layer", "Display information about traffic on the map.", TrafficLayerExample.class), 66 | new SampleDescriptor("ic_events_sample", "Events", "The pane shows you events that are triggered when you interact with the map.", EventsExample.class), 67 | }; 68 | 69 | menu = new PopupMenu(frame, samples, new Point(0, 0)); 70 | menu.addListener(this); 71 | 72 | sampleSelected(samples[0]); 73 | } 74 | 75 | @Override 76 | public void sampleSelected(SampleDescriptor descriptor) { 77 | frame.setTitle("JxMaps Demo - " + descriptor.getTitle()); 78 | contentView.sampleSelected(descriptor); 79 | 80 | ControlPanel controlPanel = contentView.getControlPanel(); 81 | if (controlPanel != null) { 82 | controlPanel.configureControlPanel(); 83 | } 84 | menu.setControlPanel(controlPanel); 85 | } 86 | 87 | static { 88 | try { 89 | initEnvironment(); 90 | } catch (Exception e) { 91 | // e.printStackTrace(); 92 | } 93 | } 94 | 95 | public static void main(String[] args) throws Exception { 96 | initEnvironment(); 97 | loadAndRegisterCustomFonts(); 98 | SwingUtilities.invokeLater(new Runnable() { 99 | public void run() { 100 | new JxMapsDemo().initAndDisplayUI(); 101 | } 102 | }); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/MenuHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.demo; 6 | 7 | import javax.swing.*; 8 | import javax.swing.plaf.basic.BasicButtonUI; 9 | import java.awt.*; 10 | import java.awt.event.ActionEvent; 11 | import java.awt.event.ActionListener; 12 | import java.awt.event.MouseAdapter; 13 | import java.awt.event.MouseEvent; 14 | 15 | class MenuHeader extends JPanel { 16 | private static final SampleIcon CLOSE_ICON = new SampleIcon(SampleDescriptor.class.getResource(SampleIcon.isRetina()? "res/close_retina.png" : "res/close.png")); 17 | private static final SampleIcon CLOSE_ICON_BLACK = new SampleIcon(SampleDescriptor.class.getResource(SampleIcon.isRetina()? "res/close_black_retina.png" : "res/close_black.png")); 18 | 19 | private JTextField menuText; 20 | private JButton closeButton; 21 | 22 | public MenuHeader(String title, final ActionListener textEnterListener, final ActionListener closeListener) { 23 | setPreferredSize(new Dimension(1, 65)); 24 | setBackground(Color.white); 25 | 26 | JLabel menuImageLabel = new JLabel(PopupMenu.MENU_ICON); 27 | menuImageLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); 28 | 29 | menuText = new JTextField(title); 30 | menuText.setOpaque(false); 31 | menuText.setBorder(BorderFactory.createEmptyBorder()); 32 | menuText.setEditable(false); 33 | menuText.addActionListener(textEnterListener); 34 | 35 | Font robotoBold18 = new Font("Roboto", Font.BOLD, 18); 36 | menuText.setFont(robotoBold18); 37 | menuText.setForeground(new Color(0x21, 0x21, 0x21)); 38 | 39 | setLayout(new GridBagLayout()); 40 | 41 | menuImageLabel.addMouseListener(new MouseAdapter() { 42 | @Override 43 | public void mouseClicked(MouseEvent e) { 44 | if (closeButton.isVisible()) { 45 | closeListener.actionPerformed(null); 46 | } 47 | } 48 | }); 49 | add(menuImageLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 1.0, 50 | GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(19, 13, 12, 0), 0, 0)); 51 | 52 | add(menuText, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, 53 | GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(21, 32, 12, 15), 0, 0)); 54 | 55 | closeButton = new JButton(CLOSE_ICON); 56 | closeButton.setToolTipText("Close"); 57 | closeButton.setBorder(BorderFactory.createEmptyBorder()); 58 | closeButton.setUI(new BasicButtonUI()); 59 | closeButton.setOpaque(false); 60 | closeButton.setRolloverIcon(CLOSE_ICON_BLACK); 61 | closeButton.addActionListener(closeListener); 62 | closeButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); 63 | closeButton.setVisible(false); 64 | 65 | add(closeButton, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, 66 | GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(22, 0, 12, 18), 0, 0)); 67 | 68 | setBorder(new Shadow(4)); 69 | } 70 | 71 | public void setText(String text) { 72 | menuText.setText(text); 73 | } 74 | 75 | public String getText() { 76 | return menuText.getText(); 77 | } 78 | 79 | public void setTextEditable(boolean value) { 80 | menuText.setEditable(value); 81 | } 82 | 83 | public boolean getTextEditable() { 84 | return menuText.isEditable(); 85 | } 86 | 87 | public void setCloseButtonVisible(boolean value) { 88 | closeButton.setVisible(value); 89 | } 90 | 91 | public boolean getCloseButtonVisible() { 92 | return closeButton.isVisible(); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/MenuListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.demo; 6 | 7 | interface MenuListener { 8 | void sampleSelected(SampleDescriptor descriptor); 9 | } 10 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/MenuScrollbarUI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.demo; 6 | 7 | import javax.swing.*; 8 | import javax.swing.plaf.metal.MetalScrollBarUI; 9 | import java.awt.*; 10 | import java.awt.image.BufferedImage; 11 | 12 | class MenuScrollbarUI extends MetalScrollBarUI { 13 | 14 | private Image imageThumb, imageTrack; 15 | 16 | private JButton button = new JButton() { 17 | @Override 18 | public Dimension getPreferredSize() { 19 | return new Dimension(0, 0); 20 | } 21 | 22 | }; 23 | 24 | static public Image create(int w, int h, Color c) { 25 | BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); 26 | Graphics2D g2d = bi.createGraphics(); 27 | g2d.setPaint(c); 28 | g2d.fillRect(0, 0, w, h); 29 | g2d.dispose(); 30 | return bi; 31 | } 32 | 33 | MenuScrollbarUI() { 34 | imageThumb = create(16, 16, new Color(0xbd, 0xbd, 0xbd)); 35 | imageTrack = create(16, 16, new Color(0xf5, 0xf5, 0xf5)); 36 | } 37 | 38 | @Override 39 | protected void paintThumb(Graphics g, JComponent c, Rectangle r) { 40 | g.setColor(Color.gray); 41 | g.drawImage(imageThumb, r.x, r.y, r.width, r.height, null); 42 | } 43 | 44 | @Override 45 | protected void paintTrack(Graphics g, JComponent c, Rectangle r) { 46 | g.drawImage(imageTrack, r.x, r.y, r.width, r.height, null); 47 | } 48 | 49 | @Override 50 | protected JButton createDecreaseButton(int orientation) { 51 | return button; 52 | } 53 | 54 | @Override 55 | protected JButton createIncreaseButton(int orientation) { 56 | return button; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/PopupMenu.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.demo; 6 | 7 | import com.teamdev.jxmaps.examples.ControlPanel; 8 | import com.teamdev.jxmaps.examples.EditableTextControlPanel; 9 | 10 | import javax.swing.*; 11 | import javax.swing.plaf.basic.BasicButtonUI; 12 | import java.awt.*; 13 | import java.awt.event.*; 14 | import java.util.LinkedList; 15 | 16 | class PopupMenu { 17 | static final SampleIcon MENU_ICON = new SampleIcon(SampleDescriptor.class.getResource("res/menu" + (SampleIcon.isRetina() ? "_retina.png" : ".png"))); 18 | static final SampleIcon MENU_BACKGROUND = new SampleIcon(SampleDescriptor.class.getResource("res/menu-background" + (SampleIcon.isRetina() ? "_retina.png" : ".png"))); 19 | 20 | final static Color TRANSPARENT_BACKGROUND = new Color(1, 1, 1, 1); 21 | final static String HIGHLIGHTED_INDEX = "highlightedIndex"; 22 | final static String FEATURES = "Features"; 23 | final static int MENU_WIDTH = 400; 24 | 25 | private final JFrame parentWindow; 26 | private final JWindow menuButtonWindow; 27 | private final JWindow menuOptionsWindow; 28 | private MenuHeader menuHeader; 29 | private JScrollPane scrollPane; 30 | private JList featureList; 31 | private boolean shouldHideMenu = true; 32 | private ControlPanel controlPanel; 33 | private JLabel aboutLabel; 34 | private AboutPanel about; 35 | 36 | private final java.util.List menuListeners = new LinkedList(); 37 | 38 | public PopupMenu(JFrame parentWindow, SampleDescriptor[] samples, final Point relativeLocation) { 39 | this.parentWindow = parentWindow; 40 | parentWindow.addWindowListener(new WindowAdapter() { 41 | @Override 42 | public void windowIconified(WindowEvent e) { 43 | menuButtonWindow.setVisible(false); 44 | menuOptionsWindow.setVisible(false); 45 | } 46 | 47 | @Override 48 | public void windowDeiconified(WindowEvent e) { 49 | menuButtonWindow.setVisible(true); 50 | } 51 | }); 52 | 53 | parentWindow.getContentPane().addComponentListener(new ComponentAdapter() { 54 | @Override 55 | public void componentResized(ComponentEvent e) { 56 | if (controlPanel != null) { 57 | menuOptionsWindow.setSize(MENU_WIDTH, controlPanel.getPreferredHeight()); 58 | menuOptionsWindow.getContentPane().revalidate(); 59 | } 60 | } 61 | }); 62 | 63 | menuButtonWindow = new JWindow(parentWindow); 64 | 65 | Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { 66 | @Override 67 | public void eventDispatched(AWTEvent event) { 68 | if (event.getID() == MouseEvent.MOUSE_EXITED) { 69 | if (menuOptionsWindow.isVisible() && !menuOptionsWindow.getBounds().contains(((MouseEvent) event).getLocationOnScreen())) { 70 | if (shouldHideMenu) { 71 | menuOptionsWindow.setVisible(false); 72 | } 73 | } 74 | } 75 | } 76 | }, AWTEvent.MOUSE_EVENT_MASK); 77 | 78 | menuButtonWindow.setBackground(TRANSPARENT_BACKGROUND); 79 | menuButtonWindow.setSize(62, 62); 80 | menuButtonWindow.setLocation(relativeLocation); 81 | 82 | final Container contentPane = menuButtonWindow.getContentPane(); 83 | contentPane.setLayout(new BorderLayout()); 84 | 85 | final JButton menuButton = new JButton(MENU_ICON); 86 | menuButton.setSize(new Dimension(62, 62)); 87 | menuButton.setBorder(BorderFactory.createEmptyBorder()); 88 | menuButton.setToolTipText("Menu"); 89 | menuButton.setOpaque(false); 90 | menuButton.setUI(new BasicButtonUI()); 91 | menuButton.addMouseListener(new MouseAdapter() { 92 | @Override 93 | public void mouseEntered(MouseEvent e) { 94 | showMenu(); 95 | } 96 | }); 97 | 98 | JComponent menuPanel = new JComponent() { 99 | @Override 100 | public void paintComponent(Graphics g) { 101 | Image image = MENU_BACKGROUND.getImage(); 102 | g.drawImage(image, 0, 0, null); 103 | } 104 | }; 105 | menuPanel.add(menuButton, BorderLayout.CENTER); 106 | 107 | contentPane.add(menuPanel, BorderLayout.CENTER); 108 | 109 | updateMenuLocation(relativeLocation); 110 | menuButtonWindow.setVisible(true); 111 | 112 | menuOptionsWindow = new JWindow(parentWindow); 113 | menuOptionsWindow.setLocation(relativeLocation); 114 | 115 | final Container contentPane1 = menuOptionsWindow.getContentPane(); 116 | 117 | JPanel mainPanel = new JPanel(); 118 | mainPanel.setOpaque(true); 119 | 120 | contentPane1.add(mainPanel); 121 | 122 | mainPanel.setLayout(new GridBagLayout()); 123 | 124 | featureList = new JList(samples); 125 | featureList.setCursor(new Cursor(Cursor.HAND_CURSOR)); 126 | scrollPane = new JScrollPane(featureList); 127 | scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); 128 | scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); 129 | 130 | featureList.addMouseListener(new MouseAdapter() { 131 | @Override 132 | public void mouseClicked(MouseEvent e) { 133 | selectSampleAndHideMenu(); 134 | } 135 | }); 136 | 137 | Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { 138 | @Override 139 | public void eventDispatched(AWTEvent event) { 140 | if (event.getID() == MouseEvent.MOUSE_MOVED) { 141 | Point cursorPosition = ((MouseEvent) event).getLocationOnScreen(); 142 | cursorPosition.translate(0, scrollPane.getViewport().getY()); 143 | if (menuOptionsWindow.isVisible() && menuOptionsWindow.getBounds().contains(cursorPosition)) { 144 | SwingUtilities.convertPointFromScreen(cursorPosition, featureList); 145 | int index = featureList.locationToIndex(cursorPosition); 146 | featureList.firePropertyChange(HIGHLIGHTED_INDEX, -1, index); 147 | } 148 | } 149 | } 150 | }, AWTEvent.MOUSE_MOTION_EVENT_MASK); 151 | 152 | featureList.setCellRenderer(new CustomListCellRenderer(featureList)); 153 | scrollPane.setBorder(null); 154 | scrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(10, 1)); 155 | MenuScrollbarUI scrollbar = new MenuScrollbarUI(); 156 | scrollPane.getVerticalScrollBar().setUI(scrollbar); 157 | 158 | ActionListener closeSampleListener = new ActionListener() { 159 | @Override 160 | public void actionPerformed(ActionEvent e) { 161 | restoreMenu(); 162 | } 163 | }; 164 | ActionListener textEnterListener = new ActionListener() { 165 | @Override 166 | public void actionPerformed(ActionEvent e) { 167 | String enteredText = menuHeader.getText(); 168 | if (controlPanel instanceof EditableTextControlPanel) { 169 | ((EditableTextControlPanel) controlPanel).onTextEntered(enteredText); 170 | } 171 | } 172 | }; 173 | menuHeader = new MenuHeader(FEATURES, textEnterListener, closeSampleListener); 174 | mainPanel.add(menuHeader, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, 175 | GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); 176 | 177 | mainPanel.add(scrollPane, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, 178 | GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); 179 | 180 | 181 | Font robotoPlain11 = new Font("Roboto", 0, 11); 182 | aboutLabel = new JLabel("About JxMaps Demo"); 183 | aboutLabel.setFont(robotoPlain11); 184 | aboutLabel.setForeground(new Color(0x75, 0x75, 0x75)); 185 | aboutLabel.setBackground(new Color(0xFA, 0xFA, 0xFA)); 186 | aboutLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); 187 | aboutLabel.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0)); 188 | aboutLabel.setHorizontalAlignment(SwingConstants.CENTER); 189 | aboutLabel.addMouseListener(new MouseAdapter() { 190 | @Override 191 | public void mouseClicked(MouseEvent e) { 192 | showAbout(); 193 | } 194 | }); 195 | 196 | mainPanel.add(scrollPane, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, 197 | GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); 198 | 199 | mainPanel.add(aboutLabel, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0, 200 | GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); 201 | 202 | parentWindow.addComponentListener(new ComponentAdapter() { 203 | @Override 204 | public void componentMoved(ComponentEvent e) { 205 | updateMenuLocation(relativeLocation); 206 | } 207 | }); 208 | 209 | about = new AboutPanel(); 210 | } 211 | 212 | private void showAbout() { 213 | setControlPanel(about); 214 | } 215 | 216 | private void selectSampleAndHideMenu() { 217 | SampleDescriptor sampleDescriptor = featureList.getSelectedValue(); 218 | for (MenuListener listener : menuListeners) 219 | listener.sampleSelected(sampleDescriptor); 220 | 221 | if (shouldHideMenu) { 222 | menuOptionsWindow.setVisible(false); 223 | } 224 | } 225 | 226 | private void restoreMenu() { 227 | menuOptionsWindow.setSize(MENU_WIDTH, parentWindow.getContentPane().getHeight()); 228 | 229 | scrollPane.getViewport().remove(controlPanel.getControlPanel()); 230 | scrollPane.setViewportView(featureList); 231 | scrollPane.getViewport().revalidate(); 232 | menuHeader.setText(FEATURES); 233 | menuHeader.setCloseButtonVisible(false); 234 | menuHeader.setTextEditable(false); 235 | aboutLabel.setVisible(true); 236 | shouldHideMenu = true; 237 | } 238 | 239 | public void setControlPanel(ControlPanel controlPanel) { 240 | if (controlPanel != null) { 241 | aboutLabel.setVisible(false); 242 | this.controlPanel = controlPanel; 243 | scrollPane.getViewport().remove(featureList); 244 | 245 | if (controlPanel instanceof AboutPanel) { 246 | menuHeader.setText(aboutLabel.getText()); 247 | } else { 248 | SampleDescriptor descriptor = featureList.getSelectedValue(); 249 | menuHeader.setText(descriptor.getTitle()); 250 | } 251 | menuHeader.setCloseButtonVisible(true); 252 | menuOptionsWindow.setVisible(true); 253 | scrollPane.setViewportView(controlPanel.getControlPanel()); 254 | scrollPane.getViewport().revalidate(); 255 | if (controlPanel instanceof EditableTextControlPanel) { 256 | menuHeader.setTextEditable(true); 257 | menuHeader.setText(((EditableTextControlPanel) controlPanel).getInitialText()); 258 | } 259 | menuOptionsWindow.setSize(MENU_WIDTH, controlPanel.getPreferredHeight()); 260 | shouldHideMenu = false; 261 | } 262 | } 263 | 264 | private void showMenu() { 265 | updateMenuOptionsLocation(); 266 | menuOptionsWindow.setSize(MENU_WIDTH, parentWindow.getContentPane().getHeight()); 267 | menuOptionsWindow.setVisible(true); 268 | } 269 | 270 | private void updateMenuLocation(Point relativeLocation) { 271 | Point newLocation = PopupMenu.this.parentWindow.getContentPane().getLocationOnScreen(); 272 | newLocation.translate(relativeLocation.x, relativeLocation.y); 273 | menuButtonWindow.setLocation(newLocation); 274 | 275 | if (menuOptionsWindow != null && menuOptionsWindow.isVisible()) { 276 | updateMenuOptionsLocation(); 277 | } 278 | } 279 | 280 | private void updateMenuOptionsLocation() { 281 | Point location = parentWindow.getContentPane().getLocationOnScreen(); 282 | menuOptionsWindow.setLocation(location.x, location.y); 283 | } 284 | 285 | public void addListener(MenuListener menuListener) { 286 | menuListeners.add(menuListener); 287 | } 288 | } 289 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/SampleDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.demo; 6 | 7 | import com.teamdev.jxmaps.swing.MapView; 8 | 9 | import javax.swing.*; 10 | import java.awt.*; 11 | 12 | class SampleDescriptor { 13 | private final SampleIcon icon; 14 | private final String title; 15 | private final String description; 16 | private Class sampleClass; 17 | 18 | public SampleDescriptor(String iconPath, String title, String description, Class sampleClass) { 19 | this.icon = new SampleIcon(SampleDescriptor.class.getResource("res/" + iconPath + (SampleIcon.isRetina() ? "_retina.png" : ".png"))); 20 | this.title = title; 21 | this.description = description; 22 | this.sampleClass = sampleClass; 23 | } 24 | 25 | public SampleIcon getIcon() { 26 | return icon; 27 | } 28 | 29 | public String getTitle() { 30 | return title; 31 | } 32 | 33 | public String getDescription() { 34 | return description; 35 | } 36 | 37 | public JComponent createInstance(Dimension size) { 38 | try { 39 | JComponent view = (JComponent) sampleClass.newInstance(); 40 | if (view instanceof MapView) { 41 | ((MapView) view).setMapSize(size); 42 | } 43 | return view; 44 | } catch (Exception e) { 45 | return null; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/SampleIcon.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.demo; 6 | 7 | import javax.swing.*; 8 | import java.awt.*; 9 | import java.awt.image.ImageObserver; 10 | import java.lang.reflect.Field; 11 | import java.net.URL; 12 | 13 | class SampleIcon extends ImageIcon { 14 | 15 | static final boolean isRetinaDisplay = isRetinaDisplay(); 16 | 17 | public static boolean isRetina() { 18 | return isRetinaDisplay; 19 | } 20 | 21 | private static boolean isRetinaDisplay() { 22 | boolean isRetina = false; 23 | GraphicsDevice graphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); 24 | 25 | try { 26 | Field field = graphicsDevice.getClass().getDeclaredField("scale"); 27 | if (field != null) { 28 | field.setAccessible(true); 29 | Object scale = field.get(graphicsDevice); 30 | if (scale instanceof Integer && (Integer) scale == 2) { 31 | isRetina = true; 32 | } 33 | } 34 | } catch (Exception e) { 35 | return false; 36 | } 37 | return isRetina; 38 | } 39 | 40 | public SampleIcon(URL resource) { 41 | super(resource); 42 | } 43 | 44 | @Override 45 | public int getIconWidth() { 46 | return isRetinaDisplay ? (super.getIconWidth() / 2) : super.getIconWidth(); 47 | } 48 | 49 | @Override 50 | public int getIconHeight() { 51 | return isRetinaDisplay ? (super.getIconHeight() / 2) : super.getIconHeight(); 52 | } 53 | 54 | public synchronized void paintIcon(Component c, Graphics g, int x, int y) { 55 | 56 | ImageObserver observer = getImageObserver(); 57 | 58 | Image image = getImage(); 59 | int width = image.getWidth(observer); 60 | int height = image.getHeight(observer); 61 | final Graphics2D g2d = (Graphics2D) g.create(x, y, width, height); 62 | 63 | if (isRetinaDisplay) { 64 | g2d.scale(0.5, 0.5); 65 | } 66 | 67 | g2d.drawImage(image, 0, 0, observer); 68 | g2d.scale(1, 1); 69 | g2d.dispose(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/Shadow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.demo; 6 | 7 | import javax.swing.border.AbstractBorder; 8 | import java.awt.*; 9 | 10 | class Shadow extends AbstractBorder { 11 | final private int shadowSize; 12 | 13 | public Shadow(int shadowSize) { 14 | this.shadowSize = shadowSize; 15 | } 16 | 17 | @Override 18 | public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { 19 | if (g instanceof Graphics2D) { 20 | Graphics2D g2d = (Graphics2D) g; 21 | g2d.setColor(new Color(239, 239, 239)); 22 | Composite composite = g2d.getComposite(); 23 | try { 24 | for (int i = 0; i < shadowSize; i++) { 25 | float alpha = 1f / (float) (i * 2 + 1); 26 | g2d.setComposite(AlphaComposite.SrcOver.derive(alpha)); 27 | int yPosition = height - shadowSize + i; 28 | g.drawLine(0, yPosition, width, yPosition); 29 | } 30 | } finally { 31 | g2d.setComposite(composite); 32 | } 33 | } 34 | } 35 | 36 | @Override 37 | public Insets getBorderInsets(Component c) { 38 | return new Insets(0, 0, shadowSize, 0); 39 | } 40 | 41 | @Override 42 | public Insets getBorderInsets(Component c, Insets insets) { 43 | insets.bottom = shadowSize; 44 | return insets; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/Roboto-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/Roboto-Bold.ttf -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/Roboto-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/Roboto-Light.ttf -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/Roboto-Medium.ttf -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/Roboto-Regular.ttf -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/Roboto-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/Roboto-Thin.ttf -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/close.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/close_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/close_black.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/close_black_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/close_black_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/close_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/close_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_chat_bubble_outline_black_24dp_1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_chat_bubble_outline_black_24dp_1x.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_directions_black_24dp_1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_directions_black_24dp_1x.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_directions_sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_directions_sample.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_directions_sample_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_directions_sample_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_elevation_sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_elevation_sample.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_elevation_sample_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_elevation_sample_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_events_sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_events_sample.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_events_sample_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_events_sample_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_geocoding_sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_geocoding_sample.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_geocoding_sample_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_geocoding_sample_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_infowindow_sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_infowindow_sample.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_infowindow_sample_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_infowindow_sample_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_language_black_24dp_1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_language_black_24dp_1x.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_location_on_black_24dp_1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_location_on_black_24dp_1x.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_markers_sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_markers_sample.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_markers_sample_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_markers_sample_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_options_sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_options_sample.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_options_sample_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_options_sample_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_places_sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_places_sample.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_places_sample_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_places_sample_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_polygon_sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_polygon_sample.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_polygon_sample_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_polygon_sample_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_polyline_sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_polyline_sample.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_polyline_sample_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_polyline_sample_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_settings_black_24dp_1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_settings_black_24dp_1x.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_simple_sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_simple_sample.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_simple_sample_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_simple_sample_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_streetview_black_24dp_1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_streetview_black_24dp_1x.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_streetview_sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_streetview_sample.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_streetview_sample_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_streetview_sample_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_styled_sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_styled_sample.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_styled_sample_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_styled_sample_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_traffic_sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_traffic_sample.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/ic_traffic_sample_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/ic_traffic_sample_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/jxmaps16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/jxmaps16x16.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/jxmaps256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/jxmaps256x256.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/jxmaps32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/jxmaps32x32.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/menu-background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/menu-background.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/menu-background_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/menu-background_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/menu.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/demo/res/menu_retina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/demo/res/menu_retina.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/ControlPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import javax.swing.*; 8 | 9 | public interface ControlPanel { 10 | JComponent getControlPanel(); 11 | 12 | void configureControlPanel(); 13 | 14 | int getPreferredHeight(); 15 | } 16 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/DirectionsExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import com.teamdev.jxmaps.ControlPosition; 8 | import com.teamdev.jxmaps.DirectionsRequest; 9 | import com.teamdev.jxmaps.DirectionsResult; 10 | import com.teamdev.jxmaps.DirectionsRouteCallback; 11 | import com.teamdev.jxmaps.DirectionsStatus; 12 | import com.teamdev.jxmaps.LatLng; 13 | import com.teamdev.jxmaps.Map; 14 | import com.teamdev.jxmaps.MapOptions; 15 | import com.teamdev.jxmaps.MapReadyHandler; 16 | import com.teamdev.jxmaps.MapStatus; 17 | import com.teamdev.jxmaps.MapTypeControlOptions; 18 | import com.teamdev.jxmaps.TravelMode; 19 | import com.teamdev.jxmaps.swing.MapView; 20 | 21 | import javax.swing.*; 22 | import javax.swing.border.AbstractBorder; 23 | import java.awt.*; 24 | import java.awt.event.ActionEvent; 25 | import java.awt.event.ActionListener; 26 | import java.awt.event.MouseAdapter; 27 | import java.awt.event.MouseEvent; 28 | 29 | /** 30 | * This example demonstrates how to calculate a route between two locations. 31 | * 32 | * @author Vitaly Eremenko 33 | */ 34 | public class DirectionsExample extends MapView implements ControlPanel { 35 | 36 | private static final Color FOREGROUND_COLOR = new Color(0xBB, 0xDE, 0xFB); 37 | 38 | private JTextField fromField; 39 | private JTextField toField; 40 | 41 | private JPanel controlPanel; 42 | 43 | public DirectionsExample() { 44 | controlPanel = new JPanel(); 45 | 46 | fromField = new JTextField("Chicago, il"); 47 | toField = new JTextField("Winona, az"); 48 | 49 | configureControlPanel(); 50 | 51 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 52 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 53 | setOnMapReadyHandler(new MapReadyHandler() { 54 | @Override 55 | public void onMapReady(MapStatus status) { 56 | // Check if the map is loaded correctly 57 | if (status == MapStatus.MAP_STATUS_OK) { 58 | // Getting the associated map object 59 | final Map map = getMap(); 60 | // Setting the map center 61 | map.setCenter(new LatLng(41.85, -87.65)); 62 | // Setting initial zoom value 63 | map.setZoom(7.0); 64 | // Creating a map options object 65 | MapOptions options = new MapOptions(); 66 | // Creating a map type control options object 67 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 68 | // Changing position of the map type control 69 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 70 | // Setting map type control options 71 | options.setMapTypeControlOptions(controlOptions); 72 | // Setting map options 73 | map.setOptions(options); 74 | 75 | calculateDirection(); 76 | } 77 | } 78 | }); 79 | } 80 | 81 | @Override 82 | public JComponent getControlPanel() { 83 | return controlPanel; 84 | } 85 | 86 | @Override 87 | public void configureControlPanel() { 88 | controlPanel.setBackground(Color.white); 89 | controlPanel.setLayout(new BorderLayout()); 90 | 91 | JPanel demoControlPanel = new JPanel(new GridBagLayout()); 92 | demoControlPanel.setBackground(new Color(61, 130, 248)); 93 | 94 | Font robotoPlain13 = new Font("Roboto", 0, 13); 95 | fromField.setForeground(FOREGROUND_COLOR); 96 | toField.setForeground(FOREGROUND_COLOR); 97 | 98 | fromField.setFont(robotoPlain13); 99 | toField.setFont(robotoPlain13); 100 | 101 | fromField.setOpaque(false); 102 | toField.setOpaque(false); 103 | 104 | fromField.setBorder(new UnderscoreBorder()); 105 | toField.setBorder(new UnderscoreBorder()); 106 | 107 | ActionListener listener = new ActionListener() { 108 | @Override 109 | public void actionPerformed(ActionEvent e) { 110 | calculateDirection(); 111 | } 112 | }; 113 | fromField.addActionListener(listener); 114 | toField.addActionListener(listener); 115 | 116 | JLabel fromIcon = new JLabel(new ImageIcon(DirectionsExample.class.getResource("res/from.png"))); 117 | JLabel dotsIcon = new JLabel(new ImageIcon(DirectionsExample.class.getResource("res/dots.png"))); 118 | JLabel toIcon = new JLabel(new ImageIcon(DirectionsExample.class.getResource("res/to.png"))); 119 | JLabel changeIcon = new JLabel(new ImageIcon(DirectionsExample.class.getResource("res/change.png"))); 120 | changeIcon.setToolTipText("Reverse starting point and destination"); 121 | changeIcon.setCursor(new Cursor(Cursor.HAND_CURSOR)); 122 | changeIcon.addMouseListener(new MouseAdapter() { 123 | @Override 124 | public void mouseClicked(MouseEvent e) { 125 | String from = fromField.getText(); 126 | String to = toField.getText(); 127 | fromField.setText(to); 128 | toField.setText(from); 129 | calculateDirection(); 130 | } 131 | }); 132 | 133 | demoControlPanel.add(fromIcon, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 134 | GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(22, 30, 0, 0), 0, 0)); 135 | demoControlPanel.add(dotsIcon, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 136 | GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 33, 0, 0), 0, 0)); 137 | demoControlPanel.add(toIcon, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, 138 | GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(6, 30, 25, 0), 0, 0)); 139 | 140 | demoControlPanel.add(fromField, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, 141 | GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(19, 22, 0, 0), 0, 0)); 142 | demoControlPanel.add(toField, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, 143 | GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(3, 22, 0, 0), 0, 0)); 144 | 145 | demoControlPanel.add(changeIcon, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, 146 | GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 22, 0, 22), 0, 0)); 147 | 148 | controlPanel.add(demoControlPanel, BorderLayout.NORTH); 149 | } 150 | 151 | @Override 152 | public int getPreferredHeight() { 153 | return 169; 154 | } 155 | 156 | class UnderscoreBorder extends AbstractBorder { 157 | @Override 158 | public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { 159 | g.setColor(FOREGROUND_COLOR); 160 | g.drawLine(0, height - 1, width, height - 1); 161 | } 162 | 163 | @Override 164 | public Insets getBorderInsets(Component c) { 165 | return new Insets(0, 0, 5, 0); 166 | } 167 | 168 | @Override 169 | public Insets getBorderInsets(Component c, Insets insets) { 170 | insets.bottom = 5; 171 | return insets; 172 | } 173 | } 174 | 175 | private void calculateDirection() { 176 | // Getting the associated map object 177 | final Map map = getMap(); 178 | // Creating a directions request 179 | DirectionsRequest request = new DirectionsRequest(); 180 | // Setting of the origin location to the request 181 | request.setOriginString(fromField.getText()); 182 | // Setting of the destination location to the request 183 | request.setDestinationString(toField.getText()); 184 | // Setting of the travel mode 185 | request.setTravelMode(TravelMode.DRIVING); 186 | // Calculating the route between locations 187 | getServices().getDirectionService().route(request, new DirectionsRouteCallback(map) { 188 | @Override 189 | public void onRoute(DirectionsResult result, DirectionsStatus status) { 190 | // Checking of the operation status 191 | if (status == DirectionsStatus.OK) { 192 | // Drawing the calculated route on the map 193 | map.getDirectionsRenderer().setDirections(result); 194 | } else { 195 | JOptionPane.showMessageDialog(DirectionsExample.this, "Error. Route cannot be calculated.\nPlease correct input data."); 196 | } 197 | } 198 | }); 199 | } 200 | 201 | private static void loadAndRegisterCustomFonts() { 202 | try { 203 | GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); 204 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, DirectionsExample.class.getResourceAsStream("res/Roboto-Bold.ttf"))); 205 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, DirectionsExample.class.getResourceAsStream("res/Roboto-Medium.ttf"))); 206 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, DirectionsExample.class.getResourceAsStream("res/Roboto-Regular.ttf"))); 207 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, DirectionsExample.class.getResourceAsStream("res/Roboto-Thin.ttf"))); 208 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, DirectionsExample.class.getResourceAsStream("res/Roboto-Light.ttf"))); 209 | } catch (Exception e) { 210 | throw new RuntimeException(e); 211 | } 212 | } 213 | 214 | public static void main(String[] args) { 215 | loadAndRegisterCustomFonts(); 216 | 217 | JFrame frame = new JFrame("Directions"); 218 | final DirectionsExample sample = new DirectionsExample(); 219 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 220 | frame.add(sample, BorderLayout.CENTER); 221 | frame.setSize(700, 500); 222 | frame.setLocationRelativeTo(null); 223 | frame.setVisible(true); 224 | 225 | new OptionsWindow(sample, new Dimension(300, 100)) { 226 | @Override 227 | public void initContent(JWindow contentWindow) { 228 | contentWindow.add(sample.controlPanel); 229 | } 230 | }; 231 | } 232 | } 233 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/EditableTextControlPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | public interface EditableTextControlPanel extends ControlPanel { 8 | void onTextEntered(String value); 9 | 10 | String getInitialText(); 11 | } 12 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/ElevationExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import com.teamdev.jxmaps.ControlPosition; 8 | import com.teamdev.jxmaps.ElevationCallback; 9 | import com.teamdev.jxmaps.ElevationResult; 10 | import com.teamdev.jxmaps.ElevationService; 11 | import com.teamdev.jxmaps.ElevationStatus; 12 | import com.teamdev.jxmaps.InfoWindow; 13 | import com.teamdev.jxmaps.LatLng; 14 | import com.teamdev.jxmaps.LocationElevationRequest; 15 | import com.teamdev.jxmaps.Map; 16 | import com.teamdev.jxmaps.MapMouseEvent; 17 | import com.teamdev.jxmaps.MapOptions; 18 | import com.teamdev.jxmaps.MapReadyHandler; 19 | import com.teamdev.jxmaps.MapStatus; 20 | import com.teamdev.jxmaps.MapTypeControlOptions; 21 | import com.teamdev.jxmaps.MapTypeId; 22 | import com.teamdev.jxmaps.MouseEvent; 23 | import com.teamdev.jxmaps.swing.MapView; 24 | 25 | import javax.swing.*; 26 | import java.awt.*; 27 | 28 | /** 29 | * This example demonstrates how to calculate elevation by location. 30 | * 31 | * @author Vitaly Eremenko 32 | */ 33 | public class ElevationExample extends MapView { 34 | 35 | InfoWindow infoWindow; 36 | 37 | public ElevationExample() { 38 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 39 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 40 | setOnMapReadyHandler(new MapReadyHandler() { 41 | @Override 42 | public void onMapReady(MapStatus status) { 43 | // Check if the map is loaded correctly 44 | if (status == MapStatus.MAP_STATUS_OK) { 45 | // Getting the associated map object 46 | final Map map = getMap(); 47 | // Setting the map center 48 | map.setCenter(new LatLng(60.85026, -147.57934999999998)); 49 | // Setting initial zoom value 50 | map.setZoom(7.0); 51 | // Setting initial map type 52 | map.setMapTypeId(MapTypeId.HYBRID); 53 | // Creating a map options object 54 | MapOptions options = new MapOptions(); 55 | // Creating a map type control options object 56 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 57 | // Changing position of the map type control 58 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 59 | // Setting map type control options 60 | options.setMapTypeControlOptions(controlOptions); 61 | // Setting map options 62 | map.setOptions(options); 63 | 64 | showElevationInfo(map, map.getCenter(), true); 65 | 66 | // Adding of event listener to the click event 67 | map.addEventListener("click", new MapMouseEvent() { 68 | @Override 69 | public void onEvent(final MouseEvent mouseEvent) { 70 | showElevationInfo(map, mouseEvent.latLng(), false); 71 | } 72 | }); 73 | } 74 | } 75 | }); 76 | } 77 | 78 | private void showElevationInfo(final Map map, final LatLng latLng, final boolean initial) { 79 | // Getting the elevation service instance 80 | final ElevationService elevationService = getServices().getElevationService(); 81 | 82 | // Checking if info window has already opened 83 | if (infoWindow != null) { 84 | // Close info window 85 | infoWindow.close(); 86 | } 87 | 88 | // Creating an elevation request 89 | LocationElevationRequest request = new LocationElevationRequest(); 90 | LatLng[] locations = {latLng}; 91 | // Setting location to the elevation request 92 | request.setLocations(locations); 93 | 94 | // Evaluating of the elevation for a location 95 | elevationService.getElevationForLocations(request, new ElevationCallback(map) { 96 | @Override 97 | public void onComplete(ElevationResult[] result, ElevationStatus status) { 98 | // Checking operation status 99 | if (status == ElevationStatus.OK) { 100 | // Creating an info window 101 | infoWindow = new InfoWindow(map); 102 | String content = "The elevation at this point is " + (int) result[0].getElevation() + " meters. "; 103 | if (initial) 104 | content += "

Click anywhere on the map to get the elevation data at that point."; 105 | // Setting content of the info window 106 | infoWindow.setContent(content); 107 | // Moving the info window to the source location 108 | infoWindow.setPosition(latLng); 109 | // Showing the info window 110 | infoWindow.open(map); 111 | } 112 | } 113 | }); 114 | } 115 | 116 | public static void main(String[] args) { 117 | final ElevationExample sample = new ElevationExample(); 118 | 119 | JFrame frame = new JFrame("Elevation"); 120 | 121 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 122 | frame.add(sample, BorderLayout.CENTER); 123 | frame.setSize(700, 500); 124 | frame.setLocationRelativeTo(null); 125 | frame.setVisible(true); 126 | } 127 | 128 | } 129 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/EventsExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import com.teamdev.jxmaps.*; 8 | import com.teamdev.jxmaps.swing.MapView; 9 | 10 | import javax.swing.*; 11 | import java.awt.*; 12 | import java.awt.event.ActionEvent; 13 | import java.awt.event.ActionListener; 14 | 15 | /** 16 | * This example demonstrates how to process MAP_EVENTS from map. 17 | * 18 | * @author Vitaly Eremenko 19 | * @author Sergei Piletsky 20 | */ 21 | public class EventsExample extends JComponent implements ControlPanel { 22 | 23 | private static final Color SELECTION_COLOR = new Color(0x99, 0xCC, 0xFF); 24 | private static final Color BACKGROUND_COLOR = Color.white; 25 | private static final Color FOREGROUND_COLOR = new Color(0x21, 0x21, 0x21); 26 | 27 | static class MapEvent extends JLabel { 28 | private static final double PI2 = Math.PI / 2; 29 | private static final double STEP = 0.1; 30 | private final Timer updateTimer; 31 | private double transparency; 32 | private double x; 33 | 34 | public MapEvent(String name) { 35 | setText(name); 36 | 37 | updateTimer = new Timer(50, new ActionListener() { 38 | @Override 39 | public void actionPerformed(ActionEvent e) { 40 | transparency = Math.cos(x); 41 | x += STEP; 42 | if (x > PI2) { 43 | transparency = 0.0f; 44 | Timer source = (Timer) e.getSource(); 45 | source.stop(); 46 | } 47 | repaint(); 48 | } 49 | }); 50 | } 51 | 52 | void highlight() { 53 | x = -PI2; 54 | if (updateTimer.isRunning()) { 55 | updateTimer.restart(); 56 | } else { 57 | updateTimer.start(); 58 | } 59 | } 60 | 61 | @Override 62 | protected void paintComponent(Graphics g) { 63 | if (g instanceof Graphics2D) { 64 | Graphics2D g2d = (Graphics2D) g; 65 | 66 | Composite composite = g2d.getComposite(); 67 | try { 68 | g2d.setComposite(AlphaComposite.SrcOver.derive((float) transparency)); 69 | g2d.setColor(getBackground()); 70 | g2d.fillRect(0, 0, getWidth(), getHeight()); 71 | } finally { 72 | g2d.setComposite(composite); 73 | } 74 | } 75 | super.paintComponent(g); 76 | } 77 | } 78 | 79 | private static final MapEvent[] MAP_EVENTS = new MapEvent[]{ 80 | new MapEvent("bounds_changed"), 81 | new MapEvent("center_changed"), 82 | new MapEvent("click"), 83 | new MapEvent("dblclick"), 84 | new MapEvent("drag"), 85 | new MapEvent("dragend"), 86 | new MapEvent("dragstart"), 87 | new MapEvent("heading_changed"), 88 | new MapEvent("idle"), 89 | new MapEvent("maptypeid_changed"), 90 | new MapEvent("mousemove"), 91 | new MapEvent("mouseout"), 92 | new MapEvent("mouseover"), 93 | new MapEvent("projection_changed"), 94 | new MapEvent("resize"), 95 | new MapEvent("rightclick"), 96 | new MapEvent("tilesloaded"), 97 | new MapEvent("tilt_changed"), 98 | new MapEvent("zoom_changed"), 99 | }; 100 | 101 | private final MapView mapView = new MapView(); 102 | private final JComponent controlPanel; 103 | 104 | public EventsExample() { 105 | setLayout(new BorderLayout()); 106 | add(mapView, BorderLayout.CENTER); 107 | 108 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 109 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 110 | mapView.setOnMapReadyHandler(new MapReadyHandler() { 111 | @Override 112 | public void onMapReady(MapStatus status) { 113 | // Check if the map is loaded correctly 114 | if (status == MapStatus.MAP_STATUS_OK) { 115 | // Getting the associated map object 116 | final Map map = mapView.getMap(); 117 | // Setting the map center 118 | map.setCenter(new LatLng(-25.363, 131.044)); 119 | // Setting initial zoom value 120 | map.setZoom(4.0); 121 | // Creating a map options object 122 | MapOptions options = new MapOptions(); 123 | // Creating a map type control options object 124 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 125 | // Changing position of the map type control 126 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 127 | // Setting map type control options 128 | options.setMapTypeControlOptions(controlOptions); 129 | // Setting map options 130 | map.setOptions(options); 131 | 132 | for (final MapEvent event : MAP_EVENTS) { 133 | // Registering event listener for each event. 134 | map.addEventListener(event.getText(), new com.teamdev.jxmaps.MapEvent() { 135 | // onEvent is called when event with event is fired 136 | @Override 137 | public void onEvent() { 138 | event.highlight(); 139 | } 140 | }); 141 | } 142 | } 143 | } 144 | }); 145 | 146 | controlPanel = new JPanel(new GridBagLayout()); 147 | controlPanel.setBackground(BACKGROUND_COLOR); 148 | int row = 0; 149 | for (MapEvent mapEvent : MAP_EVENTS) { 150 | mapEvent.setForeground(FOREGROUND_COLOR); 151 | mapEvent.setBackground(SELECTION_COLOR); 152 | mapEvent.setFont(new Font(Font.MONOSPACED, 0, 15)); 153 | 154 | controlPanel.add(mapEvent, new GridBagConstraints(0, row++, 1, 1, 1.0, 0.0, 155 | GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); 156 | } 157 | controlPanel.add(Box.createVerticalBox(), new GridBagConstraints(0, row, 1, 1, 1.0, 1.0, 158 | GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); 159 | } 160 | 161 | @Override 162 | public void configureControlPanel() { 163 | final Font monospaced15 = new Font(Font.MONOSPACED, 0, 15); 164 | 165 | controlPanel.removeAll(); 166 | int row = 0; 167 | for (MapEvent mapEvent : MAP_EVENTS) { 168 | mapEvent.setFont(monospaced15); 169 | mapEvent.setForeground(FOREGROUND_COLOR); 170 | mapEvent.setBackground(SELECTION_COLOR); 171 | mapEvent.setBorder(BorderFactory.createEmptyBorder(5, 65, 5, 5)); 172 | 173 | controlPanel.add(mapEvent, new GridBagConstraints(0, row++, 1, 1, 1.0, 0.0, 174 | GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0)); 175 | } 176 | controlPanel.add(Box.createVerticalBox(), new GridBagConstraints(0, row, 1, 1, 1.0, 1.0, 177 | GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); 178 | } 179 | 180 | @Override 181 | public JComponent getControlPanel() { 182 | return controlPanel; 183 | } 184 | 185 | @Override 186 | public int getPreferredHeight() { 187 | return getHeight(); 188 | } 189 | 190 | private void configureView() { 191 | add(controlPanel, BorderLayout.EAST); 192 | } 193 | 194 | private static void loadAndRegisterCustomFonts() { 195 | try { 196 | GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); 197 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, EventsExample.class.getResourceAsStream("res/Roboto-Bold.ttf"))); 198 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, EventsExample.class.getResourceAsStream("res/Roboto-Medium.ttf"))); 199 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, EventsExample.class.getResourceAsStream("res/Roboto-Regular.ttf"))); 200 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, EventsExample.class.getResourceAsStream("res/Roboto-Thin.ttf"))); 201 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, EventsExample.class.getResourceAsStream("res/Roboto-Light.ttf"))); 202 | } catch (Exception e) { 203 | throw new RuntimeException(e); 204 | } 205 | } 206 | 207 | public static void main(String[] args) { 208 | loadAndRegisterCustomFonts(); 209 | 210 | EventsExample eventsExample = new EventsExample(); 211 | eventsExample.configureView(); 212 | JFrame frame = new JFrame("Events"); 213 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 214 | frame.add(eventsExample, BorderLayout.CENTER); 215 | frame.setSize(700, 600); 216 | frame.setLocationRelativeTo(null); 217 | frame.setVisible(true); 218 | } 219 | } 220 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/FXMLExample.java: -------------------------------------------------------------------------------- 1 | package com.teamdev.jxmaps.examples; 2 | 3 | /* 4 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 5 | * Use is subject to Apache 2.0 license terms. 6 | */ 7 | 8 | import com.teamdev.jxmaps.javafx.MapView; 9 | import javafx.application.Application; 10 | import javafx.fxml.FXMLLoader; 11 | import javafx.scene.Scene; 12 | import javafx.scene.layout.BorderPane; 13 | import javafx.stage.Stage; 14 | 15 | import java.io.IOException; 16 | 17 | 18 | /** 19 | * This example demonstrates how to create a MapView instance, 20 | * display it in JavaFX application and open a simple map. 21 | * 22 | * @author Vitaly Eremenko 23 | */ 24 | public class FXMLExample extends Application { 25 | 26 | @Override 27 | public void init() throws Exception { 28 | // Initializing of JavaFX engine 29 | MapView.InitJavaFX(); 30 | } 31 | 32 | 33 | @Override 34 | public void start(final Stage primaryStage) throws IOException { 35 | 36 | BorderPane pane = FXMLLoader.load(getClass().getResource("res/main.fxml")); 37 | 38 | primaryStage.setTitle("FXMLSample"); 39 | primaryStage.setScene(new Scene(pane, 800, 600)); 40 | primaryStage.show(); 41 | 42 | } 43 | 44 | public static void main(String[] args) { 45 | launch(args); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/GeocoderExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import com.teamdev.jxmaps.ControlPosition; 8 | import com.teamdev.jxmaps.GeocoderCallback; 9 | import com.teamdev.jxmaps.GeocoderRequest; 10 | import com.teamdev.jxmaps.GeocoderResult; 11 | import com.teamdev.jxmaps.GeocoderStatus; 12 | import com.teamdev.jxmaps.InfoWindow; 13 | import com.teamdev.jxmaps.LatLng; 14 | import com.teamdev.jxmaps.Map; 15 | import com.teamdev.jxmaps.MapOptions; 16 | import com.teamdev.jxmaps.MapReadyHandler; 17 | import com.teamdev.jxmaps.MapStatus; 18 | import com.teamdev.jxmaps.MapTypeControlOptions; 19 | import com.teamdev.jxmaps.Marker; 20 | import com.teamdev.jxmaps.swing.MapView; 21 | 22 | import javax.swing.*; 23 | import javax.swing.plaf.basic.BasicButtonUI; 24 | import javax.swing.plaf.basic.BasicTextFieldUI; 25 | import java.awt.*; 26 | import java.awt.Point; 27 | import java.awt.event.ActionEvent; 28 | import java.awt.event.ActionListener; 29 | 30 | /** 31 | * This example demonstrates how to geocode coordinates by an address and vice versa. 32 | * 33 | * @author Vitaly Eremenko 34 | * @author Sergei Piletsky 35 | */ 36 | public class GeocoderExample extends MapView { 37 | 38 | private static final String INITIAL_LOCATION = "Beijing"; 39 | 40 | private OptionsWindow optionsWindow; 41 | 42 | public GeocoderExample() { 43 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 44 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 45 | setOnMapReadyHandler(new MapReadyHandler() { 46 | @Override 47 | public void onMapReady(MapStatus status) { 48 | // Getting the associated map object 49 | final Map map = getMap(); 50 | // Setting initial zoom value 51 | map.setZoom(7.0); 52 | // Creating a map options object 53 | MapOptions options = new MapOptions(); 54 | // Creating a map type control options object 55 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 56 | // Changing position of the map type control 57 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 58 | // Setting map type control options 59 | options.setMapTypeControlOptions(controlOptions); 60 | // Setting map options 61 | map.setOptions(options); 62 | 63 | performGeocode(INITIAL_LOCATION); 64 | } 65 | }); 66 | } 67 | 68 | @Override 69 | public void addNotify() { 70 | super.addNotify(); 71 | 72 | optionsWindow = new OptionsWindow(this, new Dimension(350, 40)) { 73 | @Override 74 | public void initContent(JWindow contentWindow) { 75 | JPanel content = new JPanel(new GridBagLayout()); 76 | content.setBackground(Color.white); 77 | 78 | Font robotoPlain13 = new Font("Roboto", 0, 13); 79 | final JTextField searchField = new JTextField(); 80 | searchField.setText(INITIAL_LOCATION); 81 | searchField.setToolTipText("Enter address or coordinates..."); 82 | searchField.setBorder(BorderFactory.createEmptyBorder()); 83 | searchField.setFont(robotoPlain13); 84 | searchField.setForeground(new Color(0x21, 0x21, 0x21)); 85 | searchField.setUI(new SearchFieldUI(searchField)); 86 | 87 | final JButton searchButton = new JButton(); 88 | searchButton.setIcon(new ImageIcon(MapOptionsExample.class.getResource("res/search.png"))); 89 | searchButton.setRolloverIcon(new ImageIcon(MapOptionsExample.class.getResource("res/search_hover.png"))); 90 | searchButton.setBorder(BorderFactory.createEmptyBorder()); 91 | searchButton.setUI(new BasicButtonUI()); 92 | searchButton.setOpaque(false); 93 | ActionListener searchActionListener = new ActionListener() { 94 | @Override 95 | public void actionPerformed(ActionEvent e) { 96 | performGeocode(searchField.getText()); 97 | } 98 | }; 99 | searchButton.addActionListener(searchActionListener); 100 | searchField.addActionListener(searchActionListener); 101 | 102 | content.add(searchField, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, 103 | GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(11, 11, 11, 0), 0, 0)); 104 | content.add(searchButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, 105 | GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(11, 0, 11, 11), 0, 0)); 106 | 107 | contentWindow.getContentPane().add(content); 108 | } 109 | 110 | @Override 111 | protected void updatePosition() { 112 | if (parentFrame.isVisible()) { 113 | Point newLocation = parentFrame.getContentPane().getLocationOnScreen(); 114 | newLocation.translate(56, 11); 115 | contentWindow.setLocation(newLocation); 116 | contentWindow.setSize(340, 40); 117 | } 118 | } 119 | }; 120 | } 121 | 122 | class SearchFieldUI extends BasicTextFieldUI { 123 | private final JTextField textField; 124 | 125 | public SearchFieldUI(JTextField textField) { 126 | this.textField = textField; 127 | } 128 | 129 | @Override 130 | protected void paintBackground(Graphics g) { 131 | super.paintBackground(g); 132 | String toolTipText = textField.getToolTipText(); 133 | String text = textField.getText(); 134 | if (toolTipText != null && text.isEmpty()) { 135 | paintPlaceholderText(g, textField); 136 | } 137 | } 138 | 139 | protected void paintPlaceholderText(Graphics g, JComponent c) { 140 | g.setColor(new Color(0x75, 0x75, 0x75)); 141 | g.setFont(c.getFont()); 142 | String text = textField.getToolTipText(); 143 | if (g instanceof Graphics2D) { 144 | Graphics2D graphics2D = (Graphics2D) g; 145 | graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 146 | } 147 | g.drawString(text, 0, 14); 148 | } 149 | } 150 | 151 | @Override 152 | public void removeNotify() { 153 | super.removeNotify(); 154 | optionsWindow.dispose(); 155 | } 156 | 157 | private void performGeocode(String text) { 158 | // Getting the associated map object 159 | final Map map = getMap(); 160 | // Creating a geocode request 161 | GeocoderRequest request = new GeocoderRequest(); 162 | // Setting address to the geocode request 163 | request.setAddress(text); 164 | 165 | // Geocoding position by the entered address 166 | getServices().getGeocoder().geocode(request, new GeocoderCallback(map) { 167 | @Override 168 | public void onComplete(GeocoderResult[] results, GeocoderStatus status) { 169 | // Checking operation status 170 | if ((status == GeocoderStatus.OK) && (results.length > 0)) { 171 | // Getting the first result 172 | GeocoderResult result = results[0]; 173 | // Getting a location of the result 174 | LatLng location = result.getGeometry().getLocation(); 175 | // Setting the map center to result location 176 | map.setCenter(location); 177 | // Creating a marker object 178 | Marker marker = new Marker(map); 179 | // Setting position of the marker to the result location 180 | marker.setPosition(location); 181 | // Creating an information window 182 | InfoWindow infoWindow = new InfoWindow(map); 183 | // Putting the address and location to the content of the information window 184 | infoWindow.setContent("" + result.getFormattedAddress() + "
" + location.toString()); 185 | // Moving the information window to the result location 186 | infoWindow.setPosition(location); 187 | // Showing of the information window 188 | infoWindow.open(map, marker); 189 | } 190 | } 191 | }); 192 | } 193 | 194 | 195 | public static void main(String[] args) { 196 | final GeocoderExample mapView = new GeocoderExample(); 197 | 198 | JFrame frame = new JFrame("Geocoder"); 199 | 200 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 201 | frame.add(mapView, BorderLayout.CENTER); 202 | frame.setSize(700, 500); 203 | frame.setLocationRelativeTo(null); 204 | frame.setVisible(true); 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/InfoWindowExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import com.teamdev.jxmaps.ControlPosition; 8 | import com.teamdev.jxmaps.InfoWindow; 9 | import com.teamdev.jxmaps.LatLng; 10 | import com.teamdev.jxmaps.Map; 11 | import com.teamdev.jxmaps.MapOptions; 12 | import com.teamdev.jxmaps.MapReadyHandler; 13 | import com.teamdev.jxmaps.MapStatus; 14 | import com.teamdev.jxmaps.MapTypeControlOptions; 15 | import com.teamdev.jxmaps.Marker; 16 | import com.teamdev.jxmaps.swing.MapView; 17 | import javax.swing.*; 18 | import javax.xml.bind.DatatypeConverter; 19 | import java.awt.*; 20 | import java.io.ByteArrayOutputStream; 21 | import java.io.InputStream; 22 | 23 | /** 24 | * This example demonstrates how to display info windows on the map. 25 | * 26 | * @author Vitaly Eremenko 27 | */ 28 | public class InfoWindowExample extends MapView { 29 | 30 | private static String convertImageStreamToString(InputStream is) { 31 | String result; 32 | try { 33 | ByteArrayOutputStream buffer = new ByteArrayOutputStream(); 34 | int nRead; 35 | byte[] data = new byte[10240]; 36 | while ((nRead = is.read(data, 0, data.length)) != -1) { 37 | buffer.write(data, 0, nRead); 38 | } 39 | buffer.flush(); 40 | result = "data:image/png;base64," + DatatypeConverter.printBase64Binary(buffer.toByteArray()); 41 | } catch (Exception e) { 42 | throw new RuntimeException(e); 43 | } 44 | return result; 45 | } 46 | 47 | private static String getBase64ImageString() { 48 | InputStream is = GeocoderExample.class.getResourceAsStream("res/Paris.png"); 49 | return convertImageStreamToString(is); 50 | } 51 | 52 | private final static String contentString = "

Paris

" + 53 | "

Paris is the home of the most visited art museum in the world.

" + 54 | "

Use InfoWindow to display custom information, related to a point on a map. InfoWindow layout can be formatted using HTML.

" + 55 | "
"; 56 | 57 | 58 | public InfoWindowExample() { 59 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 60 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 61 | setOnMapReadyHandler(new MapReadyHandler() { 62 | @Override 63 | public void onMapReady(MapStatus status) { 64 | // Check if the map is loaded correctly 65 | if (status == MapStatus.MAP_STATUS_OK) { 66 | // Getting the associated map object 67 | final Map map = getMap(); 68 | // Setting the map center 69 | map.setCenter(new LatLng(48.856614, 2.3522219000000177)); 70 | // Setting initial zoom value 71 | map.setZoom(7.0); 72 | // Creating a map options object 73 | MapOptions options = new MapOptions(); 74 | // Creating a map type control options object 75 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 76 | // Changing position of the map type control 77 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 78 | // Setting map type control options 79 | options.setMapTypeControlOptions(controlOptions); 80 | // Setting map options 81 | map.setOptions(options); 82 | // Creating a marker object 83 | final Marker marker = new Marker(map); 84 | // Moving marker to the map center 85 | marker.setPosition(map.getCenter()); 86 | // Creating an information window 87 | final InfoWindow window = new InfoWindow(map); 88 | // Setting html content to the information window 89 | window.setContent(contentString); 90 | // Showing the information window on marker 91 | window.open(map, marker); 92 | } 93 | } 94 | }); 95 | 96 | } 97 | 98 | public static void main(String[] args) { 99 | final InfoWindowExample sample = new InfoWindowExample(); 100 | 101 | JFrame frame = new JFrame("Info window"); 102 | 103 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 104 | frame.add(sample, BorderLayout.CENTER); 105 | frame.setSize(700, 500); 106 | frame.setLocationRelativeTo(null); 107 | frame.setVisible(true); 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/JavaFXExample.java: -------------------------------------------------------------------------------- 1 | package com.teamdev.jxmaps.examples; 2 | 3 | /* 4 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 5 | * Use is subject to Apache 2.0 license terms. 6 | */ 7 | 8 | import com.teamdev.jxmaps.ControlPosition; 9 | import com.teamdev.jxmaps.LatLng; 10 | import com.teamdev.jxmaps.Map; 11 | import com.teamdev.jxmaps.MapOptions; 12 | import com.teamdev.jxmaps.MapReadyHandler; 13 | import com.teamdev.jxmaps.MapStatus; 14 | import com.teamdev.jxmaps.MapTypeControlOptions; 15 | import com.teamdev.jxmaps.javafx.MapView; 16 | import javafx.application.Application; 17 | import javafx.scene.Scene; 18 | import javafx.scene.layout.BorderPane; 19 | import javafx.stage.Stage; 20 | 21 | 22 | /** 23 | * This example demonstrates how to create a MapView instance, 24 | * display it in JavaFX application and open a simple map. 25 | * 26 | * @author Vitaly Eremenko 27 | */ 28 | public class JavaFXExample extends Application { 29 | @Override 30 | public void init() throws Exception { 31 | // Initializing of JavaFX engine 32 | MapView.InitJavaFX(); 33 | } 34 | 35 | @Override 36 | public void start(final Stage primaryStage) { 37 | // Creation of a JavaFX map view 38 | final MapView mapView = new MapView(); 39 | 40 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 41 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 42 | mapView.setOnMapReadyHandler(new MapReadyHandler() { 43 | @Override 44 | public void onMapReady(MapStatus status) { 45 | // Check if the map is loaded correctly 46 | if (status == MapStatus.MAP_STATUS_OK) { 47 | // Getting the associated map object 48 | final Map map = mapView.getMap(); 49 | // Creating a map options object 50 | MapOptions options = new MapOptions(); 51 | // Creating a map type control options object 52 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 53 | // Changing position of the map type control 54 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 55 | // Setting map type control options 56 | options.setMapTypeControlOptions(controlOptions); 57 | // Setting map options 58 | map.setOptions(options); 59 | // Setting the map center 60 | map.setCenter(new LatLng(35.91466, 10.312499)); 61 | // Setting initial zoom value 62 | map.setZoom(2.0); 63 | } 64 | } 65 | }); 66 | 67 | Scene scene = new Scene(new BorderPane(mapView), 700, 500); 68 | primaryStage.setScene(scene); 69 | primaryStage.show(); 70 | } 71 | 72 | public static void main(String[] args) { 73 | launch(args); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/LightweightMapExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import com.teamdev.jxmaps.ControlPosition; 8 | import com.teamdev.jxmaps.LatLng; 9 | import com.teamdev.jxmaps.Map; 10 | import com.teamdev.jxmaps.MapComponentType; 11 | import com.teamdev.jxmaps.MapOptions; 12 | import com.teamdev.jxmaps.MapReadyHandler; 13 | import com.teamdev.jxmaps.MapStatus; 14 | import com.teamdev.jxmaps.MapTypeControlOptions; 15 | import com.teamdev.jxmaps.MapViewOptions; 16 | import com.teamdev.jxmaps.swing.MapView; 17 | 18 | import javax.swing.*; 19 | import java.awt.*; 20 | 21 | /** 22 | * This example demonstrates how to create a lightweight MapView instance, 23 | * display it in JFrame and open a simple map. 24 | * 25 | * @author Vitaly Eremenko 26 | */ 27 | public class LightweightMapExample extends MapView { 28 | public LightweightMapExample() { 29 | // Creation of MapViewer with specifying LIGHTWEIGHT mode 30 | super(new MapViewOptions(MapComponentType.LIGHTWEIGHT)); 31 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 32 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 33 | setOnMapReadyHandler(new MapReadyHandler() { 34 | @Override 35 | public void onMapReady(MapStatus status) { 36 | // Check if the map is loaded correctly 37 | if (status == MapStatus.MAP_STATUS_OK) { 38 | // Getting the associated map object 39 | final Map map = getMap(); 40 | // Creating a map options object 41 | MapOptions options = new MapOptions(); 42 | // Creating a map type control options object 43 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 44 | // Changing position of the map type control 45 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 46 | // Setting map type control options 47 | options.setMapTypeControlOptions(controlOptions); 48 | // Setting map options 49 | map.setOptions(options); 50 | // Setting the map center 51 | map.setCenter(new LatLng(35.91466, 10.312499)); 52 | // Setting initial zoom value 53 | map.setZoom(2.0); 54 | } 55 | } 56 | }); 57 | } 58 | 59 | public static void main(String[] args) { 60 | LightweightMapExample sample = new LightweightMapExample(); 61 | 62 | JFrame frame = new JFrame("Map Integration"); 63 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 64 | frame.add(sample, BorderLayout.CENTER); 65 | frame.setSize(700, 500); 66 | frame.setLocationRelativeTo(null); 67 | frame.setVisible(true); 68 | } 69 | } -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/MapExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import com.teamdev.jxmaps.Map; 8 | import com.teamdev.jxmaps.MapOptions; 9 | import com.teamdev.jxmaps.MapTypeControlOptions; 10 | import com.teamdev.jxmaps.MapReadyHandler; 11 | import com.teamdev.jxmaps.MapStatus; 12 | import com.teamdev.jxmaps.ControlPosition; 13 | import com.teamdev.jxmaps.LatLng; 14 | import com.teamdev.jxmaps.swing.MapView; 15 | import javax.swing.*; 16 | import java.awt.*; 17 | 18 | /** 19 | * This example demonstrates how to create a MapView instance, 20 | * display it in JFrame and open a simple map. 21 | * 22 | * @author Vitaly Eremenko 23 | */ 24 | public class MapExample extends MapView { 25 | public MapExample() { 26 | 27 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 28 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 29 | setOnMapReadyHandler(new MapReadyHandler() { 30 | @Override 31 | public void onMapReady(MapStatus status) { 32 | // Check if the map is loaded correctly 33 | if (status == MapStatus.MAP_STATUS_OK) { 34 | // Getting the associated map object 35 | final Map map = getMap(); 36 | // Creating a map options object 37 | MapOptions options = new MapOptions(); 38 | // Creating a map type control options object 39 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 40 | // Changing position of the map type control 41 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 42 | // Setting map type control options 43 | options.setMapTypeControlOptions(controlOptions); 44 | // Setting map options 45 | map.setOptions(options); 46 | // Setting the map center 47 | map.setCenter(new LatLng(35.91466, 10.312499)); 48 | // Setting initial zoom value 49 | map.setZoom(2.0); 50 | } 51 | } 52 | }); 53 | } 54 | 55 | public static void main(String[] args) { 56 | MapExample sample = new MapExample(); 57 | 58 | JFrame frame = new JFrame("Map Integration"); 59 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 60 | frame.add(sample, BorderLayout.CENTER); 61 | frame.setSize(700, 500); 62 | frame.setLocationRelativeTo(null); 63 | frame.setVisible(true); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/MapOptionsExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import com.teamdev.jxmaps.ControlPosition; 8 | import com.teamdev.jxmaps.LatLng; 9 | import com.teamdev.jxmaps.Map; 10 | import com.teamdev.jxmaps.MapOptions; 11 | import com.teamdev.jxmaps.MapReadyHandler; 12 | import com.teamdev.jxmaps.MapStatus; 13 | import com.teamdev.jxmaps.MapTypeControlOptions; 14 | import com.teamdev.jxmaps.ZoomControlOptions; 15 | import com.teamdev.jxmaps.ZoomControlStyle; 16 | import com.teamdev.jxmaps.swing.MapView; 17 | 18 | import javax.swing.*; 19 | import javax.swing.plaf.basic.BasicButtonUI; 20 | import java.awt.*; 21 | import java.awt.Rectangle; 22 | import java.awt.event.ActionEvent; 23 | import java.awt.event.ActionListener; 24 | 25 | /** 26 | * This example demonstrates how to customize a Map. 27 | * 28 | * @author Vitaly Eremenko 29 | * @author Sergey Piletsky 30 | */ 31 | public class MapOptionsExample extends MapView implements ControlPanel { 32 | private static final Color FOREGROUND_COLOR = new Color(0xBB, 0xDE, 0xFB); 33 | private static final Color FOREGROUND_COLOR_SELECTED = new Color(0xFE, 0xFE, 0xFE); 34 | 35 | private JPanel controlPanel; 36 | private JCheckBox defaultUiCheck; 37 | private JCheckBox dblClickCheck; 38 | private JCheckBox draggingCheck; 39 | private JCheckBox scrollWheelCheck; 40 | 41 | public MapOptionsExample() { 42 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 43 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 44 | setOnMapReadyHandler(new MapReadyHandler() { 45 | @Override 46 | public void onMapReady(MapStatus status) { 47 | // Check if the map is loaded correctly 48 | if (status == MapStatus.MAP_STATUS_OK) { 49 | // Initializing map 50 | initMap(getMap()); 51 | } 52 | } 53 | }); 54 | 55 | controlPanel = new JPanel(new GridLayout(4, 1)); 56 | 57 | defaultUiCheck = new JCheckBox("Show controls"); 58 | defaultUiCheck.setSelected(true); 59 | 60 | // Setting a handler on clicking "Show controls" checkbox 61 | defaultUiCheck.addActionListener(new ActionListener() { 62 | @Override 63 | public void actionPerformed(ActionEvent e) { 64 | // Getting current map options 65 | MapOptions options = new MapOptions(); 66 | // Updating visibility of the zoom control 67 | options.setZoomControl(defaultUiCheck.isSelected()); 68 | // Updating visibility of the map type control 69 | options.setMapTypeControl(defaultUiCheck.isSelected()); 70 | // Updating visibility of the street view control 71 | options.setStreetViewControl(defaultUiCheck.isSelected()); 72 | // Applying updated options 73 | getMap().setOptions(options); 74 | } 75 | }); 76 | 77 | dblClickCheck = new JCheckBox("Zoom on double click"); 78 | dblClickCheck.setSelected(true); 79 | 80 | // Setting a handler on clicking "Zoom on double click" checkbox 81 | dblClickCheck.addActionListener(new ActionListener() { 82 | @Override 83 | public void actionPerformed(ActionEvent e) { 84 | // Getting current map options 85 | MapOptions options = new MapOptions(); 86 | // Updating DisableDoubleClickZoom property value 87 | options.setDisableDoubleClickZoom(!dblClickCheck.isSelected()); 88 | // Applying updated options 89 | getMap().setOptions(options); 90 | } 91 | }); 92 | 93 | draggingCheck = new JCheckBox("Enable dragging"); 94 | draggingCheck.setSelected(true); 95 | 96 | // Setting a handler on clicking "Enable dragging" checkbox 97 | draggingCheck.addActionListener(new ActionListener() { 98 | @Override 99 | public void actionPerformed(ActionEvent e) { 100 | // Getting current map options 101 | MapOptions options = new MapOptions(); 102 | // Updating Draggable property value 103 | options.setDraggable(draggingCheck.isSelected()); 104 | // Applying updated options 105 | getMap().setOptions(options); 106 | } 107 | }); 108 | 109 | scrollWheelCheck = new JCheckBox("Enable ScrollWheel"); 110 | scrollWheelCheck.setSelected(true); 111 | 112 | // Setting a handler on clicking "Enable ScrollWheel" checkbox 113 | scrollWheelCheck.addActionListener(new ActionListener() { 114 | @Override 115 | public void actionPerformed(ActionEvent e) { 116 | // Getting current map options 117 | MapOptions options = new MapOptions(); 118 | // Updating the ScrollWheel property value 119 | options.setScrollWheel(scrollWheelCheck.isSelected()); 120 | // Applying updated options 121 | getMap().setOptions(options); 122 | } 123 | }); 124 | 125 | configureControlPanel(); 126 | } 127 | 128 | @Override 129 | public JComponent getControlPanel() { 130 | return controlPanel; 131 | } 132 | 133 | @Override 134 | public void configureControlPanel() { 135 | controlPanel.removeAll(); 136 | controlPanel.setBackground(Color.white); 137 | controlPanel.setLayout(new BorderLayout()); 138 | 139 | JPanel demoControlPanel = new JPanel(new GridBagLayout()); 140 | demoControlPanel.setBackground(new Color(61, 130, 248)); 141 | 142 | customizeCheckBox(defaultUiCheck); 143 | customizeCheckBox(dblClickCheck); 144 | customizeCheckBox(draggingCheck); 145 | customizeCheckBox(scrollWheelCheck); 146 | 147 | demoControlPanel.add(defaultUiCheck, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, 148 | GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(18, 8, 0, 0), 0, 0)); 149 | demoControlPanel.add(dblClickCheck, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, 150 | GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 8, 0, 0), 0, 0)); 151 | demoControlPanel.add(draggingCheck, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0, 152 | GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 8, 0, 0), 0, 0)); 153 | demoControlPanel.add(scrollWheelCheck, new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0, 154 | GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 8, 18, 0), 0, 0)); 155 | 156 | controlPanel.add(demoControlPanel, BorderLayout.NORTH); 157 | } 158 | 159 | @Override 160 | public int getPreferredHeight() { 161 | return 210; 162 | } 163 | 164 | private void customizeCheckBox(final JCheckBox checkBox) { 165 | Font robotoPlain13 = new Font("Roboto", 0, 13); 166 | checkBox.setUI(new BasicButtonUI() { 167 | @Override 168 | protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) { 169 | textRect.translate(28, 0); 170 | super.paintText(g, b, textRect, text); 171 | } 172 | }); 173 | checkBox.setFont(robotoPlain13); 174 | checkBox.setForeground(checkBox.isSelected()? FOREGROUND_COLOR_SELECTED : FOREGROUND_COLOR); 175 | checkBox.setOpaque(false); 176 | checkBox.setIcon(new ImageIcon(MapOptionsExample.class.getResource("res/checkbox_0.png"))); 177 | checkBox.setSelectedIcon(new ImageIcon(MapOptionsExample.class.getResource("res/checkbox_1.png"))); 178 | checkBox.addActionListener(new ActionListener() { 179 | @Override 180 | public void actionPerformed(ActionEvent e) { 181 | checkBox.setForeground(checkBox.isSelected()? FOREGROUND_COLOR_SELECTED : FOREGROUND_COLOR); 182 | } 183 | }); 184 | } 185 | 186 | private void initMap(Map map) { 187 | // Creating a map options object 188 | MapOptions options = new MapOptions(); 189 | // Setting visibility of the map type control 190 | options.setMapTypeControl(true); 191 | // Setting coordinates of the map center 192 | options.setCenter(new LatLng(34.0522342, -118.2436849)); // LA, ca 193 | // Setting visibility of the map type control 194 | options.setZoomControl(true); 195 | // Setting initial zoom value 196 | options.setZoom(9.0); 197 | // Creating a map type control options object 198 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 199 | // Changing position of the map type control 200 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 201 | // Setting the map type control options 202 | options.setMapTypeControlOptions(controlOptions); 203 | // Creating a zoom control options object 204 | ZoomControlOptions zoomOptions = new ZoomControlOptions(); 205 | // Changing position of the zoom control 206 | zoomOptions.setPosition(ControlPosition.LEFT_CENTER); 207 | // Changing the style of the zoom control 208 | zoomOptions.setStyle(ZoomControlStyle.LARGE); 209 | // Setting zoom control options 210 | options.setZoomControlOptions(zoomOptions); 211 | // Setting map options 212 | map.setOptions(options); 213 | 214 | dblClickCheck.doClick(); 215 | draggingCheck.doClick(); 216 | scrollWheelCheck.doClick(); 217 | controlPanel.revalidate(); 218 | controlPanel.repaint(); 219 | } 220 | 221 | private static void loadAndRegisterCustomFonts() { 222 | try { 223 | GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); 224 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, MapOptionsExample.class.getResourceAsStream("res/Roboto-Bold.ttf"))); 225 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, MapOptionsExample.class.getResourceAsStream("res/Roboto-Medium.ttf"))); 226 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, MapOptionsExample.class.getResourceAsStream("res/Roboto-Regular.ttf"))); 227 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, MapOptionsExample.class.getResourceAsStream("res/Roboto-Thin.ttf"))); 228 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, MapOptionsExample.class.getResourceAsStream("res/Roboto-Light.ttf"))); 229 | } catch (Exception e) { 230 | throw new RuntimeException(e); 231 | } 232 | } 233 | 234 | 235 | public static void main(String[] args) { 236 | loadAndRegisterCustomFonts(); 237 | 238 | JFrame frame = new JFrame("Map Options"); 239 | final MapOptionsExample sample = new MapOptionsExample(); 240 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 241 | frame.add(sample, BorderLayout.CENTER); 242 | frame.setSize(700, 500); 243 | frame.setLocationRelativeTo(null); 244 | frame.setVisible(true); 245 | 246 | OptionsWindow optionsWindow = new OptionsWindow(sample, new Dimension(300, 140)) { 247 | @Override 248 | public void initContent(JWindow contentWindow) { 249 | contentWindow.add(sample.controlPanel); 250 | } 251 | }; 252 | } 253 | } 254 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/MapViewFXControl.java: -------------------------------------------------------------------------------- 1 | package com.teamdev.jxmaps.examples; 2 | 3 | import com.teamdev.jxmaps.*; 4 | import com.teamdev.jxmaps.javafx.MapView; 5 | import javafx.fxml.FXML; 6 | import javafx.fxml.Initializable; 7 | 8 | import java.net.URL; 9 | import java.util.ResourceBundle; 10 | 11 | /** 12 | * Represents FXML control with MapViewer instance. 13 | */ 14 | public class MapViewFXControl implements Initializable { 15 | @FXML 16 | private MapView mapView; 17 | 18 | @Override 19 | public void initialize(URL location, ResourceBundle resources) { 20 | // Creation of a JavaFX map view 21 | //final MapView mapView = new MapView(); 22 | 23 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 24 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 25 | mapView.setOnMapReadyHandler(new MapReadyHandler() { 26 | @Override 27 | public void onMapReady(MapStatus status) { 28 | // Check if the map is loaded correctly 29 | if (status == MapStatus.MAP_STATUS_OK) { 30 | // Getting the associated map object 31 | final Map map = mapView.getMap(); 32 | // Creating a map options object 33 | MapOptions options = new MapOptions(); 34 | // Creating a map type control options object 35 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 36 | // Changing position of the map type control 37 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 38 | // Setting map type control options 39 | options.setMapTypeControlOptions(controlOptions); 40 | // Setting map options 41 | map.setOptions(options); 42 | // Setting the map center 43 | map.setCenter(new LatLng(35.91466, 10.312499)); 44 | // Setting initial zoom value 45 | map.setZoom(2.0); 46 | } 47 | } 48 | }); 49 | } 50 | }; -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/MarkersExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import com.teamdev.jxmaps.ControlPosition; 8 | import com.teamdev.jxmaps.InfoWindow; 9 | import com.teamdev.jxmaps.LatLng; 10 | import com.teamdev.jxmaps.Map; 11 | import com.teamdev.jxmaps.MapMouseEvent; 12 | import com.teamdev.jxmaps.MapOptions; 13 | import com.teamdev.jxmaps.MapReadyHandler; 14 | import com.teamdev.jxmaps.MapStatus; 15 | import com.teamdev.jxmaps.MapTypeControlOptions; 16 | import com.teamdev.jxmaps.Marker; 17 | import com.teamdev.jxmaps.MouseEvent; 18 | import com.teamdev.jxmaps.swing.MapView; 19 | 20 | import javax.swing.*; 21 | import java.awt.*; 22 | 23 | /** 24 | * This example demonstrates how to create and customize a Marker on the Map. 25 | * 26 | * @author Vitaly Eremenko 27 | */ 28 | public class MarkersExample extends MapView { 29 | public MarkersExample() { 30 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 31 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 32 | setOnMapReadyHandler(new MapReadyHandler() { 33 | @Override 34 | public void onMapReady(MapStatus status) { 35 | // Check if the map is loaded correctly 36 | if (status == MapStatus.MAP_STATUS_OK) { 37 | // Getting the associated map object 38 | final Map map = getMap(); 39 | // Creating a map options object 40 | MapOptions options = new MapOptions(); 41 | // Creating a map type control options object 42 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 43 | // Changing position of the map type control 44 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 45 | // Setting map type control options 46 | options.setMapTypeControlOptions(controlOptions); 47 | // Setting map options 48 | map.setOptions(options); 49 | // Setting the map center 50 | map.setCenter(new LatLng(41.3850639, 2.1734034999999494)); 51 | // Setting initial zoom value 52 | map.setZoom(9.0); 53 | // Creating a new marker object 54 | Marker marker = new Marker(map); 55 | // Setting marker position 56 | marker.setPosition(map.getCenter()); 57 | // Creating info window, that will be initially displayed on the marker 58 | final InfoWindow infoWindow = new InfoWindow(map); 59 | // Setting info window text 60 | infoWindow.setContent("Sample marker. Click on the map to add more markers. Click on the marker to remove it."); 61 | // Showing info windows under the marker 62 | infoWindow.open(map, marker); 63 | // Adding event listener that intercepts clicking on map 64 | map.addEventListener("click", new MapMouseEvent() { 65 | @Override 66 | public void onEvent(MouseEvent mouseEvent) { 67 | // Closing initially created info window 68 | infoWindow.close(); 69 | // Creating a new marker 70 | final Marker marker = new Marker(map); 71 | // Move marker to the position where user clicked 72 | marker.setPosition(mouseEvent.latLng()); 73 | 74 | // Adding event listener that intercepts clicking on marker 75 | marker.addEventListener("click", new MapMouseEvent() { 76 | @Override 77 | public void onEvent(MouseEvent mouseEvent) { 78 | // Removing marker from the map 79 | marker.remove(); 80 | } 81 | }); 82 | } 83 | }); 84 | } 85 | } 86 | }); 87 | } 88 | 89 | public static void main(String[] args) { 90 | final MarkersExample sample = new MarkersExample(); 91 | 92 | JFrame frame = new JFrame("Markers"); 93 | 94 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 95 | frame.add(sample, BorderLayout.CENTER); 96 | frame.setSize(700, 500); 97 | frame.setLocationRelativeTo(null); 98 | frame.setVisible(true); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/OptionsWindow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import com.teamdev.jxmaps.swing.MapView; 8 | 9 | import javax.swing.*; 10 | import java.awt.*; 11 | import java.awt.event.ComponentAdapter; 12 | import java.awt.event.ComponentEvent; 13 | import java.awt.event.WindowAdapter; 14 | import java.awt.event.WindowEvent; 15 | 16 | /** 17 | * Base class for windows with options. Some examples can have options. 18 | * 19 | * @author Vitaly Eremenko 20 | * @author Sergei Piletsky 21 | */ 22 | 23 | abstract class OptionsWindow { 24 | protected JFrame parentFrame; 25 | protected JWindow contentWindow; 26 | private Dimension size; 27 | 28 | public OptionsWindow(MapView parentWindow, Dimension size) { 29 | this.size = size; 30 | Container parent = parentWindow.getParent(); 31 | while (parent != null) { 32 | if (parent instanceof JFrame) { 33 | parentFrame = (JFrame) parent; 34 | break; 35 | } 36 | parent = parent.getParent(); 37 | } 38 | 39 | parentFrame.addComponentListener(new ComponentAdapter() { 40 | @Override 41 | public void componentMoved(ComponentEvent e) { 42 | updatePosition(); 43 | } 44 | 45 | @Override 46 | public void componentResized(ComponentEvent e) { 47 | updatePosition(); 48 | } 49 | }); 50 | 51 | contentWindow = new JWindow(parentFrame); 52 | contentWindow.setVisible(true); 53 | contentWindow.setFocusable(true); 54 | contentWindow.setFocusableWindowState(true); 55 | 56 | parentFrame.addWindowListener(new WindowAdapter() { 57 | @Override 58 | public void windowIconified(WindowEvent e) { 59 | contentWindow.setVisible(false); 60 | } 61 | 62 | @Override 63 | public void windowDeiconified(WindowEvent e) { 64 | contentWindow.setVisible(true); 65 | } 66 | }); 67 | 68 | initContent(contentWindow); 69 | updatePosition(); 70 | } 71 | 72 | abstract public void initContent(JWindow contentWindow); 73 | 74 | protected void updatePosition() { 75 | Rectangle bounds = new Rectangle(); 76 | bounds.setLocation((int) (parentFrame.getX() + (parentFrame.getWidth() - size.getWidth()) / 2), (int) (parentFrame.getY() + parentFrame.getHeight() - size.getHeight() - 20)); 77 | bounds.setSize(size); 78 | 79 | contentWindow.setBounds(bounds); 80 | } 81 | 82 | public void dispose() { 83 | contentWindow.dispose(); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/PlacesSearchExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import com.teamdev.jxmaps.ControlPosition; 8 | import com.teamdev.jxmaps.GeocoderCallback; 9 | import com.teamdev.jxmaps.GeocoderRequest; 10 | import com.teamdev.jxmaps.GeocoderResult; 11 | import com.teamdev.jxmaps.GeocoderStatus; 12 | import com.teamdev.jxmaps.Icon; 13 | import com.teamdev.jxmaps.InfoWindow; 14 | import com.teamdev.jxmaps.LatLng; 15 | import com.teamdev.jxmaps.Map; 16 | import com.teamdev.jxmaps.MapEvent; 17 | import com.teamdev.jxmaps.MapOptions; 18 | import com.teamdev.jxmaps.MapReadyHandler; 19 | import com.teamdev.jxmaps.MapStatus; 20 | import com.teamdev.jxmaps.MapTypeControlOptions; 21 | import com.teamdev.jxmaps.MapViewOptions; 22 | import com.teamdev.jxmaps.Marker; 23 | import com.teamdev.jxmaps.PhotoOptions; 24 | import com.teamdev.jxmaps.PlaceDetailsCallback; 25 | import com.teamdev.jxmaps.PlaceDetailsRequest; 26 | import com.teamdev.jxmaps.PlaceNearbySearchCallback; 27 | import com.teamdev.jxmaps.PlacePhoto; 28 | import com.teamdev.jxmaps.PlaceResult; 29 | import com.teamdev.jxmaps.PlaceSearchPagination; 30 | import com.teamdev.jxmaps.PlaceSearchRequest; 31 | import com.teamdev.jxmaps.PlacesService; 32 | import com.teamdev.jxmaps.PlacesServiceStatus; 33 | import com.teamdev.jxmaps.swing.MapView; 34 | 35 | import javax.swing.*; 36 | import javax.swing.event.ListSelectionEvent; 37 | import javax.swing.event.ListSelectionListener; 38 | import javax.xml.bind.DatatypeConverter; 39 | import java.awt.*; 40 | import java.awt.event.ActionEvent; 41 | import java.awt.event.ActionListener; 42 | import java.io.ByteArrayOutputStream; 43 | import java.io.InputStream; 44 | 45 | 46 | /** 47 | * This example demonstrates how to find places on the map. 48 | * Also it demonstrates how to get details about selected place. 49 | * 50 | * @author Vitaly Eremenko 51 | * @author Sergei Piletsky 52 | */ 53 | public class PlacesSearchExample extends MapView implements EditableTextControlPanel { 54 | static final MapViewOptions mapOptions; 55 | 56 | static { 57 | // initializing a map view options 58 | mapOptions = new MapViewOptions(); 59 | // enabling usage of places library 60 | mapOptions.importPlaces(); 61 | } 62 | 63 | private final boolean standalone; 64 | 65 | static final Icon restarantIcon = new Icon(); 66 | static final Icon barIcon = new Icon(); 67 | static final Icon hotelIcon = new Icon(); 68 | static final Icon restarantIconHover = new Icon(); 69 | static final Icon barIconHover = new Icon(); 70 | static final Icon hotelIconHover = new Icon(); 71 | 72 | private OptionsWindow optionsWindow; 73 | private JTextField addressEdit; 74 | private JList placesList; 75 | private ExtendedMarker[] markers; 76 | private Marker mainMarker; 77 | private JPanel controlPanel; 78 | 79 | static class ExtendedMarker extends Marker { 80 | 81 | private Icon hoverIcon; 82 | private Icon normalIcon; 83 | private final Map map; 84 | private final PlacesService placesService; 85 | 86 | public void setPlaceId(String placeId) { 87 | this.placeId = placeId; 88 | } 89 | 90 | private String placeId; 91 | 92 | public ExtendedMarker(Map map, PlacesService placesService) { 93 | super(map); 94 | this.map = map; 95 | this.placesService = placesService; 96 | 97 | addEventListener("mouseover", new MapEvent() { 98 | @Override 99 | public void onEvent() { 100 | if (hoverIcon != null) { 101 | setIcon(hoverIcon); 102 | } 103 | } 104 | }); 105 | addEventListener("mouseout", new MapEvent() { 106 | @Override 107 | public void onEvent() { 108 | if (normalIcon != null) { 109 | setIcon(normalIcon); 110 | } 111 | } 112 | }); 113 | addEventListener("click", new MapEvent() { 114 | @Override 115 | public void onEvent() { 116 | showInfoWindow(); 117 | } 118 | }); 119 | } 120 | 121 | /** 122 | * Showing info window for certain place 123 | */ 124 | private void showInfoWindow() { 125 | // Checking if placeId value is set 126 | if (placeId != null) { 127 | // Creating place details request 128 | PlaceDetailsRequest request = new PlaceDetailsRequest(); 129 | // Setting placeId to search request 130 | request.setPlaceId(placeId); 131 | // Requesting details for the place by provided placeId 132 | placesService.getDetails(request, new PlaceDetailsCallback(map) { 133 | @Override 134 | public void onComplete (PlaceResult result, PlacesServiceStatus status){ 135 | // Checking operation status 136 | if (status == PlacesServiceStatus.OK) { 137 | // Creating a info window 138 | InfoWindow window = new InfoWindow(map); 139 | // Getting details from result and setting it as info window context 140 | window.setContent(getContentByResult(result)); 141 | // Setting info window position 142 | window.setPosition(getPosition()); 143 | // Showing information about place 144 | window.open(map, this); 145 | } 146 | } 147 | } 148 | ); 149 | } 150 | } 151 | 152 | private String getContentByResult(PlaceResult result) { 153 | 154 | String textContent = "

" + result.getName() + "

"; 155 | textContent += "

" + result.getFormattedAddress() + "

"; 156 | 157 | // Creating a photo options object 158 | PhotoOptions option = new PhotoOptions(); 159 | // Setting maximum photo height 160 | option.setMaxHeight(64); 161 | // Setting maximum photo width 162 | option.setMaxWidth(64); 163 | 164 | // Getting photos from result 165 | PlacePhoto[] photos = result.getPhotos(); 166 | 167 | if ((photos != null) && (photos.length > 0)) { 168 | PlacePhoto photo = photos[0]; 169 | String imageContent = "
"; 171 | textContent = imageContent + textContent; 172 | textContent += "
"; 173 | } 174 | 175 | return textContent; 176 | } 177 | 178 | public void setIcons(Icon normalIcon, Icon hoverIcon) { 179 | this.normalIcon = normalIcon; 180 | this.hoverIcon = hoverIcon; 181 | 182 | setIcon(this.normalIcon); 183 | } 184 | } 185 | 186 | public PlacesSearchExample() { 187 | this(false); 188 | } 189 | 190 | public PlacesSearchExample(boolean standalone) { 191 | super(mapOptions); 192 | this.standalone = standalone; 193 | 194 | restarantIcon.loadFromStream(PlacesSearchExample.class.getResourceAsStream("res/restaurants_for_map.png"), "png"); 195 | barIcon.loadFromStream(PlacesSearchExample.class.getResourceAsStream("res/bars_and_pubs_for_map.png"), "png"); 196 | hotelIcon.loadFromStream(PlacesSearchExample.class.getResourceAsStream("res/hotels_for_map.png"), "png"); 197 | restarantIconHover.loadFromStream(PlacesSearchExample.class.getResourceAsStream("res/restaurants_for_map.png"), "png"); 198 | barIconHover.loadFromStream(PlacesSearchExample.class.getResourceAsStream("res/bars_and_pubs_for_map.png"), "png"); 199 | hotelIconHover.loadFromStream(PlacesSearchExample.class.getResourceAsStream("res/hotels_for_map.png"), "png"); 200 | 201 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 202 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 203 | setOnMapReadyHandler(new MapReadyHandler() { 204 | @Override 205 | public void onMapReady(MapStatus status) { 206 | // Check if the map is loaded correctly 207 | if (status == MapStatus.MAP_STATUS_OK) { 208 | init(); 209 | } 210 | } 211 | }); 212 | 213 | controlPanel = new JPanel(); 214 | 215 | addressEdit = new JTextField("London, Baker str., 221b"); 216 | addressEdit.addActionListener(new ActionListener() { 217 | @Override 218 | public void actionPerformed(ActionEvent e) { 219 | geocodePlace(addressEdit.getText()); 220 | } 221 | }); 222 | 223 | placesList = new JList(new String[]{"Restaurants", "Hotels", "Bars and pubs"}); 224 | placesList.addListSelectionListener(new ListSelectionListener() { 225 | @Override 226 | public void valueChanged(ListSelectionEvent e) { 227 | findPlaces(); 228 | } 229 | }); 230 | 231 | configureControlPanel(); 232 | } 233 | 234 | @Override 235 | public JComponent getControlPanel() { 236 | return controlPanel; 237 | } 238 | 239 | @Override 240 | public int getPreferredHeight() { 241 | return 233; 242 | } 243 | 244 | class PlaceOption { 245 | final ImageIcon icon; 246 | final String name; 247 | 248 | public PlaceOption(ImageIcon icon, String name) { 249 | this.icon = icon; 250 | this.name = name; 251 | } 252 | 253 | public ImageIcon getIcon() { 254 | return icon; 255 | } 256 | 257 | public String getName() { 258 | return name; 259 | } 260 | } 261 | 262 | class PlaceOptionsRenderer extends JPanel implements ListCellRenderer { 263 | private final Color SELECTION_BACKGROUND = new Color(0xFA, 0xFA, 0xFA); 264 | 265 | private final JLabel imageLabel; 266 | private final JLabel text; 267 | 268 | public PlaceOptionsRenderer() { 269 | setLayout(new GridBagLayout()); 270 | 271 | imageLabel = new JLabel(); 272 | imageLabel.setPreferredSize(new Dimension(18, 18)); 273 | text = new JLabel(); 274 | 275 | Font robotoPlain13 = new Font("Roboto", 0, 13); 276 | text.setFont(robotoPlain13); 277 | text.setForeground(new Color(0x21, 0x21, 0x21)); 278 | 279 | add(imageLabel, new GridBagConstraints(0, 0, 1, 3, 0.0, 0.0 280 | , GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(20, 22, 20, 22), 0, 0)); 281 | 282 | add(text, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0 283 | , GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(20, 8, 20, 22), 0, 0)); 284 | } 285 | public Component getListCellRendererComponent(JList list, 286 | Object value, 287 | int index, 288 | boolean isSelected, 289 | boolean cellHasFocus) { 290 | if (isSelected) { 291 | setBackground(SELECTION_BACKGROUND); 292 | } else { 293 | setBackground(list.getBackground()); 294 | } 295 | PlaceOption placeOption = (PlaceOption) value; 296 | imageLabel.setIcon(placeOption.getIcon()); 297 | text.setText(placeOption.getName()); 298 | return this; 299 | } 300 | } 301 | 302 | @Override 303 | public void configureControlPanel() { 304 | controlPanel.removeAll(); 305 | controlPanel.setBackground(Color.white); 306 | controlPanel.setLayout(new BorderLayout()); 307 | 308 | placesList = new JList(new PlaceOption[]{ 309 | new PlaceOption(new ImageIcon(PlacesSearchExample.class.getResource("res/restaurants.png")), "Restaurants"), 310 | new PlaceOption(new ImageIcon(PlacesSearchExample.class.getResource("res/hotels.png")), "Hotels"), 311 | new PlaceOption(new ImageIcon(PlacesSearchExample.class.getResource("res/bars_and_pubs.png")), "Bars and pubs"), 312 | }); 313 | 314 | placesList.setCellRenderer(new PlaceOptionsRenderer()); 315 | placesList.addListSelectionListener(new ListSelectionListener() { 316 | @Override 317 | public void valueChanged(ListSelectionEvent e) { 318 | findPlaces(); 319 | } 320 | }); 321 | placesList.setOpaque(false); 322 | placesList.setCursor(new Cursor(Cursor.HAND_CURSOR)); 323 | 324 | if (standalone) { 325 | controlPanel.add(addressEdit, BorderLayout.NORTH); 326 | } 327 | 328 | controlPanel.add(placesList, BorderLayout.CENTER); 329 | } 330 | 331 | @Override 332 | public void onTextEntered(String value) { 333 | geocodePlace(value); 334 | } 335 | 336 | @Override 337 | public String getInitialText() { 338 | return addressEdit.getText(); 339 | } 340 | 341 | private void findPlaces() { 342 | 343 | if (placesList.getSelectedIndex() < 0) 344 | return; 345 | 346 | // Getting the associated map object 347 | final Map map = getMap(); 348 | // Creating places search request 349 | final PlaceSearchRequest request = new PlaceSearchRequest(); 350 | // Setting start point for places search 351 | request.setLocation(map.getCenter()); 352 | // Setting radius for places search 353 | request.setRadius(500.0); 354 | 355 | final int imageType = placesList.getSelectedIndex(); 356 | 357 | final Icon iconUrl[] = new Icon[2]; 358 | 359 | switch (imageType) { 360 | case 0: 361 | iconUrl[0] = restarantIcon; 362 | iconUrl[1] = restarantIconHover; 363 | 364 | request.setTypes(new String[]{"restaurant"}); 365 | break; 366 | case 1: 367 | iconUrl[0] = hotelIcon; 368 | iconUrl[1] = hotelIconHover; 369 | 370 | request.setTypes(new String[]{"hotels"}); 371 | break; 372 | case 2: 373 | iconUrl[0] = barIcon; 374 | iconUrl[1] = barIconHover; 375 | 376 | request.setTypes(new String[]{"bar"}); 377 | break; 378 | } 379 | 380 | // Searching places near specified location 381 | getServices().getPlacesService().nearbySearch(request, new PlaceNearbySearchCallback(map) { 382 | @Override 383 | public void onComplete(PlaceResult[] results, PlacesServiceStatus status, PlaceSearchPagination pagination) { 384 | // Checking operation status 385 | if (status == PlacesServiceStatus.OK) { 386 | clearMarkers(); 387 | 388 | // Creating markers for each place 389 | markers = new ExtendedMarker[results.length]; 390 | for (int i=0; i< results.length; ++i) { 391 | PlaceResult result = results[i]; 392 | // Creating a marker for place found 393 | markers[i] = new ExtendedMarker(map, getServices().getPlacesService()); 394 | // Associating the marker with placeId (will be used on place details search) 395 | markers[i].setPlaceId(result.getPlaceId()); 396 | // Moving the marker to place location 397 | LatLng location = result.getGeometry() != null ? result.getGeometry().getLocation() : null; 398 | // Setting icons for the marker 399 | markers[i].setIcons(iconUrl[0],iconUrl[1]); 400 | if (location != null) 401 | // Setting the marker position 402 | markers[i].setPosition(location); 403 | } 404 | } 405 | } 406 | }); 407 | 408 | } 409 | 410 | private void geocodePlace(String address) { 411 | if (mainMarker != null) 412 | mainMarker.setVisible(false); 413 | mainMarker = null; 414 | clearMarkers(); 415 | 416 | // Getting the associated map object 417 | final Map map = getMap(); 418 | 419 | // Creating geocoder request 420 | GeocoderRequest request = new GeocoderRequest(); 421 | // Set address for request 422 | request.setAddress(address); 423 | // Geocoding a position by address 424 | getServices().getGeocoder().geocode(request, new GeocoderCallback(map) { 425 | @Override 426 | public void onComplete(GeocoderResult[] results, GeocoderStatus status) { 427 | // Checking operation status 428 | if ((status == GeocoderStatus.OK) && (results.length > 0)) { 429 | // Getting first result 430 | GeocoderResult result = results[0]; 431 | // Getting location (coords) 432 | LatLng location = result.getGeometry().getLocation(); 433 | // Centering map to result location 434 | map.setCenter(location); 435 | // Initializing main marker 436 | mainMarker = new Marker(map); 437 | // Moving marker to result location 438 | mainMarker.setPosition(location); 439 | // Showing marker on map 440 | mainMarker.setVisible(true); 441 | 442 | findPlaces(); 443 | } 444 | } 445 | }); 446 | } 447 | 448 | private void clearMarkers() { 449 | if (markers == null) 450 | return; 451 | for (Marker marker : markers) { 452 | marker.setVisible(false); 453 | } 454 | markers = null; 455 | } 456 | 457 | private void init() { 458 | // Getting the associated map object 459 | final Map map = getMap(); 460 | // Creating a map options object 461 | MapOptions options = new MapOptions(); 462 | // Creating a map type control options object 463 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 464 | // Changing position of the map type control 465 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 466 | // Setting map type control options 467 | options.setMapTypeControlOptions(controlOptions); 468 | // Setting map options 469 | map.setOptions(options); 470 | // Setting initial zoom value 471 | map.setZoom(15.0); 472 | 473 | geocodePlace(addressEdit.getText()); 474 | } 475 | 476 | private static void loadAndRegisterCustomFonts() { 477 | try { 478 | GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); 479 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, PlacesSearchExample.class.getResourceAsStream("res/Roboto-Bold.ttf"))); 480 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, PlacesSearchExample.class.getResourceAsStream("res/Roboto-Medium.ttf"))); 481 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, PlacesSearchExample.class.getResourceAsStream("res/Roboto-Regular.ttf"))); 482 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, PlacesSearchExample.class.getResourceAsStream("res/Roboto-Thin.ttf"))); 483 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, PlacesSearchExample.class.getResourceAsStream("res/Roboto-Light.ttf"))); 484 | } catch (Exception e) { 485 | throw new RuntimeException(e); 486 | } 487 | } 488 | 489 | public static void main(String[] args) { 490 | loadAndRegisterCustomFonts(); 491 | 492 | final PlacesSearchExample sample = new PlacesSearchExample(true); 493 | 494 | JFrame frame = new JFrame("Places Search"); 495 | 496 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 497 | frame.add(sample, BorderLayout.CENTER); 498 | frame.setSize(700, 500); 499 | frame.setLocationRelativeTo(null); 500 | frame.setVisible(true); 501 | 502 | new OptionsWindow(sample, new Dimension(350, 200)) { 503 | @Override 504 | public void initContent(JWindow contentWindow) { 505 | contentWindow.add(sample.controlPanel); 506 | } 507 | }; 508 | } 509 | } 510 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/PolygonExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import com.teamdev.jxmaps.ControlPosition; 8 | import com.teamdev.jxmaps.LatLng; 9 | import com.teamdev.jxmaps.Map; 10 | import com.teamdev.jxmaps.MapOptions; 11 | import com.teamdev.jxmaps.MapReadyHandler; 12 | import com.teamdev.jxmaps.MapStatus; 13 | import com.teamdev.jxmaps.MapTypeControlOptions; 14 | import com.teamdev.jxmaps.Polygon; 15 | import com.teamdev.jxmaps.PolygonOptions; 16 | import com.teamdev.jxmaps.swing.MapView; 17 | 18 | import javax.swing.*; 19 | import java.awt.*; 20 | 21 | /** 22 | * This example demonstrates how to draw polygons on the map. 23 | * 24 | * @author Vitaly Eremenko 25 | */ 26 | public class PolygonExample extends MapView { 27 | public PolygonExample() { 28 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 29 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 30 | setOnMapReadyHandler(new MapReadyHandler() { 31 | @Override 32 | public void onMapReady(MapStatus status) { 33 | // Check if the map is loaded correctly 34 | if (status == MapStatus.MAP_STATUS_OK) { 35 | // Getting the associated map object 36 | final Map map = getMap(); 37 | // Creating a map options object 38 | MapOptions mapOptions = new MapOptions(); 39 | // Creating a map type control options object 40 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 41 | // Changing position of the map type control 42 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 43 | // Setting map type control options 44 | mapOptions.setMapTypeControlOptions(controlOptions); 45 | // Setting map options 46 | map.setOptions(mapOptions); 47 | // Setting the map center 48 | map.setCenter(new LatLng(24.886, -70.268)); 49 | // Setting initial zoom value 50 | map.setZoom(5.0); 51 | // Creating a path (array of coordinates) that represents a polygon 52 | LatLng[] path = {new LatLng(25.774, -80.190), 53 | new LatLng(18.466, -66.118), 54 | new LatLng(32.321, -64.757), 55 | new LatLng(25.774, -80.190)}; 56 | // Creating a new polygon object 57 | Polygon polygon = new Polygon(map); 58 | // Initializing the polygon with the created path 59 | polygon.setPath(path); 60 | // Creating a polyline options object 61 | PolygonOptions options = new PolygonOptions(); 62 | // Setting fill color value 63 | options.setFillColor("#FF0000"); 64 | // Setting fill opacity value 65 | options.setFillOpacity(0.35); 66 | // Setting stroke color value 67 | options.setStrokeColor("#FF0000"); 68 | // Setting stroke opacity value 69 | options.setStrokeOpacity(0.8); 70 | // Setting stroke weight value 71 | options.setStrokeWeight(2.0); 72 | // Applying options to the polygon 73 | polygon.setOptions(options); 74 | } 75 | } 76 | }); 77 | } 78 | 79 | public static void main(String[] args) { 80 | final PolygonExample sample = new PolygonExample(); 81 | 82 | JFrame frame = new JFrame("Polygons"); 83 | 84 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 85 | frame.add(sample, BorderLayout.CENTER); 86 | frame.setSize(700, 500); 87 | frame.setLocationRelativeTo(null); 88 | frame.setVisible(true); 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/PolylineExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import com.teamdev.jxmaps.ControlPosition; 8 | import com.teamdev.jxmaps.LatLng; 9 | import com.teamdev.jxmaps.Map; 10 | import com.teamdev.jxmaps.MapOptions; 11 | import com.teamdev.jxmaps.MapReadyHandler; 12 | import com.teamdev.jxmaps.MapStatus; 13 | import com.teamdev.jxmaps.MapTypeControlOptions; 14 | import com.teamdev.jxmaps.Polyline; 15 | import com.teamdev.jxmaps.PolylineOptions; 16 | import com.teamdev.jxmaps.swing.MapView; 17 | 18 | import javax.swing.*; 19 | import java.awt.*; 20 | 21 | /** 22 | * This example demonstrates how to draw polylines on the map. 23 | * 24 | * @author Vitaly Eremenko 25 | */ 26 | public class PolylineExample extends MapView { 27 | public PolylineExample() { 28 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 29 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 30 | setOnMapReadyHandler(new MapReadyHandler() { 31 | @Override 32 | public void onMapReady(MapStatus status) { 33 | // Check if the map is loaded correctly 34 | if (status == MapStatus.MAP_STATUS_OK) { 35 | // Getting the associated map object 36 | final Map map = getMap(); 37 | // Creating a map options object 38 | MapOptions mapOptions = new MapOptions(); 39 | // Creating a map type control options object 40 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 41 | // Changing position of the map type control 42 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 43 | // Setting map type control options 44 | mapOptions.setMapTypeControlOptions(controlOptions); 45 | // Setting map options 46 | map.setOptions(mapOptions); 47 | // Setting the map center 48 | map.setCenter(new LatLng(0, -180)); 49 | // Setting initial zoom value 50 | map.setZoom(3.0); 51 | // Creating a path (array of coordinates) that represents a polyline 52 | LatLng[] path = {new LatLng(37.772, -122.214), 53 | new LatLng(21.291, -157.821), 54 | new LatLng(-18.142, 178.431), 55 | new LatLng(-27.467, 153.027)}; 56 | // Creating a new polyline object 57 | Polyline polyline = new Polyline(map); 58 | // Initializing the polyline with created path 59 | polyline.setPath(path); 60 | // Creating a polyline options object 61 | PolylineOptions options = new PolylineOptions(); 62 | // Setting geodesic property value 63 | options.setGeodesic(true); 64 | // Setting stroke color value 65 | options.setStrokeColor("#FF0000"); 66 | // Setting stroke opacity value 67 | options.setStrokeOpacity(1.0); 68 | // Setting stroke weight value 69 | options.setStrokeWeight(2.0); 70 | // Applying options to the polyline 71 | polyline.setOptions(options); 72 | } 73 | } 74 | }); 75 | } 76 | 77 | public static void main(String[] args) { 78 | final PolylineExample sample = new PolylineExample(); 79 | 80 | JFrame frame = new JFrame("Polylines"); 81 | 82 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 83 | frame.add(sample, BorderLayout.CENTER); 84 | frame.setSize(700, 500); 85 | frame.setLocationRelativeTo(null); 86 | frame.setVisible(true); 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/SaveImageExample.java: -------------------------------------------------------------------------------- 1 | package com.teamdev.jxmaps.examples; 2 | 3 | import com.teamdev.jxmaps.*; 4 | import com.teamdev.jxmaps.swing.MapView; 5 | 6 | import javax.imageio.ImageIO; 7 | import javax.swing.*; 8 | import java.awt.*; 9 | import java.awt.image.RenderedImage; 10 | import java.io.File; 11 | import java.io.IOException; 12 | 13 | /** 14 | * This example demonstrates how to save displayed map to PNG file. 15 | * 16 | * @author Vitaly Eremenko 17 | */ 18 | public class SaveImageExample extends MapView { 19 | public SaveImageExample() { 20 | 21 | // Creation of MapViewer with specifying LIGHTWEIGHT mode. getImage method of MapView class working only in the this mode. 22 | super(new MapViewOptions(MapComponentType.LIGHTWEIGHT)); 23 | 24 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 25 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 26 | setOnMapReadyHandler(new MapReadyHandler() { 27 | @Override 28 | public void onMapReady(MapStatus status) { 29 | // Check if the map is loaded correctly 30 | if (status == MapStatus.MAP_STATUS_OK) { 31 | // Getting the associated map object 32 | final Map map = getMap(); 33 | // Creating a map options object 34 | MapOptions options = new MapOptions(); 35 | // Creating a map type control options object 36 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 37 | // Changing position of the map type control 38 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 39 | // Setting map type control options 40 | options.setMapTypeControlOptions(controlOptions); 41 | // Setting map options 42 | map.setOptions(options); 43 | // Setting initial zoom value 44 | map.setZoom(2.0); 45 | // Setting the map center 46 | map.setCenter(new LatLng(35.91466, 10.312499)); 47 | 48 | // Adding of idle event listener 49 | map.addEventListener("idle", new MapEvent() { 50 | @Override 51 | public void onEvent() { 52 | // Getting of current map image 53 | Image image = getImage(); 54 | // Saving of image of the displayed map into a PNG file. 55 | try { 56 | ImageIO.write((RenderedImage) image, "PNG", new File("map-image.png")); 57 | } catch (IOException e) { 58 | e.printStackTrace(); 59 | } 60 | } 61 | }); 62 | } 63 | } 64 | }); 65 | } 66 | 67 | public static void main(String[] args) { 68 | SaveImageExample sample = new SaveImageExample(); 69 | 70 | JFrame frame = new JFrame("Save Image Example"); 71 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 72 | frame.add(sample, BorderLayout.CENTER); 73 | frame.setSize(700, 500); 74 | frame.setLocationRelativeTo(null); 75 | frame.setVisible(true); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/StreetViewExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import com.teamdev.jxmaps.ControlPosition; 8 | import com.teamdev.jxmaps.LatLng; 9 | import com.teamdev.jxmaps.Map; 10 | import com.teamdev.jxmaps.MapOptions; 11 | import com.teamdev.jxmaps.MapReadyHandler; 12 | import com.teamdev.jxmaps.MapStatus; 13 | import com.teamdev.jxmaps.MapTypeControlOptions; 14 | import com.teamdev.jxmaps.StreetViewAddressControlOptions; 15 | import com.teamdev.jxmaps.StreetViewPanoramaOptions; 16 | import com.teamdev.jxmaps.StreetViewPov; 17 | import com.teamdev.jxmaps.swing.MapView; 18 | 19 | import javax.swing.*; 20 | import java.awt.*; 21 | 22 | /** 23 | * This example demonstrates how to display street view panorama with a map. 24 | * 25 | * @author Vitaly Eremenko 26 | */ 27 | public class StreetViewExample extends MapView { 28 | public StreetViewExample() { 29 | 30 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 31 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 32 | setOnMapReadyHandler(new MapReadyHandler() { 33 | @Override 34 | public void onMapReady(MapStatus status) { 35 | // Check if the map is loaded correctly 36 | if (status == MapStatus.MAP_STATUS_OK) { 37 | // Getting the associated map object 38 | Map map = getMap(); 39 | // Creating a map options object 40 | MapOptions mapOptions = new MapOptions(); 41 | // Creating a map type control options object 42 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 43 | // Changing position of the map type control 44 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 45 | // Setting map type control options 46 | mapOptions.setMapTypeControlOptions(controlOptions); 47 | // Setting map options 48 | map.setOptions(mapOptions); 49 | // Setting the map center 50 | map.setCenter(new LatLng(51.500871, -0.1222632)); 51 | // Setting initial zoom value 52 | map.setZoom(13.0); 53 | // Creating a street view panorama options object 54 | StreetViewPanoramaOptions options = new StreetViewPanoramaOptions(); 55 | // Creating a street view address control options object 56 | StreetViewAddressControlOptions svControlOptions = new StreetViewAddressControlOptions(); 57 | // Changing position of the address control on the panorama 58 | svControlOptions.setPosition(ControlPosition.TOP_RIGHT); 59 | // Setting address control options 60 | options.setAddressControlOptions(svControlOptions); 61 | // Setting street view panorama options 62 | getPanorama().setOptions(options); 63 | // Setting initial position of the street view 64 | getPanorama().setPosition(map.getCenter()); 65 | // Creating point of view object 66 | StreetViewPov pov = new StreetViewPov(); 67 | // Setting heading for the point of view 68 | pov.setHeading(270); 69 | // Setting pitch for the point of view 70 | pov.setPitch(20); 71 | // Applying the point of view to the panorama object 72 | getPanorama().setPov(pov); 73 | } 74 | } 75 | }); 76 | } 77 | 78 | public static void main(String[] args) { 79 | final StreetViewExample sample = new StreetViewExample(); 80 | 81 | JFrame frame = new JFrame("Street View"); 82 | 83 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 84 | frame.add(sample, BorderLayout.CENTER); 85 | frame.setSize(700, 500); 86 | frame.setLocationRelativeTo(null); 87 | frame.setVisible(true); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/StreetViewLayoutExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import com.teamdev.jxmaps.*; 8 | import com.teamdev.jxmaps.swing.MapView; 9 | 10 | import javax.swing.*; 11 | import java.awt.*; 12 | 13 | /** 14 | * This example demonstrates how to customize street view panorama layout. 15 | * 16 | * @author Vitaly Eremenko 17 | */ 18 | public class StreetViewLayoutExample extends MapView { 19 | 20 | public static void main(String[] args) { 21 | 22 | final MapViewOptions option = new MapViewOptions(); 23 | option.streetViewLayout().setSize(70); 24 | option.streetViewLayout().setPosition(StreetViewLayout.Position.BOTTOM); 25 | final MapView view = new MapView(option); 26 | 27 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 28 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 29 | view.setOnMapReadyHandler(new MapReadyHandler() { 30 | @Override 31 | public void onMapReady(MapStatus status) { 32 | // Check if the map is loaded correctly 33 | if (status == MapStatus.MAP_STATUS_OK) { 34 | // Getting the associated map object 35 | Map map = view.getMap(); 36 | // Creating a map options object 37 | MapOptions mapOptions = new MapOptions(); 38 | // Creating a map type control options object 39 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 40 | // Changing position of the map type control 41 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 42 | // Setting map type control options 43 | mapOptions.setMapTypeControlOptions(controlOptions); 44 | // Setting map options 45 | map.setOptions(mapOptions); 46 | // Setting the map center 47 | map.setCenter(new LatLng(51.500871, -0.1222632)); 48 | // Setting initial zoom value 49 | map.setZoom(13.0); 50 | // Creating a street view panorama options object 51 | StreetViewPanoramaOptions options = new StreetViewPanoramaOptions(); 52 | // Creating a street view address control options object 53 | StreetViewAddressControlOptions svControlOptions = new StreetViewAddressControlOptions(); 54 | // Changing position of the address control on the panorama 55 | svControlOptions.setPosition(ControlPosition.TOP_RIGHT); 56 | // Setting address control options 57 | options.setAddressControlOptions(svControlOptions); 58 | // Setting street view panorama options 59 | view.getPanorama().setOptions(options); 60 | // Setting initial position of the street view 61 | view.getPanorama().setPosition(map.getCenter()); 62 | // Creating point of view object 63 | StreetViewPov pov = new StreetViewPov(); 64 | // Setting heading for the point of view 65 | pov.setHeading(270); 66 | // Setting pitch for the point of view 67 | pov.setPitch(20); 68 | // Applying the point of view to the panorama object 69 | view.getPanorama().setPov(pov); 70 | } 71 | } 72 | }); 73 | 74 | JFrame frame = new JFrame("Street View Layout"); 75 | 76 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 77 | frame.add(view, BorderLayout.CENTER); 78 | frame.setSize(700, 500); 79 | frame.setLocationRelativeTo(null); 80 | frame.setVisible(true); 81 | 82 | 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/StyledMapExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import com.teamdev.jxmaps.ControlPosition; 8 | import com.teamdev.jxmaps.LatLng; 9 | import com.teamdev.jxmaps.Map; 10 | import com.teamdev.jxmaps.MapOptions; 11 | import com.teamdev.jxmaps.MapTypeControlOptions; 12 | import com.teamdev.jxmaps.MapTypeId; 13 | import com.teamdev.jxmaps.MapTypeStyle; 14 | import com.teamdev.jxmaps.MapTypeStyleElementType; 15 | import com.teamdev.jxmaps.MapTypeStyleFeatureType; 16 | import com.teamdev.jxmaps.MapReadyHandler; 17 | import com.teamdev.jxmaps.MapStatus; 18 | import com.teamdev.jxmaps.MapTypeStyler; 19 | import com.teamdev.jxmaps.StyledMapType; 20 | import com.teamdev.jxmaps.swing.MapView; 21 | 22 | import javax.swing.*; 23 | import java.awt.*; 24 | 25 | /** 26 | * This example demonstrates how to customize a map. Customization defines custom colour and visibility of roads, 27 | * parks, bodies of water etc. 28 | * 29 | * @author Vitaly Eremenko 30 | */ 31 | public class StyledMapExample extends MapView { 32 | 33 | public StyledMapExample() { 34 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 35 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 36 | setOnMapReadyHandler(new MapReadyHandler() { 37 | @Override 38 | public void onMapReady(MapStatus status) { 39 | //Check if the map is loaded correctly 40 | if (status == MapStatus.MAP_STATUS_OK) 41 | //Initializing the map 42 | initMap(getMap()); 43 | } 44 | }); 45 | } 46 | 47 | /** 48 | * Create a custom colored style with a specified name and hue values 49 | */ 50 | private StyledMapType createStyledMap(Map map, String name, String hue) { 51 | 52 | // Creating a map type style object for all elements 53 | MapTypeStyle style = new MapTypeStyle(); 54 | // Styling will be applied to all elements 55 | style.setElementType(MapTypeStyleElementType.ALL); 56 | // Styling will be applied to all features 57 | style.setFeatureType(MapTypeStyleFeatureType.ALL); 58 | 59 | // Creating a map type styler object 60 | MapTypeStyler styler = new MapTypeStyler(); 61 | 62 | // Setting a new hue value for the map types styler object 63 | styler.setHue(hue); 64 | // Setting a new saturation value the map types styler object 65 | styler.setSaturation(-20); 66 | // Setting a new visibility type value the map types styler object 67 | styler.setVisibility("simplified"); 68 | // Setting a new gamma value the map types styler object 69 | styler.setGamma(0.5); 70 | // Setting a new weight value the map types styler object 71 | styler.setWeight(0.5); 72 | 73 | // Applying the map type styler to the map style object 74 | style.setStylers(new MapTypeStyler[]{styler}); 75 | 76 | // Creating a map type style object for roads 77 | MapTypeStyle roadStyle = new MapTypeStyle(); 78 | // Styling will be applied to geometry elements 79 | roadStyle.setElementType(MapTypeStyleElementType.GEOMETRY); 80 | // Styling will be applied to roads 81 | roadStyle.setFeatureType(MapTypeStyleFeatureType.ROAD); 82 | 83 | // Creating a road styler 84 | MapTypeStyler roadStyler = new MapTypeStyler(); 85 | // Setting a new lightness value the road styler object 86 | roadStyler.setLightness(100); 87 | // Setting a new visibility type value the road styler object 88 | roadStyler.setVisibility("simplified"); 89 | 90 | // Applying the road styler to road style object 91 | roadStyle.setStylers(new MapTypeStyler[]{roadStyler}); 92 | 93 | MapTypeStyle[] styles = {style, roadStyle}; 94 | 95 | // Creating a styled map type with the previously created styles 96 | StyledMapType styledMap = new StyledMapType(map, styles); 97 | // Setting a style name 98 | styledMap.setName(name); 99 | 100 | return styledMap; 101 | } 102 | 103 | private void initMap(Map map) { 104 | // Creating a map options object 105 | MapOptions options = new MapOptions(); 106 | // Creating a map type control options object 107 | MapTypeControlOptions mapTypeOptions = new MapTypeControlOptions(); 108 | // Changing position of the map type control 109 | mapTypeOptions.setPosition(ControlPosition.TOP_RIGHT); 110 | //Creation of a pink styled map object 111 | StyledMapType pinkMap = createStyledMap(map, "Pink", "#890000"); 112 | // Creation of a teal styled map object 113 | StyledMapType tealMap = createStyledMap(map, "Teal", "#00ffe6"); 114 | // Enabling the map type control on the map 115 | options.setMapTypeControl(true); 116 | // Setting the map type control options 117 | options.setMapTypeControlOptions(mapTypeOptions); 118 | // Setting the map center 119 | options.setCenter(new LatLng(41.9027835, 12.496365500000024)); 120 | // Setting initial zoom value 121 | options.setZoom(11.0); 122 | 123 | MapTypeId[] ids = {new MapTypeId("teal"), new MapTypeId("pink"), MapTypeId.ROADMAP}; 124 | // Setting available styles 125 | mapTypeOptions.setMapTypeIds(ids); 126 | 127 | // Association of map names with styles 128 | map.mapTypes().set("pink", pinkMap); 129 | map.mapTypes().set("teal", tealMap); 130 | 131 | // Setting map options 132 | map.setOptions(options); 133 | 134 | // Setting initial map type id to teal 135 | map.setMapTypeId(new MapTypeId("teal")); 136 | } 137 | 138 | public static void main(String[] args) { 139 | final StyledMapExample mapView = new StyledMapExample(); 140 | 141 | JFrame frame = new JFrame("Styled map"); 142 | 143 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 144 | frame.add(mapView, BorderLayout.CENTER); 145 | frame.setSize(700, 500); 146 | frame.setLocationRelativeTo(null); 147 | frame.setVisible(true); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/TrafficLayerExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved. 3 | * Use is subject to Apache 2.0 license terms. 4 | */ 5 | package com.teamdev.jxmaps.examples; 6 | 7 | import com.teamdev.jxmaps.*; 8 | import com.teamdev.jxmaps.swing.MapView; 9 | 10 | import javax.swing.*; 11 | import javax.swing.plaf.basic.BasicButtonUI; 12 | import javax.swing.plaf.basic.BasicTextFieldUI; 13 | import java.awt.*; 14 | import java.awt.Point; 15 | import java.awt.event.ActionEvent; 16 | import java.awt.event.ActionListener; 17 | 18 | /** 19 | * This example demonstrates how to display traffic layer on the map. 20 | * 21 | * @author Vitaly Eremenko 22 | * @author Sergei Piletsky 23 | */ 24 | public class TrafficLayerExample extends MapView { 25 | 26 | private static final String INITIAL_LOCATION = "New York"; 27 | 28 | private OptionsWindow optionsWindow; 29 | 30 | public TrafficLayerExample() { 31 | // Setting of a ready handler to MapView object. onMapReady will be called when map initialization is done and 32 | // the map object is ready to use. Current implementation of onMapReady customizes the map object. 33 | setOnMapReadyHandler(new MapReadyHandler() { 34 | @Override 35 | public void onMapReady(MapStatus status) { 36 | // Getting the associated map object 37 | final Map map = getMap(); 38 | // Setting initial zoom value 39 | map.setZoom(13.0); 40 | // Creating a map options object 41 | MapOptions options = new MapOptions(); 42 | // Creating a map type control options object 43 | MapTypeControlOptions controlOptions = new MapTypeControlOptions(); 44 | // Changing position of the map type control 45 | controlOptions.setPosition(ControlPosition.TOP_RIGHT); 46 | // Setting map type control options 47 | options.setMapTypeControlOptions(controlOptions); 48 | // Setting map options 49 | map.setOptions(options); 50 | 51 | // Enabling of traffic layer on the map 52 | new TrafficLayer(map); 53 | 54 | performGeocode(INITIAL_LOCATION); 55 | } 56 | }); 57 | } 58 | 59 | @Override 60 | public void addNotify() { 61 | super.addNotify(); 62 | 63 | optionsWindow = new OptionsWindow(this, new Dimension(350, 40)) { 64 | @Override 65 | public void initContent(JWindow contentWindow) { 66 | JPanel content = new JPanel(new GridBagLayout()); 67 | content.setBackground(Color.white); 68 | 69 | Font robotoPlain13 = new Font("Roboto", 0, 13); 70 | final JTextField searchField = new JTextField(); 71 | searchField.setText(INITIAL_LOCATION); 72 | searchField.setToolTipText("Enter address or coordinates..."); 73 | searchField.setBorder(BorderFactory.createEmptyBorder()); 74 | searchField.setFont(robotoPlain13); 75 | searchField.setForeground(new Color(0x21, 0x21, 0x21)); 76 | searchField.setUI(new SearchFieldUI(searchField)); 77 | 78 | final JButton searchButton = new JButton(); 79 | searchButton.setIcon(new ImageIcon(MapOptionsExample.class.getResource("res/search.png"))); 80 | searchButton.setRolloverIcon(new ImageIcon(MapOptionsExample.class.getResource("res/search_hover.png"))); 81 | searchButton.setBorder(BorderFactory.createEmptyBorder()); 82 | searchButton.setUI(new BasicButtonUI()); 83 | searchButton.setOpaque(false); 84 | ActionListener searchActionListener = new ActionListener() { 85 | @Override 86 | public void actionPerformed(ActionEvent e) { 87 | performGeocode(searchField.getText()); 88 | } 89 | }; 90 | searchButton.addActionListener(searchActionListener); 91 | searchField.addActionListener(searchActionListener); 92 | 93 | content.add(searchField, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, 94 | GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(11, 11, 11, 0), 0, 0)); 95 | content.add(searchButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, 96 | GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(11, 0, 11, 11), 0, 0)); 97 | 98 | contentWindow.getContentPane().add(content); 99 | } 100 | 101 | @Override 102 | protected void updatePosition() { 103 | if (parentFrame.isVisible()) { 104 | Point newLocation = parentFrame.getContentPane().getLocationOnScreen(); 105 | newLocation.translate(56, 11); 106 | contentWindow.setLocation(newLocation); 107 | contentWindow.setSize(340, 40); 108 | } 109 | } 110 | }; 111 | } 112 | 113 | class SearchFieldUI extends BasicTextFieldUI { 114 | private final JTextField textField; 115 | 116 | public SearchFieldUI(JTextField textField) { 117 | this.textField = textField; 118 | } 119 | 120 | @Override 121 | protected void paintBackground(Graphics g) { 122 | super.paintBackground(g); 123 | String toolTipText = textField.getToolTipText(); 124 | String text = textField.getText(); 125 | if (toolTipText != null && text.isEmpty()) { 126 | paintPlaceholderText(g, textField); 127 | } 128 | } 129 | 130 | protected void paintPlaceholderText(Graphics g, JComponent c) { 131 | g.setColor(new Color(0x75, 0x75, 0x75)); 132 | g.setFont(c.getFont()); 133 | String text = textField.getToolTipText(); 134 | if (g instanceof Graphics2D) { 135 | Graphics2D graphics2D = (Graphics2D) g; 136 | graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 137 | } 138 | g.drawString(text, 0, 14); 139 | } 140 | } 141 | 142 | @Override 143 | public void removeNotify() { 144 | super.removeNotify(); 145 | optionsWindow.dispose(); 146 | } 147 | 148 | private void performGeocode(String text) { 149 | // Getting the associated map object 150 | final Map map = getMap(); 151 | // Creating a geocode request 152 | GeocoderRequest request = new GeocoderRequest(); 153 | // Setting address to the geocode request 154 | request.setAddress(text); 155 | 156 | // Geocoding position by the entered address 157 | getServices().getGeocoder().geocode(request, new GeocoderCallback(map) { 158 | @Override 159 | public void onComplete(GeocoderResult[] results, GeocoderStatus status) { 160 | // Checking operation status 161 | if ((status == GeocoderStatus.OK) && (results.length > 0)) { 162 | // Getting the first result 163 | GeocoderResult result = results[0]; 164 | // Getting a location of the result 165 | LatLng location = result.getGeometry().getLocation(); 166 | // Setting the map center to result location 167 | map.setCenter(location); 168 | } 169 | } 170 | }); 171 | } 172 | 173 | 174 | public static void main(String[] args) { 175 | final TrafficLayerExample mapView = new TrafficLayerExample(); 176 | 177 | JFrame frame = new JFrame("Traffic layer"); 178 | 179 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 180 | frame.add(mapView, BorderLayout.CENTER); 181 | frame.setSize(700, 500); 182 | frame.setLocationRelativeTo(null); 183 | frame.setVisible(true); 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/Paris.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/Paris.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/Roboto-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/Roboto-Bold.ttf -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/Roboto-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/Roboto-Light.ttf -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/Roboto-Medium.ttf -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/Roboto-Regular.ttf -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/Roboto-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/Roboto-Thin.ttf -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/bars_and_pubs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/bars_and_pubs.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/bars_and_pubs_for_map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/bars_and_pubs_for_map.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/change.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/change.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/checkbox_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/checkbox_0.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/checkbox_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/checkbox_1.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/dots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/dots.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/from.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/from.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/hotels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/hotels.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/hotels_for_map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/hotels_for_map.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/main.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 |
10 |
-------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/restaurants.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/restaurants.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/restaurants_for_map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/restaurants_for_map.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/search.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/search_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/search_hover.png -------------------------------------------------------------------------------- /src/com/teamdev/jxmaps/examples/res/to.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamDev-IP/JxMaps-Examples/7590b7d76f2757dc6c9ea636b3f2dbc50758a0c8/src/com/teamdev/jxmaps/examples/res/to.png --------------------------------------------------------------------------------