Skip to content

Commit

Permalink
Release 2.3 fixes. Bug #1. Bug#22.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidzof committed Nov 11, 2014
1 parent 0c1ae31 commit c4c8aa3
Show file tree
Hide file tree
Showing 12 changed files with 240 additions and 41 deletions.
7 changes: 5 additions & 2 deletions properties/MessageBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ maxhr=Max HeartRate
fthr=Functional Threshold HeartRate
avehr=Average HeartRate
avepow=Average Power
avecad=Average Cadence
maxcad=Maximum Cadence
maxpow=Max Power
qpow=Quadratic Power
cftp=Current FTP
Expand Down Expand Up @@ -95,8 +97,8 @@ personal_data=Your Information
your_weight=Your Weight
bike_weight=Bike Weight
wheel_size=Wheel Diameter
fthr=Functional Threshold Heart Rate
ftp=Functional Threshold Power
fthr=FT Heart Rate
ftp=FT Power
metric=
trainer=Trainer
resistance=Resistance Levels
Expand All @@ -106,6 +108,7 @@ profile=Select your trainer

error=Error
warning=Warning
ftpWarning=Set Threshold Power in Preferences

start=Start
stop=Stop
Expand Down
2 changes: 0 additions & 2 deletions src/com/wattzap/model/DataStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ public void updateWorkout(String user, WorkoutData data) {
psUpdate.setString(17, data.getTcxFile());

int i = psUpdate.executeUpdate();

System.out.println("i " + i);

conn.commit();
} catch (SQLException e) {
Expand Down
1 change: 1 addition & 0 deletions src/com/wattzap/model/GPXReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public double getDistanceMeters() {
*
*/
public void load(String filename) {
points = null;
gpxFile = new GPXFile(new File(filename));
fileName = filename.substring(0, filename.lastIndexOf('.'));

Expand Down
2 changes: 1 addition & 1 deletion src/com/wattzap/model/UserPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public double getWeight() {
return getDouble("weight", 80.0);
} else {
// convert to lbs
return getDouble("weight", 80.0) / 0.45359237;
return getDouble("weight", 80.0) / LBSTOKG;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void receiveMessage(BroadcastDataMessage message) {
double ratio = (powerWatts / p.getPower());
// speed is video speed * power ratio
speed = p.getSpeed() * ratio;
System.out.println("speed " + speed + " ratio " + ratio + " power " + powerWatts + " tpower " + p.getPower());
// System.out.println("speed " + speed + " ratio " + ratio + " power " + powerWatts + " tpower " + p.getPower());

distanceKM = (speed / 3600) * timeS;

Expand Down
2 changes: 1 addition & 1 deletion src/com/wattzap/view/AboutPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class AboutPanel extends JFrame implements ActionListener {
private static final String decodeKey = "CAFEBABE";
// <html>WattzAp Virtual Turbo Trainer<br/><br/>Version: x.x.x
// <br/>Date: xx xxx xxx<br/>(c) xxxx, All rights reserved<br/>
private static final String blurb = "fykyKC5/FSQ3NTwEMmEWMDEjKWUWMyMsLSQ0ZREuJDE0IDQgfiMwan19JDdtfxQgMTIvKix7Yndtc2h0fiMwan0FJzEne2JyNylmCiE1LScmM3onMG58bSBoZndycHZpYwAqKWIzKyIrNTVlMCQxIDE3IyF+IzBqfQ==";
private static final String blurb = "fykyKC5/FSQ3NTwEMmEWMDEjKWUWMyMsLSQ0ZREuJDE0IDQgfiMwan19JDdtfxQgMTIvKix7YndtcnonMG58ASI1I39ieDYtYw8pMycsICAxfSQ3bX9qJmphdHVzdW5lAi0qZTAoJS03MmY3JzInNzUkInkgM217";
// Your software is registered
private static final String registered = "Gi4zN2IyLSM3Nic3J2ErNmMzIyIrMjYgMSQi";
// Incorrect registration key
Expand Down
32 changes: 25 additions & 7 deletions src/com/wattzap/view/ControlPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* You should have received a copy of the GNU General Public License
* along with Wattzap. If not, see <http://www.gnu.org/licenses/>.
*/
*/
package com.wattzap.view;

import java.awt.Color;
Expand All @@ -21,9 +21,12 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

Expand All @@ -34,6 +37,8 @@
import com.wattzap.model.UserPreferences;

/**
* Control button panel at bottom of main screen to start/stop routes
*
* (c) 2014 David George / Wattzap.com
*
* @author David George
Expand All @@ -42,15 +47,16 @@
public class ControlPanel extends JPanel implements ActionListener,
ChangeListener, MessageCallback {
private static final long serialVersionUID = 1L;
private final static UserPreferences userPrefs = UserPreferences.INSTANCE;
private JSlider startPosition;
private int start;

public ControlPanel() {
JButton stopButton = new JButton(UserPreferences.INSTANCE.messages
.getString("stop"));
JButton stopButton = new JButton(
UserPreferences.INSTANCE.messages.getString("stop"));
stopButton.setActionCommand("stop");
JButton startButton = new JButton(UserPreferences.INSTANCE.messages
.getString("start"));
JButton startButton = new JButton(
UserPreferences.INSTANCE.messages.getString("start"));
startButton.setActionCommand("start");

startButton.addActionListener(this);
Expand All @@ -62,14 +68,25 @@ public ControlPanel() {

MessageBus.INSTANCE.register(Messages.GPXLOAD, this);
MessageBus.INSTANCE.register(Messages.CLOSE, this);



// Border b = BorderFactory.createLineBorder( Color.black, 10 );
Border b = BorderFactory.createEmptyBorder(10, 0, 10, 0);
this.setBorder(b);

}

@Override
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if ("start".equals(command)) {
if (!userPrefs.isAntEnabled() && userPrefs.getMaxPower() == 0) {
JOptionPane.showMessageDialog(this,
UserPreferences.INSTANCE.messages
.getString("ftpWarning"),
UserPreferences.INSTANCE.messages.getString("warning"),
JOptionPane.WARNING_MESSAGE);
}

MessageBus.INSTANCE.send(Messages.START, new Double(start));
} else {
MessageBus.INSTANCE.send(Messages.STOP, null);
Expand All @@ -96,6 +113,7 @@ public void callback(Messages message, Object o) {
remove(startPosition);
}
startPosition = new JSlider(JSlider.HORIZONTAL, 0, 0, 0);

startPosition.addChangeListener(this);
startPosition.setPreferredSize(new Dimension(500, 40));
Font font = new Font("Serif", Font.ITALIC, 15);
Expand Down
7 changes: 6 additions & 1 deletion src/com/wattzap/view/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void callback(Messages message, Object o) {
this.removeGPXFile(gpxFile);
}
setVisible(false);
frame.invalidate();
//frame.invalidate();
frame.validate();
// frame.revalidate(); JDK 1.7 ONLY
}
Expand All @@ -118,6 +118,11 @@ public void callback(Messages message, Object o) {
count = 0;
frame.remove(this);
RouteReader routeData = (RouteReader) o;

if (gpxFile != null) {
// remove any previously loaded GPX file
this.removeGPXFile(gpxFile);
}
gpxFile = routeData.getGpxFile();

// TODO - change load message: gpxload, rlvload?
Expand Down
21 changes: 10 additions & 11 deletions src/com/wattzap/view/Workouts.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TimeZone;
import java.util.TreeMap;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JMenu;
Expand Down Expand Up @@ -110,6 +109,8 @@ public class Workouts extends JPanel implements ActionListener {

public Workouts() {
super(new GridLayout(1, 0));

this.setBorder(BorderFactory.createEmptyBorder(0,10,10,10));
selectedRows = null;

DefaultTableModel model = new DefaultTableModel(columnNames, 0);
Expand Down Expand Up @@ -348,7 +349,6 @@ public void actionPerformed(ActionEvent e) {
ActivityReader ar = new ActivityReader();

File dir = new File(workoutDir);
Set<File> fileTree = new HashSet<File>();
for (File entry : dir.listFiles()) {
if (entry.isFile()) {
try {
Expand Down Expand Up @@ -381,7 +381,7 @@ public void actionPerformed(ActionEvent e) {
}
JOptionPane.showMessageDialog(this, importedFiles.toString(),
"Import", JOptionPane.INFORMATION_MESSAGE);

return;
}

Expand Down Expand Up @@ -504,7 +504,6 @@ private boolean load() {
int count = 0;
for (int i : selectedRows) {
workoutData = workoutList.get(i);
System.out.println(workoutData);
String fileName = workoutData.getTcxFile();
try {
telemetry[count] = ActivityReader.readTelemetry(workoutDir
Expand Down Expand Up @@ -540,7 +539,6 @@ void reanalyze() {
int count = 0;
for (int i : selectedRows) {
workoutData = workoutList.get(i);
System.out.println(">> " + workoutData);
String fileName = workoutData.getTcxFile();
int ftp = workoutData.getFtp();
try {
Expand All @@ -550,9 +548,8 @@ void reanalyze() {
workoutData = TrainingAnalysis.analyze(telemetry[count]);
workoutData.setTcxFile(fileName);
workoutData.setFtp(ftp);
System.out.println(workoutData);

userPrefs.updateWorkout(workoutData);
userPrefs.updateWorkout(workoutData); // saves data to RDBMS
workoutList.set(i, workoutData); // FIXME updates local cache of workouts but won't fire list changed event?
} catch (Exception e1) {
logger.error(e1.getLocalizedMessage());
}
Expand Down Expand Up @@ -704,7 +701,8 @@ private void CSScatterPlot() {
}// for
}// for

GenericScatterGraph mmp = new GenericScatterGraph(series, userPrefs.messages.getString("poWtt"),
GenericScatterGraph mmp = new GenericScatterGraph(series,
userPrefs.messages.getString("poWtt"),
userPrefs.messages.getString("cDrpm"));
JFrame frame = new JFrame("Cadence Power Scatter Plot");
ImageIcon img = new ImageIcon("icons/turbo.jpg");
Expand Down Expand Up @@ -733,7 +731,8 @@ public void HRWattsScatterPlot() {
}// for
}// for

GenericScatterGraph mmp = new GenericScatterGraph(series, userPrefs.messages.getString("poWtt"),
GenericScatterGraph mmp = new GenericScatterGraph(series,
userPrefs.messages.getString("poWtt"),
userPrefs.messages.getString("hrBpm"));
JFrame frame = new JFrame("Heart Rate / Power Scatter Plot");
ImageIcon img = new ImageIcon("icons/turbo.jpg");
Expand Down
Loading

0 comments on commit c4c8aa3

Please sign in to comment.