source: josm/trunk/src/org/openstreetmap/josm/gui/preferences/display/DrawingPreference.java@ 9778

Last change on this file since 9778 was 9778, checked in by bastiK, 8 years ago

see #12507 - fix mouse wheel scrolling at some places

  • Property svn:eol-style set to native
File size: 10.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.preferences.display;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.GridBagLayout;
7import java.awt.event.ActionEvent;
8import java.awt.event.ActionListener;
9
10import javax.swing.BorderFactory;
11import javax.swing.Box;
12import javax.swing.JCheckBox;
13import javax.swing.JLabel;
14import javax.swing.JPanel;
15import javax.swing.JScrollPane;
16
17import org.openstreetmap.josm.Main;
18import org.openstreetmap.josm.actions.ExpertToggleAction;
19import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
20import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
21import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
22import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
23import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
24import org.openstreetmap.josm.gui.util.GuiHelper;
25import org.openstreetmap.josm.tools.GBC;
26
27/**
28 * Map drawing preferences.
29 */
30public class DrawingPreference implements SubPreferenceSetting {
31
32 /**
33 * Factory used to create a new {@code DrawingPreference}.
34 */
35 public static class Factory implements PreferenceSettingFactory {
36 @Override
37 public PreferenceSetting createPreferenceSetting() {
38 return new DrawingPreference();
39 }
40 }
41
42 private GPXSettingsPanel gpxPanel;
43 private final JCheckBox directionHint = new JCheckBox(tr("Draw Direction Arrows"));
44 private final JCheckBox headArrow = new JCheckBox(tr("Only on the head of a way."));
45 private final JCheckBox onewayArrow = new JCheckBox(tr("Draw oneway arrows."));
46 private final JCheckBox segmentOrderNumber = new JCheckBox(tr("Draw segment order numbers"));
47 private final JCheckBox sourceBounds = new JCheckBox(tr("Draw boundaries of downloaded data"));
48 private final JCheckBox virtualNodes = new JCheckBox(tr("Draw virtual nodes in select mode"));
49 private final JCheckBox inactive = new JCheckBox(tr("Draw inactive layers in other color"));
50 private final JCheckBox discardableKeys = new JCheckBox(tr("Display discardable keys"));
51
52 // Options that affect performance
53 private final JCheckBox useHighlighting = new JCheckBox(tr("Highlight target ways and nodes"));
54 private final JCheckBox drawHelperLine = new JCheckBox(tr("Draw rubber-band helper line"));
55 private final JCheckBox useAntialiasing = new JCheckBox(tr("Smooth map graphics (antialiasing)"));
56 private final JCheckBox useWireframeAntialiasing = new JCheckBox(tr("Smooth map graphics in wireframe mode (antialiasing)"));
57 private final JCheckBox outlineOnly = new JCheckBox(tr("Draw only outlines of areas"));
58
59 @Override
60 public void addGui(PreferenceTabbedPane gui) {
61 gpxPanel = new GPXSettingsPanel();
62 gui.addValidationListener(gpxPanel);
63 JPanel panel = gpxPanel;
64
65 JScrollPane scrollpane = new JScrollPane(panel);
66 scrollpane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
67 GuiHelper.setDefaultIncrement(scrollpane);
68 gui.getDisplayPreference().addSubTab(this, tr("GPS Points"), scrollpane);
69 panel = new JPanel(new GridBagLayout());
70 panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
71
72 // directionHint
73 directionHint.addActionListener(new ActionListener() {
74 @Override
75 public void actionPerformed(ActionEvent e) {
76 if (directionHint.isSelected()) {
77 headArrow.setSelected(Main.pref.getBoolean("draw.segment.head_only", false));
78 } else {
79 headArrow.setSelected(false);
80 }
81 headArrow.setEnabled(directionHint.isSelected());
82 }
83 });
84 directionHint.setToolTipText(tr("Draw direction hints for way segments."));
85 directionHint.setSelected(Main.pref.getBoolean("draw.segment.direction", false));
86
87 // only on the head of a way
88 headArrow.setToolTipText(tr("Only on the head of a way."));
89 headArrow.setSelected(Main.pref.getBoolean("draw.segment.head_only", false));
90 headArrow.setEnabled(directionHint.isSelected());
91
92 // draw oneway arrows
93 onewayArrow.setToolTipText(tr("Draw arrows in the direction of oneways and other directed features."));
94 onewayArrow.setSelected(Main.pref.getBoolean("draw.oneway", true));
95
96 // segment order number
97 segmentOrderNumber.setToolTipText(tr("Draw the order numbers of all segments within their way."));
98 segmentOrderNumber.setSelected(Main.pref.getBoolean("draw.segment.order_number", false));
99
100 // downloaded area
101 sourceBounds.setToolTipText(tr("Draw the boundaries of data loaded from the server."));
102 sourceBounds.setSelected(Main.pref.getBoolean("draw.data.downloaded_area", true));
103
104 // virtual nodes
105 virtualNodes.setToolTipText(tr("Draw virtual nodes in select mode for easy way modification."));
106 virtualNodes.setSelected(Main.pref.getInteger("mappaint.node.virtual-size", 8) != 0);
107
108 // background layers in inactive color
109 inactive.setToolTipText(tr("Draw the inactive data layers in a different color."));
110 inactive.setSelected(Main.pref.getBoolean("draw.data.inactive_color", true));
111
112 // antialiasing
113 useAntialiasing.setToolTipText(tr("Apply antialiasing to the map view resulting in a smoother appearance."));
114 useAntialiasing.setSelected(Main.pref.getBoolean("mappaint.use-antialiasing", true));
115
116 // wireframe mode antialiasing
117 useWireframeAntialiasing.setToolTipText(tr("Apply antialiasing to the map view in wireframe mode resulting in a smoother appearance."));
118 useWireframeAntialiasing.setSelected(Main.pref.getBoolean("mappaint.wireframe.use-antialiasing", false));
119
120 // highlighting
121 useHighlighting.setToolTipText(tr("Hightlight target nodes and ways while drawing or selecting"));
122 useHighlighting.setSelected(Main.pref.getBoolean("draw.target-highlight", true));
123
124 drawHelperLine.setToolTipText(tr("Draw rubber-band helper line"));
125 drawHelperLine.setSelected(Main.pref.getBoolean("draw.helper-line", true));
126
127 // outlineOnly
128 outlineOnly.setToolTipText(tr("This option suppresses the filling of areas, overriding anything specified in the selected style."));
129 outlineOnly.setSelected(Main.pref.getBoolean("draw.data.area_outline_only", false));
130
131 // discardable keys
132 discardableKeys.setToolTipText(tr("Display keys which have been deemed uninteresting to the point that they can be silently removed."));
133 discardableKeys.setSelected(Main.pref.getBoolean("display.discardable-keys", false));
134
135 JLabel performanceLabel = new JLabel(tr("Options that affect drawing performance"));
136
137 panel.add(new JLabel(tr("Segment drawing options")),
138 GBC.eop().insets(5, 10, 0, 0));
139 panel.add(directionHint, GBC.eop().insets(20, 0, 0, 0));
140 panel.add(headArrow, GBC.eop().insets(40, 0, 0, 0));
141 panel.add(onewayArrow, GBC.eop().insets(20, 0, 0, 0));
142 panel.add(segmentOrderNumber, GBC.eop().insets(20, 0, 0, 0));
143
144 panel.add(new JLabel(tr("Select and draw mode options")),
145 GBC.eop().insets(5, 10, 0, 0));
146 panel.add(virtualNodes, GBC.eop().insets(20, 0, 0, 0));
147 panel.add(drawHelperLine, GBC.eop().insets(20, 0, 0, 0));
148
149 panel.add(performanceLabel, GBC.eop().insets(5, 10, 0, 0));
150 panel.add(useAntialiasing, GBC.eop().insets(20, 0, 0, 0));
151 panel.add(useWireframeAntialiasing, GBC.eop().insets(20, 0, 0, 0));
152 panel.add(useHighlighting, GBC.eop().insets(20, 0, 0, 0));
153 panel.add(outlineOnly, GBC.eol().insets(20, 0, 0, 0));
154
155 panel.add(new JLabel(tr("Other options")),
156 GBC.eop().insets(5, 10, 0, 0));
157 panel.add(sourceBounds, GBC.eop().insets(20, 0, 0, 0));
158 panel.add(inactive, GBC.eop().insets(20, 0, 0, 0));
159 panel.add(discardableKeys, GBC.eop().insets(20, 0, 0, 0));
160
161 ExpertToggleAction.addVisibilitySwitcher(performanceLabel);
162 ExpertToggleAction.addVisibilitySwitcher(useAntialiasing);
163 ExpertToggleAction.addVisibilitySwitcher(useWireframeAntialiasing);
164 ExpertToggleAction.addVisibilitySwitcher(useHighlighting);
165 ExpertToggleAction.addVisibilitySwitcher(outlineOnly);
166 ExpertToggleAction.addVisibilitySwitcher(discardableKeys);
167
168 panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
169 scrollpane = new JScrollPane(panel);
170 scrollpane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
171 GuiHelper.setDefaultIncrement(scrollpane);
172 gui.getDisplayPreference().addSubTab(this, tr("OSM Data"), scrollpane);
173 }
174
175 @Override
176 public boolean ok() {
177 boolean restart = gpxPanel.savePreferences();
178 Main.pref.put("draw.data.area_outline_only", outlineOnly.isSelected());
179 Main.pref.put("draw.segment.direction", directionHint.isSelected());
180 Main.pref.put("draw.segment.head_only", headArrow.isSelected());
181 Main.pref.put("draw.oneway", onewayArrow.isSelected());
182 Main.pref.put("draw.segment.order_number", segmentOrderNumber.isSelected());
183 Main.pref.put("draw.data.downloaded_area", sourceBounds.isSelected());
184 Main.pref.put("draw.data.inactive_color", inactive.isSelected());
185 Main.pref.put("mappaint.use-antialiasing", useAntialiasing.isSelected());
186 Main.pref.put("mappaint.wireframe.use-antialiasing", useWireframeAntialiasing.isSelected());
187 Main.pref.put("draw.target-highlight", useHighlighting.isSelected());
188 Main.pref.put("draw.helper-line", drawHelperLine.isSelected());
189 Main.pref.put("display.discardable-keys", discardableKeys.isSelected());
190 int vn = Main.pref.getInteger("mappaint.node.virtual-size", 8);
191 if (virtualNodes.isSelected()) {
192 if (vn < 1) {
193 vn = 8;
194 }
195 } else {
196 vn = 0;
197 }
198 Main.pref.putInteger("mappaint.node.virtual-size", vn);
199 return restart;
200 }
201
202 @Override
203 public boolean isExpert() {
204 return false;
205 }
206
207 @Override
208 public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
209 return gui.getDisplayPreference();
210 }
211}
Note: See TracBrowser for help on using the repository browser.