Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
imagej-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
imagej-elphel
Commits
d6e178fd
Commit
d6e178fd
authored
Aug 30, 2025
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implementing properties editing/merging
parent
fea4dfdc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
163 additions
and
12 deletions
+163
-12
QuadCLTCPU.java
...main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
+163
-12
No files found.
src/main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
View file @
d6e178fd
...
...
@@ -4835,21 +4835,35 @@ public class QuadCLTCPU {
public
static
void
compareProperties
()
{
String
path1
=
"/media/elphel/SSD3-4GB/lwir16-proc/berdich3/models/models_1697875868-1697879449-b/1697877436_779067/39-dbg-02-11/1697877436_779067-INTERFRAME.corr-xml"
;
String
path2
=
"/media/elphel/SSD3-4GB/lwir16-proc/berdich3/models/models_1697875868-1697879449-b/1697877436_779067/37-dbg-01-11_noeig/1697877436_779067-INTERFRAME.corr-xml"
;
String
path1
=
"/home/elphel/lwir16-proc/eagle_mountain/configs/M51-eagle_mountain_night_02-5_4-FONT8_enh25-frac0.07_0.1_0.3-A0.4TS0.055-RS4.5-RRMS0.37-HORIZ370-HR0.45_W1.5:0.05:0.7:2:1.5-R0_7-A2A0.5-SAVEALL_tar_str-0.2-NODEBUG.corr-xml"
;
String
path2
=
"/home/elphel/lwir16-proc/eagle_mountain/configs/old/old_01/C062D-1747829570_155008-full_V5-NOINF_CALIBRATED_gmt-6-cuas_ref_sigma0_ser33-60scenes_nodebuglma_no-model_UM2-1.0_str0.28_min_str_lma0.8_frac0.1_mb_noraw_cuas.corr-xml"
;
boolean
exclude_source_paths
=
true
;
boolean
edit_mismaches
=
false
;
GenericJTabbedDialog
gd
=
new
GenericJTabbedDialog
(
"Set image pair"
,
1200
,
800
);
gd
.
addStringField
(
"First configuration path"
,
path1
,
180
,
"Full path of the first configuration properties file."
);
gd
.
addStringField
(
"Second configuration path"
,
path2
,
180
,
"Second path of the first configuration properties file."
);
gd
.
addStringField
(
"First configuration path"
,
path1
,
250
,
"Full path of the first configuration properties file."
);
gd
.
addStringField
(
"Second configuration path"
,
path2
,
250
,
"Second path of the first configuration properties file."
);
gd
.
addCheckbox
(
"Exclude source paths"
,
exclude_source_paths
,
"exclude CORRECTION_PARAMETERS.sourcePathXXX from the comparison."
);
gd
.
addCheckbox
(
"Edit mismatches"
,
edit_mismaches
,
"Ask which differences to apply."
);
gd
.
showDialog
();
if
(
gd
.
wasCanceled
())
return
;
path1
=
gd
.
getNextString
();
path2
=
gd
.
getNextString
();
compareProperties
(
path1
,
path2
);
exclude_source_paths
=
gd
.
getNextBoolean
();
edit_mismaches
=
gd
.
getNextBoolean
();
compareProperties
(
path1
,
path2
,
exclude_source_paths
,
edit_mismaches
);
}
public
static
void
compareProperties
(
String
path1
,
String
path2
)
{
String
path2
,
boolean
exclude_source_paths
,
boolean
edit_mismaches
)
{
if
(
path1
.
startsWith
(
"file:///"
))
{
path1
=
path1
.
substring
(
7
);
}
if
(
path2
.
startsWith
(
"file:///"
))
{
path2
=
path2
.
substring
(
7
);
}
Properties
properties1
,
properties2
;
properties1
=
loadProperties
(
path1
,
// String path,
...
...
@@ -4863,6 +4877,7 @@ public class QuadCLTCPU {
// Enumeration<String> en2 = (Enumeration<String>) properties2.propertyNames();
System
.
out
.
println
(
"path1 = "
+
path1
);
System
.
out
.
println
(
"path2 = "
+
path2
);
ArrayList
<
String
>
keys
=
new
ArrayList
<
String
>();
int
num_diff
=
0
;
for
(
@SuppressWarnings
(
"unchecked"
)
Enumeration
<
String
>
e
=
(
Enumeration
<
String
>)
properties1
.
propertyNames
();
e
.
hasMoreElements
();)
{
...
...
@@ -4870,6 +4885,10 @@ public class QuadCLTCPU {
String
v1
=
properties1
.
getProperty
(
key
);
String
v2
=
properties2
.
getProperty
(
key
);
if
(!
v1
.
equals
(
v2
))
{
if
(
exclude_source_paths
&&
key
.
contains
(
"CORRECTION_PARAMETERS.sourcePath"
))
{
continue
;
}
keys
.
add
(
key
);
System
.
out
.
println
(
"property1["
+
key
+
"] = "
+
v1
+
", property2["
+
key
+
"] = "
+
v2
);
num_diff
++;
}
...
...
@@ -4879,16 +4898,148 @@ public class QuadCLTCPU {
String
key
=
e
.
nextElement
();
String
v1
=
properties1
.
getProperty
(
key
);
String
v2
=
properties2
.
getProperty
(
key
);
if
(
v1
==
null
)
{
// other already printed
if
(
exclude_source_paths
&&
key
.
contains
(
"CORRECTION_PARAMETERS.sourcePath"
))
{
continue
;
}
keys
.
add
(
key
);
System
.
out
.
println
(
"property1["
+
key
+
"] = "
+
v1
+
", property2["
+
key
+
"] = "
+
v2
);
num_diff
++;
}
}
System
.
out
.
println
(
num_diff
+
" differences found"
);
if
(
edit_mismaches
)
{
int
indx
=
path2
.
lastIndexOf
(
"."
);
String
ext
=
path2
.
substring
(
indx
);
String
save_path
=
path2
.
substring
(
0
,
indx
)+
"-modified"
+
ext
;
boolean
[]
edits
=
new
boolean
[
keys
.
size
()];
boolean
done
=
false
;
while
(!
done
)
{
boolean
select_all
=
false
;
boolean
select_none
=
false
;
GenericJTabbedDialog
gd
=
new
GenericJTabbedDialog
(
"Set image pair"
,
1500
,
1000
);
for
(
int
i
=
0
;
i
<
edits
.
length
;
i
++)
{
String
key
=
keys
.
get
(
i
);
String
v1
=
properties1
.
getProperty
(
key
);
String
v2
=
properties2
.
getProperty
(
key
);
gd
.
addCheckbox
(
key
+
": "
+
"\""
+
v1
+
"\" -> \""
+
v2
+
"\""
,
edits
[
i
],
"Replace old value of the \""
+
key
+
"\" property of the file2 with the value from file1"
);
}
gd
.
addMessage
(
"--- Select/Deselect all changes, reopen dialog ---"
);
gd
.
addCheckbox
(
"Select all"
,
select_all
,
"Select all changes to apply, reopen dialog."
);
gd
.
addCheckbox
(
"Deselect all"
,
select_none
,
"Deselect all changes to apply, reopen dialog."
);
gd
.
addStringField
(
"Save path"
,
save_path
,
250
,
"Where to save modified second file."
);
String
[]
labels
=
{
"OK"
,
"Apply"
,
"Cancel"
};
String
[]
actions
=
{
"OK"
,
"_Apply"
,
"Cancel"
};
String
[]
tooltips
=
labels
;
gd
.
addButtons
(
labels
,
actions
,
tooltips
);
gd
.
showDialog
();
if
(
gd
.
wasCanceled
())
{
done
=
true
;
break
;
}
for
(
int
i
=
0
;
i
<
edits
.
length
;
i
++)
{
edits
[
i
]
=
gd
.
getNextBoolean
();
}
select_all
=
gd
.
getNextBoolean
();
select_none
=
gd
.
getNextBoolean
();
path1
=
gd
.
getNextString
();
if
(
select_all
)
{
Arrays
.
fill
(
edits
,
true
);
continue
;
}
if
(
select_none
)
{
Arrays
.
fill
(
edits
,
false
);
continue
;
}
for
(
int
i
=
0
;
i
<
edits
.
length
;
i
++)
if
(
edits
[
i
]){
String
key
=
keys
.
get
(
i
);
String
v1
=
properties1
.
getProperty
(
key
);
if
(
v1
==
null
)
{
properties2
.
remove
(
key
);
}
else
{
properties2
.
setProperty
(
key
,
v1
);
}
}
// re-evaluate all properties:
keys
=
new
ArrayList
<
String
>();
num_diff
=
0
;
for
(
@SuppressWarnings
(
"unchecked"
)
Enumeration
<
String
>
e
=
(
Enumeration
<
String
>)
properties1
.
propertyNames
();
e
.
hasMoreElements
();)
{
String
key
=
e
.
nextElement
();
String
v1
=
properties1
.
getProperty
(
key
);
String
v2
=
properties2
.
getProperty
(
key
);
if
(!
v1
.
equals
(
v2
))
{
if
(
exclude_source_paths
&&
key
.
contains
(
"CORRECTION_PARAMETERS.sourcePath"
))
{
continue
;
}
keys
.
add
(
key
);
// System.out.println("property1["+key+"] = " + v1+", property2["+key+"] = " +v2);
num_diff
++;
}
}
for
(
@SuppressWarnings
(
"unchecked"
)
Enumeration
<
String
>
e
=
(
Enumeration
<
String
>)
properties2
.
propertyNames
();
e
.
hasMoreElements
();)
{
String
key
=
e
.
nextElement
();
String
v1
=
properties1
.
getProperty
(
key
);
String
v2
=
properties2
.
getProperty
(
key
);
if
(
v1
==
null
)
{
// other already printed
if
(
exclude_source_paths
&&
key
.
contains
(
"CORRECTION_PARAMETERS.sourcePath"
))
{
continue
;
}
keys
.
add
(
key
);
// System.out.println("property1["+key+"] = " + v1+", property2["+key+"] = " +v2);
num_diff
++;
}
}
System
.
out
.
println
(
num_diff
+
" differences found"
);
edits
=
new
boolean
[
keys
.
size
()];
// all unselected
if
(!
gd
.
wasOKed
()){
// apply
OutputStream
os
;
try
{
os
=
new
FileOutputStream
(
save_path
);
}
catch
(
FileNotFoundException
e1
)
{
// missing config directory
File
dir
=
(
new
File
(
save_path
)).
getParentFile
();
if
(!
dir
.
exists
())
{
dir
.
mkdirs
();
try
{
os
=
new
FileOutputStream
(
save_path
);
}
catch
(
FileNotFoundException
e2
)
{
IJ
.
showMessage
(
"Error"
,
"Failed to create directory "
+
dir
.
getName
()
+
" to save configuration file: "
+
save_path
);
return
;
}
}
else
{
IJ
.
showMessage
(
"Error"
,
"Failed to open configuration file: "
+
save_path
);
return
;
}
}
try
{
properties2
.
storeToXML
(
os
,
"last updated "
+
new
java
.
util
.
Date
(),
"UTF8"
);
}
catch
(
IOException
e
)
{
IJ
.
showMessage
(
"Error"
,
"Failed to write XML configuration file: "
+
save_path
);
return
;
}
try
{
os
.
close
();
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
System
.
out
.
println
(
"Configuration parameters are saved to "
+
save_path
);
return
;
}
}
}
return
;
}
public
boolean
propertiesContainString
(
String
needle
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment