org.geotoolkit.gui.swing
Class LoggingPanel

Object
  extended by Component
      extended by Container
          extended by JComponent
              extended by LoggingPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Disposable

public class LoggingPanel
extends JComponent
implements Disposable

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

new LoggingPanel("org.geotoolkit").show(null);
This panel initially listens to all messages (Level.ALL). However the messages will still be filtered according the logger level. If all levels are really aimed to be reported, then a call to Logger.setLevel(Level.ALL) may be needed.

Note that a different level can be set specifically to this LoggingPanel with a call to getHandler().setLevel(aLevel). However this is only for restricting the logger messages to a higher level than the logger level.

Since:
2.0
Version:
3.12
Author:
Martin Desruisseaux (IRD, Geomatys)
See Also:
Serialized Form
Module:
display/geotk-widgets-swing (download)    View source code for this class

Nested Class Summary
static class LoggingPanel.Column
          Enumeration class for columns to be shown in a LoggingPanel.
 
Nested classes/interfaces inherited from class JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class 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 Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
LoggingPanel()
          Constructs a new logging panel.
LoggingPanel(Logger logger)
          Constructs a new logging panel and register it to the specified logger.
LoggingPanel(String logger)
          Constructs a logging panel and register it to the specified logger.
 
Method Summary
 void dispose()
          Frees any resources used by this LoggingPanel.
 void doLayout()
          Layout this component.
 Color getBackground(Level level)
          Returns the background color for the specified log record.
 int getCapacity()
          Returns the maximum number of LogRecords the handler can memorize.
 Color getForeground(Level level)
          Returns the foreground color for the given level.
 Handler getHandler()
          Returns the logging handler.
 Font getMessageFont()
          Returns the font to use for displaying the messages (last table column).
 boolean isColumnVisible(LoggingPanel.Column column)
          Returns true if the given column is visible.
 void setCapacity(int capacity)
          Sets the maximum number of LogRecords the handler can memorize.
 void setColumnVisible(LoggingPanel.Column column, boolean visible)
          Shows or hide the given column.
 void setLevelColor(Level level, Color foreground, Color background)
          Sets the foreground and background colors for messages of the specified level.
 void setMessageFont(Font font)
          Sets the font to use for displaying the messages.
 Component show(Component owner)
          Convenience method showing this logging panel into a frame.
 
Methods inherited from class JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, 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, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class 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, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, 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, transferFocusUpCycle
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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(Logger logger)
Constructs a new logging panel and register it to the specified logger.

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

LoggingPanel

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

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

getHandler

public Handler getHandler()
Returns the logging handler. This is the handler to register to loggers in order to get logging message to appear in the widget. This registration had been done automatically if this widget has been created with any constructor except the no-argument one.

Returns:
The logging handler.

isColumnVisible

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

Parameters:
column - The column to show or hide.
Returns:
true if the given column is visible.

setColumnVisible

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

Parameters:
column - The column to show or hide.
visible - The visible state for the specified column.

getCapacity

public int getCapacity()
Returns the maximum number of LogRecords the handler can memorize. If more messages are logged, then the earliest messages will be discarded.

Returns:
The current maximum number of record.

setCapacity

public void setCapacity(int capacity)
Sets the maximum number of LogRecords the handler can memorize. If more messages are logged, then the earliest messages will be discarded.

Parameters:
capacity - The new maximum number of record.

getMessageFont

public Font getMessageFont()
Returns the font to use for displaying the messages (last table column). The default is a monospaced font because some message are formatted for the console (for example they may use the drawing unicode characters).

Returns:
The font to use for displaying messages.
Since:
3.01

setMessageFont

public void setMessageFont(Font font)
Sets the font to use for displaying the messages.

Parameters:
font - The new font for displaying messages.
Since:
3.01

getForeground

public Color getForeground(Level level)
Returns the foreground color for the given level.

Parameters:
level - The level for which to get the foreground color.
Returns:
The foreground color for the given level, or null for the default color.
Since:
3.01

getBackground

public Color getBackground(Level level)
Returns the background color for the specified log record. This method returns a color based on the record level, using colors set with setLevelColor(...).

Parameters:
level - The level for which to get the background color.
Returns:
The background color for the given level, or null for the default color.
Since:
3.01

setLevelColor

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

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

doLayout

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

Overrides:
doLayout in class Container

show

public Component show(Component owner)
Convenience method showing this logging panel into a frame. Different kinds of frame can be constructed according the owner class:

Parameters:
owner - The owner, or null 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()
Frees any resources used by this LoggingPanel. If a Logger was specified at construction time, then this method unregister the LoggingPanel's handler from the specified logger. Next, Handler.close() is invoked.

This method is invoked automatically when the user closes the windows created with show(Component). If this LoggingPanel is displayed by some other ways (for example if it has been added into a JPanel), then this dispose() method must be invoked explicitly when the container is being discarded.

Specified by:
dispose in interface Disposable


Copyright © 2009-2013 Geotoolkit.org. All Rights Reserved.