| 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 render.MapContext;
|
|---|
| 15 | import render.Renderer;
|
|---|
| 16 | import s57.S57map;
|
|---|
| 17 | import s57.S57map.*;
|
|---|
| 18 |
|
|---|
| 19 | public class ShowFrame extends JFrame {
|
|---|
| 20 |
|
|---|
| 21 | S57map showMap;
|
|---|
| 22 | Picture picture;
|
|---|
| 23 |
|
|---|
| 24 | class Picture extends JPanel implements MapContext {
|
|---|
| 25 |
|
|---|
| 26 | public void drawPicture(OsmPrimitive osm, S57map map) {
|
|---|
| 27 | long id;
|
|---|
| 28 | Feature feature;
|
|---|
| 29 |
|
|---|
| 30 | id = osm.getUniqueId();
|
|---|
| 31 | feature = map.index.get(id);
|
|---|
| 32 | showMap = new S57map();
|
|---|
| 33 | showMap.nodes = map.nodes;
|
|---|
| 34 | showMap.edges = map.edges;
|
|---|
| 35 | showMap.index = map.index;
|
|---|
| 36 | if (feature != null) {
|
|---|
| 37 | showMap.features.put(feature.type, new ArrayList<Feature>());
|
|---|
| 38 | showMap.features.get(feature.type).add(feature);
|
|---|
| 39 | }
|
|---|
| 40 | repaint();
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | public void paintComponent(Graphics g) {
|
|---|
| 44 | Graphics2D g2 = (Graphics2D)g;
|
|---|
| 45 | g2.setBackground(new Color(0xb5d0d0));
|
|---|
| 46 | g2.clearRect(0, 0, 300, 300);
|
|---|
| 47 | Renderer.reRender(g2, 16, 32, showMap, this);
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | public Point2D getPoint(Snode coord) {
|
|---|
| 51 | return new Point2D.Double(150, 150);
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | public double mile(Feature feature) {
|
|---|
| 55 | return 1000;
|
|---|
| 56 | }
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | public ShowFrame(String title) {
|
|---|
| 60 | super(title);
|
|---|
| 61 | picture = new Picture();
|
|---|
| 62 | picture.setVisible(true);
|
|---|
| 63 | add(picture);
|
|---|
| 64 | pack();
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | public void showFeature(OsmPrimitive osm, S57map map) {
|
|---|
| 68 | picture.drawPicture(osm, map);
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 | }
|
|---|