- 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
Modifier and TypeClassDescription(package private) static interface
The Animable interface.(package private) class
Local class DrawCanvas.Nested classes/interfaces inherited from class simula.runtime.RTS_RTObject
RTS_RTObject.ForElt, RTS_RTObject.ForList, RTS_RTObject.ForListIterator, RTS_RTObject.OperationalState, RTS_RTObject.RTS_BOOLEAN_ARRAY, RTS_RTObject.RTS_BOUNDS, RTS_RTObject.RTS_CHARACTER_ARRAY, RTS_RTObject.RTS_INTEGER_ARRAY, RTS_RTObject.RTS_LABEL, RTS_RTObject.RTS_LONG_REAL_ARRAY, RTS_RTObject.RTS_NAME<T>, RTS_RTObject.RTS_REAL_ARRAY, RTS_RTObject.RTS_REALTYPE_ARRAY, RTS_RTObject.RTS_REF_ARRAY<T>, RTS_RTObject.RTS_TEXT_ARRAY, RTS_RTObject.SingleElt<T>, RTS_RTObject.SingleTValElt, RTS_RTObject.StepUntil, RTS_RTObject.UncaughtExceptionHandler, RTS_RTObject.WhileElt<T>, RTS_RTObject.WhileTValElt
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The color black.static final int
The color blue.static final int
The color cyan.static final int
The color darkGray.static final int
The color gray.static final int
The color green.static final int
The color lightGray.static final int
The color magenta.static final int
The color orange.static final int
The color pink.static final int
The color red.static final int
The color white.static final int
The color yellow.(package private) final RTS_Drawing.DrawCanvas
The current canvas.(package private) Color
The current background color(package private) Color
The current draw color(package private) Color
The current currentBackgroundColor(package private) Font
The current font(package private) Stroke
The current strokeprivate static final boolean
DEBUG on/off(package private) final JFrame
The current Frame.final RTS_Head
The redering set.(package private) final BufferStrategy
The buffer strategy.Fields inherited from class simula.runtime.RTS_ENVIRONMENT
_STARTTIME, CURRENTDECIMALMARK, CURRENTLOWTEN, EXCEPTION_HANDLER, maxint, maxlongreal, maxreal, minint, minlongreal, minreal, simulaReleaseID
Fields inherited from class simula.runtime.RTS_RTObject
_CORUT, _CTX, _CUR, _DL, _INPUT_LINELENGTH, _JTX, _OUTPUT_LINELENGTH, _SL, _STATE, _SYSIN, _SYSOUT, NOTEXT
-
Constructor Summary
ConstructorDescriptionRTS_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.int
color
(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.float
Get font size.Returns the rendering set.void
Request a repaint.void
setBackgroundColor
(int color) Set background color.void
setDrawColor
(int color) Set draw color.void
setFillColor
(int color) Set fill color.void
setFontSize
(float size) Set font size.void
set font style boldvoid
Set font style bold and italic.void
set font style italicvoid
set font style plainvoid
setStroke
(float size) Set stroke size.Methods inherited from class simula.runtime.RTS_BASICIO
toString
Methods inherited from class simula.runtime.RTS_ENVIRONMENT
_char, _IPOW, _IS, abs, abs, abs, addepsilon, addepsilon, arccos, arcsin, arctan, arctan2, Char, clocktime, cos, cosh, cotan, cputime, datetime, decimalmark, DEFEXCEPTION, digit, discrete, draw, edfix, edit, edit, edit, edit, edit, edtime, entier, Erlang, error, exp, getIntInfo, getTextInfo, giveIntInfo, giveTextInfo, hash, histd, histo, isochar, isorank, letter, linear, ln, loadChar, log10, lowcase, lowerbound, lowten, max, max, max, max, max, min, min, min, min, min, mod, negexp, normal, Poisson, printStaticChain, printThreadList, randint, rank, rem, rts_utility, sign, simulaid, sin, sinh, sqrt, storeChar, subepsilon, subepsilon, tan, tanh, uniform, upcase, upperbound, waitSomeTime
Methods inherited from class simula.runtime.RTS_RTObject
_ASGSTR, _ASGTXT, _GOTO, _JUMPTABLE, _JUMPTABLE, _LABEL, _PRE_LABEL, _PRE_TABLE, _SIM_LABEL, _TXTREL_EQ, _TXTREL_GE, _TXTREL_GT, _TXTREL_LE, _TXTREL_LT, _TXTREL_NE, _VALUE, arrayValue, BBLK, blanks, BPRG, call, call, CONC, copy, detach, detach, detach, doubleValue, EBLK, edObjectAttributes, edObjectIdent, floatValue, getErrorMessage, intValue, isDetachUsed, isQPSystemBlock, objectTraceIdentifier, objectTraceIdentifier, objectValue, procValue, resume, resume, resume, swapCoroutines, sysin, sysout, terminate_program, TRACE_GOTO, TRF_EQ, TRF_NE
-
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
Returns the rendering set.- Returns:
- the rendering set.
-
repaintMe
public void repaintMe()Request a repaint. -
setFontStylePlain
public void setFontStylePlain()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) 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_RTObject
Method representing the Statements in this Block
This method is virtual and must be redefined in blocks.- Overrides:
_STM
in classRTS_Simset
- Returns:
- a pointer to this _RTObject
-