1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.gui.preferences;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.Dimension;
|
---|
7 | import java.awt.event.ActionEvent;
|
---|
8 | import java.awt.event.ActionListener;
|
---|
9 | import java.awt.GridBagLayout;
|
---|
10 |
|
---|
11 | import javax.swing.BorderFactory;
|
---|
12 | import javax.swing.JCheckBox;
|
---|
13 | import javax.swing.JLabel;
|
---|
14 | import javax.swing.JTextField;
|
---|
15 | import javax.swing.JScrollPane;
|
---|
16 | import javax.swing.JPanel;
|
---|
17 | import javax.swing.Box;
|
---|
18 |
|
---|
19 | import org.openstreetmap.josm.Main;
|
---|
20 | import org.openstreetmap.josm.tools.GBC;
|
---|
21 |
|
---|
22 | public class DrawingPreference implements PreferenceSetting {
|
---|
23 |
|
---|
24 | private JCheckBox drawRawGpsLines = new JCheckBox(tr("Draw lines between raw gps points."));
|
---|
25 | private JTextField drawRawGpsMaxLineLength = new JTextField(8);
|
---|
26 | private JCheckBox forceRawGpsLines = new JCheckBox(tr("Force lines if no segments imported."));
|
---|
27 | private JCheckBox largeGpsPoints = new JCheckBox(tr("Draw large GPS points."));
|
---|
28 | private JCheckBox colorTracks = new JCheckBox(tr("Color tracks by velocity."));
|
---|
29 | private JCheckBox directionHint = new JCheckBox(tr("Draw Direction Arrows"));
|
---|
30 | private JCheckBox drawGpsArrows = new JCheckBox(tr("Draw Direction Arrows"));
|
---|
31 | private JCheckBox drawGpsArrowsFast = new JCheckBox(tr("Fast drawing (looks uglier)"));
|
---|
32 | private JTextField drawGpsArrowsMinDist = new JTextField(8);
|
---|
33 | private JCheckBox interestingDirections = new JCheckBox(tr("Only interesting direction hints (e.g. with oneway tag)."));
|
---|
34 | private JCheckBox segmentOrderNumber = new JCheckBox(tr("Draw segment order numbers"));
|
---|
35 | private JCheckBox sourceBounds = new JCheckBox(tr("Draw boundaries of downloaded data"));
|
---|
36 | private JCheckBox virtualNodes = new JCheckBox(tr("Draw virtual nodes in select mode"));
|
---|
37 | private JCheckBox inactive = new JCheckBox(tr("Draw inactive layers in other color"));
|
---|
38 | private JCheckBox useAntialiasing = new JCheckBox(tr("Smooth map graphics (antialiasing)"));
|
---|
39 |
|
---|
40 | public void addGui(PreferenceDialog gui) {
|
---|
41 | gui.display.setPreferredSize(new Dimension(400,600));
|
---|
42 | JPanel panel = new JPanel(new GridBagLayout());
|
---|
43 | panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
44 |
|
---|
45 | // drawRawGpsLines
|
---|
46 | drawRawGpsLines.addActionListener(new ActionListener(){
|
---|
47 | public void actionPerformed(ActionEvent e) {
|
---|
48 | forceRawGpsLines.setEnabled(drawRawGpsLines.isSelected());
|
---|
49 | drawRawGpsMaxLineLength.setEnabled(drawRawGpsLines.isSelected());
|
---|
50 | drawGpsArrows.setEnabled(drawRawGpsLines.isSelected());
|
---|
51 | drawGpsArrowsFast.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled());
|
---|
52 | drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled());
|
---|
53 | colorTracks.setEnabled(drawRawGpsLines.isSelected());
|
---|
54 | }
|
---|
55 | });
|
---|
56 | drawRawGpsLines.setSelected(Main.pref.getBoolean("draw.rawgps.lines"));
|
---|
57 | drawRawGpsLines.setToolTipText(tr("If your gps device draw too few lines, select this to draw lines along your way."));
|
---|
58 | panel.add(drawRawGpsLines, GBC.eol().insets(20,0,0,0));
|
---|
59 |
|
---|
60 | // drawRawGpsMaxLineLength
|
---|
61 | drawRawGpsMaxLineLength.setText(Integer.toString(Main.pref.getInteger("draw.rawgps.max-line-length", -1)));
|
---|
62 | drawRawGpsMaxLineLength.setToolTipText(tr("Maximum length (in meters) to draw lines. Set to '-1' to draw all lines."));
|
---|
63 | drawRawGpsMaxLineLength.setEnabled(drawRawGpsLines.isSelected());
|
---|
64 | panel.add(new JLabel(tr("Maximum length (meters)")), GBC.std().insets(40,0,0,0));
|
---|
65 | panel.add(drawRawGpsMaxLineLength, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
|
---|
66 |
|
---|
67 | // forceRawGpsLines
|
---|
68 | forceRawGpsLines.setToolTipText(tr("Force drawing of lines if the imported data contain no line information."));
|
---|
69 | forceRawGpsLines.setSelected(Main.pref.getBoolean("draw.rawgps.lines.force"));
|
---|
70 | forceRawGpsLines.setEnabled(drawRawGpsLines.isSelected());
|
---|
71 | panel.add(forceRawGpsLines, GBC.eop().insets(40,0,0,0));
|
---|
72 |
|
---|
73 | // drawGpsArrows
|
---|
74 | drawGpsArrows.addActionListener(new ActionListener(){
|
---|
75 | public void actionPerformed(ActionEvent e) {
|
---|
76 | drawGpsArrowsFast.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled());
|
---|
77 | drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled());
|
---|
78 | }
|
---|
79 | });
|
---|
80 | drawGpsArrows.setToolTipText(tr("Draw direction arrows for lines, connecting GPS points."));
|
---|
81 | drawGpsArrows.setSelected(Main.pref.getBoolean("draw.rawgps.direction"));
|
---|
82 | drawGpsArrows.setEnabled(drawRawGpsLines.isSelected());
|
---|
83 | panel.add(drawGpsArrows, GBC.eop().insets(40,0,0,0));
|
---|
84 |
|
---|
85 | // drawGpsArrowsFast
|
---|
86 | drawGpsArrowsFast.setToolTipText(tr("Draw the direction arrows using table lookups instead of complex math."));
|
---|
87 | drawGpsArrowsFast.setSelected(Main.pref.getBoolean("draw.rawgps.alternatedirection"));
|
---|
88 | drawGpsArrowsFast.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled());
|
---|
89 | panel.add(drawGpsArrowsFast, GBC.eop().insets(60,0,0,0));
|
---|
90 |
|
---|
91 | // drawGpsArrowsMinDist
|
---|
92 | drawGpsArrowsMinDist.setToolTipText(tr("Don't draw arrows if they are not at least this distance away from the last one."));
|
---|
93 | drawGpsArrowsMinDist.setText(Integer.toString(Main.pref.getInteger("draw.rawgps.min-arrow-distance", 0)));
|
---|
94 | drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled());
|
---|
95 | panel.add(new JLabel(tr("Minimum distance (pixels)")), GBC.std().insets(60,0,0,0));
|
---|
96 | panel.add(drawGpsArrowsMinDist, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
|
---|
97 |
|
---|
98 | // colorTracks
|
---|
99 | colorTracks.setSelected(Main.pref.getBoolean("draw.rawgps.colors"));
|
---|
100 | colorTracks.setToolTipText(tr("Choose the hue for the track color by the velocity at that point."));
|
---|
101 | colorTracks.setEnabled(drawRawGpsLines.isSelected());
|
---|
102 | panel.add(colorTracks, GBC.eop().insets(40,0,0,0));
|
---|
103 |
|
---|
104 | // largeGpsPoints
|
---|
105 | largeGpsPoints.setSelected(Main.pref.getBoolean("draw.rawgps.large"));
|
---|
106 | largeGpsPoints.setToolTipText(tr("Draw larger dots for the GPS points."));
|
---|
107 | panel.add(largeGpsPoints, GBC.eop().insets(20,0,0,0));
|
---|
108 |
|
---|
109 | panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
|
---|
110 | JScrollPane scrollpane = new JScrollPane(panel);
|
---|
111 | scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
|
---|
112 | gui.displaycontent.addTab(tr("GPS Points"), scrollpane);
|
---|
113 | panel = new JPanel(new GridBagLayout());
|
---|
114 | panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
115 |
|
---|
116 | // directionHint
|
---|
117 | directionHint.addActionListener(new ActionListener(){
|
---|
118 | public void actionPerformed(ActionEvent e) {
|
---|
119 | if (directionHint.isSelected()){
|
---|
120 | interestingDirections.setSelected(Main.pref.getBoolean("draw.segment.relevant_directions_only"));
|
---|
121 | }else{
|
---|
122 | interestingDirections.setSelected(false);
|
---|
123 | }
|
---|
124 | interestingDirections.setEnabled(directionHint.isSelected());
|
---|
125 | }
|
---|
126 | });
|
---|
127 | directionHint.setToolTipText(tr("Draw direction hints for way segments."));
|
---|
128 | directionHint.setSelected(Main.pref.getBoolean("draw.segment.direction"));
|
---|
129 | panel.add(directionHint, GBC.eop().insets(20,0,0,0));
|
---|
130 |
|
---|
131 | // only interesting directions
|
---|
132 | interestingDirections.setToolTipText(tr("Only interesting direction hints (e.g. with oneway tag)."));
|
---|
133 | interestingDirections.setSelected(Main.pref.getBoolean("draw.segment.relevant_directions_only"));
|
---|
134 | interestingDirections.setEnabled(directionHint.isSelected());
|
---|
135 | panel.add(interestingDirections, GBC.eop().insets(40,0,0,0));
|
---|
136 |
|
---|
137 | // segment order number
|
---|
138 | segmentOrderNumber.setToolTipText(tr("Draw the order numbers of all segments within their way."));
|
---|
139 | segmentOrderNumber.setSelected(Main.pref.getBoolean("draw.segment.order_number"));
|
---|
140 | panel.add(segmentOrderNumber, GBC.eop().insets(20,0,0,0));
|
---|
141 |
|
---|
142 | // antialiasing
|
---|
143 | useAntialiasing.setToolTipText(tr("Apply antialiasing to the map view resulting in a smoother appearance."));
|
---|
144 | useAntialiasing.setSelected(Main.pref.getBoolean("mappaint.use-antialiasing"));
|
---|
145 | panel.add(useAntialiasing, GBC.eop().insets(20,0,0,0));
|
---|
146 |
|
---|
147 | // downloaded area
|
---|
148 | sourceBounds.setToolTipText(tr("Draw the boundaries of data loaded from the server."));
|
---|
149 | sourceBounds.setSelected(Main.pref.getBoolean("draw.data.downloaded_area", true));
|
---|
150 | panel.add(sourceBounds, GBC.eop().insets(20,0,0,0));
|
---|
151 |
|
---|
152 | // virtual nodes
|
---|
153 | virtualNodes.setToolTipText(tr("Draw virtual nodes in select mode for easy way modification."));
|
---|
154 | virtualNodes.setSelected(Main.pref.getInteger("mappaint.node.virtual-size", 8) != 0);
|
---|
155 | panel.add(virtualNodes, GBC.eop().insets(20,0,0,0));
|
---|
156 |
|
---|
157 | // background layers in inactive color
|
---|
158 | inactive.setToolTipText(tr("Draw the inactive data layers in a different color."));
|
---|
159 | inactive.setSelected(Main.pref.getBoolean("draw.data.inactive_color", true));
|
---|
160 | panel.add(inactive, GBC.eop().insets(20,0,0,0));
|
---|
161 |
|
---|
162 | panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
|
---|
163 | scrollpane = new JScrollPane(panel);
|
---|
164 | scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
|
---|
165 | gui.displaycontent.addTab(tr("OSM Data"), scrollpane);
|
---|
166 | }
|
---|
167 |
|
---|
168 | public void ok() {
|
---|
169 | Main.pref.put("draw.rawgps.lines", drawRawGpsLines.isSelected());
|
---|
170 | Main.pref.put("draw.rawgps.max-line-length", drawRawGpsMaxLineLength.getText());
|
---|
171 | Main.pref.put("draw.rawgps.lines.force", forceRawGpsLines.isSelected());
|
---|
172 | Main.pref.put("draw.rawgps.direction", drawGpsArrows.isSelected());
|
---|
173 | Main.pref.put("draw.rawgps.alternatedirection", drawGpsArrowsFast.isSelected());
|
---|
174 | Main.pref.put("draw.rawgps.min-arrow-distance", drawGpsArrowsMinDist.getText());
|
---|
175 | Main.pref.put("draw.rawgps.colors", colorTracks.isSelected());
|
---|
176 | Main.pref.put("draw.rawgps.large", largeGpsPoints.isSelected());
|
---|
177 | Main.pref.put("draw.segment.direction", directionHint.isSelected());
|
---|
178 | Main.pref.put("draw.segment.relevant_directions_only", interestingDirections.isSelected());
|
---|
179 | Main.pref.put("draw.segment.order_number", segmentOrderNumber.isSelected());
|
---|
180 | Main.pref.put("draw.data.downloaded_area", sourceBounds.isSelected());
|
---|
181 | Main.pref.put("draw.data.inactive_color", inactive.isSelected());
|
---|
182 | Main.pref.put("mappaint.use-antialiasing", useAntialiasing.isSelected());
|
---|
183 | int vn = Main.pref.getInteger("mappaint.node.virtual-size", 8);
|
---|
184 | if(virtualNodes.isSelected()) { if (vn < 1) vn = 8; }
|
---|
185 | else { vn = 0; }
|
---|
186 | Main.pref.put("mappaint.node.virtual-size", Integer.toString(vn));
|
---|
187 | }
|
---|
188 | }
|
---|