OSDN Git Service

64b2e49bd9b633a5df95dfdfdefa7f6d474045b4
[importpicture/importpicture.git] / importPicture / src / osm / jp / gpx / AppParameters.java
1 package osm.jp.gpx;
2
3 import java.io.File;
4 import java.io.FileInputStream;
5 import java.io.FileNotFoundException;
6 import java.io.FileOutputStream;
7 import java.io.IOException;
8 import java.util.Properties;
9
10 @SuppressWarnings("serial")
11 public class AppParameters extends Properties {
12         static final String FILE_PATH = "AdjustTime.ini";
13         
14         // GPX出力: 時間的に間隔が開いたGPXログを別の<>セグメントに分割する。 {ON | OFF}
15         public static String GPX_GPXSPLIT = "GPX.gpxSplit";
16         
17         // EXIF出力: 画像ファイルのEXIF情報を変更する {ON | OFF}
18         public static String EXIF_GPXSPLIT = "EXIF.noEXIF";
19         
20         public AppParameters() throws FileNotFoundException, IOException {
21                 super();
22                 syncFile();
23         }
24
25         public AppParameters(Properties defaults) throws FileNotFoundException, IOException {
26                 super(defaults);
27                 syncFile();
28         }
29         
30         void syncFile() throws FileNotFoundException, IOException {
31                 boolean update = false;
32                 
33                 File file = new File(FILE_PATH);
34                 if (file.exists()) {
35                         update = true;
36                 }
37                 else {
38                         // ファイルがあれば、その内容をロードする。
39                         this.load(new FileInputStream(file));
40                 }
41                 
42                 //------------------------------------------------
43                 // GPX出力: 時間的に間隔が開いたGPXログを別の<>セグメントに分割する。 {ON | OFF}
44                 String valueStr = this.getProperty(GPX_GPXSPLIT);
45                 if (valueStr == null) {
46                         update = true;
47                         this.setProperty(GPX_GPXSPLIT, "ON");           
48                 }
49
50                 //------------------------------------------------
51                 //  EXIF出力: 画像ファイルのEXIF情報を変更する {ON | OFF}
52                 valueStr = this.getProperty(EXIF_GPXSPLIT);
53                 if (valueStr == null) {
54                         update = true;
55                         this.setProperty(EXIF_GPXSPLIT, "ON");
56                 }
57
58                 if (update) {
59                         // ・ファイルがなければ新たに作る
60                         // ・項目が足りない時は書き足す。
61                         this.store(new FileOutputStream(file), "defuilt settings");     
62                 }
63         }
64 }