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

Last change on this file since 31156 was 31156, checked in by malcolmh, 9 years ago

clip to map bounds

File size: 2.0 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 render.Rules.RuleSet;
27import s57.S57map;
28import s57.S57map.*;
29
30public class ShowFrame extends JFrame {
31
32 S57map showMap;
33 Picture picture;
34
35 class Picture extends JPanel implements ChartContext {
36
37 public void drawPicture(OsmPrimitive osm, S57map map) {
38 long id;
39 Feature feature;
40
41 id = osm.getUniqueId();
42 feature = map.index.get(id);
43 showMap = new S57map(true);
44 showMap.nodes = map.nodes;
45 showMap.edges = map.edges;
46 showMap.index = map.index;
47 if (feature != null) {
48 showMap.features.put(feature.type, new ArrayList<Feature>());
49 showMap.features.get(feature.type).add(feature);
50 }
51 repaint();
52 }
53
54 public void paintComponent(Graphics g) {
55 Graphics2D g2 = (Graphics2D)g;
56 g2.setBackground(new Color(0xb5d0d0));
57 Rectangle rect = new Rectangle(0, 0, 300, 300);
58 g2.clearRect(rect.x, rect.y, rect.width, rect.height);
59 Renderer.reRender(g2, RuleSet.ALL, rect, 16, 32, showMap, this);
60 }
61
62 public Point2D getPoint(Snode coord) {
63 return new Point2D.Double(150, 150);
64 }
65
66 public double mile(Feature feature) {
67 return 1000;
68 }
69 }
70
71 public ShowFrame(String title) {
72 super(title);
73 picture = new Picture();
74 picture.setVisible(true);
75 add(picture);
76 pack();
77 }
78
79 public void showFeature(OsmPrimitive osm, S57map map) {
80 picture.drawPicture(osm, map);
81 }
82
83
84}
Note: See TracBrowser for help on using the repository browser.