version 1.39, 2010/11/19 15:41:28
|
version 1.40, 2010/11/19 17:20:44
|
Line 47 sub geogebra_startcode {
|
Line 47 sub geogebra_startcode {
|
my ($id)=@_; |
my ($id)=@_; |
return (<<ENDSTARTCODE); |
return (<<ENDSTARTCODE); |
<applet name="ggbApplet_$id" code="geogebra.GeoGebraApplet" archive="geogebra.jar" |
<applet name="ggbApplet_$id" code="geogebra.GeoGebraApplet" archive="geogebra.jar" |
codebase="/adm/geogebra/" width="714" height="447" MAYSCRIPT> |
codebase="/adm/geogebra/" width="722" height="447" MAYSCRIPT> |
<param name="java_arguments" value="-Xmx512m -Djnlp.packEnabled=true"/> |
<param name="java_arguments" value="-Xmx512m -Djnlp.packEnabled=true"/> |
ENDSTARTCODE |
ENDSTARTCODE |
} |
} |
Line 74 sub geogebra_default_parameters {
|
Line 74 sub geogebra_default_parameters {
|
<param name="image" value="/adm/lonIcons/lonanim.gif" /> |
<param name="image" value="/adm/lonIcons/lonanim.gif" /> |
<param name="boxborder" value="false" /> |
<param name="boxborder" value="false" /> |
<param name="centerimage" value="true" /> |
<param name="centerimage" value="true" /> |
<param name="java_arguments" value="-Xmx512m -Djnlp.packEnabled=true" /> |
|
<param name="cache_archive" value="geogebra.jar, geogebra_main.jar, geogebra_gui.jar, geogebra_cas.jar, geogebra_algos.jar, geogebra_export.jar, geogebra_javascript.jar, jlatexmath.jar, jlm_greek.jar, jlm_cyrillic.jar, geogebra_properties.jar" /> |
<param name="cache_archive" value="geogebra.jar, geogebra_main.jar, geogebra_gui.jar, geogebra_cas.jar, geogebra_algos.jar, geogebra_export.jar, geogebra_javascript.jar, jlatexmath.jar, jlm_greek.jar, jlm_cyrillic.jar, geogebra_properties.jar" /> |
<param name="cache_version" value="3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0" /> |
<param name="cache_version" value="3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0" /> |
<param name="framePossible" value="false" /> |
<param name="framePossible" value="false" /> |
Line 159 sub update_register {
|
Line 158 sub update_register {
|
} |
} |
|
|
# |
# |
# Set a coordinate variable |
# Set a point coordinate variable |
# |
# |
sub set_coordinate { |
sub set_point_coordinate { |
my ($id,$variable,$x,$y)=@_; |
my ($id,$variable,$x,$y)=@_; |
return (<<ENDSETVARIABLE); |
return (<<ENDSETVARIABLE); |
document.ggbApplet_$id.evalCommand("$variable=($x,$y)"); |
document.ggbApplet_$id.evalCommand("$variable=($x,$y)"); |
|
document.ggbApplet_$id.setLabelVisible("$variable",false); |
ENDSETVARIABLE |
ENDSETVARIABLE |
} |
} |
|
|
# |
# |
|
# Set a slope coordinate variable |
|
# |
|
sub set_slope_coordinate { |
|
my ($id,$variable,$xrel,$yrel,$xmin,$xmax,$ymin,$ymax,$pointname)=@_; |
|
my $xvariable=$variable.'x'; |
|
my $yvariable=$variable.'y'; |
|
my $domain=$xmax-$xmin; |
|
my $range=$ymax-$ymin; |
|
my $xinterval=$domain/100.; |
|
my $yinterval=$range/200.; |
|
return (<<ENDSETSVARIABLE); |
|
document.ggbApplet_$id.evalCommand("$xvariable=Slider[0,$domain,$xinterval]"); |
|
document.ggbApplet_$id.setVisible("$xvariable", false); |
|
document.ggbApplet_$id.evalCommand("$xvariable=$xrel"); |
|
document.ggbApplet_$id.evalCommand("$yvariable=Slider[-$range,$range,$yinterval]"); |
|
document.ggbApplet_$id.setVisible("$yvariable", false); |
|
document.ggbApplet_$id.evalCommand("$yvariable=$yrel"); |
|
document.ggbApplet_$id.evalCommand("$variable=($xvariable+x($pointname),$yvariable+y($pointname))"); |
|
document.ggbApplet_$id.setLabelVisible("$variable", false); |
|
ENDSETSVARIABLE |
|
} |
|
|
|
# |
# Input field name for a coordinate variable |
# Input field name for a coordinate variable |
# |
# |
|
|
Line 189 sub generate_input_field {
|
Line 212 sub generate_input_field {
|
} |
} |
|
|
# |
# |
# Initialize a new coordinate variable at set a listener on it |
# Initialize a new point coordinate variable at set a listener on it |
# |
# |
sub new_coordinate { |
sub new_point_coordinate { |
my ($id,$variable,$x,$y)=@_; |
my ($id,$variable,$x,$y)=@_; |
if (defined($Apache::functionplotresponse::previous{&field_name($id,$variable,'x')})) { |
if (defined($Apache::functionplotresponse::previous{&field_name($id,$variable,'x')})) { |
$x=$Apache::functionplotresponse::previous{&field_name($id,$variable,'x')}; |
$x=$Apache::functionplotresponse::previous{&field_name($id,$variable,'x')}; |
Line 200 sub new_coordinate {
|
Line 223 sub new_coordinate {
|
$y=$Apache::functionplotresponse::previous{&field_name($id,$variable,'y')}; |
$y=$Apache::functionplotresponse::previous{&field_name($id,$variable,'y')}; |
} |
} |
&generate_input_field($id,$variable,$x,$y); |
&generate_input_field($id,$variable,$x,$y); |
return &set_coordinate($id,$variable,$x,$y).&update_register($id,$variable); |
return &set_point_coordinate($id,$variable,$x,$y).&update_register($id,$variable); |
|
} |
|
|
|
# |
|
# Initialize a new slope coordinate variable at set a listener on it |
|
# |
|
sub new_slope_coordinate { |
|
my ($id,$variable,$x,$y,$pointname,$xp,$yp,$xmin,$xmax,$ymin,$ymax)=@_; |
|
# |
|
# $variable: name of the slope point |
|
# $x, $y: coordinates of the slope point |
|
# $pointname: name of the associated point point |
|
# $xp $yp: coordinates of the point point |
|
# |
|
if (defined($Apache::functionplotresponse::previous{&field_name($id,$variable,'x')})) { |
|
$x=$Apache::functionplotresponse::previous{&field_name($id,$variable,'x')}; |
|
} |
|
if (defined($Apache::functionplotresponse::previous{&field_name($id,$variable,'y')})) { |
|
$y=$Apache::functionplotresponse::previous{&field_name($id,$variable,'y')}; |
|
} |
|
if (defined($Apache::functionplotresponse::previous{&field_name($id,$pointname,'x')})) { |
|
$xp=$Apache::functionplotresponse::previous{&field_name($id,$pointname,'x')}; |
|
} |
|
if (defined($Apache::functionplotresponse::previous{&field_name($id,$pointname,'y')})) { |
|
$yp=$Apache::functionplotresponse::previous{&field_name($id,$pointname,'y')}; |
|
} |
|
|
|
&generate_input_field($id,$variable,$x,$y); |
|
my $xrel=$x-$xp; |
|
my $yrel=$y-$yp; |
|
return &set_slope_coordinate($id,$variable,$xrel,$yrel,$xmin,$xmax,$ymin,$ymax,$pointname).&update_register($id,$variable); |
} |
} |
|
|
# |
# |
Line 284 ENDPLOTSCRIPT
|
Line 337 ENDPLOTSCRIPT
|
# |
# |
|
|
sub generate_spline { |
sub generate_spline { |
my ($id,$label)=@_; |
my ($id,$label,$xmin,$xmax,$ymin,$ymax)=@_; |
my $result=''; |
my $result=''; |
my $order=$Apache::functionplotresponse::splineorder{$label}; |
my $order=$Apache::functionplotresponse::splineorder{$label}; |
my $x=$Apache::functionplotresponse::splineinitx{$label}; |
my $x=$Apache::functionplotresponse::splineinitx{$label}; |
Line 293 sub generate_spline {
|
Line 346 sub generate_spline {
|
my $sy=$Apache::functionplotresponse::splinescaley{$label}; |
my $sy=$Apache::functionplotresponse::splinescaley{$label}; |
my @coords=(); |
my @coords=(); |
foreach my $i (1..$order) { |
foreach my $i (1..$order) { |
$result.=&new_coordinate($id,$label.'P'.$i,$x,$y); |
$result.=&new_point_coordinate($id,$label.'P'.$i,$x,$y); |
|
my $xp=$x; |
$x+=$sx/(2.*($order-1)); |
$x+=$sx/(2.*($order-1)); |
push(@coords,$label.'P'.$i); |
push(@coords,$label.'P'.$i); |
$result.=&new_coordinate($id,$label.'S'.$i,$x,$y+$sy); |
$result.=&new_slope_coordinate($id,$label.'S'.$i,$x,$y+$sy,$label.'P'.$i,$xp,$y,$xmin,$xmax,$ymin,$ymax); |
$x+=$sx/(2.*($order-1)); |
$x+=$sx/(2.*($order-1)); |
push(@coords,$label.'S'.$i); |
push(@coords,$label.'S'.$i); |
} |
} |
Line 1068 sub end_functionplotelements {
|
Line 1122 sub end_functionplotelements {
|
$result=&Apache::edit::end_table(); |
$result=&Apache::edit::end_table(); |
} elsif ($target eq 'web') { |
} elsif ($target eq 'web') { |
# Now is the time to render all of the stored splines |
# Now is the time to render all of the stored splines |
|
my $xmin=&Apache::lonxml::get_param('xmin',$parstack,$safeeval,-2); |
|
$xmin=(defined($xmin)?$xmin:-10); |
|
my $xmax=&Apache::lonxml::get_param('xmax',$parstack,$safeeval,-2); |
|
$xmax=(defined($xmax)?$xmax:10); |
|
my $ymin=&Apache::lonxml::get_param('ymin',$parstack,$safeeval,-2); |
|
$ymin=(defined($ymin)?$ymin:-10); |
|
my $ymax=&Apache::lonxml::get_param('ymax',$parstack,$safeeval,-2); |
|
$ymax=(defined($ymax)?$ymax:10); |
|
if ($xmax<=$xmin) { |
|
$xmax=$xmin+20; |
|
} |
|
if ($ymax<=$ymin) { |
|
$ymax=$ymin+20; |
|
} |
foreach my $label (keys(%Apache::functionplotresponse::splineorder)) { |
foreach my $label (keys(%Apache::functionplotresponse::splineorder)) { |
$result.=&generate_spline($internalid,$label); |
$result.=&generate_spline($internalid,$label,$xmin,$xmax,$ymin,$ymax); |
} |
} |
# close the init script |
# close the init script |
$result.=&end_init_script(); |
$result.=&end_init_script(); |