JavaView© v3.95.000

jv.object
Class PsPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended byjv.object.PsPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, PsUpdateIf, java.io.Serializable
Direct Known Subclasses:
MyClass_IP, PdArray_IP, PdColor_IP, PdVector_IP, PgAxes_CP, PgCatenoid_CP, PgDomain_CP, PgDomainDescr_IP, PgElementSet_TP, PgGenusSurface_CP, PgGraph_CP, PgLantern_CP, PgMaxPrinciple_CP, PgParmCurve_CP, PgParmSurface_CP, PgPointSet_IP, PgPointSet_LP, PgPointSet_MP, PgPointSet_VP, PgRuler_CP, PgSurfaceOfRotation_CP, PgSurfacePair_IP, PgTexture_IP, PgTube_CP, PgVectorField_IP, PgWeierstrassDescr_IP, PiArray_IP, PiVector_IP, PjProject_IP, PjSlider_IP, PjWorkshop_IP, PnEnergyMinimizer_IP, PsAnimation_IP, PsAuthorInfo_IP, PsCategoryList_IP, PsGeometryInfo_IP, PsJavaView_IP, PsTabPanel, PuColorPicker, PuDouble_IP, PuFunction_IP, PuInteger_IP, PvCamera_IP, PvDisplay_IP, PvLight_IP

public class PsPanel
extends java.awt.Panel
implements PsUpdateIf, java.io.Serializable

Default base class for info panels, and often used instead of Panel. Implements the update mechanism and simplifies setting of layouts. Each non-gui class may have associated inspectors derived from PsPanel.

Subclasses must call the init() method in each constructor and each init() method must call super.init() at first.

	public class myClass extends mySuperClass
		public myClass() {
			...
			if (getClass() == myClass.class)
				init();
		}
		public void init() {
			super.init();
			...
		}
 
Only this ensures that the init() method is called. Otherwise even the init() methods of the superclasses will not be called.

The default font of this class is PsConfig.FONT_TEXT.

Class contains several static methods to simplify the updating of GUI widgets. These methods first check if the GUI is already in the requested state, and invoke the GUI methods only if the widget status must be changed.

See Also:
Serialized Form

Field Summary
static int BORDER_GROOVE
           
static int BORDER_LINE
           
static int BORDER_NONE
           
static int BORDER_SUNK
           
static java.lang.String CONFIG
          Name of default control panel under which panel is registered in panel list.
static java.lang.String CONFIG_EXT
          File name suffix of control panel class to name of base class.
static java.lang.String INFO
          Name of default info panel under which panel is registered in panel list.
static java.lang.String INFO_EXT
          Identifier of class extension characterizing info panels.
static java.lang.String LABEL
          Name of default font panel under which panel is registered in panel list.
static java.lang.String LABEL_EXT
          File name suffix of font panel class to name of base class.
static java.lang.String MATERIAL
          Name of default material panel under which panel is registered in panel list.
static java.lang.String MATERIAL_EXT
          File name suffix of material panel class to name of base class.
static java.lang.String TEXTURE
          Name of default texture panel under which panel is registered in panel list.
static java.lang.String TEXTURE_EXT
          File name suffix of texture panel class to name of base class.
static java.lang.String VECTOR
          Name of default vector panel under which panel is registered in panel list.
static java.lang.String VECTOR_EXT
          File name suffix of vector panel class to name of base class.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PsPanel()
          Constructor of panel with PsStackLayout(1) as default layout manager.
PsPanel(java.awt.LayoutManager mgr)
          Constructor of panel with given layout manager.
 
Method Summary
 java.awt.Panel addLabelComponent(java.lang.String label, java.awt.Component comp)
          Add a label and a component in a horizontal panel with GridLayout(1, 2).
 void addLine(int size)
          Add a horizontal line with specified thickness as separator.
 java.awt.Label addSubTitle(java.lang.String aTitle)
          Add subtitle to panel in subheader font and return label.
 java.awt.TextField addTextField(java.lang.String label, int length)
          Add a label and textField in a horizontal panel with GridLayout(1, 2).
 java.awt.Label addTitle(java.lang.String aTitle)
          Add title to panel in header font and return the label.
static void drawBorder(java.awt.Component comp, java.awt.Graphics g, int borderType)
          Deprecated. use static void PsPanel.drawBorder(Graphics, borderType, Rectangle);
 void drawBorder(java.awt.Graphics g, int borderType)
          Draw border around this panel.
static void drawBorder(java.awt.Graphics g, int borderType, java.awt.Rectangle rectangle)
          Draw a rectangle into the given graphics context.
static void drawBorder(java.awt.Graphics g, int borderType, java.awt.Rectangle rectangle, java.awt.Color color)
          Draw a rectangle into the given graphics context with given color.
 void drawText(java.awt.Graphics g, java.awt.Point point, java.lang.String string)
          Draw text at specified position.
 PsUpdateIf getFather()
          Get the parent of this panel which receives update events.
 java.awt.Insets getInsets()
          Overwrite Container.getInsets() to create a border measured in pixels around this panel.
 java.lang.String getLanguage()
          Get language used in this panel.
 java.awt.Dimension getPreferredSize()
          Get the assigned preferred size, or whatever super provides.
 java.awt.Label getTitle()
          Get label of panel title, or null of no title exists.
 boolean hasTitle()
          Check whether panel has a title.
 void init()
           
 boolean instanceOf(java.lang.String aClassName)
          Deprecated. use "if (getClass() == PsObject.class)" instead
 void paint(java.awt.Graphics g)
          Call super.paint(g) and draw border around panel.
 void removeTitle()
          Remove label of panel title.
static boolean select(java.awt.Choice widget, int index)
          Update the selected index of a choice if the new index is different from the current selection of the widget.
 void setBackColor(java.awt.Color col)
          Assigned explicit background color such that container is not transparent.
 void setBorderType(int borderType)
          Set border of panel which is automatically drawn.
static boolean setEnabled(java.awt.Component widget, boolean bEnable)
          Assure that a component is enabled if requested.
 void setImage(java.awt.Image image)
          Deprecated. functionality will be moved into separate class in some future version.
 void setInsetSize(int size)
          Set the global inset size.
 void setInsetSizeHorizontal(int size)
          Set the vertical inset size to be used at top and bottom of this panel.
 void setInsetSizeVertical(int size)
          Set the vertical inset size to be used at top and bottom of this panel.
static boolean setLabel(java.awt.Button widget, java.lang.String text)
          Set the label of a button if it is different from the current label.
static boolean setLabel(java.awt.Checkbox widget, java.lang.String text)
          Set the label of a checkbox if it is different from the current label.
 void setOutOfDate(boolean state)
          Mark this panel as being not synchronized with the correct data of its parent.
 void setParent(PsUpdateIf parent)
          Set parent of this panel which receives update events.
 void setPreferredSize(int width, int height)
          Assigned preferred size.
static boolean setSelectedCheckbox(java.awt.CheckboxGroup widget, java.awt.Checkbox checkbox)
          In a checkbox group selected a checkbox if it is different from the current selection of the widget.
static boolean setState(java.awt.Checkbox widget, boolean bState)
          Assure that a checkbox has same state than corresponding boolean flag.
static boolean setText(java.awt.Label widget, java.lang.String text)
          Update the content of a label if the new content is different from the current content of the widget.
static boolean setText(java.awt.TextComponent widget, java.lang.String text)
          Update the content of a text field if the new content is different from the current content of the widget.
 void setTitle(java.lang.String title)
          Set string of panel title.
 void setVisible(boolean flag)
          Override Component.setVisible(boolean) to give panel a chance to update its content when is becomes visible.
 void update(java.awt.Graphics g)
          Override Component.update(Graphics) to avoid clearing the component if an image is available.
 boolean update(java.lang.Object event)
          Update the class whenever a child has changed.
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getListeners, getMaximumSize, getMinimumSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jv.object.PsUpdateIf
getName
 

Field Detail

INFO_EXT

public static final java.lang.String INFO_EXT
Identifier of class extension characterizing info panels.

See Also:
Constant Field Values

INFO

public static final java.lang.String INFO
Name of default info panel under which panel is registered in panel list.

See Also:
Constant Field Values

CONFIG_EXT

public static final java.lang.String CONFIG_EXT
File name suffix of control panel class to name of base class.

See Also:
Constant Field Values

CONFIG

public static final java.lang.String CONFIG
Name of default control panel under which panel is registered in panel list.

See Also:
Constant Field Values

LABEL_EXT

public static final java.lang.String LABEL_EXT
File name suffix of font panel class to name of base class.

See Also:
Constant Field Values

LABEL

public static final java.lang.String LABEL
Name of default font panel under which panel is registered in panel list.

See Also:
Constant Field Values

MATERIAL_EXT

public static final java.lang.String MATERIAL_EXT
File name suffix of material panel class to name of base class.

See Also:
Constant Field Values

MATERIAL

public static final java.lang.String MATERIAL
Name of default material panel under which panel is registered in panel list.

See Also:
Constant Field Values

TEXTURE_EXT

public static final java.lang.String TEXTURE_EXT
File name suffix of texture panel class to name of base class.

See Also:
Constant Field Values

TEXTURE

public static final java.lang.String TEXTURE
Name of default texture panel under which panel is registered in panel list.

See Also:
Constant Field Values

VECTOR_EXT

public static final java.lang.String VECTOR_EXT
File name suffix of vector panel class to name of base class.

See Also:
Constant Field Values

VECTOR

public static final java.lang.String VECTOR
Name of default vector panel under which panel is registered in panel list.

See Also:
Constant Field Values

BORDER_NONE

public static final int BORDER_NONE
See Also:
Constant Field Values

BORDER_LINE

public static final int BORDER_LINE
See Also:
Constant Field Values

BORDER_SUNK

public static final int BORDER_SUNK
See Also:
Constant Field Values

BORDER_GROOVE

public static final int BORDER_GROOVE
See Also:
Constant Field Values
Constructor Detail

PsPanel

public PsPanel()
Constructor of panel with PsStackLayout(1) as default layout manager.


PsPanel

public PsPanel(java.awt.LayoutManager mgr)
Constructor of panel with given layout manager. Provides better similarity with java.awt.Panel.

Since:
JavaView 2.90.000
Method Detail

init

public void init()

getPreferredSize

public java.awt.Dimension getPreferredSize()
Get the assigned preferred size, or whatever super provides.

Since:
JavaView 3.13.001

setPreferredSize

public void setPreferredSize(int width,
                             int height)
Assigned preferred size.

Since:
JavaView 3.13.001

setBackColor

public void setBackColor(java.awt.Color col)
Assigned explicit background color such that container is not transparent.

Since:
JavaView 3.13.001

getLanguage

public java.lang.String getLanguage()
Get language used in this panel.


setImage

public void setImage(java.awt.Image image)
Deprecated. functionality will be moved into separate class in some future version.

Image to be shown in the background of the canvas and set layout to null. Currently, this should only be used if no components are added to panel.


setVisible

public void setVisible(boolean flag)
Override Component.setVisible(boolean) to give panel a chance to update its content when is becomes visible. Parent of panel usually does not update panel if panel is hidden.


getFather

public PsUpdateIf getFather()
Get the parent of this panel which receives update events. The method setParent allows to set this parent.

Specified by:
getFather in interface PsUpdateIf
Returns:
parent parent of this panel
See Also:
getFather()

setParent

public void setParent(PsUpdateIf parent)
Set parent of this panel which receives update events.

The method getFather allows to retrieve this parent.

Specified by:
setParent in interface PsUpdateIf
Parameters:
parent - parent of this panel
See Also:
getFather()

update

public boolean update(java.lang.Object event)
Update the class whenever a child has changed. Method is usually invoked from the children.

Specified by:
update in interface PsUpdateIf
Parameters:
event - carries a lot of information
Returns:
true if event has been handled, otherwise false
See Also:
PsObject, PsUpdateIf.getFather(), PsUpdateIf.setParent(PsUpdateIf)

instanceOf

public final boolean instanceOf(java.lang.String aClassName)
Deprecated. use "if (getClass() == PsObject.class)" instead

Return true iff string is exact classname of current instance. Even if string denotes a super class method returns false. This method is different from Java operator instanceof which is true even if current instance is subclass of class 'aClassName'.

Parameters:
aClassName - name of class without package identifiers
Returns:
true if current object is exact instance of class

getInsets

public java.awt.Insets getInsets()
Overwrite Container.getInsets() to create a border measured in pixels around this panel. The border is either uniformly determined by setInsetSize(int) or by, additionally, specifying a vertical inset size using setInsetSizeVertical(int).

See Also:
setInsetSize(int), setInsetSizeVertical(int), setBorderType(int)

setInsetSize

public void setInsetSize(int size)
Set the global inset size. This call resets a previous vertical inset size to the new global inset size.


setInsetSizeHorizontal

public void setInsetSizeHorizontal(int size)
Set the vertical inset size to be used at top and bottom of this panel. Setting the global inset size with setInsetSize(int) at a later stage will overwrite this setting.

Since:
JavaView 3.09.002

setInsetSizeVertical

public void setInsetSizeVertical(int size)
Set the vertical inset size to be used at top and bottom of this panel. Setting the global inset size with setInsetSize(int) at a later stage will overwrite this setting.

Since:
JavaView 3.09.002

getTitle

public java.awt.Label getTitle()
Get label of panel title, or null of no title exists.


hasTitle

public boolean hasTitle()
Check whether panel has a title.


removeTitle

public void removeTitle()
Remove label of panel title.


setTitle

public void setTitle(java.lang.String title)
Set string of panel title. Method does not add the title to the panel. HACK: Also this method does not use the header font.


addTitle

public java.awt.Label addTitle(java.lang.String aTitle)
Add title to panel in header font and return the label.


addSubTitle

public java.awt.Label addSubTitle(java.lang.String aTitle)
Add subtitle to panel in subheader font and return label.


addLine

public void addLine(int size)
Add a horizontal line with specified thickness as separator.

Parameters:
size - thickness of line

addTextField

public java.awt.TextField addTextField(java.lang.String label,
                                       int length)
Add a label and textField in a horizontal panel with GridLayout(1, 2). This is a convenient method to reduce the code in inspectors.

Parameters:
label - label shown to the left of the text field
length - length of the text field
Returns:
TextField component

setText

public static boolean setText(java.awt.TextComponent widget,
                              java.lang.String text)
Update the content of a text field if the new content is different from the current content of the widget. This method is a shortcut and intended to be used in nearly all panels.

See additional comments in PsPanel#setEnabled(Component, boolean).

Parameters:
widget - the gui element which shall be updated
text - the new text of the text field
Returns:
true if the value has been update in this method.
Since:
JavaView 2.30

setText

public static boolean setText(java.awt.Label widget,
                              java.lang.String text)
Update the content of a label if the new content is different from the current content of the widget. This method is a shortcut and intended to be used in nearly all panels.

See additional comments in PsPanel#setEnabled(Component, boolean).

Parameters:
widget - the gui element which shall be updated
text - the new text of the label
Returns:
true if the value has been update in this method.
Since:
JavaView 2.30

select

public static boolean select(java.awt.Choice widget,
                             int index)
Update the selected index of a choice if the new index is different from the current selection of the widget. This method is a shortcut and intended to be used in nearly all panels.

See additional comments in PsPanel#setEnabled(Component, boolean).

Parameters:
widget - the gui element which shall be updated
index - the new selected index of the choice
Returns:
true if the value has been update in this method.
Since:
JavaView 2.30

setSelectedCheckbox

public static boolean setSelectedCheckbox(java.awt.CheckboxGroup widget,
                                          java.awt.Checkbox checkbox)
In a checkbox group selected a checkbox if it is different from the current selection of the widget. This method is a shortcut and intended to be used in nearly all panels.

See additional comments in PsPanel#setEnabled(Component, boolean).

Parameters:
widget - the gui element which shall be updated
checkbox - the new selected checkbox
Returns:
true if the value has been update in this method.
Since:
JavaView 2.30

setState

public static boolean setState(java.awt.Checkbox widget,
                               boolean bState)
Assure that a checkbox has same state than corresponding boolean flag. If state of checkbox is equal to the requested new state then do nothing.

See additional comments in PsPanel#setEnabled(Component, boolean).

Parameters:
widget - Checkbox
bState - Requested new state of the checkbox
Returns:
true if the value has been update in this method.
Since:
JavaView 2.30

setLabel

public static boolean setLabel(java.awt.Button widget,
                               java.lang.String text)
Set the label of a button if it is different from the current label. If label of button is equal to the requested new label then do nothing.

See additional comments in PsPanel#setEnabled(Component, boolean).

Parameters:
widget - Button
text - new label of the widget
Returns:
true if the value has been update in this method.
Since:
JavaView 2.30

setLabel

public static boolean setLabel(java.awt.Checkbox widget,
                               java.lang.String text)
Set the label of a checkbox if it is different from the current label. If label of checkbox is equal to the requested new label then do nothing.

See additional comments in PsPanel#setEnabled(Component, boolean).

Parameters:
widget - Checkbox
text - new label of the widget
Returns:
true if the value has been update in this method.
Since:
JavaView 2.30

setEnabled

public static boolean setEnabled(java.awt.Component widget,
                                 boolean bEnable)
Assure that a component is enabled if requested. If state of component is equal to the requested new state then do nothing.

Note: never call one of the static helper methods from an overwritten method with the same name. For example, if MyLabel extends Label and MyLabel#setEnabled(boolean) exists. Then an invocation of PsPanel.setEnabled(this, boolean) in MyLabel#setEnabled would lead to loop since PsPanel.setEnabled calls MyLabel#setEnabled.

Parameters:
widget - Component
bEnable - Requested new state of the component
Returns:
true if the value has been update in this method.
Since:
JavaView 2.30

addLabelComponent

public java.awt.Panel addLabelComponent(java.lang.String label,
                                        java.awt.Component comp)
Add a label and a component in a horizontal panel with GridLayout(1, 2). This is a convenient method to reduce the code in inspectors.

Parameters:
label - text shown to the left of the component
comp - component shown to the right of the label
Returns:
panel showing label and component

drawText

public void drawText(java.awt.Graphics g,
                     java.awt.Point point,
                     java.lang.String string)
Draw text at specified position.


drawBorder

public static void drawBorder(java.awt.Graphics g,
                              int borderType,
                              java.awt.Rectangle rectangle)
Draw a rectangle into the given graphics context.

See Also:
drawBorder(Graphics, int, Rectangle, Color)

drawBorder

public static void drawBorder(java.awt.Graphics g,
                              int borderType,
                              java.awt.Rectangle rectangle,
                              java.awt.Color color)
Draw a rectangle into the given graphics context with given color.

Since:
JavaView 2.47
See Also:
drawBorder(Graphics, int, Rectangle)

drawBorder

public void drawBorder(java.awt.Graphics g,
                       int borderType)
Draw border around this panel.


drawBorder

public static void drawBorder(java.awt.Component comp,
                              java.awt.Graphics g,
                              int borderType)
Deprecated. use static void PsPanel.drawBorder(Graphics, borderType, Rectangle);

Draw border around panel. Method calls PsPanel.drawBorder(g, borderType, new Rectangle(comp.getSize()));


setBorderType

public void setBorderType(int borderType)
Set border of panel which is automatically drawn. If borderType==PsPanel.BORDER_NONE drawing is disabled, otherwise the borderType is set and drawing is enabled.

Parameters:
borderType - type of border, for possible values see PsPanel.
See Also:
paint(Graphics)

setOutOfDate

public void setOutOfDate(boolean state)
Mark this panel as being not synchronized with the correct data of its parent. Usually, this method is invoked whenever a parent changes but this panel is temporarily not visible. In this case the next invocation of this paint(Graphics) method will at first update this panel with new data from its parent by calling this.update(m_parent).


paint

public void paint(java.awt.Graphics g)
Call super.paint(g) and draw border around panel. If this panel is out of date, then this panel is first synchronised with new data from its parent by calling this.update(m_parent).

If this panel has an image then the image is drawn before super.paint(Graphics) is called.

See Also:
setBorderType(int)

update

public void update(java.awt.Graphics g)
Override Component.update(Graphics) to avoid clearing the component if an image is available.


JavaView© v3.95.000

The software JavaView© is copyright protected. All Rights Reserved.