JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.util.legend
Class JCGridLegend

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--com.klg.jclass.util.legend.JCLegend
                          |
                          +--com.klg.jclass.util.legend.JCGridLegend
All Implemented Interfaces:
Changeable, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
JCMultiColLegend

public class JCGridLegend
extends JCLegend

JCGridLegend manages and renders a grid-based legend. It overrides JCLegend's layout methods to position legend items in a grid, where every row has the same height and every column the same width.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 int[] colWidths
           
protected  int groupGap
           
protected  int insideItemGap
           
protected  int itemGap
           
protected  int marginGap
           
 int[] rowFirstLineHeights
           
 int[] rowHeights
           
 int[] strWidths
           
 int[] symWidths
           
 
Fields inherited from class com.klg.jclass.util.legend.JCLegend
anchor, ascent, BOX, BOX_PLAIN, cachedFont, cachedVertical, cellRendererPane, changed, changedFlag, CUSTOM_ALL, CUSTOM_SYMBOL, descent, EAST, EASTWEST_MASK, HORIZONTAL, IMAGE, IMAGE_OUTLINED, imageMapInfo, legendItems, legendPopulator, legendRenderer, LINE, locale, NONE, NORTH, NORTHEAST, NORTHSOUTH_MASK, NORTHWEST, orientation, preferredSize, ps, SOUTH, SOUTHEAST, SOUTHWEST, symbolSize, textRend, updateParent, VERTICAL, WEST
 
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 com.klg.jclass.util.Changeable
BASIC_CHANGE_MASK, LAYOUT, NO_CHANGE, NOTIFY_PARENT_LAYOUT, RECALC, REDRAW
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JCGridLegend()
           
 
Method Summary
 Dimension calcLegendSize(boolean vert)
          Calculates the size of the legend based on the height and width of rows and columns.
 void fillSizeArrays(List itemList, boolean vert, Font useFont)
          Cacluates the size of each row and column.
 int getGroupGap()
          Gets the gap between the groups of items in the legend (for example, the columns/rows associated with a data view).
 int getInsideItemGap()
          Gets the gap between the symbol and text portions of a legend item.
 int getItemGap()
          Gets the gap between the legend items in the same group.
 int getMarginGap()
          Gets the gap between the edge of the legend and where the items start being layed out.
 Dimension layoutLegend(List itemList, boolean vertical, Font useFont)
          Overrides JCLegend's layoutLegend() to layout the legend items in a grid, calculating the overall size of the legend.
 void layoutLegendItems(List itemList, boolean vert)
          Lays out the legend items from the legend vector by calculating their position within the legend and filling that in the JCLegendItem instances that define the legend item.
 Point positionItemSymbol(boolean vertical, com.klg.jclass.util.legend.JCLegendItem thisItem, Dimension boxDim, Point startPos)
          Positions an legend item's symbol component.
 Point positionItemText(boolean vertical, com.klg.jclass.util.legend.JCLegendItem thisItem, Dimension boxDim, Point startPos)
           
 void setGroupGap(int gap)
          Sets the gap between the groups of items in the legend (for example, the columns/rows associated with a data view).
 void setInsideItemGap(int gap)
          Sets the gap between the symbol and text portions of a legend item.
 void setItemGap(int gap)
          Sets the gap between the legend items in the same group.
 void setMarginGap(int gap)
          Sets the gap between the edge of the legend and where the items start being layed out.
 
Methods inherited from class com.klg.jclass.util.legend.JCLegend
checkAnchor, drawLegendItem, getAnchor, getCellRendererPane, getChanged, getChanged, getDrawingArea, getDrawingArea, getGraphics, getImageMapInfo, getLegendItems, getLegendPopulator, getLegendRenderer, getOrientation, getPreferredSize, getSymbolSize, getTextRenderer, isBatched, isChanged, isChanged, isTitleItem, paintComponent, pick, recalc, setAnchor, setChanged, setChanged, setGraphics, setImageMapInfo, setLegendPopulator, setLegendRenderer, setLocale, setOrientation, setPreferredSize, setUpLegendVariables, updateParent
 
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, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, 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, 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

rowHeights

public int[] rowHeights

rowFirstLineHeights

public int[] rowFirstLineHeights

colWidths

public int[] colWidths

symWidths

public int[] symWidths

strWidths

public int[] strWidths

marginGap

protected int marginGap

itemGap

protected int itemGap

insideItemGap

protected int insideItemGap

groupGap

protected int groupGap
Constructor Detail

JCGridLegend

public JCGridLegend()
Method Detail

setMarginGap

public void setMarginGap(int gap)
Sets the gap between the edge of the legend and where the items start being layed out.

Parameters:
gap - the margin gap

getMarginGap

public int getMarginGap()
Gets the gap between the edge of the legend and where the items start being layed out.

Returns:
the margin gap

setItemGap

public void setItemGap(int gap)
Sets the gap between the legend items in the same group.

Parameters:
gap - the item gap

getItemGap

public int getItemGap()
Gets the gap between the legend items in the same group.

Returns:
the item gap

setInsideItemGap

public void setInsideItemGap(int gap)
Sets the gap between the symbol and text portions of a legend item.

Parameters:
gap - the inside item gap

getInsideItemGap

public int getInsideItemGap()
Gets the gap between the symbol and text portions of a legend item.

Returns:
the inside item gap

setGroupGap

public void setGroupGap(int gap)
Sets the gap between the groups of items in the legend (for example, the columns/rows associated with a data view).

Parameters:
gap - the group gap

getGroupGap

public int getGroupGap()
Gets the gap between the groups of items in the legend (for example, the columns/rows associated with a data view).

Returns:
the group gap

layoutLegend

public Dimension layoutLegend(List itemList,
                              boolean vertical,
                              Font useFont)
Overrides JCLegend's layoutLegend() to layout the legend items in a grid, calculating the overall size of the legend. This is accomplished by filling in the dim, pos, textPos, and symPos member of each JCLegendItem instance in the legend vector. The pickRectangle member is also filled in.

Specified by:
layoutLegend in class JCLegend
Parameters:
itemList - the legend vector, which contains a number of group vectors; each group vector contains the legend items (JCLegendItem instances) for that group
vertical - true if a vertical legend, false if a horizontal legend
useFont - the font for the legend
Returns:
the size of the legend

fillSizeArrays

public void fillSizeArrays(List itemList,
                           boolean vert,
                           Font useFont)
Cacluates the size of each row and column.

Parameters:
itemList - the legend vector of groups and item
vert - true if a vertical legend, false if a horizontal legend
useFont - the font for the legend

calcLegendSize

public Dimension calcLegendSize(boolean vert)
Calculates the size of the legend based on the height and width of rows and columns.

Parameters:
vert - true if a vertical legend, false if a horizontal legend
Returns:
A Dimension object containing the calculated legend size

layoutLegendItems

public void layoutLegendItems(List itemList,
                              boolean vert)
Lays out the legend items from the legend vector by calculating their position within the legend and filling that in the JCLegendItem instances that define the legend item.

Parameters:
itemList - the legend vector of groups and items
vert - true if a vertical legend, false if a horizontal legend

positionItemSymbol

public Point positionItemSymbol(boolean vertical,
                                com.klg.jclass.util.legend.JCLegendItem thisItem,
                                Dimension boxDim,
                                Point startPos)
Positions an legend item's symbol component. It is centered vertically for a horizontal legend. It is centered within the given block (the biggest first text line) for a vertical legend.

Parameters:
vertical - true for a vertical legend; false for a horizontal legend
thisItem - the legend item containing the symbol to be positioned
boxDim - the area to be positioned in
startPos - the position within the item's area to start positioning at
Returns:
the position within the item's area to position the symbol at

positionItemText

public Point positionItemText(boolean vertical,
                              com.klg.jclass.util.legend.JCLegendItem thisItem,
                              Dimension boxDim,
                              Point startPos)

Copyright © 2004 Quest Software Inc..
All rights reserved.