= #JxnPortable\docs\plot_examples\AutoScaleDemo.jxn

owner = @Frame( "plot_auto_rescale" )
#JXN:include/SliderInclude
owner.setFont @java.awt.Font( "Dialog", Font.BOLD, 16 )
r1 = slider.add( "r1", 1., 0., 5. )
r2 = slider.add( "r2", 1., 0., 5. )
!
cs = cos 2 PI t
sn = sin 2 PI t
!
pf1a = plot( r1 cs, r1 sn ).add( 0.8 r2 cs, 1.25 r2 sn, B )
pf1a.setAutoScale(0).setHeadline( "1a: autoscale = 0" )
pf1a.add( 1.25 r2 cs, 0.8 r2 sn, G )
!
pf1b = plot( r1 cs, r1 sn ).add( 0.8 r2 cs, 1.25 r2 sn, B )
pf1b.setAutoScale(1).setHeadline( "1b: autoscale = 1" )
pf1b.add( 1.25 r2 cs, 0.8 r2 sn, G )
!
pf1c = plot( r1 cs, r1 sn ).add( 0.8 r2 cs, 1.25 r2 sn, B )
pf1c.setAutoScale(2).setHeadline( "1c: autoscale = 2")
pf1c.add( 1.25 r2 cs, 0.8 r2 sn, G )
!
pf2a = plot( r1 cs, r1 sn ).add( 0.8 r2 cs, 1.25 r2 sn, B ).add( 1.25 r2 cs, 0.8 r2 sn, G )
pf2a.setXYBounds( -1.0, -1.5, 1.0, 1.5 ).setHeadline( "2a: setXYBounds( -1.0, -1.5, 1.0, 1.5 )" )
!
pf2b = plot( r1 cs, r1 sn ).add( 0.8 r2 cs, 1.25 r2 sn, B )
pf2b.setXYBounds( -1.0, -1.5, 1.0, 1.5 ).setHeadline( "2b: setXYBounds( -1.0, -1.5, 1.0, 1.5 ) + TODO_ADD" )
!
pf2c = plot( r1 cs, r1 sn ).add( 0.8 r2 cs, 1.25 r2 sn, B )
pf2c.setAutoScale(0).setHeadline( "2c: autoscale = 0 + TODO_ADD" )
!
! pf1a.add( 2 cs, 2 sn, ORANGE )
! pf1b.add( 2 cs, 2 sn, ORANGE )
! pf1c.add( 2 cs, 2 sn, ORANGE )
! pf2a.add( 2 cs, 2 sn, ORANGE )
! pf2b.add( 2 cs, 2 sn, ORANGE )
! pf2c.add( 2 cs, 2 sn, ORANGE )
!
grid15 = @Panel()
#JXN:include/Grid15Include( pf1a, pf1b, pf1c, pf2a, pf2b, pf2c )
owner.add( grid15, java.awt.BorderLayout.CENTER )
slider.getSliderFrame().hide()
#JXN:include/FrameInclude.jxn
!
#ifdef TODO_ADD  ! execute the following statements to see how additional objects change the scaling
. pf2b.add( 1.25 r2 cs, 0.8 r2 sn, G )  ! autoscale = -1 => no rescale on add(painter)
. pf2c.add( 1.25 r2 cs, 0.8 r2 sn, G )  ! autoscale =  0 =>   rescales on add(painter)
#endif