Skip to content

Commit

Permalink
More verbose GUI and Adding folder optimization
Browse files Browse the repository at this point in the history
-Optimized adding folder: if there are no subdirectories then the folder is added without asking for subdirectories. #17
-Output on GUI when processing Bearing
  • Loading branch information
james2432 committed Sep 1, 2017
1 parent aaef605 commit 8dc8135
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="jlCurrentlyProc" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jlProcessing" pref="426" max="32767" attributes="0"/>
<Component id="jlProcessing" pref="472" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
Expand All @@ -35,10 +35,10 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jlCurrentlyProc" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jlCurrentlyProc" alignment="3" min="-2" pref="27" max="-2" attributes="0"/>
<Component id="jlProcessing" alignment="3" min="-2" pref="47" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="78" max="32767" attributes="0"/>
<EmptySpace pref="97" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ private void initComponents() {
.addContainerGap()
.addComponent(jlCurrentlyProc)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jlProcessing, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE)
.addComponent(jlProcessing, javax.swing.GroupLayout.DEFAULT_SIZE, 472, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jlCurrentlyProc)
.addComponent(jlCurrentlyProc, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jlProcessing, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(78, Short.MAX_VALUE))
.addContainerGap(97, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents

Expand Down
44 changes: 30 additions & 14 deletions OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ public void setBearing(){
if(bearing_offset==null){
return;
}
JFMain topframe = (JFMain)SwingUtilities.getWindowAncestor(this);
topframe.showInfoBox();
topframe.setInfoBoxText("Sorting items, please wait");
Thread t = new Thread(){
public void run(){
processBearing(dir,(int)bearing_offset);
Expand All @@ -133,6 +136,7 @@ public void run(){
}

public void processBearing(String directory, int Offset){
JFMain topframe = (JFMain)SwingUtilities.getWindowAncestor(this);
File dir_photos = new File(directory);
//filter only .jpgs
FilenameFilter fileNameFilter = new FilenameFilter() {
Expand Down Expand Up @@ -163,9 +167,11 @@ public int compare(File f1, File f2)
ImageProperties imTO = null;
ImageProperties imFROM = null;
for(int i=file_list.length-1;i>=0;i--){
topframe.setInfoBoxText("Setting Bearing for:" + file_list[i]);
if(i==0){
//TODO: set last bearing
try{

Helper.setBearing(file_list[i], last_bearing);
}
catch(IOException|ImageReadException|ImageWriteException ex){
Expand All @@ -184,13 +190,15 @@ public int compare(File f1, File f2)
}
last_bearing = (Helper.calc_bearing(imFROM.getLatitude(), imFROM.getLongitude(), imTO.getLatitude(), imTO.getLongitude())+ Offset) % 360.00;
System.out.println("Calculated bearing (with offset) at: " + last_bearing);
topframe.setInfoBoxText("<html>Setting Bearing for:" + file_list[i] + "<br/>" + last_bearing + "</html>");
try{
Helper.setBearing(file_list[i], last_bearing);
}
catch(IOException|ImageReadException|ImageWriteException ex){
Logger.getLogger(JPMain.class.getName()).log(Level.SEVERE, "Error writing exif data", ex);
}
}
topframe.setInfoBoxText("Done");
}

private void setUILang(){
Expand Down Expand Up @@ -974,25 +982,33 @@ private void jbAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:e
int returnVal = fc.showSaveDialog(this);
if(returnVal == JFileChooser.APPROVE_OPTION) {
if(fc.getSelectedFiles().length==1){
int response = JOptionPane.showConfirmDialog(null, new String(r.getString("immediate_sub_folders").getBytes(), StandardCharsets.UTF_8), new String(r.getString("add_subfolders").getBytes(), StandardCharsets.UTF_8), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if(response == JOptionPane.NO_OPTION){
File folder = fc.getSelectedFile();
listDir.add(folder.getPath());
last_dir=folder.getPath();
}
else if (response == JOptionPane.YES_OPTION)
{
//Get a list of subdirectories
String[] subDirs = fc.getSelectedFile().list(new FilenameFilter(){
//Get a list of subdirectories
String[] subDirs = fc.getCurrentDirectory().list(new FilenameFilter(){
@Override
public boolean accept(File current, String name){
return new File(current,name).isDirectory();
}
});
});
if(subDirs.length>0){
int response = JOptionPane.showConfirmDialog(null, new String(r.getString("immediate_sub_folders").getBytes(), StandardCharsets.UTF_8), new String(r.getString("add_subfolders").getBytes(), StandardCharsets.UTF_8), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if(response == JOptionPane.NO_OPTION){
File folder = fc.getCurrentDirectory();
listDir.add(folder.getPath());
last_dir=folder.getPath();
}
else if (response == JOptionPane.YES_OPTION)
{


for(String subDir: subDirs){
listDir.add(new File(fc.getSelectedFile() + File.separator + subDir).getPath());
}
for(String subDir: subDirs){
listDir.add(new File(fc.getSelectedFile() + File.separator + subDir).getPath());
}
}
}
else{
File folder = fc.getCurrentDirectory();
listDir.add(folder.getPath());
last_dir=folder.getPath();
}
}
else if(fc.getSelectedFiles().length > 1)
Expand Down

0 comments on commit 8dc8135

Please sign in to comment.