org.rosuda.iplots
Class Framework

java.lang.Object
  extended by org.rosuda.iplots.Framework
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, Dependent

public class Framework
extends java.lang.Object
implements Dependent, java.awt.event.ActionListener

basic framework interface for bulding interactive statistical programs


Field Summary
 int graphicsEngine
           
 
Constructor Summary
Framework()
          initialize framework, create and select a dataset which id called "default".
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void addNewPlot(BaseCanvas bc)
           
 int addVar(SVar v)
          add a variable to the current dataset.
 int countSets()
           
 int curSetId()
           
 java.lang.String d2s(double d)
           
 NotifyMsg eventWait()
          this methods is called from R by ievent.wait and uses waitForNotification() to wait for an event.
 SVarSet getCurrentSet()
          get current dataset
 int getCurVarSetLength()
          get the length of the current dataset
 double[] getDoubleContent(int vid)
          display a new variables frame
 double[] getDoubleContent(SVar v)
           
 int getGraphicsEngine()
           
 int getLength()
           
 java.lang.String getNewTmpVar()
           
 java.lang.String getNewTmpVar(java.lang.String t)
           
 boolean getNoInteractionFlag()
           
 SVarSet getSet(int i)
           
 int getSetIdByName(java.lang.String name)
           
 java.lang.String getSetName()
           
 java.lang.String getSetName(int i)
           
 java.lang.String[] getStringContent(int vid)
           
 java.lang.String[] getStringContent(SVar v)
           
 SVar getVar(int i)
          get variable object associated with an ID in current dataset
 SVar getVar(java.lang.String name)
          get first variable object associated with a name in current dataset
 int indexOfSet(SVarSet s)
           
 boolean isSetCurrent(SVarSet s)
          verify whether a given dataset is current
static java.lang.String msgDlg(java.lang.String caption, java.lang.String msg, java.lang.String[] buttons)
          shows a modal dialog and waits until it is dismissed.
 BarCanvas newBarchart(int v)
           
 BarCanvas newBarchart(int v, int wgt)
           
 BarCanvas newBarchart(SVarSet vs, int v, int wgt)
           
 ParallelAxesCanvas newBoxplot(int i)
           
 ParallelAxesCanvas newBoxplot(int[] i)
           
 ParallelAxesCanvas newBoxplot(int[] i, int ic)
           
 ParallelAxesCanvas newBoxplot(int i, int ic)
           
 ParallelAxesCanvas newBoxplot(SVarSet vs, int[] i, int ic)
           
 FrameDevice newFrame()
           
 FrameDevice newFrame(java.lang.String tit)
           
 FrameDevice newFrame(java.lang.String tit, boolean useCommonBg, int wclass)
           
 FrameDevice newFrame(java.lang.String tit, int wclass)
           
 HamCanvas newHammock(int[] v)
           
 HamCanvas newHammock(SVarSet vs, int[] v)
           
 HistCanvas newHistogram(int v)
          display a new histogram of a variables from current dataset
 HistCanvas newHistogram(SVarSet vs, int i)
           
 LineCanvas newLineplot(int[] v)
           
 LineCanvas newLineplot(int rv, int v)
           
 LineCanvas newLineplot(int rv, int[] v)
           
 LineCanvas newLineplot(SVarSet vs, int rv, int[] v)
           
 MapCanvas newMap(int v)
           
 MapCanvas newMap(SVarSet vs, int v)
           
 MosaicCanvas newMosaic(int[] v)
           
 MosaicCanvas newMosaic(SVarSet vs, int[] v)
           
 ParallelAxesCanvas newPCP(int[] v)
           
 ParallelAxesCanvas newPCP(SVarSet vs, int[] v)
           
 ScatterCanvas newScatterplot(int v1, int v2)
          display a new scatterplot of two variables from current dataset
 ScatterCanvas newScatterplot(SVarSet vs, int v1, int v2)
           
 int newSet(java.lang.String name)
          create and select a new dataset with the specified name. please note that it is possible to create multiple datasets of the same name but then only the first of these will be retrieved by name, others have to be selected by ID
 int newVar(java.lang.String name, double[] d)
          construct a new numerical variable from supplied array of doubles.
 int newVar(java.lang.String name, double[] x, double[] y)
          construct a new map variable - SVar consisting of MapSegment instances
 int newVar(java.lang.String name, int[] d)
          construct a new numerical variable from supplied array of integers.
 int newVar(java.lang.String name, int[] ix, java.lang.String d)
           
 int newVar(java.lang.String name, int[] ix, java.lang.String[] d)
          construct a new factor variable from supplied array of integers (cases) and strings (levels).
 int newVar(java.lang.String name, java.lang.String[] d)
          construct a new categorical variable from supplied array of strings.
 void Notifying(NotifyMsg msg, java.lang.Object o, java.util.Vector path)
          is a message arrives we'll simply use triggerNotification(org.rosuda.ibase.NotifyMsg) to inform any sleeping calls to waitForNotification()
 boolean removeSet(SVarSet s)
           
 boolean removeSetById(int i)
           
 int replaceVar(int vi, double[] d)
          replaces the content of a variable. it is meant for modification ONLY. note that the length of the new content cannot exceed the original size of the variable, no cases are added.
 int replaceVar(int vi, int[] d)
          replaces the content of a variable. it is meant for modification ONLY. note that the length of the new content cannot exceed the original size of the variable, no cases are added.
 int replaceVar(int vi, int[] ids, java.lang.String[] levels)
          replaces the content of a variable. it is meant for modification ONLY. note that the length of the new content cannot exceed the original size of the variable, no cases are added.
 SVarSet selectSet(int i)
          select dataset based on its ID (initial dataset has ID 0)/
 SVarSet selectSet(java.lang.String name)
          select dataset by name. the initial dataset created during framework initialization is called "default".
 void setDebugLevel(int df)
           
 void setExtQueryString(int plotID, java.lang.String str)
           
 void setGraphicsEngine(int greng)
           
 void setNoInteractionFlag(boolean flag)
           
 void setSecMark(int[] ml)
           
 void setSecMark(int[] ml, boolean circular)
           
static java.lang.String[] toStringArray(java.lang.Object[] o)
           
 void update()
          updates any plots associated with the current dataset by sending NM_VarContentChange message
 void updateMarker()
           
 void updateMarker(SVarSet vs, int vid)
          beware!!
 void updateVars()
           
 void useExtQueryString(int plotID, boolean b)
           
 int varIsNum(int vid)
           
 int varIsNum(SVar v)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

graphicsEngine

public int graphicsEngine
Constructor Detail

Framework

public Framework()
initialize framework, create and select a dataset which id called "default". one framework supports multiple datasets, plots etc. so there should be no need for multiple frameworks usually.

Method Detail

getNewTmpVar

public java.lang.String getNewTmpVar(java.lang.String t)

getNewTmpVar

public java.lang.String getNewTmpVar()

getCurrentSet

public SVarSet getCurrentSet()
get current dataset


isSetCurrent

public boolean isSetCurrent(SVarSet s)
verify whether a given dataset is current


selectSet

public SVarSet selectSet(java.lang.String name)
select dataset by name. the initial dataset created during framework initialization is called "default".

Parameters:
name - name of the dataset
Returns:
selected dataset or null if no such dataset was found

selectSet

public SVarSet selectSet(int i)
select dataset based on its ID (initial dataset has ID 0)/

Parameters:
i - the ID
Returns:
selected dataset or null if ID out of range

getSet

public SVarSet getSet(int i)

indexOfSet

public int indexOfSet(SVarSet s)

getSetIdByName

public int getSetIdByName(java.lang.String name)

countSets

public int countSets()

curSetId

public int curSetId()

getSetName

public java.lang.String getSetName(int i)

getSetName

public java.lang.String getSetName()

removeSetById

public boolean removeSetById(int i)

removeSet

public boolean removeSet(SVarSet s)

setNoInteractionFlag

public void setNoInteractionFlag(boolean flag)

getNoInteractionFlag

public boolean getNoInteractionFlag()

newSet

public int newSet(java.lang.String name)
create and select a new dataset with the specified name. please note that it is possible to create multiple datasets of the same name but then only the first of these will be retrieved by name, others have to be selected by ID

Parameters:
name - name of the new dataset
Returns:
new dataset

getLength

public int getLength()

addVar

public int addVar(SVar v)
add a variable to the current dataset. Note that many plots assume that all variables of a dataset have the same size.

Parameters:
v - the variable
Returns:
index of the variable within the dataset. In order to prevent usage of variables across datasets, most plots take the ID of a variable as parameter and NOT the SVar object itself.

msgDlg

public static java.lang.String msgDlg(java.lang.String caption,
                                      java.lang.String msg,
                                      java.lang.String[] buttons)
shows a modal dialog and waits until it is dismissed.

Parameters:
caption - window caption
msg - message string
buttons - buttons to show (see MsgDialog constants for default sets of buttons)
Returns:
text of the button pressed

getCurVarSetLength

public int getCurVarSetLength()
get the length of the current dataset


newVar

public int newVar(java.lang.String name,
                  double[] d)
construct a new numerical variable from supplied array of doubles. Unlike datasets variables cannot have the same name within a dataset.

Parameters:
name - variable name
d - array of doubles
Returns:
ID of the new variable, -1 if an error occured (variable name already exists or user declined to create a new iSet), -2 if the user cancelled the operation and -3 if the user opted to create a new iSet

newVar

public int newVar(java.lang.String name,
                  double[] x,
                  double[] y)
construct a new map variable - SVar consisting of MapSegment instances


newVar

public int newVar(java.lang.String name,
                  int[] d)
construct a new numerical variable from supplied array of integers. Unlike datasets variables cannot have the same name within a dataset.

Parameters:
name - variable name
d - array of integers
Returns:
ID of the new variable or -1 if error occured (variable name already exists etc.)

newVar

public int newVar(java.lang.String name,
                  java.lang.String[] d)
construct a new categorical variable from supplied array of strings. Unlike datasets variables cannot have the same name within a dataset.

Parameters:
name - variable name
d - array of strings
Returns:
ID of the new variable or -1 if error occured (variable name already exists etc.)

newVar

public int newVar(java.lang.String name,
                  int[] ix,
                  java.lang.String[] d)
construct a new factor variable from supplied array of integers (cases) and strings (levels). Unlike datasets variables cannot have the same name within a dataset.

Parameters:
name - variable name
ix - array of level IDs. IDs out of range (<1 or >length(d)) are treated as missing values
d - levels (d[0]=ID 1, d[1]=ID 2, ...)
Returns:
ID of the new variable or -1 if error occured (variable name already exists etc.)

newVar

public int newVar(java.lang.String name,
                  int[] ix,
                  java.lang.String d)

toStringArray

public static java.lang.String[] toStringArray(java.lang.Object[] o)

replaceVar

public int replaceVar(int vi,
                      double[] d)
replaces the content of a variable. it is meant for modification ONLY. note that the length of the new content cannot exceed the original size of the variable, no cases are added.

Parameters:
vi - ID of the variable
d - new content
Returns:
variable ID (same as vi)

replaceVar

public int replaceVar(int vi,
                      int[] d)
replaces the content of a variable. it is meant for modification ONLY. note that the length of the new content cannot exceed the original size of the variable, no cases are added.

Parameters:
vi - ID of the variable
d - new content
Returns:
variable ID (same as vi)

replaceVar

public int replaceVar(int vi,
                      int[] ids,
                      java.lang.String[] levels)
replaces the content of a variable. it is meant for modification ONLY. note that the length of the new content cannot exceed the original size of the variable, no cases are added.

Parameters:
vi - ID of the variable
d - new content
Returns:
variable ID (same as vi)

update

public void update()
updates any plots associated with the current dataset by sending NM_VarContentChange message


getVar

public SVar getVar(int i)
get variable object associated with an ID in current dataset

Parameters:
i - variable ID
Returns:
variable object or null if ID is invalid

getVar

public SVar getVar(java.lang.String name)
get first variable object associated with a name in current dataset

Parameters:
i - variable name
Returns:
variable object or null if var of that name doesn't exist

updateMarker

public void updateMarker(SVarSet vs,
                         int vid)
beware!! this updateMerker has nothing to do with updateMarker() !!!!! bad thing!


newFrame

public FrameDevice newFrame()

newFrame

public FrameDevice newFrame(java.lang.String tit)

newFrame

public FrameDevice newFrame(java.lang.String tit,
                            int wclass)

newFrame

public FrameDevice newFrame(java.lang.String tit,
                            boolean useCommonBg,
                            int wclass)

setGraphicsEngine

public void setGraphicsEngine(int greng)

getGraphicsEngine

public int getGraphicsEngine()

addNewPlot

public void addNewPlot(BaseCanvas bc)

newScatterplot

public ScatterCanvas newScatterplot(int v1,
                                    int v2)
display a new scatterplot of two variables from current dataset

Parameters:
v1 - X-axis variable
v2 - Y-axis variable
Returns:
scatterplot canvas object

newScatterplot

public ScatterCanvas newScatterplot(SVarSet vs,
                                    int v1,
                                    int v2)

newMap

public MapCanvas newMap(int v)

newMap

public MapCanvas newMap(SVarSet vs,
                        int v)

newBarchart

public BarCanvas newBarchart(int v)

newBarchart

public BarCanvas newBarchart(int v,
                             int wgt)

newBarchart

public BarCanvas newBarchart(SVarSet vs,
                             int v,
                             int wgt)

newLineplot

public LineCanvas newLineplot(int[] v)

newLineplot

public LineCanvas newLineplot(int rv,
                              int[] v)

newLineplot

public LineCanvas newLineplot(int rv,
                              int v)

newLineplot

public LineCanvas newLineplot(SVarSet vs,
                              int rv,
                              int[] v)

newHammock

public HamCanvas newHammock(int[] v)

newHammock

public HamCanvas newHammock(SVarSet vs,
                            int[] v)

newMosaic

public MosaicCanvas newMosaic(int[] v)

newMosaic

public MosaicCanvas newMosaic(SVarSet vs,
                              int[] v)

newPCP

public ParallelAxesCanvas newPCP(int[] v)

newPCP

public ParallelAxesCanvas newPCP(SVarSet vs,
                                 int[] v)

newHistogram

public HistCanvas newHistogram(int v)
display a new histogram of a variables from current dataset

Parameters:
v - variable ID
Returns:
histogram canvas object

newHistogram

public HistCanvas newHistogram(SVarSet vs,
                               int i)

newBoxplot

public ParallelAxesCanvas newBoxplot(int i)

newBoxplot

public ParallelAxesCanvas newBoxplot(int i,
                                     int ic)

newBoxplot

public ParallelAxesCanvas newBoxplot(int[] i)

newBoxplot

public ParallelAxesCanvas newBoxplot(int[] i,
                                     int ic)

newBoxplot

public ParallelAxesCanvas newBoxplot(SVarSet vs,
                                     int[] i,
                                     int ic)

getDoubleContent

public double[] getDoubleContent(int vid)
display a new variables frame

Returns:
variable frame object public VarFrame newVarFrame() { return newVarFrame(cvs); }; public VarFrame newVarFrame(SVarSet v) { VarFrame vf=new VarFrame(v,10,10,150,400); return vf; };

getStringContent

public java.lang.String[] getStringContent(int vid)

getDoubleContent

public double[] getDoubleContent(SVar v)

getStringContent

public java.lang.String[] getStringContent(SVar v)

varIsNum

public int varIsNum(int vid)

varIsNum

public int varIsNum(SVar v)

setSecMark

public void setSecMark(int[] ml)

setSecMark

public void setSecMark(int[] ml,
                       boolean circular)

updateMarker

public void updateMarker()

updateVars

public void updateVars()

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

setDebugLevel

public void setDebugLevel(int df)

Notifying

public void Notifying(NotifyMsg msg,
                      java.lang.Object o,
                      java.util.Vector path)
is a message arrives we'll simply use triggerNotification(org.rosuda.ibase.NotifyMsg) to inform any sleeping calls to waitForNotification()

Specified by:
Notifying in interface Dependent
o - Object that sent the notification. The actual content is implementation-dependent.
path - This parameter is null for non-cascaded notify - in that case further calls to NotifyAll are not allowed. Otherwise it contains a Vector with all objects notified so far during cascaded notify. To aviod cyclic notifications every instance must either reject cascaded notifications (i.e. no calls to NotifyAll at all) or check for occurence of itself in the chain before calling NotifyAll. The only valid recursive calls in Notifying are NotifyAll(path) and NotifyAll(..,path), because only these two pass the "path" parameter to avoid cyclic loops.

eventWait

public NotifyMsg eventWait()
this methods is called from R by ievent.wait and uses waitForNotification() to wait for an event.


d2s

public java.lang.String d2s(double d)

setExtQueryString

public void setExtQueryString(int plotID,
                              java.lang.String str)

useExtQueryString

public void useExtQueryString(int plotID,
                              boolean b)