diff --git a/.gitignore b/.gitignore
index cfb80cb..2cab4bd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,22 +1,15 @@
.classpath
.project
-.externalToolBuilders/
.settings/
*.class
*.zip
*.jar
*.tar.gz
-nbbuild.xml
-Thumbs.db
-/AdjustTime.ini
/target/
-/bin/
-/build/
-/classes/
-/deploy/
-/dist/
/src/test/data/*~
/src/test/data/*.log
/src/test/data/cameradata/
/src/test/data/output
+nb*.xml
+Thumbs.db
/nbproject/
diff --git a/nbactions.xml b/nbactions.xml
deleted file mode 100644
index da01385..0000000
--- a/nbactions.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
- debug
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.5.0:exec
-
-
- -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath osm.jp.gpx.matchtime.gui.AdjustTime
- java
- true
-
-
-
- run
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.5.0:exec
-
-
- -classpath %classpath osm.jp.gpx.matchtime.gui.AdjustTime
- java
-
-
-
diff --git a/pom.xml b/pom.xml
index e26e3a2..2cb4d49 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,112 +1,123 @@
-
- 4.0.0
- AdjustTime
- AdjustTime
- 3.1.3-SNAPSHOT
+
+ 4.0.0
+ osm.surveyor
+ AdjustTerra
+ 5.3-SNAPSHOT
+
+
+ UTF-8
+ 1.8
+ ${java.version}
+ ${java.version}
+
+
+
+
+ haya4
+ Hayashi Repository
+ http://surveyor.mydns.jp/archiva/repository/haya4/
+
+ true
+
+
+ false
+
+
+
-
-
- hayashi_repository
- http://surveyor.mydns.jp/archiva/repository/hayashi_repository/
-
-
-
-
-
- hayashi_repository
- Hayashi Repository
- http://surveyor.mydns.jp/archiva/repository/hayashi_repository/
-
- true
-
-
- false
-
-
-
-
-
- hayashi_repository
- Hayashi Repository
- http://surveyor.mydns.jp/archiva/repository/hayashi_repository/
-
- true
-
-
- false
-
-
-
-
-
-
- UTF-8
- 1.8
- 1.8
-
-
- 4.12
- 1.3
-
+
+
+ org.apache.commons
+ commons-imaging
+ 1.0-alpha1
+ jar
+
+
+
+
+ org.hamcrest
+ hamcrest-core
+ 1.3
+ test
+ jar
+
+
+ junit
+ junit
+ 4.12
+ test
+ jar
+
+
+ org.apache.commons
+ commons-compress
+ 1.14
+ test
+ jar
+
+
-
-
-
- org.apache.commons
- commons-compress
- 1.14
-
+
+ install
-
-
- org.apache.commons
- commons-imaging
- 1.0-alpha1
-
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+ ${java.version}
+ ${java.version}
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 3.1.0
+
+ UTF-8
+
+
-
-
- junit
- junit
- ${junit.version}
- test
-
-
-
- org.hamcrest
- hamcrest-library
- ${hamcrest.version}
- test
-
-
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 1.6.0
+
+ osm.jp.gpx.matchtime.gui.AdjustTerra
+ false
+
+
-
-
-
-
- maven-assembly-plugin
- 3.2.0
-
-
-
- jar-with-dependencies
-
-
-
- osm.jp.gpx.matchtime.gui.AdjustTime
-
-
-
-
-
- make-assembly
- package
-
- single
-
-
-
-
-
-
+
+
+
+ maven-assembly-plugin
+ 3.2.0
+
+
+ jar-with-dependencies
+
+
+
+ osm.jp.gpx.matchtime.gui.AdjustTerra
+
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/osm/jp/gpx/AppParameters.java b/src/main/java/osm/jp/gpx/AppParameters.java
index 12a519c..8e7c610 100644
--- a/src/main/java/osm/jp/gpx/AppParameters.java
+++ b/src/main/java/osm/jp/gpx/AppParameters.java
@@ -10,16 +10,13 @@
@SuppressWarnings("serial")
public class AppParameters extends Properties {
static final String FILE_PATH = "AdjustTime.ini";
-
+
// GPX: 時間的に間隔が開いたGPXログを別のセグメントに分割する。 {ON | OFF}
public static String GPX_GPXSPLIT = "GPX.gpxSplit";
// GPX: セグメントの最初の1ノードは無視する。 {ON | OFF}
public static String GPX_NO_FIRST_NODE = "GPX.noFirstNode";
- // GPX: 生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も対象にする。 {ON | OFF}
- public static String GPX_REUSE = "GPX.REUSE";
-
// GPX: 基準時刻 {FILE_UPDATE | EXIF_TIME}
public static String GPX_BASETIME = "GPX.BASETIME";
@@ -35,7 +32,7 @@
// 対象GPXフォルダ:(GPXファイルが格納されているフォルダ)
public static String GPX_SOURCE_FOLDER = "GPX.SOURCE_FOLDER";
- // 出力フォルダ:(変換した画像ファイルとGPXファイルを出力するフォルダ)
+ // 出力フォルダ:(変換した画像ファイルを出力するフォルダ)
public static String IMG_OUTPUT_FOLDER = "IMG.OUTPUT_FOLDER";
// 出力IMG: IMG出力をする {ON | OFF}
@@ -53,9 +50,13 @@
// 出力GPX: ソースGPXのを無視する {ON | OFF}
public static String GPX_OVERWRITE_MAGVAR = "GPX.OVERWRITE_MAGVAR";
+
+ public static String GPX_REUSE = "GPX.REUSE";
- // 出力GPX: マーカーを出力する {ON | OFF}
- public static String GPX_OUTPUT_WPT = "GPX.OUTPUT_WPT";
+ //public boolean param_ImgOutputAll = false;
+ //public boolean exif = false;
+ //public boolean param_GpxSplit = false;
+ //public boolean param_GpxReuse = false;
File file;
@@ -164,14 +165,6 @@
}
//------------------------------------------------
- // GPX出力: ポイントマーカーを出力する {ON | OFF}
- valueStr = this.getProperty(GPX_OUTPUT_WPT);
- if (valueStr == null) {
- update = true;
- this.setProperty(GPX_OUTPUT_WPT, String.valueOf(false));
- }
-
- //------------------------------------------------
// GPX出力: ソースGPXのを無視する {ON | OFF}
valueStr = this.getProperty(GPX_OVERWRITE_MAGVAR);
if (valueStr == null) {
@@ -188,21 +181,52 @@
}
//------------------------------------------------
- // GPX出力: 生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も対象にする。 {ON | OFF}
- valueStr = this.getProperty(GPX_REUSE);
- if (valueStr == null) {
- update = true;
- this.setProperty(GPX_REUSE, String.valueOf(false));
- }
-
- //------------------------------------------------
// GPX: 基準時刻 {FILE_UPDATE | EXIF}
valueStr = this.getProperty(GPX_BASETIME);
if (valueStr == null) {
update = true;
- this.setProperty(GPX_BASETIME, "FILE_UPDATE");
+ setProperty(AppParameters.GPX_BASETIME, "FILE_UPDATE");
}
+ // その他のパラメータを読み取る
+ valueStr = getProperty(AppParameters.GPX_GPXSPLIT);
+ if (valueStr == null) {
+ update = true;
+ setProperty(AppParameters.GPX_GPXSPLIT, Boolean.toString(false));
+ }
+
+ valueStr = getProperty(AppParameters.GPX_NO_FIRST_NODE);
+ if (valueStr == null) {
+ update = true;
+ setProperty(AppParameters.GPX_NO_FIRST_NODE, Boolean.toString(false));
+ }
+
+ valueStr = getProperty(AppParameters.IMG_OUTPUT_ALL);
+ if (valueStr == null) {
+ update = true;
+ setProperty(AppParameters.IMG_OUTPUT_ALL, Boolean.toString(false));
+ }
+
+ valueStr = getProperty(AppParameters.GPX_OVERWRITE_MAGVAR);
+ if (valueStr == null) {
+ update = true;
+ setProperty(AppParameters.GPX_OVERWRITE_MAGVAR, Boolean.toString(false));
+ }
+
+
+ valueStr = getProperty(AppParameters.GPX_OUTPUT_SPEED);
+ if (valueStr == null) {
+ update = true;
+ setProperty(AppParameters.GPX_OUTPUT_SPEED, Boolean.toString(false));
+ }
+
+ valueStr = getProperty(AppParameters.GPX_REUSE);
+ if (valueStr == null) {
+ update = true;
+ setProperty(AppParameters.GPX_REUSE, Boolean.toString(false));
+ }
+
+
if (update) {
// ・ファイルがなければ新たに作る
// ・項目が足りない時は書き足す。
@@ -213,4 +237,108 @@
public void store() throws FileNotFoundException, IOException {
this.store(new FileOutputStream(this.file), "by AdjustTime");
}
+
+ public void printout() {
+ System.out.println(" - param: "+ AppParameters.IMG_TIME +"="+ getProperty(AppParameters.IMG_TIME) );
+ System.out.println(" - param: "+ AppParameters.IMG_BASE_FILE +"="+ getProperty(AppParameters.IMG_BASE_FILE) );
+ System.out.println(" - param: "+ AppParameters.GPX_BASETIME +"="+ getProperty(AppParameters.GPX_BASETIME) );
+ System.out.println(" - param: "+ AppParameters.IMG_SOURCE_FOLDER +"="+ getProperty(AppParameters.IMG_SOURCE_FOLDER) );
+ System.out.println(" - param: "+ AppParameters.IMG_OUTPUT_FOLDER +"="+ getProperty(AppParameters.IMG_OUTPUT_FOLDER) );
+ System.out.println(" - param: "+ AppParameters.IMG_OUTPUT +"="+ getProperty(AppParameters.IMG_OUTPUT));
+ System.out.println(" - param: "+ AppParameters.IMG_OUTPUT_ALL +"="+ isImgOutputAll());
+ System.out.println(" - param: "+ AppParameters.IMG_OUTPUT_EXIF +"= "+ isImgOutputExif());
+ System.out.println(" - param: "+ AppParameters.GPX_SOURCE_FOLDER +"="+ getProperty(AppParameters.GPX_SOURCE_FOLDER));
+ System.out.println(" - param: "+ AppParameters.GPX_OVERWRITE_MAGVAR +"="+ getProperty(AppParameters.GPX_OVERWRITE_MAGVAR));
+ System.out.println(" - param: "+ AppParameters.GPX_OUTPUT_SPEED +"="+ getProperty(AppParameters.GPX_OUTPUT_SPEED));
+ System.out.println(" - param: "+ AppParameters.GPX_GPXSPLIT +"="+ isGpxSplit());
+ System.out.println(" - param: "+ AppParameters.GPX_NO_FIRST_NODE +"="+ isGpxNoFirstNode());
+ System.out.println(" - param: "+ AppParameters.GPX_REUSE +"="+ isGpxReuse());
+ }
+
+ /**
+ * 基準時刻(ファイル更新日時 | EXIF撮影日時)
+ * @return boolean exifBase = false;
+ */
+ public boolean isExifBase() {
+ return (getProperty(AppParameters.GPX_BASETIME).equals("EXIF_TIME"));
+ }
+
+ /**
+ * IMG出力: IMGを出力する
+ * @return
+ */
+ public boolean isImgOutput() {
+ String valueStr = getProperty(AppParameters.IMG_OUTPUT);
+ if ((valueStr != null) && valueStr.equals(Boolean.toString(true))) {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isImgOutputExif() {
+ String valueStr = getProperty(AppParameters.IMG_OUTPUT_EXIF);
+ if ((valueStr != null) && valueStr.equals(Boolean.toString(true))) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * AppParameters.IMG_SOURCE_FOLDER
+ * @return new File(getProperty(AppParameters.IMG_SOURCE_FOLDER));
+ */
+ public File getImgSourceFolder() {
+ return new File(getProperty(AppParameters.IMG_SOURCE_FOLDER));
+ }
+
+ public File getGpxSourceFolder() {
+ String str = getProperty(AppParameters.GPX_SOURCE_FOLDER);
+ if (str == null) {
+ return null;
+ }
+ if (str.isEmpty()) {
+ return null;
+ }
+ return new File(str);
+ }
+
+ /**
+ * AppParameters.GPX_GPXSPLIT
+ * @return
+ */
+ public boolean isGpxSplit() {
+ return isParam(AppParameters.GPX_GPXSPLIT);
+ }
+
+ public boolean isGpxNoFirstNode() {
+ return isParam(AppParameters.GPX_NO_FIRST_NODE);
+ }
+
+ public boolean isImgOutputAll() {
+ return isParam(AppParameters.IMG_OUTPUT_ALL);
+ }
+
+ public boolean isGpxOverwriteMagvar() {
+ return isParam(AppParameters.GPX_OVERWRITE_MAGVAR);
+ }
+
+ public void setGpxOverwriteMagvar(boolean v) {
+ this.setProperty(GPX_OVERWRITE_MAGVAR, String.valueOf(v));
+ }
+
+ public boolean isGpxOutputSpeed() {
+ return isParam(AppParameters.GPX_OUTPUT_SPEED);
+ }
+
+ public boolean isGpxReuse() {
+ return isParam(AppParameters.GPX_REUSE);
+ }
+
+ boolean isParam(String item) {
+ String valueStr = getProperty(item);
+ if ((valueStr != null) && valueStr.equals(Boolean.toString(true))) {
+ return true;
+ }
+ return false;
+ }
}
diff --git a/src/main/java/osm/jp/gpx/Complementation.java b/src/main/java/osm/jp/gpx/Complementation.java
index 3eaed7a..4b5b878 100644
--- a/src/main/java/osm/jp/gpx/Complementation.java
+++ b/src/main/java/osm/jp/gpx/Complementation.java
@@ -7,8 +7,8 @@
public TagTrkpt imaTag = null;
public TagTrkpt maeTag = null;
- public static boolean param_GpxOutputSpeed = false;
- public static boolean param_GpxOverwriteMagvar = false;
+ //public static boolean param_GpxOutputSpeed = false;
+ //public static boolean param_GpxOverwriteMagvar = false;
/**
* @param imaE
@@ -27,9 +27,9 @@
* @throws ParseException
*/
public Complementation(TagTrkpt imaE, TagTrkpt maeE) throws ParseException {
- this.imaTag = new TagTrkpt(imaE.trkpt);
+ this.imaTag = imaE.clone();
if (maeE != null) {
- this.maeTag = new TagTrkpt(maeE.trkpt);
+ this.maeTag = maeE.clone();
}
}
@@ -44,7 +44,6 @@
}
catch (NumberFormatException e) {
// 数字以外ならエレメントを削除する
- imaTag.removeElement("speed");
imaTag.speedStr = null;
}
}
@@ -56,7 +55,6 @@
if (iDot > 0) {
str = str.substring(0, iDot+2);
}
- imaTag.appendElement("speed", str);
imaTag.speedStr = str;
}
}
@@ -72,7 +70,6 @@
}
catch (NumberFormatException e) {
// 数字以外ならエレメントを削除する
- imaTag.removeElement("magvar");
imaTag.magvarStr = null;
}
}
@@ -105,7 +102,6 @@
if (iDot > 0) {
str = str.substring(0, iDot);
}
- imaTag.appendElement("magvar", str);
imaTag.magvarStr = str;
}
}
diff --git a/src/main/java/osm/jp/gpx/ElementMapTRKPT.java b/src/main/java/osm/jp/gpx/ElementMapTRKPT.java
index 7d22a8e..2599ccd 100644
--- a/src/main/java/osm/jp/gpx/ElementMapTRKPT.java
+++ b/src/main/java/osm/jp/gpx/ElementMapTRKPT.java
@@ -4,14 +4,14 @@
import java.util.Date;
import java.util.TreeMap;
-import org.w3c.dom.DOMException;
-
@SuppressWarnings("serial")
public class ElementMapTRKPT extends TreeMap {
public static final long DIFF_MAE_TIME = 3000L; // before 3 secound
+ AppParameters params;
- public ElementMapTRKPT() {
+ public ElementMapTRKPT(AppParameters params) {
super(new TimeComparator());
+ this.params = params;
}
/**
@@ -27,12 +27,10 @@
*
* }
* @return keyとして登録したtime:Date
- * @throws ParseException
- * @throws DOMException
*/
- public Date put(TagTrkpt tag) throws DOMException, ParseException {
- this.put(tag.time, tag);
- return tag.time;
+ public Date put(TagTrkpt tag) {
+ this.put(tag.getTime(), tag);
+ return tag.getTime();
}
/**
@@ -52,12 +50,12 @@
// がなければ、
// 直前の位置と、現在地から進行方向を求める
// 経度(longitude)と経度から進行方向を求める
- if (Complementation.param_GpxOverwriteMagvar) {
+ if (params.isGpxOverwriteMagvar()) {
comp.complementationMagvar();
}
// 緯度・経度と時間差から速度(km/h)を求める
- if (Complementation.param_GpxOutputSpeed) {
+ if (params.isGpxOutputSpeed()) {
comp.complementationSpeed();
}
//return (TagTrkpt)(comp.imaTag.trkpt.cloneNode(true));
diff --git a/src/main/java/osm/jp/gpx/ElementMapTRKSEG.java b/src/main/java/osm/jp/gpx/ElementMapTRKSEG.java
index ca9dbc1..a3bcae0 100644
--- a/src/main/java/osm/jp/gpx/ElementMapTRKSEG.java
+++ b/src/main/java/osm/jp/gpx/ElementMapTRKSEG.java
@@ -1,119 +1,32 @@
package osm.jp.gpx;
-import java.io.File;
-import java.io.IOException;
-import java.text.ParseException;
import java.util.Date;
import java.util.TreeMap;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.*;
-import org.xml.sax.SAXException;
-
+/**
+ * GPXファイルをパースする
+ * @param gpxFile
+ * @code{
+ *
+ *
+ *
+ *
+ * 47.20000076293945
+ *
+ * 0.5
+ *
+ *
+ *
+ *
+ * }
+ */
@SuppressWarnings("serial")
public class ElementMapTRKSEG extends TreeMap {
- /**
- * TESTing
- * @param argv
- * @throws ParseException
- * @throws ParserConfigurationException
- * @throws IOException
- * @throws SAXException
- * @throws DOMException
- */
- public static void main(String[] argv) throws DOMException, SAXException, IOException, ParserConfigurationException, ParseException {
- ElementMapTRKSEG mapTRKSEG = null;
- mapTRKSEG = new ElementMapTRKSEG();
- mapTRKSEG.parse(new File("testdata/cameradata/separate.gpx"));
- mapTRKSEG.printinfo();
- }
-
public ElementMapTRKSEG() {
super(new TimeComparator());
}
/**
- * GPXファイルをパースする
- * @param gpxFile
- * @code{
- *
- *
- *
- *
- * 47.20000076293945
- *
- * 0.5
- *
- *
- *
- *
- * }
- *
- * @param gpxFile
- * @return Document
- * @throws SAXException
- * @throws IOException
- * @throws ParserConfigurationException
- * @throws DOMException
- * @throws ParseException
- */
- public Document parse(File gpxFile) throws SAXException, IOException, ParserConfigurationException, DOMException, ParseException {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- factory.setIgnoringElementContentWhitespace(true);
- factory.setIgnoringComments(true);
- factory.setValidating(true);
-
- Node gpx = builder.parse(gpxFile).getFirstChild();
- Document document = gpx.getOwnerDocument();
- NodeList nodes = gpx.getChildNodes();
- for (int i=0; i < nodes.getLength(); i++) {
- Node node2 = nodes.item(i);
- if (node2.getNodeName().equals("trk")) {
- Element trk = (Element) node2;
-
- NodeList nodes1 = trk.getChildNodes();
- for (int i1=0; i1 < nodes1.getLength(); i1++) {
- Node nodeTRKSEG = nodes1.item(i1);
- if (nodeTRKSEG.getNodeName().equals("trkseg")) {
- this.put(nodeTRKSEG);
- }
- }
- }
- }
- return document;
- }
-
- /**
- * @code{
- * 拡張put value:NodeをputするとNode内のNodeを put(key,value)する。
- * }
- * @param nodeTRKSEG
- * @throws ParseException
- * @throws DOMException
- */
- public void put(Node nodeTRKSEG) throws DOMException, ParseException {
- if (nodeTRKSEG.getNodeName().equals("trkseg")) {
- NodeList nodes2 = nodeTRKSEG.getChildNodes();
-
- ElementMapTRKPT mapTRKPT = new ElementMapTRKPT();
- for (int i2 = 0; i2 < nodes2.getLength(); i2++) {
- Node nodeTRKPT = nodes2.item(i2);
- if (nodeTRKPT.getNodeName().equals("trkpt")) {
- if (ImportPicture.param_GpxNoFirstNode && (i2 == 0)) {
- continue;
- }
- mapTRKPT.put(new TagTrkpt((Element)nodeTRKPT));
- }
- }
- this.put(mapTRKPT);
- }
- }
-
- /**
* 拡張put value:ElementMapTRKPTをputするとElementMapTRKPT内の最初のエントリのtimeを読み取ってkeyとしてthis.put(key,value)する。
* @param value
* @throws DOMException
@@ -125,15 +38,23 @@
}
}
- public void printinfo() {
- System.out.println(" +--------------------+--------------------|");
- System.out.println(" GPS logging time | First Time | Last Time |");
+ public void printheader() {
System.out.println("|--------------------------------+--------------------+--------------------|");
+ System.out.println("| GPS logging time | First Time | Last Time |");
+ System.out.println("|--------------------------------+--------------------+--------------------|");
+ }
+
+ public void printfooter() {
+ System.out.println("|--------------------------------+--------------------+--------------------|");
+ System.out.println();
+ }
+
+ public void printinfo() {
+ printheader();
for (java.util.Map.Entry map : this.entrySet()) {
ElementMapTRKPT mapTRKPT = map.getValue();
mapTRKPT.printinfo();
}
- System.out.println("|--------------------------------+--------------------+--------------------|");
- System.out.println();
+ printfooter();
}
}
diff --git a/src/main/java/osm/jp/gpx/GpxFile.java b/src/main/java/osm/jp/gpx/GpxFile.java
index bc7c306..60315e3 100644
--- a/src/main/java/osm/jp/gpx/GpxFile.java
+++ b/src/main/java/osm/jp/gpx/GpxFile.java
@@ -1,197 +1,65 @@
package osm.jp.gpx;
import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.text.ParseException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
@SuppressWarnings("serial")
public class GpxFile extends File {
- Node gpx = null;
- ElementMapTRKSEG mapTRKSEG = null;
- Document document;
+ GpxParser gpx;
+ AppParameters params;
- @SuppressWarnings("LeakingThisInConstructor")
- public GpxFile(File file) throws ParserConfigurationException, DOMException, SAXException, IOException, ParseException {
+ public GpxFile(AppParameters params, File file) throws ParserConfigurationException, SAXException, IOException, ParseException {
super(file.getParentFile(), file.getName());
-
- DocumentBuilderFactory factory = null;
- DocumentBuilder builder = null;
-
- factory = DocumentBuilderFactory.newInstance();
- builder = factory.newDocumentBuilder();
- factory.setIgnoringElementContentWhitespace(true);
- factory.setIgnoringComments(true);
- factory.setValidating(true);
-
- // GPXファイルをパースする
- mapTRKSEG = new ElementMapTRKSEG();
- document = mapTRKSEG.parse(this);
-
- // パースされた mapTRKSEG の中身を出力する
- mapTRKSEG.printinfo();
-
- // GPX file --> Node root
- gpx = builder.parse(this).getFirstChild();
+ this.params = params;
+ this.gpx = new GpxParser(params);
}
-
+
/**
- * GPX 変換出力
- * @param outDir
- * @throws FileNotFoundException
- * @throws TransformerException
+ * XMLパースを実行する
+ *
*/
- public void output(File outDir) throws FileNotFoundException, TransformerException {
- String fileName = this.getName();
- String iStr = fileName.substring(0, fileName.length() - 4);
- File outputFile = new File(outDir, iStr +"_.gpx");
- System.out.println(this.getAbsolutePath() + " => "+ outputFile.getAbsolutePath());
+ public void parse() throws ParserConfigurationException, SAXException, IOException {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setValidating(false);
- outputFile.getParentFile().mkdirs();
- DOMSource source = new DOMSource(this.gpx);
- FileOutputStream os = new FileOutputStream(outputFile);
- StreamResult result = new StreamResult(os);
- TransformerFactory transFactory = TransformerFactory.newInstance();
- Transformer transformer = transFactory.newTransformer();
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- transformer.setOutputProperty(OutputKeys.METHOD, "xml");
- transformer.transform(source, result);
+ SAXParser parser;
+ parser = factory.newSAXParser();
+ try {
+ parser.parse(this, gpx);
+ } catch (SAXParseException e) {}
- os = new FileOutputStream(outputFile);
- result = new StreamResult(os);
- transformer.transform(source, result);
+ // XMLが閉じられなかったデータを救出する
+ if (gpx.tag != null) {
+ if (gpx.tag.getTime() != null) {
+ gpx.trkpt.put(gpx.tag.clone());
+ }
+ gpx.tag = null;
+ }
+ if (gpx.trkpt.size() > 0) {
+ gpx.trkseg.put((ElementMapTRKPT)gpx.trkpt.clone());
+ gpx.trkpt.clear();
+ }
}
-
+
+ public ElementMapTRKSEG getTrksegMap() {
+ return this.gpx.trkseg;
+ }
+
/**
- * <wpt lat="35.25714922" lon="139.15490497">
- * <ele>62.099998474121094</ele>
- * <time>2012-06-11T00:44:38Z</time>
- * <name></name>
- * <link href="2012-06-11_09-44-38.jpg">
- * <text>2012-06-11_09-44-38.jpg</text>
- * </link>
- * </wpt>
- *
- * <trkpt lat="35.32123832" lon="139.56965631">
- * <ele>47.20000076293945</ele>
- * <time>2012-06-15T03:00:29Z</time>
- * </trkpt>
- *
- * @param imgDir
- * @return
- * @param iFile
- * @param timestamp
- * @param trkpt
+ * インスタンス状態の表示(parse()実行後に有効になる)
+ *
*/
- public Element createWptTag(File iFile, File imgDir, long timestamp, Element trkpt) {
- Element wpt = document.createElement("wpt");
-
- NamedNodeMap nodeMap = trkpt.getAttributes();
- if (null != nodeMap) {
- for (int j=0; j < nodeMap.getLength(); j++ ) {
- switch (nodeMap.item(j).getNodeName()) {
- case "lat":
- String lat = nodeMap.item(j).getNodeValue();
- wpt.setAttribute("lat", lat);
- break;
- case "lon":
- String lon = nodeMap.item(j).getNodeValue();
- wpt.setAttribute("lon", lon);
- break;
- }
- }
- }
-
- NodeList nodes1 = trkpt.getChildNodes();
- for (int i1=0; i1 < nodes1.getLength(); i1++) {
- Node node1 = nodes1.item(i1);
- NodeList nodes2 = node1.getChildNodes();
- switch (node1.getNodeName()) {
- case "ele":
- for (int i2=0; i2 < nodes2.getLength(); i2++) {
- Node node2 = nodes2.item(i2);
- if (node2 != null) {
- if (node2.getNodeType() == Node.TEXT_NODE) {
- String eleStr = node2.getNodeValue();
- Element eleE = document.createElement("ele");
- eleE.setTextContent(eleStr);
- wpt.appendChild(eleE);
- }
- }
- }
- break;
- case "time":
- for (int i2=0; i2 < nodes2.getLength(); i2++) {
- Node node2 = nodes2.item(i2);
- if (node2 != null) {
- if (node2.getNodeType() == Node.TEXT_NODE) {
- String timeStr = node2.getNodeValue();
- Element timeE = document.createElement("time");
- timeE.setTextContent(timeStr);
- wpt.appendChild(timeE);
- }
- }
- }
- break;
- case "magvar":
- for (int i2=0; i2 < nodes2.getLength(); i2++) {
- Node node2 = nodes2.item(i2);
- if (node2 != null) {
- if (node2.getNodeType() == Node.TEXT_NODE) {
- String magvarStr = node2.getNodeValue();
- Element magvarE = document.createElement("magvar");
- magvarE.setTextContent(magvarStr);
- wpt.appendChild(magvarE);
- }
- }
- }
- break;
- case "speed":
- for (int i2=0; i2 < nodes2.getLength(); i2++) {
- Node node2 = nodes2.item(i2);
- if (node2 != null) {
- if (node2.getNodeType() == Node.TEXT_NODE) {
- String speedStr = node2.getNodeValue();
- Element speedE = document.createElement("speed");
- speedE.setTextContent(speedStr);
- wpt.appendChild(speedE);
- }
- }
- }
- break;
- }
- }
-
- Element name = document.createElement("name");
- name.appendChild(document.createCDATASection("写真"));
- wpt.appendChild(name);
-
- Element link = document.createElement("link");
- link.setAttribute("href", ImportPicture.getShortPathName(imgDir, iFile));
- Element text = document.createElement("text");
- text.setTextContent(iFile.getName());
- link.appendChild(text);
- wpt.appendChild(link);
-
- return wpt;
+ public void printinfo() {
+ // 表示
+ System.out.println(String.format("GPX file: '%s'", getName()));
+ gpx.trkseg.printinfo();
}
}
diff --git a/src/main/java/osm/jp/gpx/GpxFolder.java b/src/main/java/osm/jp/gpx/GpxFolder.java
new file mode 100644
index 0000000..dd4af8c
--- /dev/null
+++ b/src/main/java/osm/jp/gpx/GpxFolder.java
@@ -0,0 +1,107 @@
+package osm.jp.gpx;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.xml.sax.SAXException;
+
+public class GpxFolder extends ArrayList {
+ private static final long serialVersionUID = 6178901459948163548L;
+ AppParameters params;
+
+ public GpxFolder(AppParameters params) throws ParserConfigurationException, SAXException, IOException, ParseException {
+ this.params = params;
+
+ File[] gpxfiles;
+ File gpxDir = params.getGpxSourceFolder();
+ if (gpxDir == null) {
+ // GPXファイルまたはディレクトリが存在しません。('%s')
+ throw new FileNotFoundException(String.format(ImportPicture.i18n.getString("msg.100"), "null"));
+ }
+ if (!gpxDir.exists()) {
+ // GPXファイルまたはディレクトリが存在しません。('%s')
+ throw new FileNotFoundException(String.format(ImportPicture.i18n.getString("msg.100"), gpxDir.getAbsolutePath()));
+ }
+
+ if (gpxDir.isFile()) {
+ if (accept(params, gpxDir.getName())) {
+ List fileList = new ArrayList<>();
+ fileList.add(gpxDir);
+ gpxfiles = fileList.toArray(new File[fileList.size()]);
+ }
+ else {
+ // GPXファイルまたはディレクトリが存在しません。('%s')
+ throw new FileNotFoundException(String.format(ImportPicture.i18n.getString("msg.100"), gpxDir.getAbsolutePath()));
+ }
+ }
+ else if (gpxDir.isDirectory()) {
+ // 指定されたディレクトリ内のGPXファイルすべてを対象とする
+ gpxfiles = gpxDir.listFiles(new GpxFileFilter());
+ if (gpxfiles == null) {
+ // 対象となるGPXファイルがありませんでした。('%s')
+ throw new FileNotFoundException(
+ String.format(ImportPicture.i18n.getString("msg.110"), gpxDir.getAbsolutePath())
+ );
+ }
+ if (params.isImgOutputAll() && (gpxfiles.length > 1)) {
+ // "複数のGPXファイルがあるときには、'IMG.OUTPUT_ALL'オプションは指定できません。"
+ throw new FileNotFoundException(
+ String.format(ImportPicture.i18n.getString("msg.120"))
+ );
+ }
+ }
+ else {
+ // GPXファイルまたはディレクトリが存在しません。('%s')
+ throw new FileNotFoundException(String.format(ImportPicture.i18n.getString("msg.100"), gpxDir.getAbsolutePath()));
+ }
+
+ Arrays.sort(gpxfiles, new FileSort());
+ for (File file : gpxfiles) {
+ this.add(new GpxFile(params, file));
+ }
+ }
+
+ /**
+ * 対象は '*.GPX' のみ対象とする
+ */
+ public static boolean accept(AppParameters params, String name) {
+ String filename = name.toUpperCase();
+ if (filename.endsWith(".GPX")) {
+ if (!filename.endsWith("_.GPX") || params.isGpxReuse()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * ファイル名の順序に並び替えるためのソートクラス
+ *
+ */
+ static class FileSort implements Comparator {
+ @Override
+ public int compare(File src, File target){
+ int diff = src.getName().compareTo(target.getName());
+ return diff;
+ }
+ }
+
+ /**
+ * GPXファイルフィルター
+ */
+ class GpxFileFilter implements FilenameFilter {
+ @Override
+ public boolean accept(File dir, String name) {
+ return GpxFolder.accept(params, name);
+ }
+ }
+}
diff --git a/src/main/java/osm/jp/gpx/GpxParser.java b/src/main/java/osm/jp/gpx/GpxParser.java
new file mode 100644
index 0000000..ea4c71f
--- /dev/null
+++ b/src/main/java/osm/jp/gpx/GpxParser.java
@@ -0,0 +1,151 @@
+package osm.jp.gpx;
+
+import java.text.ParseException;
+import org.xml.sax.Attributes;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * GPXファイルをパースする
+ * @param gpxFile
+ * @code{
+ *
+ *
+ *
+ *
+ * 47.20000076293945
+ *
+ * 0.5
+ *
+ *
+ *
+ *
+ * }
+ *
+ */
+public class GpxParser extends DefaultHandler {
+ StringBuffer outSb;
+ int segCnt = 0;
+ int kptCnt = 0;
+ boolean kpt = false;
+ TagTrkpt tag = null;
+ public ElementMapTRKPT trkpt;
+ public ElementMapTRKSEG trkseg = new ElementMapTRKSEG();
+
+ AppParameters params;
+
+ public GpxParser(AppParameters params) {
+ super();
+ this.params = params;
+ trkpt = new ElementMapTRKPT(params);
+ }
+
+ /**
+ * ドキュメント開始
+ */
+ public void startDocument() {
+ outSb = new StringBuffer();
+ }
+
+ /**
+ * ドキュメント終了
+ */
+ public void endDocument() {
+ }
+
+ public void startElement(String uri,String localName, String qName, Attributes atts) {
+ if(qName.equals("trkseg")){
+ segCnt++;
+ kptCnt = 0;
+ if (trkpt.size() > 0) {
+ trkpt.printinfo();
+ trkseg.put((ElementMapTRKPT) trkpt.clone());
+ trkpt.clear();
+ }
+ }
+ if(qName.equals("trkpt")){
+ kpt = true;
+ kptCnt++;
+ if (tag != null) {
+ if (tag.getTime() != null) {
+ trkpt.put(tag.clone());
+ }
+ tag = null;
+ }
+
+ Double lat = null;
+ Double lon = null;
+
+ for (int i = 0; i < atts.getLength(); i++) {
+ String aname = atts.getQName(i);
+ if (aname.equals("lat")) {
+ lat = new Double(atts.getValue(i));
+ }
+ if (aname.equals("lon")) {
+ lon = new Double(atts.getValue(i));
+ }
+ }
+
+ if ((lat != null) && (lon != null)) {
+ tag = new TagTrkpt(lat, lon);
+ }
+ }
+ if(qName.equals("ele")){
+ outSb = new StringBuffer();
+ }
+ if(qName.equals("time")){
+ outSb = new StringBuffer();
+ }
+ if(qName.equals("magvar")){
+ outSb = new StringBuffer();
+ }
+ if(qName.equals("speed")){
+ outSb = new StringBuffer();
+ }
+ }
+
+ /**
+ * 要素の終了タグ読み込み時に毎回呼ばれる
+ */
+ public void endElement(String uri,String localName,String qName) {
+ if(qName.equals("trkseg")){
+ if (trkpt.size() > 0) {
+ trkseg.put((ElementMapTRKPT) trkpt.clone());
+ trkpt.clear();
+ }
+ }
+ if(qName.equals("trkpt")){
+ kpt = false;
+ if (tag != null) {
+ if (tag.getTime() != null) {
+ trkpt.put(tag);
+ }
+ tag = null;
+ }
+ }
+ if(qName.equals("ele")){
+ tag.setEle(outSb.toString());
+ }
+ if(qName.equals("time")){
+ try {
+ tag.setTime(ImportPicture.toUTCDate(outSb.toString()));
+ } catch (ParseException e) {}
+ }
+ if(qName.equals("magvar")){
+ tag.setMagvar(outSb.toString());
+ }
+ if(qName.equals("speed")){
+ tag.setSpeed(outSb.toString());
+ }
+ outSb = new StringBuffer();
+ }
+
+ /**
+ * テキストデータ読み込み時に毎回呼ばれる
+ */
+ public void characters(char[] ch, int offset, int length) {
+ if (kpt) {
+ outSb.append(new String(ch, offset, length));
+ }
+ }
+
+ }
diff --git a/src/main/java/osm/jp/gpx/ImgFile.java b/src/main/java/osm/jp/gpx/ImgFile.java
new file mode 100644
index 0000000..c96aa53
--- /dev/null
+++ b/src/main/java/osm/jp/gpx/ImgFile.java
@@ -0,0 +1,300 @@
+package osm.jp.gpx;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.channels.FileChannel;
+import java.text.DecimalFormat;
+import java.text.ParseException;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Map;
+import java.util.TimeZone;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.commons.imaging.ImageReadException;
+import org.apache.commons.imaging.ImageWriteException;
+import org.apache.commons.imaging.Imaging;
+import org.apache.commons.imaging.common.ImageMetadata;
+import org.apache.commons.imaging.common.RationalNumber;
+import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata;
+import org.apache.commons.imaging.formats.jpeg.exif.ExifRewriter;
+import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
+import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants;
+import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants;
+import org.apache.commons.imaging.formats.tiff.write.TiffOutputDirectory;
+import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet;
+import org.xml.sax.SAXException;
+
+@SuppressWarnings("serial")
+public class ImgFile extends File {
+ boolean done = false;
+ Date imgtime = null;
+ Date gpstime = null;
+ double latitude = 0.0D;
+ double longitude = 0.0D;
+ String eleStr = "-";
+ String magvarStr = "-";
+ String speedStr = "-";
+
+ public ImgFile(File file) {
+ super(file.getParentFile(), file.getName());
+ }
+
+ public void setDone(boolean done) {
+ this.done = done;
+ }
+
+ public boolean isDone() {
+ return this.done;
+ }
+
+ /**
+ * 対象は '*.JPG' のみ対象とする
+ * @return
+ * @param name
+ */
+ public boolean isImageFile() {
+ String name = this.getName();
+ return ((name != null) && name.toUpperCase().endsWith(".JPG"));
+ }
+
+ public boolean procImageFile(AppParameters params, long delta, GpxFile gpxFile, File outDir) throws ParseException, ImageReadException, IOException, ImageWriteException, ParserConfigurationException, SAXException {
+ //ElementMapTRKSEG mapTRKSEG = gpxFile.parse();
+ boolean exifWrite = params.isImgOutputExif();
+
+ // itime <-- 画像ファイルの撮影時刻
+ // ファイルの更新日時/EXIFの撮影日時
+ imgtime = getDate(params);
+
+ // uktime <-- 画像撮影時刻に対応するGPX時刻(補正日時)
+ gpstime = new Date(imgtime.getTime() + delta);
+
+ // 時刻uktimeにおけるをtrkptに追加する
+ TagTrkpt trkptT = null;
+
+ for (Map.Entry map : gpxFile.getTrksegMap().entrySet()) {
+ ElementMapTRKPT mapTRKPT = map.getValue();
+ trkptT = mapTRKPT.getValue(gpstime);
+ if (trkptT != null) {
+ break;
+ }
+ }
+
+ if (trkptT == null) {
+ if (!params.isImgOutputAll()) {
+ return false;
+ }
+ }
+ else {
+ latitude = trkptT.lat;
+ longitude = trkptT.lon;
+
+ if (trkptT.eleStr != null) {
+ eleStr = trkptT.eleStr;
+ }
+
+ if (trkptT.magvarStr != null) {
+ magvarStr = trkptT.magvarStr;
+ }
+
+ if (trkptT.speedStr != null) {
+ speedStr = trkptT.speedStr;
+ }
+ }
+
+ outDir.mkdir();
+ if (exifWrite) {
+ exifWrite(this, gpstime, trkptT, outDir);
+ }
+ else {
+ if (params.isImgOutputAll()) {
+ // EXIFの変換を伴わない単純なファイルコピー
+ FileInputStream sStream = new FileInputStream(this);
+ FileInputStream dStream = new FileInputStream(new File(outDir, this.getName()));
+ FileChannel srcChannel = sStream.getChannel();
+ FileChannel destChannel = dStream.getChannel();
+ try {
+ srcChannel.transferTo(0, srcChannel.size(), destChannel);
+ }
+ finally {
+ srcChannel.close();
+ destChannel.close();
+ sStream.close();
+ dStream.close();
+ }
+ }
+ }
+ return true;
+ }
+
+ void exifWrite(File imageFile, Date correctedtime, TagTrkpt trkptT, File outDir) throws ImageReadException, IOException, ImageWriteException {
+ DecimalFormat yearFormatter = new DecimalFormat("0000");
+ DecimalFormat monthFormatter = new DecimalFormat("00");
+ DecimalFormat dayFormatter = new DecimalFormat("00");
+
+ TiffOutputSet outputSet = null;
+
+ ImageMetadata meta = Imaging.getMetadata(imageFile);
+ JpegImageMetadata jpegMetadata = (JpegImageMetadata)meta;
+ if (jpegMetadata != null) {
+ TiffImageMetadata exif = jpegMetadata.getExif();
+ if (exif != null) {
+ outputSet = exif.getOutputSet();
+ }
+ }
+
+ if (outputSet == null) {
+ outputSet = new TiffOutputSet();
+ }
+
+ //---- EXIF_TAG_DATE_TIME_ORIGINAL / 「撮影日時/オリジナル画像の生成日時」----
+ TiffOutputDirectory exifDir = outputSet.getOrCreateExifDirectory();
+ {
+ Calendar cal = Calendar.getInstance();
+ cal.setTimeZone(TimeZone.getTimeZone("UTC"));
+ cal.setTime(correctedtime);
+ exifDir.removeField(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
+ exifDir.add(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL, ImportPicture.toEXIFString(cal.getTime()));
+ }
+
+ //---- EXIF GPS_TIME_STAMP ----
+ TiffOutputDirectory gpsDir = outputSet.getOrCreateGPSDirectory();
+ {
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ cal.setTimeZone(TimeZone.getTimeZone("GMT+00"));
+ cal.setTime(correctedtime);
+ final String yearStr = yearFormatter.format(cal.get(Calendar.YEAR));
+ final String monthStr = monthFormatter.format(cal.get(Calendar.MONTH) + 1);
+ final String dayStr = dayFormatter.format(cal.get(Calendar.DAY_OF_MONTH));
+ final String dateStamp = yearStr +":"+ monthStr +":"+ dayStr;
+
+ gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_TIME_STAMP);
+ gpsDir.add(
+ GpsTagConstants.GPS_TAG_GPS_TIME_STAMP,
+ RationalNumber.valueOf(cal.get(Calendar.HOUR_OF_DAY)),
+ RationalNumber.valueOf(cal.get(Calendar.MINUTE)),
+ RationalNumber.valueOf(cal.get(Calendar.SECOND))
+ );
+ gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_DATE_STAMP);
+ gpsDir.add(GpsTagConstants.GPS_TAG_GPS_DATE_STAMP, dateStamp);
+ }
+
+ if (trkptT != null) {
+ //---- EXIF GPS elevation/ALTITUDE ----
+ if (trkptT.eleStr != null) {
+ final double altitude = Double.parseDouble(trkptT.eleStr);
+ gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_ALTITUDE);
+ gpsDir.add(GpsTagConstants.GPS_TAG_GPS_ALTITUDE, RationalNumber.valueOf(altitude));
+ }
+
+ //---- EXIF GPS magvar/IMG_DIRECTION ----
+ if (trkptT.magvarStr != null) {
+ final double magvar = Double.parseDouble(trkptT.magvarStr);
+ gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION);
+ gpsDir.add(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION, RationalNumber.valueOf(magvar));
+ }
+
+ //---- EXIF GPS_ ----
+ outputSet.setGPSInDegrees(trkptT.lon, trkptT.lat);
+ }
+
+ ExifRewriter rewriter = new ExifRewriter();
+ try (FileOutputStream fos = new FileOutputStream(new File(outDir, imageFile.getName()))) {
+ rewriter.updateExifMetadataLossy(imageFile, fos, outputSet);
+ }
+ }
+
+ /**
+ * 基準時刻ファイルの「更新日時」を取得する
+ * @param baseFile = new File(this.imgDir, this.params.getProperty(AppParameters.IMG_BASE_FILE));
+ * @return
+ * @throws ImageReadException
+ * @throws IOException
+ * @throws ParseException
+ */
+ Date getDate(AppParameters params) throws ImageReadException, IOException, ParseException {
+ return getDate(params, this);
+ }
+
+ /**
+ * 基準時刻ファイルの「更新日時」を取得する
+ * @param baseFile = new File(this.imgDir, this.params.getProperty(AppParameters.IMG_BASE_FILE));
+ * @return
+ * @throws ImageReadException
+ * @throws IOException
+ * @throws ParseException
+ */
+ static Date getDate(AppParameters params, File baseFile) throws ImageReadException, IOException, ParseException {
+ if (params.isExifBase()) {
+ // 基準時刻(EXIF撮影日時)
+ ImageMetadata meta = Imaging.getMetadata(baseFile);
+ JpegImageMetadata jpegMetadata = (JpegImageMetadata)meta;
+ if (jpegMetadata == null) {
+ // "'%s'にEXIF情報がありません"
+ throw new ImageReadException(
+ String.format(
+ ImportPicture.i18n.getString("msg.140"),
+ baseFile.getAbsolutePath()
+ )
+ );
+ }
+ TiffImageMetadata exif = jpegMetadata.getExif();
+ if (exif == null) {
+ // "'%s'にEXIF情報がありません"
+ throw new ImageReadException(
+ String.format(
+ ImportPicture.i18n.getString("msg.140"),
+ baseFile.getAbsolutePath()
+ )
+ );
+ }
+ String dateTimeOriginal = exif.getFieldValue(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL)[0];
+ return new Date(ImportPicture.toEXIFDate(dateTimeOriginal).getTime());
+ }
+ else {
+ // 基準時刻(ファイル更新日時)
+ return new Date(baseFile.lastModified());
+ }
+ }
+
+ /**
+ * ImgFileインスタンスの状態をTEXT化
+ * @return 1行
+ */
+ String toText() {
+ String ret = "";
+ if (isDone()) {
+ ret += (String.format("|%-32s|", this.getName()));
+ ret += (String.format("%20s|", (imgtime==null ? "" : ImportPicture.toUTCString(imgtime))));
+ ret += (String.format("%20s|", (gpstime==null ? "" : ImportPicture.toUTCString(gpstime))));
+ ret += (String.format("%14.10f|%14.10f|", latitude, longitude));
+ ret += (String.format("%8s|%6s|%6s|", eleStr, magvarStr, speedStr));
+ }
+ else {
+ ret += (String.format("|%-32s|", this.getName()));
+ ret += (String.format("%20s|", (imgtime==null ? "" : ImportPicture.toUTCString(imgtime))));
+ ret += (String.format("%20s|", (gpstime==null ? "" : ImportPicture.toUTCString(gpstime))));
+ ret += (String.format("%-14s|%-14s|", "", ""));
+ ret += (String.format("%8s|%6s|%6s|", "", "", ""));
+ }
+ return ret;
+ }
+
+ public void printinfo() {
+ System.out.println(toText());
+ }
+
+ public static void printheader() {
+ System.out.println("|--------------------------------|--------------------|--------------------|--------------|--------------|--------|------|------|");
+ System.out.println("| name | Camera Time | GPStime | Latitude | Longitude | ele |magvar| km/h |");
+ System.out.println("|--------------------------------|--------------------|--------------------|--------------|--------------|--------|------|------|");
+ }
+
+ public static void printfooter() {
+ System.out.println("|--------------------------------|--------------------|--------------------|--------------|--------------|--------|------|------|");
+ System.out.println();
+ }
+}
diff --git a/src/main/java/osm/jp/gpx/ImgFileFilter.java b/src/main/java/osm/jp/gpx/ImgFileFilter.java
new file mode 100644
index 0000000..906d6bc
--- /dev/null
+++ b/src/main/java/osm/jp/gpx/ImgFileFilter.java
@@ -0,0 +1,17 @@
+package osm.jp.gpx;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+/**
+ * JPEGファイルフィルター
+ * @author yuu
+ */
+public class ImgFileFilter implements FilenameFilter {
+
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.toUpperCase().matches(".*\\.JPG$");
+ }
+
+}
diff --git a/src/main/java/osm/jp/gpx/ImgFolder.java b/src/main/java/osm/jp/gpx/ImgFolder.java
new file mode 100644
index 0000000..66879d9
--- /dev/null
+++ b/src/main/java/osm/jp/gpx/ImgFolder.java
@@ -0,0 +1,91 @@
+package osm.jp.gpx;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import org.apache.commons.imaging.ImageReadException;
+import org.apache.commons.imaging.ImageWriteException;
+import org.xml.sax.SAXException;
+
+public class ImgFolder extends ArrayList {
+ private static final long serialVersionUID = -1137199371724546343L;
+ AppParameters params;
+ File imgDir;
+ File outDir;
+
+ public ImgFolder(AppParameters params) {
+ this.params = params;
+ imgDir = params.getImgSourceFolder();
+ File[] files = imgDir.listFiles(new ImgFileFilter());
+ Arrays.sort(files, new FileSort());
+ for (File file : files) {
+ this.add(new ImgFile(file));
+ }
+ }
+
+ public void setOutDir(File outDir) {
+ this.outDir = outDir;
+ }
+
+ public File getOutDir() {
+ return this.outDir;
+ }
+
+ public File getImgDir() {
+ return this.imgDir;
+ }
+
+ /**
+ * 個別のGPXファイルを処理する
+ *
+ * @throws ParserConfigurationException
+ * @throws IOException
+ * @throws SAXException
+ * @throws ParseException
+ * @throws ImageWriteException
+ * @throws ImageReadException
+ * @throws TransformerException
+ */
+ void procGPXfile(GpxFile gpxFile, long delta) throws ParserConfigurationException, SAXException, IOException, ParseException, ImageReadException, ImageWriteException, TransformerException {
+ // imgDir内の画像ファイルを処理する
+ //System.out.println("|--------------------------------|--------------------|--------------------|--------------|--------------|--------|------|------|");
+ //System.out.println("| name | Camera Time | GPStime | Latitude | Longitude | ele |magvar| km/h |");
+ //System.out.println("|--------------------------------|--------------------|--------------------|--------------|--------------|--------|------|------|");
+
+ //ElementMapTRKSEG seg = gpxFile.parse();
+ for (ImgFile image : this) {
+ try {
+ if (!image.isDone()) {
+ if(image.procImageFile(params, delta, gpxFile, outDir)) {
+ image.setDone(true);
+ }
+ }
+ }
+ catch(Exception e) {
+ System.out.print(String.format("%s", e.toString()));
+ continue;
+ }
+ }
+
+ //System.out.println("|--------------------------------|--------------------|--------------------|--------------|--------------|--------|------|------|");
+ }
+
+ /**
+ * ファイル名の順序に並び替えるためのソートクラス
+ *
+ */
+ static class FileSort implements Comparator {
+ @Override
+ public int compare(File src, File target){
+ int diff = src.getName().compareTo(target.getName());
+ return diff;
+ }
+ }
+}
diff --git a/src/main/java/osm/jp/gpx/ImportPicture.java b/src/main/java/osm/jp/gpx/ImportPicture.java
index 0f66415..ac6e29c 100644
--- a/src/main/java/osm/jp/gpx/ImportPicture.java
+++ b/src/main/java/osm/jp/gpx/ImportPicture.java
@@ -1,17 +1,10 @@
package osm.jp.gpx;
import java.io.*;
-import java.nio.channels.FileChannel;
import java.text.DateFormat;
-import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Comparator;
import java.util.Date;
-import java.util.Map;
import java.util.ResourceBundle;
import java.util.TimeZone;
import java.util.logging.LogManager;
@@ -22,17 +15,6 @@
import org.apache.commons.imaging.ImageReadException;
import org.apache.commons.imaging.ImageWriteException;
-import org.apache.commons.imaging.Imaging;
-import org.apache.commons.imaging.common.ImageMetadata;
-import org.apache.commons.imaging.common.RationalNumber;
-import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata;
-import org.apache.commons.imaging.formats.jpeg.exif.ExifRewriter;
-import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
-import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants;
-import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants;
-import org.apache.commons.imaging.formats.tiff.write.TiffOutputDirectory;
-import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet;
-import org.w3c.dom.*;
import org.xml.sax.SAXException;
public class ImportPicture extends Thread {
@@ -56,9 +38,7 @@
*/
public static final Logger LOGGER = Logger.getLogger("CommandLogging");
static {
- InputStream inStream = null;
- try {
- inStream = new ByteArrayInputStream(LOGGING_PROPERTIES_DATA.getBytes("UTF-8"));
+ try (InputStream inStream = new ByteArrayInputStream(LOGGING_PROPERTIES_DATA.getBytes("UTF-8"))) {
try {
LogManager.getLogManager().readConfiguration(inStream);
// "ログ設定: LogManagerを設定しました。"
@@ -73,17 +53,9 @@
catch (UnsupportedEncodingException e) {
String str = "LoggerSettings: Not supported 'UTF-8' encoding: " + e.toString();
LOGGER.severe(str);
- }
- finally {
- try {
- if (inStream != null) {
- inStream.close();
- }
- } catch (IOException e) {
- String str = "LoggerSettings: Exception occored: "+ e.toString();
- LOGGER.warning(str);
- }
- }
+ } catch (IOException e1) {
+ LOGGER.severe(e1.toString());
+ }
}
/** メイン
@@ -101,13 +73,6 @@
* @param argv
* argv[0] = INIファイルのパス名
*
- * argv[-] = dummy
- * argv[0] = 画像ファイルが格納されているディレクトリ --> imgDir
- * argv[1] = 時刻補正の基準とする画像ファイル --> baseFile
- * argv[2] = 基準画像ファイルの精確な撮影日時 "yyyy-MM-dd'T'HH:mm:ss" --> timeStr
- * argv[3] = 出力先フォルダ --> outDir
- * argv[4] = 撮影位置をロギングしたGPXファイル --> gpxDir
- *
* @throws IOException
* @throws ImageReadException
*/
@@ -117,175 +82,39 @@
obj.setUp(((argv.length < 1) ? AppParameters.FILE_PATH : argv[0]));
}
- public File gpxDir;
- public File imgDir;
- public File outDir;
- public long delta = 0;
- public boolean exif = false;
- public boolean exifBase = false;
- public ArrayList gpxFiles = new ArrayList<>();
+ //public File gpxDir;
+ public ImgFolder imgFolder;
+ public GpxFolder gpxFolder;
public AppParameters params;
- public boolean param_GpxSplit = false;
- public static boolean param_GpxNoFirstNode = false;
- public boolean param_GpxReuse = false;
- public boolean param_GpxOutputWpt = true;
- public boolean param_ImgOutputAll = false;
- public String param_GpxSourceFolder = ".";
- public static final String TIME_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ss'Z'";
private static final String EXIF_DATE_TIME_FORMAT_STRING = "yyyy:MM:dd HH:mm:ss";
- public ResourceBundle i18n = ResourceBundle.getBundle("i18n");
+ public static final ResourceBundle i18n = ResourceBundle.getBundle("i18n");
public void setUp(String paramFilePath) throws Exception {
System.out.println("Param File = '"+ paramFilePath +"'");
this.params = new AppParameters(paramFilePath);
-
- Date imgtime;
-
- System.out.println(" - param: "+ AppParameters.IMG_TIME +"="+ this.params.getProperty(AppParameters.IMG_TIME) );
- System.out.println(" - param: "+ AppParameters.IMG_BASE_FILE +"="+ this.params.getProperty(AppParameters.IMG_BASE_FILE) );
- System.out.println(" - param: "+ AppParameters.GPX_BASETIME +"="+ this.params.getProperty(AppParameters.GPX_BASETIME) );
- System.out.println(" - param: "+ AppParameters.IMG_SOURCE_FOLDER +"="+ this.params.getProperty(AppParameters.IMG_SOURCE_FOLDER) );
- System.out.println(" - param: "+ AppParameters.IMG_OUTPUT_FOLDER +"="+ this.params.getProperty(AppParameters.IMG_OUTPUT_FOLDER) );
- System.out.println(" - param: "+ AppParameters.IMG_OUTPUT +"="+ this.params.getProperty(AppParameters.IMG_OUTPUT));
- System.out.println(" - param: "+ AppParameters.IMG_OUTPUT_ALL +"="+ this.param_ImgOutputAll);
- System.out.println(" - param: "+ AppParameters.IMG_OUTPUT_EXIF +"= "+ String.valueOf(this.exif));
- System.out.println(" - param: "+ AppParameters.GPX_SOURCE_FOLDER +"="+ this.param_GpxSourceFolder);
- System.out.println(" - param: "+ AppParameters.GPX_OUTPUT_WPT +"="+ this.param_GpxOutputWpt);
- System.out.println(" - param: "+ AppParameters.GPX_OVERWRITE_MAGVAR +"="+ Complementation.param_GpxOverwriteMagvar);
- System.out.println(" - param: "+ AppParameters.GPX_OUTPUT_SPEED +"="+ Complementation.param_GpxOutputSpeed);
- System.out.println(" - param: "+ AppParameters.GPX_GPXSPLIT +"="+ this.param_GpxSplit);
- System.out.println(" - param: "+ AppParameters.GPX_NO_FIRST_NODE +"="+ ImportPicture.param_GpxNoFirstNode);
- System.out.println(" - param: "+ AppParameters.GPX_REUSE +"="+ this.param_GpxReuse);
+ params.printout();
this.ex = null;
- // argv[0] --> AppParameters.IMG_SOURCE_FOLDER に置き換え
- this.imgDir = new File(this.params.getProperty(AppParameters.IMG_SOURCE_FOLDER));
-
- // 基準時刻(ファイル更新日時 | EXIF撮影日時)
- this.exifBase = (this.params.getProperty(AppParameters.GPX_BASETIME).equals("EXIF_TIME"));
-
- // 基準時刻ファイルの「更新日時」を使って時刻合わせを行う。
- // argv[1] --> AppParameters.IMG_BASE_FILE に置き換え
- imgtime = this.adjustTime(new File(this.imgDir, this.params.getProperty(AppParameters.IMG_BASE_FILE)));
-
+
+ // AppParameters.IMG_SOURCE_FOLDER に置き換え
+ imgFolder = new ImgFolder(params);
+ gpxFolder = new GpxFolder(params);
+
// 出力ファイル
- // argv[3] --> AppParameters.IMG_OUTPUT に置き換え
- this.outDir = new File(this.params.getProperty(AppParameters.IMG_OUTPUT_FOLDER));
-
- // その他のパラメータを読み取る
- String paramStr = this.params.getProperty(AppParameters.GPX_GPXSPLIT);
- if ((paramStr != null) && (paramStr.equals(Boolean.toString(true)))) {
- this.param_GpxSplit = true;
- }
-
- paramStr = this.params.getProperty(AppParameters.GPX_NO_FIRST_NODE);
- if ((paramStr != null) && (paramStr.equals(Boolean.toString(true)))) {
- ImportPicture.param_GpxNoFirstNode = true;
- }
-
- paramStr = this.params.getProperty(AppParameters.GPX_REUSE);
- if ((paramStr != null) && (paramStr.equals(Boolean.toString(true)))) {
- this.param_GpxReuse = true;
- }
-
- paramStr = this.params.getProperty(AppParameters.IMG_OUTPUT_ALL);
- if ((paramStr != null) && (paramStr.equals(Boolean.toString(true)))) {
- this.param_ImgOutputAll = true;
- }
-
- paramStr = this.params.getProperty(AppParameters.GPX_OUTPUT_WPT);
- if ((paramStr != null) && (paramStr.equals(Boolean.toString(true)))) {
- this.param_GpxOutputWpt = true;
- }
-
- paramStr = this.params.getProperty(AppParameters.GPX_OVERWRITE_MAGVAR);
- if ((paramStr != null) && (paramStr.equals(Boolean.toString(true)))) {
- Complementation.param_GpxOverwriteMagvar = true;
- }
-
- paramStr = this.params.getProperty(AppParameters.GPX_OUTPUT_SPEED);
- if ((paramStr != null) && (paramStr.equals(Boolean.toString(true)))) {
- Complementation.param_GpxOutputSpeed = true;
- }
-
- paramStr = this.params.getProperty(AppParameters.GPX_SOURCE_FOLDER);
- if (paramStr != null) {
- this.param_GpxSourceFolder = paramStr;
- this.gpxDir = new File(this.param_GpxSourceFolder);
- if (!this.gpxDir.exists()) {
- // GPXファイルまたはディレクトリが存在しません。('%s')
- System.out.println(
- String.format(i18n.getString("msg.100"), paramStr)
- );
- return;
+ // AppParameters.IMG_OUTPUT に置き換え
+ if (params.isImgOutput()) {
+ File outDir = new File(params.getProperty(AppParameters.IMG_OUTPUT_FOLDER));
+ if (!outDir.exists()) {
+ // 出力ディレクトリが存在しないときは作成する
+ outDir.mkdir();
}
- }
- else {
- this.gpxDir = this.imgDir;
- }
-
- // 指定されたディレクトリ内のGPXファイルすべてを対象とする
- if (this.gpxDir.isDirectory()) {
- File[] files = this.gpxDir.listFiles();
- if (files == null) {
- // 対象となるGPXファイルがありませんでした。('%s')
- System.out.println(
- String.format(i18n.getString("msg.110"), this.gpxDir.getAbsolutePath())
- );
- return;
+ else if (outDir.isFile()) {
+ // 出力ディレクトリがFILEのときはERROR
+ throw new FileNotFoundException(String.format("OUTPUT directory '%s' is a File!", outDir.getAbsolutePath()));
}
- if (this.param_ImgOutputAll && (files.length > 1)) {
- // "複数のGPXファイルがあるときには、'IMG.OUTPUT_ALL'オプションは指定できません。"
- System.out.println(
- i18n.getString("msg.120")
- );
- return;
- }
-
- java.util.Arrays.sort(
- files, new java.util.Comparator() {
- @Override
- public int compare(File file1, File file2){
- return file1.getName().compareTo(file2.getName());
- }
- }
- );
- for (File file : files) {
- if (file.isFile()) {
- String filename = file.getName().toUpperCase();
- if (filename.toUpperCase().endsWith(".GPX")) {
- if (!filename.toUpperCase().endsWith("_.GPX") || this.param_GpxReuse) {
- this.gpxFiles.add(file);
- }
- }
- }
- }
- }
- else {
- this.gpxFiles.add(this.gpxDir);
- }
-
- paramStr = this.params.getProperty(AppParameters.IMG_OUTPUT_EXIF);
- if ((paramStr != null) && (paramStr.equals(Boolean.toString(true)))) {
- this.exif = true;
- }
-
- String timeStr = this.params.getProperty(AppParameters.IMG_TIME);
- try {
- Date t = toUTCDate(timeStr);
- this.delta = t.getTime() - imgtime.getTime();
- }
- catch (ParseException e) {
- // "'%s'の書式が違います(%s)"
- System.out.println(
- String.format(
- i18n.getString("msg.130"),
- timeStr,
- TIME_FORMAT_STRING
- )
- );
- return;
+ outDir = new File(outDir, imgFolder.getImgDir().getName());
+ imgFolder.setOutDir(outDir);
}
this.start();
@@ -315,345 +144,73 @@
@Override
public void run() {
try {
- if (params.getProperty(AppParameters.IMG_OUTPUT).equals(Boolean.toString(true))) {
- outDir = new File(outDir, imgDir.getName());
+ long delta = 0;
+ String timeStr = params.getProperty(AppParameters.IMG_TIME);
+ try {
+ Date t = ImportPicture.toUTCDate(timeStr);
+
+ // 基準時刻ファイルの「更新日時」を使って時刻合わせを行う。
+ // argv[1] --> AppParameters.IMG_BASE_FILE に置き換え
+ Date imgtime = ImgFile.getDate(params, getImgBaseFile());
+ delta = t.getTime() - imgtime.getTime();
}
- else {
- outDir = gpxDir;
+ catch (ParseException e) {
+ // "'%s'の書式が違います(%s)"0
+ System.out.println(
+ String.format(
+ ImportPicture.i18n.getString("msg.130"),
+ timeStr,
+ ImportPicture.TIME_FORMAT_STRING
+ )
+ );
+ return;
}
- for (File gpxFile : this.gpxFiles) {
- procGPXfile(new GpxFile(gpxFile));
+
+ for (GpxFile gpxFile : gpxFolder) {
+ gpxFile.parse();
+
+ System.out.println("time difference: "+ (delta / 1000) +"(sec)");
+ System.out.println(" Target GPX: ["+ gpxFile.getAbsolutePath() +"]");
+ System.out.println(" EXIF: "+ (params.isImgOutputExif() ? ("convert to '" + imgFolder.getOutDir().getAbsolutePath() +"'") : "off"));
+ System.out.println();
+
+ gpxFile.printinfo();
+ imgFolder.procGPXfile(gpxFile, delta);
}
+
+ // imgDir内の画像ファイルを処理する
+ ImgFile.printheader();
+ for (ImgFile image : imgFolder) {
+ image.printinfo();
+ }
+ ImgFile.printfooter();
}
- catch(ParserConfigurationException | DOMException | SAXException | IOException | ParseException | ImageReadException | ImageWriteException | IllegalArgumentException | TransformerException e) {
+ catch(ParserConfigurationException | SAXException | IOException | ParseException | ImageReadException | ImageWriteException | IllegalArgumentException | TransformerException e) {
e.printStackTrace();
this.ex = new Exception(e);
}
}
- /**
- * 個別のGPXファイルを処理する
- *
- * @throws ParserConfigurationException
- * @throws IOException
- * @throws SAXException
- * @throws ParseException
- * @throws ImageWriteException
- * @throws ImageReadException
- * @throws TransformerException
- */
- void procGPXfile(GpxFile gpxFile) throws ParserConfigurationException, SAXException, IOException, ParseException, ImageReadException, ImageWriteException, TransformerException {
- System.gc();
+
+
+
+
+
+ public static final String TIME_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ss'Z'";
- System.out.println("time difference: "+ (delta / 1000) +"(sec)");
- System.out.println(" Target GPX: ["+ gpxFile.getAbsolutePath() +"]");
- System.out.println(" EXIF: "+ (exif ? ("convert to '" + outDir.getAbsolutePath() +"'") : "off"));
- System.out.println();
+ public static Date toUTCDate(String timeStr) throws ParseException {
+ DateFormat dfUTC = new SimpleDateFormat(TIME_FORMAT_STRING);
+ dfUTC.setTimeZone(TimeZone.getTimeZone("UTC"));
+ return dfUTC.parse(timeStr);
+ }
- // imgDir内の画像ファイルを処理する
- System.out.println("|--------------------------------|--------------------|--------------------|--------------|--------------|--------|------|------|");
- System.out.println("| name | Camera Time | GPStime | Latitude | Longitude | ele |magvar| km/h |");
- System.out.println("|--------------------------------|--------------------|--------------------|--------------|--------------|--------|------|------|");
- boolean out = proc(imgDir, delta, gpxFile.mapTRKSEG, exif, gpxFile);
- System.out.println("|--------------------------------|--------------------|--------------------|--------------|--------------|--------|------|------|");
- if (out) {
- // GPX出力
- gpxFile.output(outDir);
- }
+ public static String toUTCString(Date localdate) {
+ DateFormat dfUTC = new SimpleDateFormat(TIME_FORMAT_STRING);
+ dfUTC.setTimeZone(TimeZone.getTimeZone("UTC"));
+ return dfUTC.format(localdate);
}
/**
- * 再帰メソッド
- * @throws ParseException
- * @throws IOException
- * @throws ImageReadException
- * @throws ImageWriteException
- */
- boolean proc(File dir, long delta, ElementMapTRKSEG mapTRKSEG, boolean exifWrite, GpxFile gpxFile) throws ParseException, ImageReadException, IOException, ImageWriteException {
- boolean ret = false;
- File[] files = dir.listFiles(new JpegFileFilter());
- Arrays.sort(files, new FileSort());
- for (File image : files) {
- System.out.print(String.format("|%-32s|", image.getName()));
- if (image.isDirectory()) {
- ret = proc(image, delta, mapTRKSEG, exifWrite, gpxFile);
- continue;
- }
-
- String imageName = image.getName();
- if (!checkFile(imageName)) {
- System.out.println(String.format("%20s ", "it is not image file."));
- continue;
- }
-
- Discripter result = procImageFile(image, delta, mapTRKSEG, exifWrite, gpxFile);
- ret |= result.ret;
- switch (result.control) {
- case Discripter.CONTINUE:
- continue;
- case Discripter.BREAK:
- break;
- }
- }
- return ret;
- }
-
- class Discripter {
- static final int NEXT = 0;
- static final int CONTINUE = -1;
- static final int BREAK = 1;
-
- public boolean ret;
- public int control;
- public Discripter(boolean ret) {
- this.ret = ret;
- this.control = Discripter.NEXT;
- }
- }
-
- Discripter procImageFile(File imageFile, long delta, ElementMapTRKSEG mapTRKSEG, boolean exifWrite, GpxFile gpxFile) throws ParseException, ImageReadException, IOException, ImageWriteException {
- Discripter result = new Discripter(false);
-
- // itime <-- 画像ファイルの撮影時刻
- // ファイルの更新日時/EXIFの撮影日時
- Date itime = new Date(imageFile.lastModified());
- if (this.exifBase) {
- ImageMetadata meta = Imaging.getMetadata(imageFile);
- JpegImageMetadata jpegMetadata = (JpegImageMetadata)meta;
- if (jpegMetadata == null) {
- // "'%s'にEXIF情報がありません"
- System.out.println(
- String.format(
- i18n.getString("msg.140"),
- imageFile.getAbsolutePath()
- )
- );
- result.control = Discripter.CONTINUE;
- return result;
- }
- @SuppressWarnings("LocalVariableHidesMemberVariable")
- TiffImageMetadata exif = jpegMetadata.getExif();
- if (exif == null) {
- // "'%s'にEXIF情報がありません"
- System.out.println(
- String.format(
- i18n.getString("msg.140"),
- imageFile.getAbsolutePath()
- )
- );
- result.control = Discripter.CONTINUE;
- return result;
- }
- String dateTimeOriginal = exif.getFieldValue(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL)[0];
- itime = ImportPicture.toEXIFDate(dateTimeOriginal);
- }
- System.out.print(String.format("%20s|", toUTCString(itime)));
-
- // uktime <-- 画像撮影時刻に対応するGPX時刻(補正日時)
- Date correctedtime = new Date(itime.getTime() + delta);
- System.out.print(String.format("%20s|", toUTCString(correctedtime)));
-
- // 時刻uktimeにおけるをtrkptに追加する
- String eleStr = "-";
- String magvarStr = "-";
- String speedStr = "-";
- TagTrkpt trkptT = null;
-
- for (Map.Entry map : mapTRKSEG.entrySet()) {
- ElementMapTRKPT mapTRKPT = map.getValue();
- trkptT = mapTRKPT.getValue(correctedtime);
- if (trkptT != null) {
- break;
- }
- }
-
- if (trkptT == null) {
- System.out.print(String.format("%-14s|%-14s|", "", ""));
- System.out.println(String.format("%8s|%6s|%6s|", "", "", ""));
- if (!this.param_ImgOutputAll) {
- result.control = Discripter.CONTINUE;
- return result;
- }
- }
- else {
- double latitude = trkptT.lat;
- double longitude = trkptT.lon;
-
- if (trkptT.eleStr != null) {
- eleStr = trkptT.eleStr;
- }
-
- if (trkptT.magvarStr != null) {
- magvarStr = trkptT.magvarStr;
- }
-
- if (trkptT.speedStr != null) {
- speedStr = trkptT.speedStr;
- }
- System.out.print(String.format("%14.10f|%14.10f|", latitude, longitude));
- System.out.println(String.format("%8s|%6s|%6s|", eleStr, magvarStr, speedStr));
- }
-
- result.ret = true;
- outDir.mkdir();
-
- if (exifWrite) {
- exifWrite(imageFile, correctedtime, trkptT);
-
- if (Boolean.parseBoolean(params.getProperty(AppParameters.GPX_OUTPUT_WPT))) {
- if (trkptT != null) {
- Element temp = gpxFile.createWptTag(imageFile, imgDir, itime.getTime(), trkptT.trkpt);
- gpxFile.gpx.appendChild(temp);
- }
- }
- }
- else {
- if (this.param_ImgOutputAll) {
- // EXIFの変換を伴わない単純なファイルコピー
- FileInputStream sStream = new FileInputStream(imageFile);
- FileInputStream dStream = new FileInputStream(new File(outDir, imageFile.getName()));
- FileChannel srcChannel = sStream.getChannel();
- FileChannel destChannel = dStream.getChannel();
- try {
- srcChannel.transferTo(0, srcChannel.size(), destChannel);
- }
- finally {
- srcChannel.close();
- destChannel.close();
- sStream.close();
- dStream.close();
- }
- }
- }
- result.control = Discripter.NEXT;
- return result;
- }
-
- void exifWrite(File imageFile, Date correctedtime, TagTrkpt trkptT) throws ImageReadException, IOException, ImageWriteException {
- DecimalFormat yearFormatter = new DecimalFormat("0000");
- DecimalFormat monthFormatter = new DecimalFormat("00");
- DecimalFormat dayFormatter = new DecimalFormat("00");
-
- TiffOutputSet outputSet = null;
-
- ImageMetadata meta = Imaging.getMetadata(imageFile);
- JpegImageMetadata jpegMetadata = (JpegImageMetadata)meta;
- if (jpegMetadata != null) {
- @SuppressWarnings("LocalVariableHidesMemberVariable")
- TiffImageMetadata exif = jpegMetadata.getExif();
- if (exif != null) {
- outputSet = exif.getOutputSet();
- }
- }
-
- if (outputSet == null) {
- outputSet = new TiffOutputSet();
- }
-
- //---- EXIF_TAG_DATE_TIME_ORIGINAL / 「撮影日時/オリジナル画像の生成日時」----
- TiffOutputDirectory exifDir = outputSet.getOrCreateExifDirectory();
- {
- Calendar cal = Calendar.getInstance();
- cal.setTimeZone(TimeZone.getTimeZone("UTC"));
- cal.setTime(correctedtime);
- exifDir.removeField(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
- exifDir.add(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL, ImportPicture.toEXIFString(cal.getTime()));
- }
-
- //---- EXIF GPS_TIME_STAMP ----
- TiffOutputDirectory gpsDir = outputSet.getOrCreateGPSDirectory();
- {
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- cal.setTimeZone(TimeZone.getTimeZone("GMT+00"));
- cal.setTime(correctedtime);
- final String yearStr = yearFormatter.format(cal.get(Calendar.YEAR));
- final String monthStr = monthFormatter.format(cal.get(Calendar.MONTH) + 1);
- final String dayStr = dayFormatter.format(cal.get(Calendar.DAY_OF_MONTH));
- final String dateStamp = yearStr +":"+ monthStr +":"+ dayStr;
-
- gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_TIME_STAMP);
- gpsDir.add(
- GpsTagConstants.GPS_TAG_GPS_TIME_STAMP,
- RationalNumber.valueOf(cal.get(Calendar.HOUR_OF_DAY)),
- RationalNumber.valueOf(cal.get(Calendar.MINUTE)),
- RationalNumber.valueOf(cal.get(Calendar.SECOND))
- );
- gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_DATE_STAMP);
- gpsDir.add(GpsTagConstants.GPS_TAG_GPS_DATE_STAMP, dateStamp);
- }
-
- if (trkptT != null) {
- //---- EXIF GPS elevation/ALTITUDE ----
- if (trkptT.eleStr != null) {
- final double altitude = Double.parseDouble(trkptT.eleStr);
- gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_ALTITUDE);
- gpsDir.add(GpsTagConstants.GPS_TAG_GPS_ALTITUDE, RationalNumber.valueOf(altitude));
- }
-
- //---- EXIF GPS magvar/IMG_DIRECTION ----
- if (trkptT.magvarStr != null) {
- final double magvar = Double.parseDouble(trkptT.magvarStr);
- gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION);
- gpsDir.add(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION, RationalNumber.valueOf(magvar));
- }
-
- //---- EXIF GPS_ ----
- outputSet.setGPSInDegrees(trkptT.lon, trkptT.lat);
- }
-
- ExifRewriter rewriter = new ExifRewriter();
- try (FileOutputStream fos = new FileOutputStream(new File(outDir, imageFile.getName()))) {
- rewriter.updateExifMetadataLossy(imageFile, fos, outputSet);
- }
- }
-
- // 基準時刻ファイルの「更新日時」を使って時刻合わせを行う。
- // argv[1] --> AppParameters.IMG_BASE_FILE に置き換え
- // File baseFile = new File(this.imgDir, this.params.getProperty(AppParameters.IMG_BASE_FILE));
- private Date adjustTime(File baseFile) throws ImageReadException, IOException, ParseException {
- if (exifBase) {
- ImageMetadata meta = Imaging.getMetadata(baseFile);
- JpegImageMetadata jpegMetadata = (JpegImageMetadata)meta;
- if (jpegMetadata == null) {
- // "'%s'にEXIF情報がありません"
- System.out.println(
- String.format(
- i18n.getString("msg.140"),
- baseFile.getAbsolutePath()
- )
- );
- return null;
- }
- @SuppressWarnings("LocalVariableHidesMemberVariable")
- TiffImageMetadata exif = jpegMetadata.getExif();
- if (exif == null) {
- // "'%s'にEXIF情報がありません"
- System.out.println(
- String.format(
- i18n.getString("msg.140"),
- baseFile.getAbsolutePath()
- )
- );
- return null;
- }
- String dateTimeOriginal = exif.getFieldValue(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL)[0];
- return new Date(ImportPicture.toEXIFDate(dateTimeOriginal).getTime());
- }
- else {
- return new Date(baseFile.lastModified());
- }
- }
-
- /**
- * 対象は '*.JPG' のみ対象とする
- * @return
- * @param name
- */
- public static boolean checkFile(String name) {
- return ((name != null) && name.toUpperCase().endsWith(".JPG"));
- }
-
- /**
* DateをEXIFの文字列に変換する。
* 注意:EXiFの撮影時刻はUTC時間ではない
* @param localdate
@@ -676,18 +233,10 @@
//dfUTC.setTimeZone(TimeZone.getTimeZone("UTC"));
return dfUTC.parse(timeStr);
}
-
- public static String toUTCString(Date localdate) {
- DateFormat dfUTC = new SimpleDateFormat(TIME_FORMAT_STRING);
- dfUTC.setTimeZone(TimeZone.getTimeZone("UTC"));
- return dfUTC.format(localdate);
- }
-
- public static Date toUTCDate(String timeStr) throws ParseException {
- DateFormat dfUTC = new SimpleDateFormat(TIME_FORMAT_STRING);
- dfUTC.setTimeZone(TimeZone.getTimeZone("UTC"));
- return dfUTC.parse(timeStr);
- }
+
+ public File getImgBaseFile() {
+ return new File(imgFolder.getImgDir(), params.getProperty(AppParameters.IMG_BASE_FILE));
+ }
static String getShortPathName(File dir, File iFile) {
String dirPath = dir.getAbsolutePath();
@@ -699,28 +248,4 @@
return filePath;
}
}
-
- /**
- * ファイル名の順序に並び替えるためのソートクラス
- *
- * @author hayashi
- */
- static class FileSort implements Comparator {
- @Override
- public int compare(File src, File target){
- int diff = src.getName().compareTo(target.getName());
- return diff;
- }
- }
-
- /**
- * JPEGファイルフィルター
- * @author yuu
- */
- class JpegFileFilter implements FilenameFilter {
- @Override
- public boolean accept(File dir, String name) {
- return name.toUpperCase().matches(".*\\.JPG$");
- }
- }
}
\ No newline at end of file
diff --git a/src/main/java/osm/jp/gpx/Restamp.java b/src/main/java/osm/jp/gpx/Restamp.java
index 96da1ee..0670d3d 100644
--- a/src/main/java/osm/jp/gpx/Restamp.java
+++ b/src/main/java/osm/jp/gpx/Restamp.java
@@ -173,7 +173,6 @@
public ArrayList jpgFiles = new ArrayList<>();
public static ResourceBundle i18n = ResourceBundle.getBundle("i18n");
- @SuppressWarnings("Convert2Lambda")
public void setUp(File imgDir, File baseFile1, Date baseTime1, File baseFile2, Date baseTime2) throws Exception {
// 指定されたディレクトリ内のGPXファイルすべてを対象とする
File[] files = imgDir.listFiles();
@@ -208,7 +207,6 @@
DateFormat df2 = new SimpleDateFormat(TIME_PATTERN);
// imgDir内の画像ファイルを処理する
- @SuppressWarnings("LocalVariableHidesMemberVariable")
long span = baseTime2.getTime() - baseTime1.getTime();
span = span / (bCount2 - bCount1);
int i = 0;
diff --git a/src/main/java/osm/jp/gpx/TagTrkpt.java b/src/main/java/osm/jp/gpx/TagTrkpt.java
index 171827f..f5a50e3 100644
--- a/src/main/java/osm/jp/gpx/TagTrkpt.java
+++ b/src/main/java/osm/jp/gpx/TagTrkpt.java
@@ -1,14 +1,7 @@
package osm.jp.gpx;
-import java.text.ParseException;
import java.util.Date;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
/**
* @code{
* <trkpt lat="35.32123832" lon="139.56965631">
@@ -20,8 +13,7 @@
* }
*
*/
-public class TagTrkpt {
- public Element trkpt = null;
+public class TagTrkpt implements Cloneable {
public Double lat = null;
public Double lon = null;
public String eleStr = null;
@@ -29,93 +21,74 @@
public String magvarStr = null;
public String speedStr = null;
- public TagTrkpt(Element trkpt) {
- this.trkpt = (Element) trkpt.cloneNode(true);
-
- NamedNodeMap nodeMap = trkpt.getAttributes();
- for (int j=0; j < nodeMap.getLength(); j++ ) {
- switch (nodeMap.item(j).getNodeName()) {
- case "lat":
- String latStr = nodeMap.item(j).getNodeValue();
- this.lat = new Double(latStr);
- break;
- case "lon":
- String lonStr = nodeMap.item(j).getNodeValue();
- this.lon = new Double(lonStr);
- break;
- }
- }
-
- NodeList nodes1 = trkpt.getChildNodes();
- for (int i1=0; i1 < nodes1.getLength(); i1++) {
- Node node1 = nodes1.item(i1);
- NodeList nodes2 = node1.getChildNodes();
- switch (node1.getNodeName()) {
- case "ele":
- for (int i2=0; i2 < nodes2.getLength(); i2++) {
- Node node2 = nodes2.item(i2);
- if (node2 != null) {
- if (node2.getNodeType() == Node.TEXT_NODE) {
- this.eleStr = node2.getNodeValue();
- }
- }
- }
- break;
- case "time":
- for (int i2=0; i2 < nodes2.getLength(); i2++) {
- Node node2 = nodes2.item(i2);
- if (node2 != null) {
- if (node2.getNodeType() == Node.TEXT_NODE) {
- try {
- this.time = ImportPicture.toUTCDate(node2.getNodeValue());
- } catch (ParseException e) {
- this.time = null;
- }
- }
- }
- }
- break;
- case "magvar":
- for (int i2=0; i2 < nodes2.getLength(); i2++) {
- Node node2 = nodes2.item(i2);
- if (node2 != null) {
- if (node2.getNodeType() == Node.TEXT_NODE) {
- this.magvarStr = node2.getNodeValue();
- }
- }
- }
- break;
- case "speed":
- for (int i2=0; i2 < nodes2.getLength(); i2++) {
- Node node2 = nodes2.item(i2);
- if (node2 != null) {
- if (node2.getNodeType() == Node.TEXT_NODE) {
- this.speedStr = node2.getNodeValue();
- }
- }
- }
- break;
- }
- }
+ public TagTrkpt(Double lat, Double lon) {
+ this.lat = lat;
+ this.lon = lon;
}
-
- public void removeElement(String eleName) {
- Node child;
- for (child = trkpt.getFirstChild(); child != null; child = child.getNextSibling()) {
- NodeList nodeList = child.getChildNodes();
- for(int i = 0; i < nodeList.getLength(); i++) {
- Node grandChild = child.getChildNodes().item(i);
- if (grandChild.getNodeName().equals(eleName)) {
- child.removeChild(grandChild);
- }
- }
- }
+
+ @Override
+ public TagTrkpt clone() { //基本的にはpublic修飾子を付け、自分自身の型を返り値とする
+ TagTrkpt b = null;
+
+ // ObjectクラスのcloneメソッドはCloneNotSupportedExceptionを投げる可能性があるので、try-catch文で記述(呼び出し元に投げても良い)
+ try {
+ //親クラスのcloneメソッドを呼び出す(親クラスの型で返ってくるので、自分自身の型でのキャストを忘れないようにする)
+ b =(TagTrkpt)super.clone();
+ //親クラスのcloneメソッドで深いコピー(複製先のクラス型変数と複製元のクラス型変数で指しているインスタンスの中身が違うコピー)がなされていないクラス型変数をその変数のcloneメソッドで複製し、複製先のクラス型変数に代入
+ b.lat = this.lat;
+ b.lon = this.lon;
+ b.eleStr = (this.eleStr == null ? null : this.eleStr.toString());
+ b.time = (Date) this.time.clone();
+ b.magvarStr = (this.magvarStr==null ? null : this.magvarStr.toString());
+ b.speedStr = (this.speedStr == null ? null : this.speedStr.toString());
+ } catch (Exception e){
+ e.printStackTrace();
+ }
+ return b;
+ }
+
+ public void setEle(String ele) {
+ this.eleStr = ele;
}
- public void appendElement(String eleName, String valueStr) {
- Document doc = trkpt.getOwnerDocument();
- Element newElement = doc.createElement(eleName);
- newElement.setTextContent(valueStr);
- trkpt.appendChild(newElement);
+ public void setTime(Date time) {
+ this.time = time;
+ }
+
+ public Date getTime() {
+ return this.time;
+ }
+
+ public void setMagvar(String magvar) {
+ this.magvarStr = magvar;
+ }
+
+ public void setSpeed(String speed) {
+ this.speedStr = speed;
+ }
+
+ public String toString() {
+ String ret = "";
+ System.out.println(ret);
+ return ret;
}
}
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/AboutDialog.java b/src/main/java/osm/jp/gpx/matchtime/gui/AboutDialog.java
index 1a0558c..2069c61 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/AboutDialog.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/AboutDialog.java
@@ -35,7 +35,6 @@
}
}
- @SuppressWarnings("OverridableMethodCallInConstructor")
public AboutDialog(Frame parent, boolean modal) {
super(parent, modal);
@@ -50,17 +49,17 @@
setLayout(null);
setVisible(false);
setSize(360,114);
- label1 = new java.awt.Label(AdjustTime.PROGRAM_NAME +" Version "+ AdjustTime.PROGRAM_VARSION +" ("+ AdjustTime.PROGRAM_UPDATE +")", Label.CENTER);
+ label1 = new java.awt.Label(AdjustTerra.PROGRAM_NAME +" Version "+ AdjustTerra.PROGRAM_VARSION +" ("+ AdjustTerra.PROGRAM_UPDATE +")", Label.CENTER);
label1.setBounds(10,10,340,20);
add(label1);
okButton = new java.awt.Button();
okButton.setLabel("OK");
okButton.setBounds(145,65,66,27);
add(okButton);
- label2 = new java.awt.Label("Copyright(C) 2014,2018, yuuhayashi \n The MIT License (MIT).",Label.RIGHT);
+ label2 = new java.awt.Label("Copyright(C) 2014,2018,2020 yuuhayashi \n The MIT License (MIT).",Label.RIGHT);
label2.setBounds(10,40,340,20);
add(label2);
- setTitle("About... "+ AdjustTime.PROGRAM_NAME);
+ setTitle("About... "+ AdjustTerra.PROGRAM_NAME);
//}}
//{{REGISTER_LISTENERS
@@ -71,7 +70,6 @@
//}}
}
- @SuppressWarnings("OverridableMethodCallInConstructor")
public AboutDialog(Frame parent, String title, boolean modal) {
this(parent, modal);
setTitle(title);
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/AdjustTerra.java b/src/main/java/osm/jp/gpx/matchtime/gui/AdjustTerra.java
new file mode 100644
index 0000000..d5d84a6
--- /dev/null
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/AdjustTerra.java
@@ -0,0 +1,416 @@
+package osm.jp.gpx.matchtime.gui;
+
+import osm.jp.gpx.matchtime.gui.restamp.RestampDialog;
+import java.awt.*;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.ResourceBundle;
+import java.util.TimeZone;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.*;
+import javax.swing.event.DocumentEvent;
+import osm.jp.gpx.*;
+import osm.jp.gpx.matchtime.gui.restamp.CardImageFile;
+import osm.jp.gpx.matchtime.gui.restamp.CardSourceFolder;
+
+/**
+ * 本プログラムのメインクラス
+ */
+@SuppressWarnings("serial")
+public class AdjustTerra extends JFrame
+{
+ public static final String PROGRAM_NAME = "AdjustTerra for JOSM";
+ public static final String PROGRAM_VARSION = "5.2";
+ public static final String PROGRAM_UPDATE = "2020/02/02";
+
+ AppParameters params;
+ public static SimpleDateFormat dfjp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
+
+ // Used for addNotify check.
+ boolean fComponentsAdjusted = false;
+ public static ResourceBundle i18n = ResourceBundle.getBundle("i18n");
+
+ //{{DECLARE_CONTROLS
+ JTabbedPane cardPanel; // ウィザード形式パネル(タブ型)
+ Card[] cards;
+ //}}
+
+ //---入力フィールド----------------------------------------------------
+ ParameterPanelFolder arg1_srcFolder; // 対象フォルダ
+ ParameterPanelImageFile arg2_baseTimeImg; // 開始画像ファイルパス
+ ParameterPanelTime arg2_basetime; // 開始画像の基準時刻:
+ ParameterPanelGpx arg3_gpxFile; // GPX file or Folder
+ ParameterPanelOutput arg4_output; // EXIF & 書き出しフォルダ
+
+ //{{DECLARE_MENUS
+ java.awt.MenuBar mainMenuBar;
+ java.awt.Menu menu1;
+ java.awt.MenuItem miDoNewFileList;
+ java.awt.MenuItem miDoDirSize;
+ java.awt.MenuItem miDoReadXML;
+ java.awt.MenuItem miExit;
+ java.awt.Menu menu2;
+ java.awt.MenuItem miRestamp;
+ java.awt.Menu menu3;
+ java.awt.MenuItem miAbout;
+ //}}
+
+ class SymWindow extends java.awt.event.WindowAdapter {
+ /**
+ * このFrameが閉じられるときの動作。
+ * このパネルが閉じられたら、このアプリケーションも終了させる。
+ */
+ @Override
+ public void windowClosing(java.awt.event.WindowEvent event) {
+ Object object = event.getSource();
+ if (object == AdjustTerra.this) {
+ DbMang_WindowClosing(event);
+ }
+ }
+ }
+
+ class SymAction implements java.awt.event.ActionListener {
+ @Override
+ public void actionPerformed(java.awt.event.ActionEvent event) {
+ Object object = event.getSource();
+ if (object == miAbout) {
+ miAbout_Action(event);
+ }
+ else if (object == miRestamp) {
+ try {
+ miRestamp_Action(event);
+ } catch (IOException ex) {
+ Logger.getLogger(AdjustTerra.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ else if (object == miExit) {
+ miExit_Action(event);
+ }
+ }
+ }
+
+ /**
+ * データベース内のテーブルを一覧で表示するFrame
+ * @throws IOException
+ */
+ public AdjustTerra() throws IOException
+ {
+ dfjp.setTimeZone(TimeZone.getTimeZone("JST"));
+
+ // INIT_CONTROLS
+ Container container = getContentPane();
+ container.setLayout(new BorderLayout());
+ setSize(
+ getInsets().left + getInsets().right + 720,
+ getInsets().top + getInsets().bottom + 480
+ );
+ setTitle(AdjustTerra.PROGRAM_NAME +" v"+ AdjustTerra.PROGRAM_VARSION);
+
+ //---- CENTER -----
+ JPanel mainPanel = new JPanel();
+ mainPanel.setLayout(new BorderLayout());
+ container.add(mainPanel, BorderLayout.CENTER);
+
+ //---- SOUTH -----
+ JPanel southPanel = new JPanel(new BorderLayout());
+ southPanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);
+ southPanel.add(Box.createVerticalStrut(10), BorderLayout.NORTH);
+ container.add(southPanel, BorderLayout.SOUTH);
+
+ //---- SPACE -----
+ container.add(Box.createVerticalStrut(30), BorderLayout.NORTH);
+ container.add(Box.createHorizontalStrut(10), BorderLayout.WEST);
+ container.add(Box.createHorizontalStrut(10), BorderLayout.EAST);
+
+ params = new AppParameters();
+
+ //---------------------------------------------------------------------
+ cardPanel = new JTabbedPane(JTabbedPane.LEFT);
+ mainPanel.add(cardPanel, BorderLayout.CENTER);
+
+ cards = new Card[4];
+ int cardNo = 0;
+
+ //---------------------------------------------------------------------
+ // 1.[対象フォルダ]設定パネル
+ {
+ arg1_srcFolder = new ParameterPanelFolder(
+ i18n.getString("label.110") +": ",
+ params.getProperty(AppParameters.IMG_SOURCE_FOLDER)
+ );
+ arg1_srcFolder.argField
+ .getDocument()
+ .addDocumentListener(
+ new SimpleDocumentListener() {
+ @Override
+ public void update(DocumentEvent e) {
+ toEnable(0, arg1_srcFolder.isEnable());
+ }
+ }
+ );
+
+ Card card = new CardSourceFolder(cardPanel, arg1_srcFolder);
+ cardPanel.addTab(card.getTitle(), card);
+ cardPanel.setEnabledAt(cardNo, true);
+ cards[cardNo] = card;
+ cardNo++;
+ }
+
+ //---------------------------------------------------------------------
+ // 2.[基準時刻画像]設定パネル
+ // 2a.基準時刻の入力画面
+ {
+ // 基準時刻画像
+ arg2_baseTimeImg = new ParameterPanelImageFile(
+ i18n.getString("label.210") +": ",
+ null,
+ arg1_srcFolder
+ );
+
+ // 2a. 基準時刻:
+ arg2_basetime = new ParameterPanelTime(
+ i18n.getString("label.310"),
+ null,
+ arg2_baseTimeImg
+ );
+ arg2_basetime.argField.getDocument().addDocumentListener(
+ new SimpleDocumentListener() {
+ @Override
+ public void update(DocumentEvent e) {
+ toEnable(1, arg2_basetime.isEnable());
+ }
+ }
+ );
+
+ // EXIFの日時を基準にする
+ arg2_basetime.addExifBase(i18n.getString("label.220"), params);
+
+ // ファイル更新日時を基準にする
+ arg2_basetime.addFileUpdate(i18n.getString("label.230"), params);
+
+ CardImageFile card = new CardImageFile(
+ cardPanel, arg2_basetime, (Window)this,
+ AdjustTerra.i18n.getString("tab.300"), 0, 2);
+ cardPanel.addTab(card.getTitle(), card);
+ cardPanel.setEnabledAt(cardNo, false);
+ cards[cardNo] = card;
+ cardNo++;
+ }
+
+ //---------------------------------------------------------------------
+ // 3.GPXファイル設定画面
+ {
+ // 3. GPXファイル選択パラメータ
+ arg3_gpxFile = new ParameterPanelGpx(
+ i18n.getString("label.410") + ": ",
+ params.getProperty(AppParameters.GPX_SOURCE_FOLDER)
+ );
+ arg3_gpxFile.argField.getDocument().addDocumentListener(
+ new SimpleDocumentListener() {
+ @Override
+ public void update(DocumentEvent e) {
+ toEnable(2, arg3_gpxFile.isEnable());
+ }
+ }
+ );
+
+ // "セグメント'trkseg'の最初の1ノードは無視する。"
+ arg3_gpxFile.addNoFirstNode(i18n.getString("label.420"), params);
+
+ // 3. GPXファイルを選択
+ CardGpxFile card = new CardGpxFile(
+ cardPanel, arg3_gpxFile,
+ AdjustTerra.i18n.getString("tab.400"), 1, 3);
+ cardPanel.addTab(card.getTitle(), card);
+ cardPanel.setEnabledAt(cardNo, false);
+ cards[cardNo] = card;
+ cardNo++;
+ }
+
+ //---------------------------------------------------------------------
+ // 4.EXIF更新設定画面 & 実行画面
+ {
+ // 4. ファイル変換・実行パラメータ
+ // "出力フォルダ: "
+ arg4_output = new ParameterPanelOutput(
+ i18n.getString("label.530") + ": ",
+ params.getProperty(AppParameters.IMG_OUTPUT_FOLDER)
+ );
+ arg4_output.argField.getDocument().addDocumentListener(
+ new SimpleDocumentListener() {
+ @Override
+ public void update(DocumentEvent e) {
+ toEnable(3, arg4_output.isEnable());
+ }
+ }
+ );
+
+ // "IMGの変換をする"
+ arg4_output.addCheckChangeImage(i18n.getString("label.510"), params);
+
+ // "GPXファイル時間外のファイルもコピーする"
+ arg4_output.addCheckOutofGpxTime(i18n.getString("label.520"), params);
+
+ // "EXIFの変換をする"
+ arg4_output.addCheckOutputExif(i18n.getString("label.540"), params);
+
+ // "ソースGPXのを無視する"
+ arg4_output.addCheckIgnoreMagvar(i18n.getString("label.560"), params);
+
+ // "出力GPXに[SPEED]を上書きする"
+ arg4_output.addCheckOutputSpeed(i18n.getString("label.570"), params);
+
+ // パネル表示
+ CardExifPerform card = new CardExifPerform(
+ cardPanel,
+ arg2_basetime, arg3_gpxFile, arg4_output,
+ AdjustTerra.i18n.getString("tab.500"),
+ 2, -1
+ );
+ cardPanel.addTab(card.getTitle(), card);
+ cardPanel.setEnabledAt(cardNo, false);
+ cards[cardNo] = card;
+ }
+
+ //---------------------------------------------------------------------
+ // INIT_MENUS
+ menu1 = new java.awt.Menu("File");
+ miExit = new java.awt.MenuItem(i18n.getString("menu.quit"));
+ miExit.setFont(new Font("Dialog", Font.PLAIN, 12));
+ menu1.add(miExit);
+
+ miRestamp = new java.awt.MenuItem(i18n.getString("menu.restamp") + "...");
+ miRestamp.setFont(new Font("Dialog", Font.PLAIN, 12));
+
+ menu2 = new java.awt.Menu(i18n.getString("menu.tools"));
+ menu2.setFont(new Font("Dialog", Font.PLAIN, 12));
+ menu2.add(miRestamp);
+
+ miAbout = new java.awt.MenuItem("About...");
+ miAbout.setFont(new Font("Dialog", Font.PLAIN, 12));
+
+ menu3 = new java.awt.Menu("Help");
+ menu3.setFont(new Font("Dialog", Font.PLAIN, 12));
+ menu3.add(miAbout);
+
+ mainMenuBar = new java.awt.MenuBar();
+ mainMenuBar.setHelpMenu(menu3);
+ mainMenuBar.add(menu1);
+ mainMenuBar.add(menu2);
+ mainMenuBar.add(menu3);
+ setMenuBar(mainMenuBar);
+
+ //{{REGISTER_LISTENERS
+ SymWindow aSymWindow = new SymWindow();
+ this.addWindowListener(aSymWindow);
+ SymAction lSymAction = new SymAction();
+ miAbout.addActionListener(lSymAction);
+ miRestamp.addActionListener(lSymAction);
+ miExit.addActionListener(lSymAction);
+ arg2_baseTimeImg.openButton.addActionListener(lSymAction);
+ //}}
+ }
+
+ /**
+ * Shows or hides the component depending on the boolean flag b.
+ * @param b trueのときコンポーネントを表示; その他のとき, componentを隠す.
+ * @see java.awt.Component#isVisible
+ */
+ @Override
+ public void setVisible(boolean b) {
+ if(b) {
+ setLocation(50, 50);
+ }
+ super.setVisible(b);
+ }
+
+ /**
+ * このクラスをインスタンスを生成して表示する。
+ * コマンドラインの引数はありません。
+ * @param args
+ */
+ static public void main(String args[]) {
+ SwingUtilities.invokeLater(() -> {
+ try {
+ createAndShowGUI();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ });
+ }
+ private static void createAndShowGUI() throws IOException {
+ (new AdjustTerra()).setVisible(true);
+ }
+
+ @Override
+ public void addNotify() {
+ // Record the size of the window prior to calling parents addNotify.
+ Dimension d = getSize();
+
+ super.addNotify();
+
+ if (fComponentsAdjusted)
+ return;
+
+ // Adjust components according to the insets
+ setSize(getInsets().left + getInsets().right + d.width, getInsets().top + getInsets().bottom + d.height);
+ Component components[] = getComponents();
+ for (Component component : components) {
+ Point p = component.getLocation();
+ p.translate(getInsets().left, getInsets().top);
+ component.setLocation(p);
+ }
+ fComponentsAdjusted = true;
+ }
+
+ void DbMang_WindowClosing(java.awt.event.WindowEvent event) {
+ setVisible(false); // hide the Manager
+ dispose(); // free the system resources
+ System.exit(0); // close the application
+ }
+
+ void miAbout_Action(java.awt.event.ActionEvent event) {
+ // Action from About Create and show as modal
+ (new AboutDialog(this, true)).setVisible(true);
+ }
+
+ void miRestamp_Action(java.awt.event.ActionEvent event) throws IOException {
+ (new RestampDialog(this, false)).setVisible(true);
+ }
+
+ void miExit_Action(java.awt.event.ActionEvent event) {
+ // Action from Exit Create and show as modal
+ //(new hayashi.yuu.tools.gui.QuitDialog(this, true)).setVisible(true);
+ (new QuitDialog(this, true)).setVisible(true);
+ }
+
+ void toEnable(final int cardNo, final boolean enable) {
+ if ((cardNo >= 0) && (cardNo < cards.length)) {
+ cardPanel.setEnabledAt(cardNo, enable);
+ if ((cardNo -1) >= 0) {
+ cards[cardNo -1].nextButton.setEnabled(enable);
+ }
+ if ((cardNo +1) < cards.length) {
+ cardPanel.setEnabledAt(cardNo+1, enable);
+ cards[cardNo +1].backButton.setEnabled(enable);
+ cards[cardNo].nextButton.setEnabled(enable);
+ }
+ }
+ }
+
+ //ImageIcon refImage;
+
+ /** Returns an ImageIcon, or null if the path was invalid.
+ * @param path
+ * @return */
+ public static ImageIcon createImageIcon(String path) {
+ java.net.URL imgURL = AdjustTerra.class.getResource(path);
+ if (imgURL != null) {
+ return new ImageIcon(imgURL);
+ } else {
+ System.err.println("Couldn't find file: " + path);
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/AdjustTime.java b/src/main/java/osm/jp/gpx/matchtime/gui/AdjustTime.java
deleted file mode 100644
index a317344..0000000
--- a/src/main/java/osm/jp/gpx/matchtime/gui/AdjustTime.java
+++ /dev/null
@@ -1,424 +0,0 @@
-package osm.jp.gpx.matchtime.gui;
-
-import osm.jp.gpx.matchtime.gui.restamp.RestampDialog;
-import java.awt.*;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.ResourceBundle;
-import java.util.TimeZone;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.swing.*;
-import javax.swing.event.DocumentEvent;
-import osm.jp.gpx.*;
-import osm.jp.gpx.matchtime.gui.restamp.CardImageFile;
-import osm.jp.gpx.matchtime.gui.restamp.CardSourceFolder;
-
-/**
- * 本プログラムのメインクラス
- */
-@SuppressWarnings("serial")
-public class AdjustTime extends JFrame
-{
- public static final String PROGRAM_NAME = "AdjustTime for JOSM";
- public static final String PROGRAM_VARSION = "5.02";
- public static final String PROGRAM_UPDATE = "2019/10/22";
-
- AppParameters params;
- public static SimpleDateFormat dfjp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
-
- // Used for addNotify check.
- boolean fComponentsAdjusted = false;
- public static ResourceBundle i18n = ResourceBundle.getBundle("i18n");
-
- //{{DECLARE_CONTROLS
- JTabbedPane cardPanel; // ウィザード形式パネル(タブ型)
- Card[] cards;
- //}}
-
- //---入力フィールド----------------------------------------------------
- ParameterPanelFolder arg1_srcFolder; // 対象フォルダ
- ParameterPanelImageFile arg2_baseTimeImg; // 開始画像ファイルパス
- ParameterPanelTime arg2_basetime; // 開始画像の基準時刻:
- ParameterPanelGpx arg3_gpxFile; // GPX file or Folder
- ParameterPanelOutput arg4_output; // EXIF & 書き出しフォルダ
-
- //{{DECLARE_MENUS
- java.awt.MenuBar mainMenuBar;
- java.awt.Menu menu1;
- java.awt.MenuItem miDoNewFileList;
- java.awt.MenuItem miDoDirSize;
- java.awt.MenuItem miDoReadXML;
- java.awt.MenuItem miExit;
- java.awt.Menu menu2;
- java.awt.MenuItem miRestamp;
- java.awt.Menu menu3;
- java.awt.MenuItem miAbout;
- //}}
-
- class SymWindow extends java.awt.event.WindowAdapter {
- /**
- * このFrameが閉じられるときの動作。
- * このパネルが閉じられたら、このアプリケーションも終了させる。
- */
- @Override
- public void windowClosing(java.awt.event.WindowEvent event) {
- Object object = event.getSource();
- if (object == AdjustTime.this) {
- DbMang_WindowClosing(event);
- }
- }
- }
-
- class SymAction implements java.awt.event.ActionListener {
- @Override
- public void actionPerformed(java.awt.event.ActionEvent event) {
- Object object = event.getSource();
- if (object == miAbout) {
- miAbout_Action(event);
- }
- else if (object == miRestamp) {
- try {
- miRestamp_Action(event);
- } catch (IOException ex) {
- Logger.getLogger(AdjustTime.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- else if (object == miExit) {
- miExit_Action(event);
- }
- }
- }
-
- /**
- * データベース内のテーブルを一覧で表示するFrame
- * @throws IOException
- */
- @SuppressWarnings("OverridableMethodCallInConstructor")
- public AdjustTime() throws IOException
- {
- dfjp.setTimeZone(TimeZone.getTimeZone("JST"));
-
- // INIT_CONTROLS
- Container container = getContentPane();
- container.setLayout(new BorderLayout());
- setSize(
- getInsets().left + getInsets().right + 720,
- getInsets().top + getInsets().bottom + 480
- );
- setTitle(AdjustTime.PROGRAM_NAME +" v"+ AdjustTime.PROGRAM_VARSION);
-
- //---- CENTER -----
- JPanel mainPanel = new JPanel();
- mainPanel.setLayout(new BorderLayout());
- container.add(mainPanel, BorderLayout.CENTER);
-
- //---- SOUTH -----
- JPanel southPanel = new JPanel(new BorderLayout());
- southPanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);
- southPanel.add(Box.createVerticalStrut(10), BorderLayout.NORTH);
- container.add(southPanel, BorderLayout.SOUTH);
-
- //---- SPACE -----
- container.add(Box.createVerticalStrut(30), BorderLayout.NORTH);
- container.add(Box.createHorizontalStrut(10), BorderLayout.WEST);
- container.add(Box.createHorizontalStrut(10), BorderLayout.EAST);
-
- params = new AppParameters();
-
- //---------------------------------------------------------------------
- cardPanel = new JTabbedPane(JTabbedPane.LEFT);
- mainPanel.add(cardPanel, BorderLayout.CENTER);
-
- cards = new Card[4];
- int cardNo = 0;
-
- //---------------------------------------------------------------------
- // 1.[対象フォルダ]設定パネル
- {
- arg1_srcFolder = new ParameterPanelFolder(
- i18n.getString("label.110") +": ",
- params.getProperty(AppParameters.IMG_SOURCE_FOLDER)
- );
- arg1_srcFolder.argField
- .getDocument()
- .addDocumentListener(
- new SimpleDocumentListener() {
- @Override
- public void update(DocumentEvent e) {
- toEnable(0, arg1_srcFolder.isEnable());
- }
- }
- );
-
- Card card = new CardSourceFolder(cardPanel, arg1_srcFolder);
- cardPanel.addTab(card.getTitle(), card);
- cardPanel.setEnabledAt(cardNo, true);
- cards[cardNo] = card;
- cardNo++;
- }
-
- //---------------------------------------------------------------------
- // 2.[基準時刻画像]設定パネル
- // 2a.基準時刻の入力画面
- {
- // 基準時刻画像
- arg2_baseTimeImg = new ParameterPanelImageFile(
- i18n.getString("label.210") +": ",
- null,
- arg1_srcFolder
- );
-
- // 2a. 基準時刻:
- arg2_basetime = new ParameterPanelTime(
- i18n.getString("label.310"),
- null,
- arg2_baseTimeImg
- );
- arg2_basetime.argField.getDocument().addDocumentListener(
- new SimpleDocumentListener() {
- @Override
- public void update(DocumentEvent e) {
- toEnable(1, arg2_basetime.isEnable());
- }
- }
- );
-
- // EXIFの日時を基準にする
- arg2_basetime.addExifBase(i18n.getString("label.220"), params);
-
- // ファイル更新日時を基準にする
- arg2_basetime.addFileUpdate(i18n.getString("label.230"), params);
-
- CardImageFile card = new CardImageFile(
- cardPanel, arg2_basetime, (Window)this,
- AdjustTime.i18n.getString("tab.300"), 0, 2);
- cardPanel.addTab(card.getTitle(), card);
- cardPanel.setEnabledAt(cardNo, false);
- cards[cardNo] = card;
- cardNo++;
- }
-
- //---------------------------------------------------------------------
- // 3.GPXファイル設定画面
- {
- // 3. GPXファイル選択パラメータ
- arg3_gpxFile = new ParameterPanelGpx(
- i18n.getString("label.410") + ": ",
- params.getProperty(AppParameters.GPX_SOURCE_FOLDER)
- );
- arg3_gpxFile.argField.getDocument().addDocumentListener(
- new SimpleDocumentListener() {
- @Override
- public void update(DocumentEvent e) {
- toEnable(2, arg3_gpxFile.isEnable());
- }
- }
- );
-
- // "セグメント'trkseg'の最初の1ノードは無視する。"
- arg3_gpxFile.addNoFirstNode(i18n.getString("label.420"), params);
-
- // "生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も変換の対象にする"
- arg3_gpxFile.addGpxReuse(i18n.getString("label.430"), params);
-
- // 3. GPXファイルを選択
- CardGpxFile card = new CardGpxFile(
- cardPanel, arg3_gpxFile,
- AdjustTime.i18n.getString("tab.400"), 1, 3);
- cardPanel.addTab(card.getTitle(), card);
- cardPanel.setEnabledAt(cardNo, false);
- cards[cardNo] = card;
- cardNo++;
- }
-
- //---------------------------------------------------------------------
- // 4.EXIF更新設定画面 & 実行画面
- {
- // 4. ファイル変換・実行パラメータ
- // "出力フォルダ: "
- arg4_output = new ParameterPanelOutput(
- i18n.getString("label.530") + ": ",
- params.getProperty(AppParameters.IMG_OUTPUT_FOLDER)
- );
- arg4_output.argField.getDocument().addDocumentListener(
- new SimpleDocumentListener() {
- @Override
- public void update(DocumentEvent e) {
- toEnable(3, arg4_output.isEnable());
- }
- }
- );
-
- // "IMGの変換をする"
- arg4_output.addCheckChangeImage(i18n.getString("label.510"), params);
-
- // "GPXファイル時間外のファイルもコピーする"
- arg4_output.addCheckOutofGpxTime(i18n.getString("label.520"), params);
-
- // "EXIFの変換をする"
- arg4_output.addCheckOutputExif(i18n.getString("label.540"), params);
-
- // "ポイントマーカーをGPXファイルに出力する"
- arg4_output.addCheckOutputWpt(i18n.getString("label.550"), params);
-
- // "ソースGPXのを無視する"
- arg4_output.addCheckIgnoreMagvar(i18n.getString("label.560"), params);
-
- // "出力GPXに[SPEED]を上書きする"
- arg4_output.addCheckOutputSpeed(i18n.getString("label.570"), params);
-
- // パネル表示
- CardExifPerform card = new CardExifPerform(
- cardPanel,
- arg2_basetime, arg3_gpxFile, arg4_output,
- AdjustTime.i18n.getString("tab.500"),
- 2, -1
- );
- cardPanel.addTab(card.getTitle(), card);
- cardPanel.setEnabledAt(cardNo, false);
- cards[cardNo] = card;
- }
-
- //---------------------------------------------------------------------
- // INIT_MENUS
- menu1 = new java.awt.Menu("File");
- miExit = new java.awt.MenuItem(i18n.getString("menu.quit"));
- miExit.setFont(new Font("Dialog", Font.PLAIN, 12));
- menu1.add(miExit);
-
- miRestamp = new java.awt.MenuItem(i18n.getString("menu.restamp") + "...");
- miRestamp.setFont(new Font("Dialog", Font.PLAIN, 12));
-
- menu2 = new java.awt.Menu(i18n.getString("menu.tools"));
- menu2.setFont(new Font("Dialog", Font.PLAIN, 12));
- menu2.add(miRestamp);
-
- miAbout = new java.awt.MenuItem("About...");
- miAbout.setFont(new Font("Dialog", Font.PLAIN, 12));
-
- menu3 = new java.awt.Menu("Help");
- menu3.setFont(new Font("Dialog", Font.PLAIN, 12));
- menu3.add(miAbout);
-
- mainMenuBar = new java.awt.MenuBar();
- mainMenuBar.setHelpMenu(menu3);
- mainMenuBar.add(menu1);
- mainMenuBar.add(menu2);
- mainMenuBar.add(menu3);
- setMenuBar(mainMenuBar);
-
- //{{REGISTER_LISTENERS
- SymWindow aSymWindow = new SymWindow();
- this.addWindowListener(aSymWindow);
- SymAction lSymAction = new SymAction();
- miAbout.addActionListener(lSymAction);
- miRestamp.addActionListener(lSymAction);
- miExit.addActionListener(lSymAction);
- arg2_baseTimeImg.openButton.addActionListener(lSymAction);
- //}}
- }
-
- /**
- * Shows or hides the component depending on the boolean flag b.
- * @param b trueのときコンポーネントを表示; その他のとき, componentを隠す.
- * @see java.awt.Component#isVisible
- */
- @Override
- public void setVisible(boolean b) {
- if(b) {
- setLocation(50, 50);
- }
- super.setVisible(b);
- }
-
- /**
- * このクラスをインスタンスを生成して表示する。
- * コマンドラインの引数はありません。
- * @param args
- */
- @SuppressWarnings("UseSpecificCatch")
- static public void main(String args[]) {
- SwingUtilities.invokeLater(() -> {
- try {
- createAndShowGUI();
- } catch (Exception e) {
- e.printStackTrace();
- }
- });
- }
- private static void createAndShowGUI() throws IOException {
- (new AdjustTime()).setVisible(true);
- }
-
- @Override
- public void addNotify() {
- // Record the size of the window prior to calling parents addNotify.
- Dimension d = getSize();
-
- super.addNotify();
-
- if (fComponentsAdjusted)
- return;
-
- // Adjust components according to the insets
- setSize(getInsets().left + getInsets().right + d.width, getInsets().top + getInsets().bottom + d.height);
- Component components[] = getComponents();
- for (Component component : components) {
- Point p = component.getLocation();
- p.translate(getInsets().left, getInsets().top);
- component.setLocation(p);
- }
- fComponentsAdjusted = true;
- }
-
- void DbMang_WindowClosing(java.awt.event.WindowEvent event) {
- setVisible(false); // hide the Manager
- dispose(); // free the system resources
- System.exit(0); // close the application
- }
-
- void miAbout_Action(java.awt.event.ActionEvent event) {
- // Action from About Create and show as modal
- (new AboutDialog(this, true)).setVisible(true);
- }
-
- void miRestamp_Action(java.awt.event.ActionEvent event) throws IOException {
- (new RestampDialog(this, false)).setVisible(true);
- }
-
- void miExit_Action(java.awt.event.ActionEvent event) {
- // Action from Exit Create and show as modal
- //(new hayashi.yuu.tools.gui.QuitDialog(this, true)).setVisible(true);
- (new QuitDialog(this, true)).setVisible(true);
- }
-
- void toEnable(final int cardNo, final boolean enable) {
- if ((cardNo >= 0) && (cardNo < cards.length)) {
- cardPanel.setEnabledAt(cardNo, enable);
- if ((cardNo -1) >= 0) {
- cards[cardNo -1].nextButton.setEnabled(enable);
- }
- if ((cardNo +1) < cards.length) {
- cardPanel.setEnabledAt(cardNo+1, enable);
- cards[cardNo +1].backButton.setEnabled(enable);
- cards[cardNo].nextButton.setEnabled(enable);
- }
- }
- }
-
- //ImageIcon refImage;
-
- /** Returns an ImageIcon, or null if the path was invalid.
- * @param path
- * @return */
- public static ImageIcon createImageIcon(String path) {
- java.net.URL imgURL = AdjustTime.class.getResource(path);
- if (imgURL != null) {
- return new ImageIcon(imgURL);
- } else {
- System.err.println("Couldn't find file: " + path);
- return null;
- }
- }
-}
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/Card.java b/src/main/java/osm/jp/gpx/matchtime/gui/Card.java
index 1956aeb..bc14b82 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/Card.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/Card.java
@@ -10,10 +10,11 @@
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
-import static osm.jp.gpx.matchtime.gui.AdjustTime.i18n;
+import static osm.jp.gpx.matchtime.gui.AdjustTerra.i18n;
public class Card extends JPanel {
- JTabbedPane tabbe;
+ private static final long serialVersionUID = 9050047381377607421L;
+ JTabbedPane tabbe;
public JPanel mainPanel;
String title;
int backNumber = -1;
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/CardExifPerform.java b/src/main/java/osm/jp/gpx/matchtime/gui/CardExifPerform.java
index a2f95fb..2c79270 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/CardExifPerform.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/CardExifPerform.java
@@ -9,15 +9,16 @@
import javax.swing.JTabbedPane;
import osm.jp.gpx.AppParameters;
import osm.jp.gpx.ImportPicture;
-import static osm.jp.gpx.matchtime.gui.AdjustTime.dfjp;
-import static osm.jp.gpx.matchtime.gui.AdjustTime.i18n;
+import static osm.jp.gpx.matchtime.gui.AdjustTerra.dfjp;
+import static osm.jp.gpx.matchtime.gui.AdjustTerra.i18n;
/**
* 実行パネル
* @author yuu
*/
public class CardExifPerform extends Card implements PanelAction {
- ParameterPanelTime arg_basetime; // 画像の基準時刻:
+ private static final long serialVersionUID = 8902284630791931118L;
+ ParameterPanelTime arg_basetime; // 画像の基準時刻:
ParameterPanelGpx arg_gpxFile; // GPX file or Folder
ParameterPanelOutput arg_output; // EXIF & 書き出しフォルダ
JButton doButton; // [処理実行]ボタン
@@ -83,11 +84,6 @@
argsPanel.add(arg_output.exifON);
}
- // チェックボックス "ポイントマーカーをGPXファイルに出力する"
- if (arg_output.gpxOutputWpt != null) {
- argsPanel.add(arg_output.gpxOutputWpt);
- }
-
// チェックボックス "ソースGPXのを無視する"
if (arg_output.gpxOverwriteMagvar != null) {
argsPanel.add(arg_output.gpxOverwriteMagvar);
@@ -101,7 +97,7 @@
// [処理実行]ボタン
doButton = new JButton(
i18n.getString("button.execute"),
- AdjustTime.createImageIcon("images/media_playback_start.png")
+ AdjustTerra.createImageIcon("/images/media_playback_start.png")
);
argsPanel.add(doButton);
@@ -139,7 +135,6 @@
* [実行]ボタンをクリックしたときの動作
* @param event
*/
- @SuppressWarnings("UseSpecificCatch")
void doButton_Action(java.awt.event.ActionEvent event) {
doButton.setEnabled(false);
@@ -149,9 +144,7 @@
try {
AppParameters params = new AppParameters();
- String[] argv = new String[0];
params.setProperty(AppParameters.GPX_NO_FIRST_NODE, String.valueOf(arg_gpxFile.isNoFirstNodeSelected()));
- params.setProperty(AppParameters.GPX_REUSE, String.valueOf(arg_gpxFile.isGpxReuseSelected()));
params.setProperty(AppParameters.GPX_SOURCE_FOLDER, arg_gpxFile.getText());
if ((arg_basetime.exifBase != null) && arg_basetime.exifBase.isSelected()) {
params.setProperty(AppParameters.GPX_BASETIME, "EXIF_TIME");
@@ -162,13 +155,14 @@
params.setProperty(AppParameters.IMG_SOURCE_FOLDER, arg_srcFolder.getText());
params.setProperty(AppParameters.IMG_BASE_FILE, arg_baseTimeImg.getText());
params.setProperty(AppParameters.IMG_TIME, ImportPicture.toUTCString(dfjp.parse(arg_basetime.getText())));
+
params.setProperty(AppParameters.IMG_OUTPUT, String.valueOf(arg_output.outputIMG.isSelected()));
params.setProperty(AppParameters.IMG_OUTPUT_ALL, String.valueOf(arg_output.outputIMG_all.isSelected()));
params.setProperty(AppParameters.IMG_OUTPUT_FOLDER, arg_output.getText());
+
params.setProperty(AppParameters.IMG_OUTPUT_EXIF, String.valueOf(arg_output.exifON.isSelected()));
params.setProperty(AppParameters.GPX_OVERWRITE_MAGVAR, String.valueOf(arg_output.gpxOverwriteMagvar.isSelected()));
params.setProperty(AppParameters.GPX_OUTPUT_SPEED, String.valueOf(arg_output.gpxOutputSpeed.isSelected()));
- params.setProperty(AppParameters.GPX_OUTPUT_WPT, String.valueOf(arg_output.gpxOutputWpt.isSelected()));
params.store();
}
catch(Exception e) {
@@ -190,7 +184,6 @@
}
@Override
- @SuppressWarnings("empty-statement")
public void openAction() {
; // 何もしない
}
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/CardGpxFile.java b/src/main/java/osm/jp/gpx/matchtime/gui/CardGpxFile.java
index bd9f49f..64d825b 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/CardGpxFile.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/CardGpxFile.java
@@ -6,14 +6,15 @@
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
-import static osm.jp.gpx.matchtime.gui.AdjustTime.i18n;
+import static osm.jp.gpx.matchtime.gui.AdjustTerra.i18n;
/**
* [GPXファイル]選択パネル
- * @author yuu
+ * @author haya4
*/
public class CardGpxFile extends Card implements PanelAction {
- ParameterPanelGpx arg_gpxFile;
+ private static final long serialVersionUID = -6130918418152241845L;
+ ParameterPanelGpx arg_gpxFile;
/**
* コンストラクタ
@@ -44,11 +45,6 @@
argsPanel.add(arg_gpxFile.noFirstNode);
}
- // "生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も変換の対象にする"
- if (arg_gpxFile.gpxReuse != null) {
- argsPanel.add(arg_gpxFile.gpxReuse);
- }
-
JPanel space = new JPanel();
space.setMinimumSize(new Dimension(40, 20));
space.setMaximumSize(new Dimension(40, Short.MAX_VALUE));
@@ -67,7 +63,6 @@
}
@Override
- @SuppressWarnings("empty-statement")
public void openAction() {
; // 何もしない
}
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/DoDialog.java b/src/main/java/osm/jp/gpx/matchtime/gui/DoDialog.java
index 8c991e1..a558bd0 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/DoDialog.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/DoDialog.java
@@ -27,13 +27,11 @@
JTextArea textArea; // 実行結果を表示するJTextArea (中央)
//}}
- @SuppressWarnings("OverridableMethodCallInConstructor")
public DoDialog(String[] args) {
super(); // モーダルダイアログを基盤にする
this.args = args;
// INIT_CONTROLS
- @SuppressWarnings("OverridableMethodCallInConstructor")
Container container = getContentPane();
container.setLayout(new BorderLayout());
//parentFrame.setVisible(false);
@@ -183,7 +181,6 @@
// 非同期に行われる処理
@Override
- @SuppressWarnings("SleepWhileInLoop")
public Object doInBackground() {
// ながーい処理
PrintStream defOut = System.out;
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ImageFileView.java b/src/main/java/osm/jp/gpx/matchtime/gui/ImageFileView.java
index 5507511..708c25a 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/ImageFileView.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/ImageFileView.java
@@ -37,10 +37,10 @@
/* ImageFileView.java is used by FileChooserDemo2.java. */
public class ImageFileView extends FileView {
- ImageIcon jpgIcon = Utils.createImageIcon("images/jpgIcon.gif");
- ImageIcon gifIcon = Utils.createImageIcon("images/gifIcon.gif");
- ImageIcon tiffIcon = Utils.createImageIcon("images/tiffIcon.gif");
- ImageIcon pngIcon = Utils.createImageIcon("images/pngIcon.png");
+ ImageIcon jpgIcon = Utils.createImageIcon("/images/jpgIcon.gif");
+ ImageIcon gifIcon = Utils.createImageIcon("/images/gifIcon.gif");
+ ImageIcon tiffIcon = Utils.createImageIcon("/images/tiffIcon.gif");
+ ImageIcon pngIcon = Utils.createImageIcon("/images/pngIcon.png");
@Override
public String getName(File f) {
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ImagePreview.java b/src/main/java/osm/jp/gpx/matchtime/gui/ImagePreview.java
index 203d3a2..d07d90f 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/ImagePreview.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/ImagePreview.java
@@ -45,7 +45,7 @@
static int IMAGE_SIZE_X = 320;
static int IMAGE_SIZE_Y = 240;
- @SuppressWarnings({"LeakingThisInConstructor", "OverridableMethodCallInConstructor"})
+ @SuppressWarnings({})
public ImagePreview(JFileChooser fc) {
setPreferredSize(new Dimension(IMAGE_SIZE_X + 10, IMAGE_SIZE_Y + 10));
fc.addPropertyChangeListener(this);
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanel.java b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanel.java
index 00f1418..d26be5e 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanel.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanel.java
@@ -18,7 +18,6 @@
public JLabel argLabel;
public ResourceBundle i18n = ResourceBundle.getBundle("i18n");
- @SuppressWarnings("OverridableMethodCallInConstructor")
public ParameterPanel(String label, String text) {
this();
this.argLabel.setText(label);
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelFolder.java b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelFolder.java
index a27a330..b6dae01 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelFolder.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelFolder.java
@@ -24,7 +24,6 @@
this(label, text, JFileChooser.DIRECTORIES_ONLY);
}
- @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"})
public ParameterPanelFolder(String label, String text, int chooser) {
super(label, text);
@@ -34,7 +33,7 @@
// "選択..."
selectButton = new JButton(
i18n.getString("button.select"),
- AdjustTime.createImageIcon("images/Open16.gif")
+ AdjustTerra.createImageIcon("/images/Open16.gif")
);
selectButton.addActionListener(this);
this.add(selectButton);
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelGpx.java b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelGpx.java
index 586f795..ddb975e 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelGpx.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelGpx.java
@@ -15,21 +15,19 @@
JFileChooser fc;
JButton selectButton;
public JCheckBox noFirstNode; // CheckBox: "セグメント'trkseg'の最初の1ノードは無視する。"
- public JCheckBox gpxReuse; // CheckBox: "生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も変換の対象にする"
/**
* コンストラクタ
* @param label
* @param text
*/
- @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"})
public ParameterPanelGpx(String label, String text) {
super(label, text);
// "選択..."
selectButton = new JButton(
i18n.getString("button.select"),
- AdjustTime.createImageIcon("images/Open16.gif")
+ AdjustTerra.createImageIcon("/images/Open16.gif")
);
selectButton.addActionListener(this);
this.add(selectButton);
@@ -84,23 +82,6 @@
}
/**
- * "生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も変換の対象にする"
- * @param label テキスト
- * @param params プロパティ
- */
- public void addGpxReuse(String label, AppParameters params) {
- boolean selected = false;
- if (params.getProperty(AppParameters.GPX_REUSE).equals("true")) {
- selected = true;
- }
- gpxReuse = new JCheckBox(label, selected);
- }
-
- public boolean isGpxReuseSelected() {
- return (gpxReuse != null) && gpxReuse.isSelected();
- }
-
- /**
* このフィールドに有効な値が設定されているかどうか
* @return
*/
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java
index 2c99c17..829a8a1 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java
@@ -12,7 +12,6 @@
public JButton openButton;
public ParameterPanelFolder paramDir;
- @SuppressWarnings("OverridableMethodCallInConstructor")
public ParameterPanelImageFile(
String label, String text,
ParameterPanelFolder paramDir
@@ -31,7 +30,6 @@
class SelectButtonAction implements java.awt.event.ActionListener
{
- @SuppressWarnings("override")
public void actionPerformed(ActionEvent e) {
selectImage_Action(e);
}
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelOutput.java b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelOutput.java
index ce4b1ea..07059b2 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelOutput.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelOutput.java
@@ -10,7 +10,6 @@
JCheckBox outputIMG; // IMGの変換 する/しない
JCheckBox outputIMG_all; // 'out of GPX time'でもIMGの変換をする {ON | OFF}
JCheckBox exifON; // EXIF 書き出しモード / !(EXIFの書き換えはしない)
- JCheckBox gpxOutputWpt; // GPXにを書き出す
JCheckBox gpxOverwriteMagvar; // ソースGPXのを無視する
JCheckBox gpxOutputSpeed; // GPXにを書き出す
@@ -64,20 +63,6 @@
}
/**
- * チェックボックス "ポイントマーカー[WPT]をGPXファイルに出力する"
- * @param label
- * @param params
- */
- public void addCheckOutputWpt(String label, AppParameters params) {
- boolean selected = false;
- if (params.getProperty(AppParameters.GPX_OUTPUT_WPT).equals("true")) {
- selected = true;
- }
- gpxOutputWpt = new JCheckBox(label, selected);
- gpxOutputWpt.setEnabled(true);
- }
-
- /**
* チェックボックス "ソースGPXの<MAGVAR>を無視する"
* @param label
* @param params
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelSelecter.java b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelSelecter.java
index 15b8d96..251710f 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelSelecter.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelSelecter.java
@@ -18,7 +18,6 @@
public JComboBox field;
public String value;
- @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"})
public ParameterPanelSelecter(String title, String[] items) {
super(null);
this.value = items[0];
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java
index b50ed43..1202e7e 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java
@@ -19,7 +19,7 @@
import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants;
import osm.jp.gpx.AppParameters;
import osm.jp.gpx.Restamp;
-import static osm.jp.gpx.matchtime.gui.AdjustTime.dfjp;
+import static osm.jp.gpx.matchtime.gui.AdjustTerra.dfjp;
import osm.jp.gpx.matchtime.gui.restamp.DialogCorectTime;
/**
@@ -27,7 +27,8 @@
* この1インスタンスで、1パラメータをあらわす。
*/
public class ParameterPanelTime extends ParameterPanel {
- SimpleDateFormat sdf = (SimpleDateFormat)DateFormat.getDateTimeInstance();
+ private static final long serialVersionUID = 1683226418990348336L;
+ SimpleDateFormat sdf = (SimpleDateFormat)DateFormat.getDateTimeInstance();
ParameterPanelImageFile imageFile; // 基準時刻画像
@@ -40,7 +41,6 @@
public JButton resetButton;
Window owner;
- @SuppressWarnings("OverridableMethodCallInConstructor")
public ParameterPanelTime(
String label,
String text,
@@ -112,7 +112,6 @@
this.param = param;
}
- @SuppressWarnings("override")
public void actionPerformed(ActionEvent e) {
fileSelect_Action(param);
(new DialogCorectTime(param, owner)).setVisible(true);
@@ -130,7 +129,6 @@
this.paramPanelTime = param;
}
- @SuppressWarnings("override")
public void actionPerformed(ActionEvent e) {
fileSelect_Action(paramPanelTime);
}
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/QuitDialog.java b/src/main/java/osm/jp/gpx/matchtime/gui/QuitDialog.java
index bf5b9e3..9f63cba 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/QuitDialog.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/QuitDialog.java
@@ -20,7 +20,6 @@
JButton noButton;
JLabel label1;
- @SuppressWarnings("OverridableMethodCallInConstructor")
public QuitDialog(JFrame parent, boolean modal) {
super(parent, modal);
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/images/Fit16.gif b/src/main/java/osm/jp/gpx/matchtime/gui/images/Fit16.gif
deleted file mode 100644
index 0d94f66..0000000
--- a/src/main/java/osm/jp/gpx/matchtime/gui/images/Fit16.gif
+++ /dev/null
Binary files differ
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/images/Open16.gif b/src/main/java/osm/jp/gpx/matchtime/gui/images/Open16.gif
deleted file mode 100644
index fabd567..0000000
--- a/src/main/java/osm/jp/gpx/matchtime/gui/images/Open16.gif
+++ /dev/null
Binary files differ
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/images/Original16.gif b/src/main/java/osm/jp/gpx/matchtime/gui/images/Original16.gif
deleted file mode 100644
index 57e71ce..0000000
--- a/src/main/java/osm/jp/gpx/matchtime/gui/images/Original16.gif
+++ /dev/null
Binary files differ
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/images/Rotate16.gif b/src/main/java/osm/jp/gpx/matchtime/gui/images/Rotate16.gif
deleted file mode 100644
index 587b9d2..0000000
--- a/src/main/java/osm/jp/gpx/matchtime/gui/images/Rotate16.gif
+++ /dev/null
Binary files differ
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/images/Save16.gif b/src/main/java/osm/jp/gpx/matchtime/gui/images/Save16.gif
deleted file mode 100644
index 954f1ac..0000000
--- a/src/main/java/osm/jp/gpx/matchtime/gui/images/Save16.gif
+++ /dev/null
Binary files differ
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/images/ZoomIn16.gif b/src/main/java/osm/jp/gpx/matchtime/gui/images/ZoomIn16.gif
deleted file mode 100644
index 2329426..0000000
--- a/src/main/java/osm/jp/gpx/matchtime/gui/images/ZoomIn16.gif
+++ /dev/null
Binary files differ
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/images/ZoomOut16.gif b/src/main/java/osm/jp/gpx/matchtime/gui/images/ZoomOut16.gif
deleted file mode 100644
index f9f7565..0000000
--- a/src/main/java/osm/jp/gpx/matchtime/gui/images/ZoomOut16.gif
+++ /dev/null
Binary files differ
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/images/gifIcon.gif b/src/main/java/osm/jp/gpx/matchtime/gui/images/gifIcon.gif
deleted file mode 100644
index 915e184..0000000
--- a/src/main/java/osm/jp/gpx/matchtime/gui/images/gifIcon.gif
+++ /dev/null
Binary files differ
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/images/jpgIcon.gif b/src/main/java/osm/jp/gpx/matchtime/gui/images/jpgIcon.gif
deleted file mode 100644
index 7294f36..0000000
--- a/src/main/java/osm/jp/gpx/matchtime/gui/images/jpgIcon.gif
+++ /dev/null
Binary files differ
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/images/media_playback_start.png b/src/main/java/osm/jp/gpx/matchtime/gui/images/media_playback_start.png
deleted file mode 100644
index 2f8c4b5..0000000
--- a/src/main/java/osm/jp/gpx/matchtime/gui/images/media_playback_start.png
+++ /dev/null
Binary files differ
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/images/pngIcon.png b/src/main/java/osm/jp/gpx/matchtime/gui/images/pngIcon.png
deleted file mode 100644
index bd2fd54..0000000
--- a/src/main/java/osm/jp/gpx/matchtime/gui/images/pngIcon.png
+++ /dev/null
Binary files differ
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/images/tiffIcon.gif b/src/main/java/osm/jp/gpx/matchtime/gui/images/tiffIcon.gif
deleted file mode 100644
index 84b4132..0000000
--- a/src/main/java/osm/jp/gpx/matchtime/gui/images/tiffIcon.gif
+++ /dev/null
Binary files differ
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardImageFile.java b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardImageFile.java
index 9d8826d..9ebcd0a 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardImageFile.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardImageFile.java
@@ -7,7 +7,7 @@
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
-import static osm.jp.gpx.matchtime.gui.AdjustTime.i18n;
+import static osm.jp.gpx.matchtime.gui.AdjustTerra.i18n;
import osm.jp.gpx.matchtime.gui.Card;
import osm.jp.gpx.matchtime.gui.PanelAction;
import osm.jp.gpx.matchtime.gui.ParameterPanelImageFile;
@@ -15,10 +15,11 @@
/**
* [基準画像(開始/終了)]選択パネル
- * @author yuu
+ * @author haya4
*/
public class CardImageFile extends Card implements PanelAction {
- ParameterPanelImageFile arg_baseTimeImg;
+ private static final long serialVersionUID = 1L;
+ ParameterPanelImageFile arg_baseTimeImg;
ParameterPanelTime arg_basetime;
/**
@@ -82,7 +83,6 @@
}
@Override
- @SuppressWarnings("empty-statement")
public void openAction() {
; // 何もしない
}
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardPerformFile.java b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardPerformFile.java
index e8cd76c..c323d7c 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardPerformFile.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardPerformFile.java
@@ -8,8 +8,8 @@
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
-import osm.jp.gpx.matchtime.gui.AdjustTime;
-import static osm.jp.gpx.matchtime.gui.AdjustTime.i18n;
+import osm.jp.gpx.matchtime.gui.AdjustTerra;
+import static osm.jp.gpx.matchtime.gui.AdjustTerra.i18n;
import osm.jp.gpx.matchtime.gui.Card;
import osm.jp.gpx.matchtime.gui.PanelAction;
import osm.jp.gpx.matchtime.gui.ParameterPanelTime;
@@ -19,7 +19,7 @@
* @author yuu
*/
public class CardPerformFile extends Card implements PanelAction {
- //JPanel argsPanel; // パラメータ設定パネル (上部)
+ private static final long serialVersionUID = -4796133437768564759L;
ParameterPanelTime arg1_basetime;
ParameterPanelTime arg2_basetime;
JButton doButton; // [処理実行]ボタン
@@ -35,7 +35,7 @@
ParameterPanelTime arg1_basetime,
ParameterPanelTime arg2_basetime
) {
- super(tabbe, AdjustTime.i18n.getString("tab.restamp.400"), 2, 4);
+ super(tabbe, AdjustTerra.i18n.getString("tab.restamp.400"), 2, 4);
this.arg1_basetime = arg1_basetime;
this.arg2_basetime = arg2_basetime;
@@ -46,7 +46,7 @@
// [処理実行]ボタン
doButton = new JButton(
i18n.getString("button.execute"),
- AdjustTime.createImageIcon("images/media_playback_start.png")
+ AdjustTerra.createImageIcon("/images/media_playback_start.png")
);
argsPanel.add(doButton);
@@ -72,7 +72,6 @@
* [実行]ボタンをクリックしたときの動作
* @param event
*/
- @SuppressWarnings("UseSpecificCatch")
void doButton_Action(java.awt.event.ActionEvent event) {
ArrayList arry = new ArrayList<>();
File file = arg1_basetime.getImageFile().getImageFile();
@@ -97,7 +96,6 @@
}
@Override
- @SuppressWarnings("empty-statement")
public void openAction() {
; // 何もしない
}
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardSourceFolder.java b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardSourceFolder.java
index 0250271..bc967bd 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardSourceFolder.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardSourceFolder.java
@@ -5,8 +5,8 @@
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
-import osm.jp.gpx.matchtime.gui.AdjustTime;
-import static osm.jp.gpx.matchtime.gui.AdjustTime.i18n;
+import osm.jp.gpx.matchtime.gui.AdjustTerra;
+import static osm.jp.gpx.matchtime.gui.AdjustTerra.i18n;
import osm.jp.gpx.matchtime.gui.Card;
import osm.jp.gpx.matchtime.gui.PanelAction;
import osm.jp.gpx.matchtime.gui.ParameterPanelFolder;
@@ -16,7 +16,8 @@
* @author yuu
*/
public class CardSourceFolder extends Card implements PanelAction {
- ParameterPanelFolder arg_srcFolder; // 対象フォルダ
+ private static final long serialVersionUID = -5496892696559069841L;
+ ParameterPanelFolder arg_srcFolder; // 対象フォルダ
/**
* コンストラクタ
@@ -24,7 +25,7 @@
* @param arg_srcFolder 対象フォルダ
*/
public CardSourceFolder(JTabbedPane tabbe, ParameterPanelFolder arg_srcFolder) {
- super(tabbe, AdjustTime.i18n.getString("tab.100"), -1, 1);
+ super(tabbe, AdjustTerra.i18n.getString("tab.100"), -1, 1);
this.arg_srcFolder = arg_srcFolder;
this.mainPanel.add(new JLabel(i18n.getString("label.100")), BorderLayout.NORTH);
@@ -44,7 +45,6 @@
}
@Override
- @SuppressWarnings("empty-statement")
public void openAction() {
; // 何もしない
}
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/DialogCorectTime.java b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/DialogCorectTime.java
index e026cce..89e81c3 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/DialogCorectTime.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/DialogCorectTime.java
@@ -13,9 +13,9 @@
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import osm.jp.gpx.matchtime.gui.AdjustTime;
-import static osm.jp.gpx.matchtime.gui.AdjustTime.createImageIcon;
-import static osm.jp.gpx.matchtime.gui.AdjustTime.i18n;
+import osm.jp.gpx.matchtime.gui.AdjustTerra;
+import static osm.jp.gpx.matchtime.gui.AdjustTerra.createImageIcon;
+import static osm.jp.gpx.matchtime.gui.AdjustTerra.i18n;
import osm.jp.gpx.matchtime.gui.PanelAction;
import osm.jp.gpx.matchtime.gui.ParameterPanelTime;
@@ -24,7 +24,8 @@
* @author yuu
*/
public class DialogCorectTime extends JDialog implements PanelAction {
- public JPanel mainPanel;
+ private static final long serialVersionUID = -3573167730473345932L;
+ public JPanel mainPanel;
ParameterPanelTime arg_basetime; // 開始画像の基準時刻(parent)
ParameterPanelTime basetime; // 開始画像の基準時刻(tempolarry)
java.awt.Button closeButton;
@@ -39,9 +40,8 @@
* @param arg3_basetime 開始画像の基準時刻:
* @param owner
*/
- @SuppressWarnings("OverridableMethodCallInConstructor")
public DialogCorectTime(ParameterPanelTime arg3_basetime, Window owner) {
- super(owner, AdjustTime.i18n.getString("tab.restamp.300"), Dialog.ModalityType.DOCUMENT_MODAL);
+ super(owner, AdjustTerra.i18n.getString("tab.restamp.300"), Dialog.ModalityType.DOCUMENT_MODAL);
this.arg_basetime = arg3_basetime;
// INIT_CONTROLS
@@ -87,11 +87,11 @@
// 画像ファイル選択ダイアログを起動するボタン
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
- expandButton = new JButton(createImageIcon(java.util.ResourceBundle.getBundle("i18n_ja_JP").getString("IMAGES/FIT16.GIF")));
+ expandButton = new JButton(createImageIcon("/images/Fit16.gif"));
buttonPanel.add(expandButton);
- zoomInButton = new JButton(createImageIcon("images/ZoomIn16.gif"));
+ zoomInButton = new JButton(createImageIcon("/images/ZoomIn16.gif"));
buttonPanel.add(zoomInButton);
- zoomOutButton = new JButton(createImageIcon("images/ZoomOut16.gif"));
+ zoomOutButton = new JButton(createImageIcon("/images/ZoomOut16.gif"));
buttonPanel.add(zoomOutButton);
centerPanel.add(buttonPanel, BorderLayout.SOUTH);
@@ -152,7 +152,6 @@
* 選択された画像ファイルを表示する
* 基準画像ボタンがクリックされた時に、基準時刻フィールドに基準画像の作成日時を設定する。
*/
- @SuppressWarnings("UseSpecificCatch")
public void imageView_Action() {
try {
String path = basetime.getImageFile().getImageFile().getAbsolutePath();
@@ -214,7 +213,6 @@
}
@Override
- @SuppressWarnings("empty-statement")
public void openAction() {
; // 何もしない
}
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/DoRestamp.java b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/DoRestamp.java
index 27d355a..e98f1ba 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/DoRestamp.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/DoRestamp.java
@@ -28,16 +28,13 @@
JTextArea textArea; // 実行結果を表示するJTextArea (中央)
//}}
- @SuppressWarnings("OverridableMethodCallInConstructor")
public DoRestamp(String[] args) {
super(); // 親フォームなしのモーダルダイアログを基盤にする
this.args = args;
// INIT_CONTROLS
- @SuppressWarnings("OverridableMethodCallInConstructor")
Container container = getContentPane();
container.setLayout(new BorderLayout());
- //parentFrame.setVisible(false);
setSize(getInsets().left + getInsets().right + 980, getInsets().top + getInsets().bottom + 480);
setTitle(DoRestamp.TITLE);
@@ -184,7 +181,6 @@
// 非同期に行われる処理
@Override
- @SuppressWarnings("SleepWhileInLoop")
public Object doInBackground() {
// ながーい処理
PrintStream defOut = System.out;
diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java
index 0df254a..110bfac 100644
--- a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java
+++ b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java
@@ -4,11 +4,11 @@
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import osm.jp.gpx.AppParameters;
-import osm.jp.gpx.matchtime.gui.AdjustTime;
+import osm.jp.gpx.matchtime.gui.AdjustTerra;
import osm.jp.gpx.matchtime.gui.Card;
import osm.jp.gpx.matchtime.gui.ParameterPanelFolder;
import osm.jp.gpx.matchtime.gui.ParameterPanelImageFile;
-import static osm.jp.gpx.matchtime.gui.AdjustTime.i18n;
+import static osm.jp.gpx.matchtime.gui.AdjustTerra.i18n;
import osm.jp.gpx.matchtime.gui.ParameterPanelTime;
import osm.jp.gpx.matchtime.gui.SimpleDocumentListener;
@@ -49,7 +49,6 @@
}
}
- @SuppressWarnings("OverridableMethodCallInConstructor")
public RestampDialog(Frame parent, boolean modal) throws IOException {
super(parent, modal);
@@ -142,7 +141,7 @@
CardImageFile card = new CardImageFile(
cardPanel, arg2_basetime, (Window)this,
- AdjustTime.i18n.getString("tab.restamp.200"), 0, 2);
+ AdjustTerra.i18n.getString("tab.restamp.200"), 0, 2);
cardPanel.addTab(card.getTitle(), card);
cardPanel.setEnabledAt(cardNo, false);
cards[cardNo] = card;
@@ -176,7 +175,7 @@
CardImageFile card = new CardImageFile(
cardPanel, arg3_basetime, (Window)this,
- AdjustTime.i18n.getString("tab.restamp.250"), 1, 3
+ AdjustTerra.i18n.getString("tab.restamp.250"), 1, 3
);
cardPanel.addTab(card.getTitle(), card);
cardPanel.setEnabledAt(cardNo, false);
@@ -221,7 +220,6 @@
}
}
- @SuppressWarnings("OverridableMethodCallInConstructor")
public RestampDialog(Frame parent, String title, boolean modal) throws IOException {
this(parent, modal);
setTitle(title);
diff --git a/src/main/java/osm/jp/gpx/utils/TarGz.java b/src/main/java/osm/jp/gpx/utils/TarGz.java
deleted file mode 100644
index b447f8c..0000000
--- a/src/main/java/osm/jp/gpx/utils/TarGz.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package osm.jp.gpx.utils;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
-import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
-import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
-
-/**
- * 「*.tar.gz」を解凍する。
- * ファイル更新日時をオリジナルと同じにします。
- * Apache Commons Compressライブラリ
- * commons-compress-1.14.jar
- */
-public abstract class TarGz
-{
- public static void main(String[] args) throws IOException {
- File baseDir = new File("testdata/cameradata");
- File tazFile = new File("testdata", "Sony20170518.tar.gz");
- TarGz.uncompress(tazFile, baseDir);
- }
-
- /**
- * *.tar.gz解凍
- * ファイル更新日時をオリジナルと同じにします。
- * @param tazFile 解凍する*.tar.gzファイル
- * @param dest 解凍先フォルダ
- * @throws IOException
- */
- public static void uncompress(File tazFile, File dest) throws IOException {
- dest.mkdir();
-
- TarArchiveInputStream tarIn = null;
- tarIn = new TarArchiveInputStream(new GzipCompressorInputStream(new BufferedInputStream(new FileInputStream(tazFile))));
-
- TarArchiveEntry tarEntry = tarIn.getNextTarEntry();
- while (tarEntry != null) {
- File destPath = new File(dest, tarEntry.getName());
- System.out.println("uncompress: " + destPath.getCanonicalPath());
- if (tarEntry.isDirectory()) {
- destPath.mkdirs();
- }
- else {
- File dir = new File(destPath.getParent());
- if (!dir.exists()) {
- dir.mkdirs();
- }
- destPath.createNewFile();
- byte[] btoRead = new byte[1024];
- try (BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(destPath))) {
- int len = 0;
- while ((len = tarIn.read(btoRead)) != -1) {
- bout.write(btoRead, 0, len);
- }
- }
- destPath.setLastModified(tarEntry.getLastModifiedDate().getTime());
- btoRead = null;
- }
- tarEntry = tarIn.getNextTarEntry();
- }
- tarIn.close();
- }
-}
diff --git a/src/main/resources/AdjustTerra.bat b/src/main/resources/AdjustTerra.bat
new file mode 100644
index 0000000..c1d573e
--- /dev/null
+++ b/src/main/resources/AdjustTerra.bat
@@ -0,0 +1 @@
+javaw -cp AdjustTerra.jar osm.jp.gpx.matchtime.gui.AdjustTerra
diff --git a/src/main/resources/AdjustTerra.sh b/src/main/resources/AdjustTerra.sh
new file mode 100644
index 0000000..2993ed7
--- /dev/null
+++ b/src/main/resources/AdjustTerra.sh
@@ -0,0 +1,2 @@
+javaw -cp AdjustTerra.jar osm.jp.gpx.matchtime.gui.AdjustTerra
+
diff --git a/src/main/resources/AdjustTime.ini b/src/main/resources/AdjustTime.ini
deleted file mode 100644
index 3d439b1..0000000
--- a/src/main/resources/AdjustTime.ini
+++ /dev/null
@@ -1,13 +0,0 @@
-#by AdjustTime
-GPX.BASETIME=EXIF_TIME
-IMG.OUTPUT_EXIF=true
-GPX.OUTPUT_SPEED=false
-GPX.noFirstNode=true
-IMG.OUTPUT=false
-GPX.gpxSplit=true
-IMG.TIME=2016-08-14T11\:45\:47
-GPX.REUSE=true
-IMG.BASE_FILE=IMG_0182.jpg
-IMG.SOURCE_FOLDER=.
-GPX.SOURCE_FOLDER=.
-IMG.OUTPUT_FOLDER=.
\ No newline at end of file
diff --git a/src/main/resources/AdjustTime2.bat b/src/main/resources/AdjustTime2.bat
deleted file mode 100644
index 96ed170..0000000
--- a/src/main/resources/AdjustTime2.bat
+++ /dev/null
@@ -1 +0,0 @@
-javaw -cp .;AdjustTime2.jar;commons-compress-1.14.jar;commons-imaging-1.0-20170205.201009-115.jar osm.jp.gpx.matchtime.gui.AdjustTime
diff --git a/src/main/resources/AdjustTime2.jnlp b/src/main/resources/AdjustTime2.jnlp
deleted file mode 100644
index d865797..0000000
--- a/src/main/resources/AdjustTime2.jnlp
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
- SwingSet2 Demo Application
- Sun Microsystems, Inc.
-
- SwingSet2 Demo Application
- A demo of the capabilities
-of the Swing Graphical User Interface.
-
-
-
-
-
-
-
-
-
-
-
-
-
- SwingSet2 Demo on Linux
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/resources/AdjustTime2.sh b/src/main/resources/AdjustTime2.sh
deleted file mode 100644
index bae5196..0000000
--- a/src/main/resources/AdjustTime2.sh
+++ /dev/null
@@ -1 +0,0 @@
-javaw -cp .:AdjustTime2.jar:commons-compress-1.14.jar:commons-imaging-1.0-20170205.201009-115.jar osm.jp.gpx.matchtime.gui.AdjustTime
diff --git a/src/main/resources/README.jp.txt b/src/main/resources/README.jp.txt
index 2749310..cc3890f 100644
--- a/src/main/resources/README.jp.txt
+++ b/src/main/resources/README.jp.txt
@@ -1,4 +1,4 @@
-[ AdjustTime ]
+[ AdjustTerra ]
GPSログファイル(GPX)を元にして写真へ「位置情報(緯度経度)」と「方向」を追記します。(EXIF更新)
@@ -26,14 +26,14 @@
http://sourceforge.jp/projects/importpicture/wiki/FrontPage
[起動]
-下記のように'AdjustTime'を起動するとGUIでパラメータを逐次設定可能です。(推奨起動方法)
+下記のように'AdjustTerra'を起動するとGUIでパラメータを逐次設定可能です。(推奨起動方法)
-> java -cp .:AdjustTime2.jar:commons-imaging-1.0-SNAPSHOT.jar osm.jp.gpx.matchtime.gui.AdjustTime
+> java -cp AdjustTerra.jar osm.jp.gpx.matchtime.gui.AdjustTerra
下記のコマンドラインによる起動方式は度重なる機能追加によりパラメーターが増大したため複雑になりすぎ作者でさえわけがわからなくなりました。
一応、過去の起動方法を記載しておきます。しかし、コマンドラインからの引数は2016-10-03版以降は正しく引き継がれません。
-'AdjustTime2.jar'と'AdjustTime.ini'を使ってください。
+GUI版の'AdjustTerra.jar'を使ってください。
> java -jar importPicture.jar