BasicStroke assitance

Still trying to learn…
I have read and re-read the Class java.awt.BasicStroke information and am still not getting it…

    from org.jfree.chart.plot import ValueMarker
from java.awt import BasicStroke
marker=ValueMarker(850,system.gui.color(217,0,0),BasicStroke(3))
chart.getPlot().addRangeMarker(marker)

This code works, I am trying make the line dashed…not really understanding I tried BasicStroke(3,1,1,1,1,1) to maybe use the defaults?!? It is getting hung up trying to coerce the 5th arg (the dash array?!?) into a float…can someone give me an example of what it wants for the float array for the dashes? This is the part I dont understand…I tried importing and using getFloatArray() but it didnt like that either…

Thanks in advance

Something like this:

import jarray
from java.awt import BasicStroke

dashes = jarray.array([6, 2], 'f')
s = BasicStroke(3.0, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0, dashes, 0.0)

Thank You! This is just what I needed!

You can even skip the jarray import - Jython will automagically turn your python list into a relevant Java type:

	s = BasicStroke(
		3.0, #width
		BasicStroke.CAP_ROUND, #cap 
		BasicStroke.JOIN_ROUND, #join
		1.0, #miterLimit
		[2, 4, 8, 16, 32], #dash pattern
		0.0) #dash_phase_offset
	
	m = ValueMarker(75, system.gui.color(200, 0, 0), s)
	chart.getPlot().addRangeMarker(m)
2 Likes

Usually. /-: I forget the traps, so I tend be pedantic.

2 Likes

Thank you both…this helps immensely because I jumped into Igniton from my PLC, VB and C background with limited knowledge of JAVA…not ideal but it is where I am!

That is a relatively rare and valuable combination. I suspect Java and Jython will come easily.