/** * Updates a Graphics according to this context * * @param g Graphics to be updated */ public void updateGraphics(Graphics2D g) { g.setFont(font); g.setColor(color); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); g.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); }
/** * Updates this context according to the given style. Moreover given Graphics is updated to this * style and used for taking the font metrics. * * @param style the style data to be used * @param g Graphics to be updated and used */ public void updateForGraphics(NodeData style, Graphics2D g) { if (style != null) update(style); updateGraphics(g); fm = g.getFontMetrics(); // update the width units // em has been updated in update() FontRenderContext frc = new FontRenderContext(null, false, false); TextLayout layout = new TextLayout("x", font, frc); ex = layout.getBounds().getHeight(); ch = fm.charWidth('0'); }