Пример #1
0
  // documentation inherited
  protected void layout() {
    super.layout();

    // if we have no view yet, stop now
    if (_view == null) {
      return;
    }

    // avoid rerendering our HTML unless something changed
    int vwidth = getWidth() - getInsets().getHorizontal();
    int vheight = getHeight() - getInsets().getVertical();
    if (_rendered != null && _rsize != null && _rsize.width == vwidth && _rsize.height == vheight) {
      return;
    }

    BufferedImage image = new BufferedImage(vwidth, vheight, BufferedImage.TYPE_4BYTE_ABGR);
    Graphics2D gfx = image.createGraphics();
    _rsize = new Rectangle(0, 0, vwidth, vheight);
    try {
      gfx.setClip(_rsize);
      if (_antialias) {
        gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      }
      _view.paint(gfx, _rsize);
    } finally {
      gfx.dispose();
    }

    // TODO: render into a properly sized image in the first place and
    // create a JME Image directly
    _rendered = new Image(image);
  }
Пример #2
0
  // documentation inherited
  protected void renderComponent(Renderer renderer) {
    super.renderComponent(renderer);

    if (_rendered != null) {
      Insets insets = getInsets();
      _rendered.render(renderer, insets.left, insets.bottom, _alpha);
    }
  }
Пример #3
0
 @Override
 public Component createTooltipComponent(String tiptext) {
   return Component.createDefaultTooltipComponent(_ctx, tiptext);
 }