com.tecnick.jwtm
Class BgPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by com.tecnick.jwtm.BgPanel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class BgPanel
extends java.awt.Panel

Title: Background Panel

Description: Class to draw panel with image background


Copyright (c) 2002-2006 Tecnick.com S.r.l (www.tecnick.com) Via Ugo Foscolo n.19 - 09045 Quartu Sant'Elena (CA) - ITALY - www.tecnick.com - info@tecnick.com
Project homepage: http://jxhtmledit.sourceforge.net
License: http://www.gnu.org/copyleft/gpl.html GPL 2

Version:
1.1.003
Author:
Nicola Asuni [www.tecnick.com].
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  java.awt.Image bg_image
          background image
static int BOTTOM
          constant for BOTTOM position
private  java.awt.Graphics bufferGraphics
          graphics for double buffering
static int CENTER
          constant for CENTER position
private  int img_h
          Background image height
private  int img_w
          Background image width
static int LEFT
          constant for LEFT position
private  int mode
           
private  java.awt.Image offscreen
          offscreen image to handle double buffering
private  int pnl_h
          Panel height
private  int pnl_w
          Panel width
static int RIGHT
          constant for RIGHT position
private static long serialVersionUID
          serialVersionUID
static int STRETCH
          constant for STRETCH mode
private  boolean stretch_done
          remember when image stretching is done (to avoid loops)
private  java.awt.Image stretched_img
          stetched copy of background image
static int TILE
          constant for TILE mode
static int TOP
          constant for TOP position
 
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
BgPanel()
          Build a void bakground panel.
BgPanel(java.awt.Image i, int m)
          Build Panel with background image.
 
Method Summary
private  void doImageStretch()
          stretch image
private  void getSizes()
          Get image and panel size.
 void paint(java.awt.Graphics g)
          Paint panel with background.
 void setImage(java.awt.Image i)
          Set background image.
 void setMode(int m)
          Set image display mode.
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, 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, getMousePosition, 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, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
serialVersionUID

See Also:
Constant Field Values

bufferGraphics

private java.awt.Graphics bufferGraphics
graphics for double buffering


offscreen

private java.awt.Image offscreen
offscreen image to handle double buffering


bg_image

private java.awt.Image bg_image
background image


stretched_img

private java.awt.Image stretched_img
stetched copy of background image


img_w

private int img_w
Background image width


img_h

private int img_h
Background image height


pnl_w

private int pnl_w
Panel width


pnl_h

private int pnl_h
Panel height


stretch_done

private boolean stretch_done
remember when image stretching is done (to avoid loops)


LEFT

public static final int LEFT
constant for LEFT position

See Also:
Constant Field Values

TOP

public static final int TOP
constant for TOP position

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
constant for RIGHT position

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
constant for BOTTOM position

See Also:
Constant Field Values

CENTER

public static final int CENTER
constant for CENTER position

See Also:
Constant Field Values

STRETCH

public static final int STRETCH
constant for STRETCH mode

See Also:
Constant Field Values

TILE

public static final int TILE
constant for TILE mode

See Also:
Constant Field Values

mode

private int mode
Constructor Detail

BgPanel

public BgPanel()
Build a void bakground panel.


BgPanel

public BgPanel(java.awt.Image i,
               int m)
Build Panel with background image.

Parameters:
i - image to display as background.
m - Display Mode. Possible values are: BgPanel.TILE, BgPanel.CENTER, BgPanel.STRETCH, BgPanel.LEFT, BgPanel.RIGHT.
Method Detail

setImage

public void setImage(java.awt.Image i)
Set background image.

Parameters:
i - image

setMode

public void setMode(int m)
Set image display mode.

Parameters:
m - Display Mode. Possible values are: BgPanel.TILE, BgPanel.CENTER, BgPanel.STRETCH, BgPanel.LEFT, BgPanel.RIGHT.

getSizes

private void getSizes()
Get image and panel size.


paint

public void paint(java.awt.Graphics g)
Paint panel with background.

Overrides:
paint in class java.awt.Container
Parameters:
g - graphics context

doImageStretch

private void doImageStretch()
stretch image