|
GLG Toolkit, Java Class Library
Version 4.6
|
This group contains methods for handling object selection and other user interaction with the GLG drawing. More...
This group contains methods for handling object selection and other user interaction with the GLG drawing.
These methods (other than AddListener) can be used inside Input and Trace listeners to implement custom user interaction and selection logic.
Functions | |
| void | AddListener (GlgCallbackType type, Object listener) |
| Adds a GLG event listener to a viewport. More... | |
| static GlgObject | CreateSelectionMessage (GlgObject top_vp, GlgCube rectangle, GlgObject selected_vp, GlgSelectionEventType selection_type, int button) |
| Searches for an Action object that would be activated by the user interaction event. More... | |
| static GlgObject | CreateSelectionNames (GlgObject top_vp, GlgCube rectangle, GlgObject selected_vp) |
| Returns a list of names of objects intersecting a given rectangle. More... | |
| static GlgObject | CreateSelectionNames (MouseEvent mouse_event, int delta, GlgObject top_vp, GlgObject selected_vp) |
| Returns a list of names of objects located under the mouse. More... | |
| static GlgObject | GetSelectedPlot () |
| Returns the plot object corresponding to the last legend item selected with the mouse, if any. More... | |
| char[] | GetWidgetPassword (String resource_name) |
| Returns password entered into the password text widget. More... | |
| Object | SendMessage (String resource_name, String message, Object param1, Object param2, Object param3, Object param4) |
| Sends a message to the object to request some action to be performed. More... | |
| static GlgTooltipFormatter | SetTooltipFormatter (GlgTooltipFormatter formatter) |
| Supplies a custom tooltip formatter. More... | |
| void AddListener | ( | GlgCallbackType | type, |
| Object | listener | ||
| ) |
Adds a GLG event listener to a viewport.
An Input listener can also be added to the light viewport.
| type | Specifies the type of a listener to be added: |
| listener | Specifies a listener that will be used to process GLG events. |
This method adds the specified listener to a viewport. A listener's entry point will be called by the GLG Toolkit upon some action:
See GlgInputListener, GlgSelectListener, GlgTraceListener and GlgHierarchyListener for the description of the available listener types and their entry points.
Only one listener of each listener type may be added to an individual viewport. Any subsequent invocations of AddListener with the same listener type will overwrite the previous value of the viewport's listener. To remove a listener, call AddListener with null as a value of the listener parameter.
Note: Listeners must be added before the drawing's hierarchy is set up.
Several listeners of the same type may be added to different viewports on different levels of the drawing hierarchy. However, only the first encountered listener on the lowest level of the hierarchy will be called. For example, if an input listener is attached to a viewport and its child viewport, only the child viewport's listener will be invoked when input event occurs in the child viewport.
If an event occurs in a child viewport that doesn't have a listener attached, the listener of the first encountered parent viewport that has the listener attached will be invoked.
The viewport's ProcessMouse attribute controls processing of the mouse selection events and tooltips inside the viewport and its child viewports.
The GlgJBean also provides methods for adding listeners to the drawings used by each GlgJBean instance.
See the Listener Events section of the Handling User Input and Other Events chapter of the GLG Programming Reference Manual for more information.
|
static |
Searches for an Action object that would be activated by the user interaction event.
This method provides a low-level API for searching all objects inside the given rectangle for an action with the specified selection trigger type attached to an object and returning a selection message for the first found action attached to the object.
The method may be used inside the GlgTraceListener's TraceCallback method to determine whether a mouse event was meant to trigger an action attached to a graphical object in a drawing.
| top_vp | The top viewport or light viewport of the selection query (must be an ancestor of selected_vp or the same as selected_vp). It may be either a viewport or a light viewport. |
| rectangle | The bounding rectangle in screen coordinates of the selected_vp viewport. All graphical shapes whose rendering intersects this rectangle, including shapes in the top_vp viewport, are included in the selection list. |
| selected_vp | The viewport relatively to which the bounding rectangle is defined. When used with the mouse events, this is the viewport in which the mouse event occurred. If a light viewport is supplied, its parent viewport will be used. |
| selection_type | Specifies the selection type:
|
| button | The mouse button (1, 2 or 3) for the CLICK_SELECTION selection type. |
|
static |
Returns a list of names of objects intersecting a given rectangle.
This method provides a low-level API to determine whether a mouse event was meant to select graphical objects in a drawing and may be used inside the GlgTraceListener's TraceCallback method to implement custom handling of mouse events.
See also CreateSelectionNames that creates selection names from an event.
Action objects attached to objects in the drawing provide a higher level interface for custom object selection processing.
A more powerful CreateSelection method of the Intermediate API returns object IDs of the selected objects and may be used to handle unnamed objects.
| top_vp | The top viewport or light viewport of the selection query (must be an ancestor of selected_vp or the same as selected_vp). It may be either a viewport or a light viewport. |
| rectangle | The bounding rectangle in screen coordinates of the selected_vp viewport. All graphical shapes whose rendering intersects this rectangle, including shapes in the top_vp viewport, are included in the selection list. |
| selected_vp | The viewport relatively to which the bounding rectangle is defined. When used with the mouse events, this is the viewport in which the mouse event occurred. If a light viewport is supplied, its parent viewport will be used. |
The method returns an array of strings containing names of all objects that overlap with the given rectangle completely or partially. Both the selected objects at the bottom of the hierarchy and all their named parents will be included.
Objects in the array are listed in the reversed order compared to their drawing order, so that the objects that are at the bottom of the drawing list and are drawn on top of other objects will be listed first in the array.
Each returned name string is a complete resource path name (relative to top_vp) which can be used get the object ID of the object:
|
static |
Returns a list of names of objects located under the mouse.
This method provides a low-level API to determine whether a mouse event was meant to select graphical objects in a drawing and may be used inside the GlgTraceListener's TraceCallback method to implement custom handling of mouse events.
See also CreateSelectionNames that creates selection names for the specified area.
Action objects attached to objects in the drawing provide a higher level interface for custom object selection processing.
A more powerful CreateSelection method of the Intermediate API returns object IDs of the selected objects and may be used to handle unnamed objects.
| mouse_event | Mouse event. |
| delta | Specifies the radius of the area around the cursor position that will be used to select objects. All graphical shapes whose rendering intersects this area, including shapes in the top_vp viewport, are included in the selection list. |
| top_vp | The top viewport or light viewport of the selection query (must be an ancestor of selected_vp or the same as selected_vp). It may be either a viewport or a light viewport. |
| selected_vp | The viewport in which the mouse event occurred. If a light viewport is supplied, its parent viewport will be used. |
Follow this link for information on using the returned array.
|
static |
Returns the plot object corresponding to the last legend item selected with the mouse, if any.
The setting of the chart's viewport ProcessMouse attribute controls when legend selection happens:
This method can be used in conjunction with a mouse click Action attached to the Legend object. The DEMOS_Java/GlgRealTimeChart.java file in the GLG installation directory provides an example of using this technique to highlight a plot when its legend icon is clicked on.
See also GetLegendSelection.
| char [] GetWidgetPassword | ( | String | resource_name | ) |
Returns password entered into the password text widget.
| resource_name | A resource path to access the password widget's viewport from the parent, or null if the method is invoked on the password widget's viewport. |
| Object SendMessage | ( | String | resource_name, |
| String | message, | ||
| Object | param1, | ||
| Object | param2, | ||
| Object | param3, | ||
| Object | param4 | ||
| ) |
Sends a message to the object to request some action to be performed.
In most cases, the object it is a viewport with a GLG input handler attached, such as a button or a slider.
| resource_name | Specifies the resource path of a child object to send the message to, or null to send the message to the object the method is invoked on. The resource path is relative to the invoking object. For example, to send the message to a viewport's handler, use the viewport as the object parameter and "Handler" as the resource_name parameter. |
| message | A string that defines the message type. |
| param1 | Message type dependent. |
| param2 | Message type dependent. |
| param3 | Message type dependent. |
| param4 | Message type dependent. |
This method is used to send a message to an input object with a request to execute some action. For example, a program can send an "Activate" message to a push button widget to simulate a user click, which will activate any click processing Action objects attached to the button. "Set" and "Reset" messages may be sent to a toggle button widget to change its value, which will also process any Action objects attached to the toggle.
The method also serves as an escape mechanism for actions that can not be easily accomplished by setting or querying a single resource, such us adding items to a list widget or querying a state of a multiple-selection list.
Refer to the Input Objects chapter of the of the GLG User's Guide and Builder Reference Manual for the description of the method's parameters and returned value for each of the GLG input handlers.
Integer parameters should be passed as GlgInteger objects.
Integer return values are also returned as Integer objects.
|
static |
Supplies a custom tooltip formatter.
A custom tooltip formatter may be used to supply custom context-sensitive tooltip strings by querying an object's properties and displaying them in the tooltip.
See GlgTooltipFormatter for more.
| formatter | Specifies a custom tooltip formatter. |