How to rotate a mapview on java swing?

104 views Asked by At

I am trying to make a map app on windows desktop. I am using the mapsforge library, but it does not have a rotation class. What I want to know is how to rotate JFrame or mapview itself.

This is the code of the main class.

private static JFrame createJFrame(final MapView mapView) {
    final PreferencesFacade preferencesFacade = new JavaPreferences(Preferences.userNodeForPackage(Main.class));

    final JFrame frame = new JFrame();
    frame.setLayout(new BorderLayout(0, 0));

    /*JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new GridLayout(2, 2));
    centerPanel.add(mapView);
    centerPanel.add(new JPanel());
    centerPanel.add(new JPanel());
    centerPanel.add(new JPanel());*/

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    frame.setUndecorated(true);
    
    frame.add(list, BorderLayout.EAST);
    frame.add(mapView, BorderLayout.CENTER);
    frame.pack();
    frame.setSize(new Dimension(1366, 700));
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            int result = JOptionPane.showConfirmDialog(frame, MESSAGE, TITLE, JOptionPane.YES_NO_OPTION);
            if (result == JOptionPane.YES_OPTION) {
                mapView.getModel().save(preferencesFacade);
                mapView.destroyAll();
                AwtGraphicFactory.clearResourceMemoryCache();
                frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            }
        }

    

    

I desperately need a way to rotate the map in this code.

0

There are 0 answers