Using jHepWork canvases, one can draw lines, arrows, ovals, interactive labels. One can use the same canvas as for plotting data and functions.
For example, use the canvas HPlot. One can add objects using the method “add” and the call “update()” method to draw all objects at once:
from jhplot import * from jhplot.shapes import * c1=HPlot("Canvas") c1.setGTitle("HShape package") c1.setLegend(0) c1.setRange(-4.0,4.0,0.0,20.0) c1.visible() arr=Arrow(0.85,0.5,0.85,0.7) arr.setColor(Color.blue) arr.setPosCoord("NDC") c1.add(arr) lab=HLabel("Interactive label",-2,10); c1.add(lab) c1.update()
Let us show how to draw interactive diagrams using the class HPlotJa. This class also can be used to show data, histograms and functions, but it is better suited for interactive diagram drawing.
We will show below how to draw Feynman diagrams:
from java.awt import * from jhplot import * from jhplot.jadraw import Diagram c1=HPlotJa("Canvas",1000,750,1,1,0) c1.setGTitle("Feynman Diagram objects", Color.blue) c1.visible() c1.showEditor(1) # show diagram editor gl=Diagram.Box(0.05,0.1) # box gl.setRelWH(0.05,0.05,"NDC") c1.add(gl) gl=Diagram.Blob(0.05,0.2) # blob gl.setRelWH(0.01,0.01,"NDC") c1.add(gl) gl=Diagram.Vertex(0, 0.05,0.3) # a vertex gl.setRelWH(0.01,0.01,"NDC") c1.add(gl) gl=Diagram.GLine(0.6,0.7) # gluon line gl.setRelWH(0.1,0.2,"NDC") c1.add(gl) c1.update()
Read the book "Scientific data analysis using Jython scripting and Java for more details.
— Sergei Chekanov 2010/03/07 16:37