Revision: f093d3fe60be
Author: kthayer
Date: Wed May 25 11:39:36 2011
Log: Cleaned up Export SOM and Hit Histogram dialog.
http://code.google.com/p/ifcsoft/source/detail?r=f093d3fe60be
Revision: 79a1181a57f8
Author: kthayer
Date: Thu May 26 10:56:00 2011
Log: Added comment about not using Netbeans 7.0 in README.txt
http://code.google.com/p/ifcsoft/source/detail?r=79a1181a57f8
==============================================================================
Revision: f093d3fe60be
Author: kthayer
Date: Wed May 25 11:39:36 2011
Log: Cleaned up Export SOM and Hit Histogram dialog.
http://code.google.com/p/ifcsoft/source/detail?r=f093d3fe60be
Modified:
/src/ifcSoft/view/som/ExportSOMAndHit.fx
=======================================
--- /src/ifcSoft/view/som/ExportSOMAndHit.fx Tue May 24 12:18:54 2011
+++ /src/ifcSoft/view/som/ExportSOMAndHit.fx Wed May 25 11:39:36 2011
@@ -7,8 +7,6 @@
import ifcSoft.MainApp;
import ifcSoft.view.dialogBox.ifcDialogBox;
-import ifcSoft.view.dialogBox.ifcDialogDirectorySelect;
-import ifcSoft.view.dialogBox.ifcDialogStringInput;
import ifcSoft.view.dialogBox.ifcDialogCheckBox;
import ifcSoft.view.dialogBox.ifcDialogIntInput;
import java.io.BufferedWriter;
@@ -16,6 +14,9 @@
import java.io.IOException;
import ifcSoft.ApplicationFacade;
import java.awt.Point;
+import javax.swing.JFileChooser;
+import ifcSoft.view.fileFilter.CSVFileFilter;
+import java.io.File;
/**
* @author kthayer
@@ -33,8 +34,6 @@
}
var exportSOMDialog:ifcDialogBox;
- var exportSOMDirSelect:ifcDialogDirectorySelect;
- var fileNameInput:ifcDialogStringInput;
var includeHitHistogramInput:ifcDialogCheckBox;
var blurrTimesInput:ifcDialogIntInput;
@@ -45,15 +44,6 @@
name: "Export SOM and Hit Histogram"
okAction: exportSOMOK
content: [
- //string input name
- fileNameInput = ifcDialogStringInput{
- name:"File name"
- }
-
- exportSOMDirSelect = ifcDialogDirectorySelect{
- mainApp:app
- initialDirectory: app.lastFilePath
- }
includeHitHistogramInput = ifcDialogCheckBox{
name: "Output Hit Histogram"
initialCheck: false
@@ -61,6 +51,7 @@
blurrTimesInput = ifcDialogIntInput{
name: "Blur passes on hit histograms"
initialInt: 0
+ disable: bind not includeHitHistogramInput.ischecked
}
]
@@ -76,96 +67,86 @@
function exportSOMOK():Void{
//TODO: if file already exists, ask permission to overwrite
- var name:String = fileNameInput.getInput();
- if(name == null or name.length() == 0){
- app.alert("Error: Filename blank");
- return;
- }
-
-
- var filepath:String = exportSOMDirSelect.getInput();
- if(filepath == null){
- app.alert("Error: No directory Selected");
- return;
- }
-
- if(not name.endsWith(".csv"))
- name+= ".csv";
-
-
- if(not filepath.endsWith("/"))
- filepath+= "/";
- var selectedFile:String = "{filepath}{name}.csv";
-
-
- var hitHistograms:Object[] = []; //multi-dimensional arrays are hard
in javaFX,
- //I cast the 2d arrays to objects for
convenience
- if(includeHitHistogramInput.getInput()){ //get the density maps
- for(i in [0..mediator.SOMp.getRawSetNames().size() - 1]){
- insert mediator.getDenseBlurred(i,blurrTimesInput.getInput()) as
Object into hitHistograms;
- }
- }
-
- var bw:BufferedWriter;
- try {
- bw = new BufferedWriter(new FileWriter(selectedFile));
- //write width and height
- bw.write("Width,{mediator.SOMwidth()}");
- bw.newLine();
- bw.write("Height,{mediator.SOMheight()}");
- bw.newLine();
-
- //Column headings
- //x, y, Dim1, Dim2, ... ,Hit Hist1, Hit Hist2, ...
- bw.write("x,y");
- for(dimName in mediator.getColNames()){
- bw.write(",{dimName}");
- }
- if(includeHitHistogramInput.getInput()){
- for(hitHistName in mediator.SOMp.getRawSetNames()){
- bw.write(",{hitHistName}");
- }
- }
- bw.newLine();
-
- //now do each node
-
- for(x in [0..mediator.SOMwidth()-1]){
- for(y in [0..mediator.SOMheight()-1]){
- bw.write("{x},{y}");
- for(i in [0..mediator.getColNames().length-1]){
- bw.write(",{mediator.SOMp.getCellVals(new Point(x, y))[i]}");
- }
- if(includeHitHistogramInput.getInput()){
- for(i in [0..mediator.SOMp.getRawSetNames().size()-1]){
- var thisHitHist:nativearray of nativearray of Float =
hitHistograms[i] as (nativearray of nativearray of Float);
- bw.write(",{thisHitHist[x][y]}");
- }
- }
-
- bw.newLine();
- }
- }
+ var fileChooser:JFileChooser;
+ if(app.lastFilePath == null){
+ fileChooser = new JFileChooser();
+ }else{
+ fileChooser = new JFileChooser(app.lastFilePath);
+ }
+ var filter:CSVFileFilter = new CSVFileFilter();
+ fileChooser.setFileFilter(filter);
+
+ if(fileChooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION){
+
+ app.lastFilePath =
fileChooser.getCurrentDirectory().getAbsolutePath();
+ var files:File = fileChooser.getSelectedFile();
+ println("saving: {files.getAbsolutePath()}");
+ var newFilename =files.getAbsolutePath();
+
+ if(not newFilename.endsWith(".csv"))
+ newFilename= "{newFilename}.csv";
+
+ var hitHistograms:Object[] = []; //multi-dimensional arrays are hard
in javaFX,
+ //I cast the 2d arrays to objects for
convenience
+ if(includeHitHistogramInput.getInput()){ //get the density maps
+ for(i in [0..mediator.SOMp.getRawSetNames().size() - 1]){
+ insert mediator.getDenseBlurred(i,blurrTimesInput.getInput())
as Object into hitHistograms;
+ }
+ }
+
+ var bw:BufferedWriter;
+ try {
+ bw = new BufferedWriter(new FileWriter(newFilename));
+ //write width and height
+ bw.write("Width,{mediator.SOMwidth()}");
+ bw.newLine();
+ bw.write("Height,{mediator.SOMheight()}");
+ bw.newLine();
+
+ //Column headings
+ //x, y, Dim1, Dim2, ... ,Hit Hist1, Hit Hist2, ...
+ bw.write("x,y");
+ for(dimName in mediator.getColNames()){
+ bw.write(",{dimName}");
+ }
+ if(includeHitHistogramInput.getInput()){
+ for(hitHistName in mediator.SOMp.getRawSetNames()){
+ bw.write(",{hitHistName}");
+ }
+ }
+ bw.newLine();
+
+ //now do each node
+
+ for(x in [0..mediator.SOMwidth()-1]){
+ for(y in [0..mediator.SOMheight()-1]){
+ bw.write("{x},{y}");
+ for(i in [0..mediator.getColNames().length-1]){
+ bw.write(",{mediator.SOMp.getCellVals(new Point(x, y))[i]}");
+ }
+ if(includeHitHistogramInput.getInput()){
+ for(i in [0..mediator.SOMp.getRawSetNames().size()-1]){
+ var thisHitHist:nativearray of nativearray of Float =
hitHistograms[i] as (nativearray of nativearray of Float);
+ bw.write(",{thisHitHist[x][y]}");
+ }
+ }
+
+ bw.newLine();
+ }
+ }
-
- bw.close();
-
- } catch (ex:IOException) {
- app.facade.sendNotification(ApplicationFacade.EXCEPTIONALERT, ex,
null);
- return;
+
+ bw.close();
+
+ } catch (ex:IOException) {
+ app.facade.sendNotification(ApplicationFacade.EXCEPTIONALERT, ex,
null);
+ return;
+ }
}
app.removeDialog(exportSOMDialog);
app.unblockContent();
- }
-
-
- function blurHitHist(hitHistsIn:Object[], blurNum:Integer): Object[] {
- var hitHists:(nativearray of nativearray of Integer)[] = hitHistsIn as
(nativearray of nativearray of Integer)[];
-
-
- return null;
}
==============================================================================
Revision: 79a1181a57f8
Author: kthayer
Date: Thu May 26 10:56:00 2011
Log: Added comment about not using Netbeans 7.0 in README.txt
http://code.google.com/p/ifcsoft/source/detail?r=79a1181a57f8
Modified:
/README.txt
=======================================
--- /README.txt Tue Feb 22 07:47:50 2011
+++ /README.txt Thu May 26 10:56:00 2011
@@ -1,6 +1,6 @@
To compile this program, you need to have both the Java SDK and JavaFX 1.3
SDK.
-I use Netbeans 6.9.1 to write it, so you should be able to load the
project in
+I use Netbeans 6.9.1 (note Netbeans 7.0 doesn't have the JavaFX plugins)
to write it, so you should be able to load the project in
Netbeans and compile it that way.
I'm not sure how exactly to compile it with the command prompt, but if you
want