Class RTS_Drawing
- All Implemented Interfaces:
Runnable
Additional System class Drawing.
The class "Drawing" introduce basic graphical capabilities. It has the class "simset" as prefix, so set-handling facilities are thus immediately available.
Simset class Drawing(title,width,height); Value title; Text title; Integer width,height;
begin ref(Head) RENDERING_SET;
Integer CURRENT_BACKGROUND_COLOR,CURRENT_DRAW_COLOR,CURRENT_FILL_COLOR,CURRENT_STROKE_WIDTH;
ref(Font) CURRENT_FONT; ! Java Class Font is not visible in Simula ;
ref(Head) Procedure renderingSet; renderingSet :- RENDERING_SET;
Integer white,lightGray,gray,darkGray,black,red,pink,orange,yellow,green,magenta,cyan,blue;
Integer Procedure color(r,g,b); Integer r,g,b; ...
Procedure setBackgroundColor(color); Integer color; CURRENT_BACKGROUND_COLOR := color;
Procedure setDrawColor(color); Integer color; CURRENT_DRAW_COLOR := color;
Procedure setFillColor(color); Integer color; CURRENT_FILL_COLOR := color;
Procedure setStroke(width); Real width; CURRENT_STROKE_WIDTH := width;
Procedure setFontStylePlain; CURRENT_FONT :- CURRENT_FONT.deriveFont(Font.PLAIN);
Procedure setFontStyleBold; CURRENT_FONT :- CURRENT_FONT.deriveFont(Font.BOLD);
Procedure setFontStyleItalic; CURRENT_FONT :- CURRENT_FONT.deriveFont(Font.ITALIC);
Procedure setFontStyleBoldItalic; CURRENT_FONT :- CURRENT_FONT.deriveFont(Font.BOLD|Font.ITALIC);
Procedure setFontSize(size); Real size; CURRENT_FONT :- CURRENT_FONT.deriveFont(size);
Real Procedure getFontSize; getFontSize := CURRENT_FONT.getSize2D;
Link class ShapeElement; ...
Link class TextElement; ...
ref(TextElement) Procedure drawText(t,x,y); Value t; Text t; Long Real x1,y1,x2,y2;
begin ref(TextElement) elt; drawText :- elt :- new TextElement(t,x,y); end;
ref(ShapeElement) Procedure drawLine(x1,y1,x2,y2); Long Real x1,y1,x2,y2;
begin ref(ShapeElement) elt; drawLine :- elt :- new ShapeElement; elt.drawLine(x1,y1,x2,y2); end;
ref(ShapeElement) Procedure drawEllipse(x,y,width,height); Long Real x,y,width,height;
begin ref(ShapeElement) elt; drawEllipse :- elt :- new ShapeElement; elt.drawEllipse(x,y,width,height); end;
ref(ShapeElement) Procedure drawRectangle(double x,double y,double width,double height)
begin ref(ShapeElement) elt; drawRectangle :- elt :- new ShapeElement; elt.drawRectangle(x,y,width,height); end;
ref(ShapeElement) Procedure drawRoundRectangle(x,y,width,height,arcw,arch); Long Real x,y,width,height,arcw,arch;
begin ref(ShapeElement) elt; drawRoundRectangle :- elt :- new ShapeElement; elt.drawRoundRectangle(x,y,width,height,arcw,arch); end;
ref(ShapeElement) Procedure fillEllipse(x,y,width,height); Long Real x,y,width,height;
begin ref(ShapeElement) elt; fillEllipse :- elt :- new ShapeElement; elt.fillEllipse(x,y,width,height); end;
ref(ShapeElement) Procedure fillRectangle(x,y,width,height); Long Real x,y,width,height;
begin ref(ShapeElement) elt; fillRectangle :- elt :- new ShapeElement; elt.fillRectangle(x,y,width,height); end;
ref(ShapeElement) Procedure fillRoundRectangle(x,y,width,height,arcw,arch); Long Real x,y,width,height,arcw,arch;
begin ref(ShapeElement) elt; fillRoundRectangle :- elt :- new ShapeElement; elt.fillRoundRectangle(x,y,width,height,arcw,arch); end;
RENDERING_SET :- new head;
CURRENT_BACKGROUND_COLOR := white;
CURRENT_DRAW_COLOR=black;
CURRENT_FILL_COLOR=gray;
CURRENT_STROKE_WIDTH := 2.5;
CURRENT_FONT=new Font(Font.SANS_SERIF,12,Font.PLAIN); ! Font size 12 ;
end Drawing;
When used as a prefix to a block or a class, "simulation" introduces simulation-oriented features through the class "process" and associated procedures.
The variable RENDERING_SET refers to a set of graphical elements to be rendered. The members of the rendering set are ShapeElements and TextElements. The elements are rendered in the order defined by the RENDERING_SET, starting with RENDERING_SET.first.
Link to GitHub: Source File.
- Author:
- Øystein Myhre Andersen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interfaceThe Animable interface.(package private) classLocal class DrawCanvas. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe color black.static final intThe color blue.static final intThe color cyan.static final intThe color darkGray.static final intThe color gray.static final intThe color green.static final intThe color lightGray.static final intThe color magenta.static final intThe color orange.static final intThe color pink.static final intThe color red.static final intThe color white.static final intThe color yellow.(package private) final RTS_Drawing.DrawCanvasThe current canvas.(package private) ColorThe current background color(package private) ColorThe current draw color(package private) ColorThe current currentBackgroundColor(package private) FontThe current font(package private) StrokeThe current strokeprivate static final booleanDEBUG on/off(package private) final JFrameThe current Frame.final RTS_HeadThe redering set.(package private) final BufferStrategyThe buffer strategy.Fields inherited from class RTS_ENVIRONMENT
_STARTTIME, CURRENTDECIMALMARK, CURRENTLOWTEN, EXCEPTION_HANDLER, maxint, maxlongreal, maxreal, minint, minlongreal, minreal, simulaReleaseIDFields inherited from class RTS_RTObject
_CORUT, _CTX, _CUR, _DL, _INPUT_LINELENGTH, _JTX, _OUTPUT_LINELENGTH, _SL, _STATE, _SYSIN, _SYSOUT, _USR, startTimeMs -
Constructor Summary
ConstructorsConstructorDescriptionRTS_Drawing(RTS_RTObject SL, RTS_TXT title, int width, int height) Create a new Drawing Canvas. -
Method Summary
Modifier and TypeMethodDescription_STM()Method representing the Statements in this Block
This method is virtual and must be redefined in blocks.intcolor(int red, int green, int blue) integer procedure color(r,g,b); integer r,g,b; ... ... ;
drawEllipse(double x, double y, double w, double h) Draw Ellipse.drawLine(double x1, double y1, double x2, double y2) Draw LinedrawRectangle(double x, double y, double w, double h) Draw Rectangle.drawRoundRectangle(double x, double y, double w, double h, double arcw, double arch) Draw Rounded Rectangle.Draw Text.fillEllipse(double x, double y, double w, double h) Fill Ellipse.fillRectangle(double x, double y, double w, double h) Fill Rectangle.fillRoundRectangle(double x, double y, double w, double h, double arcw, double arch) Fill Rounded Rectangle.floatGet font size.Returns the rendering set.voidRequest a repaint.voidsetBackgroundColor(int color) Set background color.voidsetDrawColor(int color) Set draw color.voidsetFillColor(int color) Set fill color.voidsetFontSize(float size) FontSize usually 12.0 ?voidset font style boldvoidSet font style bold and italic.voidset font style italicvoidstyle - the style constant for the Font The style argument is an integer bitmask that may be PLAIN, or a bitwise union of BOLD and/or ITALIC (for example, ITALIC or BOLD|ITALIC).voidsetStroke(float size) Set stroke size.Methods inherited from class RTS_BASICIO
terminate_program, toStringMethods inherited from class RTS_ENVIRONMENT
_char, abs, abs, abs, addepsilon, addepsilon, arccos, arcsin, arctan, arctan2, argv, blanks, Char, clocktime, confirmDialog, copy, cos, cosh, cotan, cputime, datetime, decimalmark, DEFEXCEPTION, digit, discrete, draw, edfix, edfix, edit, edit, edit, edit, edit, edit, edtime, edtime, entier, Erlang, error, exit, exp, fileChooser, hash, histd, histo, isochar, isorank, letter, linear, ln, loadChar, log10, lowcase, lowerbound, lowten, max, max, max, max, max, max, max, max, max, max, max, min, min, min, min, min, min, min, min, min, min, min, mod, negexp, normal, Poisson, printStaticChain, printThreadList, prompt, randint, rank, rem, sign, simulaid, sin, sinh, sqrt, storeChar, subepsilon, subepsilon, tan, tanh, uniform, upcase, upperbound, waitSomeTimeMethods inherited from class RTS_RTObject
_GOTO, _JUMPTABLE, _SIM_LABEL, _TREAT_GOTO_CATCH_BLOCK, _VALUE, arrayValue, BBLK, booleanValue, call, call, charValue, CONC, detach, detach, detach, doubleValue, EBLK, edObjectAttributes, edObjectIdent, floatValue, intValue, isDetachUsed, isQPSystemBlock, objectTraceIdentifier, objectTraceIdentifier, objectValue, procValue, resume, resume, resume, swapCoroutines, sysin, sysout, TRACE_GOTO
-
Field Details
-
DEBUG
private static final boolean DEBUGDEBUG on/off- See Also:
-
_white_1
public static final int _white_1The color white.- See Also:
-
_lightGray_1
public static final int _lightGray_1The color lightGray.- See Also:
-
_gray_1
public static final int _gray_1The color gray.- See Also:
-
_darkGray_1
public static final int _darkGray_1The color darkGray.- See Also:
-
_black_1
public static final int _black_1The color black.- See Also:
-
_red_1
public static final int _red_1The color red.- See Also:
-
_pink_1
public static final int _pink_1The color pink.- See Also:
-
_orange_1
public static final int _orange_1The color orange.- See Also:
-
_yellow_1
public static final int _yellow_1The color yellow.- See Also:
-
_green_1
public static final int _green_1The color green.- See Also:
-
_magenta_1
public static final int _magenta_1The color magenta.- See Also:
-
_cyan_1
public static final int _cyan_1The color cyan.- See Also:
-
_blue_1
public static final int _blue_1The color blue.- See Also:
-
frame
The current Frame. -
canvas
The current canvas. -
strategy
The buffer strategy. -
RENDERING_SET
The redering set. -
currentBackgroundColor
Color currentBackgroundColorThe current background color -
currentDrawColor
Color currentDrawColorThe current draw color -
currentFillColor
Color currentFillColorThe current currentBackgroundColor -
currentStroke
Stroke currentStrokeThe current stroke -
currentFont
Font currentFontThe current font
-
-
Constructor Details
-
RTS_Drawing
Create a new Drawing Canvas.- Parameters:
SL- staticLinktitle- panel's titlewidth- the width of the panelheight- the height of the panel
-
-
Method Details
-
renderingSet
-
repaintMe
public void repaintMe()Request a repaint. -
setFontStylePlain
public void setFontStylePlain()style - the style constant for the Font The style argument is an integer bitmask that may be PLAIN, or a bitwise union of BOLD and/or ITALIC (for example, ITALIC or BOLD|ITALIC). If the style argument does not conform to one of the expected integer bitmasks then the style is set to PLAIN.
set font style plain
-
setFontStyleBold
public void setFontStyleBold()set font style bold -
setFontStyleItalic
public void setFontStyleItalic()set font style italic -
setFontStyleBoldItalic
public void setFontStyleBoldItalic()Set font style bold and italic. -
setStroke
public void setStroke(float size) Set stroke size.- Parameters:
size- the stroke size.
-
setFontSize
public void setFontSize(float size) FontSize usually 12.0 ?
Set font size.
- Parameters:
size- the font size.
-
getFontSize
public float getFontSize()Get font size.- Returns:
- the font size.
-
setBackgroundColor
public void setBackgroundColor(int color) Set background color.- Parameters:
color- the background color
-
setDrawColor
public void setDrawColor(int color) Set draw color.- Parameters:
color- the draw color
-
setFillColor
public void setFillColor(int color) Set fill color.- Parameters:
color- the fill color
-
color
public int color(int red, int green, int blue) integer procedure color(r,g,b); integer r,g,b; ... ... ;
Creates an opaque sRGB color with the specified combined RGB value consisting of the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7.
- Parameters:
red- the red componentgreen- the green componentblue- the blue component- Returns:
- the resulting color
-
drawText
Draw Text.- Parameters:
t- the textx- the X coordinatey- the Y coordinate- Returns:
- the resulting _TextElement
-
drawLine
Draw Line- Parameters:
x1- the X coordinate of the start pointy1- the Y coordinate of the start pointx2- the X coordinate of the end pointy2- the Y coordinate of the end point- Returns:
- the resulting _ShapeElement
-
drawEllipse
Draw Ellipse.- Parameters:
x- the X coordinatey- the Y coordinatew- the width of the ellipseh- the height of the ellipse- Returns:
- the resulting _ShapeElement
-
drawRectangle
Draw Rectangle.- Parameters:
x- the X coordinatey- the Y coordinatew- the width of the rectangleh- the height of the rectangle- Returns:
- the resulting _ShapeElement
-
drawRoundRectangle
public RTS_ShapeElement drawRoundRectangle(double x, double y, double w, double h, double arcw, double arch) Draw Rounded Rectangle.- Parameters:
x- the X coordinatey- the Y coordinatew- the width of the rectangleh- the height of the rectanglearcw- the width of the arc to use to round off the cornersarch- the height of the arc to use to round off the corners- Returns:
- the resulting _ShapeElement
-
fillEllipse
Fill Ellipse.- Parameters:
x- the X coordinatey- the Y coordinatew- the width of the ellipseh- the height of the ellipse- Returns:
- the resulting _ShapeElement
-
fillRectangle
Fill Rectangle.- Parameters:
x- the X coordinatey- the Y coordinatew- the width of the rectangleh- the height of the rectangle- Returns:
- the resulting _ShapeElement
-
fillRoundRectangle
public RTS_ShapeElement fillRoundRectangle(double x, double y, double w, double h, double arcw, double arch) Fill Rounded Rectangle.- Parameters:
x- the X coordinatey- the Y coordinatew- the width of the rectangleh- the height of the rectanglearcw- the width of the arc to use to round off the cornersarch- the height of the arc to use to round off the corners- Returns:
- the resulting _ShapeElement
-
_STM
Description copied from class:RTS_RTObjectMethod representing the Statements in this Block
This method is virtual and must be redefined in blocks.- Overrides:
_STMin classRTS_Simset- Returns:
- a pointer to this _RTObject
-