UniVista Programmer's Guide

UniVista.support.screens

ScreenRenderer


Intent | Structure | Participants | Sample Code | Known Uses

Intent

Used as a means to display UniVista Screens. This class extends a generic Java container, so it too can be embedded within another container. It also handles the selecting and highlighting of ScreenObjects to provide a more user-friendly feel.

Structure

Participants

Sample Code

Removing a highlight from an object without disabling the highlight feature, simply pass null as the following excerpt shows.
// deselecting an item

renderer.selectItem(null);
//...
The code necessary for painting the highlight properly looks like the following. Notice that removing the old rectangle could have been done using XORPainting. Also, an error factor of 2 was used in painting, since it occurs that the Swing components didn't work correspondingly with Graphics.drawRect as defined by the Graphics API.
public void paintComponent(Graphics g) {
super.paintComponent(g);

// erase the previous highlight
if (selectionRect != null) {
g.setColor(getBackground());
g.drawRect(selectionRect.x, selectionRect.y, selectionRect.width, selectionRect.height);
selectionRect = null;
}
if (highlightEnabled) {
// create the new highlight
if (selectedItem != null) {
g.setColor(Color.red);
int x,y,w,h;
selectionRect = selectedItem.getUI().getBounds();
selectionRect.x -= 2; selectionRect.y -= 2;
selectionRect.height += 2; selectionRect.width += 2;

g.drawRect(selectionRect.x,selectionRect.y,selectionRect.width,selectionRect.height);
}
}
}

Known Uses

This class is essential for displaying Screens. Therefore, instances can be found in both the StudyEditor and the RunEngine where Screens play a central role.



Contact the UniVista Team | Main Page | Table of Contents