Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Showing with 96 additions and 37 deletions.
  1. BIN jars/JGps.jar
  2. +31 −17 src/ui/GpsDataLogger.form
  3. +35 −20 src/ui/GpsDataLogger.java
  4. +30 −0 src/ui/SaveTimer.java
View
BIN jars/JGps.jar
Binary file not shown.
View
48 src/ui/GpsDataLogger.form
@@ -103,7 +103,6 @@
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
- <Component id="mLogAllCheckBox" alignment="1" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="mLatitudeLabel" alignment="0" min="-2" max="-2" attributes="0"/>
@@ -116,13 +115,15 @@
<Component id="mLogSpeedSpinner" min="-2" pref="59" max="-2" attributes="0"/>
</Group>
<Component id="mFixModeLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="mSpeedLabel" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
- <EmptySpace min="0" pref="175" max="32767" attributes="0"/>
- </Group>
- <Group type="102" alignment="1" attributes="0">
- <Component id="mSpeedLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
+ <Group type="102" attributes="0">
+ <Component id="mSaveLabel" min="-2" pref="136" max="-2" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
+ <Component id="mLogAllCheckBox" min="-2" pref="213" max="-2" attributes="0"/>
+ </Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -133,28 +134,36 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
- <EmptySpace max="-2" attributes="0"/>
- <Component id="mLogAllCheckBox" min="-2" max="-2" attributes="0"/>
- <EmptySpace max="-2" attributes="0"/>
- <Component id="mLatitudeLabel" min="-2" max="-2" attributes="0"/>
- <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace pref="12" max="32767" attributes="0"/>
+ <Component id="mSaveLabel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
+ <Component id="mLatitudeLabel" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="mLogAllCheckBox" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="mLongitudeLabel" min="-2" max="-2" attributes="0"/>
- <EmptySpace max="-2" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="mAltitudeLabel" min="-2" max="-2" attributes="0"/>
- <EmptySpace max="-2" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="mHeadingLabel" min="-2" max="-2" attributes="0"/>
- <EmptySpace max="-2" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="mSpeedLabel" min="-2" max="-2" attributes="0"/>
- <EmptySpace max="-2" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="mFixModeLabel" min="-2" max="-2" attributes="0"/>
- <EmptySpace max="-2" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="mAverageSpeedLabel" min="-2" max="-2" attributes="0"/>
- <EmptySpace max="32767" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="mLogAboveSpeedLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="mLogSpeedSpinner" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
- <EmptySpace max="-2" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -235,5 +244,10 @@
<Property name="text" type="java.lang.String" value="Fix Mode: 1"/>
</Properties>
</Component>
+ <Component class="javax.swing.JLabel" name="mSaveLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Save"/>
+ </Properties>
+ </Component>
</SubComponents>
</Form>
View
55 src/ui/GpsDataLogger.java
@@ -15,6 +15,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
+import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
import util.rxtx.GpsSerialDataListener;
import util.rxtx.RxTxUtilities;
@@ -46,6 +47,8 @@ public GpsDataLogger() {
mLoggedCoordinates = new ArrayList<>();
+ mSaveLabel.setText(" ");
+
}
/** This method is called from within the constructor to
@@ -67,6 +70,7 @@ private void initComponents() {
mLogSpeedSpinner = new javax.swing.JSpinner();
mLogAllCheckBox = new javax.swing.JCheckBox();
mFixModeLabel = new javax.swing.JLabel();
+ mSaveLabel = new javax.swing.JLabel();
mMenuBar = new javax.swing.JMenuBar();
mFileMenu = new javax.swing.JMenu();
mClearCoordinatesMenuItem = new javax.swing.JMenuItem();
@@ -110,6 +114,8 @@ private void initComponents() {
mFixModeLabel.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
mFixModeLabel.setText("Fix Mode: 1");
+ mSaveLabel.setText("Save");
+
mFileMenu.setText("File");
mClearCoordinatesMenuItem.setText("Clear Logged Coordinates");
@@ -177,7 +183,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(mLogAllCheckBox, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(mLatitudeLabel)
@@ -188,20 +193,27 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(mLogAboveSpeedLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(mLogSpeedSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(mFixModeLabel))
- .addGap(0, 175, Short.MAX_VALUE))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addComponent(mSpeedLabel)
- .addGap(0, 0, Short.MAX_VALUE)))
+ .addComponent(mFixModeLabel)
+ .addComponent(mSpeedLabel))
+ .addGap(0, 0, Short.MAX_VALUE))
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(mSaveLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(mLogAllCheckBox, javax.swing.GroupLayout.PREFERRED_SIZE, 213, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(mLogAllCheckBox)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(mLatitudeLabel)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap(12, Short.MAX_VALUE)
+ .addComponent(mSaveLabel)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(mLatitudeLabel))
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(mLogAllCheckBox)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(mLongitudeLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@@ -214,7 +226,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(mFixModeLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(mAverageSpeedLabel)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(mLogAboveSpeedLabel)
.addComponent(mLogSpeedSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
@@ -257,18 +269,17 @@ private void mClearCoordinatesMenuItemActionPerformed(java.awt.event.ActionEvent
private void mSaveKmlMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mSaveKmlMenuItemActionPerformed
JFileChooser chooser = new JFileChooser();
-
- //Will need file filter
-
+ FileNameExtensionFilter filter = new FileNameExtensionFilter(("Keyhole Markup Language"), "kml");
+ chooser.setFileFilter(filter);
if (chooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION){
try {
//Create the KML object
Kml kml = new Kml();
Placemark placemark = kml.createAndSetPlacemark();
Style style = placemark.createAndAddStyle();
LineStyle lineStyle = style.createAndSetLineStyle();
- lineStyle.setWidth(2.0);
- lineStyle.setColor("ff000000");
+ lineStyle.setWidth(4.0);
+ lineStyle.setColor("7fee0000");
LineString linestring = placemark.createAndSetLineString();
//Add coordinates
linestring.setCoordinates(mLoggedCoordinates);
@@ -296,6 +307,7 @@ private void mSaveKmlMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//
private javax.swing.JLabel mLongitudeLabel;
private javax.swing.JMenuBar mMenuBar;
private javax.swing.JMenuItem mSaveKmlMenuItem;
+ private javax.swing.JLabel mSaveLabel;
private javax.swing.JMenu mSerialPortMenu;
private javax.swing.JLabel mSpeedLabel;
private javax.swing.JMenuItem mStartMenuItem;
@@ -329,7 +341,7 @@ public void update(Observable o, Object arg) {
mAltitudeLabel.setText("Altitude: " + numberFormatter.format(DistanceConversion.metersToFeet(model.getAltitude())));
mSpeedLabel.setText("Speed: " + model.getSpeedOverGround());
mHeadingLabel.setText("Heading: " + model.getTrueCourse());
-
+
//Set fix mode
mFixModeLabel.setText("Fix Mode: " + model.getFixMode());
@@ -343,7 +355,7 @@ public void update(Observable o, Object arg) {
if (model.getLatitudeHemisphere().equals("S")){
latitude = latitude * -1;
}
-
+
//Log coordinate if log all or speed cut off is met
if (mLogAllCheckBox.isSelected()){
logCoordinate(longitude, latitude, model.getAltitude());
@@ -360,10 +372,13 @@ public void update(Observable o, Object arg) {
}
}
-
- private void logCoordinate(double longitude, double latitude, double altitude){
+
+ private void logCoordinate(double longitude, double latitude, double altitude){
+ mSaveLabel.setText("Logging");
+ SaveTimer timer = new SaveTimer((mSaveLabel));
Coordinate loggedCoordinate = new Coordinate(longitude, latitude, altitude);
mLoggedCoordinates.add(loggedCoordinate);
+ timer.execute();
}
private void initAvailablePorts(){
View
30 src/ui/SaveTimer.java
@@ -0,0 +1,30 @@
+
+package ui;
+
+import javax.swing.JLabel;
+import javax.swing.SwingWorker;
+
+/**
+ *
+ * @author javarobots
+ */
+public class SaveTimer extends SwingWorker<Boolean,Boolean> {
+
+ private JLabel mLabel;
+
+ public SaveTimer(JLabel label){
+ mLabel = label;
+ }
+
+ @Override
+ protected Boolean doInBackground() throws Exception {
+ Thread.sleep(250);
+ return true;
+ }
+
+ @Override
+ public void done(){
+ mLabel.setText(" ");
+ }
+
+}

No commit comments for this range

Something went wrong with that request. Please try again.