[rkward-cvs] SF.net SVN: rkward: [1476] trunk/rkward/rkward/plugins

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Feb 26 15:26:11 UTC 2007


Revision: 1476
          http://svn.sourceforge.net/rkward/?rev=1476&view=rev
Author:   tfry
Date:     2007-02-26 07:26:10 -0800 (Mon, 26 Feb 2007)

Log Message:
-----------
Rework histogram_options options separation (partial undo of previous commit)
Instead of splitting by a string, the different options are now kept in different segments of the generated code

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/distributions/plot_binomial_clt.php
    trunk/rkward/rkward/plugins/distributions/plot_binomial_clt.xml
    trunk/rkward/rkward/plugins/plots/histogram_options.php
    trunk/rkward/rkward/plugins/plots/histogram_options.rkh
    trunk/rkward/rkward/plugins/plots/histogram_options.xml

Modified: trunk/rkward/rkward/plugins/distributions/plot_binomial_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/plot_binomial_clt.php	2007-02-26 15:03:40 UTC (rev 1475)
+++ trunk/rkward/rkward/plugins/distributions/plot_binomial_clt.php	2007-02-26 15:26:10 UTC (rev 1476)
@@ -44,9 +44,8 @@
 	}
 
 	if ($fun == "hist") {
-		$all_hist_code = explode (getRK_val ("histogram_opt.options_splitter_string"), getRK_val ("histogram_opt.code.printout"));
-		$histbreaksoptions = $all_hist_code[0];
-		$histoptions = $all_hist_code[1];
+		$histbreaksoptions = getRK_val ("histogram_opt.code.calculate");
+		$histoptions = getRK_val ("histogram_opt.code.printout");
 		$histoptions .= getRK_val("plotoptions.code.printout");
 	}
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/plot_binomial_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/plot_binomial_clt.xml	2007-02-26 15:03:40 UTC (rev 1475)
+++ trunk/rkward/rkward/plugins/distributions/plot_binomial_clt.xml	2007-02-26 15:26:10 UTC (rev 1476)
@@ -11,7 +11,6 @@
 		<set id="normlinecol.default_color" to="red" />
 
 		<set id="histogram_opt.varname" to="rk.temp.cltdistrib$avg" />
-		<set id="histogram_opt.options_splitter_string" to="###OPTIONS_SPLIT###" />
 		<set id="histogram_opt.allow_freq" to="false" />
 		<set id="histogram_opt.allow_barlabels" to="true" />
 		<set id="histogram_opt.allow_addtoplot" to="false" />

Modified: trunk/rkward/rkward/plugins/plots/histogram_options.php
===================================================================
--- trunk/rkward/rkward/plugins/plots/histogram_options.php	2007-02-26 15:03:40 UTC (rev 1475)
+++ trunk/rkward/rkward/plugins/plots/histogram_options.php	2007-02-26 15:26:10 UTC (rev 1476)
@@ -1,82 +1,102 @@
 <?
-function preprocess () {
-}
+function makeCodes () {
+	global $histbreaksoptions;
+	global $histoptions;
+	global $headeroptions;
 
-function calculate () {
-}
+	$histbreaksoptions = ", breaks=";
+	$histoptions = "";
+	$headeroptions = "";
+	$varname = getRK_val ("varname");
 
-function printout () {
-		$histbreaksoptions = ", breaks=";
-		$histoptions = "";
-		$headeroptions = "";
-		$varname = getRK_val ("varname");
+	$histbreaks = getRK_val ("histbreaksFunction");
+	$headeroptions .= ', Breaks, "';
+	if ($histbreaks == "cells") {
+		$histbreaksoptions .= getRK_val ("histbreaks_ncells");
+		$header_options .= getRK_val ("histbreaks_ncells") . 'cells"';
+	} else if ($histbreaks == "int") {
+		$histbreaksoptions .= "seq (floor (min (" . $varname . ", na.rm=TRUE))-0.5, ceiling (max (" . $varname . ", na.rm=TRUE))+0.5)";
+		$header_options .= 'integers"';
+	}
+	else if ($histbreaks == "vec") {
+		$histbreaksoptions .= "(function(x) {y = extendrange(x,f=0.1); seq(from=y[1], to=y[2], length=" . getRK_val ("histbreaks_veclength") . ")})(" . $varname . ")";
+		$header_options .= 'vector length ' . getRK_val ("histbreaks_veclength") . '"';
+	} else {
+		$histbreaksoptions .= "\"" . $histbreaks . "\"";
+		$header_options .= $histbreaks . '"';
+	}
 
-		$histbreaks = getRK_val ("histbreaksFunction");
-		$headeroptions .= ', Breaks, "';
-		if ($histbreaks == "cells") {
-			$histbreaksoptions .= getRK_val ("histbreaks_ncells");
-			$header_options .= getRK_val ("histbreaks_ncells") . 'cells"';
-		} else if ($histbreaks == "int") {
-			$histbreaksoptions .= "seq (floor (min (" . $varname . ", na.rm=TRUE))-0.5, ceiling (max (" . $varname . ", na.rm=TRUE))+0.5)";
-			$header_options .= 'integers"';
-		}
-		else if ($histbreaks == "vec") {
-			$histbreaksoptions .= "(function(x) {y = extendrange(x,f=0.1); seq(from=y[1], to=y[2], length=" . getRK_val ("histbreaks_veclength") . ")})(" . $varname . ")";
-			$header_options .= 'vector length ' . getRK_val ("histbreaks_veclength") . '"';
-		} else {
-			$histbreaksoptions .= "\"" . $histbreaks . "\"";
-			$header_options .= $histbreaks . '"';
-		}
+	$addbars = getRK_val ("addtoplot");
+	if ($addbars) $histoptions .= ", add=TRUE";
 
-		$addbars = getRK_val ("addtoplot");
-		if ($addbars) $histoptions .= ", add=TRUE";
+	$freq = getRK_val ("freq");
+	if (!$freq) {
+		$histoptions .= ", freq=FALSE";
+		$headeroptions .= ', Scale, "Density"';
+	} else {
+		$headeroptions .= ', Scale, "Frequency"';
+	}
 
-		$freq = getRK_val ("freq");
-		if (!$freq) {
-			$histoptions .= ", freq=FALSE";
-			$headeroptions .= ', Scale, "Density"';
-		} else {
-			$headeroptions .= ', Scale, "Frequency"';
-		}
+	$labels = getRK_val ("barlabels");
+	if ($labels) $histoptions .= ", labels=TRUE";
 
-		$labels = getRK_val ("barlabels");
-		if ($labels) $histoptions .= ", labels=TRUE";
+	$right = getRK_val ("rightclosed");
+	if (!$right) {
+		$headeroptions .= ', "Right closed", "FALSE"';
+		$histoptions .= ", right=FALSE";
+	} else {
+		$headeroptions .= ', "Right closed", "TRUE"';
+	}
 
-		$right = getRK_val ("rightclosed");
-		if (!$right) {
-			$headeroptions .= ', "Right closed", "FALSE"';
-			$histoptions .= ", right=FALSE";
-		} else {
-			$headeroptions .= ', "Right closed", "TRUE"';
-		}
+	$inclowest = getRK_val ("include_lowest");
+	if (!$inclowest) {
+		$headeroptions .= ', "Include in lowest cell", "FALSE"';
+		$histoptions .= ", include.lowest=FALSE";
+	} else {
+		$headeroptions .= ', "Include in lowest cell", "TRUE"';
+	}
 
-		$inclowest = getRK_val ("include_lowest");
-		if (!$inclowest) {
-			$headeroptions .= ', "Include in lowest cell", "FALSE"';
-			$histoptions .= ", include.lowest=FALSE";
-		} else {
-			$headeroptions .= ', "Include in lowest cell", "TRUE"';
-		}
+	$histlty = getRK_val ("histlinetype");
+	$histoptions .= ", lty=" . "\"" . $histlty . "\"";
 
-		$histlty = getRK_val ("histlinetype");
-		$histoptions .= ", lty=" . "\"" . $histlty . "\"";
+	if ($histlty != "blank") {
+		$density = getRK_val ("density");
+		$histoptions .= ", density=" . $density;
+		if ($density > 0) $histoptions .= ", angle=" . getRK_val ("angle");
+		if (getRK_val ("doborder")) $histbordercol = getRK_val ("histbordercol.code.printout");
+		else $histbordercol = ", border=FALSE";
+	}
 
-		if ($histlty != "blank") {
-			$density = getRK_val ("density");
-			$histoptions .= ", density=" . $density;
-			if ($density > 0) $histoptions .= ", angle=" . getRK_val ("angle");
-			if (getRK_val ("doborder")) $histbordercol = getRK_val ("histbordercol.code.printout");
-			else $histbordercol = ", border=FALSE";
-		}
+	$histfillcol = "";
+	if (getRK_val ("usefillcol")) $histfillcol = getRK_val ("histfillcol.code.printout");
 
-			$histfillcol = "";
-			if (getRK_val ("usefillcol")) $histfillcol = getRK_val ("histfillcol.code.printout");
+	$histoptions .= $histbordercol . $histfillcol;
+}
 
-			$histoptions .= $histbordercol . $histfillcol;
-		$splitter = getRK_val ("options_splitter_string");
-		echo ($histbreaksoptions . $splitter . $histoptions . $splitter . $headeroptions);
+function preprocess () {
+	global $headeroptions;
+
+	makeCodes();
+
+	echo ($headeroptions);
 }
 
+function calculate () {
+	global $histbreaksoptions;
+
+	// makeCodes() has already run
+
+	echo ($histbreaksoptions);
+}
+
+function printout () {
+	global $histoptions;
+
+	// makeCodes() has already run
+
+	echo ($histoptions);
+}
+
 function cleanup () {
 }
 ?>

Modified: trunk/rkward/rkward/plugins/plots/histogram_options.rkh
===================================================================
--- trunk/rkward/rkward/plugins/plots/histogram_options.rkh	2007-02-26 15:03:40 UTC (rev 1475)
+++ trunk/rkward/rkward/plugins/plots/histogram_options.rkh	2007-02-26 15:26:10 UTC (rev 1476)
@@ -39,10 +39,15 @@
 		The following external tags are provided for use in the embeding plugin.
 		<ul>
 			<li><i>varname</i>: For linking to the variable name for which histogram is being plotted. This is used in the 'Integer numbers' option for breaks.</li>
-			<li><i>allow_freq</i>: Setting this to "true" ("false") enables ("disables") the display of the 'Frequency' checkbox.</li>
-			<li><i>allow_barlabels</i>: Setting this to "true" ("false") enables ("disables") the display of the 'Bar labels' checkbox.</li>
-			<li><i>allow_addtoplot</i>: Setting this to "true" ("false") enables ("disables") the display of the 'Add bars to current plot' checkbox.</li>
+			<li><i>allow_freq</i>: Setting this to "true" ("false") enables (disables) the display of the 'Frequency' checkbox.</li>
+			<li><i>allow_barlabels</i>: Setting this to "true" ("false") enables (disables) the display of the 'Bar labels' checkbox.</li>
+			<li><i>allow_addtoplot</i>: Setting this to "true" ("false") enables (disables) the display of the 'Add bars to current plot' checkbox.</li>
 		</ul>
-			A special string, <b>HIST_STRING_SPLITTER</b> has been embeded in the plugin printout for demarcating the <i>breaks</i> options from other plot.histogram options. Use it to split the <i>code.printout</i> string from the embeding plugin's php file.
+		In order to allow flexible use, the generated options are separated into three different sections:
+		<ul>
+			<li><i>code.preprocess</i>: Options suitable for use in a call to rk.header(). These are safe to ignore, if you do not need them.</li>
+			<li><i>code.calculate</i>: This contains only the <i>breaks</i>-option.</li>
+			<li><i>code.printout</i>: This contains all the other options determining the look of the plot.</li>
+		</ul>
 	</section>
 </document>

Modified: trunk/rkward/rkward/plugins/plots/histogram_options.xml
===================================================================
--- trunk/rkward/rkward/plugins/plots/histogram_options.xml	2007-02-26 15:03:40 UTC (rev 1475)
+++ trunk/rkward/rkward/plugins/plots/histogram_options.xml	2007-02-26 15:26:10 UTC (rev 1476)
@@ -4,8 +4,6 @@
 	<help file="histogram_options.rkh"/>
 	<logic>
 		<external id="varname" default=""/>
-		<external id="options_splitter_string" default=""/>
-		<external id="make_header_options" default="1" />
 		<external id="allow_freq" default="true"/>
 		<external id="allow_barlabels" default="true"/>
 		<external id="allow_addtoplot" default="true"/>


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list