当前位置: 首页>>代码示例>>Java>>正文


Java TreeCellRenderer.getTreeCellRendererComponent方法代码示例

本文整理汇总了Java中javax.swing.tree.TreeCellRenderer.getTreeCellRendererComponent方法的典型用法代码示例。如果您正苦于以下问题:Java TreeCellRenderer.getTreeCellRendererComponent方法的具体用法?Java TreeCellRenderer.getTreeCellRendererComponent怎么用?Java TreeCellRenderer.getTreeCellRendererComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.tree.TreeCellRenderer的用法示例。


在下文中一共展示了TreeCellRenderer.getTreeCellRendererComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTreeCellRendererComponent

import javax.swing.tree.TreeCellRenderer; //导入方法依赖的package包/类
public Component getTreeCellRendererComponent(JTree tree,
                                                 Object value,
                                                 boolean selected,
                                                 boolean expanded,
                                                 boolean leaf,
                                                 int row,
                                                 boolean hasFocus) {
       boolean isResultRootNode =
                       (value instanceof TreeNode)
                       && (((TreeNode) value).getParent() == null);
// render no icon space an empty icon of a callStackFrame
       boolean isCallstackFrame = false;
       if (null != value) {
           isCallstackFrame = (Visualizer.findNode(value) instanceof CallstackFrameNode);
       }

       TreeCellRenderer renderer = (isResultRootNode || isCallstackFrame)
                                   ? noIconTreeCellRenderer
                                   : defaultTreeCellRenderer;
       return renderer.getTreeCellRendererComponent(
               tree, value, selected, expanded, leaf, row, hasFocus);
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ResultTreeView.java

示例2: isCellEditable

import javax.swing.tree.TreeCellRenderer; //导入方法依赖的package包/类
public boolean isCellEditable(final EventObject anEvent) {
    if (anEvent instanceof MouseEvent) {
        final MouseEvent event = (MouseEvent) anEvent;
        final int row = treeTable.rowAtPoint(event.getPoint());
        final Rectangle bounds = tree.getRowBounds(row);
        int offset = bounds.x;
        final Object node = tree.getPathForRow(row).getLastPathComponent();
        final boolean leaf = tree.getModel().isLeaf(node);
        final boolean expanded = tree.isExpanded(row);
        final TreeCellRenderer tcr = tree.getCellRenderer();
        final Component treeComponent = tcr.getTreeCellRendererComponent(
                tree, node, true, expanded, leaf, row, false);
        if (treeComponent instanceof JLabel) {
            final JLabel label = (JLabel) treeComponent;

            final Icon icon = label.getIcon();
            if (icon != null) {
                offset += icon.getIconWidth() + label.getIconTextGap();
            }

        }
        if (event.getPoint().x < offset)
            return false;
    }
    return deligate.isCellEditable(anEvent);
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:27,代码来源:FirstRowCellEditor.java

示例3: paintRow

import javax.swing.tree.TreeCellRenderer; //导入方法依赖的package包/类
/**
 * Paints the renderer part of a row. The receiver should NOT modify
 * clipBounds, or insets.
 *
 * @param g - the graphics configuration
 * @param clipBounds -
 * @param insets -
 * @param bounds - bounds of expand control
 * @param path - path to draw control for
 * @param row - row to draw control for
 * @param isExpanded - is the row expanded
 * @param hasBeenExpanded - has the row already been expanded
 * @param isLeaf - is the path a leaf
 */
protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets,
                        Rectangle bounds, TreePath path, int row,
                        boolean isExpanded, boolean hasBeenExpanded,
                        boolean isLeaf)
{
  boolean selected = tree.isPathSelected(path);
  boolean hasIcons = false;
  Object node = path.getLastPathComponent();

  paintExpandControl(g, clipBounds, insets, bounds, path, row, isExpanded,
                     hasBeenExpanded, isLeaf);

  TreeCellRenderer dtcr = currentCellRenderer;

  boolean focused = false;
  if (treeSelectionModel != null)
    focused = treeSelectionModel.getLeadSelectionRow() == row
              && tree.isFocusOwner();

  Component c = dtcr.getTreeCellRendererComponent(tree, node, selected,
                                                  isExpanded, isLeaf, row,
                                                  focused);

  rendererPane.paintComponent(g, c, c.getParent(), bounds);
}
 
开发者ID:vilie,项目名称:javify,代码行数:40,代码来源:BasicTreeUI.java

示例4: getCellRendererAndBounds

import javax.swing.tree.TreeCellRenderer; //导入方法依赖的package包/类
@Override
protected Pair<Component, Rectangle> getCellRendererAndBounds(Integer key) {
  int rowIndex = key.intValue();

  TreePath path = myComponent.getPathForRow(rowIndex);
  if (path == null) return null;

  Rectangle bounds = myComponent.getPathBounds(path);
  if (bounds == null) return null;

  TreeCellRenderer renderer = myComponent.getCellRenderer();
  if (renderer == null) return null;

  Object node = path.getLastPathComponent();
  Component rendererComponent = renderer.getTreeCellRendererComponent(
    myComponent,
    node,
    myComponent.isRowSelected(rowIndex),
    myComponent.isExpanded(rowIndex),
    myComponent.getModel().isLeaf(node),
    rowIndex,
    myComponent.hasFocus()
  );
  return Pair.create(rendererComponent, bounds);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:TreeExpandableItemsHandler.java

示例5: paintRow

import javax.swing.tree.TreeCellRenderer; //导入方法依赖的package包/类
/**
 * Paints the renderer part of a row. The receiver should NOT modify
 * clipBounds, or insets.
 * 
 * @param g - the graphics configuration
 * @param clipBounds -
 * @param insets -
 * @param bounds - bounds of expand control
 * @param path - path to draw control for
 * @param row - row to draw control for
 * @param isExpanded - is the row expanded
 * @param hasBeenExpanded - has the row already been expanded
 * @param isLeaf - is the path a leaf
 */
protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets,
                        Rectangle bounds, TreePath path, int row,
                        boolean isExpanded, boolean hasBeenExpanded,
                        boolean isLeaf)
{
  boolean selected = tree.isPathSelected(path);
  boolean hasIcons = false;
  Object node = path.getLastPathComponent();

  paintExpandControl(g, clipBounds, insets, bounds, path, row, isExpanded,
                     hasBeenExpanded, isLeaf);

  TreeCellRenderer dtcr = currentCellRenderer;

  boolean focused = false;
  if (treeSelectionModel != null)
    focused = treeSelectionModel.getLeadSelectionRow() == row
              && tree.isFocusOwner();

  Component c = dtcr.getTreeCellRendererComponent(tree, node, selected,
                                                  isExpanded, isLeaf, row,
                                                  focused);

  rendererPane.paintComponent(g, c, c.getParent(), bounds);
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:40,代码来源:BasicTreeUI.java

示例6: getRolloverRenderer

import javax.swing.tree.TreeCellRenderer; //导入方法依赖的package包/类
@Override
protected RolloverRenderer getRolloverRenderer(Point location, boolean prepare) {
    TreeCellRenderer renderer = component.getCellRenderer();
    RolloverRenderer rollover = renderer instanceof RolloverRenderer 
        ? (RolloverRenderer) renderer : null;
    if ((rollover != null) && !rollover.isEnabled()) {
        rollover = null;
    }
    if ((rollover != null) && prepare) {
        TreePath path = component.getPathForRow(location.y);
        Object element = path != null ? path.getLastPathComponent() : null;
        renderer.getTreeCellRendererComponent(component, element, false, 
                false, false, 
                location.y, false);
    }
    return rollover;
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:18,代码来源:TreeRolloverController.java

示例7: initEditorOffset

import javax.swing.tree.TreeCellRenderer; //导入方法依赖的package包/类
/**
     * @param row
     * @param isSelected
     */
    protected void initEditorOffset(JTable table, int row, int column,
            boolean isSelected) {
        if (tree == null)
            return;
//        Rectangle bounds = tree.getRowBounds(row);
//        int offset = bounds.x;
        Object node = tree.getPathForRow(row).getLastPathComponent();
        boolean leaf = tree.getModel().isLeaf(node);
        boolean expanded = tree.isExpanded(row);
        TreeCellRenderer tcr = tree.getCellRenderer();
        Component editorComponent = tcr.getTreeCellRendererComponent(tree, node,
                isSelected, expanded, leaf, row, false);

        ((TreeTableTextField) getComponent()).init(row,
                column, table, tree, editorComponent);
    }
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:21,代码来源:TreeTableCellEditor.java

示例8: createTreeRenderer

import javax.swing.tree.TreeCellRenderer; //导入方法依赖的package包/类
/**
 * Creates and returns a core default tree cell renderer with tooltip.
 * @return
 */
private TreeCellRenderer createTreeRenderer() {
    final TreeCellRenderer delegate = new DefaultTreeCellRenderer();
    TreeCellRenderer renderer = new TreeCellRenderer() {

        @Override
        public Component getTreeCellRendererComponent(JTree tree, Object value, 
                boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            Component result = delegate.getTreeCellRendererComponent(tree, value, 
                    selected, expanded, leaf, row, hasFocus);
            ((JComponent) result).setToolTipText(String.valueOf(tree.getPathForRow(row)));
             return result;
        }
        
    };
    return renderer;
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:21,代码来源:JXTreeTableVisualCheck.java

示例9: getCellRendererAndBounds

import javax.swing.tree.TreeCellRenderer; //导入方法依赖的package包/类
protected Pair<Component, Rectangle> getCellRendererAndBounds(Integer key) {
  int rowIndex = key.intValue();

  TreePath path = myComponent.getPathForRow(rowIndex);
  if (path == null) return null;

  Rectangle bounds = myComponent.getPathBounds(path);
  if (bounds == null) return null;

  TreeCellRenderer renderer = myComponent.getCellRenderer();
  if (renderer == null) return null;

  Object node = path.getLastPathComponent();
  Component rendererComponent = renderer.getTreeCellRendererComponent(
    myComponent,
    node,
    myComponent.isRowSelected(rowIndex),
    myComponent.isExpanded(rowIndex),
    myComponent.getModel().isLeaf(node),
    rowIndex,
    myComponent.hasFocus()
  );
  return Pair.create(rendererComponent, bounds);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:TreeExpandableItemsHandler.java

示例10: getCellRendererAndBounds

import javax.swing.tree.TreeCellRenderer; //导入方法依赖的package包/类
@Override
protected Pair<Component, Rectangle> getCellRendererAndBounds(Integer key) {
  int rowIndex = key.intValue();

  TreePath path = myComponent.getPathForRow(rowIndex);
  if (path == null) return null;

  Rectangle bounds = myComponent.getPathBounds(path);
  if (bounds == null) return null;

  TreeCellRenderer renderer = myComponent.getCellRenderer();
  if (renderer == null) return null;

  Object node = path.getLastPathComponent();
  Component rendererComponent = renderer.getTreeCellRendererComponent(
          myComponent,
          node,
          myComponent.isRowSelected(rowIndex),
          myComponent.isExpanded(rowIndex),
          myComponent.getModel().isLeaf(node),
          rowIndex,
          myComponent.hasFocus()
  );
  return Pair.create(rendererComponent, bounds);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:TreeExpandableItemsHandler.java

示例11: createTreeCellRenderer

import javax.swing.tree.TreeCellRenderer; //导入方法依赖的package包/类
/**
 * Creates a cell renderer for the tree view.
 *
 * @param delegate delegating/original tree renderer.
 * @return call renderer for the tree view.
 */
private TreeCellRenderer createTreeCellRenderer(final TreeCellRenderer delegate) {
    return new DefaultTreeCellRenderer() {
        @Override
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            return delegate.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:DocumentViewPanel.java

示例12: getTextForNodeObject

import javax.swing.tree.TreeCellRenderer; //导入方法依赖的package包/类
private String getTextForNodeObject(JTree tree, Object lastPathComponent) {
    TreeCellRenderer renderer = tree.getCellRenderer();
    if (renderer == null) {
        return null;
    }
    Component c = renderer.getTreeCellRendererComponent(tree, lastPathComponent, false, false, false, 0, false);
    if (c != null && c instanceof JLabel) {
        return ((JLabel) c).getText();
    }
    return lastPathComponent.toString();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:12,代码来源:JTreeJavaElement.java

示例13: paintRow

import javax.swing.tree.TreeCellRenderer; //导入方法依赖的package包/类
private void paintRow(TreeCellRenderer renderer,
           DefaultTreeCellRenderer dtcr, SynthContext treeContext,
           SynthContext cellContext, Graphics g, Rectangle clipBounds,
           Insets insets, Rectangle bounds, Rectangle rowBounds,
           TreePath path, int row, boolean isExpanded,
           boolean hasBeenExpanded, boolean isLeaf) {
    // Don't paint the renderer if editing this row.
    boolean selected = tree.isRowSelected(row);

    JTree.DropLocation dropLocation = tree.getDropLocation();
    boolean isDrop = dropLocation != null
                     && dropLocation.getChildIndex() == -1
                     && path == dropLocation.getPath();

    int state = ENABLED;
    if (selected || isDrop) {
        state |= SELECTED;
    }

    if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
        state |= FOCUSED;
    }

    cellContext.setComponentState(state);

    if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof
                         UIResource)) {
        dtcr.setBorderSelectionColor(style.getColor(
                                         cellContext, ColorType.FOCUS));
    }
    SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
    cellContext.getPainter().paintTreeCellBackground(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    cellContext.getPainter().paintTreeCellBorder(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    if (editingComponent != null && editingRow == row) {
        return;
    }

    int leadIndex;

    if (tree.hasFocus()) {
        leadIndex = getLeadSelectionRow();
    }
    else {
        leadIndex = -1;
    }

    Component component = renderer.getTreeCellRendererComponent(
                     tree, path.getLastPathComponent(),
                     selected, isExpanded, isLeaf, row,
                     (leadIndex == row));

    rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
                                bounds.width, bounds.height, true);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:59,代码来源:SynthTreeUI.java

示例14: getNodeText

import javax.swing.tree.TreeCellRenderer; //导入方法依赖的package包/类
/**
 * Returns the label text of <code>node</code> in <code>tree</code>.
 */
private String getNodeText(JTree tree, Object node) {
  TreeCellRenderer renderer = tree.getCellRenderer();
  Component childLabel = renderer.
      getTreeCellRendererComponent(tree, node, 
         false, true, false, 0, false);
  return ((JLabel)((JComponent)childLabel).getComponent(0)).getText();
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:11,代码来源:CatalogTreeTest.java

示例15: setCellRenderer

import javax.swing.tree.TreeCellRenderer; //导入方法依赖的package包/类
public void setCellRenderer(final TreeCellRenderer x) {
  super.setCellRenderer(
      new TreeCellRenderer() {
        public Component getTreeCellRendererComponent(JTree tree, Object value,
                                                      boolean selected, boolean expanded,
                                                      boolean leaf, int row, boolean hasFocus) {
          return x.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, myCellFocused);
        }
      }
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:TreeTableTree.java


注:本文中的javax.swing.tree.TreeCellRenderer.getTreeCellRendererComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。