public @Override Insets getInsets(Insets insets) { Insets result; //Call getBorder(), not just read the field - if swingRendering, the border will be constructed, and the //insets are what will make the indent property work; HtmlLabelUI doesn't need this, it just reads the //insets property, but BasicLabelUI and its ilk do Border b = getBorder(); if (b == null) { result = EMPTY_INSETS; } else { //workaround for open jdk bug, see issue #192388 try { result = b.getBorderInsets(this); } catch( NullPointerException e ) { Logger.getLogger(HtmlRendererImpl.class.getName()).log(Level.FINE, null, e); result = EMPTY_INSETS; } } if( null != insets ) { insets.set( result.top, result.left, result.bottom, result.right); return insets; } return result; }
private Dimension calcPreferredSize(HtmlRendererImpl r) { Insets ins = r.getInsets(); Dimension prefSize = new java.awt.Dimension(ins.left + ins.right, ins.top + ins.bottom); String text = r.getText();
private void paintIconAndTextCentered(Graphics g, HtmlRendererImpl r) { Insets ins = r.getInsets(); Icon ic = r.getIcon(); int w = r.getWidth() - (ins.left + ins.right);
Insets ins = r.getInsets();
private Dimension calcPreferredSize(HtmlRendererImpl r) { Insets ins = r.getInsets(); Dimension prefSize = new java.awt.Dimension(ins.left + ins.right, ins.top + ins.bottom); String text = r.getText();
private Dimension calcPreferredSize(HtmlRendererImpl r) { Insets ins = r.getInsets(); Dimension prefSize = new java.awt.Dimension(ins.left + ins.right, ins.top + ins.bottom); String text = r.getText();
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); } } /*
Insets ins = r.getInsets();
Insets ins = r.getInsets();