]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/function/SetLineWidth.java
Version 18.6, December 2016
[GpsPrune.git] / tim / prune / function / SetLineWidth.java
1 package tim.prune.function;
2
3 import tim.prune.App;
4 import tim.prune.DataSubscriber;
5 import tim.prune.UpdateMessageBroker;
6 import tim.prune.config.Config;
7
8 /**
9  * Function to set the width with which lines are drawn
10  */
11 public class SetLineWidth extends SingleNumericParameterFunction
12 {
13
14         /**
15          * Constructor
16          * @param inApp App object
17          */
18         public SetLineWidth(App inApp) {
19                 super(inApp, 1, 4);
20         }
21
22         /** @return name key */
23         public String getNameKey() {
24                 return "function.setlinewidth";
25         }
26
27         /** @return description key */
28         public String getDescriptionKey() {
29                 return "dialog.setlinewidth.text";
30         }
31
32         /** @return the current value to display */
33         public int getCurrentParamValue() {
34                 return Config.getConfigInt(Config.KEY_LINE_WIDTH);
35         }
36
37         /**
38          * Run function
39          */
40         public void begin()
41         {
42                 // Not required, because this function is started from a ChooseSingleParameter function
43                 // and goes directly to the completeFunction method.
44         }
45
46         /**
47          * Complete the function using the given line width parameter
48          */
49         public void completeFunction(int inLineWidth)
50         {
51                 final int currLineWidth = Config.getConfigInt(Config.KEY_LINE_WIDTH);
52                 if (inLineWidth >= 1 && inLineWidth <= 4 && inLineWidth != currLineWidth)
53                 {
54                         Config.setConfigInt(Config.KEY_LINE_WIDTH, inLineWidth);
55                         UpdateMessageBroker.informSubscribers(DataSubscriber.SELECTION_CHANGED);
56                 }
57         }
58 }