snakeprogram
Class SnakeIO

java.lang.Object
  extended by snakeprogram.SnakeIO

public class SnakeIO
extends java.lang.Object

This class is used for reading and writing snakes. It uses file dialogs and dialogs for errors. There are two types of files. Elongation data, Snake data, and image condition data. Copyright (c) 2010, Lehigh University All rights reserved. see COPYING for license.


Constructor Summary
SnakeIO()
           
 
Method Summary
static double[] getEndpointChanges(Snake s, int cur, int prev)
          Finds the 'overlapping' coordinates as determined by the shortest distance, without transforming the snake, by lining indicies.
static java.lang.String getOpenFileName(java.awt.Frame parent)
          Open file dialog
static java.lang.String getSaveFileName(java.awt.Frame parent, java.lang.String title)
          Save file dialog
static MultipleSnakesStore loadSnakes(java.awt.Frame parent, java.util.HashMap<java.lang.String,java.lang.Double> values)
          This loads the snakes from a snake store file.
static MultipleSnakesStore loadSnakes(java.lang.String fname, java.util.HashMap<java.lang.String,java.lang.Double> values)
          This loads the snakes from a snake store file.
static double measureDistance(java.util.ArrayList<double[]> pts, int start, int stop)
           
static void writeSnakeElongationData(java.awt.Frame parent, java.util.HashMap<java.lang.String,java.lang.Double> values, MultipleSnakesStore SnakeStore, int total_frames)
          Writes out the elongation data for each snake in px, as a function of time.
static void writeSnakeElongationData(java.lang.String fname, java.util.HashMap<java.lang.String,java.lang.Double> values, MultipleSnakesStore SnakeStore, int total_frames)
          Writes out the elongation data for each snake in px, as a function of time.
static void writeSnakes(java.awt.Frame parent, java.util.HashMap<java.lang.String,java.lang.Double> values, MultipleSnakesStore SnakeStore)
          Writes out the Snake Data for saving and restoring the actual traced snakes.
static void writeSnakes(java.lang.String fname, java.util.HashMap<java.lang.String,java.lang.Double> values, MultipleSnakesStore SnakeStore)
          Writes out the Snake Data for saving and restoring the actual traced snakes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SnakeIO

public SnakeIO()
Method Detail

getSaveFileName

public static java.lang.String getSaveFileName(java.awt.Frame parent,
                                               java.lang.String title)
Save file dialog


getOpenFileName

public static java.lang.String getOpenFileName(java.awt.Frame parent)
Open file dialog


writeSnakeElongationData

public static void writeSnakeElongationData(java.lang.String fname,
                                            java.util.HashMap<java.lang.String,java.lang.Double> values,
                                            MultipleSnakesStore SnakeStore,
                                            int total_frames)
Writes out the elongation data for each snake in px, as a function of time. No GUI.

Parameters:
fname - this is the filename to save the data too.
values - This contians the constant values as key values pairs
SnakeStore - Contains the snake data
total_frames - for writing elongation data of every frame even when there isn't a snake

writeSnakeElongationData

public static void writeSnakeElongationData(java.awt.Frame parent,
                                            java.util.HashMap<java.lang.String,java.lang.Double> values,
                                            MultipleSnakesStore SnakeStore,
                                            int total_frames)
Writes out the elongation data for each snake in px, as a function of time. included in the output file are the constants from the snake panel. This version includes a Dialog for getting the filename

Parameters:
parent - This just needs to be a frame so the dialog can appear. It could be a new frame or null.
values - This contians the constant values as key values pairs
SnakeStore - Contains the snake data
total_frames - for writing elongation data of every frame even when there isn't a snake

getEndpointChanges

public static double[] getEndpointChanges(Snake s,
                                          int cur,
                                          int prev)
Finds the 'overlapping' coordinates as determined by the shortest distance, without transforming the snake, by lining indicies. Then it separates the lengths into three parts body differences and end differences. The body difference is subsequently divided in have and added to both parts of the filament.


measureDistance

public static double measureDistance(java.util.ArrayList<double[]> pts,
                                     int start,
                                     int stop)

writeSnakes

public static void writeSnakes(java.lang.String fname,
                               java.util.HashMap<java.lang.String,java.lang.Double> values,
                               MultipleSnakesStore SnakeStore)
Writes out the Snake Data for saving and restoring the actual traced snakes. Includes the constants and all of the snake points. No GUI.

Parameters:
fname - This is the file name
values - This hashmap stores all of the constants for the current simulation.
SnakeStore - Contains the snake data

writeSnakes

public static void writeSnakes(java.awt.Frame parent,
                               java.util.HashMap<java.lang.String,java.lang.Double> values,
                               MultipleSnakesStore SnakeStore)
Writes out the Snake Data for saving and restoring the actual traced snakes. Includes the constants and all of the snake points.

Parameters:
parent - This is a Frame for showing dialogs this could be null or a new Frame
values - This hashmap stores all of the constants for the current simulation.
SnakeStore - Contains the snake data

loadSnakes

public static MultipleSnakesStore loadSnakes(java.lang.String fname,
                                             java.util.HashMap<java.lang.String,java.lang.Double> values)
This loads the snakes from a snake store file. This reads the file for constants first, then when it finds the first snake it begins to load snake data. NO GUI

Parameters:
fname - The name of the file to be opened
values - A hashmap that the key,value pairs will be put into. If there are already values they will be replaced.

loadSnakes

public static MultipleSnakesStore loadSnakes(java.awt.Frame parent,
                                             java.util.HashMap<java.lang.String,java.lang.Double> values)
This loads the snakes from a snake store file. SnakeFrame is nescessary to set the constants. This reads the file for constants first, then when it finds the first snake it begins to load snake data.

Parameters:
parent - Just a frame for the dialogs. It could a new frame or null if you don't have one handy
values - A hashmap that the key,value pairs will be put into. If there are already values they will be replaced.