<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Consider the following ooRexx program that exploits the JRE (the
Java classes available via the Java runtime environment, installed
by OpenJDK) for Java2D:</p>
<blockquote>
jdor=.bsf~new("org.oorexx.handlers.jdor.JavaDrawingHandler") --
create a JDOR handler<br>
call BsfCommandHandler "add", "JDOR", jdor -- add the JDOR
handler to ooRexx<br>
address JDOR -- set default environment to the JDOR
command handler<br>
-- now we may use JDOR commands, executed by default by
the JDOR command handler<br>
width =220 -- define width of image in pixels
(there are 72 px to an inch)<br>
height=250 -- define height of image in pixels
(there are 72 px to an inch)<br>
newImage width height -- create new bitmap with currX=0,
currY=0, width=220, height=250<br>
winShow -- show frame on screen<br>
-- draw two lines forming a big X<br>
drawLine (width-1) (height-1) -- from currX=0, currY=0<br>
color red -- set the color to red (preregistered
with nickname "RED")<br>
moveTo (width-1) 0 -- currX=219, currY=0<br>
position -- query current position<br>
say "--> rc="pp(rc) -- RC refers to the previous
command's result: "219 0" (currX=219, currY=0)<br>
drawLine 0 (height-1) -- from currX=219, currY=0<br>
-- draw a rectangle at the center of the bitmap<br>
len = 50 -- drawing a rectangle with each side
being 50 px (a square)<br>
moveTo (width-len)/2 (height-len)/2 -- go to the center minus
half of the square's side lengths<br>
color green -- set color to green (preregistered
with nickname "GREEN")<br>
fillRect len len -- fill the square with the green
color<br>
stroke str3 3 -- set line stroke to 3 points width,
store it with nickname "STR3"<br>
color blue -- set color to blue (preregistered
with nickname "BLUE")<br>
drawRect len len -- draw the frame with the blue color<br>
-- draw a string (text) at the lower half of the bitmap<br>
color somePurple 127 46 111 -- define a custom RGB color,
store it with nickname "SOMEPURPLE"<br>
color -- query current color<br>
say "--> rc="pp(rc) -- show result from command (a Java
color object)<br>
say " rc~toString:" pp(rc~toString) -- shows the RGB
intensities of the current color<br>
-- draw three lines of centered strings at the bottom<br>
lineHeight = 15 -- default font size is 12px, add 3 px
lead<br>
newY=height-40 -- draw the three strings at the
bottom<br>
clrs=("somePurple", "blue", "gray") -- define three different
colors<br>
text=("Hello, Rexx world ...", "... from JDOR ...", "(a Rexx
command handler)") -- array of 3 strings<br>
do counter c i=0 to 30 by lineHeight -- iterate over array
of strings<br>
s=text[c] -- fetch the string to draw from array<br>
stringBounds s -- get the bounding box dimensions for
this string<br>
parse var rc . . w . -- parse the width of the string's
bounding box<br>
moveTo (width-w)/2 (newY+i) -- calc x position to center
this string, set y position<br>
color clrs[c] -- fetch and use the color from the
array<br>
drawString s -- draw the string<br>
end<br>
-- save the current image<br>
saveImage "jdor_doc_sample.png" -- save image to file
"jdor_doc_sample.png"<br>
sleep 3.123 -- sleep for 3.123 seconds<br>
<br>
::requires "BSF.CLS" -- get ooRexx-Java bridge, contains
JDOR Rexx command handler<br>
</blockquote>
<p>To see its output in the command line window and the produced
graphic cf.
<a class="moz-txt-link-rfc2396E" href="https://wi.wu.ac.at/rgf/rexx/misc/jdor_doc.tmp/jdor_doc.html"><https://wi.wu.ac.at/rgf/rexx/misc/jdor_doc.tmp/jdor_doc.html></a>.
That is also at the same time (a temporary) location of the JDOR
(Java2D for ooRexx) documentation.</p>
<p>---</p>
<p>This program runs on all versions of Java/OpenJDK unchanged.</p>
<p>With your currently intended warning all of a sudden all users of
such programs/applications get frightened for no good reason!</p>
<p>---rony<br>
</p>
<p><br>
</p>
<p></p>
<p><br>
</p>
<p><br>
</p>
<p><br>
</p>
</body>
</html>