source: osm/applications/editors/josm/plugins/smed2/src/panels/ShowFrame.java@ 30317

Last change on this file since 30317 was 30285, checked in by malcolmh, 11 years ago

save

File size: 1.8 KB
Line 
1/* Copyright 2014 Malcolm Herring
2 *
3 * This is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License.
6 *
7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.
8 */
9
10package panels;
11
12import java.awt.Color;
13import java.awt.Graphics;
14import java.awt.Graphics2D;
15import java.awt.geom.Point2D;
16import java.util.ArrayList;
17
18import javax.swing.JFrame;
19import javax.swing.JPanel;
20
21import org.openstreetmap.josm.data.osm.OsmPrimitive;
22
23import render.MapContext;
24import render.Renderer;
25import s57.S57map;
26import s57.S57map.*;
27
28public class ShowFrame extends JFrame {
29
30 S57map showMap;
31 Picture picture;
32
33 class Picture extends JPanel implements MapContext {
34
35 public void drawPicture(OsmPrimitive osm, S57map map) {
36 long id;
37 Feature feature;
38
39 id = osm.getUniqueId();
40 feature = map.index.get(id);
41 showMap = new S57map();
42 showMap.nodes = map.nodes;
43 showMap.edges = map.edges;
44 showMap.index = map.index;
45 if (feature != null) {
46 showMap.features.put(feature.type, new ArrayList<Feature>());
47 showMap.features.get(feature.type).add(feature);
48 }
49 repaint();
50 }
51
52 public void paintComponent(Graphics g) {
53 Graphics2D g2 = (Graphics2D)g;
54 g2.setBackground(new Color(0xb5d0d0));
55 g2.clearRect(0, 0, 300, 300);
56 Renderer.reRender(g2, 16, 32, showMap, this);
57 }
58
59 public Point2D getPoint(Snode coord) {
60 return new Point2D.Double(150, 150);
61 }
62
63 public double mile(Feature feature) {
64 return 1000;
65 }
66 }
67
68 public ShowFrame(String title) {
69 super(title);
70 picture = new Picture();
71 picture.setVisible(true);
72 add(picture);
73 pack();
74 }
75
76 public void showFeature(OsmPrimitive osm, S57map map) {
77 picture.drawPicture(osm, map);
78 }
79
80
81}
Note: See TracBrowser for help on using the repository browser.