Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.geotools.gui.swing
Class LoggingPanel  view LoggingPanel download LoggingPanel.java

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.geotools.gui.swing.LoggingPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class LoggingPanel
extends javax.swing.JPanel

A panel displaying logging messages. The windows displaying Geotools's logging messages can be constructed with the following code:

 new LoggingPanel("org.geotools").show 55 (null);
 
This panel is initially set to listen to messages of level Level.CONFIG>Level.CONFIG 55 or higher. This level can be changed with getHandler() 55 .setLevel(aLevel).

Version:
$Id: LoggingPanel.java,v 1.5 2003/02/09 23:38:11 lbruand Exp $

Nested Class Summary
private  class LoggingPanel.CellRenderer
          Display cell contents.
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.String CVSID
           
private  java.util.List levelColors
          Pairs of foreground and background colors to use for displaying logging messages.
private  int[] levelValues
          The levels for colors enumerated in levelColors.
private  java.util.logging.Logger logger
          The logger specified at construction time, or null if none.
private  LoggingTableModel model
          The model for this component.
private  javax.swing.JTable table
          The table for displaying logging messages.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
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
LoggingPanel()
          Constructs a new logging panel.
LoggingPanel(java.util.logging.Logger logger)
          Constructs a new logging panel and register it to the specified logger.
LoggingPanel(java.lang.String logger)
          Construct a logging panel and register it to the specified logger.
 
Method Summary
 void dispose()
          Free any resources used by this LoggingPanel.
 void doLayout()
          Layout this component.
 java.awt.Color getBackground(java.util.logging.LogRecord record)
          Returns the background color for the specified log record.
 int getCapacity()
          Returns the capacity.
private  java.awt.Color getColor(java.util.logging.LogRecord record, int offset)
          Returns the foreground or background color for the specified record.
 java.awt.Color getForeground(java.util.logging.LogRecord record)
          Returns the foreground color for the specified log record.
 java.util.logging.Handler getHandler()
          Returns the logging handler.
 void setCapacity(int capacity)
          Set the capacity.
 void setLevelColor(java.util.logging.Level level, java.awt.Color foreground, java.awt.Color background)
          Set the foreground and background colors for messages of the specified level.
 java.awt.Component show(java.awt.Component owner)
          Convenience method showing this logging panel into a frame.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusDownCycle, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, 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, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, 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, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CVSID

public static final java.lang.String CVSID
See Also:
Constant Field Values

model

private final LoggingTableModel model
The model for this component.


table

private final javax.swing.JTable table
The table for displaying logging messages.


levelValues

private int[] levelValues
The levels for colors enumerated in levelColors. This array must be in increasing order. Logging messages of level levelValues[i] or higher will be displayed with foreground color levelColors[i*2] and background color levelColors[i*2+1].

See Also:
Level.intValue()>Level.intValue() 55 , getForeground(LogRecord) 55 , getBackground(LogRecord) 55

levelColors

private final java.util.List levelColors
Pairs of foreground and background colors to use for displaying logging messages. Logging messages of level levelValues[i] or higher will be displayed with foreground color levelColors[i*2] and background color levelColors[i*2+1].

See Also:
getForeground(LogRecord) 55 , getBackground(LogRecord) 55

logger

private java.util.logging.Logger logger
The logger specified at construction time, or null if none.

Constructor Detail

LoggingPanel

public LoggingPanel()
Constructs a new logging panel. This panel is not registered to any logger. Registration can be done with the following code:
 logger.addHandler 55 (getHandler() 55 );
 


LoggingPanel

public LoggingPanel(java.util.logging.Logger logger)
Constructs a new logging panel and register it to the specified logger.


LoggingPanel

public LoggingPanel(java.lang.String logger)
Construct a logging panel and register it to the specified logger.

Method Detail

getHandler

public java.util.logging.Handler getHandler()
Returns the logging handler.


getCapacity

public int getCapacity()
Returns the capacity. This is the maximum number of java.util.logging.LogRecords the handler can memorize. If more messages are logged, then the earliest messages will be discarted.


setCapacity

public void setCapacity(int capacity)
Set the capacity. This is the maximum number of java.util.logging.LogRecords the handler can memorize. If more messages are logged, then the earliest messages will be discarted.


getForeground

public java.awt.Color getForeground(java.util.logging.LogRecord record)
Returns the foreground color for the specified log record. This method is invoked at rendering time for every cell in the table's "message" column. The default implementation returns a color based on the record's level, using colors set with setLevelColor(java.util.logging.Level, java.awt.Color, java.awt.Color) 55 .


getBackground

public java.awt.Color getBackground(java.util.logging.LogRecord record)
Returns the background color for the specified log record. This method is invoked at rendering time for every cell in the table's "message" column. The default implementation returns a color based on the record's level, using colors set with setLevelColor(java.util.logging.Level, java.awt.Color, java.awt.Color) 55 .


getColor

private java.awt.Color getColor(java.util.logging.LogRecord record,
                                int offset)
Returns the foreground or background color for the specified record.


setLevelColor

public void setLevelColor(java.util.logging.Level level,
                          java.awt.Color foreground,
                          java.awt.Color background)
Set the foreground and background colors for messages of the specified level. The specified colors will apply on any messages of level level or greater, up to the next level set with an other call to setLevelColor(...).


doLayout

public void doLayout()
Layout this component. This method give all the remaining space, if any, to the last table's column. This column is usually the one with logging messages.


show

public java.awt.Component show(java.awt.Component owner)
Convenience method showing this logging panel into a frame. Different kinds of frame can be constructed according owner class:
  • If owner or one of its parent is a JDesktopPane, then panel is added into a JInternalFrame.
  • If owner or one of its parent is a Frame or a Dialog, then panel is added into a JDialog.
  • Otherwise, panel is added into a JFrame.


dispose

public void dispose()
Free any resources used by this LoggingPanel. If a java.util.logging.Logger was specified at construction time, then this method unregister the LoggingPanel's handler from the specified logger. Next, Handler.close()>Handler.close() 55 is invoked.

This method is invoked automatically when the user close the windows created with show(Component) 55 . If this LoggingPanel is displayed by some other ways (for example if it has been added into a javax.swing.JPanel), then this dispose() should be invoked explicitely when the container is being discarted.