Search in sources :

Example 1 with Color3f

use of javax.vecmath.Color3f in project ffx by mjschnie.

the class GraphicsCanvas method loadPrefs.

/**
 * Load preferences from the user node.
 */
public void loadPrefs() {
    String c = GraphicsCanvas.class.getName();
    RendererCache.bondwidth = prefs.getInt(c + ".bondwidth", 3);
    RendererCache.detail = prefs.getInt(c + ".detail", 3);
    RendererCache.radius = prefs.getDouble(c + ".radius", 1.0d);
    String s = prefs.get(c + ".mouse", MouseMode.ACTIVESYSTEM.name());
    if (s.equalsIgnoreCase("ACTIVESYSTEM") || s.equalsIgnoreCase("SYSTEMBELOWMOUSE")) {
        mouseMode = MouseMode.valueOf(s);
    } else {
        mouseMode = MouseMode.ACTIVESYSTEM;
    }
    mainPanel.getMainMenu().setMouseMode(mouseMode);
    RendererCache.highlightSelections = prefs.getBoolean(c + ".highlight", false);
    mainPanel.getMainMenu().setHighlighting(RendererCache.highlightSelections);
    String[] hlColor = prefs.get(c + ".highlightColor", "153 153 255").trim().split(" +");
    Color newColor = new Color(Integer.parseInt(hlColor[0]), Integer.parseInt(hlColor[1]), Integer.parseInt(hlColor[2]));
    RendererCache.selectionColor = new Color3f(newColor);
    RendererCache.labelAtoms = prefs.getBoolean(c + ".labelAtoms", false);
    mainPanel.getMainMenu().setAtomLabels(RendererCache.labelAtoms);
    RendererCache.labelResidues = prefs.getBoolean(c + ".labelResidues", false);
    mainPanel.getMainMenu().setResidueLabels(RendererCache.labelResidues);
    /*
         * int fontSize = prefs.getInt("Graphics_labelSize", 12); J3DGraphics2D
         * j2D = getOffscreenCanvas3D().getGraphics2D(); Font currentFont =
         * j2D.getFont(); Font newFont = new Font(currentFont.getName(),
         * currentFont.getStyle(), fontSize); j2D.setFont(newFont); String[]
         * fontColor = prefs.get("Graphics_labelColor", "255 255 255")
         * .trim().split(" +"); newColor = new
         * Color(Integer.parseInt(fontColor[0]), Integer
         * .parseInt(fontColor[1]), Integer.parseInt(fontColor[2]));
         * j2D.setPaint(newColor);
         */
    String[] pickColor = prefs.get(c + ".pickColor", "102 255 102").trim().split(" +");
    newColor = new Color(Integer.parseInt(pickColor[0]), Integer.parseInt(pickColor[1]), Integer.parseInt(pickColor[2]));
    RendererCache.pickingColor = new Color3f(newColor);
    String pickLevel = prefs.get(c + ".pickLevel", "PickAtom");
    mainPanel.getMainMenu().setPickLevel(pickLevel);
    boolean pickMode = prefs.getBoolean(c + ".picking", false);
    if (pickMode) {
        rendererPicking.setPicking(true);
    }
    mainPanel.getMainMenu().setPickBehavior(pickMode);
    String[] userColor = prefs.get(c + ".userColor", "255 255 255").trim().split(" +");
    newColor = new Color(Integer.parseInt(userColor[0]), Integer.parseInt(userColor[1]), Integer.parseInt(userColor[2]));
    RendererCache.userColor = new Color3f(newColor);
/*
         * String[] bgColor = prefs.get("Graphics_backgroundColor", "0 0 0")
         * .trim().split(" +"); newColor = new
         * Color(Integer.parseInt(bgColor[0]), Integer .parseInt(bgColor[1]),
         * Integer.parseInt(bgColor[2])); background.setColor(new
         * Color3f(newColor));
         */
}
Also used : Color(java.awt.Color) Color3f(javax.vecmath.Color3f)

Example 2 with Color3f

use of javax.vecmath.Color3f in project ffx by mjschnie.

the class GraphicsCanvas method setSelectionColor.

/**
 * <p>
 * setSelectionColor</p>
 */
public void setSelectionColor() {
    Color3f col = new Color3f();
    RendererCache.selectionColor.get(col);
    Color newcolor = JColorChooser.showDialog(this, "Choose Selection Color", col.get());
    if (newcolor != null) {
        RendererCache.selectionColor = new Color3f(newcolor);
    }
    if (RendererCache.highlightSelections) {
        this.updateScene(mainPanel.getDataRoot(), false, false, null, true, RendererCache.ColorModel.SELECT);
    }
}
Also used : Color3f(javax.vecmath.Color3f) Color(java.awt.Color)

Example 3 with Color3f

use of javax.vecmath.Color3f in project ffx by mjschnie.

the class GraphicsCanvas method setUserColor.

/**
 * <p>
 * setUserColor</p>
 */
public void setUserColor() {
    Color3f col = new Color3f();
    RendererCache.selectionColor.get(col);
    Color newcolor = JColorChooser.showDialog(this, "Choose User Color", col.get());
    if (newcolor != null) {
        RendererCache.userColor = new Color3f(newcolor);
    }
}
Also used : Color3f(javax.vecmath.Color3f) Color(java.awt.Color)

Example 4 with Color3f

use of javax.vecmath.Color3f in project ffx by mjschnie.

the class GraphicsCanvas method setGraphicsPickingColor.

/**
 * <p>
 * setGraphicsPickingColor</p>
 */
public void setGraphicsPickingColor() {
    Color3f col = new Color3f();
    RendererCache.pickingColor.get(col);
    Color newcolor = JColorChooser.showDialog(this, "Choose Picking Color", col.get());
    if (newcolor != null) {
        RendererCache.pickingColor = new Color3f(newcolor);
    }
}
Also used : Color3f(javax.vecmath.Color3f) Color(java.awt.Color)

Example 5 with Color3f

use of javax.vecmath.Color3f in project ffx by mjschnie.

the class MolecularAssembly method createBox.

/**
 * <p>
 * createBox</p>
 */
public void createBox() {
    int vertices = 8;
    LineArray la = new LineArray(4 * vertices, GeometryArray.COORDINATES | GeometryArray.COLOR_4 | GeometryArray.NORMALS);
    la.setCapability(LineArray.ALLOW_COORDINATE_WRITE);
    la.setCapability(LineArray.ALLOW_COORDINATE_READ);
    la.setCapability(LineArray.ALLOW_COLOR_WRITE);
    la.setCapability(LineArray.ALLOW_COUNT_READ);
    la.setCapability(LineArray.ALLOW_INTERSECT);
    la.setCapability(LineArray.ALLOW_FORMAT_READ);
    // Create a normal
    // for (ListIterator<MSNode> li = bondlist.listIterator(); li.hasNext(); ){
    // la.setCoordinate(i, a1);
    // la.setColor(i, col);
    // la.setNormal(i++, a1);
    // }
    ColoringAttributes cola = new ColoringAttributes(new Color3f(), ColoringAttributes.SHADE_GOURAUD);
    Appearance app = new Appearance();
    lineAttributes = new LineAttributes();
    lineAttributes.setLineWidth(RendererCache.bondwidth);
    lineAttributes.setCapability(LineAttributes.ALLOW_WIDTH_WRITE);
    lineAttributes.setLineAntialiasingEnable(true);
    app.setLineAttributes(lineAttributes);
    app.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_READ);
    app.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_WRITE);
    RenderingAttributes ra = new RenderingAttributes();
    ra.setAlphaTestValue(0.1f);
    ra.setAlphaTestFunction(RenderingAttributes.GREATER);
    ra.setDepthBufferEnable(true);
    ra.setDepthBufferWriteEnable(true);
    app.setRenderingAttributes(ra);
    app.setColoringAttributes(cola);
    Shape3D wireframe = new Shape3D(la, app);
    // PickTool.setCapabilities(wire, PickTool.INTERSECT_COORD);
    wireframe.setUserData(this);
    wireframe.setBounds(new BoundingSphere(new Point3d(0, 0, 0), 10.0));
    try {
        wireframe.setBoundsAutoCompute(false);
    } catch (Exception e) {
        e.printStackTrace();
    }
    wireframe.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
    wireframe.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
// return wire;
}
Also used : BoundingSphere(javax.media.j3d.BoundingSphere) Point3d(javax.vecmath.Point3d) Color3f(javax.vecmath.Color3f) RenderingAttributes(javax.media.j3d.RenderingAttributes) LineArray(javax.media.j3d.LineArray) ColoringAttributes(javax.media.j3d.ColoringAttributes) Shape3D(javax.media.j3d.Shape3D) Appearance(javax.media.j3d.Appearance) LineAttributes(javax.media.j3d.LineAttributes)

Aggregations

Color3f (javax.vecmath.Color3f)11 Color (java.awt.Color)6 Appearance (javax.media.j3d.Appearance)3 BoundingSphere (javax.media.j3d.BoundingSphere)3 Point3d (javax.vecmath.Point3d)3 Vector3d (javax.vecmath.Vector3d)3 ColoringAttributes (javax.media.j3d.ColoringAttributes)2 LineArray (javax.media.j3d.LineArray)2 LineAttributes (javax.media.j3d.LineAttributes)2 RenderingAttributes (javax.media.j3d.RenderingAttributes)2 Shape3D (javax.media.j3d.Shape3D)2 Transform3D (javax.media.j3d.Transform3D)2 TransformGroup (javax.media.j3d.TransformGroup)2 Cone (com.sun.j3d.utils.geometry.Cone)1 Cylinder (com.sun.j3d.utils.geometry.Cylinder)1 Sphere (com.sun.j3d.utils.geometry.Sphere)1 SimpleUniverse (com.sun.j3d.utils.universe.SimpleUniverse)1 Atom (ffx.potential.bonded.Atom)1 Bond (ffx.potential.bonded.Bond)1 ROLS (ffx.potential.bonded.ROLS)1