1 | package panels;
|
---|
2 |
|
---|
3 | import java.awt.Color;
|
---|
4 | import java.awt.Graphics;
|
---|
5 | import java.awt.Graphics2D;
|
---|
6 | import java.awt.geom.Point2D;
|
---|
7 | import java.util.ArrayList;
|
---|
8 |
|
---|
9 | import javax.swing.JFrame;
|
---|
10 | import javax.swing.JPanel;
|
---|
11 |
|
---|
12 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
13 |
|
---|
14 | import seamap.MapContext;
|
---|
15 | import seamap.Renderer;
|
---|
16 | import seamap.SeaMap;
|
---|
17 | import seamap.SeaMap.*;
|
---|
18 |
|
---|
19 | public class ShowFrame extends JFrame {
|
---|
20 |
|
---|
21 | SeaMap showMap;
|
---|
22 | Picture picture;
|
---|
23 |
|
---|
24 | class Picture extends JPanel implements MapContext {
|
---|
25 |
|
---|
26 | public void drawPicture(OsmPrimitive osm, SeaMap map) {
|
---|
27 | long id;
|
---|
28 | Feature feature;
|
---|
29 |
|
---|
30 | id = osm.getUniqueId();
|
---|
31 | feature = map.index.get(id);
|
---|
32 | showMap = new SeaMap();
|
---|
33 | showMap.nodes = map.nodes;
|
---|
34 | showMap.edges = map.edges;
|
---|
35 | showMap.areas = map.areas;
|
---|
36 | showMap.index = map.index;
|
---|
37 | if (feature != null) {
|
---|
38 | showMap.features.put(feature.type, new ArrayList<Feature>());
|
---|
39 | showMap.features.get(feature.type).add(feature);
|
---|
40 | }
|
---|
41 | repaint();
|
---|
42 | }
|
---|
43 |
|
---|
44 | public void paintComponent(Graphics g) {
|
---|
45 | Graphics2D g2 = (Graphics2D)g;
|
---|
46 | g2.setBackground(new Color(0xb5d0d0));
|
---|
47 | g2.clearRect(0, 0, 300, 300);
|
---|
48 | Renderer.reRender(g2, 16, 32, showMap, this);
|
---|
49 | }
|
---|
50 |
|
---|
51 | @Override
|
---|
52 | public Point2D getPoint(Snode coord) {
|
---|
53 | return new Point2D.Double(150, 150);
|
---|
54 | }
|
---|
55 |
|
---|
56 | public double mile(Feature feature) {
|
---|
57 | return 1000;
|
---|
58 | }
|
---|
59 | }
|
---|
60 |
|
---|
61 | public ShowFrame(String title) {
|
---|
62 | super(title);
|
---|
63 | picture = new Picture();
|
---|
64 | picture.setVisible(true);
|
---|
65 | add(picture);
|
---|
66 | pack();
|
---|
67 | }
|
---|
68 |
|
---|
69 | public void showFeature(OsmPrimitive osm, SeaMap map) {
|
---|
70 | picture.drawPicture(osm, map);
|
---|
71 | }
|
---|
72 |
|
---|
73 |
|
---|
74 | }
|
---|