Back to index

wims  3.65+svn20090927
Classes | Public Member Functions | Protected Member Functions | Private Attributes
ptolemy.plot.EditablePlotApplet Class Reference

This applet reads a URL giving a Plot file for a plot and places the data into an editable plot. More...

Inheritance diagram for ptolemy.plot.EditablePlotApplet:
Inheritance graph
[legend]
Collaboration diagram for ptolemy.plot.EditablePlotApplet:
Collaboration graph
[legend]

List of all members.

Classes

class  ChoiceListener

Public Member Functions

void init ()
 Initialize the applet.
String getAppletInfo ()
 Return a string describing this applet.
PlotBox newPlot ()
 Create a new Plot object for the applet.
String ReadApplet ()
 Construct a Plot applet.
String[][] getParameterInfo ()
 Return information about parameters.
synchronized void read_from_param (String data)
 Initialize the applet.
synchronized void read_function_from_param (String function, String names, String totaal, int xmin, int xmax, int plotsteps, int smooth)
PlotBox plot ()
 Return the plot object to operate on.
void setPlot (PlotBox plot)
 Set the plot object to operate on.

Protected Member Functions

void _setPlotSize (int appletWidth, int appletHeight)
 Given the size of the applet, set the size of the plot.
void _read (InputStream in) throws IOException
 Read the specified stream.

Private Attributes

JComboBox _choice

Detailed Description

This applet reads a URL giving a Plot file for a plot and places the data into an editable plot.

See also:
EditablePlot
Author:
Edward A. Lee
Version:
Id:
EditablePlotApplet.java,v 1.31 2005/07/08 19:59:37 cxh Exp
Since:
Ptolemy II 0.4 .ProposedRating red (eal) .AcceptedRating red (cxh)

Definition at line 55 of file EditablePlotApplet.java.


Member Function Documentation

void ptolemy.plot.PlotApplet._read ( InputStream  in) throws IOException [inline, protected, inherited]

Read the specified stream.

Derived classes may override this to support other file formats.

Parameters:
inThe input stream.
Exceptions:
IOExceptionIf the stream cannot be read.

Definition at line 389 of file PlotApplet.java.

                                                            {
        plot().read(in);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void ptolemy.plot.EditablePlotApplet._setPlotSize ( int  appletWidth,
int  appletHeight 
) [inline, protected]

Given the size of the applet, set the size of the plot.

Derived classes may override this to allow room for other widgets below the plot.

Parameters:
appletWidthThe width of the applet.
appletHeightThe height of the applet.

Reimplemented from ptolemy.plot.PlotApplet.

Definition at line 109 of file EditablePlotApplet.java.

                                                                   {
        if (appletHeight > 50) {
            plot().setSize(appletWidth, appletHeight - 50);
        } else {
            plot().setSize(appletWidth, appletHeight);
        }
    }

Here is the call graph for this function:

Return a string describing this applet.

Reimplemented from ptolemy.plot.PlotApplet.

Definition at line 86 of file EditablePlotApplet.java.

                                  {
        return "EditablePlotDemo "
                + ": Demo of EditablePlot.\n"
                + "By: Edward A. Lee\n "
                + "($Id: EditablePlotApplet.java,v 1.31 2005/07/08 19:59:37 cxh Exp $)";
    }
String [][] ptolemy.plot.PlotApplet.getParameterInfo ( ) [inline, inherited]

Return information about parameters.

Returns:
A array of arrays giving parameter names, the type, and the default value or description.

Definition at line 105 of file PlotApplet.java.

                                         {
        String[][] pinfo = {
                { "background", "hexcolor value", "background color" },
                { "foreground", "hexcolor value", "foreground color" },
                { "dataurl", "url", "the URL of the data to plot" },
                { "height", "integer", "100" },
              { "width", "integer", "100" }, 
              { "function", "String", "function1,function2,function3,function4 ..." }, 
              { "smooth", "integer", "0 or 1 : use with care. default=0" }, 
              { "names", "String", "names function1,name function2 ... or left blank " }, 
              { "xmin", "integer", "minimum x-value or left blank for auto detection" }, 
              { "xmax", "integer", "maximum x-value or left blank for auto detection" }, 
              { "ymin", "integer", "minimum y-value or left blank for auto detection" }, 
              { "ymax", "integer", "maximum y-value or left blank for auto detection" }, 
              { "xlog", "integer", "x-axis is log-scale: 0 or 1: default 0" }, 
              { "ylog", "integer", "y-axis is log-scale: 0 or 1: default 0" }, 
              { "color", "integer", " 0 or 1 :default 1" }, 
              { "xtics", "String", " zero 0, one 1, two 2, pi 3.1428, four 4, five 5 " }, 
              { "ytics", "String", " thing1 0, thing2 1, thing3 2, three 3, four 4, five 5 " }, 
              { "xlabel", "String", "label of the x-axis: default x-axis" }, 
              { "ylabel", "String", "label of the y-axis: default y-axis" }, 
              { "title", "String", "title of the plot" }, 
              };
        return pinfo;
    }

Initialize the applet.

Place an instance of EditablePlot and a widget for selecting the data set to edit.

Reimplemented from ptolemy.plot.PlotApplet.

Definition at line 62 of file EditablePlotApplet.java.

                       {
        super.init();

        JPanel controlPanel = new JPanel();

        // Make the panel transparent so that the background shows through.
        controlPanel.setOpaque(false);
        getContentPane().add(controlPanel, BorderLayout.SOUTH);

        controlPanel.add(new JLabel("Data set to edit:"));

        _choice = new JComboBox();
        controlPanel.add(_choice);

        for (int i = 0; i < ((Plot) plot()).getNumDataSets(); i++) {
            _choice.addItem(plot().getLegend(i));
        }

        _choice.addActionListener(new ChoiceListener());
    }

Here is the call graph for this function:

Create a new Plot object for the applet.

Derived classes can redefine this method to return a different type of plot object.

Reimplemented from ptolemy.plot.PlotApplet.

Definition at line 96 of file EditablePlotApplet.java.

                             {
        return new EditablePlot();
    }
PlotBox ptolemy.plot.PlotApplet.plot ( ) [inline, inherited]

Return the plot object to operate on.

Returns:
The plot object associated with this applet.

Definition at line 367 of file PlotApplet.java.

                          {
        return _plot;
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.PlotApplet.read_from_param ( String  data) [inline, inherited]

Initialize the applet.

Read the applet parameters.

Subclasses that extend this method and call Swing UI methods should do so in the Swing Event thread by calling SwingUtilities.invokeAndWait(). Note that some Plot methods will automatically run in the Swing Event thread, some will not. For details about SwingUtilities.invokeAndWait(), see The Sun Applet Tutorial

Definition at line 143 of file PlotApplet.java.

                                                         {
       StringTokenizer f = new StringTokenizer(data, ";");
       int max=f.countTokens();String line="";
       for(int s=0;s<max;s++){
           line=f.nextToken();
            plot().read(line);
           //System.out.println("regel "+s+" = "+line);
        }
        showStatus("Done");
       repaint(); 
    }                                                                                     

Here is the call graph for this function:

Here is the caller graph for this function:

synchronized void ptolemy.plot.PlotApplet.read_function_from_param ( String  function,
String  names,
String  totaal,
int  xmin,
int  xmax,
int  plotsteps,
int  smooth 
) [inline, inherited]

Definition at line 155 of file PlotApplet.java.

                                                                                                                                            {
       String fun;String line="";String fff;
       Symbols symbols=new Symbols();
       double stap=(double) (xmax-xmin)/plotsteps;double org=stap;double y=0.0;double x=0.0;double dy=0.0;
       float diff;
       int s;int max;int tot=0;int n;String legenda="";
       if(names.length()!=0){ n=1; } else { n=0; }
       StringTokenizer ff = new StringTokenizer(function, ",");max=ff.countTokens();
       StringTokenizer nn = new StringTokenizer(names, ",");
       for(s=0;s<max;s++){
           if(n==0){ totaal=totaal+";dataset:"+s; } else {legenda=nn.nextToken(); totaal=totaal+";dataset:"+legenda; } 
           fff=ff.nextToken();
           System.out.println("functie "+s + "="+fff);
           for(x=xmin; x<xmax; x=x+stap){
              if(smooth==1){
                  diff=(float) Math.abs(y-dy);
                  if(diff>10*stap && stap>0.001){stap=0.5*stap;}else{stap=org;}
              }
              fun=fff.replaceAll("x","("+Double.toString(x)+")");
              try { y=symbols.eval(fun);} catch (SyntaxException e) {System.out.println("error "+e); }
              totaal=totaal+";"+x+","+y;
              tot++;
           }
       }
       System.out.println("totaal aantal punten is "+tot);
       StringTokenizer f = new StringTokenizer(totaal, ";");max=f.countTokens();
       for(s=0;s<max;s++){
           plot().read(f.nextToken());
       }
       showStatus("Done");
       repaint(); 
    }                                                                                     

Here is the call graph for this function:

Here is the caller graph for this function:

String ptolemy.plot.PlotApplet.ReadApplet ( ) [inline, inherited]

Construct a Plot applet.

Definition at line 85 of file PlotApplet.java.

                              {
                                                                                                                
        String reply="";
       reply=plot().ReadPlotApplet();                                                                                                                 
    return reply;                                                                                                                          
    }

Here is the call graph for this function:

void ptolemy.plot.PlotApplet.setPlot ( PlotBox  plot) [inline, inherited]

Set the plot object to operate on.

Parameters:
plotThe plot object to associate with this applet.

Definition at line 374 of file PlotApplet.java.

                                      {
        // FIXME: this method is necessary for PxgraphApplet to work
        // properly.  We could modify newPlot() to set _plot, but
        // that would change the newPlot() contract, so we add another method.
        _plot = plot;
    }

Here is the call graph for this function:


Member Data Documentation

Definition at line 120 of file EditablePlotApplet.java.


The documentation for this class was generated from the following file: