2013-04-23 5 views

답변

3

WaypointsWaypointPainter 통해 제공하고이 페인터를 JXMapViewer에 전달해야합니다. 기본적으로 WaypointPainterSet<Waypoint>을 허용하므로 WaypointPainerList을 허용하는 자체 클래스로 확장 할 수 있습니다.

import org.jdesktop.swingx.JXMapKit; 
import org.jdesktop.swingx.JXMapViewer; 
import org.jdesktop.swingx.mapviewer.DefaultWaypoint; 
import org.jdesktop.swingx.mapviewer.Waypoint; 
import org.jdesktop.swingx.mapviewer.WaypointPainter; 

import javax.swing.*; 
import java.util.ArrayList; 
import java.util.HashSet; 
import java.util.List; 

class CustomPainter extends WaypointPainter<JXMapViewer> { 
    public void setWaypoints(List<? extends Waypoint> waypoints) { 
     super.setWaypoints(new HashSet<Waypoint>(waypoints)); 
    } 
} 

public class Waypoints { 
    public static void main(String[] args) { 
     List<DefaultWaypoint> waypoints = new ArrayList<DefaultWaypoint>(); 
     waypoints.add(new DefaultWaypoint(51.5, 0)); 

     JXMapKit jxMapKit = new JXMapKit(); 
     jxMapKit.setDefaultProvider(JXMapKit.DefaultProviders.OpenStreetMaps); 
     CustomPainter painter = new CustomPainter(); 
     painter.setWaypoints(waypoints); 
     jxMapKit.getMainMap().setOverlayPainter(painter); 

     final JFrame frame = new JFrame(); 
     frame.add(jxMapKit); 
     frame.setSize(300, 300); 
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
     frame.setLocationRelativeTo(null); 
     SwingUtilities.invokeLater(new Runnable() { 
      @Override 
      public void run() { 
       frame.setVisible(true); 
      } 
     }); 
    } 
} 
+0

감사합니다 .... 그 작업 !!! –

관련 문제