Browse files

Remove absolute paths, have it load the cars file on startup, get rid…

… of some of the warnings about deprecated methods
  • Loading branch information...
1 parent 127ff6f commit 0c3d9667589441f32de1a62b7900ecf7941aba88 @eagereyes committed May 11, 2010
Showing with 31 additions and 31 deletions.
  1. +11 −15 src/org/mediavirus/parvis/file/STFFile.java
  2. +20 −16 src/org/mediavirus/parvis/gui/MainFrame.java
View
26 src/org/mediavirus/parvis/file/STFFile.java
@@ -70,9 +70,6 @@
*/
public class STFFile extends SimpleParallelSpaceModel {
- /** The url of the file. */
- URL url;
-
private int tempNumDimensions;
private int bytesRead = 0;
@@ -82,17 +79,18 @@
private boolean isStringLabel[];
private String name = "";
+
+ private String fileName;
/**
* Creates a new STFFile with the given url. The content is not read until
* readContents() is called.
*
* @param url The url of the file to read.
*/
- public STFFile(URL url) {
- this.url = url;
- name = url.getFile();
- name = name.substring(name.lastIndexOf('/') + 1);
+ public STFFile(String fname) {
+ fileName = fname;
+ name = fname.substring(name.lastIndexOf('/') + 1);
}
/**
@@ -112,14 +110,12 @@ public String getName(){
public void readContents() throws IOException{
fireProgressEvent(new ProgressEvent(this, ProgressEvent.PROGRESS_START, 0.0f, "loading file"));
+
+ File f = new File(fileName);
+ filesize = (int) f.length();
+// System.out.println("filesize: " + filesize);
- URLConnection conn = url.openConnection();
- conn.connect();
-
- filesize = conn.getContentLength();
- System.out.println("filesize: " + filesize);
-
- InputStreamReader in = new InputStreamReader(conn.getInputStream());
+ InputStreamReader in = new InputStreamReader(new FileInputStream(f));
readFirstLine(in);
readHeaderLines(in);
@@ -338,7 +334,7 @@ protected void fireProgressEvent(ProgressEvent e){
*/
public static void main(String args[]){
try {
- STFFile f = new STFFile(new URL("file:///d:/uni/visualisierung/datasets/table1.stf"));
+ STFFile f = new STFFile("data/cars.stf");
f.readContents();
}
View
36 src/org/mediavirus/parvis/gui/MainFrame.java
@@ -24,32 +24,36 @@
package org.mediavirus.parvis.gui;
-import javax.swing.*;
-import java.io.*;
-import java.net.*;
+import java.io.File;
+import java.io.IOException;
-import org.mediavirus.parvis.file.*;
-import org.mediavirus.parvis.model.*;
+import javax.swing.JFileChooser;
+import javax.swing.UIManager;
+
+import org.mediavirus.parvis.file.STFFile;
+import org.mediavirus.parvis.model.Brush;
/**
*
* @author flo
*/
public class MainFrame extends javax.swing.JFrame implements ProgressListener, BrushListener {
- /** Creates new form MainFrame */
+ private static final String INITIALFILENAME = "data/cars.stf";
+
+ /** Creates new form MainFrame */
public MainFrame() {
initComponents();
parallelDisplay.addProgressListener(this);
parallelDisplay.addBrushListener(this);
BrushList brushList = new BrushList(parallelDisplay);
brushList.setLocation(this.getX() + this.getWidth(), this.getY());
- brushList.show();
+ brushList.setVisible(true);
CorrelationFrame correlationFrame = new CorrelationFrame(parallelDisplay);
correlationFrame.setLocation(this.getX() + this.getWidth(), this.getY() + brushList.getHeight());
- correlationFrame.show();
+ correlationFrame.setVisible(true);
this.setSize(800, 600);
@@ -313,7 +317,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
urlBar.add(datasourceLabel);
urlField.setFont(new java.awt.Font("Dialog", 0, 10));
- urlField.setText("file:///C:/data/uni/vis/datasets/cars.stf");
+ urlField.setText(INITIALFILENAME);
urlField.setMargin(new java.awt.Insets(0, 0, 0, 5));
urlField.setMinimumSize(null);
urlField.setPreferredSize(null);
@@ -462,11 +466,13 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
setJMenuBar(menuBar);
pack();
+
+ urlFieldActionPerformed(null);
}//GEN-END:initComponents
private void preferencesMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_preferencesMenuActionPerformed
PrefsFrame pf = new PrefsFrame(parallelDisplay);
- pf.show();
+ pf.setVisible(true);
}//GEN-LAST:event_preferencesMenuActionPerformed
private void saveBrushItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBrushItemActionPerformed
@@ -600,7 +606,7 @@ private void setEditModeBrush(java.awt.event.ActionEvent evt) {//GEN-FIRST:event
private void urlFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_urlFieldActionPerformed
try {
- STFFile f = new STFFile(new URL(urlField.getText()));
+ STFFile f = new STFFile(urlField.getText());
f.addProgressListener(this);
f.readContents();
@@ -641,11 +647,9 @@ public String getDescription(){
if (option == JFileChooser.APPROVE_OPTION) {
if (chooser.getSelectedFile() != null){
currentPath = chooser.getSelectedFile().getParentFile();
- String urltext = "file:///" + chooser.getSelectedFile().getAbsolutePath();
- urltext = urltext.replace('\\','/');
- urlField.setText(urltext);
+ urlField.setText(chooser.getSelectedFile().getAbsolutePath());
try {
- STFFile f = new STFFile(new URL(urltext));
+ STFFile f = new STFFile(chooser.getSelectedFile().getAbsolutePath());
f.readContents();
parallelDisplay.setModel(f);
@@ -669,7 +673,7 @@ private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitFor
*/
public static void main(String args[]) {
UIManager.put("org.mediavirus.parvis.gui.ParallelDisplayUI", "org.mediavirus.parvis.gui.BasicParallelDisplayUI");
- new MainFrame().show();
+ new MainFrame().setVisible(true);
}
private long progressstart = 0;

0 comments on commit 0c3d966

Please sign in to comment.