Imp
[using it]
Interface Manipulation Package v4.0 (2008-06-25) a-projector ©copyright Author


imp.gui
Class GraphicsViewer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by imp.gui.IComponent
                      extended by imp.gui.GraphicsViewer
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class GraphicsViewer
extends IComponent

Defines a panel in which 2D graphics is displayed.

E.g.: <imp-gui:graphics-viewer interaction='reticule' bgcolor='yellow'>
<icon x='240' y='100' icon='./../tools/doc-files/projector.gif'/>
<label x='60' y='60' text='<h1>Hi ! <font color=red>You</font></h1>'/>
<rectangle x='350' y='50' width='40' height='30' bgcolor='green' color='red'/>
<oval x='350' y='50' width='40' color='blue'/>
</imp-gui:graphics-viewer>
The origin is the upper-left graphics-viewer corner with rightward and downward directions, as in an image

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
 
Method Summary
 GraphicsViewer add(int depth, Value component)
          Adds a XML graphical element and return this.
 JComponent addImage(int depth, int x, int y, BufferedImage image)
          Adds an image or icon to this canvas.
 JComponent addLabel(int depth, int x, int y, String text)
          Adds a textual label to this canvas.
 Polyline addPolyline(int depth, Polygon polygon, boolean closed, String bgcolor, String color)
          Adds a polyline to this canvas.
 JComponent get(int index)
          Gets the component of the given index.
 String getInteraction()
          Gets the interaction mode.
 void outputValue(String value)
          Called when a mouse interaction is output.
 void remove(JComponent component)
          Remove a component.
 void removeAll()
          Removes all components.
 GraphicsViewer setInteraction(String interaction)
          Sets the interaction mode and return this.
 
Methods inherited from class imp.gui.IComponent
getBgcolor, getColor, getTextFont, getTitle, getTooltip, grab, refresh, setBgcolor, setColor, setHeight, setTextFont, setTitle, setTooltip, setWidth
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

add

public GraphicsViewer add(int depth,
                          Value component)
Adds a XML graphical element and return this.

Parameters:
depth - [optional, default is -1] Element depth, acts as an index. A value of -1 indicates the bottommost position. A value of 0 indicates the topmost position: higher position values are lower in the display.
component - An element defined by a set of field's value.
As String:
An element defined by a string.
icon <icon x= .. y= .. d= .. icon = {icon-URL}/>
label <label x= .. y= .. d= .. text = {text-in-HTML-format}/>
polygon <polygon x-a={1st-horizontal-position} y-a={1st-vertical-position} x-b={2nd-..}.. d= .. closed={true-or-false} color/bgcolor= .. />
cross <cross x= .. y= .. d= .. form= .. size= .. color= .. />
rectangle (also called square) <rectangle x= .. y= .. d= .. width= .. height= .. color/bgcolor= .. />
line (also called arrow) <line x-a= .. x-b= .. y-a= .. y-b= .. arrow = {true-or-false} color= .. />
line (also called arrow) <line x= .. y= .. d= .. size= .. orientation= .. arrow = {true-or-false} color= .. />
oval (also called circle) <oval x= .. y= .. d= .. width= .. height= .. orientation= .. rectangularity={0.1 .. 10} color/bgcolor= .. />
ellipse <ellipse x= .. y= .. d= .. Ixx={2nd-order-xx-momentum} Ixy={2nd-order-xy-momentum} Iyy={2nd-order-yy-momentum} color/bgcolor= .. />
Here:
d= .. is the optional object/polygon index, defining its depth: the highest index corresponds to the higher layer.
(x= .. , y= .. ) is the object/polygon central position in pixel.
A polygon can be closed or open (i.e. a polyline).
size= .. , width= .. and height= .. are the polygon sizes and orientation= .. is the polygon orientation in radian.
color= .. is the polygon color. If bgcolor= .. is defined the polygon is filled with this color.
An oval is a so-called hyper-ellipse of equation: (x/width)^r + (y/height)^r = 1, where r is the rectangularity . With r=2 this is a simple ellipse. The higher r, the more rectangular the oval.
An ellipse is also defined by second order momenta, i.e. with the equation: x^2 / Ixx + 2 x y / Ixy + y^2 / Iyy = 1.
The cross size default is 5 and the cross form could be 'x' for a x cross (default), '+' for a + cross, 's' for a square, 'o' for a circle.

addImage

public JComponent addImage(int depth,
                           int x,
                           int y,
                           BufferedImage image)
Adds an image or icon to this canvas.

Parameters:
depth - [optional, default is -1] Element depth, acts as an index. A value of -1 indicates the bottommost position. A value of 0 indicates the topmost position: higher position values are lower in the display.
x - [optional, default is position the image in the upper-left corner] Image horizontal central position.
y - [optional, default is position the image in the upper-left corner] Image vertical central position.
image - The image to show.
As String:
The image URL location to show.
Returns:
The added swing component.

addLabel

public JComponent addLabel(int depth,
                           int x,
                           int y,
                           String text)
Adds a textual label to this canvas.

Parameters:
depth - [optional, default is -1] Element depth, acts as an index. A value of -1 indicates the bottommost position. A value of 0 indicates the topmost position: higher position values are lower in the display.
x - Label horizontal central position.
y - Label vertical central position.
text - The label text.
Returns:
The added swing component.

addPolyline

public Polyline addPolyline(int depth,
                            Polygon polygon,
                            boolean closed,
                            String bgcolor,
                            String color)
Adds a polyline to this canvas.

Parameters:
depth - [optional, default is -1] Element depth, acts as an index. A value of -1 indicates the bottommost position. A value of 0 indicates the topmost position: higher position values are lower in the display.
polygon - Points defining this polyline (see the Polyline factory for predefined polygons: points, lines, ellipses, ..).
closed - [optional, default is false] True if the polyline is closed (thus a geometric polygon), false if an open polyline.
bgcolor - [optional, default is null] Polygon fill color, if any (i.e if not null).
color - Polyline border color, if any (else null).
Returns:
The added swing component.

get

public JComponent get(int index)
Gets the component of the given index.

Parameters:
index - The component index.
Returns:
The component of the given index.

getInteraction

public String getInteraction()
Gets the interaction mode.


outputValue

public void outputValue(String value)
Called when a mouse interaction is output.

Parameters:
value - The mouse interaction value.

remove

public void remove(JComponent component)
Remove a component.


removeAll

public void removeAll()
Removes all components.

Overrides:
removeAll in class Container

setInteraction

public GraphicsViewer setInteraction(String interaction)
Sets the interaction mode and return this.

Parameters:
interaction - The mouse interaction.