JavaFX NMEA Reader (Drag and Drop)
JavaFX NMEA Reader
This is a project i did for my friend ,he wanted to view his fleet movement from data downloaded by his GPS that's a NMEA file.
With javaFX , ArcGIS and gauges from steelseries.
I will just show you a short video clip,
Note that the NMEA file is from arcgis sample data.not my friends.
The code that reads the NMEA file
IGPSWatcher watcher watcher =new FileGPSWatcher(file, 500, true);
try {
watcher.addListener(new GPSEventListener(){
@Override
public void onStatusChanged(GPSStatus newStatus) {
}
@Override
public void onPositionChanged(final GeoPosition newPosition) {
compassGauge.setValueAnimated(newPosition.getLocation().getCourse());
speedGauge.setValueAnimated(newPosition.getLocation().getSpeed());
Platform.runLater(new Runnable(){
@Override
public void run() {
log.appendText(newPosition.toString()+"\n");
}
});
}
@Override
public void onNMEASentenceReceived(String newSentence) {
}
@Override
public void onSatellitesInViewChanged(Map<Integer, Satellite> sattellitesInView) {
}
}); } catch (GPSException ex) {
Logger.getLogger(JavaFXApplication27.class.getName()).log(Level.SEVERE, null, ex);
}
In javafx drag and drop is pretty simple
root is the pane that has the map
root.setOnDragOver(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
Dragboard db = event.getDragboard();
if (db.hasFiles()) {
event.acceptTransferModes(TransferMode.LINK);
} else {
event.consume();
}
}
});
root.setOnDragDropped(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
Dragboard db = event.getDragboard();
boolean success = false;
if (db.hasFiles()) {
success = true;
String filePath;
filePath = db.getFiles().get(0).getAbsolutePath();
System.out.println(filePath);//prints the nmea filepath
}
event.setDropCompleted(success);
event.consume();
}
});
Screen shots
This is a project i did for my friend ,he wanted to view his fleet movement from data downloaded by his GPS that's a NMEA file.
With javaFX , ArcGIS and gauges from steelseries.
I will just show you a short video clip,
Note that the NMEA file is from arcgis sample data.not my friends.
IGPSWatcher watcher watcher =new FileGPSWatcher(file, 500, true);
try {
watcher.addListener(new GPSEventListener(){
@Override
public void onStatusChanged(GPSStatus newStatus) {
}
@Override
public void onPositionChanged(final GeoPosition newPosition) {
compassGauge.setValueAnimated(newPosition.getLocation().getCourse());
speedGauge.setValueAnimated(newPosition.getLocation().getSpeed());
Platform.runLater(new Runnable(){
@Override
public void run() {
log.appendText(newPosition.toString()+"\n");
}
});
}
@Override
public void onNMEASentenceReceived(String newSentence) {
}
@Override
public void onSatellitesInViewChanged(Map<Integer, Satellite> sattellitesInView) {
}
}); } catch (GPSException ex) {
Logger.getLogger(JavaFXApplication27.class.getName()).log(Level.SEVERE, null, ex);
}
In javafx drag and drop is pretty simple
root is the pane that has the map
root.setOnDragOver(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
Dragboard db = event.getDragboard();
if (db.hasFiles()) {
event.acceptTransferModes(TransferMode.LINK);
} else {
event.consume();
}
}
});
root.setOnDragDropped(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
Dragboard db = event.getDragboard();
boolean success = false;
if (db.hasFiles()) {
success = true;
String filePath;
filePath = db.getFiles().get(0).getAbsolutePath();
System.out.println(filePath);//prints the nmea filepath
}
event.setDropCompleted(success);
event.consume();
}
});
Screen shots
Comments
Post a Comment