Skip to content

Commit

Permalink
Merge branch '2016-11' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
reubot authored Dec 13, 2017
2 parents cd6a736 + 34025ae commit 2f73aab
Show file tree
Hide file tree
Showing 9 changed files with 1,342 additions and 801 deletions.
27 changes: 18 additions & 9 deletions GO_Sync/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,20 @@
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>edu.usf.cutr.go_sync.gui.MainForm</mainClass>
<packageName>edu.usf.cutr.go_sync.gui</packageName>
</manifest>
<archive>
<manifest>
<mainClass>edu.usf.cutr.go_sync.gui.MainForm</mainClass>
<packageName>edu.usf.cutr.go_sync.gui</packageName>
</manifest>
<manifestEntries>
<mode>development</mode>
<url>${pom.url}</url>
<url>${project.url}</url>
</manifestEntries>
</archive>
</configuration>
Expand Down Expand Up @@ -96,6 +97,14 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Expand Down
60 changes: 44 additions & 16 deletions GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/MainForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,17 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.ProgressMonitor;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.*;

import edu.usf.cutr.go_sync.object.OperatorInfo;
import edu.usf.cutr.go_sync.task.CompareData;
import edu.usf.cutr.go_sync.task.OsmTask;
import edu.usf.cutr.go_sync.task.RevertChangeset;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.HttpURLConnection;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -58,13 +51,13 @@
import java.awt.event.KeyListener;

import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout;
import javax.swing.LayoutStyle.ComponentPlacement;

import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.Dimension;

//TODO add radius selection
/**
*
Expand All @@ -85,6 +78,7 @@ public class MainForm extends javax.swing.JFrame implements PropertyChangeListen
private OsmTask task;
private List<DefaultOperator> ops;


/** Creates new form MainForm */
public MainForm() {
setMinimumSize(new Dimension(660, 460));
Expand Down Expand Up @@ -387,7 +381,24 @@ public void itemStateChanged(java.awt.event.ItemEvent evt) {
gbc_jLabel1.gridwidth = 12;
gbc_jLabel1.gridx = 0;
gbc_jLabel1.gridy = 3;

compareDataPanel.add(jLabel1, gbc_jLabel1);


distanceThreshold = new JSpinner();
distanceThreshold.setValue(400);
GridBagConstraints gbc_threshold = new GridBagConstraints();
JLabel threshold_label = new JLabel("Approximate Comparision Distance Threshold (m)");
// gbc_threshold.fill = GridBagConstraints.HORIZONTAL;
gbc_threshold.insets = new Insets(0, 0, 5, 5);
gbc_threshold.gridwidth = 12;

gbc_threshold.gridy = 4;
gbc_threshold.gridx = 0;
compareDataPanel.add(threshold_label,gbc_threshold);
gbc_threshold.gridx = 6;
compareDataPanel.add(distanceThreshold, gbc_threshold);

compareButton = new javax.swing.JButton();

compareButton.setText("Run");
Expand All @@ -400,7 +411,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
gbc_compareButton.insets = new Insets(0, 0, 0, 5);
gbc_compareButton.gridwidth = 12;
gbc_compareButton.gridx = 0;
gbc_compareButton.gridy = 4;
gbc_compareButton.gridy = 5;
compareDataPanel.add(compareButton, gbc_compareButton);

revertChangesetPanel.setName(""); // NOI18N
Expand Down Expand Up @@ -551,6 +562,7 @@ private void compareButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN
progressMonitor.setProgress(0);
compareButton.setEnabled(false);
compareTask = new CompareData(progressMonitor, taskOutput);
compareTask.setRangeThreshold(Double.parseDouble(distanceThreshold.getValue().toString()));
task = compareTask;
task.addPropertyChangeListener(this);
try{
Expand Down Expand Up @@ -629,8 +641,21 @@ private boolean UnzipGTFS(File zipFile, URL zipURL) {
//TODO test that URL is actually ZIP files

if (zipFile == null) {
//TODO check ftp codes
if (zipURL.getProtocol().equals("http"))
{
HttpURLConnection zipHttpCon = ((HttpURLConnection)zipURL.openConnection());
int response_code = zipHttpCon.getResponseCode();
if (response_code != 200 ) {
taskOutput.append("HTTP server returned " +response_code + " " + zipHttpCon.getResponseMessage());
System.err.println("HTTP server returned " +response_code);
return false;
}
}
System.out.println("Unzipping " + zipURL.toString() + " to " + unzipLocation);
zip = new ZipInputStream(zipURL.openStream());
InputStream zipstr = zipURL.openStream();
System.out.println(zipstr + " " );
zip = new ZipInputStream(new BufferedInputStream(zipstr));
} else {
if (!(Files.probeContentType(zipFile.toPath())).equals("application/zip"))
{System.out.println((Files.probeContentType(zipFile.toPath())));
Expand All @@ -640,6 +665,7 @@ private boolean UnzipGTFS(File zipFile, URL zipURL) {
}

ZipEntry next_file;
// System.out.println("Zip is " + zip.available() + zip.getNextEntry());

while ((next_file = zip.getNextEntry()) != null) {

Expand All @@ -653,6 +679,7 @@ private boolean UnzipGTFS(File zipFile, URL zipURL) {
out.write(buf, 0, len);
}


out.close();
//out.flush();
//do any processing here if you’d like
Expand Down Expand Up @@ -694,15 +721,15 @@ public static void main(String args[]) {
try {
// Set system native Java L&F
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (UnsupportedLookAndFeelException e) {
} catch (UnsupportedLookAndFeelException|ClassNotFoundException|InstantiationException|IllegalAccessException e) {
System.err.println("Error setting LookAndFeel: " + e.getLocalizedMessage());
} catch (ClassNotFoundException e) {
/* } catch (ClassNotFoundException e) {
System.err.println("Error setting LookAndFeel: " + e.getLocalizedMessage());
} catch (InstantiationException e) {
System.err.println("Error setting LookAndFeel: " + e.getLocalizedMessage());
} catch (IllegalAccessException e) {
System.err.println("Error setting LookAndFeel: " + e.getLocalizedMessage());
}
*/ }

java.awt.EventQueue.invokeLater(new Runnable() {

Expand Down Expand Up @@ -747,6 +774,7 @@ public void propertyChange(PropertyChangeEvent evt) {
private javax.swing.JLabel fileNameLabel;
private javax.swing.JTextField gtfsIdDigitField;
private javax.swing.JLabel jLabel1;
private JSpinner distanceThreshold;
private javax.swing.JPanel compareDataPanel;
private javax.swing.JPanel revertChangesetPanel;
private javax.swing.JPanel gtfsDataPanel;
Expand Down
Loading

0 comments on commit 2f73aab

Please sign in to comment.