/* * [ConstellationNodeRenderer.java] * * Summary: Renders one file leaf or Dir node in the JTree. * * Copyright: (c) 2011-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2011-01-31 initial version */ package com.mindprod.constellation; import javax.swing.JTree; import javax.swing.tree.DefaultTreeCellRenderer; import java.awt.Component; /** * Renders one file leaf or Dir node in the JTree. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2011-01-31 initial version * @since 2011-01-31 */ class ConstellationNodeRenderer extends DefaultTreeCellRenderer { /** * constructor */ public ConstellationNodeRenderer() { super(); } /** * prepare a component that renders this ConstellationFileLeaf or ConstellationDirNode. * Icon used depends on IncludeState. */ public Component getTreeCellRendererComponent( JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus ) { ConstellationNode cn = ( ConstellationNode ) value; this.setIcon( cn.getStateIcon() ); return super.getTreeCellRendererComponent( tree, value, selected, expanded, leaf, row, hasFocus ); } }