# this shows how Autoplot/das2 can be hacked with a jython script to accomplish
# a goal.  Note .vap files of this will not work.

theplot= dom.controller.plot.controller.dasPlot

from org.das2.graph import Renderer
from math import cos, sin
from java.awt.geom import Line2D
class MyRenderer( Renderer ):
    def render( self, g, xAxis, yAxis, mon=None ):
         g.setColor( Color.GRAY )
         orx= xAxis.transform( Units.dimensionless.createDatum( 0.0 ) )
         ory= yAxis.transform( Units.dimensionless.createDatum( 0.0 ) )
         for i in xrange( 0, 12 ):
              radx= xAxis.transform( Units.dimensionless.createDatum( 100 * cos( i*30.*PI/180 ) ) )
              rady= yAxis.transform( Units.dimensionless.createDatum( 100 * sin( i*30.*PI/180 ) ) )
              g.draw( Line2D.Double( orx, ory, radx, rady ) )
   
myRend= MyRenderer()

theplot.removeRenderer( theplot.getRenderer(0) )
theplot.addRenderer( myRend )

from org.das2.qds.ops.Ops import cos as dscos
from org.das2.qds.ops.Ops import sin as dssin

angle= linspace( 0, 360, 360 ) * PI / 180
radius= dscos( angle*5 )
plot( radius * dscos( angle ) , radius * dssin(angle) )
