source: osm/applications/editors/josm/plugins/seachartedit/src/panels/ShowFrame.java@ 32226

Last change on this file since 32226 was 31569, checked in by donvip, 9 years ago

[josm_seachart] fix build

File size: 2.2 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.Rectangle;
16import java.awt.geom.Point2D;
17import java.util.ArrayList;
18
19import javax.swing.JFrame;
20import javax.swing.JPanel;
21
22import org.openstreetmap.josm.data.osm.OsmPrimitive;
23
24import render.ChartContext;
25import render.Renderer;
26import s57.S57map;
27import s57.S57map.*;
28
29public class ShowFrame extends JFrame {
30
31 S57map showMap;
32 Picture picture;
33
34 class Picture extends JPanel implements ChartContext {
35
36 public void drawPicture(OsmPrimitive osm, S57map map) {
37 long id;
38 Feature feature;
39
40 id = osm.getUniqueId();
41 feature = map.index.get(id);
42 showMap = new S57map(true);
43 showMap.nodes = map.nodes;
44 showMap.edges = map.edges;
45 showMap.index = map.index;
46 if (feature != null) {
47 showMap.features.put(feature.type, new ArrayList<Feature>());
48 showMap.features.get(feature.type).add(feature);
49 }
50 repaint();
51 }
52
53 public void paintComponent(Graphics g) {
54 Graphics2D g2 = (Graphics2D)g;
55 g2.setBackground(new Color(0xb5d0d0));
56 Rectangle rect = new Rectangle(0, 0, 300, 300);
57 g2.clearRect(rect.x, rect.y, rect.width, rect.height);
58 Renderer.reRender(g2, rect, 16, 32, showMap, this);
59 }
60
61 public Point2D getPoint(Snode coord) {
62 return new Point2D.Double(150, 150);
63 }
64
65 public double mile(Feature feature) {
66 return 1000;
67 }
68
69 @Override
70 public boolean clip() {
71 // TODO Auto-generated method stub
72 return false;
73 }
74
75 @Override
76 public Color background() {
77 // TODO Auto-generated method stub
78 return null;
79 }
80
81 @Override
82 public RuleSet ruleset() {
83 // TODO Auto-generated method stub
84 return null;
85 }
86 }
87
88 public ShowFrame(String title) {
89 super(title);
90 picture = new Picture();
91 picture.setVisible(true);
92 add(picture);
93 pack();
94 }
95
96 public void showFeature(OsmPrimitive osm, S57map map) {
97 picture.drawPicture(osm, map);
98 }
99}
Note: See TracBrowser for help on using the repository browser.