# Class SwingTreeMap<N,Row,Column>

java.lang.Object
com.treemap.AbstractTreeMap<JComponent, N, Row, Column, Color, Font>
com.treemap.swing.SwingTreeMap<N,Row,Column>

All Implemented Interfaces:
  `TreeMap<JComponent, N, Row, Column, Color, Font>`

public class SwingTreeMap<N,Row,Column> extends AbstractTreeMap<JComponent, N, Row, Column, Color, Font>
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.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:

- ## Field Summary

  ### Fields inherited from class AbstractTreeMap

  `controller, licenseModel, view`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SwingTreeMap()`
  Creates a TreeMap component with default settings and configuration.
  `SwingTreeMap(com.macrofocus.molap.dataframe.DataFrame<Row,Column,?> dataFrame)`
  Creates a TreeMap component with the specified Swing TableModel.
  `SwingTreeMap(TreeMapModel<N,Row,Column,Color,Font> model)`
  Creates a TreeMap component with the its native data model.
  `SwingTreeMap(TableModel tableModel)`
  Creates a TreeMap component with the specified Swing TableModel.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected TreeMapController<JComponent, N, Row, Column, Color, Font>`
  `createController(TreeMapView<JComponent, N, Row, Column, Color, Font> view)`
  `protected TreeMapModel<N,Row,Column,Color,Font>`
  `createTreeMapModel(com.macrofocus.molap.dataframe.DataFrame<Row,Column,?> dataFrame)`
  `protected TreeMapView<JComponent, N, Row, Column, Color, Font>`
  `createView()`
  `JComponent`
  `getNativeComponent()`
  `static void`
  `main(String[] args)`
  Sort of a Hello World! application to demonstrate the most basic use of the TreeMap API
  `static void`
  `setLicenseKey(String username, String key)`
  Register the license key that legally entitle the use of TreeMap.

  ### Methods inherited from class AbstractTreeMap

  `getController, getModel, getView, setAggregation, setAlgorithm, setBackground, setBackgroundByName, setColor, setColorByName, setController, setDepth, setGroupBy, setGroupByByNames, setHeaderBackgroundColor, setHeaderFont, setHeaderForegroundColor, setHeight, setHeightByName, setLabeling, setLabelingBackgroundColor, setLabelingFont, setLabelingForegroundColor, setLabels, setLabelsByNames, setLightSourceAmbient, setLightSourceHeight, setLightSourceX, setLightSourceY, setLightSourceZ, setModel, setNesting, setOrdering, setRendering, setScale, setSize, setSizeByName, setToolTip, setToolTipByNames, setView`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### SwingTreeMap

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

  - ### SwingTreeMap

    public SwingTreeMap(TreeMapModel<N,Row,Column,Color,Font> model)
    Creates a TreeMap component with the its native data model.
    Parameters:
      `model` - a TreeMapModel

  - ### SwingTreeMap

    public SwingTreeMap(TableModel tableModel)
    Creates a TreeMap component with the specified Swing TableModel.
    Parameters:
      `tableModel` - a Swing TableModel

  - ### SwingTreeMap

    public SwingTreeMap(com.macrofocus.molap.dataframe.DataFrame<Row,Column,?> dataFrame)
    Creates a TreeMap component with the specified Swing TableModel.
    Parameters:
      `dataFrame` - a DataFrame

- ## Method Details

  - ### setLicenseKey

    public static void setLicenseKey(String username, String key)
    Register the license key that legally entitle the use of TreeMap. This should be called prior to the first instantiation of this component.
    Parameters:
      `username` - the user name
      `key` - the license key

  - ### createTreeMapModel

    protected TreeMapModel<N,Row,Column,Color,Font> createTreeMapModel(com.macrofocus.molap.dataframe.DataFrame<Row,Column,?> dataFrame)

  - ### createView

    protected TreeMapView<JComponent, N, Row, Column, Color, Font> createView()

  - ### createController

    protected TreeMapController<JComponent, N, Row, Column, Color, Font> createController(TreeMapView<JComponent, N, Row, Column, Color, Font> view)

  - ### getNativeComponent

    public JComponent getNativeComponent()

  - ### main

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