x = 0; // in a table we want to have the whole row selected } else { x = h.isSelected() ? ((h.getIcon() == null) ? 0 : (h.getIcon().getIconWidth() + h.getIconTextGap())) : 0; x += h.getIndent(); x = 0; // in a table we want to have the whole row selected } else { x = ((h.getIcon() == null) ? 0 : (h.getIcon().getIconWidth() + h.getIconTextGap()));
Icon icon = r.getIcon();
private void paintIconAndTextCentered(Graphics g, HtmlRendererImpl r) { Insets ins = r.getInsets(); Icon ic = r.getIcon(); int w = r.getWidth() - (ins.left + ins.right); int txtX = ins.left;
Icon icon = r.getIcon();
public void update(Graphics g, JComponent c) { Color bg = getBackgroundFor ((HtmlRendererImpl) c); HtmlRendererImpl h = (HtmlRendererImpl) c; if (bg != null) { int x = h.isSelected() ? (h.getIcon() == null ? 0 : h.getIcon().getIconWidth() + h.getIconTextGap()) : 0; x += h.getIndent(); g.setColor(bg); g.fillRect(x, 0, c.getWidth()-x,c.getHeight()); } if (h.isLeadSelection()) { Color focus = UIManager.getColor("Tree.selectionBorderColor"); // NOI18N if (focus == null || focus.equals (bg)) { focus = Color.BLUE; } int x = (h.getIcon() == null ? 0 : h.getIcon().getIconWidth() + h.getIconTextGap()); g.setColor(focus); g.drawRect (x, 0, c.getWidth() - (x + 1), c.getHeight()-1); } paint(g, c); }
public void update(Graphics g, JComponent c) { Color bg = getBackgroundFor ((HtmlRendererImpl) c); HtmlRendererImpl h = (HtmlRendererImpl) c; if (bg != null) { int x = h.isSelected() ? (h.getIcon() == null ? 0 : h.getIcon().getIconWidth() + h.getIconTextGap()) : 0; x += h.getIndent(); g.setColor(bg); g.fillRect(x, 0, c.getWidth()-x,c.getHeight()); } if (h.isLeadSelection()) { Color focus = UIManager.getColor("Tree.selectionBorderColor"); // NOI18N if (focus == null || focus.equals (bg)) { focus = Color.BLUE; } int x = (h.getIcon() == null ? 0 : h.getIcon().getIconWidth() + h.getIconTextGap()); g.setColor(focus); g.drawRect (x, 0, c.getWidth() - (x + 1), c.getHeight()-1); } paint(g, c); }
Icon icon = r.getIcon();
Icon icon = r.getIcon();
private void paintIconAndTextCentered (Graphics g, HtmlRendererImpl r) { Insets ins = r.getInsets(); Icon ic = r.getIcon(); int w = r.getWidth() - (ins.left + ins.right); int txtX = ins.left; int txtY = 0; if (ic != null && ic.getIconWidth() > 0 && ic.getIconHeight() > 0) { int iconx = w > ic.getIconWidth() ? (w / 2) - (ic.getIconWidth() / 2) : txtX; int icony = 0; ic.paintIcon(r, g, iconx, icony); txtY += ic.getIconHeight() + r.getIconTextGap(); } int txtW = r.getPreferredSize().width; txtX = txtW < r.getWidth() ? (r.getWidth() / 2) - (txtW / 2) : 0; int txtH = r.getHeight() - txtY; Font f = r.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); txtY += fm.getMaxAscent(); Color background = getBackgroundFor (r); Color foreground = ensureContrastingColor (getForegroundFor (r), background); if (r.isHtml()) { HtmlRenderer._renderHTML(r.getText(), 0, g, txtX, txtY, txtW, txtH, f, foreground, r.getRenderStyle(), true, background); } else { HtmlRenderer.renderString(r.getText(), g, txtX, txtY, txtW, txtH, r.getFont(), foreground, r.getRenderStyle(), true); } } /*
private void paintIconAndTextCentered (Graphics g, HtmlRendererImpl r) { Insets ins = r.getInsets(); Icon ic = r.getIcon(); int w = r.getWidth() - (ins.left + ins.right); int txtX = ins.left; int txtY = 0; if (ic != null && ic.getIconWidth() > 0 && ic.getIconHeight() > 0) { int iconx = w > ic.getIconWidth() ? (w / 2) - (ic.getIconWidth() / 2) : txtX; int icony = 0; ic.paintIcon(r, g, iconx, icony); txtY += ic.getIconHeight() + r.getIconTextGap(); } int txtW = r.getPreferredSize().width; txtX = txtW < r.getWidth() ? (r.getWidth() / 2) - (txtW / 2) : 0; int txtH = r.getHeight() - txtY; Font f = r.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); txtY += fm.getMaxAscent(); Color background = getBackgroundFor (r); Color foreground = ensureContrastingColor (getForegroundFor (r), background); if (r.isHtml()) { HtmlRenderer._renderHTML(r.getText(), 0, g, txtX, txtY, txtW, txtH, f, foreground, r.getRenderStyle(), true, background); } else { HtmlRenderer.renderString(r.getText(), g, txtX, txtY, txtW, txtH, r.getFont(), foreground, r.getRenderStyle(), true); } } /*
Icon icon = r.getIcon();
Icon icon = r.getIcon();