Package horcher.visual

Source Code of horcher.visual.AntiAliased

/**27.07.2008
* Jan Gunnar Gleixner
* Horcher
*
*
*/
package horcher.visual;

import javax.media.j3d.Appearance;
import javax.media.j3d.LineAttributes;
import javax.media.j3d.PolygonAttributes;
import javax.media.j3d.Shape3D;

import com.sun.j3d.utils.geometry.Primitive;

public class AntiAliased<E extends Primitive> extends Primitive {
  private final E primitive, rahmen;

  @SuppressWarnings("unchecked")
  public AntiAliased(final E prim) {
    this.primitive = prim;
    this.rahmen = (E) prim.cloneTree(true);
    this.update();
    this.addChild(this.primitive);
    this.addChild(this.rahmen);
  }
  @Override
  public Appearance getAppearance(final int arg0) {
    return this.primitive.getAppearance(arg0);
  }
  @Override
  public Shape3D getShape(final int arg0) {
    return this.primitive.getShape(arg0);
  }
  @Override
  public void setAppearance(final Appearance arg0) {
    this.primitive.setAppearance(arg0);
    this.update();
  }

  private void update() {
    final Appearance appear = this.primitive.getAppearance();
    final Appearance appearR = new Appearance();
    appearR.setMaterial(appear.getMaterial());
    appearR.setColoringAttributes(appear.getColoringAttributes());
    appearR.setRenderingAttributes(appear.getRenderingAttributes());
    final LineAttributes lineAttr2 = new LineAttributes();
    lineAttr2.setLineAntialiasingEnable(true);
    appearR.setLineAttributes(lineAttr2);

    final PolygonAttributes polyAttr2 = new PolygonAttributes();
    polyAttr2.setPolygonMode(PolygonAttributes.POLYGON_LINE);
    appearR.setPolygonAttributes(polyAttr2);

    this.rahmen.setAppearance(appearR);
  }
}
TOP

Related Classes of horcher.visual.AntiAliased

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.