edu.ull.cgunay.plots
Class MatLab

java.lang.Object
  |
  +--edu.ull.cgunay.plots.Grapher
        |
        +--edu.ull.cgunay.plots.MatLab

public class MatLab
extends Grapher

Grapher implementation for plotting with the MatLab program.

See description in Grapher for the usage.

Created: Fri Apr 12 22:18:46 2002

Modified: $Date: 2003/03/21 05:10:57 $

Version:
$Revision: 1.17 $ for this file.
Author:
Cengiz Gunay
See Also:
Grapher

Nested Class Summary
(package private)  class MatLab.Axis
          Overriding original Axis definition.
(package private)  class MatLab.DefaultDataType
          Simple plot command type.
(package private)  class MatLab.ErrorDataType
           
(package private)  class MatLab.ImpulseDataType
           
(package private)  class MatLab.MatLabDataType
           
(package private)  class MatLab.MultiAxes
           
(package private)  class MatLab.PatternIterator
          If multiple datasets are plotted on same axis, cycle through these (only required for stupid Matlab).
 
Nested classes inherited from class edu.ull.cgunay.plots.Grapher
Grapher.Data, Grapher.ErrorData, Grapher.PreciseProfileData, Grapher.ProfileData, Grapher.VerticalBar
 
Field Summary
(package private)  MatLab.PatternIterator patterns
           
 
Fields inherited from class edu.ull.cgunay.plots.Grapher
dataTypes, err, msg, out, points, process, windowNumber
 
Constructor Summary
MatLab()
          Spawns matlab interpreter and defines datatypes.
 
Method Summary
 String assign(String var, String value)
          Add a proper MatLab termination to the superior definition.
 void close()
          Exits matlab process.
 String command(String line)
          Add end-of-line separator for matlab.
 Grapher.Axis createAxis()
          Convenience method to get instance of Axis defined here.
 Grapher.MultiAxes createMultiAxes(Grapher.Axis[] axes)
          Convenience method to get instance of MultiAxes defined here.
 Grapher.MultiAxes createMultiAxes(List axes)
          Convenience method to get instance of MultiAxes defined here.
 String def_func(String name, String[] params, String body)
          Creates a file in the current directory named with the function for matlab.
(package private)  String labelString(Grapher.Data plot)
          Returns a proper dataset label statement in MatLab if label available.
 String mul(String a, String b)
          Returns a String that is a scalar product for MatLab which is "(a) .* (b)".
 PlotHandle multiPlot(Collection plots, PrintStream out)
          Initial implementation of a collection of separate plots appear on one figure aligend vertically with matching ranges.
 String plotToString(SimplePlot plot)
          Deprecated.  
 String plotToString(SpikePlot plot)
          Returns a String representation of a spike plot for the Grapher.
 String plotToStringAlt(Plot plot)
          Alternative to plotToString, supposed to replace it soon.
 String quote(String value)
          Matlab style 'quoting'.
 String range(Range range)
          Returns range in the matlab format "a:(b-a)/points:b"
 void setWindow(int windowNumber)
          Opens new matlab figure.
 PlotHandle superposedPlot(String title, Collection plots, PrintStream out)
          Initial implementation of a superposed collection of plots appearing on one figure.
(package private)  String titleString(HasAxisLabels plot)
          Returns a proper title statement in MatLab if available.
 void writeEPS(PlotHandle handle, String filename)
          Exports an EPS file of the previously visualized (required) plot.
 void writeEPSbw(PlotHandle handle, String filename)
          Exports a black-n-white EPS file of the previously visualized (required) plot.
(package private)  String xLabelString(HasAxisLabels plot)
          Returns a proper statement in MatLab to set the x-axis label if available.
(package private)  String yLabelString(HasAxisLabels plot)
          Returns a proper statement in MatLab to set the y-axis label if available.
 
Methods inherited from class edu.ull.cgunay.plots.Grapher
add, display, div, exp, func, geq, getPoints, multiPlot, neg, paren, profile, response, setPoints, sub, superposedPlot, variable, waitForResponse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

patterns

MatLab.PatternIterator patterns
Constructor Detail

MatLab

public MatLab()
       throws GrapherNotAvailableException
Spawns matlab interpreter and defines datatypes.

TODO: the datatypes should anonymously be defined in this constructor for simplicity rather than being defined as one-time use inner classes. Doesn't make sense.

Throws:
GrapherNotAvailableException - if an error occurs
See Also:
Grapher.DataType
Method Detail

plotToString

public String plotToString(SpikePlot plot)
Deprecated.  

Description copied from class: Grapher
Returns a String representation of a spike plot for the Grapher.

Specified by:
plotToString in class Grapher
Parameters:
plot - a SpikePlot value
Returns:
a String value
See Also:
plotToStringAlt(Plot)

plotToString

public String plotToString(SimplePlot plot)
Deprecated.  

Matlab specific plotting command. Calls Plot.body().

Specified by:
plotToString in class Grapher
Parameters:
plot - a Plot value
Returns:
a String value
See Also:
plotToStringAlt(edu.ull.cgunay.plots.Plot), SimplePlot.body()

createAxis

public Grapher.Axis createAxis()
Convenience method to get instance of Axis defined here.

Specified by:
createAxis in class Grapher
Returns:
an Axis subclass instance for the given grapher.

createMultiAxes

public Grapher.MultiAxes createMultiAxes(Grapher.Axis[] axes)
Convenience method to get instance of MultiAxes defined here.

Specified by:
createMultiAxes in class Grapher
Parameters:
axes - a Grapher.Axis[] value
Returns:
a Grapher.MultiAxes value

createMultiAxes

public Grapher.MultiAxes createMultiAxes(List axes)
Convenience method to get instance of MultiAxes defined here.

Specified by:
createMultiAxes in class Grapher
Parameters:
axes - a List of Grapher.Axis[] values
Returns:
a Grapher.MultiAxes value

plotToStringAlt

public String plotToStringAlt(Plot plot)
Alternative to plotToString, supposed to replace it soon.

TODO: Should it stay in Grapher?

Specified by:
plotToStringAlt in class Grapher
Parameters:
plot - a Plot value
Returns:
a String value

labelString

String labelString(Grapher.Data plot)
Returns a proper dataset label statement in MatLab if label available.

Parameters:
plot - a Plot value
Returns:
Label setting statement or "" if no label exists.

titleString

String titleString(HasAxisLabels plot)
Returns a proper title statement in MatLab if available.

Parameters:
plot - a Plot value
Returns:
MatLab statement or "" if no title exists.

xLabelString

String xLabelString(HasAxisLabels plot)
Returns a proper statement in MatLab to set the x-axis label if available.

Parameters:
plot - a Plot value
Returns:
a String value

yLabelString

String yLabelString(HasAxisLabels plot)
Returns a proper statement in MatLab to set the y-axis label if available.

Parameters:
plot - a Plot value
Returns:
a String value

multiPlot

public PlotHandle multiPlot(Collection plots,
                            PrintStream out)
Initial implementation of a collection of separate plots appear on one figure aligend vertically with matching ranges.

Specified by:
multiPlot in class Grapher
Parameters:
plots - a Collection value
out - a PrintStream value
Returns:
a String value
See Also:
GNUPlot.multiPlot(java.util.Collection, java.io.PrintStream), multiPlot(java.util.Collection, java.io.PrintStream)

superposedPlot

public PlotHandle superposedPlot(String title,
                                 Collection plots,
                                 PrintStream out)
Initial implementation of a superposed collection of plots appearing on one figure.

Note: SpikePlots currently not allowed.

TODO: return a Plot from this.

Specified by:
superposedPlot in class Grapher
Parameters:
plots - a Collection value
title - a String value
out - a PrintStream value
Returns:
a String value

mul

public String mul(String a,
                  String b)
Returns a String that is a scalar product for MatLab which is "(a) .* (b)".

Overrides:
mul in class Grapher
Parameters:
a - a String value
b - a String value
Returns:
a String value

def_func

public String def_func(String name,
                       String[] params,
                       String body)
Creates a file in the current directory named with the function for matlab.

Specified by:
def_func in class Grapher
Parameters:
name - a String value, name of the function
params - a String[] value, parameter names of the function
body - a String value, the body of the function
Returns:
a String value

assign

public String assign(String var,
                     String value)
Add a proper MatLab termination to the superior definition.

Overrides:
assign in class Grapher
Parameters:
var - a String value
value - a String value
Returns:
a String value

range

public String range(Range range)
Returns range in the matlab format "a:(b-a)/points:b"

Overrides:
range in class Grapher
Parameters:
range - a Range value
Returns:
a String value

close

public void close()
Exits matlab process.

Overrides:
close in class Grapher

quote

public String quote(String value)
Matlab style 'quoting'.

Overrides:
quote in class Grapher
Parameters:
value - a String value

command

public String command(String line)
Add end-of-line separator for matlab.

Overrides:
command in class Grapher
Parameters:
line - a String value

setWindow

public void setWindow(int windowNumber)
Opens new matlab figure.

Specified by:
setWindow in class Grapher
Parameters:
windowNumber - an int value

writeEPS

public void writeEPS(PlotHandle handle,
                     String filename)
Description copied from class: Grapher
Exports an EPS file of the previously visualized (required) plot.

Specified by:
writeEPS in class Grapher
Parameters:
handle - a PlotHandle value
filename - a String value

writeEPSbw

public void writeEPSbw(PlotHandle handle,
                       String filename)
Description copied from class: Grapher
Exports a black-n-white EPS file of the previously visualized (required) plot.

TODO: make some export properties to handle these.

Specified by:
writeEPSbw in class Grapher
Parameters:
handle - a PlotHandle value
filename - a String value