org.geotools.gui.swing
Class LoggingPanel

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(null);
 
This panel is initially set to listen to messages of level Level.CONFIG or higher. This level can be changed with getHandler().setLevel(aLevel).

Since:
2.0
Version:
$Id: LoggingPanel.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux
See Also:
Serialized Form

Nested Class Summary
static class LoggingPanel.Column
          Enumeration class for columns to be shown in a LoggingPanel.
 
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 LoggingPanel.Column CLASS
          Constant for setColumnVisible(org.geotools.gui.swing.LoggingPanel.Column, boolean).
static LoggingPanel.Column LEVEL
          Constant for setColumnVisible(org.geotools.gui.swing.LoggingPanel.Column, boolean).
static LoggingPanel.Column LOGGER
          Constant for setColumnVisible(org.geotools.gui.swing.LoggingPanel.Column, boolean).
static LoggingPanel.Column MESSAGE
          Constant for setColumnVisible(org.geotools.gui.swing.LoggingPanel.Column, boolean).
static LoggingPanel.Column METHOD
          Constant for setColumnVisible(org.geotools.gui.swing.LoggingPanel.Column, boolean).
static LoggingPanel.Column TIME_OF_DAY
          Constant for setColumnVisible(org.geotools.gui.swing.LoggingPanel.Column, boolean).
 
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.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 .
 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.
 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.
 boolean isColumnVisible(LoggingPanel.Column column)
          Returns if the given column is visible.
 void setCapacity(int capacity)
          Set the capacity.
 void setColumnVisible(LoggingPanel.Column column, boolean visible)
          Show or hide the given column.
 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, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, 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, getPropertyChangeListeners, getPropertyChangeListeners, 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, removePropertyChangeListener, removePropertyChangeListener, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, 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, 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, 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, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, 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

LOGGER

public static final LoggingPanel.Column LOGGER
Constant for setColumnVisible(org.geotools.gui.swing.LoggingPanel.Column, boolean).


CLASS

public static final LoggingPanel.Column CLASS
Constant for setColumnVisible(org.geotools.gui.swing.LoggingPanel.Column, boolean).


METHOD

public static final LoggingPanel.Column METHOD
Constant for setColumnVisible(org.geotools.gui.swing.LoggingPanel.Column, boolean).


TIME_OF_DAY

public static final LoggingPanel.Column TIME_OF_DAY
Constant for setColumnVisible(org.geotools.gui.swing.LoggingPanel.Column, boolean).


LEVEL

public static final LoggingPanel.Column LEVEL
Constant for setColumnVisible(org.geotools.gui.swing.LoggingPanel.Column, boolean).


MESSAGE

public static final LoggingPanel.Column MESSAGE
Constant for setColumnVisible(org.geotools.gui.swing.LoggingPanel.Column, boolean).

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(getHandler());
 


LoggingPanel

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

Parameters:
logger - The logger to listen to, or for the root logger.

LoggingPanel

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

Parameters:
logger - The logger name to listen to, or for the root logger.
Method Detail

getHandler

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


isColumnVisible

public boolean isColumnVisible(LoggingPanel.Column column)
Returns if the given column is visible.

Parameters:
column - The column to show or hide. May be one of LOGGER, CLASS, METHOD, TIME_OF_DAY, LEVEL or MESSAGE.

setColumnVisible

public void setColumnVisible(LoggingPanel.Column column,
                             boolean visible)
Show or hide the given column.

Parameters:
column - The column to show or hide. May be one of LOGGER, CLASS, METHOD, TIME_OF_DAY, LEVEL or MESSAGE.
visible - The visible state for the specified column.

getCapacity

public int getCapacity()
Returns the capacity. This is the maximum number of 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 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).

Parameters:
record - The record to get the foreground color.
Returns:
The foreground color for the specified record, or for the default color.

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).

Parameters:
record - The record to get the background color.
Returns:
The background color for the specified record, or for the default color.

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 or greater, up to the next level set with an other call to .

Parameters:
level - The minimal level to set color for.
foreground - The foreground color, or for the default color.
background - The background color, or for the default color.

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 class:

Parameters:
owner - The owner, or to show this logging panel in a top-level window.
Returns:
The frame. May be a JInternalFrame, a JDialog or a JFrame.

dispose

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

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



Copyright © GeoTools. All Rights Reserved.