code: 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');
      }
docs: 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