Element: DrawingPanel.
Icon:
Text: A 2D container for Drawables.
Description: A DrawingPanel is a special container to host drawable children. Even when it is considered a container, it cannot be used to host other type of elements.
Drawing panels represent a region of the two-dimensional plane and provide their own coordinate system, from the point (Minimum X, Minimum Y) to (Maximum X, Maximum Y). (Even though the scales can also be automatically adjusted.)
Drawing panels are interactive and respond to the different gestures of the mouse according to the following procedure:
When the user clicks on the panel, the action associated to the "On Press" property is invoked. Immediately after, properties "X" and "Y" receive the values corresponding to the current position of the mouse. This also invokes the action associated to the "On Drag" property.
When the user drags the mouse (with the mouse button pressed), properties "X" and "Y" are updated, and the action associated to the property "On Drag" is invoked.
When the user finally releases the mouse button (if inside the panel), the action associated to the property "On Release" is invoked.
Drawing panels also respond to keyboard interaction. When the user click on them, they get focus so that hitting a keyboard key triggers a Key Action. The key pressed can be obtained through the Key Pressed property.
Table of properties |
||
Name | Description | Values accepted |
Scales | ||
Autoscale X | Whether to automatically compute the scale in the X axis. | A boolean variable or one of the constants true or false. |
Autoscale Y | Whether to automatically compute the scale in the Y axis. | A boolean variable or one of the constants true or false. |
Minimum X | The smallest value of the X coordinate that is visible in the panel. | A constant or variable of type double. |
Maximum X | The greatest value of the X coordinate that is visible in the panel. | A constant or variable of type double. |
Minimum Y | The smallest value of the Y coordinate that is visible in the panel. | A constant or variable of type double. |
Maximum Y | The greatest value of the Y coordinate that is visible in the panel. | A constant or variable of type double. |
Interaction | ||
X | The X coordinate of the position of the mouse. | A variable of type double. |
Y | The Y coordinate of the position of the mouse. | A variable of type double. |
On Press | The action to invoke when the mouse is pressed on the panel. | The Java code to invoke for the action. |
On Drag | The action to invoke when the mouse is dragged on the panel. | The Java code to invoke for the action. |
On Release | The action to invoke when the mouse is released on the panel. | The Java code to invoke for the action. |
Mouse Enter | The action to invoke when the pointer enters the element. | The Java code to invoke for the action. |
Mouse Exit | The action to invoke when the pointer leaves the element. | The Java code to invoke for the action. |
Key Action | The action to invoke when any key is hit while the panel has focus. | The Java code to invoke for the action. |
Key Pressed | The integer code of the key pressed. | A variable of type int. |
Configuration |
||
Square | Whether to keep a 1:1 ratio between the X and Y scales. | A boolean variable or one of the constants true or false. |
Gutters | The empty spaces to leave around the drawing area of the panel. | An Object variable of the class java.awt.Rectangle or four integers, separated by commas, corresponding to the top, left, bottom and right margins, respectively. |
Coordinates | Whether to display the current coordinates of the mouse when the user clicks on the panel. | A boolean variable or one of the constants true or false. |
X Format | The format for the visualization of the X coordinate. | Any value acepted by the class java.text.DecimalFormat. See additional info. Default is "x=0.000". |
Y Format | The format for the visualization of the Y coordinate. | Any value acepted by the class java.text.DecimalFormat. See additional info. Default is "y=0.000". |
Graphical Aspect |
||
Visible | The visibility of the element. | A boolean variable or one of the constants true or false. |
Size | The size of the element. | An Object variable of the class java.awt.Dimension or the integer values for the width and the height, respectively, separated by a comma. |
Background | The color used for the background of the element and that of its children (unless they explicitely set their own value for this property). | An Object variable of the class java.awt.Color
or one of the predefined colors: black,
blue, cyan, darkGray, gray, green, lightGray, magenta, orange, pink,
red, white, yellow.
A color can also be specified providing its integer RGB coordinates (between 0 and 255), plus an optional transparency coordinate. The default value is decided by the system. |
Foreground | The color used for any text displayed by the element or by its children (unless they explicitely set their own value for this property). | See the values for the Background property. |
Font | The font used for any text displayed by the element or by its children (unless they explicitely set their own value for this property). | An Object variable of the class java.awt.Font
or a set of family, style and size, separated by commas. The style
must be one of plain,
bold, italic, bold | italic. Example: Monospaced,italic,18.
The default value is decided by the system. |
Tooltip | The text displayed when the cursor lingers on top of the element. | Any constant or variable of type String. |