Subsections

3.18 JaPlot class

For complicated tasks which involve a lot of drawings, one should use the JaPlot canvas, which is rather similar to the HPlot class but it has many advanced features:

This class is based on the JaxoDraw package by [] which was originally designed to draw Feynman diagrams. At the original JaxoDraw, the JaPlot canvas has a complete graphical user interface that allows to carry out all actions in a mouse click-and-drag fashion. In addition, the package was significantly modified by adding the possibility to draw the standard jHepWork objects (H1D, P1D, H2D, F1D).

Build a JaPlot canvas, use the following script:

>>> from jhplot import JaPlot
>>> c1=JaPlot("Canvas")
>>> c1=visible()

The syntax associated with the JaPlot is rather similar to the HPlot ones. Look at the example scripts which start with the name "japlot" in the example directory. The largest difference from the HPlot is that there are many methods related to drawing axes which cannot be called directly, but via the method getPad(), i.e.

>>> from java.awt import Color 
>>> from jhplot import JaPlot
>>> c1=JaPlot("Canvas",1,2)
>>> c1=visible()
>>> c1.cd(1,2)
>>> pad=c1.getPad()             # get current pad
>>> pad.setRange(0,0,1)         # set axis range [0,1] on X 
>>> pad.setFillColor(Color.red) # set new pad color
>>> pad. + [F4]                 # check other methods associated with pad.

In addition, one can show object editor which can be used to move, resize etc. different pads.


3.18.1 Drawing Feynman diagrams

One JaPlot is called, one can draw Feynman diagrams using JaxoDraw mouse click-and-drag fashion (you have to start the Editor from the Option menu). One can also draw Feynman diagrams programmically using Java or Jython using static methods of the Diagram class. Look at the example in japlot_feynman.py. This is a typical example:

>>> from jhplot import JaPlot
>>> from jhplot.jadraw import Diagram
>>> c1=JaPlot("Canvas",800,600,1,1,0) # create JaPlot but do not show any axis 
>>> c1.setGTitle("Feynman Diagram objects", Color.blue)
>>> c1.visible()
>>> c1.showEditor(1)
>>> 
>>> gl=Diagram.GlLine(0.3,0.8) # create a gluon line using the NDC coordinates  
>>> gl.setRelWH(0.1,0.0,"NDC") # object size using the NDC coordinates 
>>> c1.add(gl)
>>>
>>> gl=Diagram.GlLoop(0.3,0.9)  # create a gluon loop in the NDC coordinates 
>>> gl.setRelWH(0.05,0.0,"NDC")  object size using the NDC coordinates  
>>> c1.add(gl)
>>>
>>> c1.update() # update and show all

It should be noted the way how JaPlot canvas is created: in this case no axes are shown (last argument is 0i, i.e. false in Java syntax). Also, always call update() method to draw the objects.

3.18.2 SJaPlot class

Similar to SHPlot, one can create a singleton representing the JaPlot canvas object using the static class SJaPlot. In this case, every execution of the scripts in the jHepWork IDE does not create a new object of the canvas, but it just redraws it. This is an example of how to create such canvas:

>>> from jhplot import SJaPlot
>>> c1=SJaPlot.getCanvas()
>>> c1.setGTitle("Global title");
>>> c1.setNameX("Xaxis")
>>> c1.setNameY("Yaxis")
>>> c1.visible(1)
>>> ....

All methods of JaPlot are also applicable to the SJaPlot class.