You can subscribe to this list here.
2011 |
Jan
|
Feb
|
Mar
|
Apr
(12) |
May
(7) |
Jun
(4) |
Jul
(1) |
Aug
(22) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2012 |
Jan
|
Feb
(21) |
Mar
(9) |
Apr
(8) |
May
(5) |
Jun
(11) |
Jul
(7) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(4) |
Dec
(1) |
2013 |
Jan
(15) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(20) |
Jul
(6) |
Aug
(4) |
Sep
(4) |
Oct
(5) |
Nov
|
Dec
(2) |
2014 |
Jan
(2) |
Feb
(1) |
Mar
(7) |
Apr
(11) |
May
(14) |
Jun
(4) |
Jul
(13) |
Aug
(7) |
Sep
(10) |
Oct
(19) |
Nov
(3) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
(15) |
May
(12) |
Jun
(16) |
Jul
(12) |
Aug
(15) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
(1) |
Mar
(3) |
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
(28) |
Sep
(1) |
Oct
(4) |
Nov
(31) |
Dec
(21) |
2017 |
Jan
(31) |
Feb
(3) |
Mar
(3) |
Apr
(14) |
May
|
Jun
(3) |
Jul
|
Aug
(18) |
Sep
(5) |
Oct
(8) |
Nov
(9) |
Dec
(8) |
2018 |
Jan
(17) |
Feb
(3) |
Mar
(16) |
Apr
|
May
|
Jun
(1) |
Jul
(15) |
Aug
(1) |
Sep
(8) |
Oct
(8) |
Nov
(13) |
Dec
(4) |
2019 |
Jan
(4) |
Feb
(6) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(15) |
Sep
(1) |
Oct
|
Nov
(3) |
Dec
(8) |
2020 |
Jan
(3) |
Feb
(3) |
Mar
(1) |
Apr
(9) |
May
(21) |
Jun
(6) |
Jul
(21) |
Aug
(14) |
Sep
(3) |
Oct
(8) |
Nov
(5) |
Dec
(7) |
2021 |
Jan
(3) |
Feb
(12) |
Mar
(6) |
Apr
(1) |
May
(2) |
Jun
(7) |
Jul
(21) |
Aug
(26) |
Sep
(10) |
Oct
(4) |
Nov
(3) |
Dec
(4) |
2022 |
Jan
(15) |
Feb
(3) |
Mar
|
Apr
(4) |
May
|
Jun
(5) |
Jul
(12) |
Aug
(64) |
Sep
(14) |
Oct
(19) |
Nov
(13) |
Dec
(6) |
2023 |
Jan
(1) |
Feb
(6) |
Mar
(3) |
Apr
(4) |
May
(3) |
Jun
(21) |
Jul
(5) |
Aug
(1) |
Sep
(1) |
Oct
(3) |
Nov
(2) |
Dec
|
2024 |
Jan
(11) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <or...@us...> - 2022-11-03 12:51:41
|
Revision: 1020 http://sourceforge.net/p/bsf4oorexx/code/1020 Author: orexx Date: 2022-11-03 12:51:37 +0000 (Thu, 03 Nov 2022) Log Message: ----------- 20221103 Allow all nicknames to fall back to Rexx variable names. Modified Paths: -------------- sandbox/rgf/jdor/JavaDrawingHandler.java sandbox/rgf/jdor/doc/jdor_doc.html Modified: sandbox/rgf/jdor/JavaDrawingHandler.java =================================================================== --- sandbox/rgf/jdor/JavaDrawingHandler.java 2022-11-02 17:19:51 UTC (rev 1019) +++ sandbox/rgf/jdor/JavaDrawingHandler.java 2022-11-03 12:51:37 UTC (rev 1020) @@ -10,7 +10,7 @@ author: Rony G. Flatscher date: 2022-09-05/2022-10-05 - version: 100.20221102 + version: 100.20221103 license: Apache license 2.0 license: @@ -92,6 +92,9 @@ - added new 'render' command to query or change the settings; note: if animating text (using drawString) it may be necessary to turn off text antialiasing to inhibit a trail/shmear, cf. 3-110_JDOR_animate_composite.rxj as an example + 2022-11-03: - the following commands now also take a Rexx variable named by the supplied + nick name, if not found in the registries: BACKGROUND, COLOR, FONT, GRADIENT_PAINT, + IMAGE_SIZE, IMAGE_TYPE, PAINT, SET_XOR_MODE, STROKE */ /* Sample program in ooRexx (temporarily): @@ -281,7 +284,7 @@ /* static definitions */ // default image sizes - static final public String version = "100.20221102"; + static final public String version = "100.20221103"; static final private int prefWidth = 500; static final private int prefHeight = 500; static private int prefImageType = BufferedImage.TYPE_INT_ARGB; // default with alpha (only png supported) @@ -684,14 +687,17 @@ newX = string2int(arrCommand[1]); newY = string2int(arrCommand[2]); jd.setLocation(newX, newY); - if (bUseInt4numbers) + if (isOR) { - canonical = canonical+" "+newX+" "+newY; + if (bUseInt4numbers) + { + canonical = canonical+" "+newX+" "+newY; + } + else + { + canonical = canonical+" "+arrCommand[1]+" "+arrCommand[2]; + } } - else - { - canonical = canonical+" "+arrCommand[1]+" "+arrCommand[2]; - } } if (isOR) @@ -762,7 +768,10 @@ throw new IllegalArgumentException("the supplied \"frameVisible\" argument \""+newValue+"\" is not a valid BSF4ooRexx850 boolean value, valid values (in any case) are: " + "\"0\", \"1\", \"false\", \"true\", \".false\", \".true\""); } - canonical=canonical+" "+newValue; + if (isOR) + { + canonical=canonical+" "+newValue; + } jd.setAlwaysOnTop(retBoolValue); // set value } break; @@ -1085,7 +1094,10 @@ if (arrCommand.length>1) { double tmpScaleX = Double.parseDouble(arrCommand[1]); - canonical = canonical + " " + arrCommand[1]; + if (isOR) + { + canonical = canonical + " " + arrCommand[1]; + } if (arrCommand.length==2) // { @@ -1096,7 +1108,10 @@ { printScaleY = Double.parseDouble(arrCommand[2]); printScaleX = tmpScaleX; - canonical = canonical + " " + arrCommand[2]; + if (isOR) + { + canonical = canonical + " " + arrCommand[2]; + } } } if (isOR) @@ -1103,8 +1118,6 @@ { writeOutput(slot,canonical); } - - //return printScaleX+" "+printScaleY; return resultValue; } @@ -1170,11 +1183,14 @@ catch (Throwable t) {} if (tmpImage==null) { - throw new IllegalArgumentException("image (must be a BufferedImage) with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\" or \"pushImage "+name+"\" or assign an BufferedImage to a Rexx variable named \""+name+"\""); + throw new IllegalArgumentException("image (must be a BufferedImage) with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\" or \"pushImage "+name+"\" or assign a BufferedImage to a Rexx variable named \""+name+"\""); } } - canonical = canonical+" "+name; + if (isOR) + { + canonical = canonical+" "+name; + } } if (isOR) { @@ -1423,7 +1439,15 @@ BufferedImage img = hmImages.get(name.toUpperCase()); if (img==null) { - throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\""); + try + { + img = (BufferedImage) getContextVariable(slot, name); // try to get from a Rexx variable + } + catch (Throwable t) {} + if (img==null) + { + throw new IllegalArgumentException("image (must be a BufferedImage) with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\" or \"pushImage "+name+"\" or assign a BufferedImage to a Rexx variable named \""+name+"\""); + } } if (isOR) @@ -1453,7 +1477,7 @@ catch (Throwable t) {} if (tmpImage==null) { - throw new IllegalArgumentException("image (must be a BufferedImage) with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\" or \"pushImage "+name+"\" or assign an BufferedImage to a Rexx variable named \""+name+"\""); + throw new IllegalArgumentException("image (must be a BufferedImage) with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\" or \"pushImage "+name+"\" or assign a BufferedImage to a Rexx variable named \""+name+"\""); } } if (isOR) @@ -1482,7 +1506,20 @@ tmpImg = hmImages.get(name.toUpperCase()); if (tmpImg==null) { - throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\""); + try // try to get from a Rexx variable + { + tmpImg = (BufferedImage) getContextVariable(slot, name); + } + catch (Throwable t) {} + if (tmpImg==null) + { + String errMsg="image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\" or supply a Rexx variable referring to a BufferedImage"; + if (isOR) + { + writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); + } + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-2", errMsg ); + } } if (isOR) { @@ -1597,12 +1634,20 @@ color = hmColors.get(colorNickName.toUpperCase()); if (color==null) { - String errMsg="color with the supplied nickname \""+colorNickName+"\" is not registered"; - if (isOR) + try // try to get from a Rexx variable { - writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); + color = (Color) getContextVariable(slot, colorNickName); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-2", errMsg ); + catch (Throwable t) {} + if (color==null) + { + String errMsg="color with the supplied nickname \""+colorNickName+"\" is not registered nor is it a Rexx variable referring to a color"; + if (isOR) + { + writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); + } + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-3", errMsg ); + } } if (isOR) { @@ -1711,12 +1756,20 @@ gradientPaint = hmGradientPaints.get(paintNickName.toUpperCase()); if (gradientPaint==null) { - String errMsg="gradientPaint with the supplied nickname \""+paintNickName+"\" is not registered"; - if (isOR) + try // try to get from a Rexx variable { - writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); + gradientPaint = (GradientPaint) getContextVariable(slot, paintNickName); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-3", errMsg ); + catch (Throwable t) {} + if (gradientPaint==null) + { + String errMsg="gradientPaint with the supplied nickname \""+paintNickName+"\" is not registered nor is it a Rexx variable referring to a GradientPaint object"; + if (isOR) + { + writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); + } + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-4", errMsg ); + } } if (isOR) { @@ -1723,7 +1776,6 @@ writeOutput(slot, canonical); } bufGC.setPaint(gradientPaint); - // return gradientPaint; return resultValue; } @@ -1741,7 +1793,7 @@ { writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-4", errMsg ); + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-5", errMsg ); } x2 = Float.parseFloat(arrCommand[5]); @@ -1755,7 +1807,7 @@ { writeOutput(slot, "-- ERROR (nickname2 argument): ["+command+"]"); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-5", errMsg ); + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-6", errMsg ); } if (isOR) { @@ -1828,21 +1880,29 @@ if (arrCommand.length==2) { String nickName = arrCommand[1]; // get color name - canonical=canonical+" "+nickName; + if (isOR) + { + canonical=canonical+" "+nickName; + } Paint paint=null; paint=hmGradientPaints.get(nickName.toUpperCase()); // first consult gradientPaints if (paint==null) // now try the registered colors { paint=hmColors.get(nickName.toUpperCase()); + try // try to get from a Rexx variable + { + paint = (Paint) getContextVariable(slot, nickName); + } + catch (Throwable t) {} } if (paint==null) // neither found { - String errMsg="neither paint nor gradientPaint with the supplied nickname \""+nickName+"\" is registered"; + String errMsg="neither paint nor gradientPaint with the supplied nickname \""+nickName+"\" is registered nor supplied with a Rexx variable of that name"; if (isOR) { writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-6", errMsg ); + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-7", errMsg ); } if (isOR) { @@ -1870,16 +1930,27 @@ if (arrCommand.length==2) { String colorNickName = arrCommand[1]; // get color name - canonical=canonical+" "+colorNickName; + if (isOR) + { + canonical=canonical+" "+colorNickName; + } Color color=hmColors.get(colorNickName.toUpperCase()); if (color==null) { - String errMsg="color with the supplied nickname \""+colorNickName+"\" is not registered"; - if (isOR) + try // try to get from a Rexx variable { - writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); + color = (Color) getContextVariable(slot, colorNickName); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-7", errMsg ); + catch (Throwable t) {} + if (color==null) + { + String errMsg="color with the supplied nickname \""+colorNickName+"\" is not registered nor is it a Rexx variable referring to a color"; + if (isOR) + { + writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); + } + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-8", errMsg ); + } } if (isOR) { @@ -1899,16 +1970,28 @@ throw new IllegalArgumentException("this command needs exactly 1 argument, received "+(arrCommand.length-1)+" instead"); } String colorNickName = arrCommand[1]; // get color name - canonical=canonical+" "+colorNickName; + if (isOR) + { + canonical=canonical+" "+colorNickName; + } Color color=hmColors.get(colorNickName.toUpperCase()); if (color==null) { - String errMsg="color with the supplied nickname \""+colorNickName+"\" is not registered"; - if (isOR) + try // try to get from a Rexx variable { - writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); + color = (Color) getContextVariable(slot, colorNickName); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-8", errMsg ); + catch (Throwable t) {} + + if (color==null) + { + String errMsg="color with the supplied nickname \""+colorNickName+"\" is not registered nor supplied via a Rexx variable of that name"; + if (isOR) + { + writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); + } + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-9", errMsg ); + } } if (isOR) { @@ -2105,16 +2188,18 @@ int newHeight = string2int(arrCommand[4]); resultValue = newX+" "+newY+" "+newWidth+" "+newHeight; - if (bUseInt4numbers) + if (isOR) { - canonical = canonical+" "+resultValue; + if (bUseInt4numbers) + { + canonical = canonical+" "+resultValue; + } + else + { + canonical = canonical+" "+arrCommand[1] + " " + arrCommand[2] + + " "+arrCommand[3] + " " + arrCommand[4] ; + } } - else - { - canonical = canonical+" "+arrCommand[1] + " " + arrCommand[2] + - " "+arrCommand[3] + " " + arrCommand[4] ; - } - bufGC.clipRect(newX, newY, newWidth, newHeight); } // no exception, so args o.k. @@ -2211,12 +2296,21 @@ stroke = hmStrokes.get(strokeNickName.toUpperCase()); if (stroke==null) { - String errMsg="stroke with the supplied nickname \""+strokeNickName+"\" is not registered"; - if (isOR) + try // try to get from a Rexx variable { - writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); + stroke = (Stroke) getContextVariable(slot, strokeNickName); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-9", errMsg ); + catch (Throwable t) {} + + if (stroke==null) + { + String errMsg="stroke with the supplied nickname \""+strokeNickName+"\" is not registered nor is it a Rexx variable referring to a stroke"; + if (isOR) + { + writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); + } + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-10", errMsg ); + } } if (isOR) { @@ -2453,15 +2547,22 @@ font = hmFonts.get(fontNickName.toUpperCase()); if (font==null) { - String errMsg="font with the supplied nickname \""+fontNickName+"\" is not registered"; - if (isOR) + try // try to get from a Rexx variable { - writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); + font = (Font) getContextVariable(slot, fontNickName); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-10", errMsg ); + catch (Throwable t) {} + if (font==null) + { + String errMsg="font with the supplied nickname \""+fontNickName+"\" is not registered nor is it a Rexx variable referring to a font"; + if (isOR) + { + writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); + } + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-11", errMsg ); + } } - bufGC.setFont(font); if (isOR) { @@ -2486,10 +2587,18 @@ { writeOutput(slot, "-- ERROR (fontname argument): ["+command+"]"); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-11", errMsg ); + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-12", errMsg ); } + else // adjust currFontStyle and currFontSize + { + currFontStyle=font.getStyle(); + currFontSize =font.getSize(); + } } - canonical = canonical + " " + fontName; + if (isOR) + { + canonical = canonical + " " + fontName; + } hmFonts.put(fontNickName.toUpperCase(),font); bufGC.setFont(font); if (isOR) @@ -2682,16 +2791,20 @@ int height = string2int(arrCommand[2]); int dx = string2int(arrCommand[3]); int dy = string2int(arrCommand[4]); - canonical = canonical+" "+width+" "+height+" "+dx+" "+dy; - if (bUseInt4numbers) + + if (isOR) { canonical = canonical+" "+width+" "+height+" "+dx+" "+dy; + if (bUseInt4numbers) + { + canonical = canonical+" "+width+" "+height+" "+dx+" "+dy; + } + else + { + canonical = canonical+" "+arrCommand[1]+" "+arrCommand[2]+ + " "+arrCommand[3]+" "+arrCommand[4]; + } } - else - { - canonical = canonical+" "+arrCommand[1]+" "+arrCommand[2]+ - " "+arrCommand[3]+" "+arrCommand[4]; - } bufGC.copyArea(currX, currY, width, height, dx, dy); @@ -2719,14 +2832,17 @@ } int width = string2int(arrCommand[1]); int height = string2int(arrCommand[2]); - if (bUseInt4numbers) + if (isOR) { - canonical = canonical+" "+width+" "+height; + if (bUseInt4numbers) + { + canonical = canonical+" "+width+" "+height; + } + else + { + canonical = canonical+" "+arrCommand[1]+" "+arrCommand[2]; + } } - else - { - canonical = canonical+" "+arrCommand[1]+" "+arrCommand[2]; - } int arcWidth=-1, arcHeight=-1; if (isRoundRect) @@ -2733,14 +2849,17 @@ { arcWidth = string2int(arrCommand[3]); arcHeight = string2int(arrCommand[4]); - if (bUseInt4numbers) + if (isOR) { - canonical = canonical+" "+arcWidth+" "+arcHeight; + if (bUseInt4numbers) + { + canonical = canonical+" "+arcWidth+" "+arcHeight; + } + else + { + canonical = canonical+" "+arrCommand[3]+" "+arrCommand[4]; + } } - else - { - canonical = canonical+" "+arrCommand[3]+" "+arrCommand[4]; - } } // no exception, so args o.k. switch (cmd) @@ -2868,7 +2987,6 @@ { writeOutput(slot, canonical+" "+nickName+" "+fileName); } - // return img; return img.getWidth()+" "+img.getHeight(); } @@ -2977,15 +3095,17 @@ { int x = string2int(arrCommand[2]); int y = string2int(arrCommand[3]); - if (bUseInt4numbers) + if (isOR) { - canonical = canonical+" "+x+" "+y; + if (bUseInt4numbers) + { + canonical = canonical+" "+x+" "+y; + } + else + { + canonical = canonical+" "+arrCommand[2]+" "+arrCommand[3]; + } } - else - { - canonical = canonical+" "+arrCommand[2]+" "+arrCommand[3]; - } - bufGC.rotate(radiansTheta, x, y); } } @@ -3058,7 +3178,7 @@ { writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-12", errMsg ); + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-13", errMsg ); } } switch (argNum) @@ -3106,18 +3226,15 @@ else if (argNum>5) { // canonical=canonical+" "+srcX1+" "+srcY1+" "+srcX2+" "+srcY2; - if (isOR) + if (bUseInt4numbers) { - if (bUseInt4numbers) - { - canonical = canonical+" "+srcX1+" "+srcY1+" "+srcX2+" "+srcY2; - } - else - { - canonical = canonical+" "+arrCommand[4]+" "+arrCommand[5]+ - arrCommand[6]+" "+arrCommand[7]; - } + canonical = canonical+" "+srcX1+" "+srcY1+" "+srcX2+" "+srcY2; } + else + { + canonical = canonical+" "+arrCommand[4]+" "+arrCommand[5]+ + arrCommand[6]+" "+arrCommand[7]; + } if (argNum==9) // bkgColor { @@ -3289,7 +3406,6 @@ { writeOutput(slot, canonical); } - // return tmpG2D; } else // POP_GC { @@ -3305,7 +3421,7 @@ { writeOutput(slot, "-- ERROR (stack empty): ["+command+"]"); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-13", errMsg ); + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-14", errMsg ); } bufGC.dispose(); // dispose current GC bufGC=d2d; // replace with previous GC @@ -3313,7 +3429,6 @@ { writeOutput(slot, canonical); } - // return bufGC; resultValue=bufGC; // old one is disposed, so cannot use that anymore } return resultValue; @@ -3347,7 +3462,6 @@ writeOutput(slot, canonical); } return img; // return pushed (copy) image - // return resultValue; } else // POP_IMAGE: the returned image should be used to draw via current GC { @@ -3363,7 +3477,7 @@ { writeOutput(slot, "-- ERROR (empty stack): ["+command+"]"); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-14", errMsg ); + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-15", errMsg ); } // bufGC.clearRect(0,0,bufImage.getWidth(),bufImage.getHeight()); // clear rectangle @@ -3383,7 +3497,7 @@ { writeOutput(slot, "-- FAILURE (unimplemented command): ["+command+"]"); } - return createCondition (slot, nrCommand, command, ConditionType.FAILURE, "-17", "unimplemented command"); + return createCondition (slot, nrCommand, command, ConditionType.FAILURE, "-16", "unimplemented command"); } } catch (Throwable t) // raise error condition if args etc. were causing exceptions @@ -3392,7 +3506,7 @@ { writeOutput(slot, "-- ERROR (argument): ["+command+"]"); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-16", t.toString() ); + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-17", t.toString() ); } // draws/changes have occurred, redraw if we have a JavaDrawingFrame instance to show to user @@ -3839,21 +3953,21 @@ // define the enum values for the commands available to Rexx programs, // supplying the strings associated with them // ? synonyms too + // 20220929: do not support Shapes, maybe in a future update; one can always + // get access using "gc" command and interact with it from ooRexx directly + // java.awt.Graphics or java.awt.Graphics2D related + BACKGROUND ( "background" ) , // "background [colorNickName]" query current background color or set CLEAR_RECT ( "clearRect" ) , // "clear width height": uses current color to clear background + CLIP ( "clip" ) , // "clip [x y w h]" -> get (getClipBounds()) or clipRect(x y w h) + CLIP_REMOVE ( "clipRemove" ) , // "clipRemove" -> setClip(null) COLOR ( "color" ) , // "color [colorNickName [r g b [a]]" query current color or set + define new color COMPOSITE ( "composite" ) , // "composite [rule [alpha]]": get current or get and set new; - -// 20220929: do not (yet) support Shapes, maybe in a future update - - CLIP_REMOVE ( "clipRemove" ) , // "clipRemove" -> setClip(null) - CLIP ( "clip" ) , // "clip [x y w h]" -> get (getClipBounds()) or clipRect(x y w h) - + COPY_AREA ( "copyArea" ) , // "copyArea width height distX distY" DRAW_3D_RECT ( "draw3DRect" ) , // "draw3DRect width height raised" - 20220906 DRAW_ARC ( "drawArc" ) , // "drawArc width height startAngle arcAngle" DRAW_IMAGE ( "drawImage" ) , // "drawImage nickName [bkgColor] | nickName width height [bkgColor] | nickName width height srcX1 srcY1 srcX2 srcY2 [bkgColor]" - DRAW_LINE ( "drawLine" ) , // "drawLine toX toY" DRAW_OVAL ( "drawOval" ) , // "drawOval width height" DRAW_POLYGON ( "drawPolygon" ) , // "drawPolygon []xPoints []yPoints nPoints @@ -3861,7 +3975,6 @@ DRAW_RECT ( "drawRect" ) , // "drawRect width height" DRAW_ROUND_RECT ( "drawRoundRect" ) , // "drawRoundRect width height arcWidth arcHeight" DRAW_STRING ( "drawString" ) , // "drawString text" - FILL_3D_RECT ( "fill3DRect" ) , // "fill3DRect width height raised" - 20220906 FILL_ARC ( "fillArc" ) , // "fillArc width height startAngle arcAngle" FILL_OVAL ( "fillOval" ) , // "fillOval width height" @@ -3869,71 +3982,53 @@ FILL_RECT ( "fillRect" ) , // "fillRect width height" FILL_ROUND_RECT ( "fillRoundRect" ) , // "fillRoundRect width height arcWidth arcHeight" FONT ( "font" ) , // "font [fontNickName [name]]" query or set font using curr type and size - GRADIENT_PAINT ( "gradientPaint" ) , // "gradientPaint paintNickName [x1 y1 colorName1 x2 y2 colorName2 [cyclic]]": set or define and set gradientPaint - PAINT ( "paint" ) , // "paint [gradiantPaintNickName|colorNickName]" query or set paint (for background) // 2022-09-22, paint, as of 20220922 cf. <http://underpop.online.fr/j/java/help/colors-graphics-programming.html.gz> - MOVE_TO ( "moveTo" ) , // "pos [x y]" query or set position, synonyms: "goto" - ROTATE ( "rotate" ) , // "rotate [theta [x y]]" query or set rotation - SCALE ( "scale" ) , // "scale [x [y]]" query or set scale for x, y; if y omitted, uses x - SET_PAINT_MODE ( "setPaintMode" ) , // "setPaintMode": cf. Grahpics#setPaintMode() - SHEAR ( "shear" ) , // "shear [x [y]]" query or set shear for x, y; if y omitted, uses x - SLEEP ( "sleep" ) , // "sleep msecs" (uses Thread.sleep()) - STROKE ( "stroke" ) , // "stroke [strokeNickName [width [cap join [miterlimit [[]floatDash floatDashPhase]]]]" query or set stroke - TRANSLATE ( "translate" ) , // "translate [x [y]]" query origin or move origin; if y omitted, uses x - SET_XOR_MODE ( "setXorMode" ) , // "xorMode colorNickName": sets xorMode to supplied color - - COPY_AREA ( "copyArea" ) , // "copyArea width height distX distY" - TRANSFORM ( "transform" ) , // "transform { | RESET | translateX translateY scaleX scaleY shearX shearY} " query, change reset Graphics2D's AfineTransform - - // ------------------------------ - // commands for control, maintenance logic - PREFERRED_IMAGE_TYPE ( "preferredImageType" ) , // "preferredImageType [type]": get or set preferred image type, type can be integer or name of BufferedImage TYPE constant - NEW ( "new" ) , // "new [width height [type]]" creates a new BufferedImage - RESET ( "reset" ) , // "reset" synonym: "clear", clears everything, resets - FONT_SIZE ( "fontSize" ) , // "fontSize size FONT_STYLE ( "fontStyle" ) , // "fontStyle 0=PLAIN | 1=BOLD | 2=ITALIC | 3=BOLD+ITALIC - GET_GC ( "GC" ) , // "GC" returns current GC (GraphicsContext) GET_IMAGE ( "image" ) , // "image [nickName]" returns image or nickName-stored image GET_STATE ( "getState" ) , // "getState [ctxtVariableName]" returns a StringTable with current variables, stacks and HashMaps; - + GRADIENT_PAINT ( "gradientPaint" ) , // "gradientPaint paintNickName [x1 y1 colorName1 x2 y2 colorName2 [cyclic]]": set or define and set gradientPaint + IMAGE_COPY ( "imageCopy" ) , // "imageCopy [nickName]": get a copy of the current image, if nickName supplied use from registry and if not found from Rexx variable IMAGE_SIZE ( "imageSize" ) , // "imageSize [imageNickName]": returns width and height IMAGE_TYPE ( "imageType" ) , // "imageType [nickName]": get current image's type, if nickName supplied return its image type LOAD_IMAGE ( "loadImage" ) , // "loadImage imageNickName filename", loads an image -> returns its dimension - SAVE_IMAGE ( "saveImage" ) , // "saveImage filename", saves current image to file - - // 2022-11-01 - IMAGE_COPY ( "imageCopy" ) , // "imageCopy [nickName]": get a copy of the current image, if nickName supplied use from registry and if not found from Rexx variable - STRING_BOUNDS ( "stringBounds" ) , // "stringBounds string": returns the Rectangle2D x y w h (in floats?) - - // 2022-11-02 - RENDER ( "render" ) , // "render [opt1 [opt2]]": returns or sets the current antialiasing settings for rendering - - PUSH_GC ( "pushGC" ) , // "pushGC" push current gc + MOVE_TO ( "moveTo" ) , // "pos [x y]" query or set position, synonyms: "goto" + NEW ( "new" ) , // "new [width height [type]]" creates a new BufferedImage + PAINT ( "paint" ) , // "paint [gradiantPaintNickName|colorNickName]" query or set paint (for background) // 2022-09-22, paint, as of 20220922 cf. <http://underpop.online.fr/j/java/help/colors-graphics-programming.html.gz> POP_GC ( "popGC" ) , // "popGC" pop and set previous gc - - PUSH_IMAGE ( "pushImage" ) , // "pushImage [nickName]" push current image displayed POP_IMAGE ( "popImage" ) , // "popImage" pop and display previous image - + PREFERRED_IMAGE_TYPE ( "preferredImageType" ) , // "preferredImageType [type]": get or set preferred image type, type can be integer or name of BufferedImage TYPE constant PRINT_IMAGE ( "printImage" ) , // "printImage [nickName]": print image, either current or the one by nickname PRINT_POS ( "printPos" ) , // "printPos [X Y]: get or set position of left upperhand corner; honored if printScaleToPage is false PRINT_SCALE ( "printScale" ) , // "printScale [scaleX [scaleY]": get or set scaleX (if no scaleY use scaleX); honored if printScaleToPage is false PRINT_SCALE_TO_PAGE ( "printScaleToPage" ) , // "printScaleToPage [.true|.false]": get or set - + PUSH_GC ( "pushGC" ) , // "pushGC" push current gc + PUSH_IMAGE ( "pushImage" ) , // "pushImage [nickName]" push current image displayed + RENDER ( "render" ) , // "render [opt1 [opt2]]": returns or sets the current antialiasing settings for rendering + RESET ( "reset" ) , // "reset" synonym: "clear", clears everything, resets + ROTATE ( "rotate" ) , // "rotate [theta [x y]]" query or set rotation + SAVE_IMAGE ( "saveImage" ) , // "saveImage filename", saves current image to file + SCALE ( "scale" ) , // "scale [x [y]]" query or set scale for x, y; if y omitted, uses x + SET_PAINT_MODE ( "setPaintMode" ) , // "setPaintMode": cf. Grahpics#setPaintMode() + SET_XOR_MODE ( "setXorMode" ) , // "xorMode colorNickName": sets xorMode to supplied color + SHEAR ( "shear" ) , // "shear [x [y]]" query or set shear for x, y; if y omitted, uses x + SLEEP ( "sleep" ) , // "sleep msecs" (uses Thread.sleep()) + STRING_BOUNDS ( "stringBounds" ) , // "stringBounds string": returns the Rectangle2D x y w h (in floats?) + STROKE ( "stroke" ) , // "stroke [strokeNickName [width [cap join [miterlimit [[]floatDash floatDashPhase]]]]" query or set stroke + TRANSFORM ( "transform" ) , // "transform { | RESET | translateX translateY scaleX scaleY shearX shearY} " query, change reset Graphics2D's AfineTransform + TRANSLATE ( "translate" ) , // "translate [x [y]]" query origin or move origin; if y omitted, uses x + WIN_ALWAYS_ON_TOP ( "winAlwaysOnTop" ) , // "winAlwaysOnTop [.true | .false]" get or set of this window state + WIN_ALWAYS_ON_TOP_SUPPORTED ( "winAlwaysOnTopSupported" ) , // "winAlwaysOnTopSupported" get value WIN_CLOSE ( "winClose" ) , // S "winClose" synonym: "exit" closes JavaDrawingFrame instance WIN_FRAME ( "winFrame" ) , // "winFrame [.true|.false]": query or set JFrame's frame according to argument WIN_HIDE ( "winHide" ) , // "winHide" hide JavaDrawingFrame - WIN_LOCATION ( "winLocation" ) , // (synonym: WINMOVETO)"winLocation [x y]" get or set location on screen - WIN_TO_BACK ( "winToBack" ) , // "winToBack" put window into the back - WIN_TO_FRONT ( "winToFront" ) , // "winToFront" put window into the front - WIN_ALWAYS_ON_TOP ( "winAlwaysOnTop" ) , // "winAlwaysOnTop [.true | .false]" get or set of this window state - WIN_ALWAYS_ON_TOP_SUPPORTED ( "winAlwaysOnTopSupported" ) , // "winAlwaysOnTopSupported" get value - WIN_SCREEN_SIZE ( "winScreenSize" ) , // "winScreenSize" query screen's width and size WIN_SHOW ( "winShow" ) , // "winShow" show JavaDrawingFrame WIN_SIZE ( "winSize" ) , // "winSize [width height]" query or set position WIN_TITLE ( "winTitle" ) , // "winTitle [newtitle]": get or set JFrame's title + WIN_TO_BACK ( "winToBack" ) , // "winToBack" put window into the back + WIN_TO_FRONT ( "winToFront" ) , // "winToFront" put window into the front WIN_UPDATE ( "winUpdate" ) , // "winUpdate [.true|.false]" get or set whether Frame should be updated upon draws/changes WIN_VISIBLE ( "winVisible" ) , // "winVisible [.true|.false]" get or set visibility Modified: sandbox/rgf/jdor/doc/jdor_doc.html =================================================================== --- sandbox/rgf/jdor/doc/jdor_doc.html 2022-11-02 17:19:51 UTC (rev 1019) +++ sandbox/rgf/jdor/doc/jdor_doc.html 2022-11-03 12:51:37 UTC (rev 1020) @@ -501,7 +501,7 @@ <td colspan="3"> Queries and optionally sets the background color to a registered color. <br>Querying the current value (no argument supplied) will return it, setting - (changing) the value to a new value will return the old (previously set) value + (changing) the value to a new color value will return the old (previously set) value via the Rexx variable <em>RC</em>. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the @@ -510,8 +510,9 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> colorNickName - <td> The name of a registered color (cf. <em><a href="#cmdColor">color</a></em> command) to - which the background color should be set to. + <td> The name of a registered color (cf. <em><a href="#cmdColor">color</a></em> command) + or the name of a Rexx variable referring to a color + to which the background color should be set to. <!-- -------------------------------------------------------- --> @@ -569,12 +570,14 @@ via the Rexx variable <em>RC</em>. <br>Supplying only the <em>colorNickName</em> argument will load the color from the - internal register and assign it to the <a href="#cmdGC"><em>GC</em></a> to + internal register + or from a Rexx variable by that name referring to a color + and assign it to the <a href="#cmdGC"><em>GC</em></a> to be used for drawing from now on. <br>Supplying in addition <em>intensity</em> (cf. <a href="#dtRGB"><em>RGB color</em></a> or <a href="#dtRGBA"><em>RGBA color</em></a>) - for the colors <em>red</em>, <em>green</em>, <em>blue</em>, + for the colors <em>red</em>, <em>green</em>, <em>blue</em>, and optionally <em>alpha</em>, a <em>java.awt.Color</em> of that type gets created, registered with the supplied <em>colorNickName</em> and then used for setting the new color. @@ -586,7 +589,9 @@ <td> <td class="argument"> colorNickName <td> <em>colorNickName</em> gets uppercased and is used to look up the internal - color registry for the denoted color which should be used from now on. The + color registry for the denoted color + or the name of a Rexx variable referring to a color + which should be used from now on. The previously defined color gets gets returned via the Rexx variable <em>RC</em>. <tr class="ArgumentRowColor"><td><!-- table row --> @@ -982,7 +987,9 @@ via the Rexx variable <em>RC</em>. <br>Supplying only the <em>fontNickName</em> argument will load the font from the - internal register and use it until it gets changed again. + internal register + or from a Rexx variable of that name which refers to a font + and use it for drawing strings until it gets changed again. <br>Supplying in addition the <em>fontName</em>, a <em>java.awt.Font</em> gets loaded from the system, registered with the supplied <em>fontNickName</em> @@ -993,7 +1000,9 @@ <em>ITALIC</em>, <em>BOLD</em>, <em>BOLDITALIC</em>) and/or a trailing dash or blank and size information (e.g. <em>"Arial BOLD 18"</em> or <em>"Arial-BOLD-18"</em>, <em>"Arial 18"</em> or - <em>"Arial-BOLD"</em>). + <em>"Arial-BOLD"</em>). If the font style and font size get embedded + in the font name the <em>JDOR</em> fields <em>currFontSize</em> and <em>currFontStyle</em> get updated + accordingly. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the methods <em>getFont()</em>, <em>setFont(...)</em>, as @@ -1003,7 +1012,8 @@ <td> <td class="argument"> fontNickName <td> <em>fontNickName</em> gets uppercased and is used to look up the internal - font registry for the denoted font which should be used from now on. + font registry for the denoted font which should be used from now on + or taken as the name of a Rexx variable which refers to an font. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1082,8 +1092,10 @@ following entries are available: <ul> <li><em>colors</em> (a <em>java.util.HashMap</em>) + <li><em>currAntiAliasing</em> <li><em>currFontSize</em> <li><em>currFontStyle</em> + <li><em>currTextAntiAliasing</em> <li><em>currVisible</em> <li><em>currWinUpdate</em> <li><em>currX</em> @@ -1230,13 +1242,16 @@ <em>width</em> and <em>height</em> which can be referred to via the Rexx variable <em>RC</em> upon return from this command. <br>Supplying the optional <em>imageNickName</em> argument will return the size of the image - from the internal register. + from the internal register, + or from a Rexx variable referring to an image. <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> imageNickName <td> optional <em>imageNickName</em> gets uppercased and is used to look up the internal - image registry, get its size which is returned via the Rexx variable <em>RC</em>. + image registry + or the name of a Rexx variable referring to an image, + get its size which is returned via the Rexx variable <em>RC</em>. <!-- -------------------------------------------------------- --> @@ -1246,13 +1261,15 @@ <td colspan="2"> Query the image type. With no arguments returns the current image's type which can be referred to via the Rexx variable <em>RC</em> upon return from this command. <br>Supplying the optional <em>imageNickName</em> argument will return the type of the image - from the internal register. + from the internal register, + or from a Rexx variable referring to an image. <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> imageNickName <td> optional <em>imageNickName</em> gets uppercased and is used to look up the internal - image registry, get its type which is returned via the Rexx variable <em>RC</em>. + image registry or the name of a Rexx variable referring to an image, + get its type which is returned via the Rexx variable <em>RC</em>. @@ -1314,7 +1331,9 @@ <td> <td class="argument"> nickName <td> <em>nickName</em> in uppercase will be used to look up a gradientPaint and if not found - a color in the respective internal registries in this order. + a color in the respective internal registries + or stored in a Rexx variable by that name + in this order. <!-- -------------------------------------------------------- --> @@ -1622,8 +1641,8 @@ <td> <td class="argument"> colorNickName <td> <em>colorNickName</em> gets uppercased and is used to look up the internal - color registry for the denoted color which should be used from now on for - <em>xorMode</em> processing. + color registry for the denoted color or stored in a Rexx variable + which should be used from now on for <em>xorMode</em> processing. <!-- -------------------------------------------------------- --> @@ -1707,7 +1726,8 @@ <td> <td class="argument"> strokeNickName <td> <em>strokeNickName</em> is uppercased and used to fetch the stroke from the internal stroke - registry, sets the <em>Graphics[2D]</em> object to it and returns the previous stroke via the Rexx + registry or stored in a Rexx variable, sets the <em>Graphics[2D]</em> object to it and + returns the previous stroke via the Rexx variable <em>RC</em>. <tr class="ArgumentRowColor"><td><!-- table row --> @@ -2060,7 +2080,7 @@ <center> <hr width="75%"> <small> - JDOC synopsis of commands, version: 100.20221102 + JDOC synopsis of commands, version: 100.20221103 <br>Acknowledgement: the author wishes to thank DI Walter Pachl <br>for his help in testing and proof reading </small> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <or...@us...> - 2022-11-02 17:19:54
|
Revision: 1019 http://sourceforge.net/p/bsf4oorexx/code/1019 Author: orexx Date: 2022-11-02 17:19:51 +0000 (Wed, 02 Nov 2022) Log Message: ----------- 20221102 'font' command gains decode() ability, new 'render' command. Modified Paths: -------------- sandbox/rgf/jdor/JavaDrawingHandler.java sandbox/rgf/jdor/doc/jdor_doc.html sandbox/rgf/jdor/doc/jdor_doc_sample.png sandbox/rgf/jdor/samples/2-120_JDOR_shear.rxj sandbox/rgf/jdor/samples/3-110_JDOR_animate_composite.rxj Modified: sandbox/rgf/jdor/JavaDrawingHandler.java =================================================================== --- sandbox/rgf/jdor/JavaDrawingHandler.java 2022-11-02 17:19:38 UTC (rev 1018) +++ sandbox/rgf/jdor/JavaDrawingHandler.java 2022-11-02 17:19:51 UTC (rev 1019) @@ -10,7 +10,7 @@ author: Rony G. Flatscher date: 2022-09-05/2022-10-05 - version: 100.20221101 + version: 100.20221102 license: Apache license 2.0 license: @@ -85,7 +85,13 @@ - new command "imageCopy": returns a copy of an image (maybe for buffering purposes) - new command "stringBounds": returns the Rectangle2D floats for "x y width height" for the supplied string (allows for adjusting the string) - + 2022-11-02: - when loading a font try also Font.decode(...) if a replacement font was + created; now one can append the style and size information directly after the fontname + - turned antialiasing and text antialising on (renderings will look better on + high resoulution targets) + - added new 'render' command to query or change the settings; note: if animating + text (using drawString) it may be necessary to turn off text antialiasing to + inhibit a trail/shmear, cf. 3-110_JDOR_animate_composite.rxj as an example */ /* Sample program in ooRexx (temporarily): @@ -136,7 +142,6 @@ package org.oorexx.handlers.jdor; - import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Graphics2D; @@ -154,6 +159,7 @@ import java.awt.GradientPaint; import java.awt.Paint; import java.awt.Rectangle; +import java.awt.RenderingHints; import java.awt.Stroke; import java.awt.BasicStroke; import java.awt.event.WindowAdapter; @@ -275,7 +281,7 @@ /* static definitions */ // default image sizes - static final public String version = "100.20221101"; + static final public String version = "100.20221102"; static final private int prefWidth = 500; static final private int prefHeight = 500; static private int prefImageType = BufferedImage.TYPE_INT_ARGB; // default with alpha (only png supported) @@ -297,9 +303,14 @@ static final HashMap<Integer,String> alphaCompositesInt2Name = new HashMap<>(); // FontStyle - static final HashMap<String,Integer> fontStyles = new HashMap<>(); - static final HashMap<Integer,String> fontStylesInt2Name = new HashMap<>(); + static final HashMap<String,Integer> fontStyles = new HashMap<>(); + static final HashMap<Integer,String> fontStylesInt2Name = new HashMap<>(); + // RenderingHint.Key supported for "rendering" command + static final HashMap<String,Object> renderingHints = new HashMap<>(); + static final HashMap<String,String> renderingHintsAlias = new HashMap<>(); + static final HashMap<Object,String> renderingHintsObj2Name = new HashMap<>(); + static { // ---------------------------------------------------------------------- // Color @@ -369,12 +380,28 @@ // ---------------------------------------------------------------------- // FontStyle - fontStyles.put("PLAIN" , 0); - fontStyles.put("BOLD" , 1); - fontStyles.put("ITALIC" , 2); - fontStyles.put("BOLD_ITALIC", 3); + fontStyles.put("PLAIN" , 0); + fontStyles.put("BOLD" , 1); + fontStyles.put("ITALIC" , 2); + fontStyles.put("BOLDITALIC", 3); // allow for looking up constant names (key) by value fontStyles.forEach((K,V)->fontStylesInt2Name.put(V,K)); + + // ---------------------------------------------------------------------- + renderingHints.put("ALIASON" , RenderingHints.VALUE_ANTIALIAS_ON); + renderingHints.put("ALIASOFF" , RenderingHints.VALUE_ANTIALIAS_OFF); + renderingHints.put("ALIASDEFAULT" , RenderingHints.VALUE_ANTIALIAS_DEFAULT); + renderingHints.put("TEXTALIASON" , RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + renderingHints.put("TEXTALIASOFF" , RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); + renderingHints.put("TEXTALIASDEFAULT", RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); + renderingHintsAlias.put("ALIASON" , "aliasOn" ); + renderingHintsAlias.put("ALIASOFF" , "aliasOff" ); + renderingHintsAlias.put("ALIASDEFAULT" , "aliasDefault" ); + renderingHintsAlias.put("TEXTALIASON" , "textAliasOn" ); + renderingHintsAlias.put("TEXTALIASOFF" , "textAliasOff" ); + renderingHintsAlias.put("TEXTALIASDEFAULT", "textAliasDefault" ); + // allow for looking up constant names (key) by value + renderingHints.forEach((K,V)->renderingHintsObj2Name.put(V,K)); } @@ -406,6 +433,9 @@ boolean currVisible = false; boolean currWinUpdate = true; // update Frame whenever we draw: allows turning updating on/off + // 2022-11-02: makes a difference when rendered to screen as well, so by default antialising is turned on + Object currAntiAliasing = RenderingHints.VALUE_ANTIALIAS_ON; + Object currTextAntiAliasing = RenderingHints.VALUE_TEXT_ANTIALIAS_ON; /** Stack for graphic configurations. */ ArrayDeque <Graphics2D>adGCStack = new ArrayDeque<>(); @@ -440,7 +470,7 @@ Graphics2D tGC = null; if (adGCStack.size()>0) { - tGC = adGCStack.pop(); + tGC = adGCStack.pop(); } while (tGC!=null) { @@ -552,6 +582,8 @@ bufImage = new BufferedImage(prefWidth, prefHeight, prefImageType); bufGC = (Graphics2D) bufImage.getGraphics(); bufGC.setColor(Color.BLACK); + bufGC.setRenderingHint(RenderingHints.KEY_ANTIALIASING, currAntiAliasing); + bufGC.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, currTextAntiAliasing); Font currFont = bufGC.getFont(); currFontStyle = currFont.getStyle(); currFontSize = currFont.getSize(); @@ -1318,6 +1350,9 @@ bufImage=new BufferedImage(width, height, type); // create new image bufGC=(Graphics2D) bufImage.getGraphics(); // get its GraphicsConfiguration bufGC.setColor(Color.BLACK); // make sure color is set to black + + bufGC.setRenderingHint(RenderingHints.KEY_ANTIALIASING, currAntiAliasing); + bufGC.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, currTextAntiAliasing); if (jd!=null) // update Frame if it exists { jd.bufImage=bufImage; @@ -1501,6 +1536,10 @@ rop.sendMessage2("SETENTRY", "printScaleX" , printScaleX); rop.sendMessage2("SETENTRY", "printScaleY" , printScaleY); + // current rendering options in effect + rop.sendMessage2("SETENTRY", "currAntiAliasing" , currAntiAliasing); + rop.sendMessage2("SETENTRY", "currTextAntiAliasing", currTextAntiAliasing); + // current GraphicConfiguration rop.sendMessage2("SETENTRY", "gc.background" , bufGC.getBackground()); rop.sendMessage2("SETENTRY", "gc.color" , bufGC.getColor() ); @@ -1947,6 +1986,83 @@ return resultValue; } + + case RENDER: // "render [opt1 [opt2]]": returns or sets the current antialiasing settings for rendering + { + int argNum=arrCommand.length; + if (argNum>3) + { + throw new IllegalArgumentException("this command needs either no, one or two rendering arguments, received "+(argNum-1)+" instead"); + } + + // get current settings + Object o1=bufGC.getRenderingHint(RenderingHints.KEY_ANTIALIASING); + Object o2=bufGC.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); + String s1=renderingHintsObj2Name.get(o1); + String s2=renderingHintsObj2Name.get(o2); + resultValue = s1+" "+s2; // query current value (to be returned if change occurs) + + if (argNum==1) + { + if (isOR) + { + writeOutput(slot, canonical); + } + return resultValue; + } + + String strArg = arrCommand[1].toUpperCase(); // get argument + if (!renderingHints.containsKey(strArg)) + { + throw new IllegalArgumentException("unknown value for argument # 1: \""+arrCommand[1]+"\""); + } + + if (strArg.startsWith("TEXT")) + { + currTextAntiAliasing = renderingHints.get(strArg); + bufGC.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, currTextAntiAliasing); + } + else + { + currAntiAliasing = renderingHints.get(strArg); + bufGC.setRenderingHint(RenderingHints.KEY_ANTIALIASING, currAntiAliasing); + } + if (isOR) + { + canonical=canonical+" "+renderingHintsAlias.get(strArg); + } + + if (argNum==3) + { + strArg = arrCommand[2].toUpperCase(); + if (!renderingHints.containsKey(strArg)) + { + throw new IllegalArgumentException("unknown value for argument # 1: \""+arrCommand[1]+"\""); + } + if (strArg.startsWith("TEXT")) + { + currTextAntiAliasing = renderingHints.get(strArg); + bufGC.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, currTextAntiAliasing); + } + else + { + currAntiAliasing = renderingHints.get(strArg); + bufGC.setRenderingHint(RenderingHints.KEY_ANTIALIASING, currAntiAliasing); + } + if (isOR) + { + canonical=canonical+" "+renderingHintsAlias.get(strArg); + } + } + + if (isOR) + { + writeOutput(slot, canonical); + } + return resultValue; + } + + case CLIP_REMOVE: // "removeClip" -> setClip(null) { if (arrCommand.length!=1) @@ -2357,14 +2473,21 @@ // o.k. Font name may contain blanks so use start of third word and all what remains String fontName = command.substring(alWordBoundaries.get(2)[0]); font = new Font(fontName, currFontStyle, currFontSize); - if (font==null) + // note: it may be the case that the font is not found and a replacement (Dialog.plain) gets returned + if (font==null || !font.getFontName().startsWith(fontName) ) { - String errMsg="font \""+fontName+"\" could not be loaded"; - if (isOR) + // 2022-11-02: use Font.decode(): if a registered Font with style and size encoded + // e.g. "Arial-BOLD-18", "Arial BOLD 18", "Arial-BOLD", "Arial 18", "Arial" + font = Font.decode(fontName); + if (font==null) { - writeOutput(slot, "-- ERROR (fontname argument): ["+command+"]"); + String errMsg="font \""+fontName+"\" could not be loaded"; + if (isOR) + { + writeOutput(slot, "-- ERROR (fontname argument): ["+command+"]"); + } + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-11", errMsg ); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-11", errMsg ); } canonical = canonical + " " + fontName; hmFonts.put(fontNickName.toUpperCase(),font); @@ -3783,6 +3906,9 @@ IMAGE_COPY ( "imageCopy" ) , // "imageCopy [nickName]": get a copy of the current image, if nickName supplied use from registry and if not found from Rexx variable STRING_BOUNDS ( "stringBounds" ) , // "stringBounds string": returns the Rectangle2D x y w h (in floats?) + // 2022-11-02 + RENDER ( "render" ) , // "render [opt1 [opt2]]": returns or sets the current antialiasing settings for rendering + PUSH_GC ( "pushGC" ) , // "pushGC" push current gc POP_GC ( "popGC" ) , // "popGC" pop and set previous gc Modified: sandbox/rgf/jdor/doc/jdor_doc.html =================================================================== --- sandbox/rgf/jdor/doc/jdor_doc.html 2022-11-02 17:19:38 UTC (rev 1018) +++ sandbox/rgf/jdor/doc/jdor_doc.html 2022-11-02 17:19:51 UTC (rev 1019) @@ -675,7 +675,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "drawArc" - <td colspan="2"> Draws an arc. Angles increase counterclockwise. + <td colspan="2"> Draws an arc which is part of the oval inscribed in a rectangle. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>drawArc(...)()</em>. @@ -684,7 +684,7 @@ <td class="argument"> width height startAngle arcAngle <td> <em>width</em> and <em>height</em> in pixels of the rectangle, <em>startAngle</em> in degrees (<em>0</em> is the 3 o'clock position), <em>arcAngle</em> - angular extend in degrees relative to <em>startAngle</em>. + angular extend in degrees relative to <em>startAngle</em> (angles increase counterclockwise). <!-- -------------------------------------------------------- --> @@ -883,7 +883,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "fillArc" - <td colspan="2"> Fills an arc. Angles increase counterclockwise. + <td colspan="2"> Fills an arc which is part of the oval inscribed in a rectangle. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>fillArc(...)()</em>. @@ -892,7 +892,7 @@ <td class="argument"> width height startAngle arcAngle <td> <em>width</em> and <em>height</em> in pixels of the rectangle, <em>startAngle</em> in degrees (<em>0</em> is the 3 o'clock position), <em>arcAngle</em> - angular extent in degrees relative to <em>startAngle</em>. + angular extent in degrees relative to <em>startAngle</em> (angles increase counterclockwise). @@ -983,15 +983,21 @@ <br>Supplying only the <em>fontNickName</em> argument will load the font from the internal register and use it until it gets changed again. + <br>Supplying in addition the <em>fontName</em>, a <em>java.awt.Font</em> gets loaded from the system, registered with the supplied <em>fontNickName</em> and then used for setting the new font. The font size is taken from <a href="#cmdFontSize"><em>fontSize</em></a> - and the style from <a href="#cmdFontStyle"><em>fontStyle</em></a>. + and the style from <a href="#cmdFontStyle"><em>fontStyle</em></a> unless + the font name includes a trailing dash or blank, optionally a style (one of <em>PLAIN</em>, + <em>ITALIC</em>, <em>BOLD</em>, <em>BOLDITALIC</em>) and/or a trailing dash + or blank and size information (e.g. <em>"Arial BOLD 18"</em> or + <em>"Arial-BOLD-18"</em>, <em>"Arial 18"</em> or + <em>"Arial-BOLD"</em>). <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the - methods <em>getFont()</em>, <em>setFont(...)</em>, as well as the Java class - <em>java.awt.Font</em>. + methods <em>getFont()</em>, <em>setFont(...)</em>, as + well as the Java class <em>java.awt.Font</em> and the method <em>decode(fontName)</em>. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1054,7 +1060,7 @@ new font, defaults to <em>0</em> (<em>PLAIN</em>). Additional font style values are: <em>1</em> (<em>BOLD</em>), <em>2</em> (<em>ITALIC</em>) and - <em>3</em> (<em>BOLD_ITALIC</em>). + <em>3</em> (<em>BOLDITALIC</em>). <!-- -------------------------------------------------------- --> @@ -1474,9 +1480,40 @@ in the internal image registry. + <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> + <td class="command"> "render" + <td colspan="2"> Queries and optionally allows to change general and text antialiasing + rendering hints. + + <br>Querying the current value (no argument supplied) will return it, setting + (changing) the value to a new value will return the old (previously set) value + via the Rexx variable <em>RC</em>. The blank delimited string consists of two + values, the first representing the setting of <em>RenderingHints.KEY_ANTIALIASING</em> + (controls general antialiasing, JDOR default set to <em>"aliasOn"</em>) + and the second the setting of <em>RenderingHints.KEY_TEXT_ANTIALIASING</em> + (controls text antialising, JDOR default set to <em>"textAliasOn"</em>). By default + these two keys are set to <em><code>aliasOn textAliasOn</code></em> to get the best + rendering on high resolution screens and print devices. + + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + methods <em>getRenderingHint()</em>, <em>setRenderingHint(...)</em> and the Java class + <em>java.awt.RenderingHints</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> rendering1 [rendering2] + <td> <em>rendering1</em> and optionally <em>rendering2</em> are values for either + <em>RenderingHints.KEY_ANTIALIASING</em> (one of the values <em>"aliasOn"</em>, + <em>"aliasOff"</em>, <em>"aliasDefault"</em>) or + <em>RenderingHints.KEY_TEXT_ANTIALIASING</em> (<em>"textAliasOn"</em>, + <em>"textAliasOff"</em>, <em>"textAliasDefault"</em>). + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> <td class="command" id="cmdReset"> "reset" <br> "clear" <td colspan="2"> Resets the following runtime values: <ul> @@ -1645,7 +1682,7 @@ <td class="argument"> string <td> <em>string</em> (text) for which the bounds get returned if drawn in the current font using the current graphics context. The string returned via the Rexx - variable <em>RC</em> consists of: <em>"x y width height"</em>. + variable <em>RC</em> consists of blank delimited fields: <em>"x y width height"</em>. <!-- -------------------------------------------------------- --> @@ -1670,7 +1707,7 @@ <td> <td class="argument"> strokeNickName <td> <em>strokeNickName</em> is uppercased and used to fetch the stroke from the internal stroke - registry, sets the <em>Graphics[2D]</em> object to it and returns the stroke via the Rexx + registry, sets the <em>Graphics[2D]</em> object to it and returns the previous stroke via the Rexx variable <em>RC</em>. <tr class="ArgumentRowColor"><td><!-- table row --> @@ -1677,7 +1714,7 @@ <td> <td class="argument"> strokeNickName width <td> Defines a new stroke of <em>width</em> in pixels, stores it in the internal registry - with the uppercased <em>strokeNickName</em> and returns the new stroke via the Rexx + with the uppercased <em>strokeNickName</em> and returns the previous stroke via the Rexx variable <em>RC</em>. <tr class="ArgumentRowColor"><td><!-- table row --> @@ -1685,7 +1722,7 @@ <td class="argument"> strokeNickName width cap join <td> Defines a new stroke of <em>width</em> in pixels, <em>cap</em>, <em>join</em>, stores it in the internal registry with the uppercased <em>strokeNickName</em> - and returns the new stroke via the Rexx variable <em>RC</em>. + and returns the previous stroke via the Rexx variable <em>RC</em>. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1693,7 +1730,7 @@ <td> Defines a new stroke of <em>width</em> in pixels, <em>cap</em>, <em>join</em>, <em>miterlimit</em>, stores it in the internal registry with the uppercased <em>strokeNickName</em> - and returns the new stroke via the Rexx variable <em>RC</em>. + and returns the previous stroke via the Rexx variable <em>RC</em>. <tr class="ArgumentRowColor"><td><!-- table row --> @@ -1703,7 +1740,7 @@ <em>miterlimit</em>, <a href="#dtDashArray"><em>dashArray</em></a>, <em>dashPhase</em>, stores it in the internal registry with the uppercased <em>strokeNickName</em> - and returns the new stroke via the Rexx variable <em>RC</em>. + and returns the previous stroke via the Rexx variable <em>RC</em>. <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> @@ -2023,7 +2060,7 @@ <center> <hr width="75%"> <small> - JDOC synopsis of commands, version: 100.20221101 + JDOC synopsis of commands, version: 100.20221102 <br>Acknowledgement: the author wishes to thank DI Walter Pachl <br>for his help in testing and proof reading </small> Modified: sandbox/rgf/jdor/doc/jdor_doc_sample.png =================================================================== (Binary files differ) Modified: sandbox/rgf/jdor/samples/2-120_JDOR_shear.rxj =================================================================== --- sandbox/rgf/jdor/samples/2-120_JDOR_shear.rxj 2022-11-02 17:19:38 UTC (rev 1018) +++ sandbox/rgf/jdor/samples/2-120_JDOR_shear.rxj 2022-11-02 17:19:51 UTC (rev 1019) @@ -48,7 +48,7 @@ pkgLocal=.context~package~local -- get package's local environment -- add PIXEL.PER.CM entry to it, thereafter can be retrieved via the -- environment symbol .PIXEL.PER.CM from any place in this package -pkgLocal~pixel.per.cm = 72 / 2.54 -- there are 72 dots per inch, an inch is 2.54cm -> 28.3464567 pixel per cm +pkgLocal~dpcm = 72 / 2.54 -- there are 72 dots per inch, an inch is 2.54cm -> 28.3464567 dpcm (dots per cm) new 450 350 -- create image winShow -- show image in a window (a JFrame) @@ -109,8 +109,8 @@ drawTickMarks: procedure use strict arg tickStart, tickSize=4, lineLength=54 - do i = tickStart while i < lineLength/.pixel.per.cm - tick = i * .pixel.per.cm + do i = tickStart while i < lineLength/.dpcm + tick = i * .dpcm -- x-axis moveTo tick (-tickSize) drawLine tick tickSize @@ -126,10 +126,11 @@ drawRect: procedure use strict arg x=1, y=1, w=2, h=1 -- arguments are cm values - x=x*.pixel.per.cm -- calculate pixels - y=y*.pixel.per.cm -- calculate pixels - w=w*.pixel.per.cm -- calculate pixels - h=h*.pixel.per.cm -- calculate pixels + -- calculate needed dots per cm (dpcm) + x=x*.dpcm -- calculate dots (pixels) + y=y*.dpcm -- calculate dots (pixels) + w=w*.dpcm -- calculate dots (pixels) + h=h*.dpcm -- calculate dots (pixels) moveTo x y drawRect w h return Modified: sandbox/rgf/jdor/samples/3-110_JDOR_animate_composite.rxj =================================================================== --- sandbox/rgf/jdor/samples/3-110_JDOR_animate_composite.rxj 2022-11-02 17:19:38 UTC (rev 1018) +++ sandbox/rgf/jdor/samples/3-110_JDOR_animate_composite.rxj 2022-11-02 17:19:51 UTC (rev 1019) @@ -12,6 +12,8 @@ animation effects gets positioned without a frame to the lower right hand of the screen. + Note: + Date: 2022-10-30 Author: Rony G. Flatscher, WU Vienna @@ -21,6 +23,9 @@ Changed: 2022-11-01 - use new command 'stringBounds' and calculate center for the concluding string, let that string move in from the right + 2022-11-02 - adding flashing animation for five seconds + - turn off text aliasing for animated text/string (interpolation + pixel would distort the drawn string) license: @@ -110,6 +115,7 @@ -- get bounds of string, draw it at the center, but let it move in color blue -- change color +font f2 "Serif bolditalic 19" -- for final flashing, alternate definition of a font: embedd style and size fontSize 18 -- change font size fontStyle Italic -- change font style font f1 "Serif" -- create and use the font @@ -123,6 +129,7 @@ x=w+1 -- move one pixel outside of the image moveTo x y2 -- position say "moving in from the right ..." +render textAliasOff -- otherwise a blue trail gets created from the interpolation pixels loop while x>x2 winUpdate .false -- do not update window (frame) composite clear -- use CLEAR composite (to remove from image) @@ -135,9 +142,36 @@ sleep 0.01 -- sleep causes animation effect end -say "'sleep 5' ..." -sleep 5 +-- flash for 5 seconds +say "flashing for 5 seconds ..." +dt0=.dateTime~new +bErase=.true +bBold =.false +do while (.dateTime~new - dt0)~seconds < 5 + if bErase then -- erase string/text? + do + composite clear + drawString str + composite src_over + end + else -- draw string/text + do + if bBold then font f1 -- now show in f1 (Serif italic 18) + else font f2 -- now show in f2 (Serif bolditalic 19) + bBold=\bBold -- invert boolean value for next round + stringBounds str -- uses current font and current graphic context + parse var rc x1 y1 width1 height1 -- get fields + x2=(w-width1)/2 -- horizontal center position + y2=(h-y1)/2 -- vertical center position + moveTo x2 y2 + drawString str + end + bErase=\bErase -- invert boolean value + sleep 0.3 -- cause animation effect +end +say "we are done." + -- say "press enter to end ..."; parse pull ::requires "BSF.CLS" -- get ooRexx-Java bridge This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <or...@us...> - 2022-11-02 17:19:41
|
Revision: 1018 http://sourceforge.net/p/bsf4oorexx/code/1018 Author: orexx Date: 2022-11-02 17:19:38 +0000 (Wed, 02 Nov 2022) Log Message: ----------- 20221102 'font' command gains decode() ability, new 'render' command. Modified Paths: -------------- branches/850/bsf4oorexx.dev/bin/BSF.CLS branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html branches/850/bsf4oorexx.dev/information/jdor/jdor_doc_sample.png branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java branches/850/createDistributionForBSF4ooRexx8.cmd branches/850/samples/2-120_JDOR_shear.rxj branches/850/samples/3-110_JDOR_animate_composite.rxj Modified: branches/850/bsf4oorexx.dev/bin/BSF.CLS =================================================================== --- branches/850/bsf4oorexx.dev/bin/BSF.CLS 2022-11-01 18:48:56 UTC (rev 1017) +++ branches/850/bsf4oorexx.dev/bin/BSF.CLS 2022-11-02 17:19:38 UTC (rev 1018) @@ -821,7 +821,7 @@ BSF_ARRAY_PROXY: MAKEARRAY and SUPPLIER now only return entries with values as does Object Rexx with native arrays) - version: 6.41 (20210205) -- "6" -> Java minimum level "1.6/6.0", 41 -> ooRexx minimum level "4.1" + version: 8.50 (20221102) -- "6" -> Java minimum level "1.6/6.0", 41 -> ooRexx minimum level "4.1" If this program is part of a distribution of an Apache foundation project (e.g. BSF, the Bean Scripting Framework), then the immediately following Apache foundation license @@ -922,7 +922,7 @@ if initialize.bsf.dir() then -- setup .bsfrexx do - .bsf4rexx~version="850.20221101" -- set version (date distribution got created) + .bsf4rexx~version="850.20221102" -- set version (date distribution got created) .bsf4rexx~opSys =opsys -- save operating system name as supplied by Rexx' PARSE SOURCE .bsf4rexx~opSys1 =opsys~left(1)~upper -- save operating system name's initial letter in uppercase .bsf4rexx~opSys2 =opsys~left(2)~upper -- save operating system name's first two letters in uppercase Modified: branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html =================================================================== --- branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html 2022-11-01 18:48:56 UTC (rev 1017) +++ branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html 2022-11-02 17:19:38 UTC (rev 1018) @@ -675,7 +675,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "drawArc" - <td colspan="2"> Draws an arc. Angles increase counterclockwise. + <td colspan="2"> Draws an arc which is part of the oval inscribed in a rectangle. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>drawArc(...)()</em>. @@ -684,7 +684,7 @@ <td class="argument"> width height startAngle arcAngle <td> <em>width</em> and <em>height</em> in pixels of the rectangle, <em>startAngle</em> in degrees (<em>0</em> is the 3 o'clock position), <em>arcAngle</em> - angular extend in degrees relative to <em>startAngle</em>. + angular extend in degrees relative to <em>startAngle</em> (angles increase counterclockwise). <!-- -------------------------------------------------------- --> @@ -883,7 +883,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "fillArc" - <td colspan="2"> Fills an arc. Angles increase counterclockwise. + <td colspan="2"> Fills an arc which is part of the oval inscribed in a rectangle. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>fillArc(...)()</em>. @@ -892,7 +892,7 @@ <td class="argument"> width height startAngle arcAngle <td> <em>width</em> and <em>height</em> in pixels of the rectangle, <em>startAngle</em> in degrees (<em>0</em> is the 3 o'clock position), <em>arcAngle</em> - angular extent in degrees relative to <em>startAngle</em>. + angular extent in degrees relative to <em>startAngle</em> (angles increase counterclockwise). @@ -983,15 +983,21 @@ <br>Supplying only the <em>fontNickName</em> argument will load the font from the internal register and use it until it gets changed again. + <br>Supplying in addition the <em>fontName</em>, a <em>java.awt.Font</em> gets loaded from the system, registered with the supplied <em>fontNickName</em> and then used for setting the new font. The font size is taken from <a href="#cmdFontSize"><em>fontSize</em></a> - and the style from <a href="#cmdFontStyle"><em>fontStyle</em></a>. + and the style from <a href="#cmdFontStyle"><em>fontStyle</em></a> unless + the font name includes a trailing dash or blank, optionally a style (one of <em>PLAIN</em>, + <em>ITALIC</em>, <em>BOLD</em>, <em>BOLDITALIC</em>) and/or a trailing dash + or blank and size information (e.g. <em>"Arial BOLD 18"</em> or + <em>"Arial-BOLD-18"</em>, <em>"Arial 18"</em> or + <em>"Arial-BOLD"</em>). <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the - methods <em>getFont()</em>, <em>setFont(...)</em>, as well as the Java class - <em>java.awt.Font</em>. + methods <em>getFont()</em>, <em>setFont(...)</em>, as + well as the Java class <em>java.awt.Font</em> and the method <em>decode(fontName)</em>. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1054,7 +1060,7 @@ new font, defaults to <em>0</em> (<em>PLAIN</em>). Additional font style values are: <em>1</em> (<em>BOLD</em>), <em>2</em> (<em>ITALIC</em>) and - <em>3</em> (<em>BOLD_ITALIC</em>). + <em>3</em> (<em>BOLDITALIC</em>). <!-- -------------------------------------------------------- --> @@ -1474,9 +1480,40 @@ in the internal image registry. + <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> + <td class="command"> "render" + <td colspan="2"> Queries and optionally allows to change general and text antialiasing + rendering hints. + + <br>Querying the current value (no argument supplied) will return it, setting + (changing) the value to a new value will return the old (previously set) value + via the Rexx variable <em>RC</em>. The blank delimited string consists of two + values, the first representing the setting of <em>RenderingHints.KEY_ANTIALIASING</em> + (controls general antialiasing, JDOR default set to <em>"aliasOn"</em>) + and the second the setting of <em>RenderingHints.KEY_TEXT_ANTIALIASING</em> + (controls text antialising, JDOR default set to <em>"textAliasOn"</em>). By default + these two keys are set to <em><code>aliasOn textAliasOn</code></em> to get the best + rendering on high resolution screens and print devices. + + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + methods <em>getRenderingHint()</em>, <em>setRenderingHint(...)</em> and the Java class + <em>java.awt.RenderingHints</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> rendering1 [rendering2] + <td> <em>rendering1</em> and optionally <em>rendering2</em> are values for either + <em>RenderingHints.KEY_ANTIALIASING</em> (one of the values <em>"aliasOn"</em>, + <em>"aliasOff"</em>, <em>"aliasDefault"</em>) or + <em>RenderingHints.KEY_TEXT_ANTIALIASING</em> (<em>"textAliasOn"</em>, + <em>"textAliasOff"</em>, <em>"textAliasDefault"</em>). + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> <td class="command" id="cmdReset"> "reset" <br> "clear" <td colspan="2"> Resets the following runtime values: <ul> @@ -1645,7 +1682,7 @@ <td class="argument"> string <td> <em>string</em> (text) for which the bounds get returned if drawn in the current font using the current graphics context. The string returned via the Rexx - variable <em>RC</em> consists of: <em>"x y width height"</em>. + variable <em>RC</em> consists of blank delimited fields: <em>"x y width height"</em>. <!-- -------------------------------------------------------- --> @@ -1670,7 +1707,7 @@ <td> <td class="argument"> strokeNickName <td> <em>strokeNickName</em> is uppercased and used to fetch the stroke from the internal stroke - registry, sets the <em>Graphics[2D]</em> object to it and returns the stroke via the Rexx + registry, sets the <em>Graphics[2D]</em> object to it and returns the previous stroke via the Rexx variable <em>RC</em>. <tr class="ArgumentRowColor"><td><!-- table row --> @@ -1677,7 +1714,7 @@ <td> <td class="argument"> strokeNickName width <td> Defines a new stroke of <em>width</em> in pixels, stores it in the internal registry - with the uppercased <em>strokeNickName</em> and returns the new stroke via the Rexx + with the uppercased <em>strokeNickName</em> and returns the previous stroke via the Rexx variable <em>RC</em>. <tr class="ArgumentRowColor"><td><!-- table row --> @@ -1685,7 +1722,7 @@ <td class="argument"> strokeNickName width cap join <td> Defines a new stroke of <em>width</em> in pixels, <em>cap</em>, <em>join</em>, stores it in the internal registry with the uppercased <em>strokeNickName</em> - and returns the new stroke via the Rexx variable <em>RC</em>. + and returns the previous stroke via the Rexx variable <em>RC</em>. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1693,7 +1730,7 @@ <td> Defines a new stroke of <em>width</em> in pixels, <em>cap</em>, <em>join</em>, <em>miterlimit</em>, stores it in the internal registry with the uppercased <em>strokeNickName</em> - and returns the new stroke via the Rexx variable <em>RC</em>. + and returns the previous stroke via the Rexx variable <em>RC</em>. <tr class="ArgumentRowColor"><td><!-- table row --> @@ -1703,7 +1740,7 @@ <em>miterlimit</em>, <a href="#dtDashArray"><em>dashArray</em></a>, <em>dashPhase</em>, stores it in the internal registry with the uppercased <em>strokeNickName</em> - and returns the new stroke via the Rexx variable <em>RC</em>. + and returns the previous stroke via the Rexx variable <em>RC</em>. <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> @@ -2023,7 +2060,7 @@ <center> <hr width="75%"> <small> - JDOC synopsis of commands, version: 100.20221101 + JDOC synopsis of commands, version: 100.20221102 <br>Acknowledgement: the author wishes to thank DI Walter Pachl <br>for his help in testing and proof reading </small> Modified: branches/850/bsf4oorexx.dev/information/jdor/jdor_doc_sample.png =================================================================== (Binary files differ) Modified: branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java =================================================================== --- branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java 2022-11-01 18:48:56 UTC (rev 1017) +++ branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java 2022-11-02 17:19:38 UTC (rev 1018) @@ -10,7 +10,7 @@ author: Rony G. Flatscher date: 2022-09-05/2022-10-05 - version: 100.20221101 + version: 100.20221102 license: Apache license 2.0 license: @@ -85,7 +85,7 @@ - new command "imageCopy": returns a copy of an image (maybe for buffering purposes) - new command "stringBounds": returns the Rectangle2D floats for "x y width height" for the supplied string (allows for adjusting the string) - + 2022-11-02: - when loading a font try also Font.getFont(...) in addition */ /* Sample program in ooRexx (temporarily): @@ -136,7 +136,6 @@ package org.oorexx.handlers.jdor; - import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Graphics2D; @@ -154,6 +153,7 @@ import java.awt.GradientPaint; import java.awt.Paint; import java.awt.Rectangle; +import java.awt.RenderingHints; import java.awt.Stroke; import java.awt.BasicStroke; import java.awt.event.WindowAdapter; @@ -275,7 +275,7 @@ /* static definitions */ // default image sizes - static final public String version = "100.20221101"; + static final public String version = "100.20221102"; static final private int prefWidth = 500; static final private int prefHeight = 500; static private int prefImageType = BufferedImage.TYPE_INT_ARGB; // default with alpha (only png supported) @@ -297,9 +297,14 @@ static final HashMap<Integer,String> alphaCompositesInt2Name = new HashMap<>(); // FontStyle - static final HashMap<String,Integer> fontStyles = new HashMap<>(); - static final HashMap<Integer,String> fontStylesInt2Name = new HashMap<>(); + static final HashMap<String,Integer> fontStyles = new HashMap<>(); + static final HashMap<Integer,String> fontStylesInt2Name = new HashMap<>(); + // RenderingHint.Key supported for "rendering" command + static final HashMap<String,Object> renderingHints = new HashMap<>(); + static final HashMap<String,String> renderingHintsAlias = new HashMap<>(); + static final HashMap<Object,String> renderingHintsObj2Name = new HashMap<>(); + static { // ---------------------------------------------------------------------- // Color @@ -369,12 +374,28 @@ // ---------------------------------------------------------------------- // FontStyle - fontStyles.put("PLAIN" , 0); - fontStyles.put("BOLD" , 1); - fontStyles.put("ITALIC" , 2); - fontStyles.put("BOLD_ITALIC", 3); + fontStyles.put("PLAIN" , 0); + fontStyles.put("BOLD" , 1); + fontStyles.put("ITALIC" , 2); + fontStyles.put("BOLDITALIC", 3); // allow for looking up constant names (key) by value fontStyles.forEach((K,V)->fontStylesInt2Name.put(V,K)); + + // ---------------------------------------------------------------------- + renderingHints.put("ALIASON" , RenderingHints.VALUE_ANTIALIAS_ON); + renderingHints.put("ALIASOFF" , RenderingHints.VALUE_ANTIALIAS_OFF); + renderingHints.put("ALIASDEFAULT" , RenderingHints.VALUE_ANTIALIAS_DEFAULT); + renderingHints.put("TEXTALIASON" , RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + renderingHints.put("TEXTALIASOFF" , RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); + renderingHints.put("TEXTALIASDEFAULT", RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); + renderingHintsAlias.put("ALIASON" , "aliasOn" ); + renderingHintsAlias.put("ALIASOFF" , "aliasOff" ); + renderingHintsAlias.put("ALIASDEFAULT" , "aliasDefault" ); + renderingHintsAlias.put("TEXTALIASON" , "textAliasOn" ); + renderingHintsAlias.put("TEXTALIASOFF" , "textAliasOff" ); + renderingHintsAlias.put("TEXTALIASDEFAULT", "textAliasDefault" ); + // allow for looking up constant names (key) by value + renderingHints.forEach((K,V)->renderingHintsObj2Name.put(V,K)); } @@ -406,6 +427,9 @@ boolean currVisible = false; boolean currWinUpdate = true; // update Frame whenever we draw: allows turning updating on/off + // 2022-11-02: makes a difference when rendered to screen as well, so by default antialising is turned on + Object currAntiAliasing = RenderingHints.VALUE_ANTIALIAS_ON; + Object currTextAntiAliasing = RenderingHints.VALUE_TEXT_ANTIALIAS_ON; /** Stack for graphic configurations. */ ArrayDeque <Graphics2D>adGCStack = new ArrayDeque<>(); @@ -440,7 +464,7 @@ Graphics2D tGC = null; if (adGCStack.size()>0) { - tGC = adGCStack.pop(); + tGC = adGCStack.pop(); } while (tGC!=null) { @@ -552,6 +576,8 @@ bufImage = new BufferedImage(prefWidth, prefHeight, prefImageType); bufGC = (Graphics2D) bufImage.getGraphics(); bufGC.setColor(Color.BLACK); + bufGC.setRenderingHint(RenderingHints.KEY_ANTIALIASING, currAntiAliasing); + bufGC.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, currTextAntiAliasing); Font currFont = bufGC.getFont(); currFontStyle = currFont.getStyle(); currFontSize = currFont.getSize(); @@ -1318,6 +1344,9 @@ bufImage=new BufferedImage(width, height, type); // create new image bufGC=(Graphics2D) bufImage.getGraphics(); // get its GraphicsConfiguration bufGC.setColor(Color.BLACK); // make sure color is set to black + + bufGC.setRenderingHint(RenderingHints.KEY_ANTIALIASING, currAntiAliasing); + bufGC.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, currTextAntiAliasing); if (jd!=null) // update Frame if it exists { jd.bufImage=bufImage; @@ -1501,6 +1530,10 @@ rop.sendMessage2("SETENTRY", "printScaleX" , printScaleX); rop.sendMessage2("SETENTRY", "printScaleY" , printScaleY); + // current rendering options in effect + rop.sendMessage2("SETENTRY", "currAntiAliasing" , currAntiAliasing); + rop.sendMessage2("SETENTRY", "currTextAntiAliasing", currTextAntiAliasing); + // current GraphicConfiguration rop.sendMessage2("SETENTRY", "gc.background" , bufGC.getBackground()); rop.sendMessage2("SETENTRY", "gc.color" , bufGC.getColor() ); @@ -1947,6 +1980,83 @@ return resultValue; } + + case RENDER: // "render [opt1 [opt2]]": returns or sets the current antialiasing settings for rendering + { + int argNum=arrCommand.length; + if (argNum>3) + { + throw new IllegalArgumentException("this command needs either no, one or two rendering arguments, received "+(argNum-1)+" instead"); + } + + // get current settings + Object o1=bufGC.getRenderingHint(RenderingHints.KEY_ANTIALIASING); + Object o2=bufGC.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); + String s1=renderingHintsObj2Name.get(o1); + String s2=renderingHintsObj2Name.get(o2); + resultValue = s1+" "+s2; // query current value (to be returned if change occurs) + + if (argNum==1) + { + if (isOR) + { + writeOutput(slot, canonical); + } + return resultValue; + } + + String strArg = arrCommand[1].toUpperCase(); // get argument + if (!renderingHints.containsKey(strArg)) + { + throw new IllegalArgumentException("unknown value for argument # 1: \""+arrCommand[1]+"\""); + } + + if (strArg.startsWith("TEXT")) + { + currTextAntiAliasing = renderingHints.get(strArg); + bufGC.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, currTextAntiAliasing); + } + else + { + currAntiAliasing = renderingHints.get(strArg); + bufGC.setRenderingHint(RenderingHints.KEY_ANTIALIASING, currAntiAliasing); + } + if (isOR) + { + canonical=canonical+" "+renderingHintsAlias.get(strArg); + } + + if (argNum==3) + { + strArg = arrCommand[2].toUpperCase(); + if (!renderingHints.containsKey(strArg)) + { + throw new IllegalArgumentException("unknown value for argument # 1: \""+arrCommand[1]+"\""); + } + if (strArg.startsWith("TEXT")) + { + currTextAntiAliasing = renderingHints.get(strArg); + bufGC.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, currTextAntiAliasing); + } + else + { + currAntiAliasing = renderingHints.get(strArg); + bufGC.setRenderingHint(RenderingHints.KEY_ANTIALIASING, currAntiAliasing); + } + if (isOR) + { + canonical=canonical+" "+renderingHintsAlias.get(strArg); + } + } + + if (isOR) + { + writeOutput(slot, canonical); + } + return resultValue; + } + + case CLIP_REMOVE: // "removeClip" -> setClip(null) { if (arrCommand.length!=1) @@ -2357,14 +2467,21 @@ // o.k. Font name may contain blanks so use start of third word and all what remains String fontName = command.substring(alWordBoundaries.get(2)[0]); font = new Font(fontName, currFontStyle, currFontSize); - if (font==null) + // note: it may be the case that the font is not found and a replacement (Dialog.plain) gets returned + if (font==null || !font.getFontName().startsWith(fontName) ) { - String errMsg="font \""+fontName+"\" could not be loaded"; - if (isOR) + // 2022-11-02: use Font.decode(): if a registered Font with style and size encoded + // e.g. "Arial-BOLD-18", "Arial BOLD 18", "Arial-BOLD", "Arial 18", "Arial" + font = Font.decode(fontName); + if (font==null) { - writeOutput(slot, "-- ERROR (fontname argument): ["+command+"]"); + String errMsg="font \""+fontName+"\" could not be loaded"; + if (isOR) + { + writeOutput(slot, "-- ERROR (fontname argument): ["+command+"]"); + } + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-11", errMsg ); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-11", errMsg ); } canonical = canonical + " " + fontName; hmFonts.put(fontNickName.toUpperCase(),font); @@ -3783,6 +3900,9 @@ IMAGE_COPY ( "imageCopy" ) , // "imageCopy [nickName]": get a copy of the current image, if nickName supplied use from registry and if not found from Rexx variable STRING_BOUNDS ( "stringBounds" ) , // "stringBounds string": returns the Rectangle2D x y w h (in floats?) + // 2022-11-02 + RENDER ( "render" ) , // "render [opt1 [opt2]]": returns or sets the current antialiasing settings for rendering + PUSH_GC ( "pushGC" ) , // "pushGC" push current gc POP_GC ( "popGC" ) , // "popGC" pop and set previous gc Modified: branches/850/createDistributionForBSF4ooRexx8.cmd =================================================================== --- branches/850/createDistributionForBSF4ooRexx8.cmd 2022-11-01 18:48:56 UTC (rev 1017) +++ branches/850/createDistributionForBSF4ooRexx8.cmd 2022-11-02 17:19:38 UTC (rev 1018) @@ -36,9 +36,9 @@ @echo adding javax.servlet.jsp and javax.servlet.http to CLASSPATH set CLASSPATH=%CLASSPATH%;F:\download\java\java2s.com-javax.servlet.jsp\javax.servlet.jsp.jar;F:\download\java\java2s.com-javax.servlet.jsp\javax.servlet-3.0.0.v201112011016.jar -set releaseDate=20221101 -set runDate=20221101 -set doc_date=20221101 +set releaseDate=20221102 +set runDate=20221102 +set doc_date=20221102 @rem values to use for creating the BSF jarfile @rem set bsfDate=20090910 Modified: branches/850/samples/2-120_JDOR_shear.rxj =================================================================== --- branches/850/samples/2-120_JDOR_shear.rxj 2022-11-01 18:48:56 UTC (rev 1017) +++ branches/850/samples/2-120_JDOR_shear.rxj 2022-11-02 17:19:38 UTC (rev 1018) @@ -48,7 +48,7 @@ pkgLocal=.context~package~local -- get package's local environment -- add PIXEL.PER.CM entry to it, thereafter can be retrieved via the -- environment symbol .PIXEL.PER.CM from any place in this package -pkgLocal~pixel.per.cm = 72 / 2.54 -- there are 72 dots per inch, an inch is 2.54cm -> 28.3464567 pixel per cm +pkgLocal~dpcm = 72 / 2.54 -- there are 72 dots per inch, an inch is 2.54cm -> 28.3464567 dpcm (dots per cm) new 450 350 -- create image winShow -- show image in a window (a JFrame) @@ -109,8 +109,8 @@ drawTickMarks: procedure use strict arg tickStart, tickSize=4, lineLength=54 - do i = tickStart while i < lineLength/.pixel.per.cm - tick = i * .pixel.per.cm + do i = tickStart while i < lineLength/.dpcm + tick = i * .dpcm -- x-axis moveTo tick (-tickSize) drawLine tick tickSize @@ -126,10 +126,11 @@ drawRect: procedure use strict arg x=1, y=1, w=2, h=1 -- arguments are cm values - x=x*.pixel.per.cm -- calculate pixels - y=y*.pixel.per.cm -- calculate pixels - w=w*.pixel.per.cm -- calculate pixels - h=h*.pixel.per.cm -- calculate pixels + -- calculate needed dots per cm (dpcm) + x=x*.dpcm -- calculate dots (pixels) + y=y*.dpcm -- calculate dots (pixels) + w=w*.dpcm -- calculate dots (pixels) + h=h*.dpcm -- calculate dots (pixels) moveTo x y drawRect w h return Modified: branches/850/samples/3-110_JDOR_animate_composite.rxj =================================================================== --- branches/850/samples/3-110_JDOR_animate_composite.rxj 2022-11-01 18:48:56 UTC (rev 1017) +++ branches/850/samples/3-110_JDOR_animate_composite.rxj 2022-11-02 17:19:38 UTC (rev 1018) @@ -12,6 +12,8 @@ animation effects gets positioned without a frame to the lower right hand of the screen. + Note: + Date: 2022-10-30 Author: Rony G. Flatscher, WU Vienna @@ -21,6 +23,9 @@ Changed: 2022-11-01 - use new command 'stringBounds' and calculate center for the concluding string, let that string move in from the right + 2022-11-02 - adding flashing animation for five seconds + - turn off text aliasing for animated text/string (interpolation + pixel would distort the drawn string) license: @@ -110,6 +115,7 @@ -- get bounds of string, draw it at the center, but let it move in color blue -- change color +font f2 "Serif bolditalic 19" -- for final flashing, alternate definition of a font: embedd style and size fontSize 18 -- change font size fontStyle Italic -- change font style font f1 "Serif" -- create and use the font @@ -123,6 +129,7 @@ x=w+1 -- move one pixel outside of the image moveTo x y2 -- position say "moving in from the right ..." +render textAliasOff -- otherwise a blue trail gets created from the interpolation pixels loop while x>x2 winUpdate .false -- do not update window (frame) composite clear -- use CLEAR composite (to remove from image) @@ -135,9 +142,36 @@ sleep 0.01 -- sleep causes animation effect end -say "'sleep 5' ..." -sleep 5 +-- flash for 5 seconds +say "flashing for 5 seconds ..." +dt0=.dateTime~new +bErase=.true +bBold =.false +do while (.dateTime~new - dt0)~seconds < 5 + if bErase then -- erase string/text? + do + composite clear + drawString str + composite src_over + end + else -- draw string/text + do + if bBold then font f1 -- now show in f1 (Serif italic 18) + else font f2 -- now show in f2 (Serif bolditalic 19) + bBold=\bBold -- invert boolean value for next round + stringBounds str -- uses current font and current graphic context + parse var rc x1 y1 width1 height1 -- get fields + x2=(w-width1)/2 -- horizontal center position + y2=(h-y1)/2 -- vertical center position + moveTo x2 y2 + drawString str + end + bErase=\bErase -- invert boolean value + sleep 0.3 -- cause animation effect +end +say "we are done." + -- say "press enter to end ..."; parse pull ::requires "BSF.CLS" -- get ooRexx-Java bridge This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <or...@us...> - 2022-11-01 18:49:18
|
Revision: 1017 http://sourceforge.net/p/bsf4oorexx/code/1017 Author: orexx Date: 2022-11-01 18:48:56 +0000 (Tue, 01 Nov 2022) Log Message: ----------- 20221101 New beta, reflecting new JDOR commands imageCopy and stringBounds. Modified Paths: -------------- branches/850/bsf4oorexx.dev/bin/BSF.CLS branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html branches/850/bsf4oorexx.dev/information/jdor/jdor_doc_sample.png branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java branches/850/createDistributionForBSF4ooRexx8.cmd branches/850/samples/3-110_JDOR_animate_composite.rxj Modified: branches/850/bsf4oorexx.dev/bin/BSF.CLS =================================================================== --- branches/850/bsf4oorexx.dev/bin/BSF.CLS 2022-11-01 18:48:14 UTC (rev 1016) +++ branches/850/bsf4oorexx.dev/bin/BSF.CLS 2022-11-01 18:48:56 UTC (rev 1017) @@ -922,7 +922,7 @@ if initialize.bsf.dir() then -- setup .bsfrexx do - .bsf4rexx~version="850.20221031" -- set version (date distribution got created) + .bsf4rexx~version="850.20221101" -- set version (date distribution got created) .bsf4rexx~opSys =opsys -- save operating system name as supplied by Rexx' PARSE SOURCE .bsf4rexx~opSys1 =opsys~left(1)~upper -- save operating system name's initial letter in uppercase .bsf4rexx~opSys2 =opsys~left(2)~upper -- save operating system name's first two letters in uppercase Modified: branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html =================================================================== --- branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html 2022-11-01 18:48:14 UTC (rev 1016) +++ branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html 2022-11-01 18:48:56 UTC (rev 1017) @@ -161,8 +161,9 @@ drawLine width height -- from currX=0, currY=0 color red -- set the color to red (preregistered with nickname "RED") moveTo width 0 -- currX=220, currY=0 + position -- query current position say "--> rc="pp(rc) -- RC refers to the previous command's result: "220 0" (currX=220, currY=0) - drawLine 0 height -- from currX=250, currY=0 + drawLine 0 height -- from currX=220, currY=0 -- draw a rectangle at the center of the bitmap len = 50 -- drawing a rectangle with each side being 50 px (a square) moveTo (width-len)/2 (height-len)/2 -- go to the center minus half of the square's side lengths @@ -173,8 +174,9 @@ drawRect len len -- draw the frame with the blue color -- draw a string (text) at the lower half of the bitmap color somePurple 127 46 111 -- define a custom RGB color, store it with nickname "SOMEPURPLE" - say "--> rc="pp(rc) -- show result from command (the Java color object) - say " rc~toString:" pp(rc~toString) -- shows the RGB intensities of the color + color -- query current color + say "--> rc="pp(rc) -- show result from command (a Java color object) + say " rc~toString:" pp(rc~toString) -- shows the RGB intensities of the current color newY=height-40 lineHeight = 15 -- default font size is 12px, add 3 px space -- define an array of three strings @@ -673,7 +675,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "drawArc" - <td colspan="2"> Draws an arc . + <td colspan="2"> Draws an arc. Angles increase counterclockwise. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>drawArc(...)()</em>. @@ -691,8 +693,8 @@ <td class="command"> "drawImage" <td colspan="2"> Draws an image which got previously loaded from the filesystem with the command <em><a href="#cmdLoadImage">loadImage</a></em> and stored internally - with an <em>nickName</em> in the internal image registry, or an image that got - pushed with a <em>nickName</em> in the command <em><a href="#cmdPushImage">pushImage</a></em>, + with an <em>imageNickName</em> in the internal image registry, or an image that got + pushed with a <em>imageNickName</em> in the command <em><a href="#cmdPushImage">pushImage</a></em>, or stored in a Rexx variable. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the @@ -700,8 +702,8 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> - <td class="argument"> nickName [bkgColor] - <td> <em>nickName</em> denotes the name of an image stored in the + <td class="argument"> imageNickName [bkgColor] + <td> <em>imageNickName</em> denotes the name of an image stored in the internal image registry or the name of a Rexx variable referring to an image. Draws as much of the image as possible. @@ -709,8 +711,8 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> - <td class="argument"> nickName width height [bkgColor] - <td> <em>nickName</em> denotes the name of an image stored in the + <td class="argument"> imageNickName width height [bkgColor] + <td> <em>imageNickName</em> denotes the name of an image stored in the internal image registry or the name of a Rexx variable referring to an image. Draws as much of the image as possible scaled to the @@ -720,8 +722,8 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> - <td class="argument"> nickName width height srcX1 srcY1 srcX2 srcY2 [bkgColor] - <td> <em>nickName</em> denotes the name of an image stored in the + <td class="argument"> imageNickName width height srcX1 srcY1 srcX2 srcY2 [bkgColor] + <td> <em>imageNickName</em> denotes the name of an image stored in the internal image registry or the name of a Rexx variable referring to an image. Draws as much of the image as possible scaled to the @@ -840,12 +842,16 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "drawString" + <td class="command" id="cmdDrawString"> "drawString" <td colspan="2"> Draws a string (text). <br><em>Note:</em> In order to preserve leading blanks in a string, only the first (delimiting) blank after the command <em>drawString</em> will be consumed, all following characters - including leading whitespace - are regarded to constitute the string to be drawn. + <br><em>Hint:</em> if you have a need to know the bounds (a rectangle) of the + string using the current font and the current graphics context you may want to use the + command <a href="#cmdStringBounds">stringBounds</a>. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>drawString(...)</em>. @@ -877,7 +883,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "fillArc" - <td colspan="2"> Fills an arc . + <td colspan="2"> Fills an arc. Angles increase counterclockwise. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>fillArc(...)()</em>. @@ -1047,8 +1053,8 @@ <td> <em>style</em> a number or symbolic name that gets used when loading a new font, defaults to <em>0</em> (<em>PLAIN</em>). Additional font style values are: <em>1</em> (<em>BOLD</em>), - <em>2</em> (<em>ITALIC</em>) and - <em>3</em> (<em>BOLD</em> and <em>ITALIC</em>). + <em>2</em> (<em>ITALIC</em>) and + <em>3</em> (<em>BOLD_ITALIC</em>). <!-- -------------------------------------------------------- --> @@ -1195,6 +1201,24 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> + <td class="command"> "imageCopy" + <td colspan="2"> Creates and returns a copy of an image which got previously loaded from the filesystem + with the command <em><a href="#cmdLoadImage">loadImage</a></em> and stored internally + with an <em>imageNickName</em> in the internal image registry, or an image that got + pushed with a <em>imageNickName</em> in the command <em><a href="#cmdPushImage">pushImage</a></em>, + or stored in a Rexx variable. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> imageNickName [bkgColor] + <td> <em>imageNickName</em> denotes the name of an image stored in the + internal image registry or the name of a Rexx variable referring + to a <em>BufferedImage</em>. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> <td class="command"> "imageSize" <td colspan="2"> Query the image size (dimension). With no arguments returns the current image's <em>width</em> and <em>height</em> which can be referred to via the Rexx variable @@ -1209,7 +1233,6 @@ image registry, get its size which is returned via the Rexx variable <em>RC</em>. - <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> @@ -1589,7 +1612,8 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "sleep" - <td colspan="2"> Sleeps (halts execution) for the number of <em>seconds</em>. + <td colspan="2"> Sleeps (halts execution) for the given interval expressed + in <em>seconds</em>. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1602,6 +1626,31 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> + <td class="command" id="cmdStringBounds"> "stringBounds" + <td colspan="2"> Returns the bounds (a rectangle) for the supplied string (text) + if drawn in the current font on the current graphic context (via the Rexx variable <em>RC</em>). + One can use this information to exactly set the <a href="#cmdMoveTo">position</a> + before using the <a href="#cmdDrawString">drawString</a> command to draw the string. + + <br><em>Note:</em> In order to preserve leading blanks in a string, only the + first (delimiting) blank after the command <em>drawString</em> will be consumed, all + following characters - including leading whitespace - are regarded to constitute + the string to be drawn. + + <br>Cf. the Java documentation for the Java class <em>java.awt.FontMetrics</em> and the + method <em>getStringBounds(String str, Graphics context)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> string + <td> <em>string</em> (text) for which the bounds get returned if drawn in the + current font using the current graphics context. The string returned via the Rexx + variable <em>RC</em> consists of: <em>"x y width height"</em>. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> <td class="command" id="cmdStroke"> "stroke" <td colspan="2"> Queries, defines and sets strokes. @@ -1974,7 +2023,7 @@ <center> <hr width="75%"> <small> - JDOC synopsis of commands, version: 100.20221031 + JDOC synopsis of commands, version: 100.20221101 <br>Acknowledgement: the author wishes to thank DI Walter Pachl <br>for his help in testing and proof reading </small> Modified: branches/850/bsf4oorexx.dev/information/jdor/jdor_doc_sample.png =================================================================== (Binary files differ) Modified: branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java =================================================================== --- branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java 2022-11-01 18:48:14 UTC (rev 1016) +++ branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java 2022-11-01 18:48:56 UTC (rev 1017) @@ -10,7 +10,7 @@ author: Rony G. Flatscher date: 2022-09-05/2022-10-05 - version: 003.20221031 + version: 100.20221101 license: Apache license 2.0 license: @@ -80,6 +80,12 @@ image cannot be found in the registry by that nickname - PRINT_IMAGE now also can take an image (must be a BufferedImage) from a Rexx variable named after the nickname (only if not found in the image registry) + 2022-11-01: - add fontStyles[Int2Name], replace fontStyle numeric value with name, if + "bUseName4canonical" is set + - new command "imageCopy": returns a copy of an image (maybe for buffering purposes) + - new command "stringBounds": returns the Rectangle2D floats for "x y width height" + for the supplied string (allows for adjusting the string) + */ /* Sample program in ooRexx (temporarily): @@ -134,7 +140,8 @@ import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Graphics2D; -import java.awt.geom.AffineTransform; +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; import java.awt.Toolkit; import javax.swing.JFrame; import javax.swing.JPanel; @@ -142,6 +149,7 @@ import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Font; +import java.awt.FontMetrics; import java.awt.Dimension; import java.awt.GradientPaint; import java.awt.Paint; @@ -267,7 +275,7 @@ /* static definitions */ // default image sizes - static final public String version = "005.20221031"; + static final public String version = "100.20221101"; static final private int prefWidth = 500; static final private int prefHeight = 500; static private int prefImageType = BufferedImage.TYPE_INT_ARGB; // default with alpha (only png supported) @@ -288,6 +296,10 @@ static final HashMap<String,Integer> alphaComposites = new HashMap<>(); static final HashMap<Integer,String> alphaCompositesInt2Name = new HashMap<>(); + // FontStyle + static final HashMap<String,Integer> fontStyles = new HashMap<>(); + static final HashMap<Integer,String> fontStylesInt2Name = new HashMap<>(); + static { // ---------------------------------------------------------------------- // Color @@ -354,6 +366,15 @@ alphaComposites.put("XOR" , 12); // allow for looking up constant names (key) by value alphaComposites.forEach((K,V)->alphaCompositesInt2Name.put(V,K)); + + // ---------------------------------------------------------------------- + // FontStyle + fontStyles.put("PLAIN" , 0); + fontStyles.put("BOLD" , 1); + fontStyles.put("ITALIC" , 2); + fontStyles.put("BOLD_ITALIC", 3); + // allow for looking up constant names (key) by value + fontStyles.forEach((K,V)->fontStylesInt2Name.put(V,K)); } @@ -1108,14 +1129,8 @@ { String name = arrCommand[1]; // get nickname tmpImage = hmImages.get(name.toUpperCase()); -/* --- if (tmpImage==null) { - throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\""); - } --- */ - if (tmpImage==null) - { try { tmpImage = (BufferedImage) getContextVariable(slot, name); // try to get from a Rexx variable @@ -1383,6 +1398,42 @@ return ""+img.getType(); } + case IMAGE_COPY: // "imageCopy [nickName]": get a copy of the current image, if nickName supplied use from registry and if not found from Rexx variable + { + if (arrCommand.length>2) + { + throw new IllegalArgumentException("this command needs either no or exactly 1 argument (image's nickname for lookup), received "+(arrCommand.length-1)+" instead"); + } + BufferedImage tmpImage = bufImage; // current image + if (arrCommand.length==2) // load image + { + String name = arrCommand[1]; // get nickname + tmpImage = hmImages.get(name.toUpperCase()); + if (tmpImage==null) + { + try + { + tmpImage = (BufferedImage) getContextVariable(slot, name); // try to get from a Rexx variable + } + catch (Throwable t) {} + if (tmpImage==null) + { + throw new IllegalArgumentException("image (must be a BufferedImage) with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\" or \"pushImage "+name+"\" or assign an BufferedImage to a Rexx variable named \""+name+"\""); + } + } + if (isOR) + { + canonical = canonical+" "+name; + } + } + if (isOR) + { + writeOutput(slot, canonical); + } + return copyImage(tmpImage); // return copy of image + } + + case IMAGE_SIZE: // "imageSize [nickName]" { if (arrCommand.length>2) @@ -2190,18 +2241,33 @@ if (arrCommand.length==2) { - int newFontStyle = Integer.parseInt(arrCommand[1]); - // no exception, so args o.k. - if (newFontStyle<0 || newFontStyle>3) + int fontStyle; + String newFontStyle = arrCommand[1].toUpperCase(); + if (startRexxVariableChar.indexOf(newFontStyle.charAt(0))>=0) // a symbolic name? { - throw new IllegalArgumentException("illegal fontStyle ["+newFontStyle+"]: must be one of 0 (PLAIN), 1 (BOLD), 2 (ITALIC) or 3 (BOLD+ITALIC)"); + if (!fontStyles.containsKey(newFontStyle)) + { + throw new IllegalArgumentException("unknown value for \"fontStyle\" argument: \""+arrCommand[1]+"\""); + } + fontStyle=fontStyles.get(newFontStyle); } - currFontStyle = newFontStyle; + else // verbatim int type + { + fontStyle=Integer.parseInt(newFontStyle); + if (!fontStyles.containsValue(fontStyle)) + { + throw new IllegalArgumentException("unknown value for \"fontStyle\" argument: \""+arrCommand[1]+"\""); + } + } if (isOR) { - canonical=canonical+" "+newFontStyle; + canonical = canonical + " " + + (bUseNames4canonical ? fontStylesInt2Name.get(fontStyle) : arrCommand[1]) ; } + currFontStyle=fontStyle; + } + if (isOR) { writeOutput(slot, canonical); @@ -2265,32 +2331,12 @@ canonical = canonical + " " + fontNickName; } - // Dialog", "DialogInput", "Serif", "SansSerif", "Monospaced" if (arrCommand.length==2 ) { font = hmFonts.get(fontNickName.toUpperCase()); -/* -- 2022-10-31 (injected the day before): remove, as it should be possible to use these fonts with a nickname if (font==null) { - // maybe one of the five operating system independent fonts? - if ("Dialog DialogInput Serif SansSerif Monospaced".indexOf(fontNickName)>=0) - { - font = new Font(fontNickName, currFontStyle, currFontSize); - } - if (font==null) - { - String errMsg="font with the supplied nickname \""+fontNickName+"\" is not registered"; - if (isOR) - { - writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); - } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-10", errMsg ); - } - } --- */ - if (font==null) - { String errMsg="font with the supplied nickname \""+fontNickName+"\" is not registered"; if (isOR) { @@ -2305,7 +2351,6 @@ { writeOutput(slot, canonical); } - // return font; return resultValue; } @@ -2321,6 +2366,7 @@ } return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-11", errMsg ); } + canonical = canonical + " " + fontName; hmFonts.put(fontNickName.toUpperCase(),font); bufGC.setFont(font); if (isOR) @@ -2327,7 +2373,6 @@ { writeOutput(slot, canonical); } - // return font; return resultValue; } @@ -2433,6 +2478,41 @@ } break; + + // 2022-11-01: return bounds of string with current font and gc + case STRING_BOUNDS: // ( "stringBounds" ) , // "stringBounds string": returns width and height) + { + // ArrayList<int[]> al = getWordBoundaries(command); // parse command return word boundaries + ArrayList<int[]> al = alWordBoundaries; + if (al.size()<2) + { + throw new IllegalArgumentException("this command needs 1 argument (the string to be measured with current font and graphic context)"); + } + // no exception, so args o.k. + // to fetch leading blanks we skip over first blank (unlike for other commands where we ignore all blanks after the command) + int [] pos = (int []) al.get(0); + String str = command.substring(pos[1]+1); // extract String: skip over first trailing blank + + FontMetrics fm = bufGC.getFontMetrics(); // get current font metrics + String strResult = null; + + // int width = fm.stringWidth(str); + // TODO: use getMaxAscent() and getMaxDescent() instead? or use + // int height = fm.getAscent() + fm.getDescent(); + // strResult = width + " " + height; + + Rectangle2D r2d = fm.getStringBounds(str, bufGC); + strResult = r2d.getX()+" "+r2d.getY()+" "+r2d.getWidth()+" "+r2d.getHeight(); + + if (isOR) + { + writeOutput(slot,canonical+" "+str); + } + return strResult; + } + + + case DRAW_OVAL: // "drawOval width height" case FILL_OVAL: { @@ -3699,6 +3779,10 @@ LOAD_IMAGE ( "loadImage" ) , // "loadImage imageNickName filename", loads an image -> returns its dimension SAVE_IMAGE ( "saveImage" ) , // "saveImage filename", saves current image to file + // 2022-11-01 + IMAGE_COPY ( "imageCopy" ) , // "imageCopy [nickName]": get a copy of the current image, if nickName supplied use from registry and if not found from Rexx variable + STRING_BOUNDS ( "stringBounds" ) , // "stringBounds string": returns the Rectangle2D x y w h (in floats?) + PUSH_GC ( "pushGC" ) , // "pushGC" push current gc POP_GC ( "popGC" ) , // "popGC" pop and set previous gc Modified: branches/850/createDistributionForBSF4ooRexx8.cmd =================================================================== --- branches/850/createDistributionForBSF4ooRexx8.cmd 2022-11-01 18:48:14 UTC (rev 1016) +++ branches/850/createDistributionForBSF4ooRexx8.cmd 2022-11-01 18:48:56 UTC (rev 1017) @@ -36,9 +36,9 @@ @echo adding javax.servlet.jsp and javax.servlet.http to CLASSPATH set CLASSPATH=%CLASSPATH%;F:\download\java\java2s.com-javax.servlet.jsp\javax.servlet.jsp.jar;F:\download\java\java2s.com-javax.servlet.jsp\javax.servlet-3.0.0.v201112011016.jar -set releaseDate=20221031 -set runDate=20221031 -set doc_date=20221031 +set releaseDate=20221101 +set runDate=20221101 +set doc_date=20221101 @rem values to use for creating the BSF jarfile @rem set bsfDate=20090910 Modified: branches/850/samples/3-110_JDOR_animate_composite.rxj =================================================================== --- branches/850/samples/3-110_JDOR_animate_composite.rxj 2022-11-01 18:48:14 UTC (rev 1016) +++ branches/850/samples/3-110_JDOR_animate_composite.rxj 2022-11-01 18:48:56 UTC (rev 1017) @@ -19,6 +19,9 @@ last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + Changed: 2022-11-01 - use new command 'stringBounds' and calculate center for the + concluding string, let that string move in from the right + license: ------------------------ Apache Version 2.0 license ------------------------- @@ -43,8 +46,8 @@ jdor=.bsf~new("org.oorexx.handlers.jdor.JavaDrawingHandler") call BsfCommandHandler "add", "JDOR", jdor --- address jdor -- set default environment to JDOR -address jdor with error using (.error) -- set default environment to JDOR +address jdor -- set default environment to JDOR +-- address jdor with error using (.error) -- set default environment to JDOR w=400 -- width h=400 -- height @@ -69,7 +72,7 @@ parse var loc name x y size loadImage name name -- load image from file use filename as nick name moveTo x y -- move to desired location - composite src_over 0.01 -- composite set to transparent (alpha to 0.01) + composite src_over 0.025 -- composite set to transparent (alpha to 0.01) do i=1 to 100 -- repeatedly drawing adds current alpha to existing picture (fade in) drawImage name size size -- draw image with desired size sleep 0.01 -- sleep causes animation effect @@ -105,11 +108,33 @@ end end -moveTo 75 200 -color blue -fontSize 18 -font f1 "Serif" -drawString "Wer are done, goodbye! ('sleep 5' ...)" +-- get bounds of string, draw it at the center, but let it move in +color blue -- change color +fontSize 18 -- change font size +fontStyle Italic -- change font style +font f1 "Serif" -- create and use the font +str="We are done, goodbye! ('sleep 5' ...)" -- string to show +stringBounds str -- current font and current graphic context +say " str:" pp(str) +say "'stringBounds str' returned rc:" pp(rc) "(in pixels)" +parse var rc x1 y1 width1 height1 -- get fields +x2=(w-width1)/2 -- horizontal center position +y2=(h-y1)/2 -- vertical center position +x=w+1 -- move one pixel outside of the image +moveTo x y2 -- position +say "moving in from the right ..." +loop while x>x2 + winUpdate .false -- do not update window (frame) + composite clear -- use CLEAR composite (to remove from image) + drawString str -- draw the string + x+=-1 -- move one pixel to the left + composite src_over -- re-establish writing src over destination + moveTo x y2 -- go to next position + drawString str -- draw the string + winUpdate .true -- do not update window (frame) + sleep 0.01 -- sleep causes animation effect +end + say "'sleep 5' ..." sleep 5 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <or...@us...> - 2022-11-01 18:48:22
|
Revision: 1016 http://sourceforge.net/p/bsf4oorexx/code/1016 Author: orexx Date: 2022-11-01 18:48:14 +0000 (Tue, 01 Nov 2022) Log Message: ----------- 20221101 New commands imageCopy and stringBounds. Modified Paths: -------------- sandbox/rgf/jdor/JavaDrawingHandler.java sandbox/rgf/jdor/doc/jdor_doc.html sandbox/rgf/jdor/samples/3-110_JDOR_animate_composite.rxj Modified: sandbox/rgf/jdor/JavaDrawingHandler.java =================================================================== --- sandbox/rgf/jdor/JavaDrawingHandler.java 2022-10-31 17:10:23 UTC (rev 1015) +++ sandbox/rgf/jdor/JavaDrawingHandler.java 2022-11-01 18:48:14 UTC (rev 1016) @@ -10,7 +10,7 @@ author: Rony G. Flatscher date: 2022-09-05/2022-10-05 - version: 003.20221031 + version: 100.20221101 license: Apache license 2.0 license: @@ -80,6 +80,12 @@ image cannot be found in the registry by that nickname - PRINT_IMAGE now also can take an image (must be a BufferedImage) from a Rexx variable named after the nickname (only if not found in the image registry) + 2022-11-01: - add fontStyles[Int2Name], replace fontStyle numeric value with name, if + "bUseName4canonical" is set + - new command "imageCopy": returns a copy of an image (maybe for buffering purposes) + - new command "stringBounds": returns the Rectangle2D floats for "x y width height" + for the supplied string (allows for adjusting the string) + */ /* Sample program in ooRexx (temporarily): @@ -134,7 +140,8 @@ import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Graphics2D; -import java.awt.geom.AffineTransform; +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; import java.awt.Toolkit; import javax.swing.JFrame; import javax.swing.JPanel; @@ -142,6 +149,7 @@ import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Font; +import java.awt.FontMetrics; import java.awt.Dimension; import java.awt.GradientPaint; import java.awt.Paint; @@ -267,7 +275,7 @@ /* static definitions */ // default image sizes - static final public String version = "005.20221031"; + static final public String version = "100.20221101"; static final private int prefWidth = 500; static final private int prefHeight = 500; static private int prefImageType = BufferedImage.TYPE_INT_ARGB; // default with alpha (only png supported) @@ -288,6 +296,10 @@ static final HashMap<String,Integer> alphaComposites = new HashMap<>(); static final HashMap<Integer,String> alphaCompositesInt2Name = new HashMap<>(); + // FontStyle + static final HashMap<String,Integer> fontStyles = new HashMap<>(); + static final HashMap<Integer,String> fontStylesInt2Name = new HashMap<>(); + static { // ---------------------------------------------------------------------- // Color @@ -354,6 +366,15 @@ alphaComposites.put("XOR" , 12); // allow for looking up constant names (key) by value alphaComposites.forEach((K,V)->alphaCompositesInt2Name.put(V,K)); + + // ---------------------------------------------------------------------- + // FontStyle + fontStyles.put("PLAIN" , 0); + fontStyles.put("BOLD" , 1); + fontStyles.put("ITALIC" , 2); + fontStyles.put("BOLD_ITALIC", 3); + // allow for looking up constant names (key) by value + fontStyles.forEach((K,V)->fontStylesInt2Name.put(V,K)); } @@ -1108,14 +1129,8 @@ { String name = arrCommand[1]; // get nickname tmpImage = hmImages.get(name.toUpperCase()); -/* --- if (tmpImage==null) { - throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\""); - } --- */ - if (tmpImage==null) - { try { tmpImage = (BufferedImage) getContextVariable(slot, name); // try to get from a Rexx variable @@ -1383,6 +1398,42 @@ return ""+img.getType(); } + case IMAGE_COPY: // "imageCopy [nickName]": get a copy of the current image, if nickName supplied use from registry and if not found from Rexx variable + { + if (arrCommand.length>2) + { + throw new IllegalArgumentException("this command needs either no or exactly 1 argument (image's nickname for lookup), received "+(arrCommand.length-1)+" instead"); + } + BufferedImage tmpImage = bufImage; // current image + if (arrCommand.length==2) // load image + { + String name = arrCommand[1]; // get nickname + tmpImage = hmImages.get(name.toUpperCase()); + if (tmpImage==null) + { + try + { + tmpImage = (BufferedImage) getContextVariable(slot, name); // try to get from a Rexx variable + } + catch (Throwable t) {} + if (tmpImage==null) + { + throw new IllegalArgumentException("image (must be a BufferedImage) with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\" or \"pushImage "+name+"\" or assign an BufferedImage to a Rexx variable named \""+name+"\""); + } + } + if (isOR) + { + canonical = canonical+" "+name; + } + } + if (isOR) + { + writeOutput(slot, canonical); + } + return copyImage(tmpImage); // return copy of image + } + + case IMAGE_SIZE: // "imageSize [nickName]" { if (arrCommand.length>2) @@ -2190,18 +2241,33 @@ if (arrCommand.length==2) { - int newFontStyle = Integer.parseInt(arrCommand[1]); - // no exception, so args o.k. - if (newFontStyle<0 || newFontStyle>3) + int fontStyle; + String newFontStyle = arrCommand[1].toUpperCase(); + if (startRexxVariableChar.indexOf(newFontStyle.charAt(0))>=0) // a symbolic name? { - throw new IllegalArgumentException("illegal fontStyle ["+newFontStyle+"]: must be one of 0 (PLAIN), 1 (BOLD), 2 (ITALIC) or 3 (BOLD+ITALIC)"); + if (!fontStyles.containsKey(newFontStyle)) + { + throw new IllegalArgumentException("unknown value for \"fontStyle\" argument: \""+arrCommand[1]+"\""); + } + fontStyle=fontStyles.get(newFontStyle); } - currFontStyle = newFontStyle; + else // verbatim int type + { + fontStyle=Integer.parseInt(newFontStyle); + if (!fontStyles.containsValue(fontStyle)) + { + throw new IllegalArgumentException("unknown value for \"fontStyle\" argument: \""+arrCommand[1]+"\""); + } + } if (isOR) { - canonical=canonical+" "+newFontStyle; + canonical = canonical + " " + + (bUseNames4canonical ? fontStylesInt2Name.get(fontStyle) : arrCommand[1]) ; } + currFontStyle=fontStyle; + } + if (isOR) { writeOutput(slot, canonical); @@ -2265,32 +2331,12 @@ canonical = canonical + " " + fontNickName; } - // Dialog", "DialogInput", "Serif", "SansSerif", "Monospaced" if (arrCommand.length==2 ) { font = hmFonts.get(fontNickName.toUpperCase()); -/* -- 2022-10-31 (injected the day before): remove, as it should be possible to use these fonts with a nickname if (font==null) { - // maybe one of the five operating system independent fonts? - if ("Dialog DialogInput Serif SansSerif Monospaced".indexOf(fontNickName)>=0) - { - font = new Font(fontNickName, currFontStyle, currFontSize); - } - if (font==null) - { - String errMsg="font with the supplied nickname \""+fontNickName+"\" is not registered"; - if (isOR) - { - writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); - } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-10", errMsg ); - } - } --- */ - if (font==null) - { String errMsg="font with the supplied nickname \""+fontNickName+"\" is not registered"; if (isOR) { @@ -2305,7 +2351,6 @@ { writeOutput(slot, canonical); } - // return font; return resultValue; } @@ -2321,6 +2366,7 @@ } return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-11", errMsg ); } + canonical = canonical + " " + fontName; hmFonts.put(fontNickName.toUpperCase(),font); bufGC.setFont(font); if (isOR) @@ -2327,7 +2373,6 @@ { writeOutput(slot, canonical); } - // return font; return resultValue; } @@ -2433,6 +2478,41 @@ } break; + + // 2022-11-01: return bounds of string with current font and gc + case STRING_BOUNDS: // ( "stringBounds" ) , // "stringBounds string": returns width and height) + { + // ArrayList<int[]> al = getWordBoundaries(command); // parse command return word boundaries + ArrayList<int[]> al = alWordBoundaries; + if (al.size()<2) + { + throw new IllegalArgumentException("this command needs 1 argument (the string to be measured with current font and graphic context)"); + } + // no exception, so args o.k. + // to fetch leading blanks we skip over first blank (unlike for other commands where we ignore all blanks after the command) + int [] pos = (int []) al.get(0); + String str = command.substring(pos[1]+1); // extract String: skip over first trailing blank + + FontMetrics fm = bufGC.getFontMetrics(); // get current font metrics + String strResult = null; + + // int width = fm.stringWidth(str); + // TODO: use getMaxAscent() and getMaxDescent() instead? or use + // int height = fm.getAscent() + fm.getDescent(); + // strResult = width + " " + height; + + Rectangle2D r2d = fm.getStringBounds(str, bufGC); + strResult = r2d.getX()+" "+r2d.getY()+" "+r2d.getWidth()+" "+r2d.getHeight(); + + if (isOR) + { + writeOutput(slot,canonical+" "+str); + } + return strResult; + } + + + case DRAW_OVAL: // "drawOval width height" case FILL_OVAL: { @@ -3699,6 +3779,10 @@ LOAD_IMAGE ( "loadImage" ) , // "loadImage imageNickName filename", loads an image -> returns its dimension SAVE_IMAGE ( "saveImage" ) , // "saveImage filename", saves current image to file + // 2022-11-01 + IMAGE_COPY ( "imageCopy" ) , // "imageCopy [nickName]": get a copy of the current image, if nickName supplied use from registry and if not found from Rexx variable + STRING_BOUNDS ( "stringBounds" ) , // "stringBounds string": returns the Rectangle2D x y w h (in floats?) + PUSH_GC ( "pushGC" ) , // "pushGC" push current gc POP_GC ( "popGC" ) , // "popGC" pop and set previous gc Modified: sandbox/rgf/jdor/doc/jdor_doc.html =================================================================== --- sandbox/rgf/jdor/doc/jdor_doc.html 2022-10-31 17:10:23 UTC (rev 1015) +++ sandbox/rgf/jdor/doc/jdor_doc.html 2022-11-01 18:48:14 UTC (rev 1016) @@ -675,7 +675,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "drawArc" - <td colspan="2"> Draws an arc . + <td colspan="2"> Draws an arc. Angles increase counterclockwise. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>drawArc(...)()</em>. @@ -693,8 +693,8 @@ <td class="command"> "drawImage" <td colspan="2"> Draws an image which got previously loaded from the filesystem with the command <em><a href="#cmdLoadImage">loadImage</a></em> and stored internally - with an <em>nickName</em> in the internal image registry, or an image that got - pushed with a <em>nickName</em> in the command <em><a href="#cmdPushImage">pushImage</a></em>, + with an <em>imageNickName</em> in the internal image registry, or an image that got + pushed with a <em>imageNickName</em> in the command <em><a href="#cmdPushImage">pushImage</a></em>, or stored in a Rexx variable. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the @@ -702,8 +702,8 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> - <td class="argument"> nickName [bkgColor] - <td> <em>nickName</em> denotes the name of an image stored in the + <td class="argument"> imageNickName [bkgColor] + <td> <em>imageNickName</em> denotes the name of an image stored in the internal image registry or the name of a Rexx variable referring to an image. Draws as much of the image as possible. @@ -711,8 +711,8 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> - <td class="argument"> nickName width height [bkgColor] - <td> <em>nickName</em> denotes the name of an image stored in the + <td class="argument"> imageNickName width height [bkgColor] + <td> <em>imageNickName</em> denotes the name of an image stored in the internal image registry or the name of a Rexx variable referring to an image. Draws as much of the image as possible scaled to the @@ -722,8 +722,8 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> - <td class="argument"> nickName width height srcX1 srcY1 srcX2 srcY2 [bkgColor] - <td> <em>nickName</em> denotes the name of an image stored in the + <td class="argument"> imageNickName width height srcX1 srcY1 srcX2 srcY2 [bkgColor] + <td> <em>imageNickName</em> denotes the name of an image stored in the internal image registry or the name of a Rexx variable referring to an image. Draws as much of the image as possible scaled to the @@ -842,12 +842,16 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "drawString" + <td class="command" id="cmdDrawString"> "drawString" <td colspan="2"> Draws a string (text). <br><em>Note:</em> In order to preserve leading blanks in a string, only the first (delimiting) blank after the command <em>drawString</em> will be consumed, all following characters - including leading whitespace - are regarded to constitute the string to be drawn. + <br><em>Hint:</em> if you have a need to know the bounds (a rectangle) of the + string using the current font and the current graphics context you may want to use the + command <a href="#cmdStringBounds">stringBounds</a>. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>drawString(...)</em>. @@ -879,7 +883,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "fillArc" - <td colspan="2"> Fills an arc . + <td colspan="2"> Fills an arc. Angles increase counterclockwise. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>fillArc(...)()</em>. @@ -1049,8 +1053,8 @@ <td> <em>style</em> a number or symbolic name that gets used when loading a new font, defaults to <em>0</em> (<em>PLAIN</em>). Additional font style values are: <em>1</em> (<em>BOLD</em>), - <em>2</em> (<em>ITALIC</em>) and - <em>3</em> (<em>BOLD</em> and <em>ITALIC</em>). + <em>2</em> (<em>ITALIC</em>) and + <em>3</em> (<em>BOLD_ITALIC</em>). <!-- -------------------------------------------------------- --> @@ -1197,6 +1201,24 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> + <td class="command"> "imageCopy" + <td colspan="2"> Creates and returns a copy of an image which got previously loaded from the filesystem + with the command <em><a href="#cmdLoadImage">loadImage</a></em> and stored internally + with an <em>imageNickName</em> in the internal image registry, or an image that got + pushed with a <em>imageNickName</em> in the command <em><a href="#cmdPushImage">pushImage</a></em>, + or stored in a Rexx variable. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> imageNickName [bkgColor] + <td> <em>imageNickName</em> denotes the name of an image stored in the + internal image registry or the name of a Rexx variable referring + to a <em>BufferedImage</em>. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> <td class="command"> "imageSize" <td colspan="2"> Query the image size (dimension). With no arguments returns the current image's <em>width</em> and <em>height</em> which can be referred to via the Rexx variable @@ -1211,7 +1233,6 @@ image registry, get its size which is returned via the Rexx variable <em>RC</em>. - <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> @@ -1591,7 +1612,8 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "sleep" - <td colspan="2"> Sleeps (halts execution) for the number of <em>seconds</em>. + <td colspan="2"> Sleeps (halts execution) for the given interval expressed + in <em>seconds</em>. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1604,6 +1626,31 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> + <td class="command" id="cmdStringBounds"> "stringBounds" + <td colspan="2"> Returns the bounds (a rectangle) for the supplied string (text) + if drawn in the current font on the current graphic context (via the Rexx variable <em>RC</em>). + One can use this information to exactly set the <a href="#cmdMoveTo">position</a> + before using the <a href="#cmdDrawString">drawString</a> command to draw the string. + + <br><em>Note:</em> In order to preserve leading blanks in a string, only the + first (delimiting) blank after the command <em>drawString</em> will be consumed, all + following characters - including leading whitespace - are regarded to constitute + the string to be drawn. + + <br>Cf. the Java documentation for the Java class <em>java.awt.FontMetrics</em> and the + method <em>getStringBounds(String str, Graphics context)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> string + <td> <em>string</em> (text) for which the bounds get returned if drawn in the + current font using the current graphics context. The string returned via the Rexx + variable <em>RC</em> consists of: <em>"x y width height"</em>. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> <td class="command" id="cmdStroke"> "stroke" <td colspan="2"> Queries, defines and sets strokes. @@ -1976,7 +2023,7 @@ <center> <hr width="75%"> <small> - JDOC synopsis of commands, version: 100.20221031 + JDOC synopsis of commands, version: 100.20221101 <br>Acknowledgement: the author wishes to thank DI Walter Pachl <br>for his help in testing and proof reading </small> Modified: sandbox/rgf/jdor/samples/3-110_JDOR_animate_composite.rxj =================================================================== --- sandbox/rgf/jdor/samples/3-110_JDOR_animate_composite.rxj 2022-10-31 17:10:23 UTC (rev 1015) +++ sandbox/rgf/jdor/samples/3-110_JDOR_animate_composite.rxj 2022-11-01 18:48:14 UTC (rev 1016) @@ -19,6 +19,9 @@ last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + Changed: 2022-11-01 - use new command 'stringBounds' and calculate center for the + concluding string, let that string move in from the right + license: ------------------------ Apache Version 2.0 license ------------------------- @@ -105,11 +108,33 @@ end end -moveTo 75 200 -color blue -fontSize 18 -font f1 "Serif" -drawString "We are done, goodbye! ('sleep 5' ...)" +-- get bounds of string, draw it at the center, but let it move in +color blue -- change color +fontSize 18 -- change font size +fontStyle Italic -- change font style +font f1 "Serif" -- create and use the font +str="We are done, goodbye! ('sleep 5' ...)" -- string to show +stringBounds str -- current font and current graphic context +say " str:" pp(str) +say "'stringBounds str' returned rc:" pp(rc) "(in pixels)" +parse var rc x1 y1 width1 height1 -- get fields +x2=(w-width1)/2 -- horizontal center position +y2=(h-y1)/2 -- vertical center position +x=w+1 -- move one pixel outside of the image +moveTo x y2 -- position +say "moving in from the right ..." +loop while x>x2 + winUpdate .false -- do not update window (frame) + composite clear -- use CLEAR composite (to remove from image) + drawString str -- draw the string + x+=-1 -- move one pixel to the left + composite src_over -- re-establish writing src over destination + moveTo x y2 -- go to next position + drawString str -- draw the string + winUpdate .true -- do not update window (frame) + sleep 0.01 -- sleep causes animation effect +end + say "'sleep 5' ..." sleep 5 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <or...@us...> - 2022-10-31 17:10:26
|
Revision: 1015 http://sourceforge.net/p/bsf4oorexx/code/1015 Author: orexx Date: 2022-10-31 17:10:23 +0000 (Mon, 31 Oct 2022) Log Message: ----------- 20221031 Changes for todays new beta. Modified Paths: -------------- branches/850/bsf4oorexx.dev/bin/BSF.CLS branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java branches/850/createDistributionForBSF4ooRexx8.cmd branches/850/samples/1-120_JDOR_bw.rxj branches/850/samples/1-120_JDOR_color_text.rxj branches/850/samples/1-130_JDOR_rotate.rxj branches/850/samples/1-140_JDOR_images.rxj branches/850/samples/1-140_JDOR_images_reversed.rxj branches/850/samples/1-150_JDOR_string_circle.rxj branches/850/samples/1-160_JDOR_getState.rxj branches/850/samples/1-170_JDOR_lineHeight.rxj branches/850/samples/1-180_JDOR_sandGlass.rxj branches/850/samples/1-180_JDOR_sandGlass_float_colors.rxj branches/850/samples/1-180_JDOR_sandGlass_log.rxj branches/850/samples/2-110_JDOR_listShowPrintFonts.rxj branches/850/samples/2-120_JDOR_shear.rxj branches/850/samples/2-130_JDOR_animate_two_frames.rxj branches/850/samples/3-100_create_bitmap_JDOR_commands.rxj branches/850/samples/3-110_JDOR_animate_composite.rxj Modified: branches/850/bsf4oorexx.dev/bin/BSF.CLS =================================================================== --- branches/850/bsf4oorexx.dev/bin/BSF.CLS 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/bsf4oorexx.dev/bin/BSF.CLS 2022-10-31 17:10:23 UTC (rev 1015) @@ -922,7 +922,7 @@ if initialize.bsf.dir() then -- setup .bsfrexx do - .bsf4rexx~version="850.20221030" -- set version (date distribution got created) + .bsf4rexx~version="850.20221031" -- set version (date distribution got created) .bsf4rexx~opSys =opsys -- save operating system name as supplied by Rexx' PARSE SOURCE .bsf4rexx~opSys1 =opsys~left(1)~upper -- save operating system name's initial letter in uppercase .bsf4rexx~opSys2 =opsys~left(2)~upper -- save operating system name's first two letters in uppercase Modified: branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html =================================================================== --- branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html 2022-10-31 17:10:23 UTC (rev 1015) @@ -295,8 +295,8 @@ <em><a href="#cmdTranslate">translate</a></em>, <em><a href="#cmdScale">scale</a></em>, <em><a href="#cmdShear">shear</a></em> - will cause the respective factors - to be changed accordingly in the <em>Graphics2D</em>'s maintained <em>AffineTransform</em>. + will cause the respective factors to be changed accordingly in the <em>Graphics2D</em>'s + maintained <em>AffineTransform</em>. <br>The <em><a href="#cmdTransform">transform</a></em> command allows to interact with the <em>Graphics2D</em>'s <em>AffineTransform</em> to query, set or reset the @@ -496,7 +496,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdBackground"> "background" - <td colspan="3"> Queries or sets the background color to a registered color. + <td colspan="3"> Queries and optionally sets the background color to a registered color. <br>Querying the current value (no argument supplied) will return it, setting (changing) the value to a new value will return the old (previously set) value @@ -531,7 +531,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdClip"> "clip" - <td colspan="2"> Queries or sets a clipping area of an image. Returns a + <td colspan="2"> Queries and optionally sets a clipping area of an image. Returns a blank delimited string with the <em>x</em>, <em>y</em>, <em>width</em> and <em>height</em> values of the previously defined clipping rectangle (area) or <em>.nil</em> if no such area was defined @@ -604,7 +604,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "composite" - <td colspan="2"> Queries or creates and sets the composite value (an instance of the + <td colspan="2"> Queries and optionally sets or creates the composite value (an instance of the Java class <em>java.awt.AlphaComposite</em>). <br>Querying the current value (no argument supplied) will return it, setting @@ -692,7 +692,8 @@ <td colspan="2"> Draws an image which got previously loaded from the filesystem with the command <em><a href="#cmdLoadImage">loadImage</a></em> and stored internally with an <em>nickName</em> in the internal image registry, or an image that got - pushed with a <em>nickName</em> in the command <em><a href="#cmdPushImage">pushImage</a></em> + pushed with a <em>nickName</em> in the command <em><a href="#cmdPushImage">pushImage</a></em>, + or stored in a Rexx variable. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>drawImage(...)</em>. @@ -701,7 +702,8 @@ <td> <td class="argument"> nickName [bkgColor] <td> <em>nickName</em> denotes the name of an image stored in the - internal image registry. Draws as much of the image as possible. + internal image registry or the name of a Rexx variable referring + to an image. Draws as much of the image as possible. <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. @@ -709,7 +711,9 @@ <td> <td class="argument"> nickName width height [bkgColor] <td> <em>nickName</em> denotes the name of an image stored in the - internal image registry. Draws as much of the image as possible scaled to the + internal image registry or the name of a Rexx variable referring + to an image. + Draws as much of the image as possible scaled to the <em>width</em> and <em>height</em> in pixels. <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. @@ -718,48 +722,9 @@ <td> <td class="argument"> nickName width height srcX1 srcY1 srcX2 srcY2 [bkgColor] <td> <em>nickName</em> denotes the name of an image stored in the - internal image registry. Draws as much of the image as possible scaled to the - <em>width</em> and <em>height</em> in pixels, using from the image the rectangle - with the first corner with the coordinate <em>srcX1</em> and <em>srcY1</em> and - the second corner with the coordinate <em>srcX2</em> and <em>srcY2</em>. - - <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. - - - <!-- -------------------------------------------------------- --> - <tr class="CommandRowColumn"><!-- table row --> - <td class="cmdNr"> - <td class="command"> "drawImageFromVar" - <td colspan="2"> Draws an image (an instance of <em>java.awt.Image</em>) referred - to by a Rexx variable. - <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the - method <em>drawImageFromVar(...)</em>. - - <tr class="ArgumentRowColor"><td><!-- table row --> - <td> - <td class="argument"> rexxVariableName [bkgColor] - <td> <em>rexxVariableName</em> denotes the name of a Rexx variable that refers to an image - (hint: enquote the Rexx variable name). - Draws as much of the image as possible. - - <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. - - <tr class="ArgumentRowColor"><td><!-- table row --> - <td> - <td class="argument"> rexxVariableName width height [bkgColor] - <td> <em>rexxVariableName</em> denotes the name of a Rexx variable that refers to an image - (hint: enquote the Rexx variable name). + internal image registry or the name of a Rexx variable referring + to an image. Draws as much of the image as possible scaled to the - <em>width</em> and <em>height</em> in pixels. - - <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. - - <tr class="ArgumentRowColor"><td><!-- table row --> - <td> - <td class="argument"> rexxVariableName width height srcX1 srcY1 srcX2 srcY2 [bkgColor] - <td> <em>rexxVariableName</em> denotes the name of a Rexx variable that refers to an image - (hint: enquote the Rexx variable name). - Draws as much of the image as possible scaled to the <em>width</em> and <em>height</em> in pixels, using from the image the rectangle with the first corner with the coordinate <em>srcX1</em> and <em>srcY1</em> and the second corner with the coordinate <em>srcX2</em> and <em>srcY2</em>. @@ -1027,16 +992,6 @@ <td class="argument"> fontNickName <td> <em>fontNickName</em> gets uppercased and is used to look up the internal font registry for the denoted font which should be used from now on. - <br> - <em>Note:</em> if - <em>fontNickName</em> is one of the operating system independent font names - <em>"Dialog"</em>, - <em>"DialogInput"</em>, - <em>"Serif"</em>, - <em>"SansSerif"</em>, - <em>"Monospaced"</em>, then a font of this kind gets created using - the currently set <a href="#cmdFontSize"><em>fontSize</em></a> - and <a href="#cmdFontStyle"><em>fontStyle</em></a> instead. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1056,7 +1011,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdFontSize"> "fontSize" - <td colspan="2"> Queries or sets the font size to be used when loading a new + <td colspan="2"> Queries and optionally sets the font size to be used when loading a new <a href="#cmdFont"><em>font</em></a>. <br>Querying the current value (no argument supplied) will return it, setting @@ -1076,7 +1031,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdFontStyle"> "fontStyle" - <td colspan="2"> Queries or sets the font style to be used when loading a new + <td colspan="2"> Queries and optionally sets the font style to be used when loading a new <a href="#cmdFont"><em>font</em></a>. <br>Querying the current value (no argument supplied) will return it, setting @@ -1160,7 +1115,7 @@ <td class="command" id="cmdMoveTo"> "goto" <br> "location" <br> "moveTo" <br> "pos" <br> "position" - <td colspan="2"> Queries or sets <em>currX</em> and <em>currX</em> in the current image. + <td colspan="2"> Queries and optionally sets <em>currX</em> and <em>currX</em> in the current image. <br>Querying the current value (no argument supplied) will return it, setting (changing) the value to a new value will return the old (previously set) value @@ -1317,7 +1272,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdPaint"> "paint" - <td colspan="2"> Queries or sets current paint (used for filling). + <td colspan="2"> Queries and optionally sets current paint (used for filling). <br>Querying the current value (no argument supplied) will return it, setting (changing) the value to a new value will return the old (previously set) value @@ -1358,7 +1313,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdPreferredImageType"> "preferredImageType" - <td colspan="2"> Queries or sets the preferred image type used for creating new images + <td colspan="2"> Queries and optionally sets the preferred image type used for creating new images (cf. <a href="#cmdNew">new</a> command). Returns the image type via the Rexx variable <em>RC</em> upon return from this command. @@ -1391,13 +1346,15 @@ <td class="cmdNr"> <td class="command"> "printImage" <td colspan="2"> Uses the default printer to print the image. If the <em>imageNickName</em> - is supplied, it gets uppercased and used to look it up in the image registry and prints it. + is supplied, it gets uppercased and used to look it up in the image registry or if not + found from a Rexx variable of the same name and prints it. <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> imageNickName <td> optional <em>imageNickName</em> is uppercased and used to look up the image from the internal - registry that should get printed. + registry or the name of a Rexx variable referring to an image of type <em>BufferedImage</em> + that should get printed. <!-- -------------------------------------------------------- --> @@ -1404,7 +1361,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "printPos" - <td colspan="2"> Queries or sets the left upper hand corner on the page where the image should + <td colspan="2"> Queries and optionally sets the left upper hand corner on the page where the image should be drawn to. This command has no effect if <em>printScaleToPage</em> was set to <em>.true</em> (<em>1</em>). @@ -1440,7 +1397,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "printScaleToPage" - <td colspan="2"> Queries or sets the value. + <td colspan="2"> Queries and optionally sets the value. <br>Querying the current value (no argument supplied) will return it, setting (changing) the value to a new value will return the old (previously set) value @@ -1568,8 +1525,12 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdScale"> "scale" - <td colspan="2"> Queries or sets the scale factor for the <em>y</em> and <em>y</em> axis. - The command returns the scale values at the time of invocation. + <td colspan="2"> Queries and optionally changes ("concatenates") the scale factor for + the <em>x</em> and <em>y</em> axis. The command returns the scale values + at the time of invocation. + <br>Cf. the Java documentation for the Java class <em>Graphics2D</em> and the + method <em>scale(...)</em>. + <br>To set these factors to absolute values use the <a href="#cmdTransform">transform</a> command. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1609,8 +1570,12 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdShear"> "shear" - <td colspan="2"> Queries or sets the shear (skew) factor for the <em>y</em> and <em>y</em> - axis. The command returns the shear values at the time of invocation. + <td colspan="2"> Queries and optionally changes ("concatenates") the shear (skew) factor for + the <em>x</em> and <em>y</em> axis. The command returns the shear values + at the time of invocation. + <br>Cf. the Java documentation for the Java class <em>Graphics2D</em> and the + method <em>shear(...)</em>. + <br>To set these factors to absolute values use the <a href="#cmdTransform">transform</a> command. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1700,6 +1665,10 @@ to <em>currX</em> and <em>y</em> pixels to <em>currY</em>. The command returns the translate values at the time of invocation. + <br>Cf. the Java documentation for the Java class <em>Graphics2D</em> and the + method <em>translate(...)</em>. + <br>To set these factors to absolute values use the <a href="#cmdTransform">transform</a> command. + <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> x [y] @@ -1720,8 +1689,8 @@ calculate the effective <em>x</em> and <em>y</em> values for the target device according to this formula: - <p><code> x' = scaleX*x + shearX*y + translateX </code> - <br><code> y' = scaleY*y + shearY*x + translateY </code> + <p><code> x' = translateX + scaleX*x + shearX*y </code> + <br><code> y' = translateY + scaleY*y + shearY*x </code> <p>Cf. the Java documentation for the Java classes <em>java.awt.geom.AffineTransform</em>, <em>java.awt.Graphics2D</em> and the methods <em>getTransform()</em>, <em>setTransform(...)</em>. @@ -1746,7 +1715,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "winAlwaysOnTop" - <td colspan="2"> Queries or sets the value. + <td colspan="2"> Queries and optionally sets the value. <br>Querying the current value (no argument supplied) will return it, setting (changing) the value to a new value will return the old (previously set) value @@ -1796,7 +1765,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "winFrame" - <td colspan="2"> Queries or sets the value. + <td colspan="2"> Queries and optionally sets the value. <br>Querying the current value (no argument supplied) will return it, setting (changing) the value to a new value will return the old (previously set) value @@ -1836,7 +1805,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "winLocation"<br> "winMoveTo" - <td colspan="2"> Queries or sets the location of the frame (window) that shows the current image. + <td colspan="2"> Queries and optionally sets location of the frame (window) that shows the current image. <br>Querying the current value (no argument supplied) will return it, setting (changing) the value to a new value will return the old (previously set) value @@ -1881,7 +1850,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "winSize" - <td colspan="2"> Queries or sets the size of the frame (window) that displays + <td colspan="2"> Queries and optionally sets the size of the frame (window) that displays the current image. <br>Querying the current value (no argument supplied) will return it, setting @@ -1902,7 +1871,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "winTitle" - <td colspan="2"> Queries or sets the title of the frame (window) that displays + <td colspan="2"> Queries and optionally sets the title of the frame (window) that displays the current image. <br>Querying the current value (no argument supplied) will return it, setting @@ -1950,7 +1919,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "winUpdate" - <td colspan="2"> Queries or sets the value. If set to <em>.true</em>, the frame (window) + <td colspan="2"> Queries and optionally sets the value. If set to <em>.true</em>, the frame (window) that displays the current image will be updated each time a change occurs in the current image, otherwise the frame (window) does not get visually updated. @@ -1974,8 +1943,8 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "winVisible" - <td colspan="2"> Queries or sets the value. If set to <em>.true</em>, the frame (window) - that displays the current image will be shown, otherwise it will be hided. + <td colspan="2"> Queries and optionally sets the value. If set to <em>.true</em>, the frame (window) + that displays the current image will be shown, otherwise it will be hidden. <br>Querying the current value (no argument supplied) will return it, setting @@ -2005,7 +1974,7 @@ <center> <hr width="75%"> <small> - JDOC synopsis of commands, version: 100.20221030 + JDOC synopsis of commands, version: 100.20221031 <br>Acknowledgement: the author wishes to thank DI Walter Pachl <br>for his help in testing and proof reading </small> Modified: branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java =================================================================== --- branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java 2022-10-31 17:10:23 UTC (rev 1015) @@ -10,7 +10,7 @@ author: Rony G. Flatscher date: 2022-09-05/2022-10-05 - version: 003.20221030 + version: 003.20221031 license: Apache license 2.0 license: @@ -74,6 +74,12 @@ - "font": fixed bug if using one of the operating system independent (logical) fonts named "Dialog", "DialogInput", "Serif", "SansSerif", "Monospaced": now honors also fontSize and fontStyle + 2022-10-31: - fix COMPOSITE (correct int value caused exception) + - removed command DRAW_IMAGE_FROM_VAR_NAME, instead changed DRAW_IMAGE to + try to fetch the image from a Rexx variable named as the nickName, if an + image cannot be found in the registry by that nickname + - PRINT_IMAGE now also can take an image (must be a BufferedImage) from a Rexx + variable named after the nickname (only if not found in the image registry) */ /* Sample program in ooRexx (temporarily): @@ -261,7 +267,7 @@ /* static definitions */ // default image sizes - static final public String version = "005.20221030"; + static final public String version = "005.20221031"; static final private int prefWidth = 500; static final private int prefHeight = 500; static private int prefImageType = BufferedImage.TYPE_INT_ARGB; // default with alpha (only png supported) @@ -1102,10 +1108,25 @@ { String name = arrCommand[1]; // get nickname tmpImage = hmImages.get(name.toUpperCase()); +/* --- if (tmpImage==null) { throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\""); } +-- */ + if (tmpImage==null) + { + try + { + tmpImage = (BufferedImage) getContextVariable(slot, name); // try to get from a Rexx variable + } + catch (Throwable t) {} + if (tmpImage==null) + { + throw new IllegalArgumentException("image (must be a BufferedImage) with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\" or \"pushImage "+name+"\" or assign an BufferedImage to a Rexx variable named \""+name+"\""); + } + } + canonical = canonical+" "+name; } if (isOR) @@ -1843,13 +1864,13 @@ { throw new IllegalArgumentException("unknown value for \"rule\" argument: \""+arrCommand[1]+"\""); } - intRule=alphaComposites.get(ruleName); + intRule=val; } if (isOR) { canonical=canonical+" "+ - (bUseNames4canonical ? alphaCompositesInt2Name.get(ruleName) : ruleName) ; + (bUseNames4canonical ? alphaCompositesInt2Name.get(intRule) : intRule) ; } AlphaComposite ac = null; @@ -2249,6 +2270,7 @@ if (arrCommand.length==2 ) { font = hmFonts.get(fontNickName.toUpperCase()); +/* -- 2022-10-31 (injected the day before): remove, as it should be possible to use these fonts with a nickname if (font==null) { // maybe one of the five operating system independent fonts? @@ -2266,6 +2288,18 @@ return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-10", errMsg ); } } +-- */ + if (font==null) + { + String errMsg="font with the supplied nickname \""+fontNickName+"\" is not registered"; + if (isOR) + { + writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); + } + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-10", errMsg ); + } + + bufGC.setFont(font); if (isOR) { @@ -2762,7 +2796,7 @@ // rgf, 2022-10-21: command to allow drawing an image referred to by a rexx Variable - case DRAW_IMAGE_FROM_REXX_VAR: // "drawImageFromVar rexxVarName [bkgColor] | rexxVarName width height [bkgColor] | rexxVarName width height srcX1 srcY1 srcX2 srcY2 [bkgColor]" +// case DRAW_IMAGE_FROM_REXX_VAR: // "drawImageFromVar rexxVarName [bkgColor] | rexxVarName width height [bkgColor] | rexxVarName width height srcX1 srcY1 srcX2 srcY2 [bkgColor]" case DRAW_IMAGE: // "drawImage nickName [bkgColor] | nickName width height [bkgColor] | nickName width height srcX1 srcY1 srcX2 srcY2 [bkgColor]" { int argNum = arrCommand.length; @@ -2783,17 +2817,17 @@ img = hmImages.get(name.toUpperCase()); if (img==null) { - throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\" or \"pushImage "+name+"\""); + try + { + img = (Image) getContextVariable(slot, name); // try to get from a Rexx variable + } + catch (Throwable t) {} + if (img==null) + { + throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\" or \"pushImage "+name+"\" or assign an image to a Rexx variable named \""+name+"\""); + } } } - else // fetch from the denoted Rexx variable - { - img = (Image) getContextVariable(slot, name); - if (img==null) - { - throw new IllegalArgumentException("Rexx variable named \""+name+"\" does not refer to an image"); - } - } int width=0, height=0, srcX1=0, srcY1=0, srcX2=0, srcY2=0; String colorNickName=null; @@ -3617,8 +3651,6 @@ DRAW_ARC ( "drawArc" ) , // "drawArc width height startAngle arcAngle" DRAW_IMAGE ( "drawImage" ) , // "drawImage nickName [bkgColor] | nickName width height [bkgColor] | nickName width height srcX1 srcY1 srcX2 srcY2 [bkgColor]" - DRAW_IMAGE_FROM_REXX_VAR ( "drawImageFromVar" ) , // "drawImageFromVar rexxVarName [bkgColor] | rexxVarName width height [bkgColor] | rexxVarName width height srcX1 srcY1 srcX2 srcY2 [bkgColor]" - DRAW_LINE ( "drawLine" ) , // "drawLine toX toY" DRAW_OVAL ( "drawOval" ) , // "drawOval width height" DRAW_POLYGON ( "drawPolygon" ) , // "drawPolygon []xPoints []yPoints nPoints Modified: branches/850/createDistributionForBSF4ooRexx8.cmd =================================================================== --- branches/850/createDistributionForBSF4ooRexx8.cmd 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/createDistributionForBSF4ooRexx8.cmd 2022-10-31 17:10:23 UTC (rev 1015) @@ -36,9 +36,9 @@ @echo adding javax.servlet.jsp and javax.servlet.http to CLASSPATH set CLASSPATH=%CLASSPATH%;F:\download\java\java2s.com-javax.servlet.jsp\javax.servlet.jsp.jar;F:\download\java\java2s.com-javax.servlet.jsp\javax.servlet-3.0.0.v201112011016.jar -set releaseDate=20221030 -set runDate=20221030 -set doc_date=20221030 +set releaseDate=20221031 +set runDate=20221031 +set doc_date=20221031 @rem values to use for creating the BSF jarfile @rem set bsfDate=20090910 Modified: branches/850/samples/1-120_JDOR_bw.rxj =================================================================== --- branches/850/samples/1-120_JDOR_bw.rxj 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/samples/1-120_JDOR_bw.rxj 2022-10-31 17:10:23 UTC (rev 1015) @@ -12,7 +12,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -44,14 +44,15 @@ winShow -- show frame -- draw two lines forming a big X drawLine 300 500 -- currX=0, currY=0 -goto 300 0 -- currX=300, currY=0 +moveTo 300 0 -- currX=300, currY=0 drawLine 0 500 -- draw a rectangle at the center of the bitmap -goto (300-50)/2 (500-50)/2 +moveTo (300-50)/2 (500-50)/2 fillRect 50 50 drawRect 50 50 -- draw a test at the lower half of the bitmap -goto 50 450 +moveTo 50 450 drawString "Hello, world via JDOR ..." +say "'sleep 3' ..." sleep 3 -- sleep for three seconds -- say "press enter to end.";parse pull \ No newline at end of file Modified: branches/850/samples/1-120_JDOR_color_text.rxj =================================================================== --- branches/850/samples/1-120_JDOR_color_text.rxj 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/samples/1-120_JDOR_color_text.rxj 2022-10-31 17:10:23 UTC (rev 1015) @@ -12,7 +12,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -43,11 +43,11 @@ winShow -- show frame -- draw two lines forming a big X drawLine 300 500 -- currX=0, currY=0 -goto 300 0 -- currX=300, currY=0 +moveTo 300 0 -- currX=300, currY=0 color red drawLine 0 500 -- draw a rectangle at the center of the bitmap -goto (300-50)/2 (500-50)/2 +moveTo (300-50)/2 (500-50)/2 color green fillRect 50 50 @@ -55,9 +55,10 @@ color blue drawRect 50 50 -- draw a test at the lower half of the bitmap -goto 50 450 +moveTo 50 450 color somePurple 127 46 111 drawString "Hello, world via JDOR ..." +say "'sleep 3' ..." sleep 3 -- sleep for three seconds -- say "press enter to end.";parse pull ::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available Modified: branches/850/samples/1-130_JDOR_rotate.rxj =================================================================== --- branches/850/samples/1-130_JDOR_rotate.rxj 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/samples/1-130_JDOR_rotate.rxj 2022-10-31 17:10:23 UTC (rev 1015) @@ -13,7 +13,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -42,8 +42,8 @@ new 500 500 -- create new bitmap winShow -- show frame -- draw two lines forming a big X -goto 100 150 -- currX=100, currY=150 - -- define and set color, register it with the name "saddlebrown50" +moveTo 100 150 -- currX=100, currY=150 + -- define and set color, register it with the name "saddlebrown50" color saddlebrown50 139 69 19 127 -- R,G,B,alpha=127 (50 % transparency) fillRect 50 50 -- first fill color blue -- set color to blue (predefined) @@ -52,7 +52,7 @@ drawOval 50 50 -- draw border -- draw a rectangle at the center of the bitmap translate 260 250 -- move origin 0,0 to (260,250) -goto 0 0 -- x=0, y=0 (effectively: x=0+260, y=0+250) +moveTo 0 0 -- x=0, y=0 (effectively: x=0+260, y=0+250) rotate 45 -- rotate by 45 degrees (clock wise starting out from 3 o'clock) color saddlebrown50 -- use registered color named saddlebrown50 [R,G,B,alpha=127 (50 % transparency)] fillRect 50 75 -- fill 50% transparency @@ -61,6 +61,7 @@ drawRect 50 75 -- draw border in blue color red -- set color to red (predefined) drawOval 50 75 -- draw border in red +say "'sleep 5' ..." sleep 5 -- sleep for five seconds -- say "press enter to end.";parse pull Modified: branches/850/samples/1-140_JDOR_images.rxj =================================================================== --- branches/850/samples/1-140_JDOR_images.rxj 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/samples/1-140_JDOR_images.rxj 2022-10-31 17:10:23 UTC (rev 1015) @@ -11,7 +11,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -42,13 +42,14 @@ winShow -- show frame loadImage b4r_logo bsf4oorexx_256.png drawImage b4r_logo 50 50 -goto 200 200 +moveTo 200 200 loadImage orx_logo oorexx_256.png drawImage orx_logo 75 75 -goto 400 400 +moveTo 400 400 say "rc:" rc -- rc contains the return value loadImage ooo_logo oorexx4ooo_256.png drawImage ooo_logo 100 100 +say "'sleep 5' ..." sleep 5 -- sleep for five seconds -- say "press enter to end.";parse pull Modified: branches/850/samples/1-140_JDOR_images_reversed.rxj =================================================================== --- branches/850/samples/1-140_JDOR_images_reversed.rxj 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/samples/1-140_JDOR_images_reversed.rxj 2022-10-31 17:10:23 UTC (rev 1015) @@ -12,7 +12,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -44,13 +44,14 @@ "scale 1 -1" -- flip y-axis (positive y grow up, however ...) loadImage b4r_logo bsf4oorexx_256.png drawImage b4r_logo 50 50 -goto 200 200 +moveTo 200 200 loadImage orx_logo oorexx_256.png drawImage orx_logo 75 75 -goto 400 400 +moveTo 400 400 say "rc:" rc -- rc contains the return value loadImage ooo_logo oorexx4ooo_256.png drawImage ooo_logo 100 100 +say "'sleep 5' ..." sleep 5 -- sleep for five seconds -- say "press enter to end.";parse pull Modified: branches/850/samples/1-150_JDOR_string_circle.rxj =================================================================== --- branches/850/samples/1-150_JDOR_string_circle.rxj 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/samples/1-150_JDOR_string_circle.rxj 2022-10-31 17:10:23 UTC (rev 1015) @@ -11,7 +11,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -38,13 +38,12 @@ call addJdorHandler -- load and add the Java Rexx command handler, using default name: JDOR address jdor -- set default environment to JDOR winShow -- will implicitly create a 500x500 bitmap -goto 450 450 +moveTo 450 450 loadImage orx oorexx_256.png drawImage orx 50 50 color blue -goto 0 20 +moveTo 0 20 drawString "Hello at:" .dateTime~new -goto translate 250 250 -- move 0,0 to center color red fontstyle 3 -- bold=1 + italic=2 @@ -54,7 +53,7 @@ fontstyle 0 -- normal fontsize 14 -- size=14 font mono "Monospaced" -goto 10 0 -- currX=10, currY=0 +moveTo 10 0 -- currX=10, currY=0 angle=30 do i=2 to 360/angle rotate angle -- rotates entire image @@ -62,6 +61,7 @@ if random(0,1) then do; color red; font serif1; end else do; "color gray"; "font mono" ; end end +say "'sleep 5' ..." sleep 5 -- sleep for five seconds -- say "press enter to end.";parse pull ::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available \ No newline at end of file Modified: branches/850/samples/1-160_JDOR_getState.rxj =================================================================== --- branches/850/samples/1-160_JDOR_getState.rxj 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/samples/1-160_JDOR_getState.rxj 2022-10-31 17:10:23 UTC (rev 1015) @@ -12,7 +12,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -42,11 +42,11 @@ winShow -- show frame -- draw two lines forming a big X drawLine 300 500 -- from currX=0, currY=0 to x2=300 y2=500 -pos 300 0 -- alias "goto": currX=300, currY=0 +pos 300 0 -- alias for "moveTo": currX=300, currY=0 color red drawLine 0 500 -- from currX=300, currY=0 to x2=0 y2=500 -- draw a rectangle at the center of the bitmap -goto (300-50)/2 (500-50)/2 -- currX= +goto (300-50)/2 (500-50)/2 -- alias for "moveTo": currX=125, currY=225 say "rc:" pp(rc) ".rs="pp(.rs) color saddlebrown50 139 69 19 127 -- R,G,B,alpha=127 (50 % transparency) fillRect 50 50 @@ -62,6 +62,7 @@ do counter c idx over currState~allIndexes~sort say " " right(c,2)":" left(pp(idx),20,".") pp(currState[idx]) end +say "'sleep 5' ..." sleep 5 -- sleep for five seconds -- say "press enter to end.";parse pull ::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available \ No newline at end of file Modified: branches/850/samples/1-170_JDOR_lineHeight.rxj =================================================================== --- branches/850/samples/1-170_JDOR_lineHeight.rxj 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/samples/1-170_JDOR_lineHeight.rxj 2022-10-31 17:10:23 UTC (rev 1015) @@ -13,7 +13,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -46,12 +46,12 @@ -- draw two lines forming a big X drawLine width height -- from currX=0, currY=0 color red -- set the color to red (preregistered with nickname "RED") -goto width 0 -- currX=220, currY=0 +moveTo width 0 -- currX=220, currY=0 say "--> rc="pp(rc) -- RC refers to the previous command's result: "220 0" (currX=220, currY=0) drawLine 0 height -- from currX=250, currY=0 -- draw a rectangle at the center of the bitmap len = 50 -- drawing a rectangle with each side being 50 px (a square) -goto (width-len)/2 (height-len)/2 -- go to the center minus half of the square's side lengths +moveTo (width-len)/2 (height-len)/2 -- go to the center minus half of the square's side lengths color green -- set color to green (preregistered with nickname "GREEN") fillRect len len -- fill the square with the green color stroke str3 3 -- set line stroke to 3 points width, store it with nickname "STR3" @@ -70,11 +70,12 @@ say "lineHeight: " pp(lineHeight) -- show line height text=("Hello, Rexx world ...", "... from JDOR ...", "(Rexx command handler)") -- array of 3 strings do counter c i=0 to 30 by lineHeight -- iterate over array of strings - goto 50 (newY+i) -- set position + moveTo 50 (newY+i) -- set position drawString text[c] -- draw the string end -- save the current image saveImage "1-170_JDOR_lineHeight.png" -- save image to file "1-170_JDOR_lineHeight.png" +say "'sleep 3.123' ..." sleep 3.123 -- sleep for 3.123 seconds ::requires "jdor.cls" -- Rexx package that defines the public routine addJdorHandler() Modified: branches/850/samples/1-180_JDOR_sandGlass.rxj =================================================================== --- branches/850/samples/1-180_JDOR_sandGlass.rxj 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/samples/1-180_JDOR_sandGlass.rxj 2022-10-31 17:10:23 UTC (rev 1015) @@ -12,7 +12,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -55,11 +55,12 @@ h = height-m color colors[i] stroke strokes[i] - goto m m; drawLine w m - goto w m; drawLine m h - goto m h; drawLine w h - goto w h; drawLine m m + moveTo m m; drawLine w m + moveTo w m; drawLine m h + moveTo m h; drawLine w h + moveTo w h; drawLine m m end +say "'sleep 3' ..." sleep 3 -- sleep for three seconds -- say 'hit enter to continue...'; parse pull . Modified: branches/850/samples/1-180_JDOR_sandGlass_float_colors.rxj =================================================================== --- branches/850/samples/1-180_JDOR_sandGlass_float_colors.rxj 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/samples/1-180_JDOR_sandGlass_float_colors.rxj 2022-10-31 17:10:23 UTC (rev 1015) @@ -13,7 +13,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -71,11 +71,12 @@ h = height-m color colors[i] stroke strokes[i] - goto m m; drawLine w m - goto w m; drawLine m h - goto m h; drawLine w h - goto w h; drawLine m m + moveTo m m; drawLine w m + moveTo w m; drawLine m h + moveTo m h; drawLine w h + moveTo w h; drawLine m m end +say "'sleep 3' ..." sleep 3 -- sleep for three seconds -- say 'hit enter to continue...'; parse pull . Modified: branches/850/samples/1-180_JDOR_sandGlass_log.rxj =================================================================== --- branches/850/samples/1-180_JDOR_sandGlass_log.rxj 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/samples/1-180_JDOR_sandGlass_log.rxj 2022-10-31 17:10:23 UTC (rev 1015) @@ -14,7 +14,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - added hint about sleeping time last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -59,13 +59,14 @@ h = height-m "color" colors[i] -- set defined color "STROKE" strokes[i] -- set defined stroke - "PoS" m m; "DRAWLINE" w m -- sets the x and y position - "GOTO" w m; "drawline" m h -- GOTO is a synonym for POS - "pos" m h; "DRAWLINE" w h -- sets the x and y position - "GOTO" w h; "drawline" m m -- GOTO is a synonym for POS + "PoS" m m; "DRAWLINE" w m -- POS is a synonym for MOVETO sets the x and y position + "GOTO" w m; "drawline" m h -- GOTO is a synonym for MOVETO + "pos" m h; "DRAWLINE" w h -- POS is a synonym for MOVETO sets the x and y position + "GOTO" w h; "drawline" m m -- GOTO is a synonym for MOVETO end s~close saveImage "1-180_JDOR_sandGlass.png" -- "png" allows for ARGB (RGB colors with alpha (transparency9) +say "'sleep 3' ..." sleep 3 -- sleep for three seconds ::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available \ No newline at end of file Modified: branches/850/samples/2-110_JDOR_listShowPrintFonts.rxj =================================================================== --- branches/850/samples/2-110_JDOR_listShowPrintFonts.rxj 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/samples/2-110_JDOR_listShowPrintFonts.rxj 2022-10-31 17:10:23 UTC (rev 1015) @@ -20,6 +20,7 @@ Changes: 2022-10-20, ---rgf: adjust for corrected drawString command, simplify footer, let footer stand out by being printed on white background, add total number of pages + 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -96,11 +97,11 @@ end fontName=allFontFamilies[i] -- get current font family name (Rexx) y=currLine*lineHeight -- calculate y (Rexx) - goto xCol1 y -- goto x y (JDOR command) + moveTo xCol1 y -- moveTo x y (JDOR command) say i~right(3)":" fontName -- show fontName on command line (Rexx) font mono -- use already loaded monotype font (JDOR command) drawString i~right(3)":" fontName -- write font family name (JDOR command) - goto xCol2 y -- goto x y (JDOR command) + moveTo xCol2 y -- moveTo x y (JDOR command) font "font"i fontName -- load and use font family font (JDOR command) drawString "Hello world, this is ooRexx using the JDOR command handler ..." -- (JDOR command) currLine+=1 -- increase line (Rexx) @@ -112,6 +113,7 @@ say say "you have a total of" pp(nrItems) "fonts installed on your system!" +say "'sleep 3.009' ..." "sleep" 3 + .009 -- let us look at the last image for three plus 9/1000 more seconds ;) (JDOR command) exit @@ -118,13 +120,13 @@ printFooter: tmpFileName = fileName || pageNr"."fileType -- define file name background white -- set background to white (by clearRect command below) - goto 0 (lines*lineHeight+9) + moveTo 0 (lines*lineHeight+9) clearRect width (2*lineHeight+3) y=(lines+2)*lineHeight -- calc footer position fontSize 10; font dialog "Dialog" -- set font size and font - goto xCol1 y; drawString "page" pageNr"/"totalPages "(as of:" .dateTime~new")" -- write footer part 1 - goto xCol2 y; drawString tmpFileName -- write footer part 2 + moveTo xCol1 y; drawString "page" pageNr"/"totalPages "(as of:" .dateTime~new")" -- write footer part 1 + moveTo xCol2 y; drawString tmpFileName -- write footer part 2 background oldBackground -- winUpdate .true-- update Frame (JDOR command) say "saving sample to:" pp(tmpFileName) Modified: branches/850/samples/2-120_JDOR_shear.rxj =================================================================== --- branches/850/samples/2-120_JDOR_shear.rxj 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/samples/2-120_JDOR_shear.rxj 2022-10-31 17:10:23 UTC (rev 1015) @@ -62,11 +62,12 @@ color blue -- change color call drawFigure -- draw the same figure as above -say "Press enter to end ..." -parse pull . +say "sleep 5 ..." +sleep 5 +-- say "Press enter to end ..."; parse pull . exit -drawFigure: procedure -- moves origin, draws axes with right and down error, draws rectangle +drawFigure: procedure -- moves origin, draws axes with right and down arrow, draws rectangle lineLength = 54 arrowLength = 4 tickSize = 4 Modified: branches/850/samples/2-130_JDOR_animate_two_frames.rxj =================================================================== --- branches/850/samples/2-130_JDOR_animate_two_frames.rxj 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/samples/2-130_JDOR_animate_two_frames.rxj 2022-10-31 17:10:23 UTC (rev 1015) @@ -92,7 +92,7 @@ say "image~toString:" pp(jImage~toString) say -- note the name of a Rexx variable needs to be quoted, otherwise its value gets used -address sdor drawImageFromVar "jImage" -- use image from Rexx variable named "jImage" +address sdor drawImage "jImage" -- use image from Rexx variable named "jImage" sleep 0.75 -- sleep (wait) a bit sleepTime=1/30 -- appr. 30 updates per second @@ -101,13 +101,15 @@ do i=0 to 360+90 by 5 -- rotate 1 1/4 rounds ... round+=1 address sdor rotate i center -- rotate transform - address sdor drawImageFromVar "jImage" -- draw image referred to by the Rexx variable "jImage" + address sdor drawImage "jImage" -- draw image referred to by the Rexx variable "jImage" sleep sleepTime -- sleeping causes animation effect end say "finished after" pp(round) "rotations" -say "press enter to end ..." -parse pull +say "'sleep 5' ..." +sleep 5 +-- say "press enter to end ..."; parse pull + ::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available Modified: branches/850/samples/3-100_create_bitmap_JDOR_commands.rxj =================================================================== --- branches/850/samples/3-100_create_bitmap_JDOR_commands.rxj 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/samples/3-100_create_bitmap_JDOR_commands.rxj 2022-10-31 17:10:23 UTC (rev 1015) @@ -20,7 +20,7 @@ Author: Rony G. Flatscher, Wien University - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -87,18 +87,18 @@ do counter c i over positions tmpX=i[1] tmpY=i[2] - goto tmpX tmpY + moveTo tmpX tmpY fileName = images[c] imageFromFile="img_"c loadImage imageFromFile fileName drawImage imageFromFile - goto tmpX tmpY+10 + moveTo tmpX tmpY+10 drawString fileName -- drawing at 50% of size either on the right or left of the original sized picture if c=3 then tmpX -= 256 else tmpX += 256+128 - goto tmpX tmpY + moveTo tmpX tmpY drawImage imageFromFile tmpX+128 tmpY+128 0 0 256 256 end -- sleep 0.5 @@ -107,11 +107,11 @@ -- draw a string (text) using the current (default) font color green text="Hello, world, it is:" .dateTime~new -goto (0+borderWidth) (height/2-20) +moveTo (0+borderWidth) (height/2-20) drawString text -- draw a thick line underneath stroke stroke5 -goto (0+borderWidth) (height/2-10) +moveTo (0+borderWidth) (height/2-10) drawLine 260 (height/2-10) -- sleep 0.5 @@ -135,7 +135,7 @@ end fontSize size font "font"c fontName - goto xPos (yStart+(size*c)+5) + moveTo xPos (yStart+(size*c)+5) text=c"." fontName hint"," size "points" drawString text end @@ -149,7 +149,7 @@ -- draw a line from upper right hand corner down: coordinates must be integers! color teal stroke dashedStroke -goto (width-borderWidth) (0+borderWidth) +moveTo (width-borderWidth) (0+borderWidth) drawLine (width-format(width/17,,0)) 200 -- move 0,0 co-ordinate relative to current position (i.e. to center) @@ -160,7 +160,7 @@ do counter c i=1 to 360/15 -- 24 steps! rotate 15 -- rotate by 15\xB0 text="--> Hello, world, it is:" .dateTime~new "<-- #" c "("c*15"\xB0) " - goto 0 0 + moveTo 0 0 drawString text end @@ -174,7 +174,7 @@ -- draw an ellipse (if rectangle is a square, then a circle gets drawn) color magenta stroke dashedStroke -goto 0 50 +moveTo 0 50 drawOval 275 75 -- sleep 0.5 @@ -189,7 +189,7 @@ s = r*2 x = borderWidth+width/2-r y = borderWidth+height/2-r -goto x y +moveTo x y drawOval s s -- sleep 0.5 Modified: branches/850/samples/3-110_JDOR_animate_composite.rxj =================================================================== --- branches/850/samples/3-110_JDOR_animate_composite.rxj 2022-10-31 17:09:43 UTC (rev 1014) +++ branches/850/samples/3-110_JDOR_animate_composite.rxj 2022-10-31 17:10:23 UTC (rev 1015) @@ -105,14 +105,15 @@ end end -moveTo 25 200 +moveTo 75 200 color blue fontSize 18 -font "Serif" -drawString "Wer are done, goodbye! (press enter to end ...)" +font f1 "Serif" +drawString "Wer are done, goodbye! ('sleep 5' ...)" +say "'sleep 5' ..." +sleep 5 -say "press enter to end ..." -parse pull +-- say "press enter to end ..."; parse pull ::requires "BSF.CLS" -- get ooRexx-Java bridge This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <or...@us...> - 2022-10-31 17:09:46
|
Revision: 1014 http://sourceforge.net/p/bsf4oorexx/code/1014 Author: orexx Date: 2022-10-31 17:09:43 +0000 (Mon, 31 Oct 2022) Log Message: ----------- 20221031 correct composite command, fold (and remove) drawImageFromVarName into drawImage and printImage, update samples slightly. Modified Paths: -------------- sandbox/rgf/jdor/JavaDrawingHandler.java sandbox/rgf/jdor/doc/jdor_doc.html sandbox/rgf/jdor/doc/jdor_doc_sample.png sandbox/rgf/jdor/doc/jdor_doc_sample.rex sandbox/rgf/jdor/samples/1-120_JDOR_bw.rxj sandbox/rgf/jdor/samples/1-120_JDOR_color_text.rxj sandbox/rgf/jdor/samples/1-130_JDOR_rotate.rxj sandbox/rgf/jdor/samples/1-140_JDOR_images.rxj sandbox/rgf/jdor/samples/1-140_JDOR_images_reversed.rxj sandbox/rgf/jdor/samples/1-150_JDOR_string_circle.rxj sandbox/rgf/jdor/samples/1-160_JDOR_getState.rxj sandbox/rgf/jdor/samples/1-170_JDOR_lineHeight.rxj sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass.rxj sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass_float_colors.rxj sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass_log.rxj sandbox/rgf/jdor/samples/2-110_JDOR_listShowPrintFonts.rxj sandbox/rgf/jdor/samples/2-120_JDOR_shear.rxj sandbox/rgf/jdor/samples/2-130_JDOR_animate_two_frames.rxj sandbox/rgf/jdor/samples/3-100_create_bitmap_JDOR_commands.rxj sandbox/rgf/jdor/samples/3-110_JDOR_animate_composite.rxj Modified: sandbox/rgf/jdor/JavaDrawingHandler.java =================================================================== --- sandbox/rgf/jdor/JavaDrawingHandler.java 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/JavaDrawingHandler.java 2022-10-31 17:09:43 UTC (rev 1014) @@ -10,7 +10,7 @@ author: Rony G. Flatscher date: 2022-09-05/2022-10-05 - version: 003.20221030 + version: 003.20221031 license: Apache license 2.0 license: @@ -74,6 +74,12 @@ - "font": fixed bug if using one of the operating system independent (logical) fonts named "Dialog", "DialogInput", "Serif", "SansSerif", "Monospaced": now honors also fontSize and fontStyle + 2022-10-31: - fix COMPOSITE (correct int value caused exception) + - removed command DRAW_IMAGE_FROM_VAR_NAME, instead changed DRAW_IMAGE to + try to fetch the image from a Rexx variable named as the nickName, if an + image cannot be found in the registry by that nickname + - PRINT_IMAGE now also can take an image (must be a BufferedImage) from a Rexx + variable named after the nickname (only if not found in the image registry) */ /* Sample program in ooRexx (temporarily): @@ -261,7 +267,7 @@ /* static definitions */ // default image sizes - static final public String version = "005.20221030"; + static final public String version = "005.20221031"; static final private int prefWidth = 500; static final private int prefHeight = 500; static private int prefImageType = BufferedImage.TYPE_INT_ARGB; // default with alpha (only png supported) @@ -1102,10 +1108,25 @@ { String name = arrCommand[1]; // get nickname tmpImage = hmImages.get(name.toUpperCase()); +/* --- if (tmpImage==null) { throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\""); } +-- */ + if (tmpImage==null) + { + try + { + tmpImage = (BufferedImage) getContextVariable(slot, name); // try to get from a Rexx variable + } + catch (Throwable t) {} + if (tmpImage==null) + { + throw new IllegalArgumentException("image (must be a BufferedImage) with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\" or \"pushImage "+name+"\" or assign an BufferedImage to a Rexx variable named \""+name+"\""); + } + } + canonical = canonical+" "+name; } if (isOR) @@ -1843,13 +1864,13 @@ { throw new IllegalArgumentException("unknown value for \"rule\" argument: \""+arrCommand[1]+"\""); } - intRule=alphaComposites.get(ruleName); + intRule=val; } if (isOR) { canonical=canonical+" "+ - (bUseNames4canonical ? alphaCompositesInt2Name.get(ruleName) : ruleName) ; + (bUseNames4canonical ? alphaCompositesInt2Name.get(intRule) : intRule) ; } AlphaComposite ac = null; @@ -2249,6 +2270,7 @@ if (arrCommand.length==2 ) { font = hmFonts.get(fontNickName.toUpperCase()); +/* -- 2022-10-31 (injected the day before): remove, as it should be possible to use these fonts with a nickname if (font==null) { // maybe one of the five operating system independent fonts? @@ -2266,6 +2288,18 @@ return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-10", errMsg ); } } +-- */ + if (font==null) + { + String errMsg="font with the supplied nickname \""+fontNickName+"\" is not registered"; + if (isOR) + { + writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); + } + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-10", errMsg ); + } + + bufGC.setFont(font); if (isOR) { @@ -2762,7 +2796,7 @@ // rgf, 2022-10-21: command to allow drawing an image referred to by a rexx Variable - case DRAW_IMAGE_FROM_REXX_VAR: // "drawImageFromVar rexxVarName [bkgColor] | rexxVarName width height [bkgColor] | rexxVarName width height srcX1 srcY1 srcX2 srcY2 [bkgColor]" +// case DRAW_IMAGE_FROM_REXX_VAR: // "drawImageFromVar rexxVarName [bkgColor] | rexxVarName width height [bkgColor] | rexxVarName width height srcX1 srcY1 srcX2 srcY2 [bkgColor]" case DRAW_IMAGE: // "drawImage nickName [bkgColor] | nickName width height [bkgColor] | nickName width height srcX1 srcY1 srcX2 srcY2 [bkgColor]" { int argNum = arrCommand.length; @@ -2783,17 +2817,17 @@ img = hmImages.get(name.toUpperCase()); if (img==null) { - throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\" or \"pushImage "+name+"\""); + try + { + img = (Image) getContextVariable(slot, name); // try to get from a Rexx variable + } + catch (Throwable t) {} + if (img==null) + { + throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\" or \"pushImage "+name+"\" or assign an image to a Rexx variable named \""+name+"\""); + } } } - else // fetch from the denoted Rexx variable - { - img = (Image) getContextVariable(slot, name); - if (img==null) - { - throw new IllegalArgumentException("Rexx variable named \""+name+"\" does not refer to an image"); - } - } int width=0, height=0, srcX1=0, srcY1=0, srcX2=0, srcY2=0; String colorNickName=null; @@ -3617,8 +3651,6 @@ DRAW_ARC ( "drawArc" ) , // "drawArc width height startAngle arcAngle" DRAW_IMAGE ( "drawImage" ) , // "drawImage nickName [bkgColor] | nickName width height [bkgColor] | nickName width height srcX1 srcY1 srcX2 srcY2 [bkgColor]" - DRAW_IMAGE_FROM_REXX_VAR ( "drawImageFromVar" ) , // "drawImageFromVar rexxVarName [bkgColor] | rexxVarName width height [bkgColor] | rexxVarName width height srcX1 srcY1 srcX2 srcY2 [bkgColor]" - DRAW_LINE ( "drawLine" ) , // "drawLine toX toY" DRAW_OVAL ( "drawOval" ) , // "drawOval width height" DRAW_POLYGON ( "drawPolygon" ) , // "drawPolygon []xPoints []yPoints nPoints Modified: sandbox/rgf/jdor/doc/jdor_doc.html =================================================================== --- sandbox/rgf/jdor/doc/jdor_doc.html 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/doc/jdor_doc.html 2022-10-31 17:09:43 UTC (rev 1014) @@ -161,8 +161,9 @@ drawLine width height -- from currX=0, currY=0 color red -- set the color to red (preregistered with nickname "RED") moveTo width 0 -- currX=220, currY=0 + position -- query current position say "--> rc="pp(rc) -- RC refers to the previous command's result: "220 0" (currX=220, currY=0) - drawLine 0 height -- from currX=250, currY=0 + drawLine 0 height -- from currX=220, currY=0 -- draw a rectangle at the center of the bitmap len = 50 -- drawing a rectangle with each side being 50 px (a square) moveTo (width-len)/2 (height-len)/2 -- go to the center minus half of the square's side lengths @@ -173,8 +174,9 @@ drawRect len len -- draw the frame with the blue color -- draw a string (text) at the lower half of the bitmap color somePurple 127 46 111 -- define a custom RGB color, store it with nickname "SOMEPURPLE" - say "--> rc="pp(rc) -- show result from command (the Java color object) - say " rc~toString:" pp(rc~toString) -- shows the RGB intensities of the color + color -- query current color + say "--> rc="pp(rc) -- show result from command (a Java color object) + say " rc~toString:" pp(rc~toString) -- shows the RGB intensities of the current color newY=height-40 lineHeight = 15 -- default font size is 12px, add 3 px space -- define an array of three strings @@ -295,8 +297,8 @@ <em><a href="#cmdTranslate">translate</a></em>, <em><a href="#cmdScale">scale</a></em>, <em><a href="#cmdShear">shear</a></em> - will cause the respective factors - to be changed accordingly in the <em>Graphics2D</em>'s maintained <em>AffineTransform</em>. + will cause the respective factors to be changed accordingly in the <em>Graphics2D</em>'s + maintained <em>AffineTransform</em>. <br>The <em><a href="#cmdTransform">transform</a></em> command allows to interact with the <em>Graphics2D</em>'s <em>AffineTransform</em> to query, set or reset the @@ -496,7 +498,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdBackground"> "background" - <td colspan="3"> Queries or sets the background color to a registered color. + <td colspan="3"> Queries and optionally sets the background color to a registered color. <br>Querying the current value (no argument supplied) will return it, setting (changing) the value to a new value will return the old (previously set) value @@ -531,7 +533,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdClip"> "clip" - <td colspan="2"> Queries or sets a clipping area of an image. Returns a + <td colspan="2"> Queries and optionally sets a clipping area of an image. Returns a blank delimited string with the <em>x</em>, <em>y</em>, <em>width</em> and <em>height</em> values of the previously defined clipping rectangle (area) or <em>.nil</em> if no such area was defined @@ -604,7 +606,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "composite" - <td colspan="2"> Queries or creates and sets the composite value (an instance of the + <td colspan="2"> Queries and optionally sets or creates the composite value (an instance of the Java class <em>java.awt.AlphaComposite</em>). <br>Querying the current value (no argument supplied) will return it, setting @@ -692,7 +694,8 @@ <td colspan="2"> Draws an image which got previously loaded from the filesystem with the command <em><a href="#cmdLoadImage">loadImage</a></em> and stored internally with an <em>nickName</em> in the internal image registry, or an image that got - pushed with a <em>nickName</em> in the command <em><a href="#cmdPushImage">pushImage</a></em> + pushed with a <em>nickName</em> in the command <em><a href="#cmdPushImage">pushImage</a></em>, + or stored in a Rexx variable. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>drawImage(...)</em>. @@ -701,7 +704,8 @@ <td> <td class="argument"> nickName [bkgColor] <td> <em>nickName</em> denotes the name of an image stored in the - internal image registry. Draws as much of the image as possible. + internal image registry or the name of a Rexx variable referring + to an image. Draws as much of the image as possible. <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. @@ -709,7 +713,9 @@ <td> <td class="argument"> nickName width height [bkgColor] <td> <em>nickName</em> denotes the name of an image stored in the - internal image registry. Draws as much of the image as possible scaled to the + internal image registry or the name of a Rexx variable referring + to an image. + Draws as much of the image as possible scaled to the <em>width</em> and <em>height</em> in pixels. <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. @@ -718,48 +724,9 @@ <td> <td class="argument"> nickName width height srcX1 srcY1 srcX2 srcY2 [bkgColor] <td> <em>nickName</em> denotes the name of an image stored in the - internal image registry. Draws as much of the image as possible scaled to the - <em>width</em> and <em>height</em> in pixels, using from the image the rectangle - with the first corner with the coordinate <em>srcX1</em> and <em>srcY1</em> and - the second corner with the coordinate <em>srcX2</em> and <em>srcY2</em>. - - <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. - - - <!-- -------------------------------------------------------- --> - <tr class="CommandRowColumn"><!-- table row --> - <td class="cmdNr"> - <td class="command"> "drawImageFromVar" - <td colspan="2"> Draws an image (an instance of <em>java.awt.Image</em>) referred - to by a Rexx variable. - <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the - method <em>drawImageFromVar(...)</em>. - - <tr class="ArgumentRowColor"><td><!-- table row --> - <td> - <td class="argument"> rexxVariableName [bkgColor] - <td> <em>rexxVariableName</em> denotes the name of a Rexx variable that refers to an image - (hint: enquote the Rexx variable name). - Draws as much of the image as possible. - - <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. - - <tr class="ArgumentRowColor"><td><!-- table row --> - <td> - <td class="argument"> rexxVariableName width height [bkgColor] - <td> <em>rexxVariableName</em> denotes the name of a Rexx variable that refers to an image - (hint: enquote the Rexx variable name). + internal image registry or the name of a Rexx variable referring + to an image. Draws as much of the image as possible scaled to the - <em>width</em> and <em>height</em> in pixels. - - <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. - - <tr class="ArgumentRowColor"><td><!-- table row --> - <td> - <td class="argument"> rexxVariableName width height srcX1 srcY1 srcX2 srcY2 [bkgColor] - <td> <em>rexxVariableName</em> denotes the name of a Rexx variable that refers to an image - (hint: enquote the Rexx variable name). - Draws as much of the image as possible scaled to the <em>width</em> and <em>height</em> in pixels, using from the image the rectangle with the first corner with the coordinate <em>srcX1</em> and <em>srcY1</em> and the second corner with the coordinate <em>srcX2</em> and <em>srcY2</em>. @@ -1027,16 +994,6 @@ <td class="argument"> fontNickName <td> <em>fontNickName</em> gets uppercased and is used to look up the internal font registry for the denoted font which should be used from now on. - <br> - <em>Note:</em> if - <em>fontNickName</em> is one of the operating system independent font names - <em>"Dialog"</em>, - <em>"DialogInput"</em>, - <em>"Serif"</em>, - <em>"SansSerif"</em>, - <em>"Monospaced"</em>, then a font of this kind gets created using - the currently set <a href="#cmdFontSize"><em>fontSize</em></a> - and <a href="#cmdFontStyle"><em>fontStyle</em></a> instead. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1056,7 +1013,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdFontSize"> "fontSize" - <td colspan="2"> Queries or sets the font size to be used when loading a new + <td colspan="2"> Queries and optionally sets the font size to be used when loading a new <a href="#cmdFont"><em>font</em></a>. <br>Querying the current value (no argument supplied) will return it, setting @@ -1076,7 +1033,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdFontStyle"> "fontStyle" - <td colspan="2"> Queries or sets the font style to be used when loading a new + <td colspan="2"> Queries and optionally sets the font style to be used when loading a new <a href="#cmdFont"><em>font</em></a>. <br>Querying the current value (no argument supplied) will return it, setting @@ -1160,7 +1117,7 @@ <td class="command" id="cmdMoveTo"> "goto" <br> "location" <br> "moveTo" <br> "pos" <br> "position" - <td colspan="2"> Queries or sets <em>currX</em> and <em>currX</em> in the current image. + <td colspan="2"> Queries and optionally sets <em>currX</em> and <em>currX</em> in the current image. <br>Querying the current value (no argument supplied) will return it, setting (changing) the value to a new value will return the old (previously set) value @@ -1317,7 +1274,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdPaint"> "paint" - <td colspan="2"> Queries or sets current paint (used for filling). + <td colspan="2"> Queries and optionally sets current paint (used for filling). <br>Querying the current value (no argument supplied) will return it, setting (changing) the value to a new value will return the old (previously set) value @@ -1358,7 +1315,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdPreferredImageType"> "preferredImageType" - <td colspan="2"> Queries or sets the preferred image type used for creating new images + <td colspan="2"> Queries and optionally sets the preferred image type used for creating new images (cf. <a href="#cmdNew">new</a> command). Returns the image type via the Rexx variable <em>RC</em> upon return from this command. @@ -1391,13 +1348,15 @@ <td class="cmdNr"> <td class="command"> "printImage" <td colspan="2"> Uses the default printer to print the image. If the <em>imageNickName</em> - is supplied, it gets uppercased and used to look it up in the image registry and prints it. + is supplied, it gets uppercased and used to look it up in the image registry or if not + found from a Rexx variable of the same name and prints it. <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> imageNickName <td> optional <em>imageNickName</em> is uppercased and used to look up the image from the internal - registry that should get printed. + registry or the name of a Rexx variable referring to an image of type <em>BufferedImage</em> + that should get printed. <!-- -------------------------------------------------------- --> @@ -1404,7 +1363,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "printPos" - <td colspan="2"> Queries or sets the left upper hand corner on the page where the image should + <td colspan="2"> Queries and optionally sets the left upper hand corner on the page where the image should be drawn to. This command has no effect if <em>printScaleToPage</em> was set to <em>.true</em> (<em>1</em>). @@ -1440,7 +1399,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "printScaleToPage" - <td colspan="2"> Queries or sets the value. + <td colspan="2"> Queries and optionally sets the value. <br>Querying the current value (no argument supplied) will return it, setting (changing) the value to a new value will return the old (previously set) value @@ -1568,8 +1527,12 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdScale"> "scale" - <td colspan="2"> Queries or sets the scale factor for the <em>y</em> and <em>y</em> axis. - The command returns the scale values at the time of invocation. + <td colspan="2"> Queries and optionally changes ("concatenates") the scale factor for + the <em>x</em> and <em>y</em> axis. The command returns the scale values + at the time of invocation. + <br>Cf. the Java documentation for the Java class <em>Graphics2D</em> and the + method <em>scale(...)</em>. + <br>To set these factors to absolute values use the <a href="#cmdTransform">transform</a> command. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1609,8 +1572,12 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdShear"> "shear" - <td colspan="2"> Queries or sets the shear (skew) factor for the <em>y</em> and <em>y</em> - axis. The command returns the shear values at the time of invocation. + <td colspan="2"> Queries and optionally changes ("concatenates") the shear (skew) factor for + the <em>x</em> and <em>y</em> axis. The command returns the shear values + at the time of invocation. + <br>Cf. the Java documentation for the Java class <em>Graphics2D</em> and the + method <em>shear(...)</em>. + <br>To set these factors to absolute values use the <a href="#cmdTransform">transform</a> command. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1700,6 +1667,10 @@ to <em>currX</em> and <em>y</em> pixels to <em>currY</em>. The command returns the translate values at the time of invocation. + <br>Cf. the Java documentation for the Java class <em>Graphics2D</em> and the + method <em>translate(...)</em>. + <br>To set these factors to absolute values use the <a href="#cmdTransform">transform</a> command. + <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> x [y] @@ -1720,8 +1691,8 @@ calculate the effective <em>x</em> and <em>y</em> values for the target device according to this formula: - <p><code> x' = scaleX*x + shearX*y + translateX </code> - <br><code> y' = scaleY*y + shearY*x + translateY </code> + <p><code> x' = translateX + scaleX*x + shearX*y </code> + <br><code> y' = translateY + scaleY*y + shearY*x </code> <p>Cf. the Java documentation for the Java classes <em>java.awt.geom.AffineTransform</em>, <em>java.awt.Graphics2D</em> and the methods <em>getTransform()</em>, <em>setTransform(...)</em>. @@ -1746,7 +1717,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "winAlwaysOnTop" - <td colspan="2"> Queries or sets the value. + <td colspan="2"> Queries and optionally sets the value. <br>Querying the current value (no argument supplied) will return it, setting (changing) the value to a new value will return the old (previously set) value @@ -1796,7 +1767,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "winFrame" - <td colspan="2"> Queries or sets the value. + <td colspan="2"> Queries and optionally sets the value. <br>Querying the current value (no argument supplied) will return it, setting (changing) the value to a new value will return the old (previously set) value @@ -1836,7 +1807,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "winLocation"<br> "winMoveTo" - <td colspan="2"> Queries or sets the location of the frame (window) that shows the current image. + <td colspan="2"> Queries and optionally sets location of the frame (window) that shows the current image. <br>Querying the current value (no argument supplied) will return it, setting (changing) the value to a new value will return the old (previously set) value @@ -1881,7 +1852,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "winSize" - <td colspan="2"> Queries or sets the size of the frame (window) that displays + <td colspan="2"> Queries and optionally sets the size of the frame (window) that displays the current image. <br>Querying the current value (no argument supplied) will return it, setting @@ -1902,7 +1873,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "winTitle" - <td colspan="2"> Queries or sets the title of the frame (window) that displays + <td colspan="2"> Queries and optionally sets the title of the frame (window) that displays the current image. <br>Querying the current value (no argument supplied) will return it, setting @@ -1950,7 +1921,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "winUpdate" - <td colspan="2"> Queries or sets the value. If set to <em>.true</em>, the frame (window) + <td colspan="2"> Queries and optionally sets the value. If set to <em>.true</em>, the frame (window) that displays the current image will be updated each time a change occurs in the current image, otherwise the frame (window) does not get visually updated. @@ -1974,8 +1945,8 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "winVisible" - <td colspan="2"> Queries or sets the value. If set to <em>.true</em>, the frame (window) - that displays the current image will be shown, otherwise it will be hided. + <td colspan="2"> Queries and optionally sets the value. If set to <em>.true</em>, the frame (window) + that displays the current image will be shown, otherwise it will be hidden. <br>Querying the current value (no argument supplied) will return it, setting @@ -2005,7 +1976,7 @@ <center> <hr width="75%"> <small> - JDOC synopsis of commands, version: 100.20221030 + JDOC synopsis of commands, version: 100.20221031 <br>Acknowledgement: the author wishes to thank DI Walter Pachl <br>for his help in testing and proof reading </small> Modified: sandbox/rgf/jdor/doc/jdor_doc_sample.png =================================================================== (Binary files differ) Modified: sandbox/rgf/jdor/doc/jdor_doc_sample.rex =================================================================== --- sandbox/rgf/jdor/doc/jdor_doc_sample.rex 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/doc/jdor_doc_sample.rex 2022-10-31 17:09:43 UTC (rev 1014) @@ -8,8 +8,9 @@ drawLine width height -- from currX=0, currY=0 color red -- set the color to red (preregistered with nickname "RED") moveTo width 0 -- currX=220, currY=0 +position -- query current position say "--> rc="pp(rc) -- RC refers to the previous command's result: "220 0" (currX=220, currY=0) -drawLine 0 height -- from currX=250, currY=0 +drawLine 0 height -- from currX=220, currY=0 -- draw a rectangle at the center of the bitmap len = 50 -- drawing a rectangle with each side being 50 px (a square) moveTo (width-len)/2 (height-len)/2 -- go to the center minus half of the square's side lengths @@ -20,8 +21,9 @@ drawRect len len -- draw the frame with the blue color -- draw a string (text) at the lower half of the bitmap color somePurple 127 46 111 -- define a custom RGB color, store it with nickname "SOMEPURPLE" -say "--> rc="pp(rc) -- show result from command (the Java color object) -say " rc~toString:" pp(rc~toString) -- shows the RGB intensities of the color +color -- query current color +say "--> rc="pp(rc) -- show result from command (a Java color object) +say " rc~toString:" pp(rc~toString) -- shows the RGB intensities of the current color newY=height-40 lineHeight = 15 -- default font size is 12px, add 3 px space -- define an array of three strings Modified: sandbox/rgf/jdor/samples/1-120_JDOR_bw.rxj =================================================================== --- sandbox/rgf/jdor/samples/1-120_JDOR_bw.rxj 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/samples/1-120_JDOR_bw.rxj 2022-10-31 17:09:43 UTC (rev 1014) @@ -12,7 +12,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -44,14 +44,15 @@ winShow -- show frame -- draw two lines forming a big X drawLine 300 500 -- currX=0, currY=0 -goto 300 0 -- currX=300, currY=0 +moveTo 300 0 -- currX=300, currY=0 drawLine 0 500 -- draw a rectangle at the center of the bitmap -goto (300-50)/2 (500-50)/2 +moveTo (300-50)/2 (500-50)/2 fillRect 50 50 drawRect 50 50 -- draw a test at the lower half of the bitmap -goto 50 450 +moveTo 50 450 drawString "Hello, world via JDOR ..." +say "'sleep 3' ..." sleep 3 -- sleep for three seconds -- say "press enter to end.";parse pull \ No newline at end of file Modified: sandbox/rgf/jdor/samples/1-120_JDOR_color_text.rxj =================================================================== --- sandbox/rgf/jdor/samples/1-120_JDOR_color_text.rxj 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/samples/1-120_JDOR_color_text.rxj 2022-10-31 17:09:43 UTC (rev 1014) @@ -12,7 +12,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -43,11 +43,11 @@ winShow -- show frame -- draw two lines forming a big X drawLine 300 500 -- currX=0, currY=0 -goto 300 0 -- currX=300, currY=0 +moveTo 300 0 -- currX=300, currY=0 color red drawLine 0 500 -- draw a rectangle at the center of the bitmap -goto (300-50)/2 (500-50)/2 +moveTo (300-50)/2 (500-50)/2 color green fillRect 50 50 @@ -55,9 +55,10 @@ color blue drawRect 50 50 -- draw a test at the lower half of the bitmap -goto 50 450 +moveTo 50 450 color somePurple 127 46 111 drawString "Hello, world via JDOR ..." +say "'sleep 3' ..." sleep 3 -- sleep for three seconds -- say "press enter to end.";parse pull ::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available Modified: sandbox/rgf/jdor/samples/1-130_JDOR_rotate.rxj =================================================================== --- sandbox/rgf/jdor/samples/1-130_JDOR_rotate.rxj 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/samples/1-130_JDOR_rotate.rxj 2022-10-31 17:09:43 UTC (rev 1014) @@ -13,7 +13,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -42,8 +42,8 @@ new 500 500 -- create new bitmap winShow -- show frame -- draw two lines forming a big X -goto 100 150 -- currX=100, currY=150 - -- define and set color, register it with the name "saddlebrown50" +moveTo 100 150 -- currX=100, currY=150 + -- define and set color, register it with the name "saddlebrown50" color saddlebrown50 139 69 19 127 -- R,G,B,alpha=127 (50 % transparency) fillRect 50 50 -- first fill color blue -- set color to blue (predefined) @@ -52,7 +52,7 @@ drawOval 50 50 -- draw border -- draw a rectangle at the center of the bitmap translate 260 250 -- move origin 0,0 to (260,250) -goto 0 0 -- x=0, y=0 (effectively: x=0+260, y=0+250) +moveTo 0 0 -- x=0, y=0 (effectively: x=0+260, y=0+250) rotate 45 -- rotate by 45 degrees (clock wise starting out from 3 o'clock) color saddlebrown50 -- use registered color named saddlebrown50 [R,G,B,alpha=127 (50 % transparency)] fillRect 50 75 -- fill 50% transparency @@ -61,6 +61,7 @@ drawRect 50 75 -- draw border in blue color red -- set color to red (predefined) drawOval 50 75 -- draw border in red +say "'sleep 5' ..." sleep 5 -- sleep for five seconds -- say "press enter to end.";parse pull Modified: sandbox/rgf/jdor/samples/1-140_JDOR_images.rxj =================================================================== --- sandbox/rgf/jdor/samples/1-140_JDOR_images.rxj 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/samples/1-140_JDOR_images.rxj 2022-10-31 17:09:43 UTC (rev 1014) @@ -11,7 +11,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -42,13 +42,14 @@ winShow -- show frame loadImage b4r_logo bsf4oorexx_256.png drawImage b4r_logo 50 50 -goto 200 200 +moveTo 200 200 loadImage orx_logo oorexx_256.png drawImage orx_logo 75 75 -goto 400 400 +moveTo 400 400 say "rc:" rc -- rc contains the return value loadImage ooo_logo oorexx4ooo_256.png drawImage ooo_logo 100 100 +say "'sleep 5' ..." sleep 5 -- sleep for five seconds -- say "press enter to end.";parse pull Modified: sandbox/rgf/jdor/samples/1-140_JDOR_images_reversed.rxj =================================================================== --- sandbox/rgf/jdor/samples/1-140_JDOR_images_reversed.rxj 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/samples/1-140_JDOR_images_reversed.rxj 2022-10-31 17:09:43 UTC (rev 1014) @@ -12,7 +12,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -44,13 +44,14 @@ "scale 1 -1" -- flip y-axis (positive y grow up, however ...) loadImage b4r_logo bsf4oorexx_256.png drawImage b4r_logo 50 50 -goto 200 200 +moveTo 200 200 loadImage orx_logo oorexx_256.png drawImage orx_logo 75 75 -goto 400 400 +moveTo 400 400 say "rc:" rc -- rc contains the return value loadImage ooo_logo oorexx4ooo_256.png drawImage ooo_logo 100 100 +say "'sleep 5' ..." sleep 5 -- sleep for five seconds -- say "press enter to end.";parse pull Modified: sandbox/rgf/jdor/samples/1-150_JDOR_string_circle.rxj =================================================================== --- sandbox/rgf/jdor/samples/1-150_JDOR_string_circle.rxj 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/samples/1-150_JDOR_string_circle.rxj 2022-10-31 17:09:43 UTC (rev 1014) @@ -11,7 +11,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -38,13 +38,12 @@ call addJdorHandler -- load and add the Java Rexx command handler, using default name: JDOR address jdor -- set default environment to JDOR winShow -- will implicitly create a 500x500 bitmap -goto 450 450 +moveTo 450 450 loadImage orx oorexx_256.png drawImage orx 50 50 color blue -goto 0 20 +moveTo 0 20 drawString "Hello at:" .dateTime~new -goto translate 250 250 -- move 0,0 to center color red fontstyle 3 -- bold=1 + italic=2 @@ -54,7 +53,7 @@ fontstyle 0 -- normal fontsize 14 -- size=14 font mono "Monospaced" -goto 10 0 -- currX=10, currY=0 +moveTo 10 0 -- currX=10, currY=0 angle=30 do i=2 to 360/angle rotate angle -- rotates entire image @@ -62,6 +61,7 @@ if random(0,1) then do; color red; font serif1; end else do; "color gray"; "font mono" ; end end +say "'sleep 5' ..." sleep 5 -- sleep for five seconds -- say "press enter to end.";parse pull ::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available \ No newline at end of file Modified: sandbox/rgf/jdor/samples/1-160_JDOR_getState.rxj =================================================================== --- sandbox/rgf/jdor/samples/1-160_JDOR_getState.rxj 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/samples/1-160_JDOR_getState.rxj 2022-10-31 17:09:43 UTC (rev 1014) @@ -12,7 +12,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -42,11 +42,11 @@ winShow -- show frame -- draw two lines forming a big X drawLine 300 500 -- from currX=0, currY=0 to x2=300 y2=500 -pos 300 0 -- alias "goto": currX=300, currY=0 +pos 300 0 -- alias for "moveTo": currX=300, currY=0 color red drawLine 0 500 -- from currX=300, currY=0 to x2=0 y2=500 -- draw a rectangle at the center of the bitmap -goto (300-50)/2 (500-50)/2 -- currX= +goto (300-50)/2 (500-50)/2 -- alias for "moveTo": currX=125, currY=225 say "rc:" pp(rc) ".rs="pp(.rs) color saddlebrown50 139 69 19 127 -- R,G,B,alpha=127 (50 % transparency) fillRect 50 50 @@ -62,6 +62,7 @@ do counter c idx over currState~allIndexes~sort say " " right(c,2)":" left(pp(idx),20,".") pp(currState[idx]) end +say "'sleep 5' ..." sleep 5 -- sleep for five seconds -- say "press enter to end.";parse pull ::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available \ No newline at end of file Modified: sandbox/rgf/jdor/samples/1-170_JDOR_lineHeight.rxj =================================================================== --- sandbox/rgf/jdor/samples/1-170_JDOR_lineHeight.rxj 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/samples/1-170_JDOR_lineHeight.rxj 2022-10-31 17:09:43 UTC (rev 1014) @@ -13,7 +13,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -46,12 +46,12 @@ -- draw two lines forming a big X drawLine width height -- from currX=0, currY=0 color red -- set the color to red (preregistered with nickname "RED") -goto width 0 -- currX=220, currY=0 +moveTo width 0 -- currX=220, currY=0 say "--> rc="pp(rc) -- RC refers to the previous command's result: "220 0" (currX=220, currY=0) drawLine 0 height -- from currX=250, currY=0 -- draw a rectangle at the center of the bitmap len = 50 -- drawing a rectangle with each side being 50 px (a square) -goto (width-len)/2 (height-len)/2 -- go to the center minus half of the square's side lengths +moveTo (width-len)/2 (height-len)/2 -- go to the center minus half of the square's side lengths color green -- set color to green (preregistered with nickname "GREEN") fillRect len len -- fill the square with the green color stroke str3 3 -- set line stroke to 3 points width, store it with nickname "STR3" @@ -70,11 +70,12 @@ say "lineHeight: " pp(lineHeight) -- show line height text=("Hello, Rexx world ...", "... from JDOR ...", "(Rexx command handler)") -- array of 3 strings do counter c i=0 to 30 by lineHeight -- iterate over array of strings - goto 50 (newY+i) -- set position + moveTo 50 (newY+i) -- set position drawString text[c] -- draw the string end -- save the current image saveImage "1-170_JDOR_lineHeight.png" -- save image to file "1-170_JDOR_lineHeight.png" +say "'sleep 3.123' ..." sleep 3.123 -- sleep for 3.123 seconds ::requires "jdor.cls" -- Rexx package that defines the public routine addJdorHandler() Modified: sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass.rxj =================================================================== --- sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass.rxj 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass.rxj 2022-10-31 17:09:43 UTC (rev 1014) @@ -12,7 +12,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -55,11 +55,12 @@ h = height-m color colors[i] stroke strokes[i] - goto m m; drawLine w m - goto w m; drawLine m h - goto m h; drawLine w h - goto w h; drawLine m m + moveTo m m; drawLine w m + moveTo w m; drawLine m h + moveTo m h; drawLine w h + moveTo w h; drawLine m m end +say "'sleep 3' ..." sleep 3 -- sleep for three seconds -- say 'hit enter to continue...'; parse pull . Modified: sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass_float_colors.rxj =================================================================== --- sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass_float_colors.rxj 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass_float_colors.rxj 2022-10-31 17:09:43 UTC (rev 1014) @@ -13,7 +13,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -71,11 +71,12 @@ h = height-m color colors[i] stroke strokes[i] - goto m m; drawLine w m - goto w m; drawLine m h - goto m h; drawLine w h - goto w h; drawLine m m + moveTo m m; drawLine w m + moveTo w m; drawLine m h + moveTo m h; drawLine w h + moveTo w h; drawLine m m end +say "'sleep 3' ..." sleep 3 -- sleep for three seconds -- say 'hit enter to continue...'; parse pull . Modified: sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass_log.rxj =================================================================== --- sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass_log.rxj 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass_log.rxj 2022-10-31 17:09:43 UTC (rev 1014) @@ -14,7 +14,7 @@ Author: Rony G. Flatscher, WU Vienna - Changes: -- + Changes: 2022-10-31 - added hint about sleeping time last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -59,13 +59,14 @@ h = height-m "color" colors[i] -- set defined color "STROKE" strokes[i] -- set defined stroke - "PoS" m m; "DRAWLINE" w m -- sets the x and y position - "GOTO" w m; "drawline" m h -- GOTO is a synonym for POS - "pos" m h; "DRAWLINE" w h -- sets the x and y position - "GOTO" w h; "drawline" m m -- GOTO is a synonym for POS + "PoS" m m; "DRAWLINE" w m -- POS is a synonym for MOVETO sets the x and y position + "GOTO" w m; "drawline" m h -- GOTO is a synonym for MOVETO + "pos" m h; "DRAWLINE" w h -- POS is a synonym for MOVETO sets the x and y position + "GOTO" w h; "drawline" m m -- GOTO is a synonym for MOVETO end s~close saveImage "1-180_JDOR_sandGlass.png" -- "png" allows for ARGB (RGB colors with alpha (transparency9) +say "'sleep 3' ..." sleep 3 -- sleep for three seconds ::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available \ No newline at end of file Modified: sandbox/rgf/jdor/samples/2-110_JDOR_listShowPrintFonts.rxj =================================================================== --- sandbox/rgf/jdor/samples/2-110_JDOR_listShowPrintFonts.rxj 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/samples/2-110_JDOR_listShowPrintFonts.rxj 2022-10-31 17:09:43 UTC (rev 1014) @@ -20,6 +20,7 @@ Changes: 2022-10-20, ---rgf: adjust for corrected drawString command, simplify footer, let footer stand out by being printed on white background, add total number of pages + 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -96,11 +97,11 @@ end fontName=allFontFamilies[i] -- get current font family name (Rexx) y=currLine*lineHeight -- calculate y (Rexx) - goto xCol1 y -- goto x y (JDOR command) + moveTo xCol1 y -- moveTo x y (JDOR command) say i~right(3)":" fontName -- show fontName on command line (Rexx) font mono -- use already loaded monotype font (JDOR command) drawString i~right(3)":" fontName -- write font family name (JDOR command) - goto xCol2 y -- goto x y (JDOR command) + moveTo xCol2 y -- moveTo x y (JDOR command) font "font"i fontName -- load and use font family font (JDOR command) drawString "Hello world, this is ooRexx using the JDOR command handler ..." -- (JDOR command) currLine+=1 -- increase line (Rexx) @@ -112,6 +113,7 @@ say say "you have a total of" pp(nrItems) "fonts installed on your system!" +say "'sleep 3.009' ..." "sleep" 3 + .009 -- let us look at the last image for three plus 9/1000 more seconds ;) (JDOR command) exit @@ -118,13 +120,13 @@ printFooter: tmpFileName = fileName || pageNr"."fileType -- define file name background white -- set background to white (by clearRect command below) - goto 0 (lines*lineHeight+9) + moveTo 0 (lines*lineHeight+9) clearRect width (2*lineHeight+3) y=(lines+2)*lineHeight -- calc footer position fontSize 10; font dialog "Dialog" -- set font size and font - goto xCol1 y; drawString "page" pageNr"/"totalPages "(as of:" .dateTime~new")" -- write footer part 1 - goto xCol2 y; drawString tmpFileName -- write footer part 2 + moveTo xCol1 y; drawString "page" pageNr"/"totalPages "(as of:" .dateTime~new")" -- write footer part 1 + moveTo xCol2 y; drawString tmpFileName -- write footer part 2 background oldBackground -- winUpdate .true-- update Frame (JDOR command) say "saving sample to:" pp(tmpFileName) Modified: sandbox/rgf/jdor/samples/2-120_JDOR_shear.rxj =================================================================== --- sandbox/rgf/jdor/samples/2-120_JDOR_shear.rxj 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/samples/2-120_JDOR_shear.rxj 2022-10-31 17:09:43 UTC (rev 1014) @@ -62,11 +62,12 @@ color blue -- change color call drawFigure -- draw the same figure as above -say "Press enter to end ..." -parse pull . +say "sleep 5 ..." +sleep 5 +-- say "Press enter to end ..."; parse pull . exit -drawFigure: procedure -- moves origin, draws axes with right and down error, draws rectangle +drawFigure: procedure -- moves origin, draws axes with right and down arrow, draws rectangle lineLength = 54 arrowLength = 4 tickSize = 4 Modified: sandbox/rgf/jdor/samples/2-130_JDOR_animate_two_frames.rxj =================================================================== --- sandbox/rgf/jdor/samples/2-130_JDOR_animate_two_frames.rxj 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/samples/2-130_JDOR_animate_two_frames.rxj 2022-10-31 17:09:43 UTC (rev 1014) @@ -92,7 +92,7 @@ say "image~toString:" pp(jImage~toString) say -- note the name of a Rexx variable needs to be quoted, otherwise its value gets used -address sdor drawImageFromVar "jImage" -- use image from Rexx variable named "jImage" +address sdor drawImage "jImage" -- use image from Rexx variable named "jImage" sleep 0.75 -- sleep (wait) a bit sleepTime=1/30 -- appr. 30 updates per second @@ -101,13 +101,15 @@ do i=0 to 360+90 by 5 -- rotate 1 1/4 rounds ... round+=1 address sdor rotate i center -- rotate transform - address sdor drawImageFromVar "jImage" -- draw image referred to by the Rexx variable "jImage" + address sdor drawImage "jImage" -- draw image referred to by the Rexx variable "jImage" sleep sleepTime -- sleeping causes animation effect end say "finished after" pp(round) "rotations" -say "press enter to end ..." -parse pull +say "'sleep 5' ..." +sleep 5 +-- say "press enter to end ..."; parse pull + ::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available Modified: sandbox/rgf/jdor/samples/3-100_create_bitmap_JDOR_commands.rxj =================================================================== --- sandbox/rgf/jdor/samples/3-100_create_bitmap_JDOR_commands.rxj 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/samples/3-100_create_bitmap_JDOR_commands.rxj 2022-10-31 17:09:43 UTC (rev 1014) @@ -20,7 +20,7 @@ Author: Rony G. Flatscher, Wien University - Changes: -- + Changes: 2022-10-31 - changed "goto" to "moveTo" last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ (svn hint: use 'propset svn:keywords "Author Date Revision" filename') @@ -87,18 +87,18 @@ do counter c i over positions tmpX=i[1] tmpY=i[2] - goto tmpX tmpY + moveTo tmpX tmpY fileName = images[c] imageFromFile="img_"c loadImage imageFromFile fileName drawImage imageFromFile - goto tmpX tmpY+10 + moveTo tmpX tmpY+10 drawString fileName -- drawing at 50% of size either on the right or left of the original sized picture if c=3 then tmpX -= 256 else tmpX += 256+128 - goto tmpX tmpY + moveTo tmpX tmpY drawImage imageFromFile tmpX+128 tmpY+128 0 0 256 256 end -- sleep 0.5 @@ -107,11 +107,11 @@ -- draw a string (text) using the current (default) font color green text="Hello, world, it is:" .dateTime~new -goto (0+borderWidth) (height/2-20) +moveTo (0+borderWidth) (height/2-20) drawString text -- draw a thick line underneath stroke stroke5 -goto (0+borderWidth) (height/2-10) +moveTo (0+borderWidth) (height/2-10) drawLine 260 (height/2-10) -- sleep 0.5 @@ -135,7 +135,7 @@ end fontSize size font "font"c fontName - goto xPos (yStart+(size*c)+5) + moveTo xPos (yStart+(size*c)+5) text=c"." fontName hint"," size "points" drawString text end @@ -149,7 +149,7 @@ -- draw a line from upper right hand corner down: coordinates must be integers! color teal stroke dashedStroke -goto (width-borderWidth) (0+borderWidth) +moveTo (width-borderWidth) (0+borderWidth) drawLine (width-format(width/17,,0)) 200 -- move 0,0 co-ordinate relative to current position (i.e. to center) @@ -160,7 +160,7 @@ do counter c i=1 to 360/15 -- 24 steps! rotate 15 -- rotate by 15\xB0 text="--> Hello, world, it is:" .dateTime~new "<-- #" c "("c*15"\xB0) " - goto 0 0 + moveTo 0 0 drawString text end @@ -174,7 +174,7 @@ -- draw an ellipse (if rectangle is a square, then a circle gets drawn) color magenta stroke dashedStroke -goto 0 50 +moveTo 0 50 drawOval 275 75 -- sleep 0.5 @@ -189,7 +189,7 @@ s = r*2 x = borderWidth+width/2-r y = borderWidth+height/2-r -goto x y +moveTo x y drawOval s s -- sleep 0.5 Modified: sandbox/rgf/jdor/samples/3-110_JDOR_animate_composite.rxj =================================================================== --- sandbox/rgf/jdor/samples/3-110_JDOR_animate_composite.rxj 2022-10-30 18:55:41 UTC (rev 1013) +++ sandbox/rgf/jdor/samples/3-110_JDOR_animate_composite.rxj 2022-10-31 17:09:43 UTC (rev 1014) @@ -43,8 +43,8 @@ jdor=.bsf~new("org.oorexx.handlers.jdor.JavaDrawingHandler") call BsfCommandHandler "add", "JDOR", jdor --- address jdor -- set default environment to JDOR -address jdor with error using (.error) -- set default environment to JDOR +address jdor -- set default environment to JDOR +-- address jdor with error using (.error) -- set default environment to JDOR w=400 -- width h=400 -- height @@ -69,7 +69,7 @@ parse var loc name x y size loadImage name name -- load image from file use filename as nick name moveTo x y -- move to desired location - composite src_over 0.01 -- composite set to transparent (alpha to 0.01) + composite src_over 0.025 -- composite set to transparent (alpha to 0.01) do i=1 to 100 -- repeatedly drawing adds current alpha to existing picture (fade in) drawImage name size size -- draw image with desired size sleep 0.01 -- sleep causes animation effect @@ -105,14 +105,15 @@ end end -moveTo 25 200 +moveTo 75 200 color blue fontSize 18 -font "Serif" -drawString "Wer are done, goodbye! (press enter to end ...)" +font f1 "Serif" +drawString "We are done, goodbye! ('sleep 5' ...)" +say "'sleep 5' ..." +sleep 5 -say "press enter to end ..." -parse pull +-- say "press enter to end ..."; parse pull ::requires "BSF.CLS" -- get ooRexx-Java bridge This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <or...@us...> - 2022-10-30 18:55:43
|
Revision: 1013 http://sourceforge.net/p/bsf4oorexx/code/1013 Author: orexx Date: 2022-10-30 18:55:41 +0000 (Sun, 30 Oct 2022) Log Message: ----------- 20221030 Updated JDOR, added samples, new beta release. Modified Paths: -------------- branches/850/bsf4oorexx.dev/bin/BSF.CLS branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java branches/850/createDistributionForBSF4ooRexx8.cmd branches/850/samples/1-180_JDOR_sandGlass.rxj branches/850/samples/index.html Added Paths: ----------- branches/850/samples/1-180_JDOR_sandGlass_float_colors.rxj branches/850/samples/2-120_JDOR_shear.rxj branches/850/samples/2-130_JDOR_animate_two_frames.rxj branches/850/samples/3-110_JDOR_animate_composite.rxj Modified: branches/850/bsf4oorexx.dev/bin/BSF.CLS =================================================================== --- branches/850/bsf4oorexx.dev/bin/BSF.CLS 2022-10-30 18:54:22 UTC (rev 1012) +++ branches/850/bsf4oorexx.dev/bin/BSF.CLS 2022-10-30 18:55:41 UTC (rev 1013) @@ -922,7 +922,7 @@ if initialize.bsf.dir() then -- setup .bsfrexx do - .bsf4rexx~version="850.20221023" -- set version (date distribution got created) + .bsf4rexx~version="850.20221030" -- set version (date distribution got created) .bsf4rexx~opSys =opsys -- save operating system name as supplied by Rexx' PARSE SOURCE .bsf4rexx~opSys1 =opsys~left(1)~upper -- save operating system name's initial letter in uppercase .bsf4rexx~opSys2 =opsys~left(2)~upper -- save operating system name's first two letters in uppercase Modified: branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html =================================================================== --- branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html 2022-10-30 18:54:22 UTC (rev 1012) +++ branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html 2022-10-30 18:55:41 UTC (rev 1013) @@ -16,7 +16,7 @@ ============================================================================= Synopsis like documentation of the JDOR Rexx command handler commands. - 2022-10-02, rgf + 2022-10-26, rgf --> @@ -25,20 +25,59 @@ <title>JDOR Synopsis</title> <style> /* --- definition list----------------------- */ + dl { + width: 90%; + display: inline-table; + break-before: avoid-page; + break-inside: always; + padding: 0; + margin: 5 + } + dt { - font-weight: bold; - font-style: italic; - } + border-top: 1px dotted SaddleBrown; + float: left; + width: 20%; + font-weight: bold; + font-style: italic; + background: WhiteSmoke; + padding: 0; + margin: 0; + } - dl, - dd { - font-size: .9rem; - } + dt::after { + content: ':'; + } + dt.heading { + border-top: 0; + float: left; + width: 100%; + background: none; + font-size: 120%; + font-style: normal; + font-weight: bold; + } + + dt.heading::after { + content: ''; + } + + dd { - margin-bottom: 1px; - } + border-top: 1px dotted SaddleBrown; + float: left; + width: 80%; + background: WhiteSmoke; + padding: 0; + margin: 0; + } + dd:not(:last-of-type) { + padding-bottom: 0.5em; + } + + /* --- table -------------------------------- */ table { border = 1px; @@ -89,11 +128,11 @@ counter-increment: command-count; } - tr.ArgumentRowColor:nth-child(even) { + + tr.ArgumentRowColor { background-color: LightYellow; } - /* also highlight :nth-child colored rows on hover */ tr.ArgumentRowColor:hover { background-color: PaleGoldenRod; } @@ -121,12 +160,12 @@ -- draw two lines forming a big X drawLine width height -- from currX=0, currY=0 color red -- set the color to red (preregistered with nickname "RED") - goto width 0 -- currX=220, currY=0 + moveTo width 0 -- currX=220, currY=0 say "--> rc="pp(rc) -- RC refers to the previous command's result: "220 0" (currX=220, currY=0) drawLine 0 height -- from currX=250, currY=0 -- draw a rectangle at the center of the bitmap len = 50 -- drawing a rectangle with each side being 50 px (a square) - goto (width-len)/2 (height-len)/2 -- go to the center minus half of the square's side lengths + moveTo (width-len)/2 (height-len)/2 -- go to the center minus half of the square's side lengths color green -- set color to green (preregistered with nickname "GREEN") fillRect len len -- fill the square with the green color stroke str3 3 -- set line stroke to 3 points width, store it with nickname "STR3" @@ -141,7 +180,7 @@ -- define an array of three strings text=("Hello, Rexx world ...", "... from JDOR ...", "(Rexx command handler)") -- array of 3 strings do counter c i=0 to 30 by lineHeight -- iterate over array of strings - goto 50 (newY+i) -- set position + moveTo 50 (newY+i) -- set position drawString text[c] -- draw the string end -- save the current image @@ -169,18 +208,62 @@ <p> The <em>JDOR</em> Rexx command handler makes <em>Java2D</em> functionality available to Rexx programmers. The commands are formed after the methods in the <em>java.awt.Graphics</em> -and <em>java.awt.Graphics2D</em> Java classes. The only difference are the <em>x</em> and -<em>y</em> co-ordinates which many methods have as their first two arguments: the Rexx programmer -defines these co-ordinates with the <em>GOTO x y</em> command and therefore are left out from -the arguments of the Rexx commands matching the Java method names. +and <em>java.awt.Graphics2D</em> Java classes. The only difference is that the <em>x</em> and +<em>y</em> co-ordinates used by many methods as their first two arguments are handled +differently. +The Rexx programmer defines these co-ordinates with the <a href="#cmdMoveTo"><em>moveTo x y</em></a> command +preceding command and they are therefore omitted from +the Rexx commands matching the Java method names. +<p>Many methods in the classes <em>Graphis[2D]</em> expect arguments to be integers. +To ease programming argument values that may be calculated (e.g. <em>x</em> or <em>y</em> +positions, <em>width</em>, <em>height</em>, ...) and yield decimal numbers +will get rounded to integer values by <em>JDOR</em>. -<p>For the Rexx programmers the following <em>JDOR</em> related materials may be helpful: +<p><em>Hint:</em> using the redirection option of the Rexx <em>ADDRESS</em> keyword instruction + (i.e., its <em>WITH</em> subkeyword with the redirection definitions) has the following effects: <ul> + <li>redirecting <em>INPUT</em>: all commands are taken and processed from the redirected + input. + <br><em>Note:</em> you need to supply at least one command (e.g. a comment command like + <code><em>"-- some comment"</code></em>) to the command handler + such that it gets invoked and becomes able to note that input is redirected, such + that it takes the commands from the redirected input. + + <li>redirecting <em>OUTPUT</em>: all processed commands will be put into the output target + in canonical form, thereby standardizing the names and arguments of the commands. The + output can be regarded as a saved macro that can be replayed by redirecting the + <em>INPUT</em> in another <em>JDOR</em> program to it. + + <br>In the case that an error or failure is caused by a command it will be put into + a comment with information about the error or failure (in this case supplying more + detailed information, like the exact location). + + <li>redirecting <em>ERROR</em>: all commands causing an error or failure condition will + supplied together with the kind of error or failure. In the case of a failure more + detailed information gets supplied, like the exact location. + <br><em>Hint</em>: while developing or changing <em>JDOR</em> programs one can get + the detailed error and failure information by redirecting like this: + + <pre>ADDRESS JDOR WITH using error (.error) /* activate error redirection */ </pre> + + In addition ooRexx + will communicate the result of executing a command by setting the environment + symbol <em>.RS</em> (value <em>0</em> indicates successful completion, <em>-1</em> + indicates a failure and <em>1</em> indicates an error). + <br>Once all errors and failures got fixed, the production code may then remove + error redirection by changing the above redirection statetement to: + <pre>ADDRESS JDOR /* all unqualified commands should go to this handler */ </pre> +</ul> + + + +<p>To Rexx programmers the following <em>JDOR</em> related materials may be helpful: +<ul> <li><a href="https://www.rexxla.org/presentations/2022/202209_JDOR_command_handler.pdf">Introducing the JDOR Rexx Command Handler for Easy Creation of Bitmaps and Bitmap Manipulations on Windows, - Mac and Linux</a> presented at the <a href="https://www.rexxla.org/events/schedule.rsp?year=2022">33rd I - nternational Rexx Symposium 2022</a> (<a href="https://www.rexxla.org/">The Rexx Language Assocation</a>) + Mac and Linux</a> presented at the <a href="https://www.rexxla.org/events/schedule.rsp?year=2022">33rd + International Rexx Symposium 2022</a> (<a href="https://www.rexxla.org/">The Rexx Language Assocation</a>) </ul> <p>For the newcomer the following <em>Java 2D</em> related tutorial may be helpful (as of 2022-09-29): @@ -190,47 +273,72 @@ <p><hr><p> + +<!-- <h3>Some (Informally Defined) Terms</h3> +unfortunately, Firefox would do a page break when printing such that the terms +start on the next page, no matter how much space is available; hence moving the +title to the definition list +--> + + <dl> - <dt>AffineTransform</dt> - <dd>The Java class <em>java.awt.geom.AffineTransform</em> allows to define and maintain - <em>rotate(...)</em>, <em>scale(...)</em>, <em>shear(...)</em>, - <em>translate(...)</em> operations which all can be applied at once with the - <em>java.awt.Graphics2D</em>'s <em>transform(anAffineTransform)</em> method. - One benefit is that <em>GC</em> (graphic configuration, see below) is not permanently changed to these transformation - values. + <dt class="heading">Some Terms and their Informal Definition<br> </dt> - <p>Currently there is no JDOR command to support this directly, however the same effect can - be achieved with the <em><a href="#cmdPushGC">pushGC</a></em> command, followed by any transform - commands - (<em><a href="#cmdRotate">rotate(...)</a></em>, - <em><a href="#cmdScale">scale(...)</a></em>, - <em><a href="#cmdShear">shear(...)</a></em>, - <em><a href="#cmdTranslate">translate(...)</a></em>) - and the <em><a href="#cmdPopGC">popGC</a></em> command which will reinstate the previous pushed <em>GC</em>. - <p> + <dt id="dtAffineTransform">AffineTransform</dt> + <dd>The Java class <em>java.awt.geom.AffineTransform</em> + allows to define and maintain the <em>translate</em>, <em>scale</em>, <em>shear</em> + factors in a matrix. <em>java.awt.Graphics2D</em> methods use it to calculate the effective <em>x</em> + and <em>y</em> values. + <br>The commands + <em><a href="#cmdTranslate">translate</a></em>, + <em><a href="#cmdScale">scale</a></em>, + <em><a href="#cmdShear">shear</a></em> + will cause the respective factors + to be changed accordingly in the <em>Graphics2D</em>'s maintained <em>AffineTransform</em>. - Alternatively, the Rexx programmer can fetch the <em>GC</em> object (cf. <em><a href="#cmdGC">GC</a></em> command) - and interact with it directly and use the <em>transform(...)</em> method directly supplying - an instance of <em>java.awt.geom.AffineTransform</em>. + <br>The <em><a href="#cmdTransform">transform</a></em> command allows to interact with + the <em>Graphics2D</em>'s <em>AffineTransform</em> to query, set or reset the + six transform factors <em>translateX</em>, <em>translateY</em>, + <em>scaleX</em>, <em>scaleY</em>, <em>shearX</em>, <em>shearY</em> directly. </dd> - <dt>coordinate system<dt> + <dt>coordinate system</dt> <dd>The 0-based, two dimensional coordinate system to address each pixel of an image of - width</em> and height</em> in size. The location (coordinate) <em>x=0</em> and - <em>y=0</em>, the <em>origin</em> denotes the pixel in the upper left hand corner. - Increasing <em>x</em> move along to the <em>right</em> (along the <em>x-axis</em>), - increasing <em>y</em> along to the bottom (along the <em>y-axis</em>). + <em>width</em> and <em>height</em> in size. The location (coordinate) <em>x=0</em> and + <em>y=0</em> as the <em>origin</em> denotes the pixel in the upper left hand corner. + Increasing <em>x</em> moves along to the <em>right</em> (along the <em>x-axis</em>), + increasing <em>y</em> moves along to the bottom (along the <em>y-axis</em>). </dd> - <dt>currX currY</dt> + <dt>"comment command"</dt> + <dd>Sometimes it is desired to turn a command (maybe temporarily) into a comment, such that it + does not get executed. <em>JDOR</em> treats all commands as comments that start with + any of the following characters: + <code>-</code> (dash), + <code>;</code> (semi colon), + <code>/</code> (slash), + <code>"</code> (double quote), + <code>'</code> (single quote), + <code>.</code> (dot), + <code>:</code> (colon), + <code>!</code> (exclamation mark), + <code>?</code> (question mark), + <code>_</code> (underscore). Therefore it is sufficient to prefix a command with one + of these characters in order to turn it into "comment command". + <br>If the output is redirected comment commands will be passed on to it. + </dd> + + <dt>currX, currY</dt> <dd><em>currX</em> and <em>currY</em> denote the current position of the starting (upper left hand) point used when clearing, drawing or filling. It can be set with - the <a href="#cmdGoto"><em>goto x y</em></a> command (alias names for this command are - <a href="#cmdGoto"><em>location x y</em></a> and - <a href="#cmdGoto"><em>pos x y</em></a>). - The JDOR command handler will insert <em>currX</em> and <em>currY</em> whenever a + the <a href="#cmdMoveTo"><em>goto x y</em></a> command (alias names for this command are + <a href="#cmdMoveTo"><em>location x y</em></a>, + <a href="#cmdMoveTo"><em>moveTo x y</em></a>, + <a href="#cmdMoveTo"><em>pos x y</em></a> and + <a href="#cmdMoveTo"><em>position x y</em></a>). + The JDOR command handler will insert <em>currX</em> and <em>currY</em> whenever an <em>x</em> and <em>y</em> position must be supplied to a Java2D method. </dd> @@ -243,13 +351,13 @@ represents an array of float values. There are two possibilities to supply this array to the command: <ul> - <li>either as a string consisting of a comma separated list of numbers in parantheses + <li>either as a string consisting of a comma separated list of numbers in parentheses (must be quoted to form a valid Rexx string and must not contain whitespace) e.g.: <em>"(1,3,1,3)"</em> <li>or passing a Rexx variable that refers to the appropriate Java array e.g.: <br><em>dashArray=bsf.createJavaArrayOf("float.class", 1, 3, 1, 3)</em> - and then submitting the quoted name of the Rexx variable, e.g. <em>"dashArray"</em>, + and then submitting the quoted name of the Rexx variable, e.g., <em>"dashArray"</em>, as array argument; the command handler will then fetch the array from the Rexx variable (after fetching the Rexx variable by name from the command context). </ul> @@ -256,15 +364,15 @@ </dd> <dt id="dtGC">GC</dt> - <dd>A <em>graphical configuration</em>, an instance of the Java class + <dd>A <em>graphic context</em>, an instance of the Java class <em>java.awt.Graphics</em> or <em>java.awt.Graphics2D</em> which allows for interacting (drawing, transforming, etc.) with an image (a bitmap) - and maintains its state (e.g. current origin, current rotation, current color, ...). + and maintains its state (i.e. current origin, current rotation, current color, ...). The command <a href="#cmdGC"><em>GC</em></a> allows for retrieving the current <em>GC</em>. </dd> <dt>image type</dt> - <dd>The image type defines the basic properties of an image which also determines + <dd>The image type defines the basic properties of an image and also determines in which format an image can be stored in the file system. The supported types are defined as constants in the Java class <em>java.awt.image.BufferedImage</em> and are listed in the command <em><a href="#cmdNew">new</a></em>, subsection arguments. @@ -274,18 +382,26 @@ <dt>pixel</dt> <dd>picture element, usually the size of 1/72 of an inch</dd> - <dt>RGB color</dt> - <dd>A color mix of the colors <em>red</em>, <em>green</em> and <em>blue</em> each defined - with an intensity between <em>0</em> and <em>255</em>. + <dt id="dtRGB">RGB color</dt> + <dd>A color mix of the colors <em>red</em>, <em>green</em>, and <em>blue</em>, each defined + as an intensity between the integer values <em>0</em> and <em>255</em> or alternatively as a float + value between <em>0.0</em> (<em>0.0%</em>) and <em>1.0</em> (<em>100.0%</em>) representing + the percentage of the intensity (e.g. <em>0.5</em> represents <em>50.0%</em> intensity). + <br><em>Note:</em> if any of the supplied numbers includes the decimal dot then all the numbers + are taken as float values. </dd> - <dt>RGBA color</dt> - <dd>A color mix of the colors <em>red</em>, <em>green</em>, <em>blue</em> and - <em>alpha</em> (transparency/opaqueness) each defined with an intensity between - <em>0</em> and <em>255</em>. <em>Note:</em> an <em>alpha</em> intensity - of <em>0</em> means "complete transparency", and an intensitiy of - <em>255</em> means "no transparency". - + <dt id="dtRGBA">RGBA color</dt> + <dd>A color mix of the colors <em>red</em>, <em>green</em>, <em>blue</em>, and <em>alpha</em> + each defined + as an intensity between the integer values <em>0</em> and <em>255</em> or alternatively as a float + value between <em>0.0</em> (<em>0.0%</em>) and <em>1.0</em> (<em>100.0%</em>) representing + the percentage of the intensity (e.g. <em>0.5</em> represents <em>50.0%</em> intensity). + <br><em>Note:</em> if any of the supplied numbers includes the decimal dot then all the numbers + are taken as float values. + <br><em>Note:</em> an <em>alpha</em> intensity + of <em>0</em> means "complete transparency", and an intensity of + <em>255</em> (or expressed as a float value of exactly <em>1.0</em>) means "no transparency". </dd> <dt>rotate</dt> @@ -318,12 +434,12 @@ <a href="#cmdDrawPolyline"><em>drawPolyline</em></a> or <a href="#cmdFillPolygon"><em>fillPolygon</em></a> - expect two arrays for the <em>x y</em> coordinates of the - points. + expect two arrays for the <em>x</em> and <em>y</em> coordinates of the + points, respectively. There are two possibilities to supply these arrays to the JDOR command handler: <ul> - <li>either as a string consisting of a comma separated list of numbers in parantheses + <li>either as a string consisting of a comma separated list of numbers in parentheses (must be quoted to form a valid Rexx string and must not contain whitespace) e.g.: <em>"(10,30,40,50,110,140)"</em> @@ -401,7 +517,7 @@ <td class="cmdNr"> <td class="command"> "clearRect" <td colspan="2"> Clears a rectangle of the supplied <em>width</em> and <em>height</em> - at the current <em>x</em> and <em>y</em> position (cf. <em><a href="#cmdGoto">goto</a></em> command), + at the current <em>x</em> and <em>y</em> position (cf. <em><a href="#cmdMoveTo">goto</a></em> command), using the <em>background</em> (cf. <em><a href="#cmdBackground">background</a></em> command) color. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>clearRect(...)</em>. @@ -409,7 +525,7 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> width height - <td> <em>width</em> and <em>height</em> in pixel of the rectangle. + <td> <em>width</em> and <em>height</em> in pixels of the rectangle. <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> @@ -451,11 +567,13 @@ via the Rexx variable <em>RC</em>. <br>Supplying only the <em>colorNickName</em> argument will load the color from the - internal register and assign it to the <a href="#cmdGC"><em>GC</em></a> to be used for drawing from now on. + internal register and assign it to the <a href="#cmdGC"><em>GC</em></a> to + be used for drawing from now on. - <br>Supplying in addition the intensity values for the colors <em>red</em>, <em>green</em>, - <em>blue</em>, and optionally <em>alpha</em> (between <em>0</em>=fully transparent to - <em>255</em>=fully opaque), a <em>java.awt.Color</em> of that type gets created, registered with + <br>Supplying in addition <em>intensity</em> (cf. <a href="#dtRGB"><em>RGB color</em></a> or + <a href="#dtRGBA"><em>RGBA color</em></a>) + for the colors <em>red</em>, <em>green</em>, <em>blue</em>, + and optionally <em>alpha</em>, a <em>java.awt.Color</em> of that type gets created, registered with the supplied <em>colorNickName</em> and then used for setting the new color. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the @@ -466,17 +584,20 @@ <td> <td class="argument"> colorNickName <td> <em>colorNickName</em> gets uppercased and is used to look up the internal - color registry for the denoted color which should be used from now on and gets - returned via the Rexx variable <em>RC</em>. + color registry for the denoted color which should be used from now on. The + previously defined color gets gets returned via the Rexx variable <em>RC</em>. <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> colorNickName r g b [alpha] - <td> This command creates a color using an intensity beteween <em>0</em> and - <em>255</em> for each of the colors <em>red</em>, <em>green</em>, <em>blue</em> - and optionally for <em>alpha</em> (between <em>0</em>=fully transparent to <em>255</em>=fully opaque). - This color will be used from now on and gets stored in the color registry using the supplied - <em>colorNickName</em> in uppercase and returned via the Rexx variable <em>RC</em>. + <td> This command creates a color using the supplied <em>intensities</em> + (cf. <a href="#dtRGB"><em>RGB color</em></a> or + <a href="#dtRGBA"><em>RGBA color</em></a>) + for each of the colors <em>red</em>, <em>green</em>, <em>blue</em> + and optionally for <em>alpha</em>. + This color will be used from now on and gets stored in the color registry using + the supplied <em>colorNickName</em> in uppercase. The previously defined color + gets returned via the Rexx variable <em>RC</em>. <!-- -------------------------------------------------------- --> @@ -517,6 +638,23 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> + <td class="command"> "copyArea" + <td colspan="2"> Copies an area of the image to the given distance. + + <br>Cf. the Java documentation for the Java class <em>Graphics</em> and the + method <em>copyArea(...)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> width height dX dY + <td> <em>width</em> and <em>height</em> in pixels of the image area to copy, + <em>dX</em> (can be negative) and <em>dY</em> (can be negative) the + distance in pixels where to copy to. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> <td class="command"> "draw3DRect" <td colspan="2"> Draws a rectangle with 3D appearance (raised or sunken). @@ -526,7 +664,7 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> width height raised - <td> <em>width</em> and <em>height</em> in pixel of the rectangle, + <td> <em>width</em> and <em>height</em> in pixels of the rectangle, <em>raised</em> needs to be either set to <em>.true</em> for raised or to <em>.false</em> for sunken appearance. @@ -542,7 +680,7 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> width height startAngle arcAngle - <td> <em>width</em> and <em>height</em> in pixel of the rectangle, + <td> <em>width</em> and <em>height</em> in pixels of the rectangle, <em>startAngle</em> in degrees (<em>0</em> is the 3 o'clock position), <em>arcAngle</em> angular extend in degrees relative to <em>startAngle</em>. @@ -572,7 +710,7 @@ <td class="argument"> nickName width height [bkgColor] <td> <em>nickName</em> denotes the name of an image stored in the internal image registry. Draws as much of the image as possible scaled to the - <em>width</em> and <em>height</em> in pixel. + <em>width</em> and <em>height</em> in pixels. <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. @@ -581,7 +719,7 @@ <td class="argument"> nickName width height srcX1 srcY1 srcX2 srcY2 [bkgColor] <td> <em>nickName</em> denotes the name of an image stored in the internal image registry. Draws as much of the image as possible scaled to the - <em>width</em> and <em>height</em> in pixel, using from the image the rectangle + <em>width</em> and <em>height</em> in pixels, using from the image the rectangle with the first corner with the coordinate <em>srcX1</em> and <em>srcY1</em> and the second corner with the coordinate <em>srcX2</em> and <em>srcY2</em>. @@ -612,7 +750,7 @@ <td> <em>rexxVariableName</em> denotes the name of a Rexx variable that refers to an image (hint: enquote the Rexx variable name). Draws as much of the image as possible scaled to the - <em>width</em> and <em>height</em> in pixel. + <em>width</em> and <em>height</em> in pixels. <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. @@ -622,7 +760,7 @@ <td> <em>rexxVariableName</em> denotes the name of a Rexx variable that refers to an image (hint: enquote the Rexx variable name). Draws as much of the image as possible scaled to the - <em>width</em> and <em>height</em> in pixel, using from the image the rectangle + <em>width</em> and <em>height</em> in pixels, using from the image the rectangle with the first corner with the coordinate <em>srcX1</em> and <em>srcY1</em> and the second corner with the coordinate <em>srcX2</em> and <em>srcY2</em>. @@ -765,7 +903,7 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> width height raised - <td> <em>width</em> and <em>height</em> in pixel of the rectangle, + <td> <em>width</em> and <em>height</em> in pixels of the rectangle, <em>raised</em> is either set to <em>.true</em> for raised or to <em>.false</em> for sunken appearance. @@ -781,7 +919,7 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> width height startAngle arcAngle - <td> <em>width</em> and <em>height</em> in pixel of the rectangle, + <td> <em>width</em> and <em>height</em> in pixels of the rectangle, <em>startAngle</em> in degrees (<em>0</em> is the 3 o'clock position), <em>arcAngle</em> angular extent in degrees relative to <em>startAngle</em>. @@ -874,7 +1012,6 @@ <br>Supplying only the <em>fontNickName</em> argument will load the font from the internal register and use it until it gets changed again. - <br>Supplying in addition the <em>fontName</em>, a <em>java.awt.Font</em> gets loaded from the system, registered with the supplied <em>fontNickName</em> and then used for setting the new font. The font size is taken from @@ -889,8 +1026,17 @@ <td> <td class="argument"> fontNickName <td> <em>fontNickName</em> gets uppercased and is used to look up the internal - font registry for the denoted font which should be used from now on and gets - returned via the Rexx variable <em>RC</em>. + font registry for the denoted font which should be used from now on. + <br> + <em>Note:</em> if + <em>fontNickName</em> is one of the operating system independent font names + <em>"Dialog"</em>, + <em>"DialogInput"</em>, + <em>"Serif"</em>, + <em>"SansSerif"</em>, + <em>"Monospaced"</em>, then a font of this kind gets created using + the currently set <a href="#cmdFontSize"><em>fontSize</em></a> + and <a href="#cmdFontStyle"><em>fontStyle</em></a> instead. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -954,7 +1100,7 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdGC"> "GC" - <td colspan="2"> Queries the <em><a href="#dtGC">GC</a></em> (graphical configuration) object (an + <td colspan="2"> Queries the <em><a href="#dtGC">GC</a></em> (graphical context) object (an instance of the class <em>Graphics[2D]</em>) and returns it via the Rexx variable <em>RC</em> upon return from this command. One can then use all <em>Graphics[2D]</em> methods from an ooRexx program directly. @@ -969,7 +1115,6 @@ following entries are available: <ul> <li><em>colors</em> (a <em>java.util.HashMap</em>) - <li><em>currAngle</em> <li><em>currFontSize</em> <li><em>currFontStyle</em> <li><em>currVisible</em> @@ -1012,7 +1157,9 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command" id="cmdGoto"> "goto" <br> "location" <br> "pos" + <td class="command" id="cmdMoveTo"> "goto" <br> "location" + <br> "moveTo" <br> "pos" + <br> "position" <td colspan="2"> Queries or sets <em>currX</em> and <em>currX</em> in the current image. <br>Querying the current value (no argument supplied) will return it, setting @@ -1019,7 +1166,9 @@ (changing) the value to a new value will return the old (previously set) value via the Rexx variable <em>RC</em>. - <br>The command names <em>location</em> and <em>pos</em> are aliases, synonyms for this command. + <br><em>Note:</em> The command names <em>goto</em>, <em>location</em>, + <em>moveTo</em> (used for the canonical representation of this command when + output gets redirected), <em>pos</em> and <em>position</em> are aliases, synonyms. <tr class="ArgumentRowColor"><td><!-- table row --> @@ -1142,6 +1291,7 @@ <em>imageNickName</em> in the internal image registry. + <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> @@ -1187,9 +1337,10 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdPopGC"> "popGC" - <td colspan="2"> Disposes the current <a href="#dtGC"><em>GC</em></a> and replaces it by popping - a <em>GC</em> from the stack, thereby resetting all the graphical - configuration changes to that state and returns the popped (now current) <a href="#dtGC"><em>GC</em></a> + <td colspan="2"> Disposes the current <a href="#dtGC"><em>GC</em></a> + (<em>Graphics[2D]</em>) object and replaces it + by popping a <em>GC</em> from the stack, thereby resetting all + changes to that state and returns the popped (now current) <a href="#dtGC"><em>GC</em></a> via the Rexx variable <em>RC</em>. @@ -1315,15 +1466,16 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdPushGC"> "pushGC" - <td colspan="2"> Push the current <a href="#dtGC"><em>GC</em></a> (graphical configuration) on the stack, thereby - saving the current configuration (settings and transformations). This command will then - create a copy of the current <a href="#dtGC"><em>GC</em></a> which will get used from then on. + <td colspan="2"> Push the current <a href="#dtGC"><em>GC</em></a> (<em>Graphics[2D]</em>) + object on the stack, thereby saving its current state (settings and transformations). + This command will then create a copy of the current <a href="#dtGC"><em>GC</em></a> which + will get used from then on. - The pushed <a href="#dtGC"><em>GC</em></a> will get returned - via the Rexx variable <em>RC</em>. + The pushed <a href="#dtGC"><em>GC</em></a> (a <em>Graphics[2D]</em> object) will get returned + via the Rexx variable <em>RC</em>. - <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the - method <em>create()</em>. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>create()</em>. <!-- -------------------------------------------------------- --> @@ -1351,7 +1503,6 @@ <li><em>colors</em>: the <em>java.util.HashMap</em> gets emptied except for the constant colors defined in the <em>java.awt.Color</em> class - <li><em>currAngle</em>: <em>0</em> <li><em>currFontSize</em>: <em>12</em> <li><em>currFontStyle</em>: <em>0</em> <li><em>currX</em>: <em>0</em> @@ -1376,16 +1527,12 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdRotate"> "rotate" - <td colspan="2"> Queries the runtime variable <em>currAngle</em> (if no arguments are - supplied) or rotates the image such that new drawings are rotated in effect. + <td colspan="2"> Rotates the image such that new drawings are appear rotated in effect. - This command returns the value of the runtime variable <em>currAngle</em> - (which accumulates rotation theta values, but may not be correct after - <a href="#cmdPopGC">popGC</em></a> or <a href="#cmdReset">reset</em></a> commands) - via the Rexx variable <em>RC</em>. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>rotate(...)</em>. - <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the - method <em>rotate(...)</em>. Note: this command converts the supplied degrees (<em>0</em> + <br><em>Note:</em> this command converts the supplied degrees (<em>0</em> to <em>360</em>) to radians and supplies it to the Java method. <tr class="ArgumentRowColor"><td><!-- table row --> @@ -1421,7 +1568,8 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdScale"> "scale" - <td colspan="2"> Sets the scale factor for the <em>y</em> and <em>y</em> axis. + <td colspan="2"> Queries or sets the scale factor for the <em>y</em> and <em>y</em> axis. + The command returns the scale values at the time of invocation. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1434,17 +1582,35 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "setPaintMode" - <td colspan="2"> Invokes the <em>setPaintMode</em> + <td colspan="2"> Invokes the <em>setPaintMode</em> method. - <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the - method <em>setPaintMode()</em>. + <br>Cf. the Java documentation for the Java class <em>Graphics2D</em> and the + methods <em>setPaintMode()</em> and <em>setXORMode(...)</em>. <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> + <td class="command"> "setXorMode" + <td colspan="2"> Invokes the <em>setXorMode</em> method with the supplied color. + + <br>Cf. the Java documentation for the Java class <em>Graphics2D</em> and the + methods <em>setXORMode(...)</em> and <em>setPaintMode()</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> colorNickName + <td> <em>colorNickName</em> gets uppercased and is used to look up the internal + color registry for the denoted color which should be used from now on for + <em>xorMode</em> processing. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> <td class="command" id="cmdShear"> "shear" - <td colspan="2"> Sets the shear (skew) factor for the <em>y</em> and <em>y</em> axis. + <td colspan="2"> Queries or sets the shear (skew) factor for the <em>y</em> and <em>y</em> + axis. The command returns the shear values at the time of invocation. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1490,7 +1656,8 @@ <td> <td class="argument"> strokeNickName <td> <em>strokeNickName</em> is uppercased and used to fetch the stroke from the internal stroke - registry, sets the graphic configuration to it and returns the stroke via the Rexx variable <em>RC</em>. + registry, sets the <em>Graphics[2D]</em> object to it and returns the stroke via the Rexx + variable <em>RC</em>. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1528,8 +1695,10 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdTranslate"> "translate" - <td colspan="2"> Moves the origin <em>"(0,0)"</em> from the upper left hand - corner by adding <em>x</em> pixels to <em>currX</em> and <em>y</em> pixels to <em>currY</em>. + <td colspan="2"> Query or moves the current origin (originally at + <em>"(0,0)"</em>) from the upper left hand corner by adding <em>x</em> pixels + to <em>currX</em> and <em>y</em> pixels to <em>currY</em>. The command returns + the translate values at the time of invocation. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1541,6 +1710,41 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> + <td class="command" id="cmdTransform"> "transform" + <td colspan="2"> Queries, resets or changes the current + <em><a href="#dtAffineTransform">AffineTransform</em></a> settings. + The command returns six blank delimited decimal numbers in the order: <em>translateX</em>, + <em>translateY</em>, <em>scaleX</em>, <em>scaleY</em>, <em>shearX</em>, <em>shearY</em> + at the time of invocation. + </em>The <em>AffineTransform</em> defines a matrix that gets used to + calculate the effective <em>x</em> and <em>y</em> values for the target device according + to this formula: + + <p><code> x' = scaleX*x + shearX*y + translateX </code> + <br><code> y' = scaleY*y + shearY*x + translateY </code> + + <p>Cf. the Java documentation for the Java classes <em>java.awt.geom.AffineTransform</em>, + <em>java.awt.Graphics2D</em> and the methods <em>getTransform()</em>, <em>setTransform(...)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> translateX translateY scaleX scaleY shearX shearY + <td> The arguments are taken to be decimal numbers and used to set the new values to take effect. + If a value for an argument consists of a dot (.) only, then that argument's value does not + get changed (its current value gets used instead). + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> R[ESET] + <td> The current transform will be reset such that <em>translateX</em>, + <em>translateY</em>, <em>shearX</em>, <em>shearY</em> get set to <em>0.0</em> and + <em>scaleX</em> and <em>scaleY</em> to <em>1.0</em>. It is only necessary to supply + the first letter. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> <td class="command"> "winAlwaysOnTop" <td colspan="2"> Queries or sets the value. @@ -1794,31 +1998,14 @@ - <!-- -------------------------------------------------------- --> - <tr class="CommandRowColumn"><!-- table row --> - <td class="cmdNr"> - <td class="command"> "xorMode" - <td colspan="2"> Sets the <em>xorMode</em> color. - <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the - method <em>setXORMode(...)</em>. - - <tr class="ArgumentRowColor"><td><!-- table row --> - <td> - <td class="argument"> colorNickName - <td> <em>colorNickName</em> gets uppercased and is used to look up the internal - color registry for the denoted color which should be used from now on for - <em>xorMode</em> processing. - - </table> - <p> <center> <hr width="75%"> <small> - JDOC synopsis of commands, version: 100.20221023 + JDOC synopsis of commands, version: 100.20221030 <br>Acknowledgement: the author wishes to thank DI Walter Pachl <br>for his help in testing and proof reading </small> Modified: branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java =================================================================== --- branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java 2022-10-30 18:54:22 UTC (rev 1012) +++ branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java 2022-10-30 18:55:41 UTC (rev 1013) @@ -1,7 +1,6 @@ // cf. <https://zetcode.com/gfx/java2d/basicdrawing/> + // TODO: B4R -> resolving constructors, if class is not public -// TODO: define a package (e.g. org.oorexx.handler.jdor ?) -// TODO: pushGC: also save GC related current values? /* Java classes that constitute the JDOR ("JavaDrawing ooRexx") command handler. @@ -11,7 +10,7 @@ author: Rony G. Flatscher date: 2022-09-05/2022-10-05 - version: 003.20221020 + version: 003.20221030 license: Apache license 2.0 license: @@ -48,11 +47,33 @@ - new command "drawImageFromVar": allow an image referred to by a Rexx variable to be drawn (to ease drawing images on different JDOR handler instances) - 2022-10-22: - fold DRAW_IMAGE_FROM_VAR into DRAW_IMAGE + 2022-10-22: - fold DRAW_IMAGE_FROM_VAR into DRAW_IMAGE implementation - corrected LOAD_IMAGE to return dimension instead of image (cf. documentation) - change logic for queryable and setable commands: if setting new value, return previous value - 2022-10-23: - reworkd some WIN_* commands to not automatically create and show JFrame + 2022-10-23: - reworked some WIN_* commands to not automatically create and show JFrame + 2022-10-26: - allow float values to define colors in addition to int values + - add synonym POSITION for POS command + 2022-10-27: - added command "copyImage" + 2022-10-28: - translate, scale and shear now return values at time of invocation + - new command "transform" to allow querying, setting and resetting Graphics2D's + AffineTransform + 2022-10-29: - "transform": uses default AffineTransform() for reset, "reset" argument can + be reduced to first letter ('r' or 'R'), setting argument values + now allows to use the Rexx anonymous variable "." (the dot) which + causes no change in the respective argument's value (its current + value gets reused) + - fixed errors in areas tested for the first time (like testing caps or linend values) + - added string2int(strValue): allows for supplying float and double values but + return an int value rounded with Math.round() in places where floats may be + produced (e.g. calculating positions, lengths, widths) but Graphics[2D] methods + expect int values instead + 2022-10-30: - add public instance fields "bUseNames4canonical" (true -> replace ints with + constant names, else int value) and "bUseInt4numbers" (true -> use int value, + else number as supplied) + - "font": fixed bug if using one of the operating system independent (logical) + fonts named "Dialog", "DialogInput", "Serif", "SansSerif", "Monospaced": + now honors also fontSize and fontStyle */ /* Sample program in ooRexx (temporarily): @@ -107,6 +128,7 @@ import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.geom.AffineTransform; import java.awt.Toolkit; import javax.swing.JFrame; import javax.swing.JPanel; @@ -239,7 +261,7 @@ /* static definitions */ // default image sizes - static final public String version = "005.20221022"; + static final public String version = "005.20221030"; static final private int prefWidth = 500; static final private int prefHeight = 500; static private int prefImageType = BufferedImage.TYPE_INT_ARGB; // default with alpha (only png supported) @@ -331,6 +353,9 @@ int nrCommand=0; // in case many commands, indicates which command may have caused an error or failure condition + public boolean bUseNames4canonical=true; // if true: use constant names instead of int values in canonical output + public boolean bUseInt4numbers =true; // if true: use int values instead of the supplied numbers in canonical output + /* instance definitions */ JavaDrawingFrame jd = null; // maintance a singleton or empty boolean bDebug=false; // true; // false; // true @@ -337,7 +362,6 @@ // we draw here and do a drawImage in the Surface paint BufferedImage bufImage = null; - // int currImageType = prefImageType; Graphics2D bufGC = null; /* printer related values */ @@ -348,9 +372,6 @@ /* current values */ int currX = 0; int currY = 0; -// TODO: if popGC reset currAngle to that one; needs to also push currAngle; -// not necessary in the first incarnation - double currAngle = 0; // if rotate gets used, keeps current angle (in radians) int currFontStyle = 0; // PLAIN by default int currFontSize = 12; // by default @@ -378,7 +399,6 @@ { currX = 0; currY = 0; - currAngle = 0; currFontStyle = 0; // PLAIN by default currFontSize = 12; @@ -602,10 +622,17 @@ if (arrCommand.length==3) { - newX = Integer.parseInt(arrCommand[1]); - newY = Integer.parseInt(arrCommand[2]); + newX = string2int(arrCommand[1]); + newY = string2int(arrCommand[2]); jd.setLocation(newX, newY); - canonical = canonical+" "+newX+" "+newY; + if (bUseInt4numbers) + { + canonical = canonical+" "+newX+" "+newY; + } + else + { + canonical = canonical+" "+arrCommand[1]+" "+arrCommand[2]; + } } if (isOR) @@ -921,12 +948,20 @@ throw new IllegalArgumentException("this command needs no or exactly 2 arguments, received "+(arrCommand.length-1)+" instead"); } - int newWidth = Integer.parseInt(arrCommand[1]); - int newHeight = Integer.parseInt(arrCommand[2]); + int newWidth = string2int(arrCommand[1]); + int newHeight = string2int(arrCommand[2]); if (isOR) { - writeOutput(slot, canonical+" "+newWidth+" "+newHeight); + if (bUseInt4numbers) + { + canonical = canonical+" "+newWidth+" "+newHeight; + } + else + { + canonical = canonical+" "+arrCommand[1]+" "+arrCommand[2]; + } + writeOutput(slot, canonical); } // no exception, so args o.k. jd.resizeSurface(newWidth, newHeight); // will use invokeLater() @@ -1023,11 +1058,11 @@ resultValue = printPosX+" "+printPosY; // query current value (to be returned if change occurs) - int newX = Integer.parseInt(arrCommand[1]); + int newX = string2int(arrCommand[1]); int newY = newX; // default to newX if (arrCommand.length==3) { - newY = Integer.parseInt(arrCommand[2]); + newY = string2int(arrCommand[2]); } // no exception, so args o.k. printPosX = newX; @@ -1034,7 +1069,15 @@ printPosY = newY; if (isOR) { - canonical=canonical+" "+newX+" "+newY; + if (bUseInt4numbers) + { + canonical = canonical+" "+newX+" "+newY; + } + else + { + canonical = canonical+" "+arrCommand[1] + " " + + (arrCommand.length==3 ? arrCommand[2] : arrCommand[1]); + } } if (isOR) { @@ -1103,33 +1146,52 @@ case SHEAR: // "shear x [y]" set scale for x, y; if y omitted, uses x { int argNum=arrCommand.length; - if (argNum<2 || argNum>3) + if (argNum>3) { - throw new IllegalArgumentException("this command needs either one or 2 arguments, received "+(arrCommand.length-1)+" instead"); + throw new IllegalArgumentException("this command needs either no, one or 2 arguments, received "+(arrCommand.length-1)+" instead"); } - double newX = Double.parseDouble(arrCommand[1]); - double newY = newX; // default to X value in case Y value is omitted - if (argNum==3) // Y value supplied, use it - { - newY=Double.parseDouble(arrCommand[2]); - } - String strResult= newX+" "+newY; + // get current settings + AffineTransform at=bufGC.getTransform(); + String strResult=null; + double newX=0, newY=0; if (cmd==Command.SCALE) { - bufGC.scale(newX,newY); + strResult=at.getScaleX()+" "+at.getScaleY(); } - else + else // SHEAR { - bufGC.shear(newX,newY); + strResult=at.getShearX()+" "+at.getShearY(); } + + if (argNum>1) // set value + { + newX = Double.parseDouble(arrCommand[1]); + newY = newX; // default to X value in case Y value is omitted + if (argNum==3) // Y value supplied, use it + { + newY=Double.parseDouble(arrCommand[2]); + } + + if (cmd==Command.SCALE) + { + bufGC.scale(newX,newY); + } + else + { + bufGC.shear(newX,newY); + } + } if (isOR) { - writeOutput(slot, canonical+" "+strResult); // write canonical form + if (argNum>1) + { + canonical=canonical+" "+newX+" "+newY; + } + writeOutput(slot, canonical); // write canonical form } - // return strResult; - return null; // returns null, i.e. RC="0" -> command executed alright + return strResult; // current/old settings } case NEW: // "new [width height [type]]" creates a new BufferedImage @@ -1144,11 +1206,18 @@ if (arrCommand.length>2) { - width = Integer.parseInt(arrCommand[1]); - height = Integer.parseInt(arrCommand[2]); + width = string2int(arrCommand[1]); + height = string2int(arrCommand[2]); if (isOR) { - canonical = canonical + " " + width + " " + height; + if (bUseInt4numbers) + { + canonical = canonical+" "+width+" "+height; + } + else + { + canonical = canonical+" "+arrCommand[1] + " " + arrCommand[2]; + } } if (arrCommand.length>3) @@ -1158,7 +1227,7 @@ { if (!imageTypes.containsKey(argType)) { - throw new IllegalArgumentException("unknown value for \"type\" argument"); + throw new IllegalArgumentException("unknown value for \"type\" argument: \""+arrCommand[3]+"\""); } type=imageTypes.get(argType); } @@ -1167,12 +1236,13 @@ type=Integer.parseInt(arrCommand[3]); if (!imageTypes.containsValue(type)) { - throw new IllegalArgumentException("unknown value for \"type\" argument"); + throw new IllegalArgumentException("unknown value for \"type\" argument: \""+arrCommand[3]+"\""); } } if (isOR) { - canonical = canonical + " " + argType; + canonical = canonical + " " + + (bUseNames4canonical ? imageTypesInt2Name.get(type) : argType) ; } } } @@ -1195,7 +1265,14 @@ while (tmpGC != null) { tmpGC.dispose(); - tmpGC = adGCStack.pop(); + if (adGCStack.size()>0) + { + tmpGC = adGCStack.pop(); // pop next GC + } + else // no more GCs on stack + { + tmpGC = null; + } } bufGC.dispose(); bufGC=null; @@ -1228,7 +1305,7 @@ { if (!imageTypes.containsKey(newType)) { - throw new IllegalArgumentException("unknown value for \"type\" argument"); + throw new Illegal... [truncated message content] |
From: <or...@us...> - 2022-10-30 18:54:24
|
Revision: 1012 http://sourceforge.net/p/bsf4oorexx/code/1012 Author: orexx Date: 2022-10-30 18:54:22 +0000 (Sun, 30 Oct 2022) Log Message: ----------- 20221030 Fixed bug in loading operating system independent fonts, add a few new examples. Modified Paths: -------------- sandbox/rgf/jdor/JavaDrawingHandler.java sandbox/rgf/jdor/doc/jdor_doc.html Added Paths: ----------- sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass_float_colors.rxj sandbox/rgf/jdor/samples/2-120_JDOR_shear.rxj sandbox/rgf/jdor/samples/2-130_JDOR_animate_two_frames.rxj sandbox/rgf/jdor/samples/3-110_JDOR_animate_composite.rxj Modified: sandbox/rgf/jdor/JavaDrawingHandler.java =================================================================== --- sandbox/rgf/jdor/JavaDrawingHandler.java 2022-10-30 14:30:13 UTC (rev 1011) +++ sandbox/rgf/jdor/JavaDrawingHandler.java 2022-10-30 18:54:22 UTC (rev 1012) @@ -71,6 +71,9 @@ 2022-10-30: - add public instance fields "bUseNames4canonical" (true -> replace ints with constant names, else int value) and "bUseInt4numbers" (true -> use int value, else number as supplied) + - "font": fixed bug if using one of the operating system independent (logical) + fonts named "Dialog", "DialogInput", "Serif", "SansSerif", "Monospaced": + now honors also fontSize and fontStyle */ /* Sample program in ooRexx (temporarily): @@ -2240,17 +2243,28 @@ { canonical = canonical + " " + fontNickName; } - if (arrCommand.length==2) + + + // Dialog", "DialogInput", "Serif", "SansSerif", "Monospaced" + if (arrCommand.length==2 ) { font = hmFonts.get(fontNickName.toUpperCase()); if (font==null) { - String errMsg="font with the supplied nickname \""+fontNickName+"\" is not registered"; - if (isOR) + // maybe one of the five operating system independent fonts? + if ("Dialog DialogInput Serif SansSerif Monospaced".indexOf(fontNickName)>=0) { - writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); + font = new Font(fontNickName, currFontStyle, currFontSize); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-10", errMsg ); + if (font==null) + { + String errMsg="font with the supplied nickname \""+fontNickName+"\" is not registered"; + if (isOR) + { + writeOutput(slot, "-- ERROR (nickname argument): ["+command+"]"); + } + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-10", errMsg ); + } } bufGC.setFont(font); if (isOR) Modified: sandbox/rgf/jdor/doc/jdor_doc.html =================================================================== --- sandbox/rgf/jdor/doc/jdor_doc.html 2022-10-30 14:30:13 UTC (rev 1011) +++ sandbox/rgf/jdor/doc/jdor_doc.html 2022-10-30 18:54:22 UTC (rev 1012) @@ -288,18 +288,20 @@ <dt id="dtAffineTransform">AffineTransform</dt> <dd>The Java class <em>java.awt.geom.AffineTransform</em> - allows to define and maintain the <em>scale(...)</em>, <em>shear(...)</em>, <em>translate(...)</em> + allows to define and maintain the <em>translate</em>, <em>scale</em>, <em>shear</em> factors in a matrix. <em>java.awt.Graphics2D</em> methods use it to calculate the effective <em>x</em> and <em>y</em> values. <br>The commands - <em><a href="#cmdScale">scale(...)</a></em>, - <em><a href="#cmdShear">shear(...)</a></em> - <em><a href="#cmdTranslate">translate(...)</a></em> will cause the respective factors + <em><a href="#cmdTranslate">translate</a></em>, + <em><a href="#cmdScale">scale</a></em>, + <em><a href="#cmdShear">shear</a></em> + will cause the respective factors to be changed accordingly in the <em>Graphics2D</em>'s maintained <em>AffineTransform</em>. <br>The <em><a href="#cmdTransform">transform</a></em> command allows to interact with - the <em>Graphics2D</em>'s <em>AffineTransform</em> to query, change or reset the - transform factors. + the <em>Graphics2D</em>'s <em>AffineTransform</em> to query, set or reset the + six transform factors <em>translateX</em>, <em>translateY</em>, + <em>scaleX</em>, <em>scaleY</em>, <em>shearX</em>, <em>shearY</em> directly. </dd> <dt>coordinate system</dt> @@ -1010,7 +1012,6 @@ <br>Supplying only the <em>fontNickName</em> argument will load the font from the internal register and use it until it gets changed again. - <br>Supplying in addition the <em>fontName</em>, a <em>java.awt.Font</em> gets loaded from the system, registered with the supplied <em>fontNickName</em> and then used for setting the new font. The font size is taken from @@ -1025,8 +1026,17 @@ <td> <td class="argument"> fontNickName <td> <em>fontNickName</em> gets uppercased and is used to look up the internal - font registry for the denoted font which should be used from now on and gets - returned via the Rexx variable <em>RC</em>. + font registry for the denoted font which should be used from now on. + <br> + <em>Note:</em> if + <em>fontNickName</em> is one of the operating system independent font names + <em>"Dialog"</em>, + <em>"DialogInput"</em>, + <em>"Serif"</em>, + <em>"SansSerif"</em>, + <em>"Monospaced"</em>, then a font of this kind gets created using + the currently set <a href="#cmdFontSize"><em>fontSize</em></a> + and <a href="#cmdFontStyle"><em>fontStyle</em></a> instead. <tr class="ArgumentRowColor"><td><!-- table row --> <td> @@ -1706,8 +1716,14 @@ The command returns six blank delimited decimal numbers in the order: <em>translateX</em>, <em>translateY</em>, <em>scaleX</em>, <em>scaleY</em>, <em>shearX</em>, <em>shearY</em> at the time of invocation. + </em>The <em>AffineTransform</em> defines a matrix that gets used to + calculate the effective <em>x</em> and <em>y</em> values for the target device according + to this formula: - <br>Cf. the Java documentation for the Java classes <em>java.awt.geom.AffineTransform</em>, + <p><code> x' = scaleX*x + shearX*y + translateX </code> + <br><code> y' = scaleY*y + shearY*x + translateY </code> + + <p>Cf. the Java documentation for the Java classes <em>java.awt.geom.AffineTransform</em>, <em>java.awt.Graphics2D</em> and the methods <em>getTransform()</em>, <em>setTransform(...)</em>. <tr class="ArgumentRowColor"><td><!-- table row --> @@ -1989,7 +2005,7 @@ <center> <hr width="75%"> <small> - JDOC synopsis of commands, version: 100.20221029 + JDOC synopsis of commands, version: 100.20221030 <br>Acknowledgement: the author wishes to thank DI Walter Pachl <br>for his help in testing and proof reading </small> Added: sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass_float_colors.rxj =================================================================== --- sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass_float_colors.rxj (rev 0) +++ sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass_float_colors.rxj 2022-10-30 18:54:22 UTC (rev 1012) @@ -0,0 +1,82 @@ +#!/usr/bin/env rexx +/* + Name: "1-180_JDOR_sandGlass_float_colors.rxj" + Invoke: "rexx 1-180_JDOR_sandGlass_float_colors.rxj" + "rexxj 1-180_JDOR_sandGlass_float_colors.rxj" (Windows) + "rexxj.sh 1-180_JDOR_sandGlass_float_colors.rxj" (Unix) + + Purpose: Demonstrates the use of JDOR for drawing a sand glass using different + colors and strokes. The colors get defined as float values between + 0.0 and 1.0 corresponding to the colors in 1-180_JDOR_sandGlass.rxj + + Date: 2022-10-26 + + Author: Rony G. Flatscher, WU Vienna + + Changes: -- + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- +*/ + +call addJdorHandler -- load and add the Java Rexx command handler, using default name: JDOR +address jdor -- set default environment to JDOR +stroke st5 5 -- define stroke of 5 pts +stroke st3 3 -- define stroke of 3 pts +stroke st1 1 -- define stroke of 1 pt + +-- color saddlebrown50 139 69 19 128 -- R,G,B,alpha=128 (~50 % transparency) +-- as floats (at least one of the arguments must include the dot): +r=0.545098039 -- 53,7% red (or: 139/255) +g=0.270588235 -- 27,1% green (or: 69/255) +b=0.0745098039 -- 7,5% blue (or: 19/255) +a=0.5 -- 50,0% alpha (or: 128 of 256) +color saddlebrown50 r g b a -- define and set this color + +-- color green20 0 255 0 51 -- R,G,B,alpha= 51 (~20 % transparency) +-- as floats (at least one of the arguments must include the dot): +r=0.0 -- 0,0% red (or: 0/255) +g=1.0 -- 100,0% green (or: 255/255) +b=0.0 -- 0,0% blue (or: 0/255) +a=0.2 -- 20,0% alpha (or: 51/255) +color green20 r g b a -- define and set this color + +strokes=st1, st3, st5 -- Rexx array of stroke nick names +colors =black, saddlebrown50, green20 -- Rexx array of color nick names +width=500 +height=500 +new width height -- create new bitmap +winShow -- show frame +do i=1 to 3 + m=50+(i-1)*50 -- margin + w = width-m + h = height-m + color colors[i] + stroke strokes[i] + goto m m; drawLine w m + goto w m; drawLine m h + goto m h; drawLine w h + goto w h; drawLine m m +end +sleep 3 -- sleep for three seconds +-- say 'hit enter to continue...'; parse pull . + +::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available \ No newline at end of file Property changes on: sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass_float_colors.rxj ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: sandbox/rgf/jdor/samples/2-120_JDOR_shear.rxj =================================================================== --- sandbox/rgf/jdor/samples/2-120_JDOR_shear.rxj (rev 0) +++ sandbox/rgf/jdor/samples/2-120_JDOR_shear.rxj 2022-10-30 18:54:22 UTC (rev 1012) @@ -0,0 +1,137 @@ +#!/usr/bin/env rexx +/* + Name: "2-120_JDOR_shear.rxj" + Invoke: "rexx 2-120_JDOR_shear.rxj" + "rexxj 2-120_JDOR_shear.rxj" (Windows) + "rexxj.sh 2-120_JDOR_shear.rxj" (Unix) + + Purpose: Demonstrates the use of the JDOR commands to create arrowed axes with + ticks (every 0.5cm and 1.0cm) arrows and a rectangle (one by two centimeters). + The same drawing gets created at a different location demonstrating the effect + of shear. This sample can be used to compare the Rexx commands directly with + a Java program (http://www.java2s.com/Code/Java/2D-Graphics-GUI/TransformShear.htm) + that achieves the same drawing by using the <em>Java2D</em> APIs + directly. + + Date: 2022-10-30 + + Author: Rony G. Flatscher, WU Vienna + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- +*/ + +jdor=.bsf~new("org.oorexx.handlers.jdor.JavaDrawingHandler") -- create a JDOR handler +call BsfCommandHandler "add", "JDOR", jdor -- add the JDOR handler to ooRexx + +address jdor -- set default environment to JDOR +-- address jdor with error using (.error) -- show error/failures in detail (for debugging) + +pkgLocal=.context~package~local -- get package's local environment + -- add PIXEL.PER.CM entry to it, thereafter can be retrieved via the + -- environment symbol .PIXEL.PER.CM from any place in this package +pkgLocal~pixel.per.cm = 72 / 2.54 -- there are 72 dots per inch, an inch is 2.54cm -> 28.3464567 pixel per cm + +new 450 350 -- create image +winShow -- show image in a window (a JFrame) +winTitle "Shear Sample (a Transform)" + +call drawFigure -- draw figure + +translate 150 0 -- move current origin 150 pixels to the right +shear (-.5) 0 -- apply shearing +stroke str1 1 CAP_BUTT JOIN_BEVEL 0 "(3,1)" 0 -- change line for drawing +color blue -- change color +call drawFigure -- draw the same figure as above + +say "Press enter to end ..." +parse pull . +exit + +drawFigure: procedure -- moves origin, draws axes with right and down error, draws rectangle + lineLength = 54 + arrowLength = 4 + tickSize = 4 + + translate 75 75 + call drawAxes lineLength + call drawArrows arrowLength, lineLength + call drawTickMarks .5, tickSize/2, lineLength -- half-centimeter tick marks + call drawTickMarks 1 , tickSize, lineLength -- Full-centimeter tick marks + call drawRect 1, 1, 2, 1 -- in cm: x, y, width, height + return + +drawAxes: procedure + use strict arg lineLength=54 + -- x-axis + moveTo (-lineLength) 0 + drawLine lineLength 0 + -- y-axis + moveTo 0 (-lineLength) + drawLine 0 lineLength + return + +drawArrows: procedure + use strict arg arrowLength=4, lineLength=54 + -- arrows + arr_endpoint = lineLength-arrowLength -- left and right hand y-location of arrow ends + -- x-axis, right arrow + moveTo arr_endpoint (-arrowLength) -- upper endpoint + drawLine lineLength 0 + moveTo arr_endpoint arrowLength -- lower endpoint + drawLine lineLength 0 + -- y-axis, down arrow + moveTo (-arrowLength) arr_endpoint -- left endpoint + drawLine 0 lineLength + moveTo arrowLength arr_endpoint -- right endpoint + drawLine 0 lineLength + return + +drawTickMarks: procedure + use strict arg tickStart, tickSize=4, lineLength=54 + + do i = tickStart while i < lineLength/.pixel.per.cm + tick = i * .pixel.per.cm + -- x-axis + moveTo tick (-tickSize) + drawLine tick tickSize + moveTo (-tick) (-tickSize) + drawLine (-tick) tickSize + -- y-axis + moveTo (-tickSize) tick -- y-axis + drawLine tickSize tick + moveTo (-tickSize) (-tick) + drawLine tickSize (-tick) + end + return + +drawRect: procedure + use strict arg x=1, y=1, w=2, h=1 -- arguments are cm values + x=x*.pixel.per.cm -- calculate pixels + y=y*.pixel.per.cm -- calculate pixels + w=w*.pixel.per.cm -- calculate pixels + h=h*.pixel.per.cm -- calculate pixels + moveTo x y + drawRect w h + return + +::requires "BSF.CLS" -- get ooRexx-Java bridge + Property changes on: sandbox/rgf/jdor/samples/2-120_JDOR_shear.rxj ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: sandbox/rgf/jdor/samples/2-130_JDOR_animate_two_frames.rxj =================================================================== --- sandbox/rgf/jdor/samples/2-130_JDOR_animate_two_frames.rxj (rev 0) +++ sandbox/rgf/jdor/samples/2-130_JDOR_animate_two_frames.rxj 2022-10-30 18:54:22 UTC (rev 1012) @@ -0,0 +1,113 @@ +#!/usr/bin/env rexx +/* + Name: "2-130_JDOR_animate_two_frames.rxj" + Invoke: "rexx 2-130_JDOR_animate_two_frames.rxj" + "rexxj 2-130_JDOR_animate_two_frames.rxj" (Windows) + "rexxj.sh 2-130_JDOR_animate_two_frames.rxj" (Unix) + + Purpose: Demonstrates the use of the JDOR commands to create two JDOR command handlers, + moving their windows (frames) to the top left and top right hand side (that + window has its frame removed) of the current screen, being always + displayed on top of all other windows. The first (top left) handler is + used to load three logos and draw them at different sizes, using the + resulting image to draw it on the second (top right) window repeatedly after + rotating and briefly sleeping, such that the top right window gets animated + (approximately 30 times per second). + + Date: 2022-10-30 + + Author: Rony G. Flatscher, WU Vienna + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- +*/ + +jdor=.bsf~new("org.oorexx.handlers.jdor.JavaDrawingHandler") +call BsfCommandHandler "add", "JDOR", jdor + +sdor=.bsf~new("org.oorexx.handlers.jdor.JavaDrawingHandler") +call BsfCommandHandler "add", "SDOR", sdor + +address jdor -- set default environment to JDOR +-- address jdor with error using (.error) -- use for debugging the JDOR commands + +w=400 -- width +h=400 -- height +center=w/2 h/2 -- center of image (used in rotate command below) +new w h -- create new bitmap + +address sdor new w h -- create new bitmap with the same dimension +address sdor winFrame .false -- remove frame + +winShow -- show frame +winAlwaysOnTop .true -- make sure frame is always on top +winMoveTo 0 0 -- move to left upper corner of screen + +address sdor winShow -- show window (without frame) +-- say "press enter to continue"; parse pull + +winScreenSize -- query current screen's size +parse var rc scrW scrH +address sdor winMoveTo (scrW-w) 0 -- move frameless window to upper right corner +address sdor winAlwaysOnTop .true -- make sure window remains on top of all other windows + +say "the two windows are set to be always on top of all other windows" + +loadImage b4r_logo bsf4oorexx_256.png -- load the bsf4oorexx bitmap +moveTo 110 110 +drawImage b4r_logo 50 50 -- upper left hand side + +moveTo (w-110) (h-110) -- lower right hand side +loadImage ooo_logo oorexx4ooo_256.png -- load OOo bitmap +drawImage ooo_logo 50 50 + +orxX = (w-75)/2 -- calculate to place ooRexx logo to center +orxY = (h-75)/2 +moveTo orxX orxY -- center +loadImage orx_logo oorexx_256.png +drawImage orx_logo 75 75 + +say "fetching the current image from the left window ..." +image -- query current image, command return value in variable "RC" +say "image returned in variable ""RC"":" pp(rc) +jImage=rc -- save image in Rexx variable named "jImage" +say "image~toString:" pp(jImage~toString) +say + -- note the name of a Rexx variable needs to be quoted, otherwise its value gets used +address sdor drawImageFromVar "jImage" -- use image from Rexx variable named "jImage" +sleep 0.75 -- sleep (wait) a bit + +sleepTime=1/30 -- appr. 30 updates per second +say "animate rotating image on the right (frameless) window ..." +round=0 +do i=0 to 360+90 by 5 -- rotate 1 1/4 rounds ... + round+=1 + address sdor rotate i center -- rotate transform + address sdor drawImageFromVar "jImage" -- draw image referred to by the Rexx variable "jImage" + sleep sleepTime -- sleeping causes animation effect +end +say "finished after" pp(round) "rotations" + +say "press enter to end ..." +parse pull + +::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available + Property changes on: sandbox/rgf/jdor/samples/2-130_JDOR_animate_two_frames.rxj ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: sandbox/rgf/jdor/samples/3-110_JDOR_animate_composite.rxj =================================================================== --- sandbox/rgf/jdor/samples/3-110_JDOR_animate_composite.rxj (rev 0) +++ sandbox/rgf/jdor/samples/3-110_JDOR_animate_composite.rxj 2022-10-30 18:54:22 UTC (rev 1012) @@ -0,0 +1,118 @@ +#!/usr/bin/env rexx +/* + Name: "3-110_animate_composite.rxj" + Invoke: "rexx 3-110_animate_composite.rxj" + "rexxj 3-110_animate_composite.rxj" (Windows) + "rexxj.sh 3-110_animate_composite.rxj" (Unix) + + Purpose: Demonstrates the usage of the "composite" command to realize + fade-in animation effects as well as moving out bitmaps (images) + over the bottom edge, over the left edge and diagonally to the + upper right hand corner. The window (frame) to demonstrate the + animation effects gets positioned without a frame to the lower + right hand of the screen. + + Date: 2022-10-30 + + Author: Rony G. Flatscher, WU Vienna + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- +*/ + +/* Cf. e.g. <https://docs.oracle.com/javase/tutorial/2d/advanced/compositing.html> */ + +jdor=.bsf~new("org.oorexx.handlers.jdor.JavaDrawingHandler") +call BsfCommandHandler "add", "JDOR", jdor + +-- address jdor -- set default environment to JDOR +address jdor with error using (.error) -- set default environment to JDOR + +w=400 -- width +h=400 -- height +center=w/2 h/2 -- center of image +new w h -- create new bitmap + +winFrame .false -- hide frame +winScreenSize -- get current screen size +parse var rc width height -- parse dimension +winMoveTo (width-w) (height-h) -- move to screen's lower right hand corner +winShow -- show frame +winAlwaysOnTop .true -- show it always on top of all other windows + +b4r_x = 110 -- position of bsf4oorexx logo + -- define filenames, locations and sizes of three bitmaps +locations=.array~of( "bsf4oorexx_256.png" b4r_x b4r_x 50 , - + "oorexx4ooo_256.png" (w-b4r_x) (w-b4r_x) 50, - + "oorexx_256.png" trunc((w-75)/2) trunc((h-75)/2) 75) +say "fade in ..." +do loc over locations -- load and draw bitmaps + say "processing:" pp(loc) + parse var loc name x y size + loadImage name name -- load image from file use filename as nick name + moveTo x y -- move to desired location + composite src_over 0.01 -- composite set to transparent (alpha to 0.01) + do i=1 to 100 -- repeatedly drawing adds current alpha to existing picture (fade in) + drawImage name size size -- draw image with desired size + sleep 0.01 -- sleep causes animation effect + end + composite src_over -- reset composite (defaulting alpha to 1.0) + drawImage name size size -- draw image with alpha 1.0 +end + +say "Moving out ..." +do counter c loc over locations + parse var loc name x y size + say "#" c": moving out - name:" name "x:" x "y:" y "size:" size + moveTo x y + loop + winUpdate .false -- do not update window (frame) + composite clear -- use CLEAR composite (to remove image) + drawImage name size size -- draw image with given size, clears it + composite src_over -- re-establish writing src over destination + select case c -- determine how we move out + when 1 then y=y+1 -- bsf4oorexx_256.png: move down + when 2 then x=x-1 -- oorexx4ooo_256.png: move left + otherwise -- oorexx_256.png: move diagonally right and up + x=x+1 + y=y-1 + end + moveTo x y -- go to next position + drawImage name size size -- draw at new position + winUpdate .true -- do not update window (frame) + + if x>w | (x+size)<0 then leave + if y>w | (y+size)<0 then leave + sleep 0.01 -- sleep causes animation effect + end +end + +moveTo 25 200 +color blue +fontSize 18 +font "Serif" +drawString "Wer are done, goodbye! (press enter to end ...)" + +say "press enter to end ..." +parse pull + +::requires "BSF.CLS" -- get ooRexx-Java bridge + Property changes on: sandbox/rgf/jdor/samples/3-110_JDOR_animate_composite.rxj ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <or...@us...> - 2022-10-30 14:30:14
|
Revision: 1011 http://sourceforge.net/p/bsf4oorexx/code/1011 Author: orexx Date: 2022-10-30 14:30:13 +0000 (Sun, 30 Oct 2022) Log Message: ----------- 20221030 Adding copyArea and transform commands, use constant names and int values by default in canonical version, when output got redirected, adjust documentation. Modified Paths: -------------- sandbox/rgf/jdor/JavaDrawingHandler.java sandbox/rgf/jdor/doc/jdor_doc.html sandbox/rgf/jdor/doc/jdor_doc_sample.rex sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass.rxj Modified: sandbox/rgf/jdor/JavaDrawingHandler.java =================================================================== --- sandbox/rgf/jdor/JavaDrawingHandler.java 2022-10-23 14:35:22 UTC (rev 1010) +++ sandbox/rgf/jdor/JavaDrawingHandler.java 2022-10-30 14:30:13 UTC (rev 1011) @@ -1,7 +1,6 @@ // cf. <https://zetcode.com/gfx/java2d/basicdrawing/> + // TODO: B4R -> resolving constructors, if class is not public -// TODO: define a package (e.g. org.oorexx.handler.jdor ?) -// TODO: pushGC: also save GC related current values? /* Java classes that constitute the JDOR ("JavaDrawing ooRexx") command handler. @@ -11,7 +10,7 @@ author: Rony G. Flatscher date: 2022-09-05/2022-10-05 - version: 003.20221020 + version: 003.20221030 license: Apache license 2.0 license: @@ -48,11 +47,30 @@ - new command "drawImageFromVar": allow an image referred to by a Rexx variable to be drawn (to ease drawing images on different JDOR handler instances) - 2022-10-22: - fold DRAW_IMAGE_FROM_VAR into DRAW_IMAGE + 2022-10-22: - fold DRAW_IMAGE_FROM_VAR into DRAW_IMAGE implementation - corrected LOAD_IMAGE to return dimension instead of image (cf. documentation) - change logic for queryable and setable commands: if setting new value, return previous value - 2022-10-23: - reworkd some WIN_* commands to not automatically create and show JFrame + 2022-10-23: - reworked some WIN_* commands to not automatically create and show JFrame + 2022-10-26: - allow float values to define colors in addition to int values + - add synonym POSITION for POS command + 2022-10-27: - added command "copyImage" + 2022-10-28: - translate, scale and shear now return values at time of invocation + - new command "transform" to allow querying, setting and resetting Graphics2D's + AffineTransform + 2022-10-29: - "transform": uses default AffineTransform() for reset, "reset" argument can + be reduced to first letter ('r' or 'R'), setting argument values + now allows to use the Rexx anonymous variable "." (the dot) which + causes no change in the respective argument's value (its current + value gets reused) + - fixed errors in areas tested for the first time (like testing caps or linend values) + - added string2int(strValue): allows for supplying float and double values but + return an int value rounded with Math.round() in places where floats may be + produced (e.g. calculating positions, lengths, widths) but Graphics[2D] methods + expect int values instead + 2022-10-30: - add public instance fields "bUseNames4canonical" (true -> replace ints with + constant names, else int value) and "bUseInt4numbers" (true -> use int value, + else number as supplied) */ /* Sample program in ooRexx (temporarily): @@ -107,6 +125,7 @@ import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.geom.AffineTransform; import java.awt.Toolkit; import javax.swing.JFrame; import javax.swing.JPanel; @@ -239,7 +258,7 @@ /* static definitions */ // default image sizes - static final public String version = "005.20221022"; + static final public String version = "005.20221030"; static final private int prefWidth = 500; static final private int prefHeight = 500; static private int prefImageType = BufferedImage.TYPE_INT_ARGB; // default with alpha (only png supported) @@ -331,6 +350,9 @@ int nrCommand=0; // in case many commands, indicates which command may have caused an error or failure condition + public boolean bUseNames4canonical=true; // if true: use constant names instead of int values in canonical output + public boolean bUseInt4numbers =true; // if true: use int values instead of the supplied numbers in canonical output + /* instance definitions */ JavaDrawingFrame jd = null; // maintance a singleton or empty boolean bDebug=false; // true; // false; // true @@ -337,7 +359,6 @@ // we draw here and do a drawImage in the Surface paint BufferedImage bufImage = null; - // int currImageType = prefImageType; Graphics2D bufGC = null; /* printer related values */ @@ -348,9 +369,6 @@ /* current values */ int currX = 0; int currY = 0; -// TODO: if popGC reset currAngle to that one; needs to also push currAngle; -// not necessary in the first incarnation - double currAngle = 0; // if rotate gets used, keeps current angle (in radians) int currFontStyle = 0; // PLAIN by default int currFontSize = 12; // by default @@ -378,7 +396,6 @@ { currX = 0; currY = 0; - currAngle = 0; currFontStyle = 0; // PLAIN by default currFontSize = 12; @@ -602,10 +619,17 @@ if (arrCommand.length==3) { - newX = Integer.parseInt(arrCommand[1]); - newY = Integer.parseInt(arrCommand[2]); + newX = string2int(arrCommand[1]); + newY = string2int(arrCommand[2]); jd.setLocation(newX, newY); - canonical = canonical+" "+newX+" "+newY; + if (bUseInt4numbers) + { + canonical = canonical+" "+newX+" "+newY; + } + else + { + canonical = canonical+" "+arrCommand[1]+" "+arrCommand[2]; + } } if (isOR) @@ -921,12 +945,20 @@ throw new IllegalArgumentException("this command needs no or exactly 2 arguments, received "+(arrCommand.length-1)+" instead"); } - int newWidth = Integer.parseInt(arrCommand[1]); - int newHeight = Integer.parseInt(arrCommand[2]); + int newWidth = string2int(arrCommand[1]); + int newHeight = string2int(arrCommand[2]); if (isOR) { - writeOutput(slot, canonical+" "+newWidth+" "+newHeight); + if (bUseInt4numbers) + { + canonical = canonical+" "+newWidth+" "+newHeight; + } + else + { + canonical = canonical+" "+arrCommand[1]+" "+arrCommand[2]; + } + writeOutput(slot, canonical); } // no exception, so args o.k. jd.resizeSurface(newWidth, newHeight); // will use invokeLater() @@ -1023,11 +1055,11 @@ resultValue = printPosX+" "+printPosY; // query current value (to be returned if change occurs) - int newX = Integer.parseInt(arrCommand[1]); + int newX = string2int(arrCommand[1]); int newY = newX; // default to newX if (arrCommand.length==3) { - newY = Integer.parseInt(arrCommand[2]); + newY = string2int(arrCommand[2]); } // no exception, so args o.k. printPosX = newX; @@ -1034,7 +1066,15 @@ printPosY = newY; if (isOR) { - canonical=canonical+" "+newX+" "+newY; + if (bUseInt4numbers) + { + canonical = canonical+" "+newX+" "+newY; + } + else + { + canonical = canonical+" "+arrCommand[1] + " " + + (arrCommand.length==3 ? arrCommand[2] : arrCommand[1]); + } } if (isOR) { @@ -1103,33 +1143,52 @@ case SHEAR: // "shear x [y]" set scale for x, y; if y omitted, uses x { int argNum=arrCommand.length; - if (argNum<2 || argNum>3) + if (argNum>3) { - throw new IllegalArgumentException("this command needs either one or 2 arguments, received "+(arrCommand.length-1)+" instead"); + throw new IllegalArgumentException("this command needs either no, one or 2 arguments, received "+(arrCommand.length-1)+" instead"); } - double newX = Double.parseDouble(arrCommand[1]); - double newY = newX; // default to X value in case Y value is omitted - if (argNum==3) // Y value supplied, use it - { - newY=Double.parseDouble(arrCommand[2]); - } - String strResult= newX+" "+newY; + // get current settings + AffineTransform at=bufGC.getTransform(); + String strResult=null; + double newX=0, newY=0; if (cmd==Command.SCALE) { - bufGC.scale(newX,newY); + strResult=at.getScaleX()+" "+at.getScaleY(); } - else + else // SHEAR { - bufGC.shear(newX,newY); + strResult=at.getShearX()+" "+at.getShearY(); } + + if (argNum>1) // set value + { + newX = Double.parseDouble(arrCommand[1]); + newY = newX; // default to X value in case Y value is omitted + if (argNum==3) // Y value supplied, use it + { + newY=Double.parseDouble(arrCommand[2]); + } + + if (cmd==Command.SCALE) + { + bufGC.scale(newX,newY); + } + else + { + bufGC.shear(newX,newY); + } + } if (isOR) { - writeOutput(slot, canonical+" "+strResult); // write canonical form + if (argNum>1) + { + canonical=canonical+" "+newX+" "+newY; + } + writeOutput(slot, canonical); // write canonical form } - // return strResult; - return null; // returns null, i.e. RC="0" -> command executed alright + return strResult; // current/old settings } case NEW: // "new [width height [type]]" creates a new BufferedImage @@ -1144,11 +1203,18 @@ if (arrCommand.length>2) { - width = Integer.parseInt(arrCommand[1]); - height = Integer.parseInt(arrCommand[2]); + width = string2int(arrCommand[1]); + height = string2int(arrCommand[2]); if (isOR) { - canonical = canonical + " " + width + " " + height; + if (bUseInt4numbers) + { + canonical = canonical+" "+width+" "+height; + } + else + { + canonical = canonical+" "+arrCommand[1] + " " + arrCommand[2]; + } } if (arrCommand.length>3) @@ -1158,7 +1224,7 @@ { if (!imageTypes.containsKey(argType)) { - throw new IllegalArgumentException("unknown value for \"type\" argument"); + throw new IllegalArgumentException("unknown value for \"type\" argument: \""+arrCommand[3]+"\""); } type=imageTypes.get(argType); } @@ -1167,12 +1233,13 @@ type=Integer.parseInt(arrCommand[3]); if (!imageTypes.containsValue(type)) { - throw new IllegalArgumentException("unknown value for \"type\" argument"); + throw new IllegalArgumentException("unknown value for \"type\" argument: \""+arrCommand[3]+"\""); } } if (isOR) { - canonical = canonical + " " + argType; + canonical = canonical + " " + + (bUseNames4canonical ? imageTypesInt2Name.get(type) : argType) ; } } } @@ -1195,7 +1262,14 @@ while (tmpGC != null) { tmpGC.dispose(); - tmpGC = adGCStack.pop(); + if (adGCStack.size()>0) + { + tmpGC = adGCStack.pop(); // pop next GC + } + else // no more GCs on stack + { + tmpGC = null; + } } bufGC.dispose(); bufGC=null; @@ -1228,7 +1302,7 @@ { if (!imageTypes.containsKey(newType)) { - throw new IllegalArgumentException("unknown value for \"type\" argument"); + throw new IllegalArgumentException("unknown value for \"type\" argument: \""+arrCommand[1]+"\""); } type=imageTypes.get(newType); } @@ -1237,12 +1311,13 @@ type=Integer.parseInt(newType); if (!imageTypes.containsValue(type)) { - throw new IllegalArgumentException("unknown value for \"type\" argument"); + throw new IllegalArgumentException("unknown value for \"type\" argument: \""+arrCommand[1]+"\""); } } if (isOR) { - canonical = canonical + " " + arrCommand[1]; // uses supplied argument value + canonical = canonical + " " + + (bUseNames4canonical ? imageTypesInt2Name.get(type) : arrCommand[1]) ; } prefImageType=type; } @@ -1328,7 +1403,6 @@ RexxProxy rop = (RexxProxy) newStringTable(slot); // get a StringTable rop.sendMessage2("SETENTRY", "currX" , currX); rop.sendMessage2("SETENTRY", "currY" , currY); - rop.sendMessage2("SETENTRY", "currAngle" , currAngle); rop.sendMessage2("SETENTRY", "prefImageType" , prefImageType ); // currently preferred image type @@ -1384,8 +1458,6 @@ { throw new IllegalArgumentException("this command needs either no, 1, 4 or exactly 5 arguments, received "+(arrCommand.length-1)+" instead"); } - Color color=null; - int red, green, blue, alpha; resultValue = bufGC.getColor(); // query current value (to be returned if change occurs) @@ -1398,11 +1470,14 @@ return resultValue; } + Color color=null; + String colorNickName = arrCommand[1]; // get color name if (isOR) { canonical=canonical+" "+colorNickName; } + if (arrCommand.length==2) { color = hmColors.get(colorNickName.toUpperCase()); @@ -1424,24 +1499,70 @@ return resultValue; // return previous color } - red = Integer.parseInt(arrCommand[2]); - green = Integer.parseInt(arrCommand[3]); - blue = Integer.parseInt(arrCommand[4]); - if (arrCommand.length==6) + int red=0, green=0, blue=0, alpha=0; + float fRed=0, fGreen=0, fBlue=0, fAlpha=0; + String strArguments=command.substring(alWordBoundaries.get(2)[0]); // get all arguments + boolean bFloat=(strArguments.indexOf('.')>=0); // if dot in any of the values then use float version + + if (bFloat) { - alpha = Integer.parseInt(arrCommand[5]); - color = new Color(red, green, blue, alpha); + fRed = Float.parseFloat(arrCommand[2]); + fGreen = Float.parseFloat(arrCommand[3]); + fBlue = Float.parseFloat(arrCommand[4]); + } + else + { + red = Integer.parseInt(arrCommand[2]); + green = Integer.parseInt(arrCommand[3]); + blue = Integer.parseInt(arrCommand[4]); + } + + if (arrCommand.length==6) // alpha supplied, parse and use it + { + if (bFloat) + { + fAlpha = Float.parseFloat(arrCommand[5]); + color = new Color(fRed, fGreen, fBlue, fAlpha); + } + else + { + alpha = Integer.parseInt(arrCommand[5]); + color = new Color(red, green, blue, alpha); + } + if (isOR) { - canonical = canonical + " " + red + " " + green + " " + blue + " " + alpha; + if (bFloat) + { + canonical = canonical + " " + fRed + " " + fGreen + " " + fBlue + " " + fAlpha; + } + else + { + canonical = canonical + " " + red + " " + green + " " + blue + " " + alpha; + } } } else { - color = new Color(red, green, blue); + if (bFloat) + { + color = new Color(fRed, fGreen, fBlue); + } + else + { + color = new Color(red, green, blue); + } + if (isOR) { - canonical = canonical + " " + red + " " + green + " " + blue; + if (bFloat) + { + canonical = canonical + " " + fRed + " " + fGreen + " " + fBlue; + } + else + { + canonical = canonical + " " + red + " " + green + " " + blue; + } } } hmColors.put(colorNickName.toUpperCase(),color); @@ -1450,7 +1571,7 @@ { writeOutput(slot, canonical); } - // return color; + return resultValue; // return previous color } @@ -1577,7 +1698,7 @@ throw new IllegalArgumentException("this command needs exactly 1 argument, received "+(arrCommand.length-1)+" instead"); } -// 2022-09-23: nice gradient samples: <http://www.java2s.com/Code/Java/2D-Graphics-GUI/GradientPaintdemo.htm> + // 2022-09-23: nice gradient samples: <http://www.java2s.com/Code/Java/2D-Graphics-GUI/GradientPaintdemo.htm> case PAINT: // "paint [colorNickName|gradientPaintNickName]" query or set paint to a color or a gradientPaint { resultValue = bufGC.getPaint(); // query current value (to be returned if change occurs) @@ -1657,7 +1778,7 @@ throw new IllegalArgumentException("this command needs either no or exactly 1 argument, received "+(arrCommand.length-1)+" instead"); } - case XOR_MODE: // "xorMode colorNickName": set XORMode to color + case SET_XOR_MODE: // "xorMode colorNickName": set XORMode to color { if (arrCommand.length!=2) { @@ -1703,16 +1824,12 @@ String ruleName = arrCommand[1].toUpperCase(); // get name int intRule = -1; - if (isOR) - { - canonical=canonical+" "+ruleName; - } if (startRexxVariableChar.indexOf(ruleName.charAt(0))>=0) // a symbolic name? { if (!alphaComposites.containsKey(ruleName)) { - throw new IllegalArgumentException("unknown value for \"rule\" argument"); + throw new IllegalArgumentException("unknown value for \"rule\" argument: \""+arrCommand[1]+"\""); } intRule=alphaComposites.get(ruleName); } @@ -1721,11 +1838,17 @@ int val=Integer.parseInt(ruleName); if (!alphaComposites.containsValue(val)) { - throw new IllegalArgumentException("unknown value for \"rule\" argument"); + throw new IllegalArgumentException("unknown value for \"rule\" argument: \""+arrCommand[1]+"\""); } intRule=alphaComposites.get(ruleName); } + if (isOR) + { + canonical=canonical+" "+ + (bUseNames4canonical ? alphaCompositesInt2Name.get(ruleName) : ruleName) ; + } + AlphaComposite ac = null; if (argNum==3) { @@ -1749,30 +1872,6 @@ return resultValue; } -// 2022-09-29 --> -/* -- - case CLIP_NEW: // ?? "clipNew x y w h" -> setClip(x y w h) - { - if (arrCommand.length!=5) - { - throw new IllegalArgumentException("this command expects exactly 4 arguments, received "+(arrCommand.length-1)+" instead"); - } - int newX = Integer.parseInt(arrCommand[1]); - int newY = Integer.parseInt(arrCommand[2]); - int newWidth = Integer.parseInt(arrCommand[3]); - int newHeight = Integer.parseInt(arrCommand[4]); - - // no exception, so args o.k. - String res = newX+" "+newY+" "+newWidth+" "+newHeight; - if (isOR) - { - writeOutput(slot, canonical+" "+res); - } - bufGC.setClip(newX, newY, newWidth, newHeight); - return res; - } --- */ - case CLIP_REMOVE: // "removeClip" -> setClip(null) { if (arrCommand.length!=1) @@ -1809,12 +1908,22 @@ if (arrCommand.length>1) // clip area supplied { - int newX = Integer.parseInt(arrCommand[1]); - int newY = Integer.parseInt(arrCommand[2]); - int newWidth = Integer.parseInt(arrCommand[3]); - int newHeight = Integer.parseInt(arrCommand[4]); + int newX = string2int(arrCommand[1]); + int newY = string2int(arrCommand[2]); + int newWidth = string2int(arrCommand[3]); + int newHeight = string2int(arrCommand[4]); resultValue = newX+" "+newY+" "+newWidth+" "+newHeight; - canonical = canonical+" "+resultValue; + + if (bUseInt4numbers) + { + canonical = canonical+" "+resultValue; + } + else + { + canonical = canonical+" "+arrCommand[1] + " " + arrCommand[2] + + " "+arrCommand[3] + " " + arrCommand[4] ; + } + bufGC.clipRect(newX, newY, newWidth, newHeight); } // no exception, so args o.k. @@ -1824,7 +1933,6 @@ } return resultValue; } -// <--- case DRAW_POLYLINE: // "drawPolyline []xPoints []yPoints nPoints case DRAW_POLYGON: // "drawPolygon []xPoints []yPoints nPoints @@ -1861,17 +1969,11 @@ String strNPoints=arrCommand[3]; nPoints = Integer.parseInt(strNPoints); -// System.err.println("strXPoints=["+strXPoints+"] strYPoints=["+strYPoints+"] strNPoints=["+strNPoints+"]"); -// System.err.println("\txPoints: "+Arrays.deepToString(Arrays.asList(xPoints).toArray()) ); -// System.err.println("\tyPoints: "+Arrays.deepToString(Arrays.asList(yPoints).toArray()) ); -// System.err.println("\tnPoints: ["+nPoints+"]"); if (isOR) { canonical=canonical+" "+strXPoints+" "+strYPoints+" "+strNPoints; writeOutput(slot, canonical); } -// System.err.println("\tcanonical: "+canonical+" "+strXPoints+" "+strYPoints+" "+strNPoints+"\n"); -// System.err.println("... cmd: "+cmd); switch (cmd) { @@ -1936,10 +2038,17 @@ int width, cap, join; // , miterlimit; float miterlimit; - width = Integer.parseInt(arrCommand[2]); + width = string2int(arrCommand[2]); if (isOR) { - canonical=canonical+" "+width; + if (bUseInt4numbers) + { + canonical = canonical+" "+width; + } + else + { + canonical = canonical+" "+arrCommand[2]; + } } if (argNum==3) { @@ -1951,9 +2060,9 @@ String tmpCap = arrCommand[3].toUpperCase(); if (startRexxVariableChar.indexOf(tmpCap.charAt(0))>=0) // a symbolic name? { - if (!imageTypes.containsKey(tmpCap)) + if (!endCaps.containsKey(tmpCap)) { - throw new IllegalArgumentException("unknown value for \"cap\" argument"); + throw new IllegalArgumentException("unknown value for \"cap\" argument supplied: ["+tmpCap+"]"); } cap=endCaps.get(tmpCap); } @@ -1962,7 +2071,7 @@ cap=Integer.parseInt(tmpCap); if (!endCaps.containsValue(cap)) { - throw new IllegalArgumentException("unknown value for \"cap\" argument"); + throw new IllegalArgumentException("unknown value for \"cap\" argument supplied: ["+tmpCap+"]"); } } @@ -1970,9 +2079,9 @@ String tmpJoin = arrCommand[4].toUpperCase(); if (startRexxVariableChar.indexOf(tmpJoin.charAt(0))>=0) // a symbolic name? { - if (!imageTypes.containsKey(tmpJoin)) + if (!lineJoins.containsKey(tmpJoin)) { - throw new IllegalArgumentException("unknown value for \"join\" argument"); + throw new IllegalArgumentException("unknown value for \"join\" argument supplied: ["+tmpJoin+"]"); } join=lineJoins.get(tmpJoin); } @@ -1979,14 +2088,23 @@ else // verbatim int type { join=Integer.parseInt(tmpJoin); - if (! lineJoins.containsValue(cap)) + if (! lineJoins.containsValue(join)) { - throw new IllegalArgumentException("unknown value for \"join\" argument"); + throw new IllegalArgumentException("unknown value for \"join\" argument supplied: ["+tmpJoin+"]"); } } if (isOR) { - canonical=canonical+" "+tmpCap+" "+tmpJoin; + if (bUseNames4canonical) + { + canonical=canonical+" "+ + endCapsInt2Name.get(tmpCap)+" "+ + lineJoinsInt2Name.get(tmpJoin); + } + else + { + canonical=canonical+" "+tmpCap+" "+tmpJoin; + } } if (argNum==5) { @@ -2078,7 +2196,7 @@ if (arrCommand.length==2) { - int newFontSize = Integer.parseInt(arrCommand[1]); + int newFontSize = string2int(arrCommand[1]); // no exception, so args o.k. if (newFontSize<=0) { @@ -2087,7 +2205,14 @@ currFontSize = newFontSize; if (isOR) { - canonical=canonical+" "+newFontSize; + if (bUseInt4numbers) + { + canonical = canonical+" "+newFontSize; + } + else + { + canonical = canonical+" "+arrCommand[1]; + } } } if (isOR) @@ -2174,7 +2299,7 @@ // ---------------------- - case POS: // query current coordinates or goto x, y co-ordinate + case MOVE_TO: // query current coordinates or goto x, y co-ordinate { if (arrCommand.length>3) { @@ -2183,11 +2308,11 @@ resultValue = currX+" "+currY; // query current value (to be returned if change occurs) if (arrCommand.length>1) { - int newX = Integer.parseInt(arrCommand[1]); + int newX = string2int(arrCommand[1]); int newY = newX; // default to newX in case Y is not supplied if (arrCommand.length==3) { - newY = Integer.parseInt(arrCommand[2]); + newY = string2int(arrCommand[2]); } // no exception, so args o.k. currX = newX; @@ -2194,7 +2319,15 @@ currY = newY; if (isOR) { - canonical=canonical+" "+currX+" "+currY; + if (bUseInt4numbers) + { + canonical = canonical+" "+currX+" "+currY; + } + else + { + canonical = canonical+" "+arrCommand[1]+" "+ + (arrCommand.length==3 ? arrCommand[2] : arrCommand[1]); + } } } if (isOR) @@ -2211,11 +2344,20 @@ { throw new IllegalArgumentException("this command needs exactly 2 arguments, received "+(arrCommand.length-1)+" instead"); } - int toX = Integer.parseInt(arrCommand[1]); - int toY = Integer.parseInt(arrCommand[2]); + int toX = string2int(arrCommand[1]); + int toY = string2int(arrCommand[2]); + if (isOR) { - canonical=canonical+" "+toX+" "+toY; + if (bUseInt4numbers) + { + canonical = canonical+" "+toX+" "+toY; + } + else + { + canonical = canonical+" "+arrCommand[1]+" "+arrCommand[2]; + } + writeOutput(slot,canonical); } // no exception, so args o.k. @@ -2250,8 +2392,8 @@ { throw new IllegalArgumentException("this command needs exactly 2 arguments, received "+(arrCommand.length-1)+" instead"); } - int width = Integer.parseInt(arrCommand[1]); - int height = Integer.parseInt(arrCommand[2]); + int width = string2int(arrCommand[1]); + int height = string2int(arrCommand[2]); // no exception, so args o.k. if (cmd==Command.DRAW_OVAL) { @@ -2263,11 +2405,52 @@ } if (isOR) { - writeOutput(slot, canonical+" "+width+" "+height); + if (bUseInt4numbers) + { + canonical = canonical+" "+width+" "+height; + } + else + { + canonical = canonical+" "+arrCommand[1]+" "+arrCommand[2]; + } + + writeOutput(slot, canonical); } } break; + + case COPY_AREA: // "copyArea width height distX distY" + { + if (arrCommand.length!=5) + { + throw new IllegalArgumentException("this command needs exactly 4 arguments, received "+(arrCommand.length-1)+" instead"); + } + + int width = string2int(arrCommand[1]); + int height = string2int(arrCommand[2]); + int dx = string2int(arrCommand[3]); + int dy = string2int(arrCommand[4]); + canonical = canonical+" "+width+" "+height+" "+dx+" "+dy; + if (bUseInt4numbers) + { + canonical = canonical+" "+width+" "+height+" "+dx+" "+dy; + } + else + { + canonical = canonical+" "+arrCommand[1]+" "+arrCommand[2]+ + " "+arrCommand[3]+" "+arrCommand[4]; + } + + bufGC.copyArea(currX, currY, width, height, dx, dy); + + if (isOR) + { + writeOutput(slot, canonical); + } + break; + } + case DRAW_ROUND_RECT: // "drawRoundRect width height arcWidth arcHeight" case FILL_ROUND_RECT: // "fillRoundRect width height arcWidth arcHeight" if (arrCommand.length!=5) @@ -2283,16 +2466,30 @@ { throw new IllegalArgumentException("this command needs exactly 2 arguments, received "+(arrCommand.length-1)+" instead"); } - int width = Integer.parseInt(arrCommand[1]); - int height = Integer.parseInt(arrCommand[2]); - canonical = canonical+" "+width+" "+height; + int width = string2int(arrCommand[1]); + int height = string2int(arrCommand[2]); + if (bUseInt4numbers) + { + canonical = canonical+" "+width+" "+height; + } + else + { + canonical = canonical+" "+arrCommand[1]+" "+arrCommand[2]; + } int arcWidth=-1, arcHeight=-1; if (isRoundRect) { - arcWidth = Integer.parseInt(arrCommand[3]); - arcHeight = Integer.parseInt(arrCommand[4]); - canonical = canonical+" "+arcWidth+" "+arcHeight; + arcWidth = string2int(arrCommand[3]); + arcHeight = string2int(arrCommand[4]); + if (bUseInt4numbers) + { + canonical = canonical+" "+arcWidth+" "+arcHeight; + } + else + { + canonical = canonical+" "+arrCommand[3]+" "+arrCommand[4]; + } } // no exception, so args o.k. switch (cmd) @@ -2327,8 +2524,8 @@ { throw new IllegalArgumentException("this command needs exactly 3 arguments, received "+(arrCommand.length-1)+" instead"); } - int width = Integer.parseInt(arrCommand[1]); - int height = Integer.parseInt(arrCommand[2]); + int width = string2int(arrCommand[1]); + int height = string2int(arrCommand[2]); String strRaised = arrCommand[3]; boolean raised=false; if (checkBooleanValue(strRaised)) // a valid BSF4ooRexx850 boolean value? @@ -2351,7 +2548,15 @@ } if (isOR) { - writeOutput(slot, canonical+" "+width+" "+height+" "+raised); + if (bUseInt4numbers) + { + canonical = canonical+" "+width+" "+height; + } + else + { + canonical = canonical+" "+arrCommand[1]+" "+arrCommand[2]; + } + writeOutput(slot, canonical+" "+raised); } } break; @@ -2363,10 +2568,10 @@ { throw new IllegalArgumentException("this command needs exactly 4 arguments, received "+(arrCommand.length-1)+" instead"); } - int width = Integer.parseInt(arrCommand[1]); - int height = Integer.parseInt(arrCommand[2]); - int startAngle = Integer.parseInt(arrCommand[3]); - int arcAngle = Integer.parseInt(arrCommand[4]); + int width = string2int(arrCommand[1]); + int height = string2int(arrCommand[2]); + int startAngle = string2int(arrCommand[3]); + int arcAngle = string2int(arrCommand[4]); // no exception, so args o.k. if (cmd==Command.DRAW_ARC) { @@ -2378,7 +2583,16 @@ } if (isOR) { - writeOutput(slot, canonical+" "+width+" "+height+" "+startAngle+" "+arcAngle); + if (bUseInt4numbers) + { + canonical = canonical+" "+width+" "+height+" "+startAngle+" "+arcAngle; + } + else + { + canonical = canonical+" "+arrCommand[1]+" "+arrCommand[2]+ + " "+arrCommand[3]+" "+arrCommand[4]; + } + writeOutput(slot, canonical); } } break; @@ -2484,25 +2698,14 @@ return (writeSuccess ? "1" : "0"); } - case ROTATE: // "rotate [theta [x y]]" query or set rotation + case ROTATE: // "rotate theta [x y]" query or set rotation { ArrayList<int[]> al = alWordBoundaries; int argNum = al.size(); - resultValue = ""+currAngle; // query current value (to be returned if change occurs) - - if (argNum==1) // query currAngle - { - if (isOR) - { - writeOutput(slot, canonical); - } - return resultValue; - } - if (argNum!=2 && argNum!=4) { - throw new IllegalArgumentException("this command needs no, one or exactly three arguments, received "+(arrCommand.length-1)+" instead"); + throw new IllegalArgumentException("this command needs exactly one or three arguments, received "+(arrCommand.length-1)+" instead"); } double theta = 0, radiansTheta = 0; if (argNum>1) // at least theta given @@ -2512,7 +2715,6 @@ { canonical=canonical+" "+theta; } - currAngle = (currAngle + theta) % 360; radiansTheta = Math.toRadians(theta); // turn degree to radians if (radiansTheta!=0) { @@ -2522,8 +2724,17 @@ } else // if 3 arguments, fetch arg 2 (x) and 3 (y) { - int x = Integer.parseInt(arrCommand[2]); - int y = Integer.parseInt(arrCommand[3]); + int x = string2int(arrCommand[2]); + int y = string2int(arrCommand[3]); + if (bUseInt4numbers) + { + canonical = canonical+" "+x+" "+y; + } + else + { + canonical = canonical+" "+arrCommand[2]+" "+arrCommand[3]; + } + bufGC.rotate(radiansTheta, x, y); } } @@ -2530,9 +2741,8 @@ } if (isOR) { - writeOutput(slot, canonical+" "+theta); + writeOutput(slot, canonical); } - // return ""+theta; return resultValue; } @@ -2617,18 +2827,27 @@ case 5: // bkgColor case 8: case 9: // bkgColor - width = Integer.parseInt(arrCommand[2]); - height= Integer.parseInt(arrCommand[3]); + width = string2int(arrCommand[2]); + height= string2int(arrCommand[3]); if (argNum>5) { - srcX1 = Integer.parseInt(arrCommand[4]); - srcY1 = Integer.parseInt(arrCommand[5]); - srcX2 = Integer.parseInt(arrCommand[6]); - srcY2 = Integer.parseInt(arrCommand[7]); + srcX1 = string2int(arrCommand[4]); + srcY1 = string2int(arrCommand[5]); + srcX2 = string2int(arrCommand[6]); + srcY2 = string2int(arrCommand[7]); } if (isOR) { - canonical=canonical+" "+width+" "+height; + // canonical=canonical+" "+width+" "+height; + if (bUseInt4numbers) + { + canonical = canonical+" "+width+" "+height; + } + else + { + canonical = canonical+" "+arrCommand[2]+" "+arrCommand[3]; + } + if (argNum==5) // bkgColor { canonical=canonical+" "+colorNickName; @@ -2635,7 +2854,20 @@ } else if (argNum>5) { - canonical=canonical+" "+srcX1+" "+srcY1+" "+srcX2+" "+srcY2;; + // canonical=canonical+" "+srcX1+" "+srcY1+" "+srcX2+" "+srcY2; + if (isOR) + { + if (bUseInt4numbers) + { + canonical = canonical+" "+srcX1+" "+srcY1+" "+srcX2+" "+srcY2; + } + else + { + canonical = canonical+" "+arrCommand[4]+" "+arrCommand[5]+ + arrCommand[6]+" "+arrCommand[7]; + } + } + if (argNum==9) // bkgColor { canonical=canonical+" "+colorNickName; @@ -2667,28 +2899,126 @@ break; } - case TRANSLATE: // "translate x [y]" move origin; if y omitted, uses x + case TRANSLATE: // "translate x [y]" query or move origin; if y omitted, uses x { - if (arrCommand.length<2 && arrCommand.length>3) + if (arrCommand.length>3) { - throw new IllegalArgumentException("this command needs 1 or 2 arguments, received "+(arrCommand.length-1)+" instead"); + throw new IllegalArgumentException("this command needs no, 1 or 2 arguments, received "+(arrCommand.length-1)+" instead"); } - Integer newX = Integer.parseInt(arrCommand[1]); - Integer newY = newX; // default to newX - if (arrCommand.length==3) + + // get current settings + AffineTransform at=bufGC.getTransform(); + String strResult=null; + Integer newX=null, newY=null; + + strResult=at.getTranslateX()+" "+at.getTranslateY(); + if (arrCommand.length>1) { - newY = Integer.parseInt(arrCommand[2]); + newX = string2int(arrCommand[1]); + newY = newX; // default to newX + if (arrCommand.length==3) + { + newY = string2int(arrCommand[2]); + } + // no exception, so args o.k. + bufGC.translate(newX,newY); } - // no exception, so args o.k. - bufGC.translate(newX,newY); + if (isOR) { - writeOutput(slot, canonical+" "+newX+" "+newY); + if (arrCommand.length>1) + { + // canonical = canonical+" "+newX+" "+newY; + if (bUseInt4numbers) + { + canonical = canonical+" "+newX+" "+newY; + } + else + { + canonical = canonical+" "+arrCommand[1]+" "+ + (arrCommand.length==3 ? arrCommand[2] : arrCommand[1]); + } + } + writeOutput(slot, canonical); } - // return newX+" "+newY; - return null; // RC="0", command executed alright + return strResult; // return previous setting } + + // 2022-10-28 + case TRANSFORM: // "transform { | RESET | translateX translateY scaleX scaleY shearX shearY} " query, change reset Graphics2D's AfineTransform + { + int argNum = arrCommand.length; + if (argNum!=1 && argNum!=2 && argNum!=7) + { + throw new IllegalArgumentException("this command needs exactly no, 1 or 6 arguments, received "+(arrCommand.length-1)+" instead"); + } + + AffineTransform at = bufGC.getTransform(); // get current settings + double translateX=at.getTranslateX(), + translateY=at.getTranslateY(), + scaleX =at.getScaleX(), + scaleY =at.getScaleY(), + shearX =at.getShearX(), + shearY =at.getShearY(); + + String strResult=translateX+" "+translateY+" "+ + scaleX+" "+scaleY+" "+ + shearX+" "+shearY; + + String strReset="RESET"; + if (argNum>1) + { + AffineTransform newAT=null; + if (argNum==2) // reset? + { + char c = arrCommand[1].charAt(0); + boolean bReset = (c=='r' || c=='R'); // first character must be 'r' or 'R' for 'RESET' + if (!bReset) // wrong argument! + { + throw new IllegalArgumentException("single argument supplied, must be \"RESET\" (first character gets inspected), received the value \""+arrCommand[1]+"\" instead"); + } + newAT = new AffineTransform(); // uses the default values tX=tY=shX=shY=0 and scX=scY=1 + } + else if (argNum==7) + { + // a dot keeps the current value + translateX = arrCommand[1].equals(".") ? translateX : Double.parseDouble(arrCommand[1]); + translateY = arrCommand[2].equals(".") ? translateY : Double.parseDouble(arrCommand[2]); + scaleX = arrCommand[3].equals(".") ? scaleX : Double.parseDouble(arrCommand[3]); + scaleY = arrCommand[4].equals(".") ? scaleY : Double.parseDouble(arrCommand[4]); + shearX = arrCommand[5].equals(".") ? shearX : Double.parseDouble(arrCommand[5]); + shearY = arrCommand[6].equals(".") ? shearY : Double.parseDouble(arrCommand[6]); + + // matrix: { m00/sX m10/shY m01/shX m11/sY m02/tX m12/tY } + newAT=new AffineTransform( + scaleX, shearY, shearX, scaleY, translateX, translateY + ); + } + + bufGC.setTransform(newAT); // assign AffineTransform + } + + if (isOR) + { + if (arrCommand.length==2) + { + ... [truncated message content] |
From: <or...@us...> - 2022-10-23 14:35:30
|
Revision: 1010 http://sourceforge.net/p/bsf4oorexx/code/1010 Author: orexx Date: 2022-10-23 14:35:22 +0000 (Sun, 23 Oct 2022) Log Message: ----------- 20221023 Updated binaries, JDOR. Modified Paths: -------------- branches/850/bsf4oorexx.dev/bin/BSF.CLS branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html branches/850/bsf4oorexx.dev/install/setupBSF.rex branches/850/bsf4oorexx.dev/source_cc/env4_32bit_xp.cmd branches/850/bsf4oorexx.dev/source_cc/env4_64bit_xp.cmd branches/850/bsf4oorexx.dev/source_cc/lib/BSF4ooRexx850.dll-32-x86 branches/850/bsf4oorexx.dev/source_cc/lib/BSF4ooRexx850.dll-64-amd64 branches/850/bsf4oorexx.dev/source_cc/lib/libBSF4ooRexx850.dylib-64-arm64 branches/850/bsf4oorexx.dev/source_cc/lib/libBSF4ooRexx850.dylib-64-x86_64 branches/850/bsf4oorexx.dev/source_cc/lib/libBSF4ooRexx850.dylib-universal branches/850/bsf4oorexx.dev/source_cc/lib/libBSF4ooRexx850.so-32-arm32 branches/850/bsf4oorexx.dev/source_cc/lib/libBSF4ooRexx850.so-32-x86 branches/850/bsf4oorexx.dev/source_cc/lib/libBSF4ooRexx850.so-64-amd64 branches/850/bsf4oorexx.dev/source_cc/lib/libBSF4ooRexx850.so-64-arm64 branches/850/bsf4oorexx.dev/source_cc/lib/libBSF4ooRexx850.so-64-s390x branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java branches/850/createDistributionForBSF4ooRexx8.cmd branches/850/samples/2-110_JDOR_listShowPrintFonts.rxj Modified: branches/850/bsf4oorexx.dev/bin/BSF.CLS =================================================================== --- branches/850/bsf4oorexx.dev/bin/BSF.CLS 2022-10-23 14:33:52 UTC (rev 1009) +++ branches/850/bsf4oorexx.dev/bin/BSF.CLS 2022-10-23 14:35:22 UTC (rev 1010) @@ -922,7 +922,7 @@ if initialize.bsf.dir() then -- setup .bsfrexx do - .bsf4rexx~version="850.20221005" -- set version (date distribution got created) + .bsf4rexx~version="850.20221023" -- set version (date distribution got created) .bsf4rexx~opSys =opsys -- save operating system name as supplied by Rexx' PARSE SOURCE .bsf4rexx~opSys1 =opsys~left(1)~upper -- save operating system name's initial letter in uppercase .bsf4rexx~opSys2 =opsys~left(2)~upper -- save operating system name's first two letters in uppercase Modified: branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html =================================================================== --- branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html 2022-10-23 14:33:52 UTC (rev 1009) +++ branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html 2022-10-23 14:35:22 UTC (rev 1010) @@ -134,17 +134,17 @@ drawRect len len -- draw the frame with the blue color -- draw a string (text) at the lower half of the bitmap color somePurple 127 46 111 -- define a custom RGB color, store it with nickname "SOMEPURPLE" - say "--> rc="pp(rc) -- show result from command (the Java oclor object) + say "--> rc="pp(rc) -- show result from command (the Java color object) say " rc~toString:" pp(rc~toString) -- shows the RGB intensities of the color newY=height-40 - -- define an array of three strings lineHeight = 15 -- default font size is 12px, add 3 px space + -- define an array of three strings text=("Hello, Rexx world ...", "... from JDOR ...", "(Rexx command handler)") -- array of 3 strings do counter c i=0 to 30 by lineHeight -- iterate over array of strings goto 50 (newY+i) -- set position drawString text[c] -- draw the string end - -- save the current image + -- save the current image saveImage "jdor_doc_sample.png" -- save image to file "jdor_doc_sample.png" sleep 3.123 -- sleep for 3.123 seconds @@ -158,7 +158,7 @@ --> rc=[java.awt.Color@4fe3c938] rc~toString: [java.awt.Color[r=127,g=46,b=111]] </pre> - and create and save the following image (bitmap) using as filename "<code>jdor_doc_sample.png</code>": + and create and save the following image (bitmap) using as filename "<em>jdor_doc_sample.png</em>": <p> <center><img src="jdor_doc_sample.png" border="1px"></center> @@ -168,10 +168,10 @@ <p> The <em>JDOR</em> Rexx command handler makes <em>Java2D</em> functionality available -to Rexx programmers. The commands are formed after the methods in the <code>java.awt.Graphics</code> -and <code>java.awt.Graphics2D</code> Java classes. The only difference are the <code>x</code> and -<code>y</code> co-ordinates which many methods have as their first two arguments: the Rexx programmer -defines these co-ordinates with the <code>GOTO x y</code> command and therefore are left out from +to Rexx programmers. The commands are formed after the methods in the <em>java.awt.Graphics</em> +and <em>java.awt.Graphics2D</em> Java classes. The only difference are the <em>x</em> and +<em>y</em> co-ordinates which many methods have as their first two arguments: the Rexx programmer +defines these co-ordinates with the <em>GOTO x y</em> command and therefore are left out from the arguments of the Rexx commands matching the Java method names. @@ -194,26 +194,28 @@ <dl> <dt>AffineTransform</dt> - <dd>The Java class <code>java.awt.geom.AffineTransform</code> allows to define and maintain + <dd>The Java class <em>java.awt.geom.AffineTransform</em> allows to define and maintain <em>rotate(...)</em>, <em>scale(...)</em>, <em>shear(...)</em>, <em>translate(...)</em> operations which all can be applied at once with the <em>java.awt.Graphics2D</em>'s <em>transform(anAffineTransform)</em> method. - One benefit is that <em>GC</em> is not permanently changed to these trnasformation + One benefit is that <em>GC</em> (graphic configuration, see below) is not permanently changed to these transformation values. <p>Currently there is no JDOR command to support this directly, however the same effect can - be achieved with the <em>pushGC</em> command, followed by any transforms - (<em>rotate(...)</em>, <em>scale(...)</em>, <em>shear(...)</em>, <em>translate(...)</em>) - and the <em>popGC</em> command which will reinstate the previous pushed <em>GC</em>. + be achieved with the <em><a href="#cmdPushGC">pushGC</a></em> command, followed by any transform + commands + (<em><a href="#cmdRotate">rotate(...)</a></em>, + <em><a href="#cmdScale">scale(...)</a></em>, + <em><a href="#cmdShear">shear(...)</a></em>, + <em><a href="#cmdTranslate">translate(...)</a></em>) + and the <em><a href="#cmdPopGC">popGC</a></em> command which will reinstate the previous pushed <em>GC</em>. + <p> - <p> - Alternatively, the Rexx programmer can fetch the <em>GC</em> object (cf. <em>GC</em> command) + Alternatively, the Rexx programmer can fetch the <em>GC</em> object (cf. <em><a href="#cmdGC">GC</a></em> command) and interact with it directly and use the <em>transform(...)</em> method directly supplying - an instance of <code>java.awt.geom.AffineTransform</code>. + an instance of <em>java.awt.geom.AffineTransform</em>. + </dd> - </dd><br> - - <dt>coordinate system<dt> <dd>The 0-based, two dimensional coordinate system to address each pixel of an image of width</em> and height</em> in size. The location (coordinate) <em>x=0</em> and @@ -220,22 +222,24 @@ <em>y=0</em>, the <em>origin</em> denotes the pixel in the upper left hand corner. Increasing <em>x</em> move along to the <em>right</em> (along the <em>x-axis</em>), increasing <em>y</em> along to the bottom (along the <em>y-axis</em>). - </dd><br> + </dd> <dt>currX currY</dt> <dd><em>currX</em> and <em>currY</em> denote the current position of the starting (upper left hand) point used when clearing, drawing or filling. It can be set with - the <em>goto x y</em> command (alias name for this command is <em>pos x y</em>). + the <a href="#cmdGoto"><em>goto x y</em></a> command (alias names for this command are + <a href="#cmdGoto"><em>location x y</em></a> and + <a href="#cmdGoto"><em>pos x y</em></a>). The JDOR command handler will insert <em>currX</em> and <em>currY</em> whenever a <em>x</em> and <em>y</em> position must be supplied to a Java2D method. - </dd><br> + </dd> <dt>clip</dt> - <dd>A rectangular area of which gets affected by drawings and fills. Any pixels - outside of a defined clip (clipping area) do not change.</dd><br> + <dd>A rectangular area which gets affected by drawings and fills. Any pixels + outside the defined <a href="#cmdClip">clip</a> (clipping area) do not change.</dd> <dt id="dtDashArray">dashArray</dt> - <dd>The command <em>stroke</em> allows for an argument <em>dashArray</em> that + <dd>The command <em><a href="#cmdStroke">stroke</a></em> allows for an argument <em>dashArray</em> that represents an array of float values. There are two possibilities to supply this array to the command: <ul> @@ -247,60 +251,66 @@ <br><em>dashArray=bsf.createJavaArrayOf("float.class", 1, 3, 1, 3)</em> and then submitting the quoted name of the Rexx variable, e.g. <em>"dashArray"</em>, as array argument; the command handler will then fetch the array from the Rexx variable - (after fetching the Rexx variable by name from the command context) + (after fetching the Rexx variable by name from the command context). </ul> - </dd><br> + </dd> - - <dt>GC</dt> + <dt id="dtGC">GC</dt> <dd>A <em>graphical configuration</em>, an instance of the Java class <em>java.awt.Graphics</em> or <em>java.awt.Graphics2D</em> - which allows for interacting (drawing, transforming, etc.) with an image(a bitmap). - </dd><br> + which allows for interacting (drawing, transforming, etc.) with an image (a bitmap) + and maintains its state (e.g. current origin, current rotation, current color, ...). + The command <a href="#cmdGC"><em>GC</em></a> allows for retrieving the current <em>GC</em>. + </dd> <dt>image type</dt> <dd>The image type defines the basic properties of an image which also determines in which format an image can be stored in the file system. The supported types - are defined as constants in the Java class <em>java.awt.image.BufferedImage</em>. + are defined as constants in the Java class <em>java.awt.image.BufferedImage</em> + and are listed in the command <em><a href="#cmdNew">new</a></em>, subsection arguments. </dd> <dt>pixel</dt> - <dd>picture element, usually the size of 1/72 of an inch</dd><br> + <dd>picture element, usually the size of 1/72 of an inch</dd> <dt>RGB color</dt> <dd>A color mix of the colors <em>red</em>, <em>green</em> and <em>blue</em> each defined with an intensity between <em>0</em> and <em>255</em>. - </dd><br> + </dd> <dt>RGBA color</dt> <dd>A color mix of the colors <em>red</em>, <em>green</em>, <em>blue</em> and <em>alpha</em> (transparency/opaqueness) each defined with an intensity between <em>0</em> and <em>255</em>. <em>Note:</em> an <em>alpha</em> intensity - of <em>0</em> means "no transparency", and an intensitiy of <em>255</em> - "complete transparency". - </dd><br> + of <em>0</em> means "complete transparency", and an intensitiy of + <em>255</em> means "no transparency". + </dd> + <dt>rotate</dt> - <dd>A positive or negative value in degrees (0-360) to rotate the image. <em>Note:</em> the + <dd>A positive or negative value in degrees (0-360) to <em><a href="#cmdRotate">rotate</a></em> the image. <em>Note:</em> the Java method rotate(angle) expects the value to be in radians, whereas this command expects degrees! The rotate command will convert the degree value (easier for humans) to radians before invoking the Java method (cf. <a href="https://en.wikipedia.org/wiki/Gradian">Wikipedia Gradian</a> article). - </dd><br> + </dd> <dt>scale</dt> - <dd>A positive or negative value used to multiply the <em>width</em> and <em>height</em> values. - </dd><br> + <dd>A positive or negative value used to multiply the <em>width</em> and <em>height</em> values, + cf. the command <em><a href="#cmdScale">scale</a></em>. + </dd> <dt>shear</dt> - <dd>A positive or negative value used to slant a drawing, also known as skewing. - </dd><br> + <dd>A positive or negative value used to slant a drawing, also known as skewing, + cf. the command <em><a href="#cmdShear">shear</a></em>. + </dd> <dt>translate</dt> <dd>Moving the origin to a different position, such that the effective <em>x</em> and <em>y</em> - coordinates get calculated relative to the new origin. - </dd><br> + coordinates get calculated relative to the new origin, + cf. the command <em><a href="#cmdTranslate">translate</a></em>. + </dd> <dt id="dtPointsArray">xPoints-array, yPoints-array</dt> <dd>The commands @@ -323,7 +333,7 @@ as array argument; the command handler will then fetch the array from the Rexx variable (after fetching the Rexx variable by name from the command context) </ul> - </dd><br> + </dd> </dl> @@ -352,6 +362,10 @@ between them will be reduced to a single white space according to the Rexx rules before supplying the resulting command with arguments to the Rexx command handler. +<p><em>Hint:</em> in general any command that allows for querying and setting a value will return the +current value and in the case of setting it to a new value will return the old (previously current) +value. + <p> <table> <tr> @@ -365,9 +379,13 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "background" - <td colspan="3"> Queries or sets the background color to a registered color and returns - it via the Rexx variable <code>RC</code>. + <td class="command" id="cmdBackground"> "background" + <td colspan="3"> Queries or sets the background color to a registered color. + + <br>Querying the current value (no argument supplied) will return it, setting + (changing) the value to a new value will return the old (previously set) value + via the Rexx variable <em>RC</em>. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the methods: <em>getBackground()</em>, <em>setBackground(...)</em>. @@ -374,7 +392,7 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> colorNickName - <td> The name of a registered color (cf. <em>color</em> command) to + <td> The name of a registered color (cf. <em><a href="#cmdColor">color</a></em> command) to which the background color should be set to. @@ -383,8 +401,8 @@ <td class="cmdNr"> <td class="command"> "clearRect" <td colspan="2"> Clears a rectangle of the supplied <em>width</em> and <em>height</em> - at the current <em>x</em> and <em>y</em> position (cf. <em>goto</em> command), - using the <em>background</em> (cf. <em>background</em> command) color. + at the current <em>x</em> and <em>y</em> position (cf. <em><a href="#cmdGoto">goto</a></em> command), + using the <em>background</em> (cf. <em><a href="#cmdBackground">background</a></em> command) color. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>clearRect(...)</em>. @@ -396,10 +414,11 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "clip" + <td class="command" id="cmdClip"> "clip" <td colspan="2"> Queries or sets a clipping area of an image. Returns a blank delimited string with the <em>x</em>, <em>y</em>, - <em>width</em> and <em>height</em> values of the clipping rectangle (area) + <em>width</em> and <em>height</em> values of the previously defined clipping rectangle (area) + or <em>.nil</em> if no such area was defined via the Rexx variable <em>RC</em>. If a clipping area exists already, then the intersection with it will be the new clipping area. @@ -425,14 +444,18 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "color" - <td colspan="2"> Query, get and set, define and set the color. With no arguments - returns the current Java color which can be referred to via the Rexx variable - <em>RC</em> upon return from this command. + <td class="command" id="cmdColor"> "color" + <td colspan="2"> Query, get and set, define and set the color. + <br>Querying the current value (no argument supplied) will return it, setting + (changing) the value to a new value will return the old (previously set) value + via the Rexx variable <em>RC</em>. + <br>Supplying only the <em>colorNickName</em> argument will load the color from the - internal register and use it. - <br>Supplying in addition the intensity values for the colors <em>red</em>, <em>green</em>, <em>blue</em>, - and optionally <em>alpha</em>, a <em>java.awt.Color</em> of that type gets created, registered with + internal register and assign it to the <a href="#cmdGC"><em>GC</em></a> to be used for drawing from now on. + + <br>Supplying in addition the intensity values for the colors <em>red</em>, <em>green</em>, + <em>blue</em>, and optionally <em>alpha</em> (between <em>0</em>=fully transparent to + <em>255</em>=fully opaque), a <em>java.awt.Color</em> of that type gets created, registered with the supplied <em>colorNickName</em> and then used for setting the new color. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the @@ -451,8 +474,8 @@ <td class="argument"> colorNickName r g b [alpha] <td> This command creates a color using an intensity beteween <em>0</em> and <em>255</em> for each of the colors <em>red</em>, <em>green</em>, <em>blue</em> - and optionally for <em>alpha</em> (transparency/opaqueness). This color will be - used from now on and gets stored in the color registry using the supplied + and optionally for <em>alpha</em> (between <em>0</em>=fully transparent to <em>255</em>=fully opaque). + This color will be used from now on and gets stored in the color registry using the supplied <em>colorNickName</em> in uppercase and returned via the Rexx variable <em>RC</em>. @@ -463,6 +486,10 @@ <td colspan="2"> Queries or creates and sets the composite value (an instance of the Java class <em>java.awt.AlphaComposite</em>). + <br>Querying the current value (no argument supplied) will return it, setting + (changing) the value to a new value will return the old (previously set) value + via the Rexx variable <em>RC</em>. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the methods <em>getComposite()</em>, <em>setComposite(...)</em>, and the Java class <em>java.awt.AlphaComposite</em> with its constant fields and the method @@ -471,11 +498,20 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> rule [alpha] - <td> <em>rule</em> is a number or a constant name (<em>CLEAR</em>, - <em>DST</em>, <em>DST_ATOP</em>, <em>DST_IN</em>, <em>DST_OUT</em>, - <em>DST_OVER</em>, <em>SRC</em>, <em>SRC_ATOP</em>, <em>SRC_IN</em>, - <em>SRC_OUT</em>, <em>SRC_OVER</em>, <em>XOR</em>); - <br><em>alpha</em> is an optional value between <em>0.0</em> and <em>1.0</em>. + <td> <em>rule</em>: is a number or a constant name, i.e. one of + <em>CLEAR</em> (<em>1</em>), + <em>DST</em> (<em>9</em>), + <em>DST_ATOP</em> (<em>11</em>), + <em>DST_IN</em> (<em>6</em>), + <em>DST_OUT</em> (<em>8</em>), + <em>DST_OVER</em> (<em>4</em>), + <em>SRC</em> (<em>2</em>), + <em>SRC_ATOP</em> (<em>10</em>), + <em>SRC_IN</em> (<em>5</em>), + <em>SRC_OUT</em> (<em>7</em>), + <em>SRC_OVER</em> (<em>3</em>), + <em>XOR</em> (<em>12</em>). + <br><em>alpha</em>: is an optional value between <em>0.0</em> and <em>1.0</em>. <!-- -------------------------------------------------------- --> @@ -491,8 +527,8 @@ <td> <td class="argument"> width height raised <td> <em>width</em> and <em>height</em> in pixel of the rectangle, - <em>raised</em> is either set to <em>.true</em> for raised or to <em>.false</em> - for sunken). + <em>raised</em> needs to be either set to <em>.true</em> for raised or to <em>.false</em> + for sunken appearance. <!-- -------------------------------------------------------- --> @@ -507,7 +543,7 @@ <td> <td class="argument"> width height startAngle arcAngle <td> <em>width</em> and <em>height</em> in pixel of the rectangle, - <em>startAngle</em> in degrees (0 is the 3 o'clock position), <em>arcAngle</em> + <em>startAngle</em> in degrees (<em>0</em> is the 3 o'clock position), <em>arcAngle</em> angular extend in degrees relative to <em>startAngle</em>. @@ -516,8 +552,9 @@ <td class="cmdNr"> <td class="command"> "drawImage" <td colspan="2"> Draws an image which got previously loaded from the filesystem - with the command <em>loadImage</em> and stored internally with a <em>nickName</em> - in the internal image registry. + with the command <em><a href="#cmdLoadImage">loadImage</a></em> and stored internally + with an <em>nickName</em> in the internal image registry, or an image that got + pushed with a <em>nickName</em> in the command <em><a href="#cmdPushImage">pushImage</a></em> <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>drawImage(...)</em>. @@ -554,6 +591,47 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> + <td class="command"> "drawImageFromVar" + <td colspan="2"> Draws an image (an instance of <em>java.awt.Image</em>) referred + to by a Rexx variable. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>drawImageFromVar(...)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> rexxVariableName [bkgColor] + <td> <em>rexxVariableName</em> denotes the name of a Rexx variable that refers to an image + (hint: enquote the Rexx variable name). + Draws as much of the image as possible. + + <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> rexxVariableName width height [bkgColor] + <td> <em>rexxVariableName</em> denotes the name of a Rexx variable that refers to an image + (hint: enquote the Rexx variable name). + Draws as much of the image as possible scaled to the + <em>width</em> and <em>height</em> in pixel. + + <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> rexxVariableName width height srcX1 srcY1 srcX2 srcY2 [bkgColor] + <td> <em>rexxVariableName</em> denotes the name of a Rexx variable that refers to an image + (hint: enquote the Rexx variable name). + Draws as much of the image as possible scaled to the + <em>width</em> and <em>height</em> in pixel, using from the image the rectangle + with the first corner with the coordinate <em>srcX1</em> and <em>srcY1</em> and + the second corner with the coordinate <em>srcX2</em> and <em>srcY2</em>. + + <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> <td class="command"> "drawLine" <td colspan="2"> Draws a line. @@ -563,7 +641,7 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> toX toY - <td> <em>toX</em> and <em>toY</em>, denoting the endpoint of the line. + <td> <em>toX</em> and <em>toY</em>, denoting the endpoint of the line (starting from <em>currX</em> and <em>currY</em>). <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> @@ -587,8 +665,9 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdDrawPolygon"> "drawPolygon" - <td colspan="2"> Draws a polygon using <em>nPoints</em> coordinates from the <em>xPoints-array<em> array - and </em>yPoints-array</em>. The polygon gets closed by drawing a line from the first and last point. + <td colspan="2"> Draws a polygon using <em>nPoints</em> coordinates from + <a href="#dtPointsArray"><em>xPoints-array</em></a> + and <a href="#dtPointsArray"><em>yPoints-array</em></a>. The polygon gets closed by drawing a line from the first and last point. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>drawPolygon(...). @@ -598,8 +677,8 @@ <td> Draws a polygon consisting of <em>nPoints</em> taken from the <a href="#dtPointsArray"><em>xPoints-array</em></a> and <a href="#dtPointsArray"><em>yPoints-array</em></a>. - If the endpoint is not - the same coordinate, the polygon gets closed by drawing a line from the + If the endpoint is not the same coordinate as the first point, + the polygon gets closed by drawing a line from the first to the last point. @@ -607,9 +686,8 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdDrawPolyline"> "drawPolyline" - <td colspan="2"> Draws a polyline using <em>nPoints</em> coordinates from the - <em>xPoints-array</em> and - <em>yPoints-array</em>. + <td colspan="2"> Draws a polyline using <em>nPoints</em> coordinates from + <a href="#dtPointsArray"><em>xPoints-array</em></a> and <a href="#dtPointsArray"><em>yPoints-array</em></a>. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>drawPolyline(...). @@ -616,7 +694,7 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> xPoints-array yPoints-array nPoints - <td> Draws a polyline consisting of <em>nPoints</em> taken from the + <td> Draws a polyline consisting of <em>nPoints</em> taken from <a href="#dtPointsArray"><em>xPoints-array</em></a> and <a href="#dtPointsArray"><em>yPoints-array</em></a>. @@ -661,7 +739,10 @@ <td class="cmdNr"> <td class="command"> "drawString" <td colspan="2"> Draws a string (text). - + <br><em>Note:</em> In order to preserve leading blanks in a string, only the + first (delimiting) blank after the command <em>drawString</em> will be consumed, all + following characters - including leading whitespace - are regarded to constitute + the string to be drawn. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>drawString(...)</em>. @@ -686,7 +767,7 @@ <td class="argument"> width height raised <td> <em>width</em> and <em>height</em> in pixel of the rectangle, <em>raised</em> is either set to <em>.true</em> for raised or to <em>.false</em> - for sunken). + for sunken appearance. <!-- -------------------------------------------------------- --> @@ -701,8 +782,8 @@ <td> <td class="argument"> width height startAngle arcAngle <td> <em>width</em> and <em>height</em> in pixel of the rectangle, - <em>startAngle</em> in degrees (0 is the 3 o'clock position), <em>arcAngle</em> - angular extend in degrees relative to <em>startAngle</em>. + <em>startAngle</em> in degrees (<em>0</em> is the 3 o'clock position), <em>arcAngle</em> + angular extent in degrees relative to <em>startAngle</em>. @@ -728,8 +809,8 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command" id="cmdFillPolygon"> "fillPolygon" - <td colspan="2"> Fills a polygon using <em>nPoints</em> coordinates from the <em>xPoints-array<em> array - and </em>yPoints-array</em>. + <td colspan="2"> Fills a polygon using <em>nPoints</em> coordinates from <a href="#dtPointsArray"><em>xPoints-array</em></a> + and <a href="#dtPointsArray"><em>yPoints-array</em></a>. <br><em>Note:</em> The definition list above documents how these arrays can be supplied to the command handler. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the @@ -741,8 +822,8 @@ <td> Fills a polygon consisting of <em>nPoints</em> taken from the <a href="#dtPointsArray"><em>xPoints-array</em></a> and <a href="#dtPointsArray"><em>yPoints-array</em></a>. - If the endpoint is not - the same coordinate, the polygon gets closed by filling a line from the + If the endpoint is not the same coordinate as the first poing, + the polygon gets closed by filling a line from the first to the last point. <!-- -------------------------------------------------------- --> @@ -756,7 +837,7 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> width height - <td> Fills an oval in a rectangle of <em>width</em> and + <td> Fills a rectangle of <em>width</em> and <em>height</em> pixels. If <em>width</em> and <em>height</em> are of the same length the rectangle will be a square. @@ -784,15 +865,21 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "font" - <td colspan="2"> Query, get and set, define and set the font. With no arguments - returns the current Java font which can be referred to via the Rexx variable - <em>RC</em> upon return from this command. + <td class="command" id="cmdFont"> "font" + <td colspan="2"> Query, get and set, define and set the <a href="#cmdGC"><em>GC</em></a>'s font. + + <br>Querying the current value (no argument supplied) will return it, setting + (changing) the value to a new value will return the old (previously set) value + via the Rexx variable <em>RC</em>. + <br>Supplying only the <em>fontNickName</em> argument will load the font from the internal register and use it until it gets changed again. - <br>Supplying in addition the <em>fotnName</em>, a <em>java.awt.Font</em> + + <br>Supplying in addition the <em>fontName</em>, a <em>java.awt.Font</em> gets loaded from the system, registered with the supplied <em>fontNickName</em> - and then used for setting the new font. + and then used for setting the new font. The font size is taken from + <a href="#cmdFontSize"><em>fontSize</em></a> + and the style from <a href="#cmdFontStyle"><em>fontStyle</em></a>. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the methods <em>getFont()</em>, <em>setFont(...)</em>, as well as the Java class @@ -822,10 +909,14 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "fontSize" - <td colspan="2"> Queries or sets the font size to be used when loading new fonts. - With no arguments returns the current font size which can be referred to via - the Rexx variable <em>RC</em> upon return from this command. + <td class="command" id="cmdFontSize"> "fontSize" + <td colspan="2"> Queries or sets the font size to be used when loading a new + <a href="#cmdFont"><em>font</em></a>. + + <br>Querying the current value (no argument supplied) will return it, setting + (changing) the value to a new value will return the old (previously set) value + via the Rexx variable <em>RC</em>. + <br>Cf. the Java documentation for the Java class <em>Font</em> and the constructors as well as the method <em>getSize()</em>. @@ -832,16 +923,20 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> size - <td> <em>size</em> that gets used when loading a new font, defaults to <em>12</em>. + <td> <em>size</em> (an integer value) that gets used when loading a new font, defaults to <em>12</em>. <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "fontStyle" - <td colspan="2"> Queries or sets the font style to be used when loading new fonts. - With no arguments returns the current font size which can be referred to via - the Rexx variable <em>RC</em> upon return from this command. + <td class="command" id="cmdFontStyle"> "fontStyle" + <td colspan="2"> Queries or sets the font style to be used when loading a new + <a href="#cmdFont"><em>font</em></a>. + + <br>Querying the current value (no argument supplied) will return it, setting + (changing) the value to a new value will return the old (previously set) value + via the Rexx variable <em>RC</em>. + <br>Cf. the Java documentation for the Java class <em>Font</em> and the constructors as well as the method <em>getStyle()</em>. @@ -858,11 +953,11 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "GC" - <td colspan="2"> Queries the <em>GC</em> object (an instance of the class - <em>Graphics[2D]</em>) and returns it via the Rexx variable <em>RC</em> - upon return from this command. One can then use all <em>Graphics[2D]</em> methods - from an ooRexx program directly. + <td class="command" id="cmdGC"> "GC" + <td colspan="2"> Queries the <em><a href="#dtGC">GC</a></em> (graphical configuration) object (an + instance of the class <em>Graphics[2D]</em>) and returns it via the Rexx + variable <em>RC</em> upon return from this command. One can then use all + <em>Graphics[2D]</em> methods from an ooRexx program directly. <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em>. <!-- -------------------------------------------------------- --> @@ -910,20 +1005,23 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> rexxVariableName - <td> <em>rexxVariableName</em> the Rexx variable name to store the ooRexx - <em>StringTable</em> object in the command context additionally. + <td> optional <em>rexxVariableName</em> the Rexx variable name to store the ooRexx + <em>StringTable</em> object in the command context in addition. <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "goto" <br> "pos" + <td class="command" id="cmdGoto"> "goto" <br> "location" <br> "pos" <td colspan="2"> Queries or sets <em>currX</em> and <em>currX</em> in the current image. - If no argument returns the blank delimited values of <em>currX</em> and <em>currX</em> - via the Rexx variable <em>RC</em> upon return from this command. - <br>The command name <em>pos</em> is an alias, a synonym for this command. + <br>Querying the current value (no argument supplied) will return it, setting + (changing) the value to a new value will return the old (previously set) value + via the Rexx variable <em>RC</em>. + <br>The command names <em>location</em> and <em>pos</em> are aliases, synonyms for this command. + + <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> x [y] @@ -935,9 +1033,11 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "gradientPaint" - <td colspan="2"> Query, get and set, define and set the gradientPaint. With no arguments - returns the current Java <em>gradientPaint</em> which can be referred to via the Rexx variable - <em>RC</em> upon return from this command. + <td colspan="2"> Get and set, define and set a gradientPaint (used for filling). + + This command returns the old (previously set) <a href="#cmdPaint"><em>paint</em></a> value + via the Rexx variable <em>RC</em>. + <br>Supplying only the <em>gradientPaintNickName</em> argument will load the <em>gradientPaint</em> from the internal register and use it. <br>Supplying additional arguments will cause a new gradient paint to be created, @@ -958,7 +1058,7 @@ <td> <td class="argument"> gradientPaintNickName x1 y1 colorName1 x2 y2 colorName2 [cyclic] <td> This command creates a gradient paint from point <em>x1</em>,<em>y1</em> with - color <em>colroName1</em> to <em>x2</em>,<em>y2</em> with color <em>colroName2</em>. + color <em>colorName1</em> to <em>x2</em>,<em>y2</em> with color <em>colorName2</em>. The optional <em>cyclic</em> arguments determines whether the gradient patterns should cycle repeatedly between the two colors. This gradientPaint will be used from now on and gets stored in the gradientPaint registry using the supplied @@ -974,10 +1074,10 @@ <td colspan="2"> Queries an <em>image</em> object (an instance of the class <em>java.awt.image.BufferedImage</em>) and returns it via the Rexx variable <em>RC</em> upon return from this command. - With no argument returns the current image which can be referred - to via the Rexx variable <em>RC</em> upon return from this command. - Supplying the <em>imageNickName</em> argument will load and return - the image from the internal register. + With no argument returns the current image which can be referred + to via the Rexx variable <em>RC</em> upon return from this command. + Supplying the optional <em>imageNickName</em> argument will load and return + the image from the internal image register. <br> One can then use all <em>BufferedImage</em> methods from an ooRexx program directly. Cf. the Java documentation for the Java class <em>BufferedImage</em>. @@ -984,12 +1084,10 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> imageNickName - <td> <em>imageNickName</em> gets uppercased and is used to look up the internal - image registry for the denoted image and gets - returned via the Rexx variable <em>RC</em>. + <td> optional <em>imageNickName</em> gets uppercased and is used to look up the internal + image registry for the denoted image and gets returned via the Rexx variable <em>RC</em>. - <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> @@ -997,13 +1095,13 @@ <td colspan="2"> Query the image size (dimension). With no arguments returns the current image's <em>width</em> and <em>height</em> which can be referred to via the Rexx variable <em>RC</em> upon return from this command. - <br>Supplying the <em>imageNickName</em> argument will return the size of the image + <br>Supplying the optional <em>imageNickName</em> argument will return the size of the image from the internal register. <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> imageNickName - <td> <em>imageNickName</em> gets uppercased and is used to look up the internal + <td> optional <em>imageNickName</em> gets uppercased and is used to look up the internal image registry, get its size which is returned via the Rexx variable <em>RC</em>. @@ -1014,13 +1112,13 @@ <td class="command"> "imageType" <td colspan="2"> Query the image type. With no arguments returns the current image's type which can be referred to via the Rexx variable <em>RC</em> upon return from this command. - <br>Supplying the <em>imageNickName</em> argument will return the type of the image + <br>Supplying the optional <em>imageNickName</em> argument will return the type of the image from the internal register. <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> imageNickName - <td> <em>imageNickName</em> gets uppercased and is used to look up the internal + <td> optional <em>imageNickName</em> gets uppercased and is used to look up the internal image registry, get its type which is returned via the Rexx variable <em>RC</em>. @@ -1028,7 +1126,7 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "loadImage" + <td class="command" id="cmdLoadImage"> "loadImage" <td colspan="2"> Loads an image from <em>fileName</em>, stores it with the uppercased <em>imageNickName</em> in the internal image registry and returns the image's size (dimension), i.e. <em>width</em> and <em>height</em> via the Rexx variable <em>RC</em>. @@ -1047,9 +1145,10 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "new" + <td class="command" id="cmdNew"> "new" <td colspan="2"> Creates a new image. By default the <em>width</em> and the <em>height</em> are - set to <em>500</em> and the type to <em>2</em> (<em>BufferedImage.TYPE_INT_ARGB</em>). + set to <em>500</em> and the <em>type</em> to the current value of + <a href="#cmdPreferredImageType"><em>preferredImageType</em></a>. <br>Cf. the Java documentation for the Java class <em>java.awt.image.BufferedImage</em> and and its constants. @@ -1059,32 +1158,21 @@ <td class="argument"> width height [type] <td> The size is given in <em>width</em> and <em>height</em> pixels. The optional <em>type</em> allows to override the image type. - <br><em>type</em> may have one of the following values: + <br>The optional <em>type</em>, if omitted gets set to current value of + <a href="#cmdPreferredImageType"><em>preferredImageType</em></a> (defaults + to <em>2</em> a.k.a. <em>BufferedImage.TYPE_INT_ARGB</em>). - <em>TYPE_3BYTE_BGR</em> (<em>5</em>), - <em>TYPE_4BYTE_ABGR</em> (<em>6</em>), - <em>TYPE_4BYTE_ABGR_PRE</em> (<em>7</em>), - <em>TYPE_BYTE_BINARY</em> (<em>12</em>), - <em>TYPE_BYTE_GRAY</em> (<em>10</em>), - <em>TYPE_BYTE_INDEXED</em> (<em>13</em>), - <em>TYPE_CUSTOM</em> (<em>0</em>), - <em>TYPE_INT_ARGB</em> (<em>2</em>), - <em>TYPE_INT_ARGB_PRE</em> (<em>3</em>), - <em>TYPE_INT_BGR</em> (<em>4</em>), - <em>TYPE_INT_RGB</em> (<em>1</em>), - <em>TYPE_USHORT_555_RGB</em> (<em>9</em>), - <em>TYPE_USHORT_565_RGB</em> (<em>8</em>) and - <em>TYPE_USHORT_GRAY</em> (<em>11</em>). - <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "paint" - <td colspan="2"> Queries or sets current paint. With no argument returns the - current <em>paint</em> value which can be referred to via the Rexx variable - <em>RC</em> upon return from this command. + <td class="command" id="cmdPaint"> "paint" + <td colspan="2"> Queries or sets current paint (used for filling). + <br>Querying the current value (no argument supplied) will return it, setting + (changing) the value to a new value will return the old (previously set) value + via the Rexx variable <em>RC</em>. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the methods <em>getPaint()</em>, <em>setPaint(...)</em>. @@ -1098,10 +1186,10 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "popGC" - <td colspan="2"> Disposes the current <em>GC</em> and replaces it by popping + <td class="command" id="cmdPopGC"> "popGC" + <td colspan="2"> Disposes the current <a href="#dtGC"><em>GC</em></a> and replaces it by popping a <em>GC</em> from the stack, thereby resetting all the graphical - configuration changes to that state and returns it + configuration changes to that state and returns the popped (now current) <a href="#dtGC"><em>GC</em></a> via the Rexx variable <em>RC</em>. @@ -1109,15 +1197,18 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "popImage" - <td colspan="2"> Pops the <em>image</em> from the stack and replaces - the current image. + <td colspan="2"> Pops the <em>image</em> from the stack and uses it to draw + on to the current image. + Returns the popped image via the Rexx variable <em>RC</em> upon return from this + command. <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "preferredImageType" - <td colspan="2"> Queries or sets the preferred image type used for creating new images. + <td class="command" id="cmdPreferredImageType"> "preferredImageType" + <td colspan="2"> Queries or sets the preferred image type used for creating new images + (cf. <a href="#cmdNew">new</a> command). Returns the image type via the Rexx variable <em>RC</em> upon return from this command. <br>Cf. the Java documentation for the Java class <em>java.awt.image.BufferedImage</em> and @@ -1126,10 +1217,24 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> type - <td> <em>type</em> denotes the new preferred image type + <td> denotes the new preferred image type and may have one + of the following values: + <em>TYPE_3BYTE_BGR</em> (<em>5</em>), + <em>TYPE_4BYTE_ABGR</em> (<em>6</em>), + <em>TYPE_4BYTE_ABGR_PRE</em> (<em>7</em>), + <em>TYPE_BYTE_BINARY</em> (<em>12</em>), + <em>TYPE_BYTE_GRAY</em> (<em>10</em>), + <em>TYPE_BYTE_INDEXED</em> (<em>13</em>), + <em>TYPE_CUSTOM</em> (<em>0</em>), + <em>TYPE_INT_ARGB</em> (<em>2</em>), + <em>TYPE_INT_ARGB_PRE</em> (<em>3</em>), + <em>TYPE_INT_BGR</em> (<em>4</em>), + <em>TYPE_INT_RGB</em> (<em>1</em>), + <em>TYPE_USHORT_555_RGB</em> (<em>9</em>), + <em>TYPE_USHORT_565_RGB</em> (<em>8</em>) and + <em>TYPE_USHORT_GRAY</em> (<em>11</em>). - <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> @@ -1140,7 +1245,7 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> imageNickName - <td> <em>imageNickName</em> is uppercased and used to look up the image from the internal + <td> optional <em>imageNickName</em> is uppercased and used to look up the image from the internal registry that should get printed. @@ -1148,10 +1253,14 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "printPos" - <td colspan="2"> Sets the left upper hand corner on the page where the image should + <td colspan="2"> Queries or sets the left upper hand corner on the page where the image should be drawn to. This command has no effect if <em>printScaleToPage</em> was set to - <em>.true</em> (<em>0</em>). + <em>.true</em> (<em>1</em>). + <br>Querying the current value (no argument supplied) will return it, setting + (changing) the value to a new value will return the old (previously set) value + via the Rexx variable <em>RC</em>. + <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> x [y] @@ -1165,6 +1274,10 @@ <td class="command"> "printScale" <td colspan="2"> Sets the scale factor for the print page <em>x</em> and <em>y</em> axis. + <br>Querying the current value (no argument supplied) will return it, setting + (changing) the value to a new value will return the old (previously set) value + via the Rexx variable <em>RC</em>. + <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> scaleX [scaleY] @@ -1176,7 +1289,13 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "printScaleToPage" - <td colspan="2"> Queries or sets the value. If set to <em>.true</em>, the image + <td colspan="2"> Queries or sets the value. + + <br>Querying the current value (no argument supplied) will return it, setting + (changing) the value to a new value will return the old (previously set) value + via the Rexx variable <em>RC</em>. + + If set to <em>.true</em>, the image will be scaled to the printable image area such, that the entire image gets printed proportionally. Returns the setting via the Rexx variable <em>RC</em>. @@ -1183,7 +1302,7 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> booleanValue - <td> <em>booleanValue</em> can be one of + <td> optional <em>booleanValue</em> can be one of <em>1</em>, <em>".true"</em>, <em>"true"</em>, @@ -1195,12 +1314,14 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "pushGC" - <td colspan="2"> Push the current <em>GC</em> on the stack, thereby - saving all current settings and transformations. Creates a copy of - the current <em>GC</em> and uses it from then on. - The new <em>GC</em> gets returned via the Rexx variable <em>RC</em>. + <td class="command" id="cmdPushGC"> "pushGC" + <td colspan="2"> Push the current <a href="#dtGC"><em>GC</em></a> (graphical configuration) on the stack, thereby + saving the current configuration (settings and transformations). This command will then + create a copy of the current <a href="#dtGC"><em>GC</em></a> which will get used from then on. + The pushed <a href="#dtGC"><em>GC</em></a> will get returned + via the Rexx variable <em>RC</em>. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>create()</em>. @@ -1208,7 +1329,7 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "pushImage" + <td class="command" id="cmdPushImage"> "pushImage" <td colspan="2"> Pushes a copy of the current <em>image</em> to the stack and optionally stores it with an <em>imageNickName</em> in the internal registry for later references by <em>imageNickName</em>. The image copy gets returned via the @@ -1217,7 +1338,7 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> imageNickName - <td> Optional, <em>imageNickName</em> will be uppercased and used to store the image + <td> optional <em>imageNickName</em> will be uppercased and used to store the image in the internal image registry. @@ -1224,7 +1345,7 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "reset" <br> "clear" + <td class="command" id="cmdReset"> "reset" <br> "clear" <td colspan="2"> Resets the following runtime values: <ul> <li><em>colors</em>: the <em>java.util.HashMap</em> gets emptied except for the constant colors @@ -1250,18 +1371,19 @@ The command name <em>clear</em> is an alias, a synonym for this command. - <tr class="ArgumentRowColor"><td><!-- table row --> - <td> - <td class="argument"> xyz - <td> <em>xyz</em> position on the x-axis. - <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "rotate" - <td colspan="2"> Queries or rotates the image. + <td class="command" id="cmdRotate"> "rotate" + <td colspan="2"> Queries the runtime variable <em>currAngle</em> (if no arguments are + supplied) or rotates the image such that new drawings are rotated in effect. + This command returns the value of the runtime variable <em>currAngle</em> + (which accumulates rotation theta values, but may not be correct after + <a href="#cmdPopGC">popGC</em></a> or <a href="#cmdReset">reset</em></a> commands) + via the Rexx variable <em>RC</em>. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the method <em>rotate(...)</em>. Note: this command converts the supplied degrees (<em>0</em> to <em>360</em>) to radians and supplies it to the Java method. @@ -1282,7 +1404,8 @@ <td class="command"> "saveImage" <td colspan="2"> Saves the current image to a file. If the saving of the image was successful <em>1</em> (<em>.true</em>) gets returned via the - Rexx variable <em>RC</em>, otherwise <em>0</em> (<em>.false</em>) . + Rexx variable <em>RC</em>, otherwise <em>-16</em> gets returned indicating an error has occurred + (use output or error redirection to get further information in case of an error). <br>Cf. the Java documentation for the Java class <em>javax.imageio.ImageIO</em> and the method <em>write(...)</em>. @@ -1297,7 +1420,7 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "scale" + <td class="command" id="cmdScale"> "scale" <td colspan="2"> Sets the scale factor for the <em>y</em> and <em>y</em> axis. <tr class="ArgumentRowColor"><td><!-- table row --> @@ -1320,7 +1443,7 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "shear" + <td class="command" id="cmdShear"> "shear" <td colspan="2"> Sets the shear (skew) factor for the <em>y</em> and <em>y</em> axis. <tr class="ArgumentRowColor"><td><!-- table row --> @@ -1348,10 +1471,13 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "stroke" - <td colspan="2"> Queries, defines and sets strokes. With no arguments the currently - set <em>BasicStroke</em> object gets returned via the Rexx variable <em>RC</em>. + <td class="command" id="cmdStroke"> "stroke" + <td colspan="2"> Queries, defines and sets strokes. + <br>Querying the current value (no argument supplied) will return it, setting + (changing) the value to a new value will return the old (previously set) value + via the Rexx variable <em>RC</em>. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the methods <em>getStroke()</em>, <em>setStroke(...)</em> and the Java class <em>java.awt.BasicStroke</em> with its constructors and constants for the @@ -1401,7 +1527,7 @@ <!-- -------------------------------------------------------- --> <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> - <td class="command"> "translate" + <td class="command" id="cmdTranslate"> "translate" <td colspan="2"> Moves the origin <em>"(0,0)"</em> from the upper left hand corner by adding <em>x</em> pixels to <em>currX</em> and <em>y</em> pixels to <em>currY</em>. @@ -1416,7 +1542,13 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "winAlwaysOnTop" - <td colspan="2"> Queries or sets the value. If set to <em>.true</em>, the frame (window) + <td colspan="2"> Queries or sets the value. + + <br>Querying the current value (no argument supplied) will return it, setting + (changing) the value to a new value will return the old (previously set) value + via the Rexx variable <em>RC</em>. + + If set to <em>.true</em>, the frame (window) that displays the image will be always on top of other windows. If no argument is supplied the current setting will be returned via the Rexx variable <em>RC</em>. @@ -1427,7 +1559,7 @@ <tr class="ArgumentRowColor"><td><!-- table row --> <td> <td class="argument"> booleanValue - <td> <em>booleanValue</em> can be one of + <td> optional <em>booleanValue</em> can be one of <em>1</em>, <em>".true"</em>, <em>"true"</em>, @@ -1460,7 +1592,13 @@ <tr class="CommandRowColumn"><!-- table row --> <td class="cmdNr"> <td class="command"> "winFrame" - <td colspan="2"> Queries or sets the value. If set to <em>.true</em>, the frame (window) + <td colspan="2"> Queries or sets the value. + + <br>Querying the current value (no argument supplied) will return it, sett... [truncated message content] |
From: <or...@us...> - 2022-10-23 14:34:04
|
Revision: 1009 http://sourceforge.net/p/bsf4oorexx/code/1009 Author: orexx Date: 2022-10-23 14:33:52 +0000 (Sun, 23 Oct 2022) Log Message: ----------- 20221023 Some updates, corrections; new alias LOCATION for GOTO. Modified Paths: -------------- sandbox/rgf/jdor/JavaDrawingHandler.java sandbox/rgf/jdor/doc/jdor_doc.html sandbox/rgf/jdor/doc/jdor_doc_sample.rex sandbox/rgf/jdor/doc/readmeCreateJDOR.txt sandbox/rgf/jdor/readmeCreateJDOR.txt sandbox/rgf/jdor/samples/1-160_JDOR_getState.rxj sandbox/rgf/jdor/samples/2-110_JDOR_listShowPrintFonts.rxj Modified: sandbox/rgf/jdor/JavaDrawingHandler.java =================================================================== --- sandbox/rgf/jdor/JavaDrawingHandler.java 2022-10-16 17:03:49 UTC (rev 1008) +++ sandbox/rgf/jdor/JavaDrawingHandler.java 2022-10-23 14:33:52 UTC (rev 1009) @@ -9,8 +9,9 @@ operating system (Windows, MacOS, Linux) where Java, ooRexx and BSF4ooRexx is available. - author: Rony G. Flatscher - date: 2022-09-05/2022-10-03 + author: Rony G. Flatscher + date: 2022-09-05/2022-10-05 + version: 003.20221020 license: Apache license 2.0 license: @@ -33,6 +34,27 @@ */ +/* changes: + 2022-10-05: - corrected Frame's currX and currY values + - corrected return value for IMAGE_SIZE as num+' '+num would add the + numbers with the value of the single blank value to num+" "+num to + return a string + + 2022-10-20: - corrected drawString argument: make sure to preserve leading blanks + by just skipping a single blank after the command, taking the remainder + as the whole string + + 2022-10-21: - corrected WIN_LOCATION: now honors no arguments + - new command "drawImageFromVar": allow an image referred to by a Rexx + variable to be drawn (to ease drawing images on different JDOR handler + instances) + 2022-10-22: - fold DRAW_IMAGE_FROM_VAR into DRAW_IMAGE + - corrected LOAD_IMAGE to return dimension instead of image (cf. documentation) + - change logic for queryable and setable commands: if setting new + value, return previous value + 2022-10-23: - reworkd some WIN_* commands to not automatically create and show JFrame +*/ + /* Sample program in ooRexx (temporarily): -- load and add the Java Rexx command handler, using default name: JDOR @@ -103,6 +125,7 @@ import javax.swing.SwingUtilities; +import java.awt.Image; import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; // for loading/saving @@ -161,7 +184,9 @@ add(sf); setTitle("JavaDrawingFrame"); // needs to be followed by pack() to take effect immediately - getContentPane().setPreferredSize(new Dimension(bufImage.getWidth(),bufImage.getHeight())); + currWidth=bufImage.getWidth(); + currHeight=bufImage.getHeight(); + getContentPane().setPreferredSize(new Dimension(currWidth,currHeight)); pack(); setLocationRelativeTo(null); @@ -214,7 +239,7 @@ /* static definitions */ // default image sizes - static final public String version = "001.20221002"; + static final public String version = "005.20221022"; static final private int prefWidth = 500; static final private int prefHeight = 500; static private int prefImageType = BufferedImage.TYPE_INT_ARGB; // default with alpha (only png supported) @@ -323,6 +348,8 @@ /* current values */ int currX = 0; int currY = 0; +// TODO: if popGC reset currAngle to that one; needs to also push currAngle; +// not necessary in the first incarnation double currAngle = 0; // if rotate gets used, keeps current angle (in radians) int currFontStyle = 0; // PLAIN by default @@ -484,6 +511,7 @@ } String canonical = cmd.mixedCase;; + Object resultValue = null; // process commands; jd may be null ! try @@ -503,7 +531,7 @@ } if (currVisible) // already visible, nothing to do { - return "1"; + return null; } if (jd==null) // implies creation of JavaDrawingFrame and make it visible { @@ -530,7 +558,6 @@ } jd.setVisible(false); currVisible=false; - break; } @@ -540,22 +567,24 @@ { throw new IllegalArgumentException("this command does not accept any arguments, received "+(arrCommand.length-1)+" instead"); } - if (jd!=null) - { - jd.dispatchEvent(new WindowEvent(jd, WindowEvent.WINDOW_CLOSING)); - jd=null; - } - currVisible=false; if (isOR) { writeOutput(slot, canonical); } + if (jd==null) // nothing to do + { + return null; + } + + jd.dispatchEvent(new WindowEvent(jd, WindowEvent.WINDOW_CLOSING)); + jd=null; + currVisible=false; } break; case WIN_LOCATION: // synonym WINMOVETO "winLocation [x y]" get or set JFrame location on screen { - if (arrCommand.length!=3) + if (arrCommand.length!=1 && arrCommand.length!=3) { throw new IllegalArgumentException("this command needs no or exactly 2 arguments, received "+(arrCommand.length-1)+" instead"); } @@ -569,6 +598,8 @@ int newX = jd.getX(); int newY = jd.getY(); + resultValue = newX+" "+newY; // query current value (to be returned if change occurs) + if (arrCommand.length==3) { newX = Integer.parseInt(arrCommand[1]); @@ -583,7 +614,8 @@ } if (arrCommand.length==1) { - return newX+" "+newY; + // return newX+" "+newY; + return resultValue; } break; } @@ -595,6 +627,14 @@ { throw new IllegalArgumentException("this command needs no or exactly 1 argument, received "+(arrCommand.length-1)+" instead"); } + if (jd!=null) + { + resultValue = (jd.isAlwaysOnTop() ? "1" : "0"); // query current value (to be returned if change occurs) + } + else + { + resultValue = "0"; // false, does not exist + } } case WIN_TO_BACK: // "winToBack" put window into the back case WIN_TO_FRONT: // "winToFront" put window into the front @@ -604,15 +644,20 @@ { throw new IllegalArgumentException("this command expects no arguments, received "+(arrCommand.length-1)+" instead"); } - if (jd==null) // implies creation of JavaDrawingFrame and make it visible + if (jd==null) // implies creation of JavaDrawingFrame { jd = new JavaDrawingFrame(bufImage); - jd.setVisible(true); // make sure frame is visible - currVisible=true; + if (cmd!=Command.WIN_ALWAYS_ON_TOP_SUPPORTED) + { + jd.setVisible(true); // make sure frame is visible + currVisible=true; + } + else + { + currVisible=false; + } } - boolean retBoolValue=true; - switch (cmd) { case WIN_ALWAYS_ON_TOP: @@ -620,6 +665,7 @@ if (arrCommand.length!=1) { String newValue = arrCommand[1]; + boolean retBoolValue; if (checkBooleanValue(newValue)) // a valid BSF4ooRexx850 boolean value? { @@ -633,10 +679,6 @@ canonical=canonical+" "+newValue; jd.setAlwaysOnTop(retBoolValue); // set value } - else - { - retBoolValue=jd.isAlwaysOnTop(); - } break; } @@ -649,7 +691,8 @@ break; case WIN_ALWAYS_ON_TOP_SUPPORTED: // "winAlwaysOnTopSupported" get value - retBoolValue=jd.isAlwaysOnTopSupported(); + // retBoolValue=jd.isAlwaysOnTopSupported(); + resultValue = (jd.isAlwaysOnTopSupported() ? "1" : "0"); // query current value (to be returned if change occurs) break; } @@ -658,7 +701,8 @@ writeOutput(slot, canonical); // write canonical form } - return retBoolValue ? "1" : "0"; + // return retBoolValue ? "1" : "0"; + return resultValue; } @@ -670,6 +714,7 @@ jd.setVisible(true); // make sure frame is visible currVisible=true; } + resultValue = jd.getTitle(); // query current value (to be returned if change occurs) if (arrCommand.length==1) // return current setting (via RC) { if (isOR) @@ -676,11 +721,13 @@ { writeOutput(slot,canonical); } - return jd.getTitle(); + return resultValue; } - int [] pos = (int []) alWordBoundaries.get(1); // String - String newTitle = command.substring(pos[0]); // extract String (may contain blanks) + // to fetch leading blanks we skip over first blank (unlike for other commands where we ignore all blanks after the command) + int [] pos = (int []) alWordBoundaries.get(0); + String newTitle = command.substring(pos[1]+1); // extract String: skip over first trailing blank + if (isOR) { writeOutput(slot,canonical+" "+newTitle); @@ -696,10 +743,13 @@ if (jd==null) // implies creation of JavaDrawingFrame and make it visible { jd = new JavaDrawingFrame(bufImage); - jd.setVisible(true); // make sure frame is visible - currVisible = true; + // jd.setVisible(true); // make sure frame is visible + // currVisible = true; + currVisible = false; } + resultValue = jd.currFrameVisible ? "1" : "0"; // query current value (to be returned if change occurs) + if (arrCommand.length==1) // return current setting (via RC) { if (isOR) @@ -706,7 +756,7 @@ { writeOutput(slot,canonical); } - return (jd.currFrameVisible ? "1" : "0"); + return resultValue; } if (arrCommand.length!=2) @@ -750,6 +800,8 @@ case WIN_VISIBLE: // winVisible [.true|.false]: query or set whether frame is visible { + resultValue = currVisible ? "1" : "0"; // query current value (to be returned if change occurs) + if (arrCommand.length==1) // return current setting (via RC) { if (isOR) @@ -756,7 +808,7 @@ { writeOutput(slot,canonical); } - return (currVisible ? "1" : "0"); + return resultValue; } if (arrCommand.length!=2) @@ -777,19 +829,30 @@ + "\"0\", \"1\", \"false\", \"true\", \".false\", \".true\""); } - if (currVisible==newBooleanValue) // already at the same state, ignore command + if (currVisible==newBooleanValue) // already at the same state, ignore command, but return "old" value { - return null; + return resultValue; } // no exception, so args o.k. - if (isOR) + if (isOR && arrCommand.length==2) { writeOutput(slot,canonical+" "+(newBooleanValue ? "1" : "0")); } + + if (jd==null) + { + jd = new JavaDrawingFrame(bufImage); + if (newBooleanValue) + { + jd.setVisible(true); // make frame is visible + } + } + else if (currVisible!=newBooleanValue) + { + jd.setVisible(newBooleanValue); + } currVisible = newBooleanValue; - jd.setVisible(newBooleanValue); - break; } @@ -837,12 +900,21 @@ if (jd==null) // implies creation of JavaDrawingFrame and make it visible { jd = new JavaDrawingFrame(bufImage); - jd.setVisible(true); - currVisible=true; + if (currVisible) + { + jd.setVisible(true); + } } + + resultValue = jd.currWidth+" "+jd.currHeight; // query current value (to be returned if change occurs) + if (arrCommand.length==1) // return current setting (via RC) { - return jd.currWidth+" "+jd.currHeight; + if (isOR) + { + writeOutput(slot, canonical); + } + return resultValue; } if (arrCommand.length!=3) { @@ -875,8 +947,10 @@ throw new IllegalArgumentException("this command does not expect any arguments, received "+(arrCommand.length-1)+" instead"); } - case PRINT_SCALE_TO_PAGE: // ( "printScaleToPage" ) , // "printScaleToPage [.true|.false]": get or set + case PRINT_SCALE_TO_PAGE: // "printScaleToPage [.true|.false]": query/get or set { + resultValue = (printScaleToPage ? "1" : "0"); // query current value (to be returned if change occurs) + if (arrCommand.length==1) // return current setting (via RC) { if (isOR) @@ -883,7 +957,7 @@ { writeOutput(slot,canonical); } - return (printScaleToPage ? "1" : "0"); + return resultValue; } if (arrCommand.length!=2) @@ -901,10 +975,11 @@ throw new IllegalArgumentException("the supplied \"printScaleToPage\" argument \""+newValue+"\" is not a valid BSF4ooRexx850 boolean value, valid values (in any case) are: " + "\"0\", \"1\", \"false\", \"true\", \".false\", \".true\""); } - return printScaleToPage ? "1" : "0"; + // return printScaleToPage ? "1" : "0"; + return resultValue; } - case PRINT_SCALE: // "printScale [scaleX [scaleY]": get or set scaleX (if no scaleY use scaleX) + case PRINT_SCALE: // "printScale [scaleX [scaleY]": query/get or set scaleX (if no scaleY use scaleX) { if (arrCommand.length>3) { @@ -911,6 +986,8 @@ throw new IllegalArgumentException("this command needs no or 1 or 2 arguments, received "+(arrCommand.length-1)+" instead"); } + resultValue = printScaleX+" "+printScaleY; // query current value (to be returned if change occurs) + if (arrCommand.length>1) { double tmpScaleX = Double.parseDouble(arrCommand[1]); @@ -933,7 +1010,8 @@ writeOutput(slot,canonical); } - return printScaleX+" "+printScaleY; + //return printScaleX+" "+printScaleY; + return resultValue; } case PRINT_POS: // "printPos [X [Y]]: get or set position of left upperhand corner @@ -942,6 +1020,9 @@ { throw new IllegalArgumentException("this command expects no, 1 or 2 arguments, received "+(arrCommand.length-1)+" instead"); } + + resultValue = printPosX+" "+printPosY; // query current value (to be returned if change occurs) + int newX = Integer.parseInt(arrCommand[1]); int newY = newX; // default to newX if (arrCommand.length==3) @@ -951,16 +1032,16 @@ // no exception, so args o.k. printPosX = newX; printPosY = newY; - String res = currX+" "+currY; if (isOR) { - canonical=canonical+" "+res; + canonical=canonical+" "+newX+" "+newY; } if (isOR) { writeOutput(slot, canonical); } - return res; + // return res; + return resultValue; } case PRINT_IMAGE: // "printImage [nickName]" @@ -1045,9 +1126,10 @@ } if (isOR) { - writeOutput(slot, canonical+' '+strResult); // write canonical form + writeOutput(slot, canonical+" "+strResult); // write canonical form } - return strResult; + // return strResult; + return null; // returns null, i.e. RC="0" -> command executed alright } case NEW: // "new [width height [type]]" creates a new BufferedImage @@ -1130,12 +1212,14 @@ } break; - case PREFERRED_IMAGE_TYPE: // "preferredImageType [type]": integer or constant name + case PREFERRED_IMAGE_TYPE: // "preferredImageType [type]": query or set: integer or constant name { if (arrCommand.length>2) { throw new IllegalArgumentException("this command needs either no or exactly 1 argument (preferred image type), received "+(arrCommand.length-1)+" instead"); } + resultValue = ""+prefImageType; // query current value (to be returned if change occurs) + if (arrCommand.length==2) { int type; @@ -1167,7 +1251,8 @@ { writeOutput(slot, canonical); } - return "" + prefImageType; + // return "" + prefImageType; + return resultValue; } case IMAGE_TYPE: // "imageType [nickName]" @@ -1223,7 +1308,7 @@ { writeOutput(slot, canonical); } - return tmpImg.getWidth()+' '+tmpImg.getHeight(); + return tmpImg.getWidth()+" "+tmpImg.getHeight(); } // create a RexxStringTable, fill it with current settings, stacks, maps and return it; @@ -1301,6 +1386,9 @@ } Color color=null; int red, green, blue, alpha; + + resultValue = bufGC.getColor(); // query current value (to be returned if change occurs) + if (arrCommand.length==1) { if (isOR) @@ -1307,7 +1395,7 @@ { writeOutput(slot, canonical); } - return bufGC.getColor(); + return resultValue; } String colorNickName = arrCommand[1]; // get color name @@ -1332,7 +1420,8 @@ writeOutput(slot, canonical); } bufGC.setColor(color); - return color; + // return color; + return resultValue; // return previous color } red = Integer.parseInt(arrCommand[2]); @@ -1361,17 +1450,20 @@ { writeOutput(slot, canonical); } - return color; + // return color; + return resultValue; // return previous color } - case GRADIENT_PAINT: // "gradientPaint paintNickName [x1 y1 colorName1 x2 y2 colorName2 [cyclic]]" sets or defines and sets gradientPaint + case GRADIENT_PAINT: // "gradientPaint paintNickName [x1 y1 colorName1 x2 y2 colorName2 [cyclic]]": sets or defines and sets gradientPaint { int argNum = arrCommand.length; if (argNum!=2 && argNum!=8 && argNum!=9) { - throw new IllegalArgumentException("this command needs either 7 or 8 arguments, received "+(argNum-1)+" instead"); + throw new IllegalArgumentException("this command needs either one, 7 or 8 arguments, received "+(argNum-1)+" instead"); } + resultValue = bufGC.getPaint(); // query current value (to be returned if change occurs) + String paintNickName = arrCommand[1]; // get nick name GradientPaint gradientPaint=null; @@ -1396,7 +1488,8 @@ writeOutput(slot, canonical); } bufGC.setPaint(gradientPaint); - return gradientPaint; + // return gradientPaint; + return resultValue; } Color color1=null, color2=null; @@ -1466,7 +1559,8 @@ { writeOutput(slot, canonical); } - return gradientPaint; + // return gradientPaint; + return resultValue; } case SET_PAINT_MODE: // "setPaintMode", cf. Graphics#setPaintMode @@ -1486,6 +1580,8 @@ // 2022-09-23: nice gradient samples: <http://www.java2s.com/Code/Java/2D-Graphics-GUI/GradientPaintdemo.htm> case PAINT: // "paint [colorNickName|gradientPaintNickName]" query or set paint to a color or a gradientPaint { + resultValue = bufGC.getPaint(); // query current value (to be returned if change occurs) + if (arrCommand.length==1) // return current setting (via RC) { if (isOR) @@ -1492,7 +1588,7 @@ { writeOutput(slot, canonical); } - return bufGC.getPaint(); + return resultValue; } if (arrCommand.length==2) { @@ -1518,7 +1614,8 @@ writeOutput(slot, canonical); } bufGC.setPaint(paint); - return paint; + // return paint; + return resultValue; } throw new IllegalArgumentException("this command needs either no or exactly 1 argument, received "+(arrCommand.length-1)+" instead"); } @@ -1525,6 +1622,8 @@ case BACKGROUND: // "background [colorNickName]" query current background color or set { + resultValue = bufGC.getBackground(); // query current value (to be returned if change occurs) + if (arrCommand.length==1) // return current setting (via RC) { if (isOR) @@ -1531,7 +1630,7 @@ { writeOutput(slot, canonical); } - return bufGC.getBackground(); + return resultValue; } if (arrCommand.length==2) { @@ -1552,7 +1651,8 @@ writeOutput(slot, canonical); } bufGC.setBackground(color); - return color; + // return color; + return resultValue; } throw new IllegalArgumentException("this command needs either no or exactly 1 argument, received "+(arrCommand.length-1)+" instead"); } @@ -1583,7 +1683,7 @@ return null; } - case COMPOSITE: // "composite [rule [alpha]]": get current or get and set new + case COMPOSITE: // "composite [rule [alpha]]": query current or get and set new { int argNum=arrCommand.length; if (argNum>3) @@ -1590,6 +1690,8 @@ { throw new IllegalArgumentException("this command needs either no, one (rule) or two (rule alpha) arguments, received "+(argNum-1)+" instead"); } + resultValue = bufGC.getComposite(); // query current value (to be returned if change occurs) + if (argNum==1) { if (isOR) @@ -1596,7 +1698,7 @@ { writeOutput(slot, canonical); } - return bufGC.getComposite(); + return resultValue; } String ruleName = arrCommand[1].toUpperCase(); // get name @@ -1643,7 +1745,8 @@ writeOutput(slot, canonical); } bufGC.setComposite(ac); - return ac; + // return ac; + return resultValue; } // 2022-09-29 --> @@ -1685,33 +1788,33 @@ return null; } - case CLIP: // "clip [x y w h]" -> get (getClipBounds()) or clipRect(x y w h): returns .nil if no clip set + case CLIP: // query or set "clip [x y w h]" -> get (getClipBounds()) or clipRect(x y w h): returns .nil if no clip set { if (arrCommand.length!=1 && arrCommand.length!=5) { throw new IllegalArgumentException("this command expects no or exactly 4 arguments, received "+(arrCommand.length-1)+" instead"); } - Object res=null; - if (arrCommand.length==1) + + resultValue=null; + + Rectangle r = bufGC.getClipBounds(); + if (r!=null) { - Rectangle r = bufGC.getClipBounds(); - if (r!=null) - { - res = r.x+" "+r.y+" "+r.width+" "+r.height; - } - else // indicate no clip - { - res = getNil(slot); - } + resultValue = r.x+" "+r.y+" "+r.width+" "+r.height; } - else + else // indicate no clip { + resultValue = getNil(slot); + } + + if (arrCommand.length>1) // clip area supplied + { int newX = Integer.parseInt(arrCommand[1]); int newY = Integer.parseInt(arrCommand[2]); int newWidth = Integer.parseInt(arrCommand[3]); int newHeight = Integer.parseInt(arrCommand[4]); - res = newX+" "+newY+" "+newWidth+" "+newHeight; - canonical = canonical+" "+res; + resultValue = newX+" "+newY+" "+newWidth+" "+newHeight; + canonical = canonical+" "+resultValue; bufGC.clipRect(newX, newY, newWidth, newHeight); } // no exception, so args o.k. @@ -1719,7 +1822,7 @@ { writeOutput(slot, canonical); } - return res; + return resultValue; } // <--- @@ -1792,6 +1895,9 @@ { throw new IllegalArgumentException("this command needs either no, 2 (strokeNickName width), 4 (strokeNickName width cap join), 4 or 6 arguments (strokeNickName width cap join miterlimit arrDashes dashPhase), received "+(argNum-1)+" instead"); } + + resultValue = bufGC.getStroke(); // query current value (to be returned if change occurs) + if (argNum==1) { if (isOR) @@ -1798,7 +1904,7 @@ { writeOutput(slot, canonical); } - return bufGC.getStroke(); + return resultValue; } String strokeNickName = arrCommand[1]; // get name @@ -1824,7 +1930,8 @@ writeOutput(slot, canonical); } bufGC.setStroke(stroke); - return stroke; + // return stroke; + return resultValue; } int width, cap, join; // , miterlimit; @@ -1926,7 +2033,8 @@ { writeOutput(slot, canonical); } - return stroke; + // return stroke; + return resultValue; } case FONT_STYLE: // "fontStyle [0=PLAIN | 1=BOLD | 2=ITALIC | 3=BOLD+ITALIC] @@ -1936,6 +2044,8 @@ throw new IllegalArgumentException("this command needs either no or exactly 1 argument (fontStyle), received "+(arrCommand.length-1)+" instead"); } + resultValue = "" + currFontStyle; // query current value (to be returned if change occurs) + if (arrCommand.length==2) { int newFontStyle = Integer.parseInt(arrCommand[1]); @@ -1954,7 +2064,7 @@ { writeOutput(slot, canonical); } - return "" + currFontStyle; + return resultValue; } case FONT_SIZE: // "fontSize [size]" @@ -1963,6 +2073,9 @@ { throw new IllegalArgumentException("this command needs either no or exactly 1 argument (fontSize), received "+(arrCommand.length-1)+" instead"); } + + resultValue = "" + currFontSize; // query current value (to be returned if change occurs) + if (arrCommand.length==2) { int newFontSize = Integer.parseInt(arrCommand[1]); @@ -1981,11 +2094,13 @@ { writeOutput(slot, canonical); } - return "" + currFontSize; + return resultValue; } case FONT: // "font [fontNickName [name]" query or set font; uses currFontStyle, currFontSize; "Dialog", "DialogInput", "Serif", "SansSerif", "Monospaced" { + resultValue = bufGC.getFont(); // query current value (to be returned if change occurs) + if (arrCommand.length==1) { if (isOR) @@ -1992,7 +2107,7 @@ { writeOutput(slot, canonical); } - return bufGC.getFont(); + return resultValue; } Font font=null; String fontNickName = arrCommand[1]; // get font name @@ -2017,7 +2132,8 @@ { writeOutput(slot, canonical); } - return font; + // return font; + return resultValue; } // o.k. Font name may contain blanks so use start of third word and all what remains @@ -2038,7 +2154,8 @@ { writeOutput(slot, canonical); } - return font; + // return font; + return resultValue; } case RESET: // "reset" synonym: "clear", clears everything, resets @@ -2057,12 +2174,13 @@ // ---------------------- - case POS: // return current coordinates or goto x, y co-ordinate + case POS: // query current coordinates or goto x, y co-ordinate { if (arrCommand.length>3) { throw new IllegalArgumentException("this command needs no, 1 or 2 arguments, received "+(arrCommand.length-1)+" instead"); } + resultValue = currX+" "+currY; // query current value (to be returned if change occurs) if (arrCommand.length>1) { int newX = Integer.parseInt(arrCommand[1]); @@ -2083,7 +2201,8 @@ { writeOutput(slot, canonical); } - return currX+" "+currY; + // return currX+" "+currY; + return resultValue; } case DRAW_LINE: // "drawLine toX toY" @@ -2113,8 +2232,9 @@ throw new IllegalArgumentException("this command needs 1 argument (the string to be drawn)"); } // no exception, so args o.k. - int [] pos = (int []) al.get(1); - String str = command.substring(pos[0]); // extract String + // to fetch leading blanks we skip over first blank (unlike for other commands where we ignore all blanks after the command) + int [] pos = (int []) al.get(0); + String str = command.substring(pos[1]+1); // extract String: skip over first trailing blank if (isOR) { writeOutput(slot,canonical+" "+str); @@ -2283,7 +2403,8 @@ { writeOutput(slot, canonical+" "+nickName+" "+fileName); } - return img; + // return img; + return img.getWidth()+" "+img.getHeight(); } case GET_IMAGE: // "getImage [nickName]" returns image or nickName-stored image @@ -2292,6 +2413,7 @@ { throw new IllegalArgumentException("this command needs either no or exactly 1 argument (image's nickname for lookup), received "+(arrCommand.length-1)+" instead"); } + if (arrCommand.length==1) { if (isOR) @@ -2366,6 +2488,9 @@ { ArrayList<int[]> al = alWordBoundaries; int argNum = al.size(); + + resultValue = ""+currAngle; // query current value (to be returned if change occurs) + if (argNum==1) // query currAngle { if (isOR) @@ -2372,7 +2497,7 @@ { writeOutput(slot, canonical); } - return ""+currAngle; + return resultValue; } if (argNum!=2 && argNum!=4) @@ -2407,9 +2532,13 @@ { writeOutput(slot, canonical+" "+theta); } - return ""+theta; + // return ""+theta; + return resultValue; } + + // rgf, 2022-10-21: command to allow drawing an image referred to by a rexx Variable + case DRAW_IMAGE_FROM_REXX_VAR: // "drawImageFromVar rexxVarName [bkgColor] | rexxVarName width height [bkgColor] | rexxVarName width height srcX1 srcY1 srcX2 srcY2 [bkgColor]" case DRAW_IMAGE: // "drawImage nickName [bkgColor] | nickName width height [bkgColor] | nickName width height srcX1 srcY1 srcX2 srcY2 [bkgColor]" { int argNum = arrCommand.length; @@ -2422,11 +2551,26 @@ { canonical=canonical+" "+name; } - BufferedImage img = hmImages.get(name.toUpperCase()); - if (img==null) + + // get Image + Image img = null; + if (cmd==Command.DRAW_IMAGE) // fetch from the image registry { - throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\""); + img = hmImages.get(name.toUpperCase()); + if (img==null) + { + throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\" or \"pushImage "+name+"\""); + } } + else // fetch from the denoted Rexx variable + { + img = (Image) getContextVariable(slot, name); + if (img==null) + { + throw new IllegalArgumentException("Rexx variable named \""+name+"\" does not refer to an image"); + } + } + int width=0, height=0, srcX1=0, srcY1=0, srcX2=0, srcY2=0; String colorNickName=null; Color bkgColor=null; @@ -2541,103 +2685,116 @@ { writeOutput(slot, canonical+" "+newX+" "+newY); } - return newX+" "+newY; + // return newX+" "+newY; + return null; // RC="0", command executed alright } case PUSH_GC: // pushes current GC, does a create() & assigns the new one as current case POP_GC: // pops and & assigns as current - if (arrCommand.length!=1) { - throw new IllegalArgumentException("this command does not expect arguments, received "+(arrCommand.length-1)+" argument(s)"); - } - if (cmd==Command.PUSH_GC) - { - Graphics2D tmpG2D = bufGC; - adGCStack.push(bufGC); - bufGC=(Graphics2D) bufGC.create(); // work on an independent copy from now on - if (isOR) + if (arrCommand.length!=1) { - writeOutput(slot, canonical); + throw new IllegalArgumentException("this command does not expect arguments, received "+(arrCommand.length-1)+" argument(s)"); } - return tmpG2D; - } - else - { - Graphics2D d2d=null; - if (adGCStack.size()>0) + + resultValue = bufGC; // query current value (to be returned if change occurs) + + if (cmd==Command.PUSH_GC) { - d2d=adGCStack.pop(); + Graphics2D tmpG2D = bufGC; + adGCStack.push(bufGC); + bufGC=(Graphics2D) bufGC.create(); // work on an independent copy from now on + if (isOR) + { + writeOutput(slot, canonical); + } + // return tmpG2D; } - if (d2d==null) + else // POP_GC { - String errMsg="did not return a GC (stack empty)"; + Graphics2D d2d=null; + if (adGCStack.size()>0) + { + d2d=adGCStack.pop(); + } + if (d2d==null) + { + String errMsg="did not return a GC (stack empty)"; + if (isOR) + { + writeOutput(slot, "-- ERROR (stack empty): ["+command+"]"); + } + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-13", errMsg ); + } + bufGC.dispose(); // dispose current GC + bufGC=d2d; // replace with previous GC if (isOR) { - writeOutput(slot, "-- ERROR (stack empty): ["+command+"]"); + writeOutput(slot, canonical); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-13", errMsg ); + // return bufGC; + resultValue=bufGC; // old one is disposed, so cannot use that anymore } - bufGC.dispose(); // dispose current GC - bufGC=d2d; // replace with previous GC - if (isOR) - { - writeOutput(slot, canonical); - } - return bufGC; + return resultValue; } // PUSH_IMAGE: "pushImage [nickName]" push current image displayed, if nickName store it in image HashMap as well case PUSH_IMAGE: // pushes current one, does a create() & assigns the new one as current case POP_IMAGE: // pops and & assigns as current - - if ( cmd==Command.POP_IMAGE && arrCommand.length!=1 ) { - throw new IllegalArgumentException("this command does not expect arguments, received "+(arrCommand.length-1)+" argument(s)"); - } - else if ( cmd==Command.PUSH_IMAGE && arrCommand.length>2 ) - { - throw new IllegalArgumentException("this command expects 1 argument at the most (nickName), received "+(arrCommand.length-1)+" argument(s)"); - } - - if (cmd==Command.PUSH_IMAGE) - { - BufferedImage img = copyImage(bufImage); - adImageStack.push(img); // save current image - if (arrCommand.length>1) // nickName supplied, store image in HashMap + if ( cmd==Command.POP_IMAGE && arrCommand.length!=1 ) { - String nickName = arrCommand[1]; - hmImages.put(nickName.toUpperCase(),img); // save in HashMap + throw new IllegalArgumentException("this command does not expect arguments, received "+(arrCommand.length-1)+" argument(s)"); } - if (isOR) + else if ( cmd==Command.PUSH_IMAGE && arrCommand.length>2 ) { - writeOutput(slot, canonical); + throw new IllegalArgumentException("this command expects 1 argument at the most (nickName), received "+(arrCommand.length-1)+" argument(s)"); } - return img; - } - else - { - BufferedImage img=null; - if (adImageStack.size()>0) + + + if (cmd==Command.PUSH_IMAGE) { - img=adImageStack.pop(); // get image from stack + BufferedImage img = copyImage(bufImage); + adImageStack.push(img); // save current image + if (arrCommand.length>1) // nickName supplied, store image in HashMap + { + String nickName = arrCommand[1]; + hmImages.put(nickName.toUpperCase(),img); // save in HashMap + } + if (isOR) + { + writeOutput(slot, canonical); + } + return img; // return pushed (copy) image + // return resultValue; } - if (img==null) // nothing left on stack? + else // POP_IMAGE { - String errMsg="did not return an image (stack empty)"; + BufferedImage img=null; + if (adImageStack.size()>0) + { + img=adImageStack.pop(); // get image from stack + } + if (img==null) // nothing left on stack? + { + String errMsg="did not return an image (empty stack)"; + if (isOR) + { + writeOutput(slot, "-- ERROR (empty stack): ["+command+"]"); + } + return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-14", errMsg ); + } + bufGC.drawImage(img,0,0,null); if (isOR) { - writeOutput(slot, "-- ERROR (stack empty): ["+command+"]"); + writeOutput(slot, canonical); } - return createCondition (slot, nrCommand, command, ConditionType.ERROR, "-14", errMsg ); + resultValue = img; // return popped img, not the draw result + break; // update UI if shown } - bufGC.drawImage(img,0,0,null); - if (isOR) - { - writeOutput(slot, canonical); - } - break; // update UI if shown } + default: // unknown/unhandled command, raise failure condition (should never arrive here) if (isOR) { @@ -2660,7 +2817,8 @@ { jd.sf.repaint(); // trigger a paintComponent() invocation } - return null; + // return null; + return resultValue; } private enum ConditionType @@ -3112,6 +3270,9 @@ DRAW_3D_RECT ( "draw3DRect" ) , // "draw3DRect width height raised" - 20220906 DRAW_ARC ( "drawArc" ) , // "drawArc width height startAngle arcAngle" DRAW_IMAGE ( "drawImage" ) , // "drawImage nickName [bkgColor] | nickName width height [bkgColor] | nickName width height srcX1 srcY1 srcX2 srcY2 [bkgColor]" + + DRAW_IMAGE_FROM_REXX_VAR ( "drawImageFromVar" ) , // "drawImageFromVar rexxVarName [bkgColor] | rexxVarName width height [bkgColor] | rexxVarName width height srcX1 srcY1 srcX2 srcY2 [bkgColor]" + DRAW_LINE ( "drawLine" ) , // "drawLine toX toY" DRAW_OVAL ( "drawOval" ) , // "drawOval width height" DRAW_POLYGON ( "drawPolygon" ) , // "drawPolygon []xPoints []yPoints nPoints @@ -3205,6 +3366,7 @@ // add synonyms new name enum type upperCase2Command.put( "CLEAR" , RESET ) ; upperCase2Command.put( "GOTO" , POS ) ; + upperCase2Command.put( "LOCATION" , POS ) ; // 2022-10-23: new alias upperCase2Command.put( "WINMOVETO" , WIN_LOCATION ) ; } Modified: sandbox/rgf/jdor/doc/jdor_doc.html =================================================================== --- sandbox/rgf/jdor/doc/jdor_doc.html 2022-10-16 17:03:49 UTC (rev 1008) +++ sandbox/rgf/jdor/doc/jdor_doc.html 2022-10-23 14:33:52 UTC (rev 1009) @@ -134,17 +134,17 @@ drawRect len len -- draw the frame with the blue color -- draw a string (text) at the lower half of the bitmap color somePurple 127 46 111 -- define a custom RGB color, store it with nickname "SOMEPURPLE" - say "--> rc="pp(rc) -- show result from command (the Java oclor object) + say "--> rc="pp(rc) -- show result from command (the Java color object) say " rc~toString:" pp(rc~toString) -- shows the RGB intensities of the color newY=height-40 - -- define an array of three strings lineHeight = 15 -- default font size is 12px, add 3 px space + -- define an array of three strings text=("Hello, Rexx world ...", "... from JDOR ...", "(Rexx command handler)") -- array of 3 strings do counter c i=0 to 30 by lineHeight -- iterate over array of strings goto 50 (newY+i) -- set position drawString text[c] -- draw the string end - -- save the current image + -- save the current image saveImage "jdor_doc_sample.png" -- save image to file "jdor_doc_sample.png" sleep 3.123 -- sleep for 3.123 seconds @@ -158,7 +158,7 @@ --> rc=[java.awt.Color@4fe3c938] rc~toString: [java.awt.Color[r=127,g=46,b=111]] </pre> - and create and save the following image (bitmap) using as filename "<code>jdor_doc_sample.png</code>": + and create and save the following image (bitmap) using as filename "<em>jdor_doc_sample.png</em>": <p> <center><img src="jdor_doc_sample.png" border="1px"></center> @@ -168,10 +168,10 @@ <p> The <em>JDOR</em> Rexx command handler makes <em>Java2D</em> functionality available -to Rexx programmers. The commands are formed after the methods in the <code>java.awt.Graphics</code> -and <code>java.awt.Graphics2D</code> Java classes. The only difference are the <code>x</code> and -<code>y</code> co-ordinates which many methods have as their first two arguments: the Rexx programmer -defines these co-ordinates with the <code>GOTO x y</code> command and therefore are left out from +to Rexx programmers. The commands are formed after the methods in the <em>java.awt.Graphics</em> +and <em>java.awt.Graphics2D</em> Java classes. The only difference are the <em>x</em> and +<em>y</em> co-ordinates which many methods have as their first two arguments: the Rexx programmer +defines these co-ordinates with the <em>GOTO x y</em> command and therefore are left out from the arguments of the Rexx commands matching the Java method names. @@ -194,26 +194,28 @@ <dl> <dt>AffineTransform</dt> - <dd>The Java class <code>java.awt.geom.AffineTransform</code> allows to define and maintain + <dd>The Java class <em>java.awt.geom.AffineTransform</em> allows to define and maintain <em>rotate(...)</em>, <em>scale(...)</em>, <em>shear(...)</em>, <em>translate(...)</em> operations which all can be applied at once with the <em>java.awt.Graphics2D</em>'s <em>transform(anAffineTransform)</em> method. - One benefit is that <em>GC</em> is not permanently changed to these trnasformation + One benefit is that <em>GC</em> (graphic configuration, see below) is not permanently changed to these transformation values. <p>Currently there is no JDOR command to support this directly, however the same effect can - be achieved with the <em>pushGC</em> command, followed by any transforms - (<em>rotate(...)</em>, <em>scale(...)</em>, <em>shear(...)</em>, <em>translate(...)</em>) - and the <em>popGC</em> command which will reinstate the previous pushed <em>GC</em>. + be achieved with the <em><a href="#cmdPushGC">pushGC</a></em> command, followed by any transform + commands + (<em><a href="#cmdRotate">rotate(...)</a></em>, + <em><a href="#cmdScale">scale(...)</a></em>, + <em><a href="#cmdShear">shear(...)</a></em>, + <em><a href="#cmdTranslate">translate(...)</a></em>) + and the <em><a href="#cmdPopGC">popGC</a></em> command which will reinstate the previous pushed <em>GC</em>. + <p> - <p> - ... [truncated message content] |
From: <or...@us...> - 2022-10-16 17:03:52
|
Revision: 1008 http://sourceforge.net/p/bsf4oorexx/code/1008 Author: orexx Date: 2022-10-16 17:03:49 +0000 (Sun, 16 Oct 2022) Log Message: ----------- 20221026 Remove leftover debug statements. Modified Paths: -------------- branches/850/bsf4oorexx.dev/source_cc/BSF4ooRexx.cc Modified: branches/850/bsf4oorexx.dev/source_cc/BSF4ooRexx.cc =================================================================== --- branches/850/bsf4oorexx.dev/source_cc/BSF4ooRexx.cc 2022-10-16 16:05:45 UTC (rev 1007) +++ branches/850/bsf4oorexx.dev/source_cc/BSF4ooRexx.cc 2022-10-16 17:03:49 UTC (rev 1008) @@ -5724,16 +5724,10 @@ // create option for setting "java.class.path" to CLASSPATH char *resolvedCP=resolveCLASSPATH(cp_env); // resolve potential asterisk (*) wildcard paths (introduced with Java 1.6/6) -fprintf(stderr, "%s # %d: cp_env =[%s]\n\tresolvedCP=[%s]\n", - __FUNCTION__, __LINE__, cp_env, resolvedCP); - size_t bufLen=strlen(resolvedCP)+needleLength+2; options[m].optionString = (char *) malloc(bufLen+1); // get needed memory -// snprintf( options[m].optionString, bufLen+1, "%s%s", needle, cp_env); snprintf( options[m].optionString, bufLen+1, "%s%s", needle, resolvedCP); -fprintf(stderr, "%s # %d: m=[%d] options[%d].optionString=[%s]\n", __FUNCTION__, __LINE__, m, m, options[m].optionString); - free(resolvedCP); // options[m].extraInfo=NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <or...@us...> - 2022-10-16 16:05:53
|
Revision: 1007 http://sourceforge.net/p/bsf4oorexx/code/1007 Author: orexx Date: 2022-10-16 16:05:45 +0000 (Sun, 16 Oct 2022) Log Message: ----------- 20221016 Apply new CLASSPATH processing to a potential -Djava.class.path argument supplied to BsfLoadJava(...). Modified Paths: -------------- branches/850/bsf4oorexx.dev/source_cc/BSF4ooRexx.cc Modified: branches/850/bsf4oorexx.dev/source_cc/BSF4ooRexx.cc =================================================================== --- branches/850/bsf4oorexx.dev/source_cc/BSF4ooRexx.cc 2022-10-16 15:46:47 UTC (rev 1006) +++ branches/850/bsf4oorexx.dev/source_cc/BSF4ooRexx.cc 2022-10-16 16:05:45 UTC (rev 1007) @@ -5678,8 +5678,10 @@ // turn supplied argument to CString for comparison with needle value CSTRING cTmpStrObj=context->CString(tmpStrObject); // turn to ASCII-Z string - // determine whether java.class.path is supplied via this Rexx argument, setting/overriding CLASSPATH - bCPdefined= (bCPdefined || (strncmp(cTmpStrObj, needle, needleLength)==0)); + // 2022-10-16: determine whether java.class.path is supplied via this Rexx argument, setting/overriding CLASSPATH + bool tmpBCPdefined = (strncmp(cTmpStrObj, needle, needleLength)==0); + // bCPdefined= (bCPdefined || (strncmp(cTmpStrObj, needle, needleLength)==0)); + bCPdefined= (bCPdefined || tmpBCPdefined); #if defined( UNIX ) // java.library.path bJLPdefined= (bJLPdefined || (strncmp(cTmpStrObj, jvlpNeedle, jvlpNeedleLength)==0)); @@ -5686,11 +5688,31 @@ #endif // create and save supplied option - size_t tmpLength=strlen(cTmpStrObj)+2; - char *ch = (char *) malloc(tmpLength+1); // copy Rexx argument - memset(ch, 0, tmpLength+1); // make sure that initialized to 0x00 + char *ch; - strncpy(ch, cTmpStrObj, tmpLength); + if (tmpBCPdefined) // if current argument is the classpath argument, make sure we resolve any asterisk wildcard + { + // 2022-10-16: resolve potential asterisk (*) wildcard paths (introduced with Java 1.6/6) + char *resolvedCP=resolveCLASSPATH((char *)cTmpStrObj); + size_t tmpLength=strlen(resolvedCP)+2; + ch = (char *) malloc(tmpLength+1); // copy Rexx argument + memset(ch, 0, tmpLength+1); // make sure that initialized to 0x00 + strncpy(ch, resolvedCP, tmpLength); + free (resolvedCP); + } + else // any other argument + { + size_t tmpLength=strlen(cTmpStrObj)+2; + ch = (char *) malloc(tmpLength+1); // copy Rexx argument + memset(ch, 0, tmpLength+1); // make sure that initialized to 0x00 + strncpy(ch, cTmpStrObj, tmpLength); + } + + // size_t tmpLength=strlen(cTmpStrObj)+2; + // char *ch = (char *) malloc(tmpLength+1); // copy Rexx argument + // memset(ch, 0, tmpLength+1); // make sure that initialized to 0x00 + // strncpy(ch, cTmpStrObj, tmpLength); + options[m].optionString = ch; // options[m].extraInfo = NULL; // Florian's Schuld! :) (2004-05-06) m++; // increase counter to reflect number of available options This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <or...@us...> - 2022-10-16 15:46:49
|
Revision: 1006 http://sourceforge.net/p/bsf4oorexx/code/1006 Author: orexx Date: 2022-10-16 15:46:47 +0000 (Sun, 16 Oct 2022) Log Message: ----------- 20221016 We need to resolve wildcard asterisk (*) in CLASSPATH if loading Java from Rexx. Modified Paths: -------------- branches/850/bsf4oorexx.dev/source_cc/BSF4ooRexx.cc Modified: branches/850/bsf4oorexx.dev/source_cc/BSF4ooRexx.cc =================================================================== --- branches/850/bsf4oorexx.dev/source_cc/BSF4ooRexx.cc 2022-10-05 13:40:31 UTC (rev 1005) +++ branches/850/bsf4oorexx.dev/source_cc/BSF4ooRexx.cc 2022-10-16 15:46:47 UTC (rev 1006) @@ -36,7 +36,12 @@ inline jint impl_jniRexxHaltInterpreterInstance (JNIEnv *env, jobject jobj, jstring j_rii_ID) + 2022-10-16, rgf: - resolve asterisk (*) wildcard character in CLASSPATH/java.class.path, + needed if Java gets loaded by Rexx as the JVM does not resolve it + (the Java launchers resolve the asterisk wildcard since Java 1.6/6 + with ".jar" and ".JAR" files in the denoted subdirectory) + 2022-09-20, rgf: - BsfCommandHandler(): make "List" argument optional 2022-09-02, rgf: - added stemName string argument to ... _jniCreateCollectionObject() 2022-09-01, rgf: - added ... _jniCreateCollectionObject() to create and return: @@ -1046,6 +1051,7 @@ #ifdef UNIX #include <dlfcn.h> // use the dynamic link (dl*) functions + #include <dirent.h> // 2022-10-16, rgf: needed for resolving CLASSPATH wildcards // under Linux and MacOSX not defined, ---rgf, 2003-04-05, 2017-08-18 #ifndef FALSE @@ -1101,21 +1107,21 @@ #if defined (BSF4REXX_32_BIT) #if defined (BSF4REXX_DEBUG_VERSION) - #define BSF_VERSION "850.20220920 org/rexxla/bsf/engines/rexx_DEBUG 32-bit" // version: "MajorNumber"."YYYYMMDD" + #define BSF_VERSION "850.20221016 org/rexxla/bsf/engines/rexx_DEBUG 32-bit" // version: "MajorNumber"."YYYYMMDD" #else - #define BSF_VERSION "850.20220920 org/rexxla/bsf/engines/rexx 32-bit" // version: "MajorNumber"."YYYYMMDD" + #define BSF_VERSION "850.20221016 org/rexxla/bsf/engines/rexx 32-bit" // version: "MajorNumber"."YYYYMMDD" #endif #elif defined (BSF4REXX_64_BIT) #if defined (BSF4REXX_DEBUG_VERSION) - #define BSF_VERSION "850.20220920 org/rexxla/bsf/engines/rexx_DEBUG 64-bit" // version: "MajorNumber"."YYYYMMDD" + #define BSF_VERSION "850.20221016 org/rexxla/bsf/engines/rexx_DEBUG 64-bit" // version: "MajorNumber"."YYYYMMDD" #else - #define BSF_VERSION "850.20220920 org/rexxla/bsf/engines/rexx 64-bit" // version: "MajorNumber"."YYYYMMDD" + #define BSF_VERSION "850.20221016 org/rexxla/bsf/engines/rexx 64-bit" // version: "MajorNumber"."YYYYMMDD" #endif #else #if defined (BSF4REXX_DEBUG_VERSION) - #define BSF_VERSION "850.20220920 org/rexxla/bsf/engines/rexx_DEBUG n/a-bit" // version: "MajorNumber"."YYYYMMDD" + #define BSF_VERSION "850.20221016 org/rexxla/bsf/engines/rexx_DEBUG n/a-bit" // version: "MajorNumber"."YYYYMMDD" #else - #define BSF_VERSION "850.20220920 org/rexxla/bsf/engines/rexx n/a-bit" // version: "MajorNumber"."YYYYMMDD" + #define BSF_VERSION "850.20221016 org/rexxla/bsf/engines/rexx n/a-bit" // version: "MajorNumber"."YYYYMMDD" #endif #endif @@ -5121,6 +5127,222 @@ "-D<name>=<value>", "-verbose[:{class|gc|jni|X-non-standard-name}[,...]] */ + /* 2022-10-16, ---rgf: now that BSF4ooRexx allows for using the asterisk + wildcard character in CLASSPATH, we need to resolve it in case Rexx + loads Java; + */ + +#ifdef WINDOWS + // dir has a trailing "*", e.g. "c:\some\*" + /** Query a directory for "jar" files. + * @param dir a directory path with a trailing asterisk (*) + * @param tgtBuffer buffer to put found jar files + * @param offset offset in tgtBuffer to copy data to + * @return current offset + */ + static size_t resolveAsteriskJarFiles(char *dir, char *tgtBuffer, size_t offset) + { + WIN32_FIND_DATA data; + + // remove trailing asterisk (*) + size_t pureDirLength = strlen(dir)-1; + char *pureDir = (char *) malloc(pureDirLength+2); + memcpy(pureDir, dir, pureDirLength); + pureDir[pureDirLength]=0; + + // char *queryBuffer = (char *) malloc(MAX_PATH+2); + char *queryBuffer = (char *) malloc(MAX_PATH+2); + memset(queryBuffer,0,MAX_PATH+2); + + // strncpy(buffer, dir, strlen(dir)); + strcat(queryBuffer, dir); + strcat(queryBuffer, ".jar"); // add ".jar" to asterisk: will find any spelling of ".jar" on Windows + + HANDLE hFind = FindFirstFile((char *) queryBuffer, &data); // query directory + + if ( hFind != INVALID_HANDLE_VALUE ) { + do { + if (offset!=0 && tgtBuffer[offset-1]!=';') // append semi-colon (path separator) ? + { + strcat(tgtBuffer,";"); // append path separator + offset++; + } + strncpy(tgtBuffer+offset, pureDir, pureDirLength); // add path + offset+=pureDirLength; // update offset + size_t fnLength=strlen(data.cFileName); // add filename + strncpy(tgtBuffer+offset, data.cFileName, fnLength);// update offset + offset+=fnLength; + } while (FindNextFile(hFind, &data)); + FindClose(hFind); + } + + free(pureDir); + free(queryBuffer); + return offset; + } + + /** Processes received classpath and resolves asterisk (*) wildcard paths. + * @param classpath the CLASSPATH string to process + * @return a buffer with the resolved CLASSPATH string, must be freed by receiver + */ + char * resolveCLASSPATH(char *classpath) + { + // 2022-10-15, rgf: cf. <https://devblogs.microsoft.com/oldnewthing/20100203-00/?p=15083> + // Windows: CMD -> 8 K command line limit / env registry -> 2 K limit + // total env block -> 32 K limit + int TMP_MAX_ENV_LENGTH = 8192; // 8 KB, should suffice on all systems for Java startup/classpath string + char * tgtBuffer = (char*) malloc(TMP_MAX_ENV_LENGTH+1); // must be freed by caller + size_t offset=0; + memset(tgtBuffer, 0, TMP_MAX_ENV_LENGTH); + + size_t cpLength= strlen(classpath); + size_t begin=0; + size_t end=0; + for (size_t i=0; i<cpLength; i++) + { + if ( classpath[i] == '*' || + classpath[i] == ';' || + classpath[i]==0 || + ( (i+1)==cpLength ) // fallback (to match Unix version) + ) + { + end=i; + size_t dirLength=end-begin+1; + char *dir =(char *) malloc(dirLength+1); + memset(dir, 0, dirLength+1); + strncpy(dir, classpath+begin, dirLength); + + if (classpath[i]=='*') + { + offset = resolveAsteriskJarFiles( dir, tgtBuffer, offset); + i++; // skip over '*' + tgtBuffer[offset]=classpath[i]; + } + else // copy entire path + { + strncpy(tgtBuffer+offset, dir, dirLength); + offset+=dirLength; + } + begin=end+1; // next begin + end=begin; + } + } + return tgtBuffer; + } + + +#else // Unix (tested on Linux and Darwin) + // dir has a trailing "*", e.g. "c:\some\*" + /** Query a directory for "jar" files. + * @param dir a directory path with a trailing asterisk (*) + * @param tgtBuffer buffer to put found jar files + * @param offset offset in tgtBuffer to copy data to + * @return current offset + */ + static int resolveAsteriskJarFiles(char *dir, char *tgtBuffer, int offset) + { + // remove trailing asterisk (*) + int pureDirLength = strlen(dir)-1; + char *pureDir = (char *) malloc(pureDirLength+2); // without asterisk (*) + memcpy(pureDir, dir, pureDirLength); + pureDir[pureDirLength]=0; + + DIR *xdi; + struct dirent *xdir; + xdi = opendir(pureDir); // specify the directory name + if (xdi) + { + while ((xdir = readdir(xdi)) != NULL) + { + char *fn = xdir->d_name; + if (xdir->d_type != DT_REG && xdir->d_type != DT_LNK) + { + continue; + } + + int fnLength=strlen(fn); + int lastDot=-1; + for (int i=0;i<fnLength; i++) // find position of last dot + { + if (*(fn+i)=='.') + { + lastDot=i; + } + } + + // no valid extension found? (".jar" or ".JAR") + if ( lastDot==-1 || ((lastDot+4)!=fnLength) || + ( (strcmp(fn+lastDot+1,"jar")!=0) && (strcmp(fn+lastDot+1,"JAR")!=0)) ) + { + continue; + } + + // found a valid jar/JAR file entry + if (offset!=0 && tgtBuffer[offset-1]!=':') // append semi-colon (path separator) ? + { + strcat(tgtBuffer,":"); // append path separator + offset++; + } + strncpy(tgtBuffer+offset, pureDir, pureDirLength); // add path + offset+=pureDirLength; // update offset + strncpy(tgtBuffer+offset, fn, fnLength);// update offset + offset+=fnLength; + } + closedir(xdi); + } + free (pureDir); + return offset; + } + + + char * resolveCLASSPATH(char *classpath) + { + // 2022-10-15, rgf: cf. <https://devblogs.microsoft.com/oldnewthing/20100203-00/?p=15083> + // Windows: CMD -> 8 K command line limit / env registry -> 2 K limit + // total env block -> 32 K limit + // Unix: could be larger, but a classpath of 8 KB should be enough for the foreseeable future + int TMP_MAX_ENV_LENGTH = 8192; // 8 KB, should suffice on all systems for Java startup/classpath string + char * tgtBuffer = (char*) malloc(TMP_MAX_ENV_LENGTH+1); // must be freed by caller + int offset=0; + memset(tgtBuffer, 0, TMP_MAX_ENV_LENGTH); + + int cpLength= strlen(classpath); + int begin=0, end=-1; + for (int i=0; i<cpLength; i++) + { + if ( classpath[i] == '*' || + classpath[i] == ':' || + classpath[i] == 0 || + ( (i+1)==cpLength ) // fallback + ) + { + end=i; + int dirLength=end-begin+1; + char *dir =(char *) malloc(dirLength+1); + memset(dir, 0, dirLength+1); + strncpy(dir, classpath+begin, dirLength); + + if (classpath[i]=='*') + { + offset = resolveAsteriskJarFiles(dir, tgtBuffer, offset); + i++; // skip over '*' + tgtBuffer[offset]=classpath[i]; + } + else // copy entire path + { + strncpy(tgtBuffer+offset, dir, dirLength); + offset+=dirLength; + } + begin=end+1; // next begin + end=begin; + } + } + return tgtBuffer; + } + + +#endif + /*********************************************************************/ /* load Java */ /* */ @@ -5478,10 +5700,20 @@ (cp_env!= NULL)) // CLASSPATH environment variable set { // create option for setting "java.class.path" to CLASSPATH - size_t bufLen=strlen(cp_env)+needleLength+2; + char *resolvedCP=resolveCLASSPATH(cp_env); // resolve potential asterisk (*) wildcard paths (introduced with Java 1.6/6) + +fprintf(stderr, "%s # %d: cp_env =[%s]\n\tresolvedCP=[%s]\n", + __FUNCTION__, __LINE__, cp_env, resolvedCP); + + size_t bufLen=strlen(resolvedCP)+needleLength+2; + options[m].optionString = (char *) malloc(bufLen+1); // get needed memory - snprintf( options[m].optionString, bufLen+1, "%s%s", needle, cp_env); +// snprintf( options[m].optionString, bufLen+1, "%s%s", needle, cp_env); + snprintf( options[m].optionString, bufLen+1, "%s%s", needle, resolvedCP); +fprintf(stderr, "%s # %d: m=[%d] options[%d].optionString=[%s]\n", __FUNCTION__, __LINE__, m, m, options[m].optionString); + free(resolvedCP); // + options[m].extraInfo=NULL; m++; // increase counter to reflect number of available options } @@ -5489,7 +5721,7 @@ #if defined( UNIX ) // java.library.path if ( bJLPdefined==FALSE ) // "java.library.path" not given in Rexx arguments { - // create option for setting "java.class.path" to CLASSPATH + // create option for setting "java.library.path" to typical library paths on Unix char strJLP[] = "/opt/BSF4ooRexx850:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64:."; size_t bufLen=strlen(strJLP)+needleLength+2; options[m].optionString = (char *) malloc(bufLen+1); // get needed memory This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <or...@us...> - 2022-10-03 15:24:17
|
Revision: 1003 http://sourceforge.net/p/bsf4oorexx/code/1003 Author: orexx Date: 2022-10-03 15:24:06 +0000 (Mon, 03 Oct 2022) Log Message: ----------- Use install location for class name; add footer to font family samples. Modified Paths: -------------- branches/850/samples/2-110_JDOR_listShowPrintFonts.rxj branches/850/samples/jdor.cls Modified: branches/850/samples/2-110_JDOR_listShowPrintFonts.rxj =================================================================== --- branches/850/samples/2-110_JDOR_listShowPrintFonts.rxj 2022-10-03 15:23:10 UTC (rev 1002) +++ branches/850/samples/2-110_JDOR_listShowPrintFonts.rxj 2022-10-03 15:24:06 UTC (rev 1003) @@ -63,7 +63,7 @@ -- there are 72 pixels per inch height = trunc(12.5*72+10) -- plus additional 10 px margin lineHeight=15 -- line height (includes padding) -lines = trunc(height/lineHeight) -- calc number of lines +lines = trunc(height/lineHeight) - 2 -- calc number of lines per page (allow for footer) xCol1 = 10 -- first column at 10px (margin) xCol2 = xCol1+250 -- second column 250px to the right of first column fileName="2-110_JDOR_FontSample_" -- base name for @@ -81,8 +81,12 @@ currLine=1 -- reset currLine if i>1 then do + tmpFileName = fileName || pageNr"."fileType -- define file name + y=(lines+2)*lineHeight -- calc footer position + fontSize 10; font dialog "Dialog" -- set font and font size + goto xCol1 y; drawString "page" pageNr "(".dateTime~new")" -- write footer part 1 + goto xCol2 y; drawString tmpFileName -- write footer part 2 -- winUpdate .true-- update Frame (JDOR command) - tmpFileName = fileName || (pageNr+1)"."fileType say "saving sample to:" pp(tmpFileName) "saveImage" tmpFileName -- write current image (JDOR command) if bPrint then @@ -114,8 +118,12 @@ end if i>1 then do - tmpFileName = fileName || (pageNr+1)"."fileType - say "saving sample to:" pp(tmpFileName) + tmpFileName = fileName || pageNr"."fileType -- define file name + y=(lines+2)*lineHeight -- calc footer position + fontSize 10; font dialog "Dialog" -- set font and font size + goto xCol1 y; drawString "page" pageNr "(".dateTime~new")" -- write footer part 1 + goto xCol2 y; drawString tmpFileName -- write footer part 2 + say "saving sample to:" pp(tmpFileName) -- show user file name "saveImage" tmpFileName -- (JDOR command) -- winUpdate .true -- allow update of Frame again, show current image (JDOR command) if bPrint then Modified: branches/850/samples/jdor.cls =================================================================== --- branches/850/samples/jdor.cls 2022-10-03 15:23:10 UTC (rev 1002) +++ branches/850/samples/jdor.cls 2022-10-03 15:24:06 UTC (rev 1003) @@ -37,15 +37,6 @@ ::routine addJdorHandler public use strict arg environmentName="JDOR" - call BsfCommandHandler "add", environmentName, getJDH() + call BsfCommandHandler "add", environmentName, .bsf~new("org.oorexx.handlers.jdor.JavaDrawingHandler") ::requires "BSF.CLS" -- get ooRexx-Java bridge - -::routine getJDH -- tries to load (planned) fully qualified name, fallback: unqualified - signal on syntax name s1 - return .bsf~new("org.oorexx.rexxla.handlers.jdor.JavaDrawingHandler") -s1: - signal on syntax name s2 - return .bsf~new("JavaDrawingHandler") -s2: - return .nil -- indicate that we were not able to create an instance of JDH This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <or...@us...> - 2022-10-03 15:23:12
|
Revision: 1002 http://sourceforge.net/p/bsf4oorexx/code/1002 Author: orexx Date: 2022-10-03 15:23:10 +0000 (Mon, 03 Oct 2022) Log Message: ----------- Use install location for class name; add footer to font family samples. Modified Paths: -------------- sandbox/rgf/jdor/samples/2-110_JDOR_listShowPrintFonts.rxj sandbox/rgf/jdor/samples/jdor.cls Modified: sandbox/rgf/jdor/samples/2-110_JDOR_listShowPrintFonts.rxj =================================================================== --- sandbox/rgf/jdor/samples/2-110_JDOR_listShowPrintFonts.rxj 2022-10-03 14:12:42 UTC (rev 1001) +++ sandbox/rgf/jdor/samples/2-110_JDOR_listShowPrintFonts.rxj 2022-10-03 15:23:10 UTC (rev 1002) @@ -63,7 +63,7 @@ -- there are 72 pixels per inch height = trunc(12.5*72+10) -- plus additional 10 px margin lineHeight=15 -- line height (includes padding) -lines = trunc(height/lineHeight) -- calc number of lines +lines = trunc(height/lineHeight) - 2 -- calc number of lines per page (allow for footer) xCol1 = 10 -- first column at 10px (margin) xCol2 = xCol1+250 -- second column 250px to the right of first column fileName="2-110_JDOR_FontSample_" -- base name for @@ -81,8 +81,12 @@ currLine=1 -- reset currLine if i>1 then do + tmpFileName = fileName || pageNr"."fileType -- define file name + y=(lines+2)*lineHeight -- calc footer position + fontSize 10; font dialog "Dialog" -- set font and font size + goto xCol1 y; drawString "page" pageNr "(".dateTime~new")" -- write footer part 1 + goto xCol2 y; drawString tmpFileName -- write footer part 2 -- winUpdate .true-- update Frame (JDOR command) - tmpFileName = fileName || (pageNr+1)"."fileType say "saving sample to:" pp(tmpFileName) "saveImage" tmpFileName -- write current image (JDOR command) if bPrint then @@ -114,8 +118,12 @@ end if i>1 then do - tmpFileName = fileName || (pageNr+1)"."fileType - say "saving sample to:" pp(tmpFileName) + tmpFileName = fileName || pageNr"."fileType -- define file name + y=(lines+2)*lineHeight -- calc footer position + fontSize 10; font dialog "Dialog" -- set font and font size + goto xCol1 y; drawString "page" pageNr "(".dateTime~new")" -- write footer part 1 + goto xCol2 y; drawString tmpFileName -- write footer part 2 + say "saving sample to:" pp(tmpFileName) -- show user file name "saveImage" tmpFileName -- (JDOR command) -- winUpdate .true -- allow update of Frame again, show current image (JDOR command) if bPrint then Modified: sandbox/rgf/jdor/samples/jdor.cls =================================================================== --- sandbox/rgf/jdor/samples/jdor.cls 2022-10-03 14:12:42 UTC (rev 1001) +++ sandbox/rgf/jdor/samples/jdor.cls 2022-10-03 15:23:10 UTC (rev 1002) @@ -37,15 +37,6 @@ ::routine addJdorHandler public use strict arg environmentName="JDOR" - call BsfCommandHandler "add", environmentName, getJDH() + call BsfCommandHandler "add", environmentName, .bsf~new("org.oorexx.handlers.jdor.JavaDrawingHandler") ::requires "BSF.CLS" -- get ooRexx-Java bridge - -::routine getJDH -- tries to load (planned) fully qualified name, fallback: unqualified - signal on syntax name s1 - return .bsf~new("org.oorexx.handlers.jdor.JavaDrawingHandler") -s1: - signal on syntax name s2 - return .bsf~new("JavaDrawingHandler") -s2: - return .nil -- indicate that we were not able to create an instance of JDH This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <or...@us...> - 2022-10-03 14:12:47
|
Revision: 1001 http://sourceforge.net/p/bsf4oorexx/code/1001 Author: orexx Date: 2022-10-03 14:12:42 +0000 (Mon, 03 Oct 2022) Log Message: ----------- 20221003 Add JavaDrawingHandler (JDOR). Modified Paths: -------------- branches/850/bsf4oorexx.dev/bin/BSF.CLS branches/850/bsf4oorexx.dev/cmpj.cmd Added Paths: ----------- branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java Modified: branches/850/bsf4oorexx.dev/bin/BSF.CLS =================================================================== --- branches/850/bsf4oorexx.dev/bin/BSF.CLS 2022-10-03 13:28:16 UTC (rev 1000) +++ branches/850/bsf4oorexx.dev/bin/BSF.CLS 2022-10-03 14:12:42 UTC (rev 1001) @@ -922,7 +922,7 @@ if initialize.bsf.dir() then -- setup .bsfrexx do - .bsf4rexx~version="850.20220929" -- set version (date distribution got created) + .bsf4rexx~version="850.20221003" -- set version (date distribution got created) .bsf4rexx~opSys =opsys -- save operating system name as supplied by Rexx' PARSE SOURCE .bsf4rexx~opSys1 =opsys~left(1)~upper -- save operating system name's initial letter in uppercase .bsf4rexx~opSys2 =opsys~left(2)~upper -- save operating system name's first two letters in uppercase Modified: branches/850/bsf4oorexx.dev/cmpj.cmd =================================================================== --- branches/850/bsf4oorexx.dev/cmpj.cmd 2022-10-03 13:28:16 UTC (rev 1000) +++ branches/850/bsf4oorexx.dev/cmpj.cmd 2022-10-03 14:12:42 UTC (rev 1001) @@ -30,6 +30,8 @@ set path2rexxlaBsf=%path2root%\org\rexxla\bsf +set path2jdor=%path2root%\org\oorexx\handlers\jdor + rem rgf, 20140927: make sure that the extension jar is not picked up (if bsf4oorexx-jar got installed there) set javacDefines=-Djava.ext.dirs="" set target=-target 8 @@ -165,5 +167,15 @@ @rem 2022-04-21: needs Java 1.8 due to using Arrays.stream() javac %javacDefines% %javaBaseLine% %javaSrc%\RexxAnalyzeRegistry.java && copy %javaSrc%\RexxAnalyzeRegistry* %path2engine% + +@rem 2022-10-03: adding JDOR command handler +@rem directory where "org" resides: %path2root% +@rem directory where the class files get placed to: %path2jdor% +javac %javacDefines% %javaBaseLine% %javaSrc%\JavaDrawingHandler.java +javac %javacDefines% %javaBaseLine% -d %path2root% %javaSrc%\JavaDrawingHandler.java +copy %javaSrc%\JavaDrawingHandler.java %path2jdor% + + + endlocal Added: branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java =================================================================== --- branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java (rev 0) +++ branches/850/bsf4oorexx.dev/source_java/JavaDrawingHandler.java 2022-10-03 14:12:42 UTC (rev 1001) @@ -0,0 +1,3268 @@ +// cf. <https://zetcode.com/gfx/java2d/basicdrawing/> +// TODO: B4R -> resolving constructors, if class is not public +// TODO: define a package (e.g. org.oorexx.handler.jdor ?) +// TODO: pushGC: also save GC related current values? + +/* Java classes that constitute the JDOR ("JavaDrawing ooRexx") command handler. + + This enables any programmer to easily create and manipulate bitmaps on any + operating system (Windows, MacOS, Linux) where Java, ooRexx and BSF4ooRexx is + available. + + author: Rony G. Flatscher + date: 2022-09-05/2022-10-03 + license: Apache license 2.0 + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- + +*/ + +/* Sample program in ooRexx (temporarily): + + -- load and add the Java Rexx command handler, using default name: JDOR + call addJdorHandler + address jdor -- change default address environment + + signal on failure name any + signal on error name any + + new 500 500 -- create a new bitmap + winShow -- show it in a frame + + goto 10 10 + color orange + drawString "Hello at:" .dateTime~new + translate 10 490 + color green + drawString "Hello at:" .dateTime~new + translate 490 10 + color red + drawString "Hello at:" .dateTime~new + "translate -250 -250" -- must be quoted (minus causes Rexx to try arithmetics) + color blue + drawString "Hello at:" .dateTime~new + color red + angle=30 + do i=1 to 360/angle - 1 + rotate angle + drawString "ooRexx at:" .dateTime~new + end + + save "testTranslate.png" -- save as png file + sleep 2500 -- halts execution for 2 1/2 seconds + exit + + any: -- if command raise failure or error conditions, show them + co=condition('o') -- get a directory with the condition infos + say ppCondition2(co) -- format and show the condition information + say "---" + raise propagate -- now let ooRexx handle this condition + + ::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available + ::requires "rgf_util2.rex" -- get access to ppCondition2() + +*/ + +package org.oorexx.handlers.jdor; + + +import java.awt.EventQueue; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Toolkit; +import javax.swing.JFrame; +import javax.swing.JPanel; + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Font; +import java.awt.Dimension; +import java.awt.GradientPaint; +import java.awt.Paint; +import java.awt.Rectangle; +import java.awt.Stroke; +import java.awt.BasicStroke; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.swing.SwingUtilities; + +import java.awt.image.BufferedImage; +import java.io.File; +import javax.imageio.ImageIO; // for loading/saving + +import org.apache.bsf.BSFException; +import org.rexxla.bsf.engines.rexx.*; + +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; + +// for printing support +import java.awt.print.PageFormat; +import java.awt.print.Printable; + +import javax.print.DocFlavor; +import javax.print.DocPrintJob; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.SimpleDoc; + +// ============================================================================ +/** Class to allow displaying the current image. +*/ +class JavaDrawingFrame extends JFrame +{ + /* static definitions */ + static final private int prefWidth = 500; + static final private int prefHeight = 500; + + /* instance definitions */ + boolean bDebug= false; // true + Surface sf = null; + + int currWidth = prefWidth; + int currHeight = prefHeight; + boolean currFrameVisible = true; // cf. command "winFrame [.true|.false]" + + BufferedImage bufImage = null; + + + /** Constructor. + * @param img the BufferedImage to display + */ + public JavaDrawingFrame(BufferedImage img) + { + bufImage=img; + initUI(); + } + + /** Set up the UI using predefeined width and height for content pane. */ + private void initUI() + { + sf=new Surface(); + add(sf); + setTitle("JavaDrawingFrame"); + // needs to be followed by pack() to take effect immediately + getContentPane().setPreferredSize(new Dimension(bufImage.getWidth(),bufImage.getHeight())); + pack(); + + setLocationRelativeTo(null); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + } + + /** Resizes frame. + * @param width the width in pixel + * @param height the width in pixel + */ + public void resizeSurface (int width, int height) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + doResize(width, height); + } + }); + } + + /** Resizes frame (worker method, run on the GUI thread). + * @param width the width in pixel + * @param height the width in pixel + */ + void doResize (int width, int height) + { + getContentPane().setPreferredSize(new Dimension(width, height)); + pack(); + } + + // ============================================================================ + /** Surface to draw to. */ + class Surface extends JPanel + { + @Override + public void paintComponent(Graphics g) + { + super.paintComponent(g); + g.drawImage(bufImage,0,0,null); + } + } +} + + + +// ============================================================================ +public class JavaDrawingHandler implements RexxRedirectingCommandHandler +{ + /* static definitions */ + + // default image sizes + static final public String version = "001.20221002"; + static final private int prefWidth = 500; + static final private int prefHeight = 500; + static private int prefImageType = BufferedImage.TYPE_INT_ARGB; // default with alpha (only png supported) + + // a Rexx variable symbol may start with one of the following characters + static final String startRexxVariableChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_!?"; + + static final HashMap<String,Color> predefinedColors = new HashMap<>(); + // BufferedImage + static final HashMap<String,Integer> imageTypes = new HashMap<>(); + static final HashMap<Integer,String> imageTypesInt2Name = new HashMap<>(); + // BasicStroke + static final HashMap<String,Integer> endCaps = new HashMap<>(); + static final HashMap<Integer,String> endCapsInt2Name = new HashMap<>(); + static final HashMap<String,Integer> lineJoins = new HashMap<>(); + static final HashMap<Integer,String> lineJoinsInt2Name = new HashMap<>(); + // AlphaComposite + static final HashMap<String,Integer> alphaComposites = new HashMap<>(); + static final HashMap<Integer,String> alphaCompositesInt2Name = new HashMap<>(); + + static { + // ---------------------------------------------------------------------- + // Color + predefinedColors.put("BLACK" , Color.BLACK ); + predefinedColors.put("BLUE" , Color.BLUE ); + predefinedColors.put("CYAN" , Color.CYAN ); + predefinedColors.put("DARK_GRAY" , Color.DARK_GRAY ); + predefinedColors.put("GRAY" , Color.GRAY ); + predefinedColors.put("GREEN" , Color.GREEN ); + predefinedColors.put("LIGHT_GRAY" , Color.LIGHT_GRAY ); + predefinedColors.put("MAGENTA" , Color.MAGENTA ); + predefinedColors.put("ORANGE" , Color.ORANGE ); + predefinedColors.put("PINK" , Color.PINK ); + predefinedColors.put("RED" , Color.RED ); + predefinedColors.put("WHITE" , Color.WHITE ); + predefinedColors.put("YELLOW" , Color.YELLOW ); + + // ---------------------------------------------------------------------- + // BufferedImage + imageTypes.put("TYPE_CUSTOM" , BufferedImage.TYPE_CUSTOM ); // 0 + imageTypes.put("TYPE_INT_RGB" , BufferedImage.TYPE_INT_RGB ); // 1 + imageTypes.put("TYPE_INT_ARGB" , BufferedImage.TYPE_INT_ARGB ); // 2 + imageTypes.put("TYPE_INT_ARGB_PRE" , BufferedImage.TYPE_INT_ARGB_PRE ); // 3 + imageTypes.put("TYPE_INT_BGR" , BufferedImage.TYPE_INT_BGR ); // 4 + imageTypes.put("TYPE_3BYTE_BGR" , BufferedImage.TYPE_3BYTE_BGR ); // 5 + imageTypes.put("TYPE_4BYTE_ABGR" , BufferedImage.TYPE_4BYTE_ABGR ); // 6 + imageTypes.put("TYPE_4BYTE_ABGR_PRE", BufferedImage.TYPE_4BYTE_ABGR_PRE ); // 7 + imageTypes.put("TYPE_USHORT_565_RGB", BufferedImage.TYPE_USHORT_565_RGB ); // 8 + imageTypes.put("TYPE_USHORT_555_RGB", BufferedImage.TYPE_USHORT_555_RGB ); // 9 + imageTypes.put("TYPE_BYTE_GRAY" , BufferedImage.TYPE_BYTE_GRAY ); //10 + imageTypes.put("TYPE_USHORT_GRAY" , BufferedImage.TYPE_USHORT_GRAY ); //11 + imageTypes.put("TYPE_BYTE_BINARY" , BufferedImage.TYPE_BYTE_BINARY ); //12 + imageTypes.put("TYPE_BYTE_INDEXED" , BufferedImage.TYPE_BYTE_INDEXED ); //13 + // allow for looking up constant names (key) by value + imageTypes.forEach((K,V)->imageTypesInt2Name.put(V,K)); + + // ---------------------------------------------------------------------- + // BasicStroke + endCaps.put("CAP_BUTT" , 0); + endCaps.put("CAP_ROUND" , 1); + endCaps.put("CAP_SQUARE", 2); + // allow for looking up constant names (key) by value + endCaps.forEach((K,V)->endCapsInt2Name.put(V,K)); + + lineJoins.put("JOIN_MITER", 0); + lineJoins.put("JOIN_ROUND", 1); + lineJoins.put("JOIN_BEVEL", 2); + // allow for looking up constant names (key) by value + lineJoins.forEach((K,V)->lineJoinsInt2Name.put(V,K)); + + // ---------------------------------------------------------------------- + // AlphaComposite + alphaComposites.put("CLEAR" , 1); + alphaComposites.put("DST" , 9); + alphaComposites.put("DST_ATOP", 11); + alphaComposites.put("DST_IN" , 6); + alphaComposites.put("DST_OUT" , 8); + alphaComposites.put("DST_OVER", 4); + alphaComposites.put("SRC" , 2); + alphaComposites.put("SRC_ATOP", 10); + alphaComposites.put("SRC_IN" , 5); + alphaComposites.put("SRC_OUT" , 7); + alphaComposites.put("SRC_OVER", 3); + alphaComposites.put("XOR" , 12); + // allow for looking up constant names (key) by value + alphaComposites.forEach((K,V)->alphaCompositesInt2Name.put(V,K)); + } + + + int nrCommand=0; // in case many commands, indicates which command may have caused an error or failure condition + + /* instance definitions */ + JavaDrawingFrame jd = null; // maintance a singleton or empty + boolean bDebug=false; // true; // false; // true + + // we draw here and do a drawImage in the Surface paint + BufferedImage bufImage = null; + // int currImageType = prefImageType; + Graphics2D bufGC = null; + + /* printer related values */ + boolean printScaleToPage = false; + int printPosX=0, printPosY=0; + double printScaleX=1, printScaleY=1; + + /* current values */ + int currX = 0; + int currY = 0; + double currAngle = 0; // if rotate gets used, keeps current angle (in radians) + + int currFontStyle = 0; // PLAIN by default + int currFontSize = 12; // by default + + boolean currVisible = false; + boolean currWinUpdate = true; // update Frame whenever we draw: allows turning updating on/off + + + /** Stack for graphic configurations. */ + ArrayDeque <Graphics2D>adGCStack = new ArrayDeque<>(); + + /** Stack for images. */ + ArrayDeque <BufferedImage>adImageStack = new ArrayDeque<>(); + + /** Maps for definable, loadable resources. Index is name in uppercase. */ + HashMap<String,BufferedImage> hmImages = new HashMap<>(); + /** Contains always the predefined colors (cf. Javadoc of java.awt.Color). */ + HashMap<String,Color> hmColors = new HashMap<>(predefinedColors ); + HashMap<String,GradientPaint> hmGradientPaints = new HashMap<>(); + HashMap<String,Font> hmFonts = new HashMap<>(); + HashMap<String,Stroke> hmStrokes= new HashMap<>(); + + + void reset () // reset all current variables and caches + { + currX = 0; + currY = 0; + currAngle = 0; + + currFontStyle = 0; // PLAIN by default + currFontSize = 12; + + printScaleToPage = false; + printPosX = 0; + printPosY = 0; + printScaleX = 1; + printScaleY = 1; + + // empty stack + Graphics2D tGC = null; + if (adGCStack.size()>0) + { + tGC = adGCStack.pop(); + } + while (tGC!=null) + { + tGC.dispose(); + adGCStack.pop(); + } + adImageStack.clear(); + hmImages.clear(); + hmColors=new HashMap<>(predefinedColors ); + hmGradientPaints = new HashMap<>(); + hmFonts.clear(); + hmStrokes.clear(); + if (jd!=null && bufImage!=null) + { +if (bDebug) System.err.println(" /// ---> resizeSurface(): w="+bufImage.getWidth()+", h="+bufImage.getHeight()); + jd.resizeSurface(bufImage.getWidth(), bufImage.getHeight()); // will use invokeLater() + } + } + + + /** Callback method of this command handler. + * + * @param slot opaque argument (needs to be used if invoking the Handler default methods to interact with the Rexx context) + * @param address the environment name this handler works for + * @param command the command to process + */ + public Object handleCommand(Object slot, String address, String command) + { + nrCommand++; // increase counter +if (bDebug) System.err.println("[JavaDrawingHandler].handleCommand(slot, address=["+address+"]" + + "command # ["+nrCommand+"]" + + "command=["+command+"]" + + ); + Object res=null; + if (isInputRedirected(slot)) // take commands via redirected input + { + String currCommand=null; + while ( (currCommand=readInput(slot)) != null) // feed commands from redirected input + { + res=processCommand(slot, address, command, nrCommand, currCommand); + if (checkCondition(slot)) // a Rexx condition got set: stop processing, return immediately + { + return null; + } + } + } + else // single command + { + res=processCommand(slot, address, command, nrCommand, null); + } + return res; + } + + +// TODO: currently currCommand is not processed, should be a comment; maybe needs to be revisited? + + /** Process single command + processCommand(slot, address, command, nrCommand, currCommand); + * @param slot opaque argument (needs to be used if invoking the Handler default methods to interact with the Rexx context) + * @param address the environment name this handler works for + * @param command the command to process + * @param nrCommand counter to number this command + * @param currCommand command that was received in redirected modus + */ + Object processCommand(Object slot, String address, String command, int nrCommand, String currCommand) + { + String [] arrCommand = null; + String mainCommand = command; // command via address environment + if (currCommand!=null) + { + command=currCommand; // command from redirected input + } + + boolean isOR = isOutputRedirected(slot); // is output redirected ? + + // get the boundaries of the first ten words + ArrayList<int[]> alWordBoundaries = getWordBoundaries (command, 15); + arrCommand = getNonBlankWords(command, alWordBoundaries); + + Command cmd = null; + if (arrCommand.length>0) // empty string + { + cmd=Command.getCommand(arrCommand[0]); // can be null, if not available + } + + if (cmd==null) // unknown command raise error condition + { + String commentChars = "-#;/\"'.:!?_"; // regarded as a comment if any used as first non-blank character + if (arrCommand.length==0 || arrCommand[0].length()==0 || (commentChars).indexOf(arrCommand[0].charAt(0))>=0) // treat as comment) + { + if (isOR) + { + writeOutput(slot, command); // write unchanged + } + return null; + } + String errMsg = "unknown command"; + if (isOR) + { + writeOutput(slot, "-- FAILURE (unknown command): ["+command+"]"); + } + return createCondition (slot, nrCommand, command, ConditionType.FAILURE, "-1", errMsg ); + } + + // no image as of yet, not the NEW command, hence create a default image + if (bufImage==null && !(cmd==Command.NEW)) + { + bufImage = new BufferedImage(prefWidth, prefHeight, prefImageType); + bufGC = (Graphics2D) bufImage.getGraphics(); + bufGC.setColor(Color.BLACK); + Font currFont = bufGC.getFont(); + currFontStyle = currFont.getStyle(); + currFontSize = currFont.getSize(); + } + + String canonical = cmd.mixedCase;; + + // process commands; jd may be null ! + try + { + switch (cmd) // process commands + { + // ---------------------- display, control related --- Start + case WIN_SHOW: // show frame + { + if (arrCommand.length!=1) + { + throw new IllegalArgumentException("this command does not accept any arguments, received "+(arrCommand.length-1)+" instead"); + } + if (isOR) + { + writeOutput(slot, canonical); + } + if (currVisible) // already visible, nothing to do + { + return "1"; + } + if (jd==null) // implies creation of JavaDrawingFrame and make it visible + { + jd = new JavaDrawingFrame(bufImage); + } + jd.setVisible(true); // make sure frame is visible + currVisible=true; + break; + } + + case WIN_HIDE: // hide frame + { + if (arrCommand.length!=1) + { + throw new IllegalArgumentException("this command does not accept any arguments, received "+(arrCommand.length-1)+" instead"); + } + if (isOR) + { + writeOutput(slot, canonical); + } + if (!currVisible || jd==null) // not visible already, nothing to do + { + return null; + } + jd.setVisible(false); + currVisible=false; + + break; + } + + case WIN_CLOSE: // close (exit) JFrame + { + if (arrCommand.length!=1) + { + throw new IllegalArgumentException("this command does not accept any arguments, received "+(arrCommand.length-1)+" instead"); + } + if (jd!=null) + { + jd.dispatchEvent(new WindowEvent(jd, WindowEvent.WINDOW_CLOSING)); + jd=null; + } + currVisible=false; + if (isOR) + { + writeOutput(slot, canonical); + } + } + break; + + case WIN_LOCATION: // synonym WINMOVETO "winLocation [x y]" get or set JFrame location on screen + { + if (arrCommand.length!=3) + { + throw new IllegalArgumentException("this command needs no or exactly 2 arguments, received "+(arrCommand.length-1)+" instead"); + } + if (jd==null) // implies creation of JavaDrawingFrame and make it visible + { + jd = new JavaDrawingFrame(bufImage); + jd.setVisible(true); // make sure frame is visible + currVisible=true; + } + + int newX = jd.getX(); + int newY = jd.getY(); + + if (arrCommand.length==3) + { + newX = Integer.parseInt(arrCommand[1]); + newY = Integer.parseInt(arrCommand[2]); + jd.setLocation(newX, newY); + canonical = canonical+" "+newX+" "+newY; + } + + if (isOR) + { + writeOutput(slot, canonical); // write canonical form + } + if (arrCommand.length==1) + { + return newX+" "+newY; + } + break; + } + + // new 2022-09-27 + case WIN_ALWAYS_ON_TOP: // "winAlwaysOnTop [.true | .false]" get or set of this window state + { + if (arrCommand.length>2) + { + throw new IllegalArgumentException("this command needs no or exactly 1 argument, received "+(arrCommand.length-1)+" instead"); + } + } + case WIN_TO_BACK: // "winToBack" put window into the back + case WIN_TO_FRONT: // "winToFront" put window into the front + case WIN_ALWAYS_ON_TOP_SUPPORTED: // "winAlwaysOnTopSupported" get value + { + if (cmd!=Command.WIN_ALWAYS_ON_TOP && arrCommand.length!=1) + { + throw new IllegalArgumentException("this command expects no arguments, received "+(arrCommand.length-1)+" instead"); + } + if (jd==null) // implies creation of JavaDrawingFrame and make it visible + { + jd = new JavaDrawingFrame(bufImage); + jd.setVisible(true); // make sure frame is visible + currVisible=true; + } + + boolean retBoolValue=true; + + switch (cmd) + { + case WIN_ALWAYS_ON_TOP: + { + if (arrCommand.length!=1) + { + String newValue = arrCommand[1]; + + if (checkBooleanValue(newValue)) // a valid BSF4ooRexx850 boolean value? + { + retBoolValue=getBooleanValue(newValue); // get value + } + else + { + throw new IllegalArgumentException("the supplied \"frameVisible\" argument \""+newValue+"\" is not a valid BSF4ooRexx850 boolean value, valid values (in any case) are: " + + "\"0\", \"1\", \"false\", \"true\", \".false\", \".true\""); + } + canonical=canonical+" "+newValue; + jd.setAlwaysOnTop(retBoolValue); // set value + } + else + { + retBoolValue=jd.isAlwaysOnTop(); + } + break; + } + + case WIN_TO_BACK: // "winToBack" put window into the back + jd.toBack(); + break; + + case WIN_TO_FRONT: // "winToFront" put window into the front + jd.toFront(); + break; + + case WIN_ALWAYS_ON_TOP_SUPPORTED: // "winAlwaysOnTopSupported" get value + retBoolValue=jd.isAlwaysOnTopSupported(); + break; + } + + if (isOR) + { + writeOutput(slot, canonical); // write canonical form + } + + return retBoolValue ? "1" : "0"; + } + + + case WIN_TITLE: // winTitle [newTitle]: query or set title + { + if (jd==null) // implies creation of JavaDrawingFrame and make it visible + { + jd = new JavaDrawingFrame(bufImage); + jd.setVisible(true); // make sure frame is visible + currVisible=true; + } + if (arrCommand.length==1) // return current setting (via RC) + { + if (isOR) + { + writeOutput(slot,canonical); + } + return jd.getTitle(); + } + + int [] pos = (int []) alWordBoundaries.get(1); // String + String newTitle = command.substring(pos[0]); // extract String (may contain blanks) + if (isOR) + { + writeOutput(slot,canonical+" "+newTitle); + } + // no exception, so args o.k. + jd.setTitle(newTitle); // will use invokeLater() + break; + } + + + case WIN_FRAME: // winFrame [.true|.false]: query or set whether frame is visible + { + if (jd==null) // implies creation of JavaDrawingFrame and make it visible + { + jd = new JavaDrawingFrame(bufImage); + jd.setVisible(true); // make sure frame is visible + currVisible = true; + } + + if (arrCommand.length==1) // return current setting (via RC) + { + if (isOR) + { + writeOutput(slot,canonical); + } + return (jd.currFrameVisible ? "1" : "0"); + } + + if (arrCommand.length!=2) + { + throw new IllegalArgumentException("this command needs exactly 2 arguments, received "+(arrCommand.length-1)+" instead"); + } + + String newValue = arrCommand[1]; + boolean newFrameVisible=false; + + if (checkBooleanValue(newValue)) // a valid BSF4ooRexx850 boolean value? + { + newFrameVisible=getBooleanValue(newValue); // get value + } + else + { + throw new IllegalArgumentException("the supplied \"frameVisible\" argument \""+newValue+"\" is not a valid BSF4ooRexx850 boolean value, valid values (in any case) are: " + + "\"0\", \"1\", \"false\", \"true\", \".false\", \".true\""); + } + + // no exception, so args o.k. + if (isOR) + { + writeOutput(slot, canonical+" "+ (newFrameVisible ? "1" : "0") ); + } + + if (jd.currFrameVisible!=newFrameVisible) + { + // 2022-09-22, cf. <https://stackoverflow.com/questions/8701716/how-to-remove-title-bar-in-jframe> + jd.dispose(); + jd.setUndecorated(!newFrameVisible); // <-- the title bar is removed here + jd.pack(); + jd.currFrameVisible=newFrameVisible; + if (currVisible) // make visible? + { + jd.setVisible(true); + } + } + break; + } + + case WIN_VISIBLE: // winVisible [.true|.false]: query or set whether frame is visible + { + if (arrCommand.length==1) // return current setting (via RC) + { + if (isOR) + { + writeOutput(slot,canonical); + } + return (currVisible ? "1" : "0"); + } + + if (arrCommand.length!=2) + { + throw new IllegalArgumentException("this command needs no or exactly 1 argument, received "+(arrCommand.length-1)+" instead"); + } + + String newValue = arrCommand[1]; + boolean newBooleanValue=false; + + if (checkBooleanValue(newValue)) // a valid BSF4ooRexx850 boolean value? + { + newBooleanValue=getBooleanValue(newValue); // get value + } + else + { + throw new IllegalArgumentException("the supplied \"frameVisible\" argument \""+newValue+"\" is not a valid BSF4ooRexx850 boolean value, valid values (in any case) are: " + + "\"0\", \"1\", \"false\", \"true\", \".false\", \".true\""); + } + + if (currVisible==newBooleanValue) // already at the same state, ignore command + { + return null; + } + + // no exception, so args o.k. + if (isOR) + { + writeOutput(slot,canonical+" "+(newBooleanValue ? "1" : "0")); + } + currVisible = newBooleanValue; + jd.setVisible(newBooleanValue); + + break; + } + + case WIN_UPDATE: // "winUpdate [.true|.false]" get or set whether Frame should be updated upon draws/changes + { + if (arrCommand.length==1) // return current setting (via RC) + { + if (isOR) + { + writeOutput(slot,canonical); + } + return (currWinUpdate ? "1" : "0"); + } + + if (arrCommand.length>2) + { + throw new IllegalArgumentException("this command accepts 1 argument at the most, received "+(arrCommand.length-1)+" instead"); + } + + String newValue = arrCommand[1]; + boolean newBooleanValue=false; + + if (checkBooleanValue(newValue)) // a valid BSF4ooRexx850 boolean value? + { + newBooleanValue=getBooleanValue(newValue); // get value + } + else + { + throw new IllegalArgumentException("the supplied \"frameVisible\" argument \""+newValue+"\" is not a valid BSF4ooRexx850 boolean value, valid values (in any case) are: " + + "\"0\", \"1\", \"false\", \"true\", \".false\", \".true\""); + } + // no exception, so args o.k. + currWinUpdate = newBooleanValue; + String res = (currWinUpdate ? "1" : "0"); + if (isOR) + { + writeOutput(slot,canonical+" "+res); + } + // return res; + break; + } + + case WIN_SIZE: // query or set size + { + if (jd==null) // implies creation of JavaDrawingFrame and make it visible + { + jd = new JavaDrawingFrame(bufImage); + jd.setVisible(true); + currVisible=true; + } + if (arrCommand.length==1) // return current setting (via RC) + { + return jd.currWidth+" "+jd.currHeight; + } + if (arrCommand.length!=3) + { + throw new IllegalArgumentException("this command needs no or exactly 2 arguments, received "+(arrCommand.length-1)+" instead"); + } + + int newWidth = Integer.parseInt(arrCommand[1]); + int newHeight = Integer.parseInt(arrCommand[2]); + + if (isOR) + { + writeOutput(slot, canonical+" "+newWidth+" "+newHeight); + } + // no exception, so args o.k. + jd.resizeSurface(newWidth, newHeight); // will use invokeLater() + break; + } + + case WIN_SCREEN_SIZE: // query screen size + { + if (arrCommand.length==1) // return current setting (via RC) + { + if (isOR) + { + writeOutput(slot, canonical); + } + Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize(); + return screenSize.width+" "+screenSize.height; + } + throw new IllegalArgumentException("this command does not expect any arguments, received "+(arrCommand.length-1)+" instead"); + } + + case PRINT_SCALE_TO_PAGE: // ( "printScaleToPage" ) , // "printScaleToPage [.true|.false]": get or set + { + if (arrCommand.length==1) // return current setting (via RC) + { + if (isOR) + { + writeOutput(slot,canonical); + } + return (printScaleToPage ? "1" : "0"); + } + + if (arrCommand.length!=2) + { + throw new IllegalArgumentException("this command needs no or exactly 1 argument, received "+(arrCommand.length-1)+" instead"); + } + + String newValue = arrCommand[1]; + if (checkBooleanValue(newValue)) // a valid BSF4ooRexx850 boolean value? + { + printScaleToPage=getBooleanValue(newValue); // get value + } + else + { + throw new IllegalArgumentException("the supplied \"printScaleToPage\" argument \""+newValue+"\" is not a valid BSF4ooRexx850 boolean value, valid values (in any case) are: " + + "\"0\", \"1\", \"false\", \"true\", \".false\", \".true\""); + } + return printScaleToPage ? "1" : "0"; + } + + case PRINT_SCALE: // "printScale [scaleX [scaleY]": get or set scaleX (if no scaleY use scaleX) + { + if (arrCommand.length>3) + { + throw new IllegalArgumentException("this command needs no or 1 or 2 arguments, received "+(arrCommand.length-1)+" instead"); + } + + if (arrCommand.length>1) + { + double tmpScaleX = Double.parseDouble(arrCommand[1]); + canonical = canonical + " " + arrCommand[1]; + + if (arrCommand.length==2) // + { + printScaleX=tmpScaleX; + printScaleY=tmpScaleX; // use X value also for Y + } + else // scaleY given + { + printScaleY = Double.parseDouble(arrCommand[2]); + printScaleX = tmpScaleX; + canonical = canonical + " " + arrCommand[2]; + } + } + if (isOR) + { + writeOutput(slot,canonical); + } + + return printScaleX+" "+printScaleY; + } + + case PRINT_POS: // "printPos [X [Y]]: get or set position of left upperhand corner + { + if (arrCommand.length>3) + { + throw new IllegalArgumentException("this command expects no, 1 or 2 arguments, received "+(arrCommand.length-1)+" instead"); + } + int newX = Integer.parseInt(arrCommand[1]); + int newY = newX; // default to newX + if (arrCommand.length==3) + { + newY = Integer.parseInt(arrCommand[2]); + } + // no exception, so args o.k. + printPosX = newX; + printPosY = newY; + String res = currX+" "+currY; + if (isOR) + { + canonical=canonical+" "+res; + } + if (isOR) + { + writeOutput(slot, canonical); + } + return res; + } + + case PRINT_IMAGE: // "printImage [nickName]" + { + if (arrCommand.length>2) + { + throw new IllegalArgumentException("this command needs either no or exactly 1 argument (image's nickname for lookup), received "+(arrCommand.length-1)+" instead"); + } + BufferedImage tmpImage = null; + if (arrCommand.length==1) + { + tmpImage = bufImage; + } + else + { + String name = arrCommand[1]; // get nickname + tmpImage = hmImages.get(name.toUpperCase()); + if (tmpImage==null) + { + throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\""); + } + canonical = canonical+" "+name; + } + if (isOR) + { + writeOutput(slot, canonical); + } + + // now print + PrintService service = PrintServiceLookup.lookupDefaultPrintService(); + DocPrintJob job = service.createPrintJob(); + DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; + + SimpleDoc doc = new SimpleDoc(new JavaDrawingPrintable(tmpImage,this), flavor, null); + job.print(doc, null); + return null; + } + + case SLEEP: // sleep for msecs (allows for simple animations) + { + if (arrCommand.length!=2) + { + throw new IllegalArgumentException("this command needs exactly 1 argument, received "+(arrCommand.length-1)+" instead"); + } + double secs = Double.parseDouble(arrCommand[1]); + + if (isOR) + { + writeOutput(slot, canonical+" "+secs); // write canonical form + } + try { Thread.sleep((long)(secs*1000)); } catch (Throwable t) {} + + return null; + } + + + // ---------------------- display, control related --- end + case SCALE: // "scale x [y]" set scale for x, y; if y omitted, uses x + case SHEAR: // "shear x [y]" set scale for x, y; if y omitted, uses x + { + int argNum=arrCommand.length; + if (argNum<2 || argNum>3) + { + throw new IllegalArgumentException("this command needs either one or 2 arguments, received "+(arrCommand.length-1)+" instead"); + } + + double newX = Double.parseDouble(arrCommand[1]); + double newY = newX; // default to X value in case Y value is omitted + if (argNum==3) // Y value supplied, use it + { + newY=Double.parseDouble(arrCommand[2]); + } + String strResult= newX+" "+newY; + + if (cmd==Command.SCALE) + { + bufGC.scale(newX,newY); + } + else + { + bufGC.shear(newX,newY); + } + if (isOR) + { + writeOutput(slot, canonical+' '+strResult); // write canonical form + } + return strResult; + } + + case NEW: // "new [width height [type]]" creates a new BufferedImage + { + if (arrCommand.length!=1 && arrCommand.length!=3 && arrCommand.length!=4) + { + throw new IllegalArgumentException("this command needs no, 2 (width height) or 3 (width height type) arguments, received "+(arrCommand.length-1)+" instead"); + } + int width = prefWidth; + int height = prefHeight; + int type = prefImageType; // (starts out with TYPE_INT_ARGB, i.e. wiht alpha/transparency) + + if (arrCommand.length>2) + { + width = Integer.parseInt(arrCommand[1]); + height = Integer.parseInt(arrCommand[2]); + if (isOR) + { + canonical = canonical + " " + width + " " + height; + } + + if (arrCommand.length>3) + { + String argType = arrCommand[3].toUpperCase(); + if (startRexxVariableChar.indexOf(argType.charAt(0))>=0) // a symbolic name? + { + if (!imageTypes.containsKey(argType)) + { + throw new IllegalArgumentException("unknown value for \"type\" argument"); + } + type=imageTypes.get(argType); + } + else // verbatim int type + { + type=Integer.parseInt(arrCommand[3]); + if (!imageTypes.containsValue(type)) + { + throw new IllegalArgumentException("unknown value for \"type\" argument"); + } + } + if (isOR) + { + canonical = canonical + " " + argType; + } + } + } + if (isOR) + { + writeOutput(slot, canonical); + } + // no exception, so args o.k. + if (bufImage!=null) // make sure all old GCs get disposed + { + bufImage=null; + if (bufGC!=null) + { + // empty stack, dispose GraphicConfigurations + Graphics2D tmpGC = null; + if (adGCStack.size()>0) + { + tmpGC=adGCStack.pop(); + } + while (tmpGC != null) + { + tmpGC.dispose(); + tmpGC = adGCStack.pop(); + } + bufGC.dispose(); + bufGC=null; + } + } + + bufImage=new BufferedImage(width, height, type); // create new image + bufGC=(Graphics2D) bufImage.getGraphics(); // get its GraphicsConfiguration + bufGC.setColor(Color.BLACK); // make sure color is set to black + if (jd!=null) // update Frame if it exists + { + jd.bufImage=bufImage; + } + } + break; + + case PREFERRED_IMAGE_TYPE: // "preferredImageType [type]": integer or constant name + { + if (arrCommand.length>2) + { + throw new IllegalArgumentException("this command needs either no or exactly 1 argument (preferred image type), received "+(arrCommand.length-1)+" instead"); + } + if (arrCommand.length==2) + { + int type; + String newType = arrCommand[1].toUpperCase(); + if (startRexxVariableChar.indexOf(newType.charAt(0))>=0) // a symbolic name? + { + if (!imageTypes.containsKey(newType)) + { + throw new IllegalArgumentException("unknown value for \"type\" argument"); + } + type=imageTypes.get(newType); + } + else // verbatim int type + { + type=Integer.parseInt(newType); + if (!imageTypes.containsValue(type)) + { + throw new IllegalArgumentException("unknown value for \"type\" argument"); + } + } + if (isOR) + { + canonical = canonical + " " + arrCommand[1]; // uses supplied argument value + } + prefImageType=type; + } + + if (isOR) + { + writeOutput(slot, canonical); + } + return "" + prefImageType; + } + + case IMAGE_TYPE: // "imageType [nickName]" + { + if (arrCommand.length>2) + { + throw new IllegalArgumentException("this command needs either no or exactly 1 argument (image's nickname for lookup), received "+(arrCommand.length-1)+" instead"); + } + if (arrCommand.length==1) + { + if (isOR) + { + writeOutput(slot, canonical); + } + return ""+bufImage.getType(); + } + + String name = arrCommand[1]; // get nickname + BufferedImage img = hmImages.get(name.toUpperCase()); + if (img==null) + { + throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\""); + } + + if (isOR) + { + writeOutput(slot, canonical+" "+name); + } + return ""+img.getType(); + } + + case IMAGE_SIZE: // "imageSize [nickName]" + { + if (arrCommand.length>2) + { + throw new IllegalArgumentException("this command needs either no or exactly 1 argument (image's nickname for lookup), received "+(arrCommand.length-1)+" instead"); + } + BufferedImage tmpImg = bufImage; // current image + if (arrCommand.length==2) // load image + { + String name = arrCommand[1]; // get nickname + tmpImg = hmImages.get(name.toUpperCase()); + if (tmpImg==null) + { + throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\""); + } + if (isOR) + { + canonical = canonical+" "+name; + } + } + if (isOR) + { + writeOutput(slot, canonical); + } + return tmpImg.getWidth()+' '+tmpImg.getHeight(); + } + + // create a RexxStringTable, fill it with current settings, stacks, maps and return it; + // if optional nameCtxtVariable supplied, store it as a context variable in addition + case GET_STATE: // "getstate [ctxtVariableName]" returns a StringTable with current variables, stacks and HashMaps; + { + if (arrCommand.length>2) + { + throw new IllegalArgumentException("this command needs either no or exactly 1 argument (nameOfContextVariable), received "+(arrCommand.length-1)+" instead"); + } + + if (isOR) + { + writeOutput(slot, canonical); + } + + RexxProxy rop = (RexxProxy) newStringTable(slot); // get a StringTable + rop.sendMessage2("SETENTRY", "currX" , currX); + rop.sendMessage2("SETENTRY", "currY" , currY); + rop.sendMessage2("SETENTRY", "currAngle" , currAngle); + + rop.sendMessage2("SETENTRY", "prefImageType" , prefImageType ); // currently preferred image type + + rop.sendMessage2("SETENTRY", "image" , bufImage ); + rop.sendMessage2("SETENTRY", "GC" , bufGC ); + + rop.sendMessage2("SETENTRY", "imageWidth" , bufImage.getWidth()); + rop.sendMessage2("SETENTRY", "imageHeight" , bufImage.getHeight()); + rop.sendMessage2("SETENTRY", "imageType" , bufImage.getType()); + + rop.sendMessage2("SETENTRY", "currFontStyle" , currFontStyle); + rop.sendMessage2("SETENTRY", "currFontSize" , currFontSize); + + rop.sendMessage2("SETENTRY", "currVisible" , currVisible); + rop.sendMessage2("SETENTRY", "currWinUpdate" , currWinUpdate); // if false inhibits updates of Frame + + // current... [truncated message content] |
From: <or...@us...> - 2022-10-03 13:28:19
|
Revision: 1000 http://sourceforge.net/p/bsf4oorexx/code/1000 Author: orexx Date: 2022-10-03 13:28:16 +0000 (Mon, 03 Oct 2022) Log Message: ----------- 20221003 Add JDOR Rexx command handler to sandbox. Added Paths: ----------- sandbox/rgf/jdor/ sandbox/rgf/jdor/JavaDrawingHandler.java sandbox/rgf/jdor/doc/ sandbox/rgf/jdor/doc/jdor_doc.html sandbox/rgf/jdor/doc/jdor_doc_sample.png sandbox/rgf/jdor/doc/jdor_doc_sample.rex sandbox/rgf/jdor/doc/readmeCreateJDOR.txt sandbox/rgf/jdor/readmeCreateJDOR.txt sandbox/rgf/jdor/samples/ sandbox/rgf/jdor/samples/1-120_JDOR_bw.rxj sandbox/rgf/jdor/samples/1-120_JDOR_color_text.rxj sandbox/rgf/jdor/samples/1-130_JDOR_rotate.rxj sandbox/rgf/jdor/samples/1-140_JDOR_images.rxj sandbox/rgf/jdor/samples/1-140_JDOR_images_reversed.rxj sandbox/rgf/jdor/samples/1-150_JDOR_string_circle.rxj sandbox/rgf/jdor/samples/1-160_JDOR_getState.rxj sandbox/rgf/jdor/samples/1-170_JDOR_lineHeight.rxj sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass.rxj sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass_log.rxj sandbox/rgf/jdor/samples/1-180_JDOR_sandGlass_replay_log.rxj sandbox/rgf/jdor/samples/1-200_listFonts.rxj sandbox/rgf/jdor/samples/2-110_JDOR_listShowPrintFonts.rxj sandbox/rgf/jdor/samples/3-100_create_bitmap_JDOR_commands.rxj sandbox/rgf/jdor/samples/bsf4oorexx_256.png sandbox/rgf/jdor/samples/jdor.cls sandbox/rgf/jdor/samples/oorexx4ooo_256.png sandbox/rgf/jdor/samples/oorexx_256.png Added: sandbox/rgf/jdor/JavaDrawingHandler.java =================================================================== --- sandbox/rgf/jdor/JavaDrawingHandler.java (rev 0) +++ sandbox/rgf/jdor/JavaDrawingHandler.java 2022-10-03 13:28:16 UTC (rev 1000) @@ -0,0 +1,3268 @@ +// cf. <https://zetcode.com/gfx/java2d/basicdrawing/> +// TODO: B4R -> resolving constructors, if class is not public +// TODO: define a package (e.g. org.oorexx.handler.jdor ?) +// TODO: pushGC: also save GC related current values? + +/* Java classes that constitute the JDOR ("JavaDrawing ooRexx") command handler. + + This enables any programmer to easily create and manipulate bitmaps on any + operating system (Windows, MacOS, Linux) where Java, ooRexx and BSF4ooRexx is + available. + + author: Rony G. Flatscher + date: 2022-09-05/2022-10-03 + license: Apache license 2.0 + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- + +*/ + +/* Sample program in ooRexx (temporarily): + + -- load and add the Java Rexx command handler, using default name: JDOR + call addJdorHandler + address jdor -- change default address environment + + signal on failure name any + signal on error name any + + new 500 500 -- create a new bitmap + winShow -- show it in a frame + + goto 10 10 + color orange + drawString "Hello at:" .dateTime~new + translate 10 490 + color green + drawString "Hello at:" .dateTime~new + translate 490 10 + color red + drawString "Hello at:" .dateTime~new + "translate -250 -250" -- must be quoted (minus causes Rexx to try arithmetics) + color blue + drawString "Hello at:" .dateTime~new + color red + angle=30 + do i=1 to 360/angle - 1 + rotate angle + drawString "ooRexx at:" .dateTime~new + end + + save "testTranslate.png" -- save as png file + sleep 2500 -- halts execution for 2 1/2 seconds + exit + + any: -- if command raise failure or error conditions, show them + co=condition('o') -- get a directory with the condition infos + say ppCondition2(co) -- format and show the condition information + say "---" + raise propagate -- now let ooRexx handle this condition + + ::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available + ::requires "rgf_util2.rex" -- get access to ppCondition2() + +*/ + +package org.oorexx.handlers.jdor; + + +import java.awt.EventQueue; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Toolkit; +import javax.swing.JFrame; +import javax.swing.JPanel; + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Font; +import java.awt.Dimension; +import java.awt.GradientPaint; +import java.awt.Paint; +import java.awt.Rectangle; +import java.awt.Stroke; +import java.awt.BasicStroke; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.swing.SwingUtilities; + +import java.awt.image.BufferedImage; +import java.io.File; +import javax.imageio.ImageIO; // for loading/saving + +import org.apache.bsf.BSFException; +import org.rexxla.bsf.engines.rexx.*; + +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; + +// for printing support +import java.awt.print.PageFormat; +import java.awt.print.Printable; + +import javax.print.DocFlavor; +import javax.print.DocPrintJob; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.SimpleDoc; + +// ============================================================================ +/** Class to allow displaying the current image. +*/ +class JavaDrawingFrame extends JFrame +{ + /* static definitions */ + static final private int prefWidth = 500; + static final private int prefHeight = 500; + + /* instance definitions */ + boolean bDebug= false; // true + Surface sf = null; + + int currWidth = prefWidth; + int currHeight = prefHeight; + boolean currFrameVisible = true; // cf. command "winFrame [.true|.false]" + + BufferedImage bufImage = null; + + + /** Constructor. + * @param img the BufferedImage to display + */ + public JavaDrawingFrame(BufferedImage img) + { + bufImage=img; + initUI(); + } + + /** Set up the UI using predefeined width and height for content pane. */ + private void initUI() + { + sf=new Surface(); + add(sf); + setTitle("JavaDrawingFrame"); + // needs to be followed by pack() to take effect immediately + getContentPane().setPreferredSize(new Dimension(bufImage.getWidth(),bufImage.getHeight())); + pack(); + + setLocationRelativeTo(null); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + } + + /** Resizes frame. + * @param width the width in pixel + * @param height the width in pixel + */ + public void resizeSurface (int width, int height) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + doResize(width, height); + } + }); + } + + /** Resizes frame (worker method, run on the GUI thread). + * @param width the width in pixel + * @param height the width in pixel + */ + void doResize (int width, int height) + { + getContentPane().setPreferredSize(new Dimension(width, height)); + pack(); + } + + // ============================================================================ + /** Surface to draw to. */ + class Surface extends JPanel + { + @Override + public void paintComponent(Graphics g) + { + super.paintComponent(g); + g.drawImage(bufImage,0,0,null); + } + } +} + + + +// ============================================================================ +public class JavaDrawingHandler implements RexxRedirectingCommandHandler +{ + /* static definitions */ + + // default image sizes + static final public String version = "001.20221002"; + static final private int prefWidth = 500; + static final private int prefHeight = 500; + static private int prefImageType = BufferedImage.TYPE_INT_ARGB; // default with alpha (only png supported) + + // a Rexx variable symbol may start with one of the following characters + static final String startRexxVariableChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_!?"; + + static final HashMap<String,Color> predefinedColors = new HashMap<>(); + // BufferedImage + static final HashMap<String,Integer> imageTypes = new HashMap<>(); + static final HashMap<Integer,String> imageTypesInt2Name = new HashMap<>(); + // BasicStroke + static final HashMap<String,Integer> endCaps = new HashMap<>(); + static final HashMap<Integer,String> endCapsInt2Name = new HashMap<>(); + static final HashMap<String,Integer> lineJoins = new HashMap<>(); + static final HashMap<Integer,String> lineJoinsInt2Name = new HashMap<>(); + // AlphaComposite + static final HashMap<String,Integer> alphaComposites = new HashMap<>(); + static final HashMap<Integer,String> alphaCompositesInt2Name = new HashMap<>(); + + static { + // ---------------------------------------------------------------------- + // Color + predefinedColors.put("BLACK" , Color.BLACK ); + predefinedColors.put("BLUE" , Color.BLUE ); + predefinedColors.put("CYAN" , Color.CYAN ); + predefinedColors.put("DARK_GRAY" , Color.DARK_GRAY ); + predefinedColors.put("GRAY" , Color.GRAY ); + predefinedColors.put("GREEN" , Color.GREEN ); + predefinedColors.put("LIGHT_GRAY" , Color.LIGHT_GRAY ); + predefinedColors.put("MAGENTA" , Color.MAGENTA ); + predefinedColors.put("ORANGE" , Color.ORANGE ); + predefinedColors.put("PINK" , Color.PINK ); + predefinedColors.put("RED" , Color.RED ); + predefinedColors.put("WHITE" , Color.WHITE ); + predefinedColors.put("YELLOW" , Color.YELLOW ); + + // ---------------------------------------------------------------------- + // BufferedImage + imageTypes.put("TYPE_CUSTOM" , BufferedImage.TYPE_CUSTOM ); // 0 + imageTypes.put("TYPE_INT_RGB" , BufferedImage.TYPE_INT_RGB ); // 1 + imageTypes.put("TYPE_INT_ARGB" , BufferedImage.TYPE_INT_ARGB ); // 2 + imageTypes.put("TYPE_INT_ARGB_PRE" , BufferedImage.TYPE_INT_ARGB_PRE ); // 3 + imageTypes.put("TYPE_INT_BGR" , BufferedImage.TYPE_INT_BGR ); // 4 + imageTypes.put("TYPE_3BYTE_BGR" , BufferedImage.TYPE_3BYTE_BGR ); // 5 + imageTypes.put("TYPE_4BYTE_ABGR" , BufferedImage.TYPE_4BYTE_ABGR ); // 6 + imageTypes.put("TYPE_4BYTE_ABGR_PRE", BufferedImage.TYPE_4BYTE_ABGR_PRE ); // 7 + imageTypes.put("TYPE_USHORT_565_RGB", BufferedImage.TYPE_USHORT_565_RGB ); // 8 + imageTypes.put("TYPE_USHORT_555_RGB", BufferedImage.TYPE_USHORT_555_RGB ); // 9 + imageTypes.put("TYPE_BYTE_GRAY" , BufferedImage.TYPE_BYTE_GRAY ); //10 + imageTypes.put("TYPE_USHORT_GRAY" , BufferedImage.TYPE_USHORT_GRAY ); //11 + imageTypes.put("TYPE_BYTE_BINARY" , BufferedImage.TYPE_BYTE_BINARY ); //12 + imageTypes.put("TYPE_BYTE_INDEXED" , BufferedImage.TYPE_BYTE_INDEXED ); //13 + // allow for looking up constant names (key) by value + imageTypes.forEach((K,V)->imageTypesInt2Name.put(V,K)); + + // ---------------------------------------------------------------------- + // BasicStroke + endCaps.put("CAP_BUTT" , 0); + endCaps.put("CAP_ROUND" , 1); + endCaps.put("CAP_SQUARE", 2); + // allow for looking up constant names (key) by value + endCaps.forEach((K,V)->endCapsInt2Name.put(V,K)); + + lineJoins.put("JOIN_MITER", 0); + lineJoins.put("JOIN_ROUND", 1); + lineJoins.put("JOIN_BEVEL", 2); + // allow for looking up constant names (key) by value + lineJoins.forEach((K,V)->lineJoinsInt2Name.put(V,K)); + + // ---------------------------------------------------------------------- + // AlphaComposite + alphaComposites.put("CLEAR" , 1); + alphaComposites.put("DST" , 9); + alphaComposites.put("DST_ATOP", 11); + alphaComposites.put("DST_IN" , 6); + alphaComposites.put("DST_OUT" , 8); + alphaComposites.put("DST_OVER", 4); + alphaComposites.put("SRC" , 2); + alphaComposites.put("SRC_ATOP", 10); + alphaComposites.put("SRC_IN" , 5); + alphaComposites.put("SRC_OUT" , 7); + alphaComposites.put("SRC_OVER", 3); + alphaComposites.put("XOR" , 12); + // allow for looking up constant names (key) by value + alphaComposites.forEach((K,V)->alphaCompositesInt2Name.put(V,K)); + } + + + int nrCommand=0; // in case many commands, indicates which command may have caused an error or failure condition + + /* instance definitions */ + JavaDrawingFrame jd = null; // maintance a singleton or empty + boolean bDebug=false; // true; // false; // true + + // we draw here and do a drawImage in the Surface paint + BufferedImage bufImage = null; + // int currImageType = prefImageType; + Graphics2D bufGC = null; + + /* printer related values */ + boolean printScaleToPage = false; + int printPosX=0, printPosY=0; + double printScaleX=1, printScaleY=1; + + /* current values */ + int currX = 0; + int currY = 0; + double currAngle = 0; // if rotate gets used, keeps current angle (in radians) + + int currFontStyle = 0; // PLAIN by default + int currFontSize = 12; // by default + + boolean currVisible = false; + boolean currWinUpdate = true; // update Frame whenever we draw: allows turning updating on/off + + + /** Stack for graphic configurations. */ + ArrayDeque <Graphics2D>adGCStack = new ArrayDeque<>(); + + /** Stack for images. */ + ArrayDeque <BufferedImage>adImageStack = new ArrayDeque<>(); + + /** Maps for definable, loadable resources. Index is name in uppercase. */ + HashMap<String,BufferedImage> hmImages = new HashMap<>(); + /** Contains always the predefined colors (cf. Javadoc of java.awt.Color). */ + HashMap<String,Color> hmColors = new HashMap<>(predefinedColors ); + HashMap<String,GradientPaint> hmGradientPaints = new HashMap<>(); + HashMap<String,Font> hmFonts = new HashMap<>(); + HashMap<String,Stroke> hmStrokes= new HashMap<>(); + + + void reset () // reset all current variables and caches + { + currX = 0; + currY = 0; + currAngle = 0; + + currFontStyle = 0; // PLAIN by default + currFontSize = 12; + + printScaleToPage = false; + printPosX = 0; + printPosY = 0; + printScaleX = 1; + printScaleY = 1; + + // empty stack + Graphics2D tGC = null; + if (adGCStack.size()>0) + { + tGC = adGCStack.pop(); + } + while (tGC!=null) + { + tGC.dispose(); + adGCStack.pop(); + } + adImageStack.clear(); + hmImages.clear(); + hmColors=new HashMap<>(predefinedColors ); + hmGradientPaints = new HashMap<>(); + hmFonts.clear(); + hmStrokes.clear(); + if (jd!=null && bufImage!=null) + { +if (bDebug) System.err.println(" /// ---> resizeSurface(): w="+bufImage.getWidth()+", h="+bufImage.getHeight()); + jd.resizeSurface(bufImage.getWidth(), bufImage.getHeight()); // will use invokeLater() + } + } + + + /** Callback method of this command handler. + * + * @param slot opaque argument (needs to be used if invoking the Handler default methods to interact with the Rexx context) + * @param address the environment name this handler works for + * @param command the command to process + */ + public Object handleCommand(Object slot, String address, String command) + { + nrCommand++; // increase counter +if (bDebug) System.err.println("[JavaDrawingHandler].handleCommand(slot, address=["+address+"]" + + "command # ["+nrCommand+"]" + + "command=["+command+"]" + + ); + Object res=null; + if (isInputRedirected(slot)) // take commands via redirected input + { + String currCommand=null; + while ( (currCommand=readInput(slot)) != null) // feed commands from redirected input + { + res=processCommand(slot, address, command, nrCommand, currCommand); + if (checkCondition(slot)) // a Rexx condition got set: stop processing, return immediately + { + return null; + } + } + } + else // single command + { + res=processCommand(slot, address, command, nrCommand, null); + } + return res; + } + + +// TODO: currently currCommand is not processed, should be a comment; maybe needs to be revisited? + + /** Process single command + processCommand(slot, address, command, nrCommand, currCommand); + * @param slot opaque argument (needs to be used if invoking the Handler default methods to interact with the Rexx context) + * @param address the environment name this handler works for + * @param command the command to process + * @param nrCommand counter to number this command + * @param currCommand command that was received in redirected modus + */ + Object processCommand(Object slot, String address, String command, int nrCommand, String currCommand) + { + String [] arrCommand = null; + String mainCommand = command; // command via address environment + if (currCommand!=null) + { + command=currCommand; // command from redirected input + } + + boolean isOR = isOutputRedirected(slot); // is output redirected ? + + // get the boundaries of the first ten words + ArrayList<int[]> alWordBoundaries = getWordBoundaries (command, 15); + arrCommand = getNonBlankWords(command, alWordBoundaries); + + Command cmd = null; + if (arrCommand.length>0) // empty string + { + cmd=Command.getCommand(arrCommand[0]); // can be null, if not available + } + + if (cmd==null) // unknown command raise error condition + { + String commentChars = "-#;/\"'.:!?_"; // regarded as a comment if any used as first non-blank character + if (arrCommand.length==0 || arrCommand[0].length()==0 || (commentChars).indexOf(arrCommand[0].charAt(0))>=0) // treat as comment) + { + if (isOR) + { + writeOutput(slot, command); // write unchanged + } + return null; + } + String errMsg = "unknown command"; + if (isOR) + { + writeOutput(slot, "-- FAILURE (unknown command): ["+command+"]"); + } + return createCondition (slot, nrCommand, command, ConditionType.FAILURE, "-1", errMsg ); + } + + // no image as of yet, not the NEW command, hence create a default image + if (bufImage==null && !(cmd==Command.NEW)) + { + bufImage = new BufferedImage(prefWidth, prefHeight, prefImageType); + bufGC = (Graphics2D) bufImage.getGraphics(); + bufGC.setColor(Color.BLACK); + Font currFont = bufGC.getFont(); + currFontStyle = currFont.getStyle(); + currFontSize = currFont.getSize(); + } + + String canonical = cmd.mixedCase;; + + // process commands; jd may be null ! + try + { + switch (cmd) // process commands + { + // ---------------------- display, control related --- Start + case WIN_SHOW: // show frame + { + if (arrCommand.length!=1) + { + throw new IllegalArgumentException("this command does not accept any arguments, received "+(arrCommand.length-1)+" instead"); + } + if (isOR) + { + writeOutput(slot, canonical); + } + if (currVisible) // already visible, nothing to do + { + return "1"; + } + if (jd==null) // implies creation of JavaDrawingFrame and make it visible + { + jd = new JavaDrawingFrame(bufImage); + } + jd.setVisible(true); // make sure frame is visible + currVisible=true; + break; + } + + case WIN_HIDE: // hide frame + { + if (arrCommand.length!=1) + { + throw new IllegalArgumentException("this command does not accept any arguments, received "+(arrCommand.length-1)+" instead"); + } + if (isOR) + { + writeOutput(slot, canonical); + } + if (!currVisible || jd==null) // not visible already, nothing to do + { + return null; + } + jd.setVisible(false); + currVisible=false; + + break; + } + + case WIN_CLOSE: // close (exit) JFrame + { + if (arrCommand.length!=1) + { + throw new IllegalArgumentException("this command does not accept any arguments, received "+(arrCommand.length-1)+" instead"); + } + if (jd!=null) + { + jd.dispatchEvent(new WindowEvent(jd, WindowEvent.WINDOW_CLOSING)); + jd=null; + } + currVisible=false; + if (isOR) + { + writeOutput(slot, canonical); + } + } + break; + + case WIN_LOCATION: // synonym WINMOVETO "winLocation [x y]" get or set JFrame location on screen + { + if (arrCommand.length!=3) + { + throw new IllegalArgumentException("this command needs no or exactly 2 arguments, received "+(arrCommand.length-1)+" instead"); + } + if (jd==null) // implies creation of JavaDrawingFrame and make it visible + { + jd = new JavaDrawingFrame(bufImage); + jd.setVisible(true); // make sure frame is visible + currVisible=true; + } + + int newX = jd.getX(); + int newY = jd.getY(); + + if (arrCommand.length==3) + { + newX = Integer.parseInt(arrCommand[1]); + newY = Integer.parseInt(arrCommand[2]); + jd.setLocation(newX, newY); + canonical = canonical+" "+newX+" "+newY; + } + + if (isOR) + { + writeOutput(slot, canonical); // write canonical form + } + if (arrCommand.length==1) + { + return newX+" "+newY; + } + break; + } + + // new 2022-09-27 + case WIN_ALWAYS_ON_TOP: // "winAlwaysOnTop [.true | .false]" get or set of this window state + { + if (arrCommand.length>2) + { + throw new IllegalArgumentException("this command needs no or exactly 1 argument, received "+(arrCommand.length-1)+" instead"); + } + } + case WIN_TO_BACK: // "winToBack" put window into the back + case WIN_TO_FRONT: // "winToFront" put window into the front + case WIN_ALWAYS_ON_TOP_SUPPORTED: // "winAlwaysOnTopSupported" get value + { + if (cmd!=Command.WIN_ALWAYS_ON_TOP && arrCommand.length!=1) + { + throw new IllegalArgumentException("this command expects no arguments, received "+(arrCommand.length-1)+" instead"); + } + if (jd==null) // implies creation of JavaDrawingFrame and make it visible + { + jd = new JavaDrawingFrame(bufImage); + jd.setVisible(true); // make sure frame is visible + currVisible=true; + } + + boolean retBoolValue=true; + + switch (cmd) + { + case WIN_ALWAYS_ON_TOP: + { + if (arrCommand.length!=1) + { + String newValue = arrCommand[1]; + + if (checkBooleanValue(newValue)) // a valid BSF4ooRexx850 boolean value? + { + retBoolValue=getBooleanValue(newValue); // get value + } + else + { + throw new IllegalArgumentException("the supplied \"frameVisible\" argument \""+newValue+"\" is not a valid BSF4ooRexx850 boolean value, valid values (in any case) are: " + + "\"0\", \"1\", \"false\", \"true\", \".false\", \".true\""); + } + canonical=canonical+" "+newValue; + jd.setAlwaysOnTop(retBoolValue); // set value + } + else + { + retBoolValue=jd.isAlwaysOnTop(); + } + break; + } + + case WIN_TO_BACK: // "winToBack" put window into the back + jd.toBack(); + break; + + case WIN_TO_FRONT: // "winToFront" put window into the front + jd.toFront(); + break; + + case WIN_ALWAYS_ON_TOP_SUPPORTED: // "winAlwaysOnTopSupported" get value + retBoolValue=jd.isAlwaysOnTopSupported(); + break; + } + + if (isOR) + { + writeOutput(slot, canonical); // write canonical form + } + + return retBoolValue ? "1" : "0"; + } + + + case WIN_TITLE: // winTitle [newTitle]: query or set title + { + if (jd==null) // implies creation of JavaDrawingFrame and make it visible + { + jd = new JavaDrawingFrame(bufImage); + jd.setVisible(true); // make sure frame is visible + currVisible=true; + } + if (arrCommand.length==1) // return current setting (via RC) + { + if (isOR) + { + writeOutput(slot,canonical); + } + return jd.getTitle(); + } + + int [] pos = (int []) alWordBoundaries.get(1); // String + String newTitle = command.substring(pos[0]); // extract String (may contain blanks) + if (isOR) + { + writeOutput(slot,canonical+" "+newTitle); + } + // no exception, so args o.k. + jd.setTitle(newTitle); // will use invokeLater() + break; + } + + + case WIN_FRAME: // winFrame [.true|.false]: query or set whether frame is visible + { + if (jd==null) // implies creation of JavaDrawingFrame and make it visible + { + jd = new JavaDrawingFrame(bufImage); + jd.setVisible(true); // make sure frame is visible + currVisible = true; + } + + if (arrCommand.length==1) // return current setting (via RC) + { + if (isOR) + { + writeOutput(slot,canonical); + } + return (jd.currFrameVisible ? "1" : "0"); + } + + if (arrCommand.length!=2) + { + throw new IllegalArgumentException("this command needs exactly 2 arguments, received "+(arrCommand.length-1)+" instead"); + } + + String newValue = arrCommand[1]; + boolean newFrameVisible=false; + + if (checkBooleanValue(newValue)) // a valid BSF4ooRexx850 boolean value? + { + newFrameVisible=getBooleanValue(newValue); // get value + } + else + { + throw new IllegalArgumentException("the supplied \"frameVisible\" argument \""+newValue+"\" is not a valid BSF4ooRexx850 boolean value, valid values (in any case) are: " + + "\"0\", \"1\", \"false\", \"true\", \".false\", \".true\""); + } + + // no exception, so args o.k. + if (isOR) + { + writeOutput(slot, canonical+" "+ (newFrameVisible ? "1" : "0") ); + } + + if (jd.currFrameVisible!=newFrameVisible) + { + // 2022-09-22, cf. <https://stackoverflow.com/questions/8701716/how-to-remove-title-bar-in-jframe> + jd.dispose(); + jd.setUndecorated(!newFrameVisible); // <-- the title bar is removed here + jd.pack(); + jd.currFrameVisible=newFrameVisible; + if (currVisible) // make visible? + { + jd.setVisible(true); + } + } + break; + } + + case WIN_VISIBLE: // winVisible [.true|.false]: query or set whether frame is visible + { + if (arrCommand.length==1) // return current setting (via RC) + { + if (isOR) + { + writeOutput(slot,canonical); + } + return (currVisible ? "1" : "0"); + } + + if (arrCommand.length!=2) + { + throw new IllegalArgumentException("this command needs no or exactly 1 argument, received "+(arrCommand.length-1)+" instead"); + } + + String newValue = arrCommand[1]; + boolean newBooleanValue=false; + + if (checkBooleanValue(newValue)) // a valid BSF4ooRexx850 boolean value? + { + newBooleanValue=getBooleanValue(newValue); // get value + } + else + { + throw new IllegalArgumentException("the supplied \"frameVisible\" argument \""+newValue+"\" is not a valid BSF4ooRexx850 boolean value, valid values (in any case) are: " + + "\"0\", \"1\", \"false\", \"true\", \".false\", \".true\""); + } + + if (currVisible==newBooleanValue) // already at the same state, ignore command + { + return null; + } + + // no exception, so args o.k. + if (isOR) + { + writeOutput(slot,canonical+" "+(newBooleanValue ? "1" : "0")); + } + currVisible = newBooleanValue; + jd.setVisible(newBooleanValue); + + break; + } + + case WIN_UPDATE: // "winUpdate [.true|.false]" get or set whether Frame should be updated upon draws/changes + { + if (arrCommand.length==1) // return current setting (via RC) + { + if (isOR) + { + writeOutput(slot,canonical); + } + return (currWinUpdate ? "1" : "0"); + } + + if (arrCommand.length>2) + { + throw new IllegalArgumentException("this command accepts 1 argument at the most, received "+(arrCommand.length-1)+" instead"); + } + + String newValue = arrCommand[1]; + boolean newBooleanValue=false; + + if (checkBooleanValue(newValue)) // a valid BSF4ooRexx850 boolean value? + { + newBooleanValue=getBooleanValue(newValue); // get value + } + else + { + throw new IllegalArgumentException("the supplied \"frameVisible\" argument \""+newValue+"\" is not a valid BSF4ooRexx850 boolean value, valid values (in any case) are: " + + "\"0\", \"1\", \"false\", \"true\", \".false\", \".true\""); + } + // no exception, so args o.k. + currWinUpdate = newBooleanValue; + String res = (currWinUpdate ? "1" : "0"); + if (isOR) + { + writeOutput(slot,canonical+" "+res); + } + // return res; + break; + } + + case WIN_SIZE: // query or set size + { + if (jd==null) // implies creation of JavaDrawingFrame and make it visible + { + jd = new JavaDrawingFrame(bufImage); + jd.setVisible(true); + currVisible=true; + } + if (arrCommand.length==1) // return current setting (via RC) + { + return jd.currWidth+" "+jd.currHeight; + } + if (arrCommand.length!=3) + { + throw new IllegalArgumentException("this command needs no or exactly 2 arguments, received "+(arrCommand.length-1)+" instead"); + } + + int newWidth = Integer.parseInt(arrCommand[1]); + int newHeight = Integer.parseInt(arrCommand[2]); + + if (isOR) + { + writeOutput(slot, canonical+" "+newWidth+" "+newHeight); + } + // no exception, so args o.k. + jd.resizeSurface(newWidth, newHeight); // will use invokeLater() + break; + } + + case WIN_SCREEN_SIZE: // query screen size + { + if (arrCommand.length==1) // return current setting (via RC) + { + if (isOR) + { + writeOutput(slot, canonical); + } + Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize(); + return screenSize.width+" "+screenSize.height; + } + throw new IllegalArgumentException("this command does not expect any arguments, received "+(arrCommand.length-1)+" instead"); + } + + case PRINT_SCALE_TO_PAGE: // ( "printScaleToPage" ) , // "printScaleToPage [.true|.false]": get or set + { + if (arrCommand.length==1) // return current setting (via RC) + { + if (isOR) + { + writeOutput(slot,canonical); + } + return (printScaleToPage ? "1" : "0"); + } + + if (arrCommand.length!=2) + { + throw new IllegalArgumentException("this command needs no or exactly 1 argument, received "+(arrCommand.length-1)+" instead"); + } + + String newValue = arrCommand[1]; + if (checkBooleanValue(newValue)) // a valid BSF4ooRexx850 boolean value? + { + printScaleToPage=getBooleanValue(newValue); // get value + } + else + { + throw new IllegalArgumentException("the supplied \"printScaleToPage\" argument \""+newValue+"\" is not a valid BSF4ooRexx850 boolean value, valid values (in any case) are: " + + "\"0\", \"1\", \"false\", \"true\", \".false\", \".true\""); + } + return printScaleToPage ? "1" : "0"; + } + + case PRINT_SCALE: // "printScale [scaleX [scaleY]": get or set scaleX (if no scaleY use scaleX) + { + if (arrCommand.length>3) + { + throw new IllegalArgumentException("this command needs no or 1 or 2 arguments, received "+(arrCommand.length-1)+" instead"); + } + + if (arrCommand.length>1) + { + double tmpScaleX = Double.parseDouble(arrCommand[1]); + canonical = canonical + " " + arrCommand[1]; + + if (arrCommand.length==2) // + { + printScaleX=tmpScaleX; + printScaleY=tmpScaleX; // use X value also for Y + } + else // scaleY given + { + printScaleY = Double.parseDouble(arrCommand[2]); + printScaleX = tmpScaleX; + canonical = canonical + " " + arrCommand[2]; + } + } + if (isOR) + { + writeOutput(slot,canonical); + } + + return printScaleX+" "+printScaleY; + } + + case PRINT_POS: // "printPos [X [Y]]: get or set position of left upperhand corner + { + if (arrCommand.length>3) + { + throw new IllegalArgumentException("this command expects no, 1 or 2 arguments, received "+(arrCommand.length-1)+" instead"); + } + int newX = Integer.parseInt(arrCommand[1]); + int newY = newX; // default to newX + if (arrCommand.length==3) + { + newY = Integer.parseInt(arrCommand[2]); + } + // no exception, so args o.k. + printPosX = newX; + printPosY = newY; + String res = currX+" "+currY; + if (isOR) + { + canonical=canonical+" "+res; + } + if (isOR) + { + writeOutput(slot, canonical); + } + return res; + } + + case PRINT_IMAGE: // "printImage [nickName]" + { + if (arrCommand.length>2) + { + throw new IllegalArgumentException("this command needs either no or exactly 1 argument (image's nickname for lookup), received "+(arrCommand.length-1)+" instead"); + } + BufferedImage tmpImage = null; + if (arrCommand.length==1) + { + tmpImage = bufImage; + } + else + { + String name = arrCommand[1]; // get nickname + tmpImage = hmImages.get(name.toUpperCase()); + if (tmpImage==null) + { + throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\""); + } + canonical = canonical+" "+name; + } + if (isOR) + { + writeOutput(slot, canonical); + } + + // now print + PrintService service = PrintServiceLookup.lookupDefaultPrintService(); + DocPrintJob job = service.createPrintJob(); + DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; + + SimpleDoc doc = new SimpleDoc(new JavaDrawingPrintable(tmpImage,this), flavor, null); + job.print(doc, null); + return null; + } + + case SLEEP: // sleep for msecs (allows for simple animations) + { + if (arrCommand.length!=2) + { + throw new IllegalArgumentException("this command needs exactly 1 argument, received "+(arrCommand.length-1)+" instead"); + } + double secs = Double.parseDouble(arrCommand[1]); + + if (isOR) + { + writeOutput(slot, canonical+" "+secs); // write canonical form + } + try { Thread.sleep((long)(secs*1000)); } catch (Throwable t) {} + + return null; + } + + + // ---------------------- display, control related --- end + case SCALE: // "scale x [y]" set scale for x, y; if y omitted, uses x + case SHEAR: // "shear x [y]" set scale for x, y; if y omitted, uses x + { + int argNum=arrCommand.length; + if (argNum<2 || argNum>3) + { + throw new IllegalArgumentException("this command needs either one or 2 arguments, received "+(arrCommand.length-1)+" instead"); + } + + double newX = Double.parseDouble(arrCommand[1]); + double newY = newX; // default to X value in case Y value is omitted + if (argNum==3) // Y value supplied, use it + { + newY=Double.parseDouble(arrCommand[2]); + } + String strResult= newX+" "+newY; + + if (cmd==Command.SCALE) + { + bufGC.scale(newX,newY); + } + else + { + bufGC.shear(newX,newY); + } + if (isOR) + { + writeOutput(slot, canonical+' '+strResult); // write canonical form + } + return strResult; + } + + case NEW: // "new [width height [type]]" creates a new BufferedImage + { + if (arrCommand.length!=1 && arrCommand.length!=3 && arrCommand.length!=4) + { + throw new IllegalArgumentException("this command needs no, 2 (width height) or 3 (width height type) arguments, received "+(arrCommand.length-1)+" instead"); + } + int width = prefWidth; + int height = prefHeight; + int type = prefImageType; // (starts out with TYPE_INT_ARGB, i.e. wiht alpha/transparency) + + if (arrCommand.length>2) + { + width = Integer.parseInt(arrCommand[1]); + height = Integer.parseInt(arrCommand[2]); + if (isOR) + { + canonical = canonical + " " + width + " " + height; + } + + if (arrCommand.length>3) + { + String argType = arrCommand[3].toUpperCase(); + if (startRexxVariableChar.indexOf(argType.charAt(0))>=0) // a symbolic name? + { + if (!imageTypes.containsKey(argType)) + { + throw new IllegalArgumentException("unknown value for \"type\" argument"); + } + type=imageTypes.get(argType); + } + else // verbatim int type + { + type=Integer.parseInt(arrCommand[3]); + if (!imageTypes.containsValue(type)) + { + throw new IllegalArgumentException("unknown value for \"type\" argument"); + } + } + if (isOR) + { + canonical = canonical + " " + argType; + } + } + } + if (isOR) + { + writeOutput(slot, canonical); + } + // no exception, so args o.k. + if (bufImage!=null) // make sure all old GCs get disposed + { + bufImage=null; + if (bufGC!=null) + { + // empty stack, dispose GraphicConfigurations + Graphics2D tmpGC = null; + if (adGCStack.size()>0) + { + tmpGC=adGCStack.pop(); + } + while (tmpGC != null) + { + tmpGC.dispose(); + tmpGC = adGCStack.pop(); + } + bufGC.dispose(); + bufGC=null; + } + } + + bufImage=new BufferedImage(width, height, type); // create new image + bufGC=(Graphics2D) bufImage.getGraphics(); // get its GraphicsConfiguration + bufGC.setColor(Color.BLACK); // make sure color is set to black + if (jd!=null) // update Frame if it exists + { + jd.bufImage=bufImage; + } + } + break; + + case PREFERRED_IMAGE_TYPE: // "preferredImageType [type]": integer or constant name + { + if (arrCommand.length>2) + { + throw new IllegalArgumentException("this command needs either no or exactly 1 argument (preferred image type), received "+(arrCommand.length-1)+" instead"); + } + if (arrCommand.length==2) + { + int type; + String newType = arrCommand[1].toUpperCase(); + if (startRexxVariableChar.indexOf(newType.charAt(0))>=0) // a symbolic name? + { + if (!imageTypes.containsKey(newType)) + { + throw new IllegalArgumentException("unknown value for \"type\" argument"); + } + type=imageTypes.get(newType); + } + else // verbatim int type + { + type=Integer.parseInt(newType); + if (!imageTypes.containsValue(type)) + { + throw new IllegalArgumentException("unknown value for \"type\" argument"); + } + } + if (isOR) + { + canonical = canonical + " " + arrCommand[1]; // uses supplied argument value + } + prefImageType=type; + } + + if (isOR) + { + writeOutput(slot, canonical); + } + return "" + prefImageType; + } + + case IMAGE_TYPE: // "imageType [nickName]" + { + if (arrCommand.length>2) + { + throw new IllegalArgumentException("this command needs either no or exactly 1 argument (image's nickname for lookup), received "+(arrCommand.length-1)+" instead"); + } + if (arrCommand.length==1) + { + if (isOR) + { + writeOutput(slot, canonical); + } + return ""+bufImage.getType(); + } + + String name = arrCommand[1]; // get nickname + BufferedImage img = hmImages.get(name.toUpperCase()); + if (img==null) + { + throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\""); + } + + if (isOR) + { + writeOutput(slot, canonical+" "+name); + } + return ""+img.getType(); + } + + case IMAGE_SIZE: // "imageSize [nickName]" + { + if (arrCommand.length>2) + { + throw new IllegalArgumentException("this command needs either no or exactly 1 argument (image's nickname for lookup), received "+(arrCommand.length-1)+" instead"); + } + BufferedImage tmpImg = bufImage; // current image + if (arrCommand.length==2) // load image + { + String name = arrCommand[1]; // get nickname + tmpImg = hmImages.get(name.toUpperCase()); + if (tmpImg==null) + { + throw new IllegalArgumentException("image with the name \""+name+"\" not found, you must first use \"loadImage "+name+" filename\""); + } + if (isOR) + { + canonical = canonical+" "+name; + } + } + if (isOR) + { + writeOutput(slot, canonical); + } + return tmpImg.getWidth()+' '+tmpImg.getHeight(); + } + + // create a RexxStringTable, fill it with current settings, stacks, maps and return it; + // if optional nameCtxtVariable supplied, store it as a context variable in addition + case GET_STATE: // "getstate [ctxtVariableName]" returns a StringTable with current variables, stacks and HashMaps; + { + if (arrCommand.length>2) + { + throw new IllegalArgumentException("this command needs either no or exactly 1 argument (nameOfContextVariable), received "+(arrCommand.length-1)+" instead"); + } + + if (isOR) + { + writeOutput(slot, canonical); + } + + RexxProxy rop = (RexxProxy) newStringTable(slot); // get a StringTable + rop.sendMessage2("SETENTRY", "currX" , currX); + rop.sendMessage2("SETENTRY", "currY" , currY); + rop.sendMessage2("SETENTRY", "currAngle" , currAngle); + + rop.sendMessage2("SETENTRY", "prefImageType" , prefImageType ); // currently preferred image type + + rop.sendMessage2("SETENTRY", "image" , bufImage ); + rop.sendMessage2("SETENTRY", "GC" , bufGC ); + + rop.sendMessage2("SETENTRY", "imageWidth" , bufImage.getWidth()); + rop.sendMessage2("SETENTRY", "imageHeight" , bufImage.getHeight()); + rop.sendMessage2("SETENTRY", "imageType" , bufImage.getType()); + + rop.sendMessage2("SETENTRY", "currFontStyle" , currFontStyle); + rop.sendMessage2("SETENTRY", "currFontSize" , currFontSize); + + rop.sendMessage2("SETENTRY", "currVisible" , currVisible); + rop.sendMessage2("SETENTRY", "currWinUpdate" , currWinUpdate); // if false inhibits updates of Frame + + // current print related settings + rop.sendMessage2("SETENTRY", "printScaleToPage" , (printScaleToPage ? "1" : "0") ); + rop.sendMessage2("SETENTRY", "printPosX" , printPosX); + rop.sendMessage2("SETENTRY", "printPosY" , printPosY); + rop.sendMessage2("SETENTRY", "printScaleX" , printScaleX); + rop.sendMessage2("SETENTRY", "printScaleY" , printScaleY); + + // current GraphicConfiguration + rop.sendMessage2("SETENTRY", "gc.background" , bufGC.getBackground()); + rop.sendMessage2("SETENTRY", "gc.color" , bufGC.getColor() ); + rop.sendMessage2("SETENTRY", "gc.composite" , bufGC.getComposite() ); + rop.sendMessage2("SETENTRY", "gc.font" , bufGC.getFont() ); + rop.sendMessage2("SETENTRY", "gc.... [truncated message content] |
From: <or...@us...> - 2022-10-03 13:17:15
|
Revision: 999 http://sourceforge.net/p/bsf4oorexx/code/999 Author: orexx Date: 2022-10-03 13:17:13 +0000 (Mon, 03 Oct 2022) Log Message: ----------- 20221003 Add JDOR documentation. Added Paths: ----------- branches/850/bsf4oorexx.dev/information/jdor/ branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html branches/850/bsf4oorexx.dev/information/jdor/jdor_doc_sample.png Added: branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html =================================================================== --- branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html (rev 0) +++ branches/850/bsf4oorexx.dev/information/jdor/jdor_doc.html 2022-10-03 13:17:13 UTC (rev 999) @@ -0,0 +1,1671 @@ +<!-- + ======================== Apache Version 2.0 license ========================= + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE=2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============================================================================= + + Synopsis like documentation of the JDOR Rexx command handler commands. + 2022-10-02, rgf +--> + + +<html> +<head> +<title>JDOR Synopsis</title> + <style> + /* --- definition list----------------------- */ + dt { + font-weight: bold; + font-style: italic; + } + + dl, + dd { + font-size: .9rem; + } + + dd { + margin-bottom: 1px; + } + + /* --- table -------------------------------- */ + table { + border = 1px; + cellpadding = 3; + cellspacing = 0; + counter-reset: command-count; + } + + th { + background-color: BurlyWood ; + } + + tr:hover { + background-color: PaleGoldenRod; + } + + .command { + font-weight: bold; + font-family: monospace; + font-size: .9rem; + vertical-align: text-top; + } + + .argument { + font-family: monospace; + font-style: italic; + font-size: .8rem; + vertical-align: text-top; + } + + .TableHeader { + background-color: LemonChiffon; + } + + td.cmdNr:first-child::before { + content: "("counter(command-count)")"; + } + + td.cmdNr { + font-family: monospace; + font-size: .9rem; + vertical-align: top; + text-align: center; + } + + .CommandRowColumn { + background-color: LemonChiffon; + counter-increment: command-count; + } + + tr.ArgumentRowColor:nth-child(even) { + background-color: LightYellow; + } + + /* also highlight :nth-child colored rows on hover */ + tr.ArgumentRowColor:hover { + background-color: PaleGoldenRod; + } + + </style> +</head> + +<body> +<h3>Purpose of JDOR (Java Drawing for ooRexx)</h3> + +<p>JDOR (Java drawing for <a href="https://sourceforge.net/projects/oorexx/">ooRexx</a>) is a Rexx +command handler (implemented in Java taking advantage of <a +href="https://sourceforge.net/projects/bsf4oorexx/">BSF4ooRexx850</a> and later) that makes Java's +2D functionality available to Rexx programmers via commands that simplify the interaction, yet allow +for creating the most challenging graphics (images) from Rexx. + +<p>Example: +<pre> + call addJdorHandler -- load and add the Java Rexx command handler, default name: JDOR + address jdor -- set default environment to the JDOR command handler + width =220 -- define width of image in pixels (there are 72 px to an inch) + height=250 -- define height of image in pixels (there are 72 px to an inch) + new width height -- create new bitmap with currX=0, currY=0, width=220, height=250 + winShow -- show frame on screen + -- draw two lines forming a big X + drawLine width height -- from currX=0, currY=0 + color red -- set the color to red (preregistered with nickname "RED") + goto width 0 -- currX=220, currY=0 + say "--> rc="pp(rc) -- RC refers to the previous command's result: "220 0" (currX=220, currY=0) + drawLine 0 height -- from currX=250, currY=0 + -- draw a rectangle at the center of the bitmap + len = 50 -- drawing a rectangle with each side being 50 px (a square) + goto (width-len)/2 (height-len)/2 -- go to the center minus half of the square's side lengths + color green -- set color to green (preregistered with nickname "GREEN") + fillRect len len -- fill the square with the green color + stroke str3 3 -- set line stroke to 3 points width, store it with nickname "STR3" + color blue -- set color to blue (preregistered with nickname "BLUE") + drawRect len len -- draw the frame with the blue color + -- draw a string (text) at the lower half of the bitmap + color somePurple 127 46 111 -- define a custom RGB color, store it with nickname "SOMEPURPLE" + say "--> rc="pp(rc) -- show result from command (the Java oclor object) + say " rc~toString:" pp(rc~toString) -- shows the RGB intensities of the color + newY=height-40 + -- define an array of three strings + lineHeight = 15 -- default font size is 12px, add 3 px space + text=("Hello, Rexx world ...", "... from JDOR ...", "(Rexx command handler)") -- array of 3 strings + do counter c i=0 to 30 by lineHeight -- iterate over array of strings + goto 50 (newY+i) -- set position + drawString text[c] -- draw the string + end + -- save the current image + saveImage "jdor_doc_sample.png" -- save image to file "jdor_doc_sample.png" + sleep 3.123 -- sleep for 3.123 seconds + + ::requires "jdor.cls" -- Rexx package that defines the public routine addJdorHandler() +</pre> + +<br>The above Rexx program with the JDOR commands will output the following text in the + command line window: + <pre> + --> rc=[220 0] + --> rc=[java.awt.Color@4fe3c938] + rc~toString: [java.awt.Color[r=127,g=46,b=111]] + </pre> + and create and save the following image (bitmap) using as filename "<code>jdor_doc_sample.png</code>": + <p> + <center><img src="jdor_doc_sample.png" border="1px"></center> + +<p><hr><p> + +<h3>Brief Overview</h3> + +<p> +The <em>JDOR</em> Rexx command handler makes <em>Java2D</em> functionality available +to Rexx programmers. The commands are formed after the methods in the <code>java.awt.Graphics</code> +and <code>java.awt.Graphics2D</code> Java classes. The only difference are the <code>x</code> and +<code>y</code> co-ordinates which many methods have as their first two arguments: the Rexx programmer +defines these co-ordinates with the <code>GOTO x y</code> command and therefore are left out from +the arguments of the Rexx commands matching the Java method names. + + +<p>For the Rexx programmers the following <em>JDOR</em> related materials may be helpful: +<ul> + <li><a href="https://www.rexxla.org/presentations/2022/202209_JDOR_command_handler.pdf">Introducing + the JDOR Rexx Command Handler for Easy Creation of Bitmaps and Bitmap Manipulations on Windows, + Mac and Linux</a> presented at the <a href="https://www.rexxla.org/events/schedule.rsp?year=2022">33rd I + nternational Rexx Symposium 2022</a> (<a href="https://www.rexxla.org/">The Rexx Language Assocation</a>) +</ul> + +<p>For the newcomer the following <em>Java 2D</em> related tutorial may be helpful (as of 2022-09-29): +<ul> + <li><a href="https://docs.oracle.com/javase/tutorial/2d/index.html">https://docs.oracle.com/javase/tutorial/2d/index.html</a> +</ul> + +<p><hr><p> + +<h3>Some (Informally Defined) Terms</h3> +<dl> + + <dt>AffineTransform</dt> + <dd>The Java class <code>java.awt.geom.AffineTransform</code> allows to define and maintain + <em>rotate(...)</em>, <em>scale(...)</em>, <em>shear(...)</em>, + <em>translate(...)</em> operations which all can be applied at once with the + <em>java.awt.Graphics2D</em>'s <em>transform(anAffineTransform)</em> method. + One benefit is that <em>GC</em> is not permanently changed to these trnasformation + values. + + <p>Currently there is no JDOR command to support this directly, however the same effect can + be achieved with the <em>pushGC</em> command, followed by any transforms + (<em>rotate(...)</em>, <em>scale(...)</em>, <em>shear(...)</em>, <em>translate(...)</em>) + and the <em>popGC</em> command which will reinstate the previous pushed <em>GC</em>. + + <p> + Alternatively, the Rexx programmer can fetch the <em>GC</em> object (cf. <em>GC</em> command) + and interact with it directly and use the <em>transform(...)</em> method directly supplying + an instance of <code>java.awt.geom.AffineTransform</code>. + + </dd><br> + + + <dt>coordinate system<dt> + <dd>The 0-based, two dimensional coordinate system to address each pixel of an image of + width</em> and height</em> in size. The location (coordinate) <em>x=0</em> and + <em>y=0</em>, the <em>origin</em> denotes the pixel in the upper left hand corner. + Increasing <em>x</em> move along to the <em>right</em> (along the <em>x-axis</em>), + increasing <em>y</em> along to the bottom (along the <em>y-axis</em>). + </dd><br> + + <dt>currX currY</dt> + <dd><em>currX</em> and <em>currY</em> denote the current position of the starting + (upper left hand) point used when clearing, drawing or filling. It can be set with + the <em>goto x y</em> command (alias name for this command is <em>pos x y</em>). + The JDOR command handler will insert <em>currX</em> and <em>currY</em> whenever a + <em>x</em> and <em>y</em> position must be supplied to a Java2D method. + </dd><br> + + <dt>clip</dt> + <dd>A rectangular area of which gets affected by drawings and fills. Any pixels + outside of a defined clip (clipping area) do not change.</dd><br> + + <dt id="dtDashArray">dashArray</dt> + <dd>The command <em>stroke</em> allows for an argument <em>dashArray</em> that + represents an array of float values. + There are two possibilities to supply this array to the command: + <ul> + <li>either as a string consisting of a comma separated list of numbers in parantheses + (must be quoted to form a valid Rexx string and must not contain whitespace) + e.g.: <em>"(1,3,1,3)"</em> + + <li>or passing a Rexx variable that refers to the appropriate Java array e.g.: + <br><em>dashArray=bsf.createJavaArrayOf("float.class", 1, 3, 1, 3)</em> + and then submitting the quoted name of the Rexx variable, e.g. <em>"dashArray"</em>, + as array argument; the command handler will then fetch the array from the Rexx variable + (after fetching the Rexx variable by name from the command context) + </ul> + </dd><br> + + + <dt>GC</dt> + <dd>A <em>graphical configuration</em>, an instance of the Java class + <em>java.awt.Graphics</em> or <em>java.awt.Graphics2D</em> + which allows for interacting (drawing, transforming, etc.) with an image(a bitmap). + </dd><br> + + <dt>image type</dt> + <dd>The image type defines the basic properties of an image which also determines + in which format an image can be stored in the file system. The supported types + are defined as constants in the Java class <em>java.awt.image.BufferedImage</em>. + </dd> + + + <dt>pixel</dt> + <dd>picture element, usually the size of 1/72 of an inch</dd><br> + + <dt>RGB color</dt> + <dd>A color mix of the colors <em>red</em>, <em>green</em> and <em>blue</em> each defined + with an intensity between <em>0</em> and <em>255</em>. + </dd><br> + + <dt>RGBA color</dt> + <dd>A color mix of the colors <em>red</em>, <em>green</em>, <em>blue</em> and + <em>alpha</em> (transparency/opaqueness) each defined with an intensity between + <em>0</em> and <em>255</em>. <em>Note:</em> an <em>alpha</em> intensity + of <em>0</em> means "no transparency", and an intensitiy of <em>255</em> + "complete transparency". + </dd><br> + + <dt>rotate</dt> + <dd>A positive or negative value in degrees (0-360) to rotate the image. <em>Note:</em> the + Java method rotate(angle) expects the value to be in radians, whereas this command expects + degrees! The rotate command will convert the degree value (easier for humans) to radians + before invoking the Java method (cf. <a href="https://en.wikipedia.org/wiki/Gradian">Wikipedia Gradian</a> + article). + </dd><br> + + <dt>scale</dt> + <dd>A positive or negative value used to multiply the <em>width</em> and <em>height</em> values. + </dd><br> + + <dt>shear</dt> + <dd>A positive or negative value used to slant a drawing, also known as skewing. + </dd><br> + + <dt>translate</dt> + <dd>Moving the origin to a different position, such that the effective <em>x</em> and <em>y</em> + coordinates get calculated relative to the new origin. + </dd><br> + + <dt id="dtPointsArray">xPoints-array, yPoints-array</dt> + <dd>The commands + <a href="#cmdDrawPolygon"><em>drawPolygon</em></a>, + <a href="#cmdDrawPolyline"><em>drawPolyline</em></a> or + <a href="#cmdFillPolygon"><em>fillPolygon</em></a> + + expect two arrays for the <em>x y</em> coordinates of the + points. + + There are two possibilities to supply these arrays to the JDOR command handler: + <ul> + <li>either as a string consisting of a comma separated list of numbers in parantheses + (must be quoted to form a valid Rexx string and must not contain whitespace) + e.g.: <em>"(10,30,40,50,110,140)"</em> + + <li>or passing a Rexx variable that refers to the appropriate Java array e.g.: + <br><em>xPoints=bsf.createJavaArrayOf("int.class", 10, 30, 40, 50, 110, 140)</em> + and then submitting the quoted name of the Rexx variable, e.g. <em>"xPoints"</em>, + as array argument; the command handler will then fetch the array from the Rexx variable + (after fetching the Rexx variable by name from the command context) + </ul> + </dd><br> + +</dl> + +<p><hr><p> + + +<h3>Synopsis of the <em>JDOR</em> Rexx Commands</h3> + +<p> In general the arguments to a command are blank delimited. If supplying a Rexx variable, its +referred to value will be supplied, if using a Rexx expression it will be evaluated and the +resulting value will be supplied to the Rexx command handler. + +<p>If you wish to supply the name of a Rexx variable to a command (e.g. for the commands +<a href="#cmdDrawPolygon"><em>drawPolygon</em></a>, +<a href="#cmdDrawPolyline"><em>drawPolyline</em></a>, +<a href="#cmdFillPolygon"><em>fillPolygon</em></a> or +<a href="#cmdGetState"><em>getState</em></a>) +then make sure to enquote that +variable name as otherwise its value gets supplied instead. + +<p>Commands need not be enquoted, unless their names collide with Rexx keyword names (which +at the time of writing does not happen) or are used as Rexx variable names in your program. + +<p> Unquoted literals will be uppercased according to the Rexx rules and then supplied to the +command handler. If commands or arguments are unqouted then they get uppercased as well and blanks +between them will be reduced to a single white space according to the Rexx rules before supplying +the resulting command with arguments to the Rexx command handler. + +<p> + <table> + <tr> + <tr class="TableHeader"> + <th> + <th> Command + <th> Argument(s) + <th> Description + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "background" + <td colspan="3"> Queries or sets the background color to a registered color and returns + it via the Rexx variable <code>RC</code>. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + methods: <em>getBackground()</em>, <em>setBackground(...)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> colorNickName + <td> The name of a registered color (cf. <em>color</em> command) to + which the background color should be set to. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "clearRect" + <td colspan="2"> Clears a rectangle of the supplied <em>width</em> and <em>height</em> + at the current <em>x</em> and <em>y</em> position (cf. <em>goto</em> command), + using the <em>background</em> (cf. <em>background</em> command) color. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>clearRect(...)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> width height + <td> <em>width</em> and <em>height</em> in pixel of the rectangle. + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "clip" + <td colspan="2"> Queries or sets a clipping area of an image. Returns a + blank delimited string with the <em>x</em>, <em>y</em>, + <em>width</em> and <em>height</em> values of the clipping rectangle (area) + via the Rexx variable <em>RC</em>. If a clipping area exists already, + then the intersection with it will be the new clipping area. + + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + methods <em>getClipBounds()</em>, <em>clipRect(...)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> x y width height + <td> <em>x</em> position on the x-axis, the <em>y</em> position on the y-axis, + the <em>width</em> and the <em>height</em> in pixels of the rectangle. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "clipRemove" + <td colspan="2"> Removes <em>clip</em> from image, if any defined. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>setClip(null)</em>. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "color" + <td colspan="2"> Query, get and set, define and set the color. With no arguments + returns the current Java color which can be referred to via the Rexx variable + <em>RC</em> upon return from this command. + <br>Supplying only the <em>colorNickName</em> argument will load the color from the + internal register and use it. + <br>Supplying in addition the intensity values for the colors <em>red</em>, <em>green</em>, <em>blue</em>, + and optionally <em>alpha</em>, a <em>java.awt.Color</em> of that type gets created, registered with + the supplied <em>colorNickName</em> and then used for setting the new color. + + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + methods <em>getColor()</em>, <em>setColor(...)</em>, as well as the Java class + <em>java.awt.Color</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> colorNickName + <td> <em>colorNickName</em> gets uppercased and is used to look up the internal + color registry for the denoted color which should be used from now on and gets + returned via the Rexx variable <em>RC</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> colorNickName r g b [alpha] + <td> This command creates a color using an intensity beteween <em>0</em> and + <em>255</em> for each of the colors <em>red</em>, <em>green</em>, <em>blue</em> + and optionally for <em>alpha</em> (transparency/opaqueness). This color will be + used from now on and gets stored in the color registry using the supplied + <em>colorNickName</em> in uppercase and returned via the Rexx variable <em>RC</em>. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "composite" + <td colspan="2"> Queries or creates and sets the composite value (an instance of the + Java class <em>java.awt.AlphaComposite</em>). + + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + methods <em>getComposite()</em>, <em>setComposite(...)</em>, and the Java class + <em>java.awt.AlphaComposite</em> with its constant fields and the method + <em>getInstance(...)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> rule [alpha] + <td> <em>rule</em> is a number or a constant name (<em>CLEAR</em>, + <em>DST</em>, <em>DST_ATOP</em>, <em>DST_IN</em>, <em>DST_OUT</em>, + <em>DST_OVER</em>, <em>SRC</em>, <em>SRC_ATOP</em>, <em>SRC_IN</em>, + <em>SRC_OUT</em>, <em>SRC_OVER</em>, <em>XOR</em>); + <br><em>alpha</em> is an optional value between <em>0.0</em> and <em>1.0</em>. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "draw3DRect" + <td colspan="2"> Draws a rectangle with 3D appearance (raised or sunken). + + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>draw3DRect(...)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> width height raised + <td> <em>width</em> and <em>height</em> in pixel of the rectangle, + <em>raised</em> is either set to <em>.true</em> for raised or to <em>.false</em> + for sunken). + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "drawArc" + <td colspan="2"> Draws an arc . + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>drawArc(...)()</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> width height startAngle arcAngle + <td> <em>width</em> and <em>height</em> in pixel of the rectangle, + <em>startAngle</em> in degrees (0 is the 3 o'clock position), <em>arcAngle</em> + angular extend in degrees relative to <em>startAngle</em>. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "drawImage" + <td colspan="2"> Draws an image which got previously loaded from the filesystem + with the command <em>loadImage</em> and stored internally with a <em>nickName</em> + in the internal image registry. + + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>drawImage(...)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> nickName [bkgColor] + <td> <em>nickName</em> denotes the name of an image stored in the + internal image registry. Draws as much of the image as possible. + + <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> nickName width height [bkgColor] + <td> <em>nickName</em> denotes the name of an image stored in the + internal image registry. Draws as much of the image as possible scaled to the + <em>width</em> and <em>height</em> in pixel. + + <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> nickName width height srcX1 srcY1 srcX2 srcY2 [bkgColor] + <td> <em>nickName</em> denotes the name of an image stored in the + internal image registry. Draws as much of the image as possible scaled to the + <em>width</em> and <em>height</em> in pixel, using from the image the rectangle + with the first corner with the coordinate <em>srcX1</em> and <em>srcY1</em> and + the second corner with the coordinate <em>srcX2</em> and <em>srcY2</em>. + + <br>Optional <em>bkgColor</em> is the <em>colorNickName</em> of a previously stored color. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "drawLine" + <td colspan="2"> Draws a line. + + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>drawLine(...)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> toX toY + <td> <em>toX</em> and <em>toY</em>, denoting the endpoint of the line. + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "drawOval" + <td colspan="2"> Draws an oval. + + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>drawOval()</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> width height + <td> Draws an oval in a rectangle of <em>width</em> and + <em>height</em> pixels. If <em>width</em> and + <em>height</em> are of the same length the oval will be a circle. + + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command" id="cmdDrawPolygon"> "drawPolygon" + <td colspan="2"> Draws a polygon using <em>nPoints</em> coordinates from the <em>xPoints-array<em> array + and </em>yPoints-array</em>. The polygon gets closed by drawing a line from the first and last point. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>drawPolygon(...). + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> xPoints-array yPoints-array nPoints + <td> Draws a polygon consisting of <em>nPoints</em> taken from the + <a href="#dtPointsArray"><em>xPoints-array</em></a> and + <a href="#dtPointsArray"><em>yPoints-array</em></a>. + If the endpoint is not + the same coordinate, the polygon gets closed by drawing a line from the + first to the last point. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command" id="cmdDrawPolyline"> "drawPolyline" + <td colspan="2"> Draws a polyline using <em>nPoints</em> coordinates from the + <em>xPoints-array</em> and + <em>yPoints-array</em>. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>drawPolyline(...). + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> xPoints-array yPoints-array nPoints + <td> Draws a polyline consisting of <em>nPoints</em> taken from the + <a href="#dtPointsArray"><em>xPoints-array</em></a> and + <a href="#dtPointsArray"><em>yPoints-array</em></a>. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "drawRect" + <td colspan="2"> Draws a rectangle of <em>width</em> and <em>height</em>. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>drawRect(...)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> width height + <td> Draws an oval in a rectangle of <em>width</em> and + <em>height</em> pixels. If <em>width</em> and + <em>height</em> are of the same length the rectangle will be a square. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "drawRoundRect" + <td colspan="2"> Draws a round rectangle of <em>width</em> and <em>height</em> pixels. The + corners get rounded according to <em>arcWidth</em> and <em>arcHeight</em> pixels. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>drawRoundRect(...)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> width height arcWidth arcHeight + <td> Draws an oval in a rectangle of <em>width</em> and + <em>height</em> pixels where the corners are rounded using + <em>arcWidth</em> and <em>arcHeight</em> pixels. + If <em>width</em>, <em>height</em>, <em>arcWidth</em> and <em>arcHeight</em> + are of the same length the round rectangle will be in effect a circle. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "drawString" + <td colspan="2"> Draws a string (text). + + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>drawString(...)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> string + <td> <em>string</em> (text) that gets drawn. + + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "fill3DRect" + <td colspan="2"> Fills a rectangle with 3D appearance (raised or sunken). + + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>fill3DRect(...)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> width height raised + <td> <em>width</em> and <em>height</em> in pixel of the rectangle, + <em>raised</em> is either set to <em>.true</em> for raised or to <em>.false</em> + for sunken). + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "fillArc" + <td colspan="2"> Fills an arc . + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>fillArc(...)()</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> width height startAngle arcAngle + <td> <em>width</em> and <em>height</em> in pixel of the rectangle, + <em>startAngle</em> in degrees (0 is the 3 o'clock position), <em>arcAngle</em> + angular extend in degrees relative to <em>startAngle</em>. + + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "fillOval" + <td colspan="2"> Fills an oval. + + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>fillOval()</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> width height + <td> Fills an oval in a rectangle of <em>width</em> and + <em>height</em> pixels. If <em>width</em> and + <em>height</em> are of the same length the oval will be a circle. + + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command" id="cmdFillPolygon"> "fillPolygon" + <td colspan="2"> Fills a polygon using <em>nPoints</em> coordinates from the <em>xPoints-array<em> array + and </em>yPoints-array</em>. + <br><em>Note:</em> The definition list above documents how these arrays can be supplied to the command + handler. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>fillPolygon(...). + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> xPoints-array yPoints-array nPoints + <td> Fills a polygon consisting of <em>nPoints</em> taken from the + <a href="#dtPointsArray"><em>xPoints-array</em></a> and + <a href="#dtPointsArray"><em>yPoints-array</em></a>. + If the endpoint is not + the same coordinate, the polygon gets closed by filling a line from the + first to the last point. + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "fillRect" + <td colspan="2"> Fills a rectangle of <em>width</em> and <em>height</em>. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>fillRect(...)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> width height + <td> Fills an oval in a rectangle of <em>width</em> and + <em>height</em> pixels. If <em>width</em> and + <em>height</em> are of the same length the rectangle will be a square. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "fillRoundRect" + <td colspan="2"> Fills a round rectangle of <em>width</em> and <em>height</em> pixels. The + corners get rounded according to <em>arcWidth</em> and <em>arcHeight</em> pixels. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>fillRoundRect(...)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> width height arcWidth arcHeight + <td> Fills an oval in a rectangle of <em>width</em> and + <em>height</em> pixels where the corners are rounded using + <em>arcWidth</em> and <em>arcHeight</em> pixels. + If <em>width</em>, <em>height</em>, <em>arcWidth</em> and <em>arcHeight</em> + are of the same length the round rectangle will be in effect a circle. + + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "font" + <td colspan="2"> Query, get and set, define and set the font. With no arguments + returns the current Java font which can be referred to via the Rexx variable + <em>RC</em> upon return from this command. + <br>Supplying only the <em>fontNickName</em> argument will load the font from the + internal register and use it until it gets changed again. + <br>Supplying in addition the <em>fotnName</em>, a <em>java.awt.Font</em> + gets loaded from the system, registered with the supplied <em>fontNickName</em> + and then used for setting the new font. + + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + methods <em>getFont()</em>, <em>setFont(...)</em>, as well as the Java class + <em>java.awt.Font</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> fontNickName + <td> <em>fontNickName</em> gets uppercased and is used to look up the internal + font registry for the denoted font which should be used from now on and gets + returned via the Rexx variable <em>RC</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> fontNickName fontName + <td> This command loads a font with the given <em>fontName</em> from the system + using the current <em>fontSize</em> and <em>fontStyle</em>, + stores it in the font registry using the supplied <em>fontNickName</em> in + uppercase and returns it via the Rexx variable <em>RC</em>. + <br>The following logical font names are always available on all operating + systems and can be used to set the <em>fontName</em> argument: + <em>"Dialog"</em>, <em>"DialogInput"</em>, + <em>"Monospaced"</em>, <em>"SansSerif"</em> and + <em>"Serif"</em>. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "fontSize" + <td colspan="2"> Queries or sets the font size to be used when loading new fonts. + With no arguments returns the current font size which can be referred to via + the Rexx variable <em>RC</em> upon return from this command. + <br>Cf. the Java documentation for the Java class <em>Font</em> and the + constructors as well as the method <em>getSize()</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> size + <td> <em>size</em> that gets used when loading a new font, defaults to <em>12</em>. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "fontStyle" + <td colspan="2"> Queries or sets the font style to be used when loading new fonts. + With no arguments returns the current font size which can be referred to via + the Rexx variable <em>RC</em> upon return from this command. + <br>Cf. the Java documentation for the Java class <em>Font</em> and the + constructors as well as the method <em>getStyle()</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> style + <td> <em>style</em> a number or symbolic name that gets used when loading a + new font, defaults to <em>0</em> (<em>PLAIN</em>). Additional font style + values are: <em>1</em> (<em>BOLD</em>), + <em>2</em> (<em>ITALIC</em>) and + <em>3</em> (<em>BOLD</em> and <em>ITALIC</em>). + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "GC" + <td colspan="2"> Queries the <em>GC</em> object (an instance of the class + <em>Graphics[2D]</em>) and returns it via the Rexx variable <em>RC</em> + upon return from this command. One can then use all <em>Graphics[2D]</em> methods + from an ooRexx program directly. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em>. + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command" id="cmdGetState"> "getState" + <td colspan="2"> Creates an ooRexx <em>StringTable</em> object, inserts state + information and returns it via the Rexx variable <em>RC</em>. The + following entries are available: + <ul> + <li><em>colors</em> (a <em>java.util.HashMap</em>) + <li><em>currAngle</em> + <li><em>currFontSize</em> + <li><em>currFontStyle</em> + <li><em>currVisible</em> + <li><em>currWinUpdate</em> + <li><em>currX</em> + <li><em>currY</em> + <li><em>fonts</em> (a <em>java.util.HashMap</em>) + <li><em>GC</em> + <li><em>gc.background</em> + <li><em>gc.color</em> + <li><em>gc.composite</em> + <li><em>gc.font</em> + <li><em>gc.paint</em> + <li><em>gc.stroke</em> + <li><em>gcStack</em> (a <em>java.util.ArrayDeque</em>) + <li><em>gradiantPaints</em> (a <em>java.util.HashMap</em>) + <li><em>image</em> + <li><em>imageHeight</em> + <li><em>imageStack</em> (a <em>java.util.ArrayDeque</em>) + <li><em>imageType</em> + <li><em>imageWidth</em> + <li><em>images</em> (a <em>java.util.HashMap</em>) + <li><em>prefImageType</em> + <li><em>printPosX</em> + <li><em>printPosY</em> + <li><em>printScaleToPage</em> + <li><em>printScaleX</em> + <li><em>printScaleY</em> + <li><em>strokes</em> (a <em>java.util.HashMap</em>) + </ul> + + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> rexxVariableName + <td> <em>rexxVariableName</em> the Rexx variable name to store the ooRexx + <em>StringTable</em> object in the command context additionally. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "goto" <br> "pos" + <td colspan="2"> Queries or sets <em>currX</em> and <em>currX</em> in the current image. + If no argument returns the blank delimited values of <em>currX</em> and <em>currX</em> + via the Rexx variable <em>RC</em> upon return from this command. + <br>The command name <em>pos</em> is an alias, a synonym for this command. + + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> x [y] + <td> <em>x</em> gets used to set <em>currX</em> and <em>y</em> to set <em>currY</em>. + If the argument <em>y</em> is omitted, <em>x</em> is used to set <em>currY</em> as well. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "gradientPaint" + <td colspan="2"> Query, get and set, define and set the gradientPaint. With no arguments + returns the current Java <em>gradientPaint</em> which can be referred to via the Rexx variable + <em>RC</em> upon return from this command. + <br>Supplying only the <em>gradientPaintNickName</em> argument will load the <em>gradientPaint</em> + from the internal register and use it. + <br>Supplying additional arguments will cause a new gradient paint to be created, + registered with the supplied <em>gradientPaintNickName</em> and then used for + setting the current <em>paint</em> value to the new gradientPaint. + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + methods <em>getPaint()</em>, <em>setPaint(...)</em>, as well as the Java class + <em>java.awt.GradientPaint</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> gradientPaintNickName + <td> <em>gradientPaintNickName</em> gets uppercased and is used to look up the internal + gradientPaint registry for the denoted gradient paint which should be used from now + on and gets returned via the Rexx variable <em>RC</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> gradientPaintNickName x1 y1 colorName1 x2 y2 colorName2 [cyclic] + <td> This command creates a gradient paint from point <em>x1</em>,<em>y1</em> with + color <em>colroName1</em> to <em>x2</em>,<em>y2</em> with color <em>colroName2</em>. + The optional <em>cyclic</em> arguments determines whether the gradient patterns should + cycle repeatedly between the two colors. This gradientPaint will be used from now on + and gets stored in the gradientPaint registry using the supplied + <em>gradientPaintNickName</em> in uppercase and returned via the + Rexx variable <em>RC</em>. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "image" + + <td colspan="2"> Queries an <em>image</em> object (an instance of the class + <em>java.awt.image.BufferedImage</em>) and returns it via the Rexx variable + <em>RC</em> upon return from this command. + With no argument returns the current image which can be referred + to via the Rexx variable <em>RC</em> upon return from this command. + Supplying the <em>imageNickName</em> argument will load and return + the image from the internal register. + <br> One can then use all <em>BufferedImage</em> methods from an ooRexx program directly. + Cf. the Java documentation for the Java class <em>BufferedImage</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> imageNickName + <td> <em>imageNickName</em> gets uppercased and is used to look up the internal + image registry for the denoted image and gets + returned via the Rexx variable <em>RC</em>. + + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "imageSize" + <td colspan="2"> Query the image size (dimension). With no arguments returns the current image's + <em>width</em> and <em>height</em> which can be referred to via the Rexx variable + <em>RC</em> upon return from this command. + <br>Supplying the <em>imageNickName</em> argument will return the size of the image + from the internal register. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> imageNickName + <td> <em>imageNickName</em> gets uppercased and is used to look up the internal + image registry, get its size which is returned via the Rexx variable <em>RC</em>. + + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "imageType" + <td colspan="2"> Query the image type. With no arguments returns the current image's + type which can be referred to via the Rexx variable <em>RC</em> upon return from this command. + <br>Supplying the <em>imageNickName</em> argument will return the type of the image + from the internal register. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> imageNickName + <td> <em>imageNickName</em> gets uppercased and is used to look up the internal + image registry, get its type which is returned via the Rexx variable <em>RC</em>. + + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "loadImage" + <td colspan="2"> Loads an image from <em>fileName</em>, stores it with the uppercased + <em>imageNickName</em> in the internal image registry and returns the image's + size (dimension), i.e. <em>width</em> and <em>height</em> via the Rexx variable <em>RC</em>. + + <br>Cf. the Java documentation for the Java class <em>javax.imageio.ImageIO</em> and the + method <em>read(...)</em>. + + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> imageNickName fileName + <td> The <em>fileName</em> to load the image from, storing it with the uppercased + <em>imageNickName</em> in the internal image registry. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "new" + <td colspan="2"> Creates a new image. By default the <em>width</em> and the <em>height</em> are + set to <em>500</em> and the type to <em>2</em> (<em>BufferedImage.TYPE_INT_ARGB</em>). + + <br>Cf. the Java documentation for the Java class <em>java.awt.image.BufferedImage</em> and + and its constants. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> width height [type] + <td> The size is given in <em>width</em> and <em>height</em> pixels. The optional <em>type</em> + allows to override the image type. + <br><em>type</em> may have one of the following values: + + <em>TYPE_3BYTE_BGR</em> (<em>5</em>), + <em>TYPE_4BYTE_ABGR</em> (<em>6</em>), + <em>TYPE_4BYTE_ABGR_PRE</em> (<em>7</em>), + <em>TYPE_BYTE_BINARY</em> (<em>12</em>), + <em>TYPE_BYTE_GRAY</em> (<em>10</em>), + <em>TYPE_BYTE_INDEXED</em> (<em>13</em>), + <em>TYPE_CUSTOM</em> (<em>0</em>), + <em>TYPE_INT_ARGB</em> (<em>2</em>), + <em>TYPE_INT_ARGB_PRE</em> (<em>3</em>), + <em>TYPE_INT_BGR</em> (<em>4</em>), + <em>TYPE_INT_RGB</em> (<em>1</em>), + <em>TYPE_USHORT_555_RGB</em> (<em>9</em>), + <em>TYPE_USHORT_565_RGB</em> (<em>8</em>) and + <em>TYPE_USHORT_GRAY</em> (<em>11</em>). + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "paint" + <td colspan="2"> Queries or sets current paint. With no argument returns the + current <em>paint</em> value which can be referred to via the Rexx variable + <em>RC</em> upon return from this command. + + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + methods <em>getPaint()</em>, <em>setPaint(...)</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> nickName + <td> <em>nickName</em> in uppercase will be used to look up a gradientPaint and if not found + a color in the respective internal registries in this order. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "popGC" + <td colspan="2"> Disposes the current <em>GC</em> and replaces it by popping + a <em>GC</em> from the stack, thereby resetting all the graphical + configuration changes to that state and returns it + via the Rexx variable <em>RC</em>. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "popImage" + <td colspan="2"> Pops the <em>image</em> from the stack and replaces + the current image. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "preferredImageType" + <td colspan="2"> Queries or sets the preferred image type used for creating new images. + Returns the image type via the Rexx variable <em>RC</em> upon return from this command. + + <br>Cf. the Java documentation for the Java class <em>java.awt.image.BufferedImage</em> and + and its constants. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> type + <td> <em>type</em> denotes the new preferred image type + + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "printImage" + <td colspan="2"> Uses the default printer to print the image. If the <em>imageNickName</em> + is supplied, it gets uppercased and used to look it up in the image registry and prints it. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> imageNickName + <td> <em>imageNickName</em> is uppercased and used to look up the image from the internal + registry that should get printed. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "printPos" + <td colspan="2"> Sets the left upper hand corner on the page where the image should + be drawn to. This command has no effect if <em>printScaleToPage</em> was set to + <em>.true</em> (<em>0</em>). + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> x [y] + <td> <em>x</em> and <em>y</em> to define the left upperhand corner. + If the argument <em>y</em> is omitted, then <em>x</em> gets used instead. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "printScale" + <td colspan="2"> Sets the scale factor for the print page <em>x</em> and <em>y</em> axis. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> scaleX [scaleY] + <td> <em>scaleX</em> and <em>scaleY</em> to define the scale factors. + If the argument <em>scaleY</em> is omitted, then <em>scaleX</em> gets used instead. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "printScaleToPage" + <td colspan="2"> Queries or sets the value. If set to <em>.true</em>, the image + will be scaled to the printable image area such, that the entire image gets + printed proportionally. Returns the setting via the Rexx variable <em>RC</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> booleanValue + <td> <em>booleanValue</em> can be one of + <em>1</em>, + <em>".true"</em>, + <em>"true"</em>, + <em>0</em>, + <em>".false"</em> or + <em>"false"</em>. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "pushGC" + <td colspan="2"> Push the current <em>GC</em> on the stack, thereby + saving all current settings and transformations. Creates a copy of + the current <em>GC</em> and uses it from then on. + The new <em>GC</em> gets returned via the Rexx variable <em>RC</em>. + + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>create()</em>. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "pushImage" + <td colspan="2"> Pushes a copy of the current <em>image</em> to the stack and + optionally stores it with an <em>imageNickName</em> in the internal registry for + later references by <em>imageNickName</em>. The image copy gets returned via the + Rexx variable <em>RC</em>. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> imageNickName + <td> Optional, <em>imageNickName</em> will be uppercased and used to store the image + in the internal image registry. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "reset" <br> "clear" + <td colspan="2"> Resets the following runtime values: + <ul> + <li><em>colors</em>: the <em>java.util.HashMap</em> gets emptied except for the constant colors + defined in the <em>java.awt.Color</em> class + + <li><em>currAngle</em>: <em>0</em> + <li><em>currFontSize</em>: <em>12</em> + <li><em>currFontStyle</em>: <em>0</em> + <li><em>currX</em>: <em>0</em> + <li><em>currY</em>: <em>0</em> + <li><em>fonts</em>: the <em>java.util.HashMap</em> gets emptied + <li><em>gcStack</em>: the <em>java.util.ArrayDeque</em> gets emptied + <li><em>gradiantPaints</em>: the <em>java.util.HashMap</em> gets emptied + <li><em>imageStack</em>: the <em>java.util.ArrayDeque</em> gets emptied + <li><em>images</em>: the <em>java.util.HashMap</em> gets emptied + <li><em>printPosX</em>: <em>0</em> + <li><em>printPosY</em>: <em>0</em> + <li><em>printScaleToPage</em>: <em>.false</em> + <li><em>printScaleX</em>: <em>1</em> + <li><em>printScaleY</em>: <em>1</em> + <li><em>strokes</em>: the <em>java.util.HashMap</em> gets emptied + </ul> + + The command name <em>clear</em> is an alias, a synonym for this command. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> xyz + <td> <em>xyz</em> position on the x-axis. + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "rotate" + <td colspan="2"> Queries or rotates the image. + + <br>Cf. the Java documentation for the Java class <em>Graphics[2D]</em> and the + method <em>rotate(...)</em>. Note: this command converts the supplied degrees (<em>0</em> + to <em>360</em>) to radians and supplies it to the Java method. + + <tr class="ArgumentRowColor"><td><!-- table row --> + <td> + <td class="argument"> theta [x y] + <td> <em>theta</em> is the amount of degrees the image should be rotated. If the + optional arguments <em>x</em> and <em>y</em> are supplied then a + <em>"translate x y"</em> will be invoked before rotating, followed + by <em>"translate -x -y"</em>. + + + + <!-- -------------------------------------------------------- --> + <tr class="CommandRowColumn"><!-- table row --> + <td class="cmdNr"> + <td class="command"> "saveImage" + <td colspan="2"> Saves the current image to a file. + If the saving of the image was successful <em>1</em> (<em>.true</em>) gets returned via... [truncated message content] |
From: <or...@us...> - 2022-10-03 12:44:12
|
Revision: 998 http://sourceforge.net/p/bsf4oorexx/code/998 Author: orexx Date: 2022-10-03 12:44:10 +0000 (Mon, 03 Oct 2022) Log Message: ----------- Fix missing dots. Modified Paths: -------------- branches/850/samples/1-130_JDOR_rotate.rxj branches/850/samples/1-150_JDOR_string_circle.rxj branches/850/samples/1-160_JDOR_getState.rxj branches/850/samples/1-170_JDOR_lineHeight.rxj Modified: branches/850/samples/1-130_JDOR_rotate.rxj =================================================================== --- branches/850/samples/1-130_JDOR_rotate.rxj 2022-10-03 12:07:46 UTC (rev 997) +++ branches/850/samples/1-130_JDOR_rotate.rxj 2022-10-03 12:44:10 UTC (rev 998) @@ -7,7 +7,7 @@ Purpose: Demonstrates how to use JDOR commands to draw rectangles employing translation (moving the origin 0,0 around) and - rotation + rotation. Date: 2022-10-03 Modified: branches/850/samples/1-150_JDOR_string_circle.rxj =================================================================== --- branches/850/samples/1-150_JDOR_string_circle.rxj 2022-10-03 12:07:46 UTC (rev 997) +++ branches/850/samples/1-150_JDOR_string_circle.rxj 2022-10-03 12:44:10 UTC (rev 998) @@ -5,7 +5,7 @@ "rexxj 1-150_JDOR_string_circle.rxj" (Windows) "rexxj.sh 1-150_JDOR_string_circle.rxj" (Unix) - Purpose: Demonstrates the use of the rotate command to draw strings in a circle + Purpose: Demonstrates the use of the rotate command to draw strings in a circle. Date: 2022-10-03 Modified: branches/850/samples/1-160_JDOR_getState.rxj =================================================================== --- branches/850/samples/1-160_JDOR_getState.rxj 2022-10-03 12:07:46 UTC (rev 997) +++ branches/850/samples/1-160_JDOR_getState.rxj 2022-10-03 12:44:10 UTC (rev 998) @@ -6,7 +6,7 @@ "rexxj.sh 1-160_JDOR_getState.rxj" (Unix) Purpose: Demonstrates the use of the getState command and interacting - with return values via the RC Rexx variable + with return values via the RC Rexx variable. Date: 2022-10-03 Modified: branches/850/samples/1-170_JDOR_lineHeight.rxj =================================================================== --- branches/850/samples/1-170_JDOR_lineHeight.rxj 2022-10-03 12:07:46 UTC (rev 997) +++ branches/850/samples/1-170_JDOR_lineHeight.rxj 2022-10-03 12:44:10 UTC (rev 998) @@ -7,7 +7,7 @@ Purpose: Demonstrates the use of the command font to fetch and query the size of it in order to calculate the necessary line height to draw multiple - strings with the same line height + strings with the same line height. Date: 2022-10-03 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <or...@us...> - 2022-10-03 12:07:47
|
Revision: 997 http://sourceforge.net/p/bsf4oorexx/code/997 Author: orexx Date: 2022-10-03 12:07:46 +0000 (Mon, 03 Oct 2022) Log Message: ----------- 20221003 Add sample to list installed font families. Added Paths: ----------- branches/850/samples/1-200_listFonts.rxj Added: branches/850/samples/1-200_listFonts.rxj =================================================================== --- branches/850/samples/1-200_listFonts.rxj (rev 0) +++ branches/850/samples/1-200_listFonts.rxj 2022-10-03 12:07:46 UTC (rev 997) @@ -0,0 +1,47 @@ +#!/usr/bin/env rexx +/* + Name: "1-200_listFonts.rxj" + Invoke: "rexx 1-200_listFonts.rxj" + "rexxj 1-200_listFonts.rxj" (Windows) + "rexxj.sh 1-200_listFonts.rxj" (Unix) + + Purpose: Lists all font families installed on the system. + + Date: 2022-10-03 + + Author: Rony G. Flatscher, WU Vienna + + Changes: -- + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- +*/ + +clzGE=bsf.loadClass("java.awt.GraphicsEnvironment") /* load the Java class */ +localGE=clzGE~getLocalGraphicsEnvironment /* invoke the static method "getLocalGraphicsEnvironment" */ +allFontFamilies=localGE~getAvailableFontFamilyNames /* invoke the method "getAvailableFontFamilyNames" */ +do counter c ff over allFontFamilies /* iterate over all elements of the received "allFontFamilies" Java array */ + say c~right(3)":" ff /* display the font family name */ +end +say +say "you have a total of" pp(c) "fonts installed on your system!" + +::requires BSF.CLS -- get ooRexx-Java bridge \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <or...@us...> - 2022-10-03 12:06:42
|
Revision: 996 http://sourceforge.net/p/bsf4oorexx/code/996 Author: orexx Date: 2022-10-03 12:06:28 +0000 (Mon, 03 Oct 2022) Log Message: ----------- 20221003 JDOR samples. Modified Paths: -------------- branches/850/samples/index.html Added Paths: ----------- branches/850/samples/1-120_JDOR_bw.rxj branches/850/samples/1-120_JDOR_color_text.rxj branches/850/samples/1-130_JDOR_rotate.rxj branches/850/samples/1-140_JDOR_images.rxj branches/850/samples/1-140_JDOR_images_reversed.rxj branches/850/samples/1-150_JDOR_string_circle.rxj branches/850/samples/1-160_JDOR_getState.rxj branches/850/samples/1-170_JDOR_lineHeight.rxj branches/850/samples/1-180_JDOR_sandGlass.rxj branches/850/samples/1-180_JDOR_sandGlass_log.rxj branches/850/samples/1-180_JDOR_sandGlass_replay_log.rxj branches/850/samples/2-110_JDOR_listShowPrintFonts.rxj branches/850/samples/3-100_create_bitmap_JDOR_commands.rxj branches/850/samples/jdor.cls Added: branches/850/samples/1-120_JDOR_bw.rxj =================================================================== --- branches/850/samples/1-120_JDOR_bw.rxj (rev 0) +++ branches/850/samples/1-120_JDOR_bw.rxj 2022-10-03 12:06:28 UTC (rev 996) @@ -0,0 +1,57 @@ +#!/usr/bin/env rexx +/* + Name: "1-120_JDOR_bw.rxj" + Invoke: "rexx 1-120_JDOR_bw.rxj" + "rexxj 1-120_JDOR_bw.rxj" (Windows) + "rexxj.sh 1-120_JDOR_bw.rxj" (Unix) + + Purpose: Demonstrates how to use JDOR commands to draw a cross, a string (text) and + superimpose a filled rectangle on it using a single (black) color. + + Date: 2022-10-03 + + Author: Rony G. Flatscher, WU Vienna + + Changes: -- + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- +*/ + +call jdor.cls -- makes routine addJdorHandler([environmentName]) available +call addJdorHandler -- load and add the Java Rexx command handler, default name: JDOR +address jdor -- set default environment to JDOR + +new 300 500 -- create new bitmap +winShow -- show frame + -- draw two lines forming a big X +drawLine 300 500 -- currX=0, currY=0 +goto 300 0 -- currX=300, currY=0 +drawLine 0 500 + -- draw a rectangle at the center of the bitmap +goto (300-50)/2 (500-50)/2 +fillRect 50 50 +drawRect 50 50 + -- draw a test at the lower half of the bitmap +goto 50 450 +drawString "Hello, world via JDOR ..." +sleep 3 -- sleep for three seconds +-- say "press enter to end.";parse pull \ No newline at end of file Added: branches/850/samples/1-120_JDOR_color_text.rxj =================================================================== --- branches/850/samples/1-120_JDOR_color_text.rxj (rev 0) +++ branches/850/samples/1-120_JDOR_color_text.rxj 2022-10-03 12:06:28 UTC (rev 996) @@ -0,0 +1,63 @@ +#!/usr/bin/env rexx +/* + Name: "1-120_JDOR_color_text.rxj" + Invoke: "rexx 1-120_JDOR_color_text.rxj" + "rexxj 1-120_JDOR_color_text.rxj" + "rexxj.sh 1-120_JDOR_color_text.rxj" + + Purpose: Demonstrates how to use JDOR commands to draw a cross, a string (text) and + superimpose a filled rectangle on it using different colors. + + Date: 2022-10-03 + + Author: Rony G. Flatscher, WU Vienna + + Changes: -- + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- +*/ + +call addJdorHandler -- load and add the Java Rexx command handler, using default name: JDOR +address jdor -- set default environment to JDOR + +new 300 500 -- create new bitmap +winShow -- show frame + -- draw two lines forming a big X +drawLine 300 500 -- currX=0, currY=0 +goto 300 0 -- currX=300, currY=0 +color red +drawLine 0 500 + -- draw a rectangle at the center of the bitmap +goto (300-50)/2 (500-50)/2 +color green +fillRect 50 50 + +stroke str3 3 -- set line stroke to 3 points +color blue +drawRect 50 50 + -- draw a test at the lower half of the bitmap +goto 50 450 +color somePurple 127 46 111 +drawString "Hello, world via JDOR ..." +sleep 3 -- sleep for three seconds +-- say "press enter to end.";parse pull +::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available Added: branches/850/samples/1-130_JDOR_rotate.rxj =================================================================== --- branches/850/samples/1-130_JDOR_rotate.rxj (rev 0) +++ branches/850/samples/1-130_JDOR_rotate.rxj 2022-10-03 12:06:28 UTC (rev 996) @@ -0,0 +1,67 @@ +#!/usr/bin/env rexx +/* + Name: "1-130_JDOR_rotate.rxj" + Invoke: "rexx 1-130_JDOR_rotate.rxj" + "rexxj 1-130_JDOR_rotate.rxj" (Windows) + "rexxj.sh 1-130_JDOR_rotate.rxj" (Unix) + + Purpose: Demonstrates how to use JDOR commands to draw rectangles + employing translation (moving the origin 0,0 around) and + rotation + + Date: 2022-10-03 + + Author: Rony G. Flatscher, WU Vienna + + Changes: -- + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- +*/ + +call addJdorHandler -- load and add the Java Rexx command handler, using default name: JDOR +address jdor -- set default environment to JDOR +new 500 500 -- create new bitmap +winShow -- show frame + -- draw two lines forming a big X +goto 100 150 -- currX=100, currY=150 + -- define and set color, register it with the name "saddlebrown50" +color saddlebrown50 139 69 19 127 -- R,G,B,alpha=127 (50 % transparency) +fillRect 50 50 -- first fill +color blue -- set color to blue (predefined) +drawRect 50 50 -- draw border +color red -- set color to red (predefined) +drawOval 50 50 -- draw border + -- draw a rectangle at the center of the bitmap +translate 260 250 -- move origin 0,0 to (260,250) +goto 0 0 -- x=0, y=0 (effectively: x=0+260, y=0+250) +rotate 45 -- rotate by 45 degrees (clock wise starting out from 3 o'clock) +color saddlebrown50 -- use registered color named saddlebrown50 [R,G,B,alpha=127 (50 % transparency)] +fillRect 50 75 -- fill 50% transparency +fillOval 50 75 -- fill (add) 50 % transparency +color blue -- set color to blue (predefined) +drawRect 50 75 -- draw border in blue +color red -- set color to red (predefined) +drawOval 50 75 -- draw border in red +sleep 5 -- sleep for five seconds +-- say "press enter to end.";parse pull + +::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available Added: branches/850/samples/1-140_JDOR_images.rxj =================================================================== --- branches/850/samples/1-140_JDOR_images.rxj (rev 0) +++ branches/850/samples/1-140_JDOR_images.rxj 2022-10-03 12:06:28 UTC (rev 996) @@ -0,0 +1,55 @@ +#!/usr/bin/env rexx +/* + Name: "1-140_JDOR_images.rxj" + Invoke: "rexx 1-140_JDOR_images.rxj" + "rexxj 1-140_JDOR_images.rxj" (Windows) + "rexxj.sh 1-140_JDOR_images.rxj" (Unix) + + Purpose: Demonstrates the use of the commands loadImage and drawImage. + + Date: 2022-10-03 + + Author: Rony G. Flatscher, WU Vienna + + Changes: -- + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- +*/ + +call addJdorHandler -- load and add the Java Rexx command handler, using default name: JDOR +address jdor -- set default environment to JDOR + +new 500 500 -- create new bitmap +winShow -- show frame +loadImage b4r_logo bsf4oorexx_256.png +drawImage b4r_logo 50 50 +goto 200 200 +loadImage orx_logo oorexx_256.png +drawImage orx_logo 75 75 +goto 400 400 +say "rc:" rc -- rc contains the return value +loadImage ooo_logo oorexx4ooo_256.png +drawImage ooo_logo 100 100 +sleep 5 -- sleep for five seconds +-- say "press enter to end.";parse pull + +::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available Added: branches/850/samples/1-140_JDOR_images_reversed.rxj =================================================================== --- branches/850/samples/1-140_JDOR_images_reversed.rxj (rev 0) +++ branches/850/samples/1-140_JDOR_images_reversed.rxj 2022-10-03 12:06:28 UTC (rev 996) @@ -0,0 +1,57 @@ +#!/usr/bin/env rexx +/* + Name: "1-140_JDOR_images_reversed.rxj" + Invoke: "rexx 1-140_JDOR_images_reversed.rxj" + "rexxj 1-140_JDOR_images_reversed.rxj" (Windows) + "rexxj.sh 1-140_JDOR_images_reversed.rxj" (Unix) + + Purpose: Demonstrate the use of the scale command to reverse the y-axis, + causing the co-ordinates and images to be reversed. + + Date: 2022-10-03 + + Author: Rony G. Flatscher, WU Vienna + + Changes: -- + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- +*/ + +call addJdorHandler -- load and add the Java Rexx command handler, using default name: JDOR +address jdor -- set default environment to JDOR +new 500 500 -- create new bitmap +winShow -- show frame +translate 0 500 -- move origin (0,0) to lower left hand corner +"scale 1 -1" -- flip y-axis (positive y grow up, however ...) +loadImage b4r_logo bsf4oorexx_256.png +drawImage b4r_logo 50 50 +goto 200 200 +loadImage orx_logo oorexx_256.png +drawImage orx_logo 75 75 +goto 400 400 +say "rc:" rc -- rc contains the return value +loadImage ooo_logo oorexx4ooo_256.png +drawImage ooo_logo 100 100 +sleep 5 -- sleep for five seconds +-- say "press enter to end.";parse pull + +::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available Added: branches/850/samples/1-150_JDOR_string_circle.rxj =================================================================== --- branches/850/samples/1-150_JDOR_string_circle.rxj (rev 0) +++ branches/850/samples/1-150_JDOR_string_circle.rxj 2022-10-03 12:06:28 UTC (rev 996) @@ -0,0 +1,67 @@ +#!/usr/bin/env rexx +/* + Name: "1-150_JDOR_string_circle.rxj" + Invoke: "rexx 1-150_JDOR_string_circle.rxj" + "rexxj 1-150_JDOR_string_circle.rxj" (Windows) + "rexxj.sh 1-150_JDOR_string_circle.rxj" (Unix) + + Purpose: Demonstrates the use of the rotate command to draw strings in a circle + + Date: 2022-10-03 + + Author: Rony G. Flatscher, WU Vienna + + Changes: -- + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- +*/ + +call addJdorHandler -- load and add the Java Rexx command handler, using default name: JDOR +address jdor -- set default environment to JDOR +winShow -- will implicitly create a 500x500 bitmap +goto 450 450 +loadImage orx oorexx_256.png +drawImage orx 50 50 +color blue +goto 0 20 +drawString "Hello at:" .dateTime~new +goto +translate 250 250 -- move 0,0 to center +color red +fontstyle 3 -- bold=1 + italic=2 +fontsize 18 -- size=18 +font serif1 "Serif" -- can be: "Dialog", "DialogInput", "Serif", "SansSerif", "Monospaced" +drawString "ooRexx at:" .dateTime~new +fontstyle 0 -- normal +fontsize 14 -- size=14 +font mono "Monospaced" +goto 10 0 -- currX=10, currY=0 +angle=30 +do i=2 to 360/angle + rotate angle -- rotates entire image + drawString "ooRexx at:" .dateTime~new -- now draw + if random(0,1) then do; color red; font serif1; end + else do; "color gray"; "font mono" ; end +end +sleep 5 -- sleep for five seconds +-- say "press enter to end.";parse pull +::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available \ No newline at end of file Added: branches/850/samples/1-160_JDOR_getState.rxj =================================================================== --- branches/850/samples/1-160_JDOR_getState.rxj (rev 0) +++ branches/850/samples/1-160_JDOR_getState.rxj 2022-10-03 12:06:28 UTC (rev 996) @@ -0,0 +1,67 @@ +#!/usr/bin/env rexx +/* + Name: "1-160_JDOR_getState.rxj" + Invoke: "rexx 1-160_JDOR_getState.rxj" + "rexxj 1-160_JDOR_getState.rxj" (Windows) + "rexxj.sh 1-160_JDOR_getState.rxj" (Unix) + + Purpose: Demonstrates the use of the getState command and interacting + with return values via the RC Rexx variable + + Date: 2022-10-03 + + Author: Rony G. Flatscher, WU Vienna + + Changes: -- + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- +*/ + +call addJdorHandler -- load and add the Java Rexx command handler, using default name: JDOR +address jdor -- set default environment to JDOR +new 300 500 -- create new bitmap +winShow -- show frame + -- draw two lines forming a big X +drawLine 300 500 -- from currX=0, currY=0 to x2=300 y2=500 +pos 300 0 -- alias "goto": currX=300, currY=0 +color red +drawLine 0 500 -- from currX=300, currY=0 to x2=0 y2=500 + -- draw a rectangle at the center of the bitmap +goto (300-50)/2 (500-50)/2 -- currX= +say "rc:" pp(rc) ".rs="pp(.rs) +color saddlebrown50 139 69 19 127 -- R,G,B,alpha=127 (50 % transparency) +fillRect 50 50 +stroke str3 3 -- set line stroke to 3 points +color green +drawRect 50 50 -- draw frame + +-- get current state +say "a) var(""currState""):" pp(var("currState")) -- does not exist, returns: 0 +"getState currState" -- quote, result should be saved to variable 'currState' +say "b) var(""currState""):" pp(var("currState")) -- now exists, returns: 1 +say "currState:" pp(currState) "currState~items:" pp(currState~items) +do counter c idx over currState~allIndexes~sort + say " " right(c,2)":" left(pp(idx),20,".") pp(currState[idx]) +end +sleep 5 -- sleep for five seconds +-- say "press enter to end.";parse pull +::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available \ No newline at end of file Added: branches/850/samples/1-170_JDOR_lineHeight.rxj =================================================================== --- branches/850/samples/1-170_JDOR_lineHeight.rxj (rev 0) +++ branches/850/samples/1-170_JDOR_lineHeight.rxj 2022-10-03 12:06:28 UTC (rev 996) @@ -0,0 +1,80 @@ +#!/usr/bin/env rexx +/* + Name: "1-170_JDOR_lineHeight.rxj" + Invoke: "rexx 1-170_JDOR_lineHeight.rxj" + "rexxj 1-170_JDOR_lineHeight.rxj" (Windows) + "rexxj.sh 1-170_JDOR_lineHeight.rxj" (Unix) + + Purpose: Demonstrates the use of the command font to fetch and query the size + of it in order to calculate the necessary line height to draw multiple + strings with the same line height + + Date: 2022-10-03 + + Author: Rony G. Flatscher, WU Vienna + + Changes: -- + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- +*/ + +call addJdorHandler -- load and add the Java Rexx command handler, default name: JDOR +address jdor -- set default environment to the JDOR command handler +width =220 -- define width of image in pixels (there are 72 px to an inch) +height=250 -- define height of image in pixels (there are 72 px to an inch) +new width height -- create new bitmap with currX=0, currY=0, width=220, height=250 +winShow -- show frame on screen + -- draw two lines forming a big X +drawLine width height -- from currX=0, currY=0 +color red -- set the color to red (preregistered with nickname "RED") +goto width 0 -- currX=220, currY=0 +say "--> rc="pp(rc) -- RC refers to the previous command's result: "220 0" (currX=220, currY=0) +drawLine 0 height -- from currX=250, currY=0 + -- draw a rectangle at the center of the bitmap +len = 50 -- drawing a rectangle with each side being 50 px (a square) +goto (width-len)/2 (height-len)/2 -- go to the center minus half of the square's side lengths +color green -- set color to green (preregistered with nickname "GREEN") +fillRect len len -- fill the square with the green color +stroke str3 3 -- set line stroke to 3 points width, store it with nickname "STR3" +color blue -- set color to blue (preregistered with nickname "BLUE") +drawRect len len -- draw the frame with the blue color + -- draw a string (text) at the lower half of the bitmap +color somePurple 127 46 111 -- define a custom RGB color, store it with nickname "SOMEPURPLE" +say "--> rc="pp(rc) -- show result from command (the Java oclor object) +say " rc~toString:" pp(rc~toString) -- shows the RGB intensities of the color +newY=height-40 + -- define an array of three strings +font -- get the current font +say "rc~toString:" pp(rc~toString) -- show the current font +size=rc~size -- get the size from the current font (uses method getSize() of java.awt.Font) +lineHeight = size + 3 -- line height plus 3 px interline padding +say "lineHeight: " pp(lineHeight) -- show line height +text=("Hello, Rexx world ...", "... from JDOR ...", "(Rexx command handler)") -- array of 3 strings +do counter c i=0 to 30 by lineHeight -- iterate over array of strings + goto 50 (newY+i) -- set position + drawString text[c] -- draw the string +end + -- save the current image +saveImage "1-170_JDOR_lineHeight.png" -- save image to file "1-170_JDOR_lineHeight.png" +sleep 3.123 -- sleep for 3.123 seconds + +::requires "jdor.cls" -- Rexx package that defines the public routine addJdorHandler() Added: branches/850/samples/1-180_JDOR_sandGlass.rxj =================================================================== --- branches/850/samples/1-180_JDOR_sandGlass.rxj (rev 0) +++ branches/850/samples/1-180_JDOR_sandGlass.rxj 2022-10-03 12:06:28 UTC (rev 996) @@ -0,0 +1,66 @@ +#!/usr/bin/env rexx +/* + Name: "1-180_JDOR_sandGlass.rxj" + Invoke: "rexx 1-180_JDOR_sandGlass.rxj" + "rexxj 1-180_JDOR_sandGlass.rxj" (Windows) + "rexxj.sh 1-180_JDOR_sandGlass.rxj" (Unix) + + Purpose: Demonstrates the use of JDOR for drawing a sand glass using different + colors and strokes. + + Date: 2022-10-03 + + Author: Rony G. Flatscher, WU Vienna + + Changes: -- + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- +*/ + +call addJdorHandler -- load and add the Java Rexx command handler, using default name: JDOR +address jdor -- set default environment to JDOR +stroke st5 5 -- define stroke of 5 pts +stroke st3 3 -- define stroke of 3 pts +stroke st1 1 -- define stroke of 1 pt +color saddlebrown50 139 69 19 127 -- R,G,B,alpha=127 (~50 % transparency) +color green20 0 255 0 50 -- R,G,B,alpha=127 (~20 % transparency) +strokes=st1, st3, st5 -- Rexx array of stroke nick names +colors =black, saddlebrown50, green20 -- Rexx array of color nick names +width=500 +height=500 +new width height -- create new bitmap +winShow -- show frame +do i=1 to 3 + m=50+(i-1)*50 -- margin + w = width-m + h = height-m + color colors[i] + stroke strokes[i] + goto m m; drawLine w m + goto w m; drawLine m h + goto m h; drawLine w h + goto w h; drawLine m m +end +sleep 3 -- sleep for three seconds +-- say 'hit enter to continue...'; parse pull . + +::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available \ No newline at end of file Added: branches/850/samples/1-180_JDOR_sandGlass_log.rxj =================================================================== --- branches/850/samples/1-180_JDOR_sandGlass_log.rxj (rev 0) +++ branches/850/samples/1-180_JDOR_sandGlass_log.rxj 2022-10-03 12:06:28 UTC (rev 996) @@ -0,0 +1,71 @@ +#!/usr/bin/env rexx +/* + Name: "1-180_JDOR_sandGlass_log.rxj" + Invoke: "rexx 1-180_JDOR_sandGlass_log.rxj" + "rexxj 1-180_JDOR_sandGlass_log.rxj" (Windows) + "rexxj.sh 1-180_JDOR_sandGlass_log.rxj" (Unix) + + Purpose: Demonstrates the use of output redirection saved to a file + named "1-180_JDOR_sandGlass_commands.log" (a text file) in + order to create a log (recording) of all JDOR commands in + canonized form. + + Date: 2022-10-03 + + Author: Rony G. Flatscher, WU Vienna + + Changes: -- + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- +*/ + +call addJdorHandler -- load and add the Java Rexx command handler, using default name: JDOR + +s=.stream~new("1-180_JDOR_sandGlass_commands.log")~~open("replace") +address jdor with output using (s) -- redirect output: commands will be logged in canonized form +"stroke st15 15" -- define and set stroke (15 pixels wide) +"stroke st05 5" -- define and set stroke (5 pixels wide) +"stroke st01 1" -- define and set stroke (1 pixel wide) +"color saddlebrown50 139 69 19 127" -- R,G,B,alpha=127 (~50 % transparency) +"color green20 0 255 0 50" -- R,G,B,alpha= 50 (~20 % transparency) +strokes=st01, st05, st15 -- define Rexx array of defined strokes +colors =black, saddlebrown50, green20 -- define Rexx array of defined colors +width =500 +height=500 +"NEW" width height -- create new bitmap +"winshow" -- show frame +do i=1 to 3 + m=50+(i-1)*50 -- increase margin + w = width-m + h = height-m + "color" colors[i] -- set defined color + "STROKE" strokes[i] -- set defined stroke + "PoS" m m; "DRAWLINE" w m -- sets the x and y position + "GOTO" w m; "drawline" m h -- GOTO is a synonym for POS + "pos" m h; "DRAWLINE" w h -- sets the x and y position + "GOTO" w h; "drawline" m m -- GOTO is a synonym for POS +end +s~close +saveImage "1-180_JDOR_sandGlass.png" -- "png" allows for ARGB (RGB colors with alpha (transparency9) +sleep 3 -- sleep for three seconds + +::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available \ No newline at end of file Added: branches/850/samples/1-180_JDOR_sandGlass_replay_log.rxj =================================================================== --- branches/850/samples/1-180_JDOR_sandGlass_replay_log.rxj (rev 0) +++ branches/850/samples/1-180_JDOR_sandGlass_replay_log.rxj 2022-10-03 12:06:28 UTC (rev 996) @@ -0,0 +1,49 @@ +#!/usr/bin/env rexx +/* + Name: "1-180_JDOR_sandGlass_replay_log.rxj" + Invoke: "rexx 1-180_JDOR_sandGlass_replay_log.rxj" + "rexxj 1-180_JDOR_sandGlass_replay_log.rxj" (Windows) + "rexxj.sh 1-180_JDOR_sandGlass_replay_log.rxj" (Unix) + + Purpose: Demonstrates the use of input redirection from a file + named "1-180_JDOR_sandGlass_commands.log" (a text file) + which contains the JDOR commands to be executed (replayed). + + Needs: The logfile that gets created by running "1-180_JDOR_sandGlass_log.rxj" + as it contains the commands to execute (replay). + + Date: 2022-10-03 + + Author: Rony G. Flatscher, WU Vienna + + Changes: -- + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- +*/ + +call addJdorHandler -- load and add the Java Rexx command handler, default name: JDOR + +s=.stream~new("1-180_JDOR_sandGlass_commands.log")~~open("read") +address jdor with input using (s) -- redirect input to file +"-- a comment" -- we send a comment comment to activate the handler + +::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available \ No newline at end of file Added: branches/850/samples/2-110_JDOR_listShowPrintFonts.rxj =================================================================== --- branches/850/samples/2-110_JDOR_listShowPrintFonts.rxj (rev 0) +++ branches/850/samples/2-110_JDOR_listShowPrintFonts.rxj 2022-10-03 12:06:28 UTC (rev 996) @@ -0,0 +1,133 @@ +#!/usr/bin/env rexx +/* + Name: "2-110_listShowPrintFonts.rxj" + Invoke: "rexx 2-110_listShowPrintFonts.rxj" + "rexxj 2-110_listShowPrintFonts.rxj" (Windows) + "rexxj.sh 2-110_listShowPrintFonts.rxj" (Unix) + + Purpose: Demonstrates the use of the JDOR commands to create visual samples + of all font families installed which can optionally printed. + Each page with the font samples gets stored as a gif bitmap. + + font to fetch and query the size + of it in order to calculate the necessary line height to draw multiple + strings with the same line height + + Date: 2022-10-03 + + Author: Rony G. Flatscher, WU Vienna + + Changes: -- + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- +*/ + +parse arg bPrint -- if user supplies 1 then print +if bPrint="" then -- no argument supplied, ask the user in a GUI +do + title = "Print Font Families Dialog" + message = "Do you wish to print the fonts?" + optionType = "YesNoCancel" -- 0=Yes, 1=No, 2=Cancel, -1=dialog closed by user + res=.bsf.dialog~dialogBox(message, title, "question", optionType) + if res=2 then exit -- cancel was pressed + bPrint=(res=0) -- if Yes, then set to .true, otherwise .false (do not print) +end +else bPrint=(bPrint=.true) -- if '1' supplied on the command line, then print + +clzGE=bsf.loadClass("java.awt.GraphicsEnvironment") /* load the Java class */ +localGE=clzGE~getLocalGraphicsEnvironment /* invoke the static method "getLocalGraphicsEnvironment" */ +allFontFamilies=localGE~getAvailableFontFamilyNames /* invoke the method "getAvailableFontFamilyNames" */ +nrItems=allFontFamilies~items -- get number of entries (Java array can be used as if it was an ooRexx array! */ + -- set values for creating images with the font samples +-- there are 72 pixels per inch +width = 800 -- two columns: first column font name, second column font sample +-- there are 72 pixels per inch +height = trunc(12.5*72+10) -- plus additional 10 px margin +lineHeight=15 -- line height (includes padding) +lines = trunc(height/lineHeight) -- calc number of lines +xCol1 = 10 -- first column at 10px (margin) +xCol2 = xCol1+250 -- second column 250px to the right of first column +fileName="2-110_JDOR_FontSample_" -- base name for +fileType="gif" -- save as gif bitmap + + -- we use the new JDOR Rexx command handler (cf. 2022 International Rexx Symposium) +call addJdorHandler -- load and add the Java Rexx command handler, using default name: JDOR +address jdor -- set default environment to JDOR + +-- winUpdate .false -- do not update Frame (JDOR command) +do i=1 to nrItems -- iterate over all font names in the array + if i//lines=1 then -- arrived at another group of 50 + do + pageNr=i%lines -- calc current pageNr (0-based) + currLine=1 -- reset currLine + if i>1 then + do + -- winUpdate .true-- update Frame (JDOR command) + tmpFileName = fileName || (pageNr+1)"."fileType + say "saving sample to:" pp(tmpFileName) + "saveImage" tmpFileName -- write current image (JDOR command) + if bPrint then + do + printScale 0.75 -- reduce printout by 25% (JDOR command) + printImage -- print current image (JDOR command) + end + say + end + "reset" -- reset JDOR (JDOR command) + new width height TYPE_INT_RGB -- create new image, plain RGB (can be saved as bmp, gif, jpg, png) (JDOR command) + winShow -- will show the image (fun to look at) (JDOR command) + background light_gray -- make background light_gray (JDOR command) + clearRect width height -- this will use the current background color for clearing (JDOR command) + fontSize 12 -- set font size to 12 pixels (JDOR command) + font mono "Monospaced" -- load the system's 'Monotype' font, save it as 'mono' (JDOR command) + -- winUpdate .false -- do not update Frame (JDOR command) + end + fontName=allFontFamilies[i] -- get current font family name (Rexx) + y=currLine*lineHeight -- calculate y (Rexx) + goto xCol1 y -- goto x y (JDOR command) + say i~right(3)":" fontName -- show fontName on command line (Rexx) + font mono -- use already loaded monotype font (JDOR command) + drawString i~right(3,'.')":" fontName -- write font family name (JDOR command) + goto xCol2 y -- goto x y (JDOR command) + font "font"i fontName -- load and use font family font (JDOR command) + drawString "Hello world, this is ooRexx using the JDOR command handler ..." -- (JDOR command) + currLine+=1 -- increase line (Rexx) +end +if i>1 then +do + tmpFileName = fileName || (pageNr+1)"."fileType + say "saving sample to:" pp(tmpFileName) + "saveImage" tmpFileName -- (JDOR command) + -- winUpdate .true -- allow update of Frame again, show current image (JDOR command) + if bPrint then + do + printScale 0.75 -- reduce printout by 25% (JDOR command) + printImage -- print current image (JDOR command) + end +end + +say +say "you have a total of" pp(nrItems) "fonts installed on your system!" + +"sleep" 3 + .009 -- let us look at the last image for three plus 9/1000 more seconds ;) (JDOR command) + +::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available \ No newline at end of file Added: branches/850/samples/3-100_create_bitmap_JDOR_commands.rxj =================================================================== --- branches/850/samples/3-100_create_bitmap_JDOR_commands.rxj (rev 0) +++ branches/850/samples/3-100_create_bitmap_JDOR_commands.rxj 2022-10-03 12:06:28 UTC (rev 996) @@ -0,0 +1,230 @@ +#!/usr/bin/env rexx +/* + Name: "3-100_create_bitmap_JDOR.rxj" + + Invoke: "rexx 3-100_create_bitmap_JDOR.rxj" + "rexxj 3-100_create_bitmap_JDOR.rxj" (Windows) + "rexxj.sh 3-100_create_bitmap_JDOR.rxj" (Unix) + + Purpose: Demonstrate the new JDOR Rexx command handler to achieve the same + graphic as the one in "samples/3-100_create_bitmap_JDOR.rxj": + + Demonstrate how to create a bitmap (an image) with Java's Graphics2D and + draw images (bsf4oorexx_256.png, oorexx4ooo_256.png, oorexx_256.png) in + original and 50% size, how to draw lines, strings (text), polygons and + some more... The resulting bitmap gets saved in the user's home directory + under the name "3-100_create_bitmap.png" and shown using the appropraite + operating system's command. + + Date: 2022-10-03 + + Author: Rony G. Flatscher, Wien University + + Changes: -- + + last change: Revision: $Revision: 951 $ $Author: orexx $ $Date: 2022-08-10 18:06:25 +0200 (Mi., 10 Aug 2022) $ + (svn hint: use 'propset svn:keywords "Author Date Revision" filename') + + license: + + ------------------------ Apache Version 2.0 license ------------------------- + Copyright (C) 2022 Rony G. Flatscher + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ----------------------------------------------------------------------------- + +*/ + +call addJdorHandler -- load and add the Java Rexx command handler, using default name: JDOR +arrError=.array~new +address jdor with error append using (arrError) -- set default environment to JDOR + +-- the following code is equivilant to "3-100_create_bitmap.rxj" sample +width =800 +height=800 +new width height -- create image 800x800 +pushGC -- save GC state (transform, translate, shear, scale, colors ...) + +stroke defStroke 1 -- define stroke 1 pixel thick, save with nickname "defStroke" +stroke stroke3 3 -- define stroke 3 pixel thick, save with nickname "stroke3" +stroke stroke5 5 -- define stroke 5 pixel thick, save with nickname "stroke5" +stroke stroke15 15 -- define stroke 15 pixel thick, save with nickname "stroke15" + +arrDash=bsf.createJavaArrayOf("float.class", 1,5,10,5) +stroke dashedStroke 2 0 0 1 "arrDash" 0 -- note: the Rexx variable name "arrDash" must be quoted + +borderWidth=5 + + /* cf. e.g. <https://www.w3schools.com/colors/colors_names.asp> as of 2022-07-29 */ +color teal 0 128 128 -- R,G,B no alpha, hence not transparent, set and save with nickname "teal" + +color saddlebrown 139 69 19 127 -- R,G,B,alpha=127 (50 % transparency), set and save with nickname "saddleBrown" +fillRect width height + +stroke stroke5 +drawRect width-1 height-1 +stroke defStroke + +------------------------------------------------------------------------------- + -- 256x256 bitmaps +images=.array~of("oorexx_256.png", "bsf4oorexx_256.png", "oorexx4ooo_256.png") + + -- left upper corner, center, right lower corner + -- define array of x,y arrays to position the logos +positions=.array~of( (0+borderWidth,0+borderWidth), ((width-256)/2, (height-256)/2), (height-256-borderWidth, width-256-borderWidth) ) +color white -- set color + +do counter c i over positions + tmpX=i[1] + tmpY=i[2] + goto tmpX tmpY + fileName = images[c] + imageFromFile="img_"c + loadImage imageFromFile fileName + + drawImage imageFromFile + goto tmpX tmpY+10 + drawString fileName + -- drawing at 50% of size either on the right or left of the original sized picture + if c=3 then tmpX -= 256 + else tmpX += 256+128 + goto tmpX tmpY + drawImage imageFromFile tmpX+128 tmpY+128 0 0 256 256 +end +-- sleep 0.5 + +------------------------------------------------------------------------------- + -- draw a string (text) using the current (default) font +color green +text="Hello, world, it is:" .dateTime~new +goto (0+borderWidth) (height/2-20) +drawString text + -- draw a thick line underneath +stroke stroke5 +goto (0+borderWidth) (height/2-10) +drawLine 260 (height/2-10) +-- sleep 0.5 + +------------------------------------------------------------------------------- + -- demonstrate using logical fonts +-- cf. e.g. <https://docs.oracle.com/javase/8/docs/api/constant-values.html#java.awt.Font.DIALOG> +xPos = 10 +yStart = 675 +size = 18 +color white +do counter c fontName over "Dialog", "DialogInput", "Serif", "SansSerif", "Monospaced" + if c//2 then -- switch styles + do + fontStyle 1+2 -- bold+italic + hint="(bold+italic)" + end + else + do + fontStyle 1 -- bold + hint="(bold)" + end + fontSize size + font "font"c fontName + goto xPos (yStart+(size*c)+5) + text=c"." fontName hint"," size "points" + drawString text +end +-- sleep 0.5 + +------------------------------------------------------------------------------- +say .line": popGC + pushGC ..." +popGC -- reset GC to initial configuration +pushGC -- save GC + + -- draw a line from upper right hand corner down: coordinates must be integers! +color teal +stroke dashedStroke +goto (width-borderWidth) (0+borderWidth) +drawLine (width-format(width/17,,0)) 200 + + -- move 0,0 co-ordinate relative to current position (i.e. to center) +translate (width/2) (height/2) + + -- draw a circle of yellow strings by rotating in 15\xB0 steps +color yellow +do counter c i=1 to 360/15 -- 24 steps! + rotate 15 -- rotate by 15\xB0 + text="--> Hello, world, it is:" .dateTime~new "<-- #" c "("c*15"\xB0) " + goto 0 0 + drawString text +end + + -- change color, change thickness of line +stroke stroke15 +color cyan + + -- move 0,0 co-ordinate relative to current position (from center to the left and up) +translate (-400) (-100) + + -- draw an ellipse (if rectangle is a square, then a circle gets drawn) +color magenta +stroke dashedStroke +goto 0 50 +drawOval 275 75 +-- sleep 0.5 + +------------------------------------------------------------------------------- +popGC -- reset GC to initial graphics configuration +pushGC -- save GC + + -- reset all transformation changes (will also reset 0,0 back to top left) +stroke stroke3 +color cyan +r = 200 -- radius +s = r*2 +x = borderWidth+width/2-r +y = borderWidth+height/2-r +goto x y +drawOval s s +-- sleep 0.5 + + -- change to arbitrary RGB color with alpha (transparency) +color someColor 255 153 0 200 -- R,G,B,alpha=200 (transparency) + + -- demo drawPolygon (one could use it for drawing e.g. a triangle) +stroke stroke15 -- set stroke +color someColor 0 0 255 100 -- R,G,B,alpha=100 (transparency) +translate (width/2+40) 110 + -- define polygon points, coordinates must be arrays of primitive Java int (integer values) +say "draw polygon ..." +arrX = bsf.createJavaArrayOf("int.class", 150, 250, 325, 100) +arrY = bsf.createJavaArrayOf("int.class", 150, 100, 125, 300) +drawPolygon "arrX" "arrY" arrX~items -- note: the Rexx variable names must be quoted +-- sleep 0.5 + +------------------------------------------------------------------------------- +if arrError~items>0 then say arrError + + -- save file in user's home directory +fileName = .java.lang.System~getProperty("user.home") || .file~separator || "3-100_create_bitmap_JDOR_commands.png" +saveImage fileName + + -- create the operating system dependent command to load and show the just created bitmap +parse source opsys +1 -- get operating system + if opsys="W" then cmd = quote(fileName) -- windows +else if opsys="D" then cmd = "open" quote(fileName) -- MacOS (Darwin) +else cmd = "xdg-open" quote(fileName) -- default to Linux + +say "command for operating system:" pp(cmd) -- show generated bitmap +address system cmd -- submit command to operating system + + +::requires "jdor.cls" -- makes routine addJdorHandler([environmentName]) available + +::routine quote -- enquote path in double-quotes (to cater for paths that may have blanks) + return '"' || arg(1) || '"' Modified: branches/850/samples/index.html =================================================================== --- branches/850/samples/index.html 2022-10-02 20:55:20 UTC (rev 995) +++ branches/850/samples/index.html 2022-10-03 12:06:28 UTC (rev 996) @@ -156,6 +156,56 @@ the external Rexx function BsfRawData() to turn a Rexx string into a Java byte array and a Java byte array into a Rexx string. + <dt><a href="1-120_JDOR_bw.rxj">1-120_JDOR_bw.rxj</a> + <dd>Demonstrates how to use JDOR commands to draw a cross, a string (text) and + superimpose a filled rectangle on it using a single (black) color. + + <dt><a href="1-120_JDOR_color_text.rxj">1-120_JDOR_color_text.rxj</a> + <dd>Demonstrates how to use JDOR commands to draw a cross, a string (text) and + superimpose a filled rectangle on it using different colors. + + <dt><a href="1-130_JDOR_rotate.rxj">1-130_JDOR_rotate.rxj</a> + <dd>Demonstrates how to use JDOR commands to draw rectangles + employing translation (moving the origin 0,0 around) and + rotation. + + <dt><a href="1-140_JDOR_images.rxj">1-140_JDOR_images.rxj</a> + <dd>Demonstrates the use of the JDOR commands loadImage and drawImage. + + <dt><a href="1-140_JDOR_images_reversed.rxj">1-140_JDOR_images_reversed.rxj</a> + <dd>Demonstrate the use of the scale JDOR command to reverse the y-axis, + causing the co-ordinates and images to be reversed. + + <dt><a href="1-150_JDOR_string_circle.rxj">1-150_JDOR_string_circle.rxj</a> + <dd>Demonstrates the use of the rotate JDOR command to draw strings in a circle. + + <dt><a href="1-160_JDOR_getState.rxj">1-160_JDOR_getState.rxj</a> + <dd>Demonstrates the use of the getState JDOR command and interacting + with return values via the RC Rexx variable. + + <dt><a href="1-170_JDOR_lineHeight.rxj">1-170_JDOR_lineHeight.rxj</a> + <dd>Demonstrates the use of the JDOR command font to fetch and query the size + of it in order to calculate the necessary line height to draw multiple + strings with the same line height. + + <dt><a href="1-180_JDOR_sandGlass.rxj">1-180_JDOR_sandGlass.rxj</a> + <dd>Demonstrates the use of JDOR for drawing a sand glass using different + colors and strokes. + + <dt><a href="1-180_JDOR_sandGlass_log.rxj">1-180_JDOR_sandGlass_log.rxj</a> + <dd>Demonstrates the use of <em>output redirection</em> saved to a file + named <em>"1-180_JDOR_sandGlass_commands.log"</em> (a text file) in + order to create a log (recording) of all JDOR commands in canonized form. + + <dt><a href="1-180_JDOR_sandGlass_replay_log.rxj">1-180_JDOR_sandGlass_replay_log.rxj</a> + <dd>Demonstrates the use of <em>input redirection</em> from a file + named <em>"1-180_JDOR_sandGlass_commands.log"</em> (a text file + created by <em>"1-180_JDOR_sandGlass_log.rxj"</em> above). + + <dt><a href="1-200_listFonts.rxj">1-200_listFonts.rxj</a> + <dd>Lists all font families installed on the system. + + <dt><a href="2-010_demoJavaArrays.rxj">2-010_demoJavaArrays.rxj</a> <dd>Demonstrate how to create and use Java array objects. @@ -213,6 +263,12 @@ <dt><a href="2-100_functionsPerFile.rxj">2-100_functionsPerFile.rxj</a> <dd>Lists which BSF4ooRexx functions are used in which script in a folder. + <dt><a href="2-110_JDOR_listShowPrintFonts.rxj">2-110_JDOR_listShowPrintFonts.rxj</a> + <dd>Demonstrates the use of the JDOR commands to create visual samples + of all font families installed which can optionally printed. + Each page with the font samples gets stored as a gif bitmap. + + <dt><a href="3-010_clock.rxj">3-010_clock.rxj</a> <dd>Creates and updates a graphical clock using a <code>JPanel</code>. Demonstrates extending the <code>javax.swing.JPanel</code> class at runtime such that @@ -273,7 +329,11 @@ name <code>3-100_create_bitmap.png</code> and shown using the appropraite operating system's command. + <dt><a href="3-100_create_bitmap_JDOR_commands.rxj">3-100_create_bitmap_JDOR_commands.rxj</a> + <dd>Demonstrate the new JDOR Rexx command handler to achieve the same + graphic as the one in <em>"3-100_create_bitmap_JDOR.rxj"</em> above. + <dt><a href="4-010_demo-j8-lambda.rxj">4-010_demo-j8-lambda.rxj</a> <dd>Demonstrates how to use ooRexx code to be used in Java 8's lambda-related functional programming patterns. Added: branches/850/samples/jdor.cls =================================================================== --- branches/850/samples/jdor.cls (rev 0) +++ branches/850/samples/jdor.cls 2022-10-03 12:06:28 UTC (rev 996) @@ -0,0 +1,51 @@ +#!/usr/bin/env rexx +/* + name: jdor.cls + purpose: make it easy for classic Rexx programmers to take advantage of + the new dynamic loadable Rexx command handlers of ooRexx 5.0 made + available by BSF4ooRexx850. They need to call/require this package + and thereafter can use the public routine "addJdorHandler([environmentnName])". + + "jdor" stands for "JavaDrawing with ooRexx" + + author: Rony G. Flatscher + date: 2022-09-03 + license: Apache License 2.0 + * ------------------------ Apache Version 2.0 license ------------------------- + * Copyright (C) 2022 Rony G. Flatscher + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a> + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ----------------------------------------------------------------------------- +*/ + + + +/** Creates a new command handler that will serve the environment by the name + * of the optional environmentName argument. + * @param environmentName the address environment name to use, if omitted defaults to "JDOR" +*/ +::routine addJdorHandler public + use strict arg environmentName="JDOR" + + call BsfCommandHandler "add", environmentName, getJDH() + +::requires "BSF.CLS" -- get ooRexx-Java bridge + +::routine getJDH -- tries to load (planned) fully qualified name, fallback: unqualified + signal on syntax name s1 + return .bsf~new("org.oorexx.rexxla.handlers.jdor.JavaDrawingHandler") +s1: + signal on syntax name s2 + return .bsf~new("JavaDrawingHandler") +s2: + return .nil -- indicate that we were not able to create an instance of JDH This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <or...@us...> - 2022-10-02 20:55:23
|
Revision: 995 http://sourceforge.net/p/bsf4oorexx/code/995 Author: orexx Date: 2022-10-02 20:55:20 +0000 (Sun, 02 Oct 2022) Log Message: ----------- Replace s390x version with new build and new name. Added Paths: ----------- branches/850/bsf4oorexx.dev/source_cc/lib/libBSF4ooRexx850.so-64-s390x Removed Paths: ------------- branches/850/bsf4oorexx.dev/source_cc/lib/libBSF4ooRexx.so-64-s390x Deleted: branches/850/bsf4oorexx.dev/source_cc/lib/libBSF4ooRexx.so-64-s390x =================================================================== (Binary files differ) Added: branches/850/bsf4oorexx.dev/source_cc/lib/libBSF4ooRexx850.so-64-s390x =================================================================== (Binary files differ) Index: branches/850/bsf4oorexx.dev/source_cc/lib/libBSF4ooRexx850.so-64-s390x =================================================================== --- branches/850/bsf4oorexx.dev/source_cc/lib/libBSF4ooRexx850.so-64-s390x 2022-09-29 13:59:54 UTC (rev 994) +++ branches/850/bsf4oorexx.dev/source_cc/lib/libBSF4ooRexx850.so-64-s390x 2022-10-02 20:55:20 UTC (rev 995) Property changes on: branches/850/bsf4oorexx.dev/source_cc/lib/libBSF4ooRexx850.so-64-s390x ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <or...@us...> - 2022-09-29 13:59:56
|
Revision: 994 http://sourceforge.net/p/bsf4oorexx/code/994 Author: orexx Date: 2022-09-29 13:59:54 +0000 (Thu, 29 Sep 2022) Log Message: ----------- 20220929 Add i2x() routine which converts an identityHash numeric value to a hexadecimal string. On 64-bit systems the hexadecimal string gets an underscore inserted after the eight' character to ease legibility by default. Modified Paths: -------------- branches/850/bsf4oorexx.dev/bin/BSF.CLS Modified: branches/850/bsf4oorexx.dev/bin/BSF.CLS =================================================================== --- branches/850/bsf4oorexx.dev/bin/BSF.CLS 2022-09-22 10:12:29 UTC (rev 993) +++ branches/850/bsf4oorexx.dev/bin/BSF.CLS 2022-09-29 13:59:54 UTC (rev 994) @@ -19,6 +19,11 @@ .BSF in .environment; date: + 2022-09-29, ---rgf, - new routine i2x(idValue[,deliString]): converts the identityHash number + returned by .Object's identityHash method into a hexadecimal string; + on 64-bit systems the hexadecimal string gets the deliString inserted + after the eight hexadecimal character for better legibility; uses + ooRexx 5 .rexxInfo class 2022-08-11, ---rgf, - version now reflects 850 @@ -917,7 +922,7 @@ if initialize.bsf.dir() then -- setup .bsfrexx do - .bsf4rexx~version="850.20220920" -- set version (date distribution got created) + .bsf4rexx~version="850.20220929" -- set version (date distribution got created) .bsf4rexx~opSys =opsys -- save operating system name as supplied by Rexx' PARSE SOURCE .bsf4rexx~opSys1 =opsys~left(1)~upper -- save operating system name's initial letter in uppercase .bsf4rexx~opSys2 =opsys~left(2)~upper -- save operating system name's first two letters in uppercase @@ -6300,3 +6305,28 @@ end mb~append("\"~copies(39), " ... end of Java exception chain." , .endOfLine) return mb~string + + +/** This routine creates a hexadecimal value from the identityHash number returned by .Object's + identityHash method taking the bitness of the ooRexx interpreter into account. + If running on a 64-bit interpreter the hexadeciimal value will be 16 characters + long, if running on a 32-bit interpreter it will be 8 characters long. + + @param argVal the identityHash number returned by .Object's identityHash method + @param deliString on 64-bit systems: optional delimiter string for grouping eight hex digit + characters, defaults to underscore (_) + @return hexadecimal value + @since 2022-09-29 + @author Rony G. Flatscher +*/ +::routine i2x public -- "pointer" to hexadecimal string: vonvert identityHash value to hexadecimal string + use strict arg argVal, deliString=("_") + + iDigits=.rexxinfo~internalDigits -- get number of internal digits + numeric digits iDigits + val=argVal~d2x(iDigits) -- convert to a hexadecimal string + len=(iDigits=9)~?(8,16) -- determine length of hexadecimal value + hexval = val~right(len) -- extract the hex digits representing 32 or 64 bit value + if iDigits=18, deliString<>"" then -- insert delimiter into hexadecimal string + hexVal=hexVal~insert(deliString,8) + return hexVal This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |