Search in sources :

Example 1 with Geometry

use of javax.media.j3d.Geometry in project ffx by mjschnie.

the class Atom method setView.

/**
 * {@inheritDoc}
 *
 * Polymorphic setView method.
 */
@Override
public void setView(ViewModel newViewModel, List<BranchGroup> newShapes) {
    switch(newViewModel) {
        // case INVISIBLE through case TUBE change the "ViewModel"
        case INVISIBLE:
            viewModel = ViewModel.INVISIBLE;
            setSphereVisible(false, newShapes);
            break;
        case WIREFRAME:
            viewModel = ViewModel.INVISIBLE;
            setSphereVisible(false, newShapes);
            break;
        case SPACEFILL:
            viewModel = ViewModel.SPACEFILL;
            scale = AtomVDW.get(atomType.atomicNumber) * radius;
            setSphereVisible(true, newShapes);
            break;
        case RMIN:
            viewModel = ViewModel.RMIN;
            scale = 1.0 * radius;
            setSphereVisible(true, newShapes);
            break;
        case BALLANDSTICK:
            viewModel = ViewModel.BALLANDSTICK;
            scale = AtomVDW.get(atomType.atomicNumber) / 5.0d * radius;
            setSphereVisible(true, newShapes);
            break;
        case TUBE:
            viewModel = ViewModel.TUBE;
            scale = RendererCache.radius * 0.2d;
            setSphereVisible(true, newShapes);
            break;
        case SHOWHYDROGENS:
            if (atomType.atomicNumber == 1) {
                return;
            }
            break;
        case HIDEHYDROGENS:
            if (atomType.atomicNumber == 1) {
                viewModel = ViewModel.INVISIBLE;
                setSphereVisible(false, newShapes);
                return;
            }
            break;
        case RESTRICT:
            if (!isSelected()) {
                viewModel = ViewModel.INVISIBLE;
                setSphereVisible(false, newShapes);
                return;
            }
            break;
        case DETAIL:
            int newdetail = RendererCache.detail;
            if (newdetail != detail) {
                detail = newdetail;
                if (sphere != null) {
                    Geometry geom = RendererCache.getSphereGeom(detail);
                    sphere.removeAllGeometries();
                    sphere.addGeometry(geom);
                }
            }
            double newradius = RendererCache.radius;
            if (newradius != radius) {
                radius = newradius;
                setView(viewModel, newShapes);
            }
            break;
        // Polygon Appearance Selection
        case FILL:
        case POINTS:
        case LINES:
            polygonType = newViewModel;
            appearance = RendererCache.appearanceFactory(currentCol, polygonType);
            if (viewModel != ViewModel.INVISIBLE) {
                setSphereVisible(true, newShapes);
            }
            break;
    }
}
Also used : Geometry(javax.media.j3d.Geometry)

Example 2 with Geometry

use of javax.media.j3d.Geometry in project ffx by mjschnie.

the class GraphicsAxis method createAxisLabel.

@SuppressWarnings("unchecked")
private TransformGroup createAxisLabel(String letter, Font3D font3d, Appearance ap, double x, double y, double z) {
    Text3D text = new Text3D(font3d, letter);
    text.setUserData(this);
    Transform3D t3D = new Transform3D();
    t3D.setTranslation(new Vector3d(x, y, z));
    TransformGroup tg = new TransformGroup(t3D);
    Shape3D text3d = new Shape3D(text, ap);
    text3d.setUserData(this);
    for (Enumeration<Geometry> e = text3d.getAllGeometries(); e.hasMoreElements(); ) {
        Geometry g = e.nextElement();
        g.setCapability(Geometry.ALLOW_INTERSECT);
    }
    text3d.setCapability(Shape3D.ENABLE_PICK_REPORTING);
    text3d.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
    tg.addChild(text3d);
    return tg;
}
Also used : Text3D(javax.media.j3d.Text3D) Geometry(javax.media.j3d.Geometry) Vector3d(javax.vecmath.Vector3d) Transform3D(javax.media.j3d.Transform3D) Shape3D(javax.media.j3d.Shape3D) TransformGroup(javax.media.j3d.TransformGroup)

Example 3 with Geometry

use of javax.media.j3d.Geometry in project ffx by mjschnie.

the class Bond method setView.

/**
 * {@inheritDoc}
 *
 * Polymorphic setView method.
 */
@Override
public void setView(RendererCache.ViewModel newViewModel, List<BranchGroup> newShapes) {
    switch(newViewModel) {
        case WIREFRAME:
            viewModel = ViewModel.WIREFRAME;
            setWireVisible(true);
            setCylinderVisible(false, newShapes);
            break;
        case SPACEFILL:
        case INVISIBLE:
        case RMIN:
            viewModel = ViewModel.INVISIBLE;
            setWireVisible(false);
            setCylinderVisible(false, newShapes);
            break;
        case RESTRICT:
            if (!atoms[0].isSelected() || !atoms[1].isSelected()) {
                viewModel = ViewModel.INVISIBLE;
                setWireVisible(false);
                setCylinderVisible(false, newShapes);
            }
            break;
        case BALLANDSTICK:
        case TUBE:
            viewModel = newViewModel;
            // Get the radius to use
            double rad;
            double len = getValue() / 2.0d;
            if (viewModel == RendererCache.ViewModel.BALLANDSTICK) {
                rad = 0.1d * RendererCache.radius;
            } else {
                rad = 0.2d * RendererCache.radius;
            }
            if (scale == null) {
                scale = new Vector3d();
            }
            scale.set(rad, len, rad);
            setWireVisible(false);
            setCylinderVisible(true, newShapes);
            break;
        case DETAIL:
            int res = RendererCache.detail;
            if (res != detail) {
                detail = res;
                if (branchGroup != null) {
                    Geometry geom1 = RendererCache.getCylinderGeom(0, detail);
                    Geometry geom2 = RendererCache.getCylinderGeom(1, detail);
                    Geometry geom3 = RendererCache.getCylinderGeom(2, detail);
                    cy1.removeAllGeometries();
                    cy2.removeAllGeometries();
                    cy1.addGeometry(geom1);
                    cy1.addGeometry(geom2);
                    cy1.addGeometry(geom3);
                    cy2.addGeometry(geom1);
                    cy2.addGeometry(geom2);
                    cy2.addGeometry(geom3);
                }
            }
            if (scale == null) {
                scale = new Vector3d();
            }
            double newRadius;
            if (viewModel == RendererCache.ViewModel.BALLANDSTICK) {
                newRadius = 0.1d * RendererCache.radius;
            } else if (viewModel == RendererCache.ViewModel.TUBE) {
                newRadius = 0.2d * RendererCache.radius;
            } else {
                break;
            }
            if (newRadius != scale.x) {
                scale.x = newRadius;
                scale.y = newRadius;
                if (branchGroup != null) {
                    setView(viewModel, newShapes);
                }
            }
            break;
        case SHOWHYDROGENS:
            if (atoms[0].getAtomicNumber() == 1 || atoms[1].getAtomicNumber() == 1) {
                setView(viewModel, newShapes);
            }
            break;
        case HIDEHYDROGENS:
            if (atoms[0].getAtomicNumber() == 1 || atoms[1].getAtomicNumber() == 1) {
                viewModel = ViewModel.INVISIBLE;
                setWireVisible(false);
                setCylinderVisible(false, newShapes);
            }
            break;
        case FILL:
        case POINTS:
        case LINES:
            if (branchGroup != null && viewModel != ViewModel.INVISIBLE) {
                cy1.setAppearance(atoms[0].getAtomAppearance());
                cy2.setAppearance(atoms[1].getAtomAppearance());
            }
            break;
    }
}
Also used : Geometry(javax.media.j3d.Geometry) Vector3d(javax.vecmath.Vector3d)

Example 4 with Geometry

use of javax.media.j3d.Geometry in project ffx by mjschnie.

the class RestraintBond method setView.

/**
 * {@inheritDoc}
 *
 * Polymorphic setView method.
 */
@Override
public void setView(RendererCache.ViewModel newViewModel, List<BranchGroup> newShapes) {
    switch(newViewModel) {
        case WIREFRAME:
            viewModel = ViewModel.WIREFRAME;
            setWireVisible(true);
            setCylinderVisible(false, newShapes);
            break;
        case SPACEFILL:
        case INVISIBLE:
        case RMIN:
            viewModel = ViewModel.INVISIBLE;
            setWireVisible(false);
            setCylinderVisible(false, newShapes);
            break;
        case RESTRICT:
            if (!atoms[0].isSelected() || !atoms[1].isSelected()) {
                viewModel = ViewModel.INVISIBLE;
                setWireVisible(false);
                setCylinderVisible(false, newShapes);
            }
            break;
        case BALLANDSTICK:
        case TUBE:
            viewModel = newViewModel;
            // Get the radius to use
            double rad;
            double len = getValue() / 2.0d;
            if (viewModel == RendererCache.ViewModel.BALLANDSTICK) {
                rad = 0.1d * RendererCache.radius;
            } else {
                rad = 0.2d * RendererCache.radius;
            }
            if (scale == null) {
                scale = new Vector3d();
            }
            scale.set(rad, len, rad);
            setWireVisible(false);
            setCylinderVisible(true, newShapes);
            break;
        case DETAIL:
            int res = RendererCache.detail;
            if (res != detail) {
                detail = res;
                if (branchGroup != null) {
                    Geometry geom1 = RendererCache.getCylinderGeom(0, detail);
                    Geometry geom2 = RendererCache.getCylinderGeom(1, detail);
                    Geometry geom3 = RendererCache.getCylinderGeom(2, detail);
                    cy1.removeAllGeometries();
                    cy2.removeAllGeometries();
                    cy1.addGeometry(geom1);
                    cy1.addGeometry(geom2);
                    cy1.addGeometry(geom3);
                    cy2.addGeometry(geom1);
                    cy2.addGeometry(geom2);
                    cy2.addGeometry(geom3);
                }
            }
            if (scale == null) {
                scale = new Vector3d();
            }
            double newRadius;
            if (viewModel == RendererCache.ViewModel.BALLANDSTICK) {
                newRadius = 0.1d * RendererCache.radius;
            } else if (viewModel == RendererCache.ViewModel.TUBE) {
                newRadius = 0.2d * RendererCache.radius;
            } else {
                break;
            }
            if (newRadius != scale.x) {
                scale.x = newRadius;
                scale.y = newRadius;
                if (branchGroup != null) {
                    setView(viewModel, newShapes);
                }
            }
            break;
        case SHOWHYDROGENS:
            if (atoms[0].getAtomicNumber() == 1 || atoms[1].getAtomicNumber() == 1) {
                setView(viewModel, newShapes);
            }
            break;
        case HIDEHYDROGENS:
            if (atoms[0].getAtomicNumber() == 1 || atoms[1].getAtomicNumber() == 1) {
                viewModel = ViewModel.INVISIBLE;
                setWireVisible(false);
                setCylinderVisible(false, newShapes);
            }
            break;
        case FILL:
        case POINTS:
        case LINES:
            if (branchGroup != null && viewModel != ViewModel.INVISIBLE) {
                cy1.setAppearance(atoms[0].getAtomAppearance());
                cy2.setAppearance(atoms[1].getAtomAppearance());
            }
            break;
    }
}
Also used : Geometry(javax.media.j3d.Geometry) Vector3d(javax.vecmath.Vector3d)

Aggregations

Geometry (javax.media.j3d.Geometry)4 Vector3d (javax.vecmath.Vector3d)3 Shape3D (javax.media.j3d.Shape3D)1 Text3D (javax.media.j3d.Text3D)1 Transform3D (javax.media.j3d.Transform3D)1 TransformGroup (javax.media.j3d.TransformGroup)1