All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.essilab.lablib.checkboxtree.CheckboxTreeCellRenderer Maven / Gradle / Ivy

Go to download

CheckboxTree is a Java Swing component providing a tree-like widget with checkboxes in each node. Checkboxes can toggle between the checked and unchecked state. Disabled and greyed checkboxes are also supported. The CheckboxTree API design is inspired by the JTree interface.

The newest version!
/*
 * Copyright 2007-2022 Enrico Boldrini, Lorenzo Bigagli This file is part of
 * CheckboxTree. CheckboxTree is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version. CheckboxTree is distributed in the hope that it
 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details. You should have received a copy of the GNU
 * General Public License along with CheckboxTree; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA
 */
package eu.essilab.lablib.checkboxtree;

import java.awt.Component;

import javax.swing.JTree;
import javax.swing.tree.TreeCellRenderer;

/**
 * The renderer for a cell in a CheckboxTree.
 * 
 * @author bigagli
 */
public interface CheckboxTreeCellRenderer extends TreeCellRenderer {

    /**
     * This method is redeclared just to underline that the implementor has to
     * properly display the checking/graying state of value. This
     * should go in the method parameters, but would imply changes to Swing
     * classes that were considered unpractical. For example in
     * DefaultCheckboxTreeCellRenderer the following code is used to get the
     * checking/graying states:
     * 
     * 
     * TreeCheckingModel checkingModel = ((CheckboxTree) tree).getCheckingModel();
     * 
     * TreePath path = tree.getPathForRow(row);
     * 
     * boolean enabled = checkingModel.isPathEnabled(path);
     * 
     * boolean checked = checkingModel.isPathChecked(path);
     * 
     * boolean greyed = checkingModel.isPathGreyed(path);
     * 
* * You could use a QuadristateCheckbox to properly renderer the states (as * in DefaultCheckboxTreeCellRenderer). * * @see TreeCellRenderer#getTreeCellRendererComponent */ Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus); /** * Returns whether the specified relative coordinates insist on the intended * checkbox control. It is used by the CheckboxTree mouse listener to figure * out whether to toggle a node or not. */ public boolean isOnHotspot(int x, int y); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy