/**
   * Returns tree cell renderer component.
   *
   * @param tree tree
   * @param value cell value
   * @param selected whether cell is selected or not
   * @param expanded whether cell is expanded or not
   * @param leaf whether cell is leaf or not
   * @param row cell row number
   * @param hasFocus whether cell has focus or not
   * @return cell renderer component
   */
  @Override
  public Component getTreeCellRendererComponent(
      final JTree tree,
      final Object value,
      final boolean selected,
      final boolean expanded,
      final boolean leaf,
      final int row,
      final boolean hasFocus) {
    if (checkBoxTree.getCheckBoxVisible()) {
      // Updating check state
      checkBox.setEnabled(checkBoxTree.isCheckingByUserEnabled());
      checkBox.setState(checkBoxTree.getCheckState((DefaultMutableTreeNode) value));

      // Updating actual cell renderer
      final TreeCellRenderer renderer = checkBoxTree.getActualRenderer();
      add(
          renderer.getTreeCellRendererComponent(
              tree, value, selected, expanded, leaf, row, hasFocus),
          BorderLayout.CENTER);

      return this;
    } else {
      // Returning actual cell renderer
      final TreeCellRenderer renderer = checkBoxTree.getActualRenderer();
      return renderer.getTreeCellRendererComponent(
          tree, value, selected, expanded, leaf, row, hasFocus);
    }
  }
  /**
   * Constructs new checkbox tree cell renderer.
   *
   * @param checkBoxTree checkbox tree to process
   */
  public WebCheckBoxTreeCellRenderer(final WebCheckBoxTree checkBoxTree) {
    super();
    this.checkBoxTree = checkBoxTree;

    setOpaque(false);

    checkBox = new WebTristateCheckBox();
    checkBox.setAnimated(false);
    checkBox.setMargin(0, 4, 0, WebCheckBoxTreeStyle.checkBoxRendererGap);
    add(checkBox, BorderLayout.LINE_START);
  }
 /** {@inheritDoc} */
 @Override
 public int getCheckBoxWidth() {
   return checkBox.getPreferredSize().width;
 }
 /** {@inheritDoc} */
 @Override
 public void setCheckBoxRendererGap(final int checkBoxRendererGap) {
   checkBox.getMargin().right = checkBoxRendererGap;
 }
 /** {@inheritDoc} */
 @Override
 public int getCheckBoxRendererGap() {
   return checkBox.getMargin().right;
 }