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