public void paintBorder(Component c, java.awt.Graphics g, int x, int y, int width, int height) { int iconY; int iconX = nestingDepth * DefaultOutlineCellRenderer.getNestingWidth(); if( !isLeaf ) { Icon expIcon = isExpanded ? DefaultOutlineCellRenderer.getExpandedIcon() : DefaultOutlineCellRenderer.getCollapsedIcon(); if (expIcon.getIconHeight() < height) { iconY = (height / 2) - (expIcon.getIconHeight() / 2); } else { iconY = 0; } expIcon.paintIcon(c, g, iconX, iconY); } if( null != icon ) { iconX += DefaultOutlineCellRenderer.getExpansionHandleWidth() + 1; if (icon.getIconHeight() < height) { iconY = (height / 2) - (icon.getIconHeight() / 2); } else { iconY = 0; } icon.paintIcon(c, g, iconX, iconY); } } }
public Insets getBorderInsets(Component c) { insets.left = (nestingDepth * DefaultOutlineCellRenderer.getNestingWidth()) +DefaultOutlineCellRenderer.getExpansionHandleWidth()+1; insets.left += icon != null ? icon.getIconWidth() + ICON_TEXT_GAP : 0; insets.top = 1; insets.right = 1; insets.bottom = 1; return insets; }
public void paintBorder(Component c, java.awt.Graphics g, int x, int y, int width, int height) { DefaultOutlineCellRenderer ren = (DefaultOutlineCellRenderer) c; if (ren.isShowHandle() && !ren.isLeaf()) { Icon icon = ren.isExpanded() ? getExpandedIcon() : getCollapsedIcon(); int iconY; int iconX = ren.getNestingDepth() * getNestingWidth(); if (icon.getIconHeight() < height) { iconY = (height / 2) - (icon.getIconHeight() / 2); } else { iconY = 0; } icon.paintIcon(c, g, iconX, iconY); } } }
row = tbl.convertRowIndexToModel(row); boolean leaf = tbl.getOutlineModel().isLeaf(value); setLeaf(leaf); setShowHandle(true); TreePath path = layout.getPathForRow(row); boolean expanded = layout.isExpanded(path); setExpanded (expanded); int nd = path.getPathCount() - (tbl.isRootVisible() ? 1 : 2); if (nd < 0) { nd = 0; setNestingDepth (nd ); RenderDataProvider rendata = tbl.getRenderDataProvider(); Icon icon = null; String displayName = rendata.getDisplayName(value); if (displayName != null) { setText (displayName); setToolTipText (rendata.getTooltipText(value)); Color bg = rendata.getBackground(value); Color fg = rendata.getForeground(value); if (bg != null && !isSelected) { setBackground (bg); } else { setBackground (isSelected ? tbl.getSelectionBackground() : tbl.getBackground()); setForeground (fg);
/** * {@inheritDoc} */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel renderer = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (isSelected) { renderer.setBackground(table.getSelectionBackground()); renderer.setForeground(table.getSelectionForeground()); } else { renderer.setBackground(getBackgroundColor(table, row, column)); renderer.setForeground(getForegroundColor(value, table)); } renderer.setText(getDisplayName(value)); renderer.setIcon(getIcon(value)); return renderer; }
static int getExpansionHandleWidth() { return getExpandedIcon().getIconWidth(); }
static int getNestingWidth() { return getExpansionHandleWidth(); }
/** Calculate the height of rows based on the current font. */ private void calcRowHeight() { //Users of themes can set an explicit row height, so check for it Integer i = (Integer) UIManager.get("netbeans.outline.rowHeight"); //NOI18N int rHeight; if (i != null) { rHeight = i.intValue(); } else { //Derive a row height to accomodate the font and expando icon Font f = getFont(); FontMetrics fm = getFontMetrics(f); rHeight = Math.max(fm.getHeight()+3, DefaultOutlineCellRenderer.getExpansionHandleHeight()); } //Set row height. If displayable, this will generate a new call //to paint() setRowHeight(rHeight); }
private void init() { initialized = true; setDefaultRenderer(Object.class, new DefaultOutlineCellRenderer()); ActionMap am = getActionMap(); //make rows expandable with left/rigt arrow keys Action a = am.get("selectNextColumn"); //NOI18N am.put("selectNextColumn", new ExpandAction(true, a)); //NOI18N a = am.get("selectPreviousColumn"); //NOI18N am.put("selectPreviousColumn", new ExpandAction(false, a)); //NOI18N }
public Insets getBorderInsets(Component c) { DefaultOutlineCellRenderer ren = (DefaultOutlineCellRenderer) c; if (ren.isShowHandle()) { insets.left = getExpansionHandleWidth() + (ren.getNestingDepth() * getNestingWidth()); //Defensively adjust all the insets fields insets.top = 1; insets.right = 1; insets.bottom = 1; } else { //Defensively adjust all the insets fields insets.left = 1; insets.top = 1; insets.right = 1; insets.bottom = 1; } return insets; }
/** * {@inheritDoc} */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel renderer = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (isSelected) { renderer.setBackground(table.getSelectionBackground()); renderer.setForeground(table.getSelectionForeground()); } else { renderer.setBackground(getBackgroundColor(table, row, column)); renderer.setForeground(getForegroundColor(value, table)); } renderer.setText(getDisplayName(value)); renderer.setIcon(getIcon(value)); return renderer; }
static int getExpansionHandleHeight() { return getExpandedIcon().getIconHeight(); }
TreePath path = getLayoutCache().getPathForRow(convertRowIndexToModel(row)); if (!getOutlineModel().isLeaf(path.getLastPathComponent())) { int handleWidth = DefaultOutlineCellRenderer.getExpansionHandleWidth(); Insets ins = getInsets(); int nd = path.getPathCount() - (isRootVisible() ? 1 : 2); nd = 0; int handleStart = ins.left + (nd * DefaultOutlineCellRenderer.getNestingWidth()); int handleEnd = ins.left + handleStart + handleWidth;
cell = super.getTableCellRendererComponent(table, valueToDisplay, isSelected, hasFocus, row, column);