Пример #1
0
  private void updateOpacity() {

    SurfaceRendererComponent surfaceRendererComponent =
        getComponent(SurfaceRendererComponent.class);
    if (surfaceRendererComponent != null) {
      surfaceRendererComponent.setOpacity(getRenderingOpacity());
    }

    for (Entity child : children) {
      child.updateOpacity();
    }
  }
Пример #2
0
  /**
   * Create Entity from {@link Drawable}. New Entity has plane geometry.
   *
   * @param drawable Drawable for surface.
   * @return new Entity
   */
  public static Entity from(Drawable drawable) {

    final Entity entity = new Entity();
    entity.add(SurfaceRendererComponent.from(drawable));
    entity.add(GeometryComponent.from(drawable));

    return entity;
  }
Пример #3
0
  /**
   * Create Entity from {@link View}. New Entity has plane geometry.
   *
   * @param view View for surface.
   * @return new Entity
   */
  public static Entity from(View view) {

    final Entity entity = new Entity();
    entity.add(SurfaceRendererComponent.from(view));
    entity.add(GeometryComponent.from(view));

    return entity;
  }
Пример #4
0
  /**
   * Get {@link View}. This works only for Entity which is created by {@link #from(View)} or has
   * {@link SurfaceRendererComponent} which is created by {@link
   * SurfaceRendererComponent#from(View)}.
   *
   * @return View
   */
  public View view() {
    SurfaceRendererComponent surfaceRendererComponent =
        getComponent(SurfaceRendererComponent.class);
    if (surfaceRendererComponent == null) {
      return null;
    }

    SurfaceRendererComponent.CanvasRenderer canvasRenderer =
        surfaceRendererComponent.getCanvasRenderer();
    if (canvasRenderer == null) {
      return null;
    }

    if (canvasRenderer instanceof SurfaceRendererComponent.ViewRenderer) {
      return ((SurfaceRendererComponent.ViewRenderer) canvasRenderer).getView();
    }

    return null;
  }