JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.chart3d
Class JCChart3dLegend

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--com.klg.jclass.util.legend.JCLegend
                          |
                          +--com.klg.jclass.chart3d.JCChart3dLegend
All Implemented Interfaces:
Changeable, ImageObserver, JCChart3dLegendTemplate, MenuContainer, Serializable

public class JCChart3dLegend
extends JCLegend
implements JCChart3dLegendTemplate, Serializable

JCChart3dLegend 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
protected  boolean continuousLayout
          Asks if the layout is really continuous.
protected  int distRange
          The constraints to place upon the data ranges that appear in the legend.
protected  int groupGap
          Space between groups in a legend (columns when legend vertical, rows when horizontal).
protected  int horizItemGap
          Horizontal space between items.
protected  int insideItemGap
          Space between the symbol and String inside an item.
protected  com.klg.jclass.chart3d.JCChart3dLegendLabelGenerator labelGenerator
          Label generator class.
protected  int layoutStyle
          The style to use when laying out out ranges.
protected  int legendColumns
          Number of columns in the legend.
protected  int legendRows
          Number of rows in the legend.
protected  int marginGap
          Space between outside and inside of legend.
protected  List userLabels
          List of user-specified legend labels.
protected  int vertItemGap
          Vertical space between items.
 
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.chart3d.JCChart3dLegendTemplate
CONTINUOUS, RANGE_ALL, RANGE_DATA, STEPPED
 
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
JCChart3dLegend()
          Default constructor.
 
Method Summary
protected  Dimension calcLegendSize(List itemList, boolean vertical, Dimension itemSize, boolean[] hasTitle, Dimension titleSize)
          Calculates the size of a legend.
protected  boolean[] findBiggestLegendItem(List itemList, boolean vertical, Dimension maxItemSize, Dimension titleSize)
          Finds the biggest item in the legend.
 int getDistributionRange()
          Gets the type of distribution range being used to display data in the legend (one of RANGE_DATA or RANGE_ALL).
 int getGroupGap()
          Gets the gap between groups of items in the legend (columns in a vertical legend, rows in a horizontal legend).
 int getHorizontalItemGap()
          Gets the gap between the legend items in a horizontal legend.
 int getInsideItemGap()
          Gets the gap between the symbol and text portions of a legend item.
 int getItemGap()
          Gets the gap between the legend items depending on the orientation.
 com.klg.jclass.chart3d.JCChart3dLegendLabelGenerator getLabelGenerator()
          Gets the class specifying custom labels for the legend.
 List getLabels()
          Gets the list of user specified label lists used to override default label generation.
 List getLabels(int dvIndex)
          Gets the list of user specified labels being used to override the default label generation for the specified data view.
 int getLayoutStyle()
          Gets the style being used for displaying data ranges in the legend.
 int getMarginGap()
          Gets the gap between the edge of the legend and where the items start being layed out.
 int getVerticalItemGap()
          Gets the gap between the legend items in a vertical legend.
 boolean isContinuousLayout()
          For internal use only.
 void layoutContinuousLegendItems(List itemList, boolean vertical, Dimension maxItemSize, Dimension legendSize, boolean[] hasTitle, Dimension titleSize)
          Controls the layout of the items in a continuous legend.
 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.
protected  void layoutSteppedLegendItems(List itemList, boolean vertical, Dimension maxItemSize, Dimension legendSize, boolean[] hasTitle, Dimension titleSize)
          Controls to layout of the items in a stepped legend.
 com.klg.jclass.util.legend.JCLegendItem pick(Point p)
          Overrides parent legend pick to change default behaviour.
protected  void positionTitleItem(com.klg.jclass.util.legend.JCLegendItem thisItem, int space, int titlex, int titley)
          Positions the title item above the legend.
 void setAnchor(int a)
          Sets the Anchor property, which determines the position of the legend relative to the parent component's primary draw area.
 void setContinuousLayout(boolean continuous)
          For internal use only.
 void setDistributionRange(int range)
          Sets the type of distribution range to use to display data in the legend.
 void setGroupGap(int gap)
          Sets the gap between groups of items in the legend (columns in a vertical legend, rows in a horizontal legend).
 void setHorizontalItemGap(int gap)
          Sets the gap between the legend items in a horizontal legend.
 void setInsideItemGap(int gap)
          Sets the gap between the symbol and text portions of a legend item.
 void setLabelGenerator(com.klg.jclass.chart3d.JCChart3dLegendLabelGenerator generator)
          Sets the class used to specify custom labels for the legend.
 void setLabels(int dvIndex, List labels)
          Sets a list of user specified labels used to override default label generation for the specified data view.
 void setLabels(List labels)
          Sets the list of user specified label lists used to override default label generation.
 void setLayoutStyle(int style)
          Sets the style to be used for displaying data ranges in the legend.
 void setMarginGap(int gap)
          Sets the gap between the edge of the legend and where the items start being layed out.
 void setVerticalItemGap(int gap)
          Sets the gap between the legend items in a vertical legend.
 
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, recalc, 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

layoutStyle

protected int layoutStyle
The style to use when laying out out ranges.


distRange

protected int distRange
The constraints to place upon the data ranges that appear in the legend.


labelGenerator

protected com.klg.jclass.chart3d.JCChart3dLegendLabelGenerator labelGenerator
Label generator class. Overrides all other forms of label generation.


userLabels

protected List userLabels
List of user-specified legend labels.


marginGap

protected int marginGap
Space between outside and inside of legend.


groupGap

protected int groupGap
Space between groups in a legend (columns when legend vertical, rows when horizontal).


horizItemGap

protected int horizItemGap
Horizontal space between items.


vertItemGap

protected int vertItemGap
Vertical space between items.


insideItemGap

protected int insideItemGap
Space between the symbol and String inside an item.


continuousLayout

protected boolean continuousLayout
Asks if the layout is really continuous.


legendRows

protected int legendRows
Number of rows in the legend.


legendColumns

protected int legendColumns
Number of columns in the legend.

Constructor Detail

JCChart3dLegend

public JCChart3dLegend()
Default constructor.

Method Detail

setAnchor

public void setAnchor(int a)
Sets the Anchor property, which determines the position of the legend relative to the parent component's primary draw area.

Overrides:
setAnchor in class JCLegend
Parameters:
a - The new anchor. Must be one of NORTH, SOUTH, EAST, WEST, NORTHWEST, SOUTHWEST, NORTHEAST, or SOUTHEAST

setLayoutStyle

public void setLayoutStyle(int style)
Sets the style to be used for displaying data ranges in the legend. One of CONTINUOUS or STEPPED.

Parameters:
style - The range style to use

getLayoutStyle

public int getLayoutStyle()
Gets the style being used for displaying data ranges in the legend. One of CONTINUOUS or STEPPED.

Specified by:
getLayoutStyle in interface JCChart3dLegendTemplate
Returns:
The current range style

setDistributionRange

public void setDistributionRange(int range)
Sets the type of distribution range to use to display data in the legend. One of RANGE_DATA or RANGE_ALL. RANGE_DATA constrains the legend data ranges to the minimum and maximum of the data in the chart. RANGE_ALL ensures that all data ranges are included.

Parameters:
range - The new distribution range type

getDistributionRange

public int getDistributionRange()
Gets the type of distribution range being used to display data in the legend (one of RANGE_DATA or RANGE_ALL). RANGE_DATA constrains the legend data ranges to the minimum and maximum of the data in the chart. RANGE_ALL ensures that all data ranges are included.

Specified by:
getDistributionRange in interface JCChart3dLegendTemplate
Returns:
The current distribution range type

setLabelGenerator

public void setLabelGenerator(com.klg.jclass.chart3d.JCChart3dLegendLabelGenerator generator)
Sets the class used to specify custom labels for the legend. Setting this property to a non-null value overrides all other forms of setting legend labels. A null value indicates that another method will be used. This property is ignored for legends of SCATTER charts.

Parameters:
generator - A class implementing the JCChart3dLegendLabelGenerator interface

getLabelGenerator

public com.klg.jclass.chart3d.JCChart3dLegendLabelGenerator getLabelGenerator()
Gets the class specifying custom labels for the legend. A null value indicates that another method of setting legend labels is being used.

Specified by:
getLabelGenerator in interface JCChart3dLegendTemplate
Returns:
A class implementing the JCChart3dLegendLabelGenerator interface that is being used to specify legend labels

setLabels

public void setLabels(List labels)
Sets the list of user specified label lists used to override default label generation. The passed List instance is indexed by data view number. Each item in the passed List is itself a List instance representing the list of legend labels (either String or JCMultiFieldString objects) to represent the data view in the legend.

A null value in the main List indicates that there are no legend labels specified for the data view at that index. A null value for the property indicates that no legend labels have been specified for any data view.

If the LabelGenerator property is set, this property is ignored.

Parameters:
labels - the list of user specified label lists

getLabels

public List getLabels()
Gets the list of user specified label lists used to override default label generation. The value is null if no lists have been specified. The returned List instance is indexed by a data view number. Each item in the returned List is itself a List instance representing the list of legend labels (either String or JCMultiFieldString objects) to be used for the data view.

Specified by:
getLabels in interface JCChart3dLegendTemplate
Returns:
the list of user specified label lists

setLabels

public void setLabels(int dvIndex,
                      List labels)
Sets a list of user specified labels used to override default label generation for the specified data view. Each item in the passed List instance represents a legend label (either String or JCMultiFieldString objects). A null value indicates that no override labels have been specified for the specified data view. If the LabelGenerator property is set, this property is ignored.

Parameters:
dvIndex - the data view labels are being attached to
labels - the list of user specified labels

getLabels

public List getLabels(int dvIndex)
Gets the list of user specified labels being used to override the default label generation for the specified data view. Each item in the returned List instance represents a legend label (either String or JCMultiFieldString objects). A null value indicates that no override labels have been specified for the specified data view.

Parameters:
dvIndex - the data view that the labels are being requested for
Returns:
the list of user specified labels

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

setGroupGap

public void setGroupGap(int gap)
Sets the gap between groups of items in the legend (columns in a vertical legend, rows in a horizontal legend).

Parameters:
gap - the group gap

getGroupGap

public int getGroupGap()
Gets the gap between groups of items in the legend (columns in a vertical legend, rows in a horizontal legend).

Returns:
the group gap

getItemGap

public int getItemGap()
Gets the gap between the legend items depending on the orientation.

Specified by:
getItemGap in interface JCChart3dLegendTemplate
Returns:
the item gap

setHorizontalItemGap

public void setHorizontalItemGap(int gap)
Sets the gap between the legend items in a horizontal legend.

Parameters:
gap - the item gap

getHorizontalItemGap

public int getHorizontalItemGap()
Gets the gap between the legend items in a horizontal legend.

Returns:
the item gap

setVerticalItemGap

public void setVerticalItemGap(int gap)
Sets the gap between the legend items in a vertical legend.

Parameters:
gap - the item gap

getVerticalItemGap

public int getVerticalItemGap()
Gets the gap between the legend items in a vertical legend.

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

setContinuousLayout

public void setContinuousLayout(boolean continuous)
For internal use only. Set by legend manager to determine if continuous layout is actually continuous. (In some cases, CONTINUOUS layout is forced to a STEPPED layout.)

Specified by:
setContinuousLayout in interface JCChart3dLegendTemplate
Parameters:
continuous - Is the layout actually continuous?

isContinuousLayout

public boolean isContinuousLayout()
For internal use only. Returns true if layout really is continuous. (In some cases, CONTINUOUS layout is forced to behave like a STEPPED layout.)

Specified by:
isContinuousLayout in interface JCChart3dLegendTemplate
Returns:
true if the layout is really continuous

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. It 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 horizontal
useFont - the font for the legend
Returns:
The size of the legend

findBiggestLegendItem

protected boolean[] findBiggestLegendItem(List itemList,
                                          boolean vertical,
                                          Dimension maxItemSize,
                                          Dimension titleSize)
Finds the biggest item in the legend. The width of a legend item is determined by adding the width of the symbol, the inside item gap and the width of the text. The height of a legend item is determined by the maximum height of either the symbol or the text.

Parameters:
itemList - the list of items to layout
vertical - true if the legend is vertical
maxItemSize - the size of the largest legend item, to be filled in by this method
titleSize - the size of the title item, to be filled in by this method
Returns:
true if legend has a title; false otherwise

calcLegendSize

protected Dimension calcLegendSize(List itemList,
                                   boolean vertical,
                                   Dimension itemSize,
                                   boolean[] hasTitle,
                                   Dimension titleSize)
Calculates the size of a legend. This includes calculating the number of columns and rows.

Parameters:
itemList - the list of items to layout
vertical - true if the legend is vertical
itemSize - the size of the largest legend item
hasTitle - true of this list of legend items contains a title item
titleSize - the size of the title item
Returns:
the size of the legend

layoutSteppedLegendItems

protected void layoutSteppedLegendItems(List itemList,
                                        boolean vertical,
                                        Dimension maxItemSize,
                                        Dimension legendSize,
                                        boolean[] hasTitle,
                                        Dimension titleSize)
Controls to layout of the items in a stepped legend.

Parameters:
itemList - the list of items to layout
vertical - true if the legend is vertical
maxItemSize - the size of the largest legend item
legendSize - the size of the legend
hasTitle - true of this list of legend items contains a title item
titleSize - the size of the title item

layoutContinuousLegendItems

public void layoutContinuousLegendItems(List itemList,
                                        boolean vertical,
                                        Dimension maxItemSize,
                                        Dimension legendSize,
                                        boolean[] hasTitle,
                                        Dimension titleSize)
Controls the layout of the items in a continuous legend.

Parameters:
itemList - the list of items to layout
vertical - true if the legend is vertical
maxItemSize - the size of the largest legend item
legendSize - the size of the legend
hasTitle - true if this list of legend items contains a title item
titleSize - the size of the title item

positionTitleItem

protected void positionTitleItem(com.klg.jclass.util.legend.JCLegendItem thisItem,
                                 int space,
                                 int titlex,
                                 int titley)
Positions the title item above the legend.

Parameters:
thisItem - the legend item containing the legend title
space - the space available
titlex - the x position of space available
titley - the y position of space available

pick

public com.klg.jclass.util.legend.JCLegendItem pick(Point p)
Overrides parent legend pick to change default behaviour. By default, the legend will create its own pick rectangle if one is absent. For the purposes of 3d chart legends, a null pick rectangle should prevent the pick operation.

Overrides:
pick in class JCLegend
Parameters:
p - The point at which to pick
Returns:
The JCLegendItem instance representing the picked point.

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