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

Last change on this file since 4270 was 4270, checked in by stoecker, 13 years ago

fix #6629 - patch by akks fixed by me - improve settings handling for individual GPX tracks

  • Property svn:eol-style set to native
File size: 6.6 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.gui.preferences;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5import static org.openstreetmap.josm.tools.I18n.trc;
6
7import java.awt.Dimension;
8import java.awt.GridBagLayout;
9import java.awt.event.ActionEvent;
10import java.awt.event.ActionListener;
11
12import javax.swing.BorderFactory;
13import javax.swing.Box;
14import javax.swing.ButtonGroup;
15import javax.swing.JCheckBox;
16import javax.swing.JComboBox;
17import javax.swing.JLabel;
18import javax.swing.JPanel;
19import javax.swing.JRadioButton;
20import javax.swing.JScrollPane;
21import javax.swing.JTextField;
22import javax.swing.event.ChangeEvent;
23import javax.swing.event.ChangeListener;
24
25import org.openstreetmap.josm.Main;
26import org.openstreetmap.josm.tools.GBC;
27
28public class DrawingPreference implements PreferenceSetting {
29
30 public static class Factory implements PreferenceSettingFactory {
31 public PreferenceSetting createPreferenceSetting() {
32 return new DrawingPreference();
33 }
34 }
35
36 private GPXSettingsPanel gpxPanel;
37 private JCheckBox directionHint = new JCheckBox(tr("Draw Direction Arrows"));
38 private JCheckBox headArrow = new JCheckBox(tr("Only on the head of a way."));
39 private JCheckBox onewayArrow = new JCheckBox(tr("Draw oneway arrows."));
40 private JCheckBox segmentOrderNumber = new JCheckBox(tr("Draw segment order numbers"));
41 private JCheckBox sourceBounds = new JCheckBox(tr("Draw boundaries of downloaded data"));
42 private JCheckBox virtualNodes = new JCheckBox(tr("Draw virtual nodes in select mode"));
43 private JCheckBox inactive = new JCheckBox(tr("Draw inactive layers in other color"));
44 private JCheckBox useAntialiasing = new JCheckBox(tr("Smooth map graphics (antialiasing)"));
45 private JCheckBox outlineOnly = new JCheckBox(tr("Draw only outlines of areas"));
46
47 public void addGui(PreferenceTabbedPane gui) {
48 gui.display.setPreferredSize(new Dimension(400,600));
49 gpxPanel = new GPXSettingsPanel();
50 JPanel panel = gpxPanel;
51
52 JScrollPane scrollpane = new JScrollPane(panel);
53 scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
54 gui.displaycontent.addTab(tr("GPS Points"), scrollpane);
55 panel = new JPanel(new GridBagLayout());
56 panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
57
58 // directionHint
59 directionHint.addActionListener(new ActionListener(){
60 public void actionPerformed(ActionEvent e) {
61 if (directionHint.isSelected()){
62 headArrow.setSelected(Main.pref.getBoolean("draw.segment.head_only", false));
63 }else{
64 headArrow.setSelected(false);
65 }
66 headArrow.setEnabled(directionHint.isSelected());
67 }
68 });
69 directionHint.setToolTipText(tr("Draw direction hints for way segments."));
70 directionHint.setSelected(Main.pref.getBoolean("draw.segment.direction", false));
71 panel.add(directionHint, GBC.eop().insets(20,0,0,0));
72
73 // only on the head of a way
74 headArrow.setToolTipText(tr("Only on the head of a way."));
75 headArrow.setSelected(Main.pref.getBoolean("draw.segment.head_only", false));
76 headArrow.setEnabled(directionHint.isSelected());
77 panel.add(headArrow, GBC.eop().insets(40, 0, 0, 0));
78
79 // draw oneway arrows
80 onewayArrow.setToolTipText(tr("Draw arrows in the direction of oneways and other directed features."));
81 onewayArrow.setSelected(Main.pref.getBoolean("draw.oneway", true));
82 panel.add(onewayArrow, GBC.eop().insets(20,0,0,0));
83
84 // segment order number
85 segmentOrderNumber.setToolTipText(tr("Draw the order numbers of all segments within their way."));
86 segmentOrderNumber.setSelected(Main.pref.getBoolean("draw.segment.order_number", false));
87 panel.add(segmentOrderNumber, GBC.eop().insets(20,0,0,0));
88
89 // antialiasing
90 useAntialiasing.setToolTipText(tr("Apply antialiasing to the map view resulting in a smoother appearance."));
91 useAntialiasing.setSelected(Main.pref.getBoolean("mappaint.use-antialiasing", true));
92 panel.add(useAntialiasing, GBC.eop().insets(20,0,0,0));
93
94 // downloaded area
95 sourceBounds.setToolTipText(tr("Draw the boundaries of data loaded from the server."));
96 sourceBounds.setSelected(Main.pref.getBoolean("draw.data.downloaded_area", true));
97 panel.add(sourceBounds, GBC.eop().insets(20,0,0,0));
98
99 // virtual nodes
100 virtualNodes.setToolTipText(tr("Draw virtual nodes in select mode for easy way modification."));
101 virtualNodes.setSelected(Main.pref.getInteger("mappaint.node.virtual-size", 8) != 0);
102 panel.add(virtualNodes, GBC.eop().insets(20,0,0,0));
103
104 // background layers in inactive color
105 inactive.setToolTipText(tr("Draw the inactive data layers in a different color."));
106 inactive.setSelected(Main.pref.getBoolean("draw.data.inactive_color", true));
107 panel.add(inactive, GBC.eop().insets(20,0,0,0));
108
109 // outlineOnly
110 outlineOnly.setSelected(Main.pref.getBoolean("draw.data.area_outline_only", false));
111 outlineOnly.setToolTipText(tr("This option suppresses the filling of areas, overriding anything specified in the selected style."));
112 panel.add(outlineOnly, GBC.eol().insets(20,0,0,5));
113
114 panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
115 scrollpane = new JScrollPane(panel);
116 scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
117 gui.displaycontent.addTab(tr("OSM Data"), scrollpane);
118 }
119
120 public boolean ok() {
121 gpxPanel.savePreferences();
122 Main.pref.put("draw.data.area_outline_only", outlineOnly.isSelected());
123 Main.pref.put("draw.segment.direction", directionHint.isSelected());
124 Main.pref.put("draw.segment.head_only", headArrow.isSelected());
125 Main.pref.put("draw.oneway", onewayArrow.isSelected());
126 Main.pref.put("draw.segment.order_number", segmentOrderNumber.isSelected());
127 Main.pref.put("draw.data.downloaded_area", sourceBounds.isSelected());
128 Main.pref.put("draw.data.inactive_color", inactive.isSelected());
129 Main.pref.put("mappaint.use-antialiasing", useAntialiasing.isSelected());
130 int vn = Main.pref.getInteger("mappaint.node.virtual-size", 8);
131 if (virtualNodes.isSelected()) {
132 if (vn < 1) {
133 vn = 8;
134 }
135 }
136 else {
137 vn = 0;
138 }
139 Main.pref.putInteger("mappaint.node.virtual-size", vn);
140 return false;
141 }
142}
Note: See TracBrowser for help on using the repository browser.