if (v != null) { v.paint(g, textRect); } else {
View v = (View) c.getClientProperty(BasicHTML.propertyKey); if (v != null) { v.paint(g, paintTextR); }
View v = (View) c.getClientProperty(BasicHTML.propertyKey); if (v != null) { v.paint(g, paintTextR); }
@Override public void paint(Graphics g, Shape allocation) { Rectangle alloc = allocation.getBounds(); view.setSize(alloc.width, alloc.height); view.paint(g, allocation); }
/** * Renders the view. * * @param g the graphics context * @param allocation the region to render into */ @Override public void paint(Graphics g, Shape allocation) { Rectangle alloc = allocation.getBounds(); view.setSize(alloc.width, alloc.height); view.paint(g, allocation); }
/** * Renders the view. * * @param g the graphics context * @param allocation the region to render into */ @Override public void paint(Graphics g, Shape allocation) { Rectangle alloc = allocation.getBounds(); view.setSize(alloc.width, alloc.height); view.paint(g, allocation); }
/** * Renders the view. * * @param g the graphics context * @param allocation the region to render into */ @Override public void paint(Graphics g, Shape allocation) { Rectangle alloc = allocation.getBounds(); view.setSize(alloc.width, alloc.height); view.paint(g, allocation); }
/** * Renders the view. * * @param g the graphics context * @param allocation the region to render into */ @Override public void paint(Graphics g, Shape allocation) { Rectangle alloc = allocation.getBounds(); view.setSize(alloc.width, alloc.height); view.paint(g, allocation); }
/** * Renders the view. * * @param g the graphics context * @param allocation the region to render into */ @Override public void paint(Graphics g, Shape allocation) { Rectangle alloc = allocation.getBounds(); view.setSize(alloc.width, alloc.height); view.paint(g, allocation); }
/** * Renders the view. * * @param g the graphics context * @param allocation the region to render into */ public void paint(Graphics g, Shape allocation) { if (view != null) { Rectangle alloc = (allocation instanceof Rectangle) ? (Rectangle)allocation : allocation.getBounds(); setSize(alloc.width, alloc.height); view.paint(g, allocation); } }
public void paint(Graphics g, Shape allocation) { lock(); try { if (view != null) { view.paint(g, allocation); } } finally { unlock(); } }
/** * Renders the view. * * @param g the graphics context * @param allocation the region to render into */ public void paint(Graphics g, Shape allocation) { Rectangle alloc = allocation.getBounds(); //log.fine("aloc:" + alloc + "::" + host.getVisibleRect() + "::" + host.getBounds()); //view.setSize(alloc.width, alloc.height); //this.width = alloc.width; //this.height = alloc.height; if (g.getClipBounds() == null) { g.setClip(alloc); view.paint(g, allocation); g.setClip(null); } else { //g.translate(alloc.x, alloc.y); view.paint(g, allocation); //g.translate(-alloc.x, -alloc.y); } }
/** * Renders the view. * * @param g the graphics context * @param allocation the region to render into */ @Override public void paint(Graphics g, Shape allocation) { Rectangle alloc = allocation.getBounds(); //log.fine("aloc:" + alloc + "::" + host.getVisibleRect() + "::" + host.getBounds()); //view.setSize(alloc.width, alloc.height); //this.width = alloc.width; //this.height = alloc.height; if (g.getClipBounds() == null) { g.setClip(alloc); view.paint(g, allocation); g.setClip(null); } else { //g.translate(alloc.x, alloc.y); view.paint(g, allocation); //g.translate(-alloc.x, -alloc.y); } }
public static void main(String[] args) throws Exception { System.setProperty("java.awt.headless", "true"); EventQueue.invokeLater(new Runnable() { @Override public void run() { Rectangle bounds = new Rectangle(255, 255); BufferedImage image = new BufferedImage( bounds.width, bounds.height, BufferedImage.TYPE_INT_RGB); Graphics2D d = image.createGraphics(); d.setClip(bounds); for (int i = 0; i < 1000; i++) { JEditorPane renderHelper = new JEditorPane( "text/html", "<html><body>This is my text.</body></html>"); HTMLDocument document = (HTMLDocument) renderHelper.getDocument(); document.getStyleSheet().addRule("foo{color:black;}"); View rootView = renderHelper.getUI().getRootView(renderHelper); rootView.paint(d, bounds); } } }); }
public static View drawHtmlText(Graphics _g, JComponent _parent, String _text, Rectangle _bounds) { if (_text == null || _text.equals("")) { return null; } View v = BasicHTML.createHTMLView(_parent, _text); HTMLDocument doc=(HTMLDocument)v.getDocument(); doc.getStyleSheet().addRule("body { color: #000000,padding:2px}"); v.paint(_g, _bounds); return v; }
@Override protected void paintText(final Graphics2D g2d) { final String text = component.getText(); if (text != null && !text.equals("")) { final Map map = SwingUtils.setupTextAntialias(g2d); final View v = (View) component.getClientProperty(BasicHTML.propertyKey); if (v != null) { v.paint(g2d, textRect); } else { // Drawing text paintText(g2d, component, text); } SwingUtils.restoreTextAntialias(g2d, map); } }
protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) { g.setFont(font); View v = getTextViewForTab(tabIndex); if(v != null) { // html v.paint(g, textRect); } else { // plain text int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex); if(tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) { g.setColor(tabPane.getForegroundAt(tabIndex)); } else { // tab disabled g.setColor(Theme.tabDisabledTextColor.getColor()); } // Note: Using BasicGraphicsUtils.drawStringUnderlineCharAt(...) // prevented text antialiasing with JRE 1.6.0_10 TinyUtils.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent()); } }
public void paint(Graphics _g) { if (!visible_) return; String tx = getDisplayText(); if ((tx == null)) return; Color tc = Color.BLACK; if (color_ != null) tc = color_.getColor(); _g.setColor(tc); Rectangle bd = getBounds(); if (BasicHTML.isHTMLString(tx)) { _g.setColor(Color.BLACK); if (view_ == null) view_ = DjaGraphics.drawHtmlText(_g, getGrid(), tx, bd); else { view_.paint(_g, bd); } return; } _g.setFont(getFont()); _g.setColor(tc); DjaGraphics.drawText(_g, tx, bd.x, bd.y, getAlignment(), bd.width, isUnderlined()); }
/** * {@inheritDoc} * * <p> * The HTML text is painted last, so it will appear on top of any child * nodes. * </p> */ protected void paint(final PPaintContext paintContext) { super.paint(paintContext); paintContext.pushClip(getBounds()); final Graphics2D g2 = paintContext.getGraphics(); htmlView.paint(g2, getBounds().getBounds()); paintContext.popClip(getBounds()); }
static void paintText(Graphics g, SeaGlassMenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr) { if (!lh.getText().equals("")) { if (lh.getHtmlView() != null) { // Text is HTML lh.getHtmlView().paint(g, lr.getTextRect()); } else { // Text isn't HTML g.setColor(lh.getStyle().getColor( lh.getContext(), ColorType.TEXT_FOREGROUND)); g.setFont(lh.getStyle().getFont(lh.getContext())); lh.getGraphicsUtils().paintText(lh.getContext(), g, lh.getText(), lr.getTextRect().x, lr.getTextRect().y, lh.getMenuItem().getDisplayedMnemonicIndex()); } } }