JIDE 3.5.15

com.jidesoft.treemap
Class TreeMap<N>

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.jidesoft.treemap.TreeMap<N>
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class TreeMap<N>
extends JComponent

A facade to the TreeMap model-view-controller (MVC) architecture. In brief, the controller collects user input, the model manipulates application data, and the view presents results to the user. This class wraps a TreeMapModel, TreeMapView, and TreeMapController together. It allows easy loading of the data and customization of the most common settings.

Here is a simplistic example of how to get started with this class within minutes:


 import com.jidesoft.treemap.TreeMap;
 import javax.swing.*;
 import javax.swing.table.DefaultTableModel;
 import javax.swing.table.TableModel;
 

public class Hello { public static void main(String[] args) { // Defining the data, column names and types Object[][] data = new Object[][]{ {"Hello", 12, 3.0}, {"from", 11, 4.0}, {"the", 9, 5.0}, {"TreeMap", 8, 6.0}, {"World!", 7, 7.0}, }; Object[] columnNames = new Object[]{"Name", "Value", "Strength"}; final Class[] columnTypes = new Class[]{String.class, Integer.class, Double.class};

// Creating a standard Swing TableModel TableModel tableModel = new DefaultTableModel(data, columnNames) { public Class getColumnClass(int columnIndex) { return columnTypes[columnIndex]; } };

// Creating the TreeMap TreeMap treeMap = new TreeMap(tableModel);

// Tuning the appearance of the TreeMap treeMap.setSizeByName("Value"); treeMap.setColor(2); treeMap.setBackgroundByName("Name"); treeMap.setLabels();

// Creating a frame to display final JFrame frame = new JFrame("Hello from the TreeMap World!"); frame.setSize(600, 600); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(treeMap); frame.setLocationRelativeTo(null); frame.setVisible(true); } }

The code above will produce the following output:

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
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
TreeMap()
          Creates a TreeMap component with default settings and configuration.
TreeMap(TableModel tableModel)
          Creates a TreeMap component with the specified Swing TableModel.
TreeMap(TreeMapModel<N> model)
          Creates a TreeMap component with the its native data model.
 
Method Summary
protected  TreeMapController<N> createController(TreeMapView<N> view)
           
protected  TreeMapModel createTreeMapModel(TableModel tableModel)
           
protected  TreeMapView<N> createView()
           
 TreeMapController<N> getController()
          Returns the controller used for the treemap.
 TreeMapModel<N> getModel()
          Returns the model used for the treemap.
 TreeMapView<N> getView()
          Returns the view used for the treemap.
static void main(String[] args)
          Sort of a Hello World! application to demonstrate the most basic use of the TreeMap API
 void setAggregation(Aggregation aggregation)
          Defines the aggregation scheme to use to aggregate values of the treemap.
 void setAlgorithm(Algorithm algorithm)
          Defines the algorithm to use to lay out the treemap.
 void setBackground(int column)
          Defines the field to use for background labeling.
 void setBackgroundByName(String columnName)
          Defines the field to use for background labeling.
 void setColor(int column)
          Defines the field to use for coloring.
 void setColorByName(String columnName)
          Defines the field to use for coloring.
 void setController(TreeMapController<N> controller)
          Sets the controller to be used for the treemap and register the view currently in use.
 void setDepth(Depth depth)
          Defines the depth to use to lay out the treemap.
 void setGroupBy(int... columns)
          Defines the fields to be use for grouping.
 void setGroupByByNames(String... columnNames)
          Defines the fields to be use for grouping.
 void setHeaderBackgroundColor(Color color)
          Sets the background color to use for drawing the headers.
 void setHeaderFont(Font font)
          Sets the font used for labeling the headings.
 void setHeaderForegroundColor(Color color)
          Sets the foreground color to use for drawing the headers.
 void setHeight(int column)
          Defines the field to use for mapping the height.
 void setHeightByName(String columnName)
          Defines the field to use for mapping the height.
 void setLabeling(Labeling labeling)
          Defines the labeling scheme to use to draw the treemap.
 void setLabelingBackgroundColor(Color color)
          Sets the background color to use for drawing the labels.
 void setLabelingFont(Font font)
          Sets the font used for labeling.
 void setLabelingForegroundColor(Color color)
          Sets the foreground color to use for drawing the labels.
 void setLabels(int... columns)
          Defines the fields to be use for labeling.
 void setLabelsByNames(String... columnNames)
          Defines the fields to be use for labeling.
 void setLightSourceAmbient(double value)
          Sets the light source ambient intensity used for drawing the cushions.
 void setLightSourceHeight(double value)
          Sets the light source height used for drawing the cushions.
 void setLightSourceX(double value)
          Sets the light source X position used for drawing the cushions.
 void setLightSourceY(double value)
          Sets the light source Y position used for drawing the cushions.
 void setLightSourceZ(double value)
          Sets the light source Z position used for drawing the cushions.
 void setNesting(Nesting nesting)
          Defines the nesting to use to lay out the treemap.
 void setOrdering(Ordering ordering)
          Defines the ordering to use to lay out the treemap.
 void setRendering(Rendering rendering)
          Defines the rendering scheme to use to draw the treemap.
 void setScale(Scale scale)
          Defines the scaling scheme to use to project values the treemap.
 void setSize(int column)
          Defines the field to use to represent the size.
 void setSizeByName(String columnName)
          Defines the field to use to represent the size.
 void setView(TreeMapView<N> view)
          Sets the view to be used for the treemap and register the model currently in use.
 
Methods inherited from class javax.swing.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 java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, 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 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, 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TreeMap

public TreeMap()
Creates a TreeMap component with default settings and configuration.


TreeMap

public TreeMap(TreeMapModel<N> model)
Creates a TreeMap component with the its native data model.

Parameters:
model - a TreeMapModel

TreeMap

public TreeMap(TableModel tableModel)
Creates a TreeMap component with the specified Swing TableModel.

Parameters:
tableModel - a Swing TableModel
Method Detail

getModel

public TreeMapModel<N> getModel()
Returns the model used for the treemap.

Returns:
the model in use

getView

public TreeMapView<N> getView()
Returns the view used for the treemap.

Returns:
the view in use

setView

public void setView(TreeMapView<N> view)
Sets the view to be used for the treemap and register the model currently in use. It will also register itself to the controller.

Parameters:
view - the view to be used

getController

public TreeMapController<N> getController()
Returns the controller used for the treemap.

Returns:
the controller in use

setController

public void setController(TreeMapController<N> controller)
Sets the controller to be used for the treemap and register the view currently in use.

Parameters:
controller - the controller in use

setGroupBy

public void setGroupBy(int... columns)
Defines the fields to be use for grouping.

Parameters:
columns - the indexes of the columns to be used for grouping
See Also:
DefaultTreeMapSettings.getGroupByTreeMapFields()

setGroupByByNames

public void setGroupByByNames(String... columnNames)
Defines the fields to be use for grouping.

Parameters:
columnNames - the names of the columns to be used for grouping
See Also:
DefaultTreeMapSettings.getGroupByTreeMapFields()

setLabels

public void setLabels(int... columns)
Defines the fields to be use for labeling.

Parameters:
columns - the indexes of the columns to be used for labeling
See Also:
DefaultTreeMapSettings.getLabelTreeMapFields()

setLabelsByNames

public void setLabelsByNames(String... columnNames)
Defines the fields to be use for labeling.

Parameters:
columnNames - the names of the columns to be used for labeling
See Also:
DefaultTreeMapSettings.getLabelTreeMapFields()

setBackground

public void setBackground(int column)
Defines the field to use for background labeling.

Parameters:
column - the index of the column to be used for background labeling
See Also:
DefaultTreeMapSettings.getBackgroundTreeMapField()

setBackgroundByName

public void setBackgroundByName(String columnName)
Defines the field to use for background labeling.

Parameters:
columnName - the name of the column to be used for background labeling
See Also:
DefaultTreeMapSettings.getBackgroundTreeMapField()

setSize

public void setSize(int column)
Defines the field to use to represent the size.

Parameters:
column - the index of the column to be used for representing the size
See Also:
DefaultTreeMapSettings.getSizeTreeMapField()

setSizeByName

public void setSizeByName(String columnName)
Defines the field to use to represent the size.

Parameters:
columnName - the name of the column to be used for representing the size
See Also:
DefaultTreeMapSettings.getSizeTreeMapField()

setColor

public void setColor(int column)
Defines the field to use for coloring.

Parameters:
column - the index of the column to be used for coloring
See Also:
DefaultTreeMapSettings.getColorTreeMapField()

setColorByName

public void setColorByName(String columnName)
Defines the field to use for coloring.

Parameters:
columnName - the name of the column to be used for coloring
See Also:
DefaultTreeMapSettings.getColorTreeMapField()

setHeight

public void setHeight(int column)
Defines the field to use for mapping the height.

Parameters:
column - the index of the column to be used for mapping the height
See Also:
DefaultTreeMapSettings.getHeightTreeMapField()

setHeightByName

public void setHeightByName(String columnName)
Defines the field to use for mapping the height.

Parameters:
columnName - the name of the column to be used for mapping the height
See Also:
DefaultTreeMapSettings.getHeightTreeMapField()

setAlgorithm

public void setAlgorithm(Algorithm algorithm)
Defines the algorithm to use to lay out the treemap.

Parameters:
algorithm - the algorithm to use
See Also:
DefaultTreeMapSettings.getAlgorithm(), AlgorithmFactory

setAggregation

public void setAggregation(Aggregation aggregation)
Defines the aggregation scheme to use to aggregate values of the treemap.

Parameters:
aggregation - the aggregation scheme to use
See Also:
DefaultTreeMapSettings.getAggregation(), AggregationFactory

setScale

public void setScale(Scale scale)
Defines the scaling scheme to use to project values the treemap.

Parameters:
scale - the scale scheme to use
See Also:
DefaultTreeMapSettings.getScale(), ScaleFactory

setNesting

public void setNesting(Nesting nesting)
Defines the nesting to use to lay out the treemap.

Parameters:
nesting - the nesting scheme to use
See Also:
DefaultTreeMapSettings.getNesting(), NestingFactory

setOrdering

public void setOrdering(Ordering ordering)
Defines the ordering to use to lay out the treemap.

Parameters:
ordering - the ordering to use
See Also:
DefaultTreeMapSettings.getOrdering(), OrderingFactory

setDepth

public void setDepth(Depth depth)
Defines the depth to use to lay out the treemap.

Parameters:
depth - the depth to use
See Also:
DefaultTreeMapSettings.getDepth(), DepthFactory

setLabeling

public void setLabeling(Labeling labeling)
Defines the labeling scheme to use to draw the treemap.

Parameters:
labeling - the labeling schem to use
See Also:
DefaultTreeMapFieldSettings.getLabeling(), LabelingFactory

setRendering

public void setRendering(Rendering rendering)
Defines the rendering scheme to use to draw the treemap.

Parameters:
rendering - the rendering scheme to use
See Also:
DefaultTreeMapSettings.getRendering(), RenderingFactory

setLightSourceHeight

public void setLightSourceHeight(double value)
Sets the light source height used for drawing the cushions.

Parameters:
value - the height
See Also:
DefaultTreeMapSettings.getLightSourceHeight()

setLightSourceAmbient

public void setLightSourceAmbient(double value)
Sets the light source ambient intensity used for drawing the cushions.

Parameters:
value - the ambient intensity
See Also:
DefaultTreeMapSettings.getLightSourceAmbient()

setLightSourceX

public void setLightSourceX(double value)
Sets the light source X position used for drawing the cushions.

Parameters:
value - the X position
See Also:
DefaultTreeMapSettings.getLightSourceX()

setLightSourceY

public void setLightSourceY(double value)
Sets the light source Y position used for drawing the cushions.

Parameters:
value - the Y position
See Also:
DefaultTreeMapSettings.getLightSourceY()

setLightSourceZ

public void setLightSourceZ(double value)
Sets the light source Z position used for drawing the cushions.

Parameters:
value - the Z position
See Also:
DefaultTreeMapSettings.getLightSourceZ()

setLabelingFont

public void setLabelingFont(Font font)
Sets the font used for labeling.

Parameters:
font - the font to be used
See Also:
DefaultTreeMapSettings.getLabelingFont()

setLabelingForegroundColor

public void setLabelingForegroundColor(Color color)
Sets the foreground color to use for drawing the labels.

Parameters:
color - the color to be used
See Also:
DefaultTreeMapSettings.getLabelingForeground()

setLabelingBackgroundColor

public void setLabelingBackgroundColor(Color color)
Sets the background color to use for drawing the labels.

Parameters:
color - the color to be used
See Also:
DefaultTreeMapSettings.getLabelingEffectColor()

setHeaderFont

public void setHeaderFont(Font font)
Sets the font used for labeling the headings.

Parameters:
font - the font to be used
See Also:
DefaultTreeMapSettings.getHeaderFont()

setHeaderForegroundColor

public void setHeaderForegroundColor(Color color)
Sets the foreground color to use for drawing the headers.

Parameters:
color - the color to be used
See Also:
DefaultTreeMapSettings.getHeaderForeground()

setHeaderBackgroundColor

public void setHeaderBackgroundColor(Color color)
Sets the background color to use for drawing the headers.

Parameters:
color - the color to be used
See Also:
DefaultTreeMapSettings.getHeaderBackground()

createTreeMapModel

protected TreeMapModel createTreeMapModel(TableModel tableModel)

createView

protected TreeMapView<N> createView()

createController

protected TreeMapController<N> createController(TreeMapView<N> view)

main

public static void main(String[] args)
Sort of a Hello World! application to demonstrate the most basic use of the TreeMap API


JIDE 3.5.15