java3d
  1. java3d
  2. JAVA3D-89

Improve SimpleUniverse.getPreferredConfiguration to work on dual monitor computers

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Trivial Trivial
    • Resolution: Unresolved
    • Affects Version/s: 1.3.2
    • Fix Version/s: not determined
    • Component/s: j3d-core-utils
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      89
    • Status Whiteboard:
      Hide

      owner-needed

      Show
      owner-needed

      Description

      I had the following problem with our j3d application:
      I have a dual monitor computer. When I opened the application, it opened in the
      default screen as it should. Our application doesn't have the Canvas3D in the
      beginning, it gets created after a model is imported. If I imported the model on
      the default monitor, I was able to move the application to the other screen and
      also extend it to both monitors. However, If I moved the application to the
      second screen before importing the model, I got the following exception:

      java.lang.IllegalArgumentException: adding a container to a container on a
      different GraphicsDevice
      at java.awt.Component.checkGD(Unknown Source)
      at java.awt.Container.checkGD(Unknown Source)
      at java.awt.Container.addImpl(Unknown Source)
      at java.awt.Container.add(Unknown Source)

        Activity

        Hide
        paasiala added a comment -

        I took the code of SimpleUniverse and came up with the following code that works
        independently of where the frame is:

        /**

        • Finds the preferred <code>GraphicsConfiguration</code> object
        • for the system. This object can then be used to create the
        • Canvas3D objet for this system.
        • @param window the window in which the Canvas3D will reside
          *
        • @return The best <code>GraphicsConfiguration</code> object for
        • the system.
          */
          public static GraphicsConfiguration getPreferredConfiguration(Window window) {
          GraphicsDevice device = window.getGraphicsConfiguration().getDevice();
          GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
          String stereo;

        // Check if the user has set the Java 3D stereo option.
        // Getting the system properties causes appletviewer to fail with a
        // security exception without a try/catch.

        stereo = (String) java.security.AccessController.doPrivileged(
        new java.security.PrivilegedAction() {
        public Object run()

        { return System.getProperty("j3d.stereo"); }

        });

        // update template based on properties.
        if (stereo != null)

        { if (stereo.equals("REQUIRED")) template.setStereo(GraphicsConfigTemplate.REQUIRED); else if (stereo.equals("PREFERRED")) template.setStereo(GraphicsConfigTemplate.PREFERRED); }

        // Return the GraphicsConfiguration that best fits our needs.
        return device.getBestConfiguration(template);
        }

        Show
        paasiala added a comment - I took the code of SimpleUniverse and came up with the following code that works independently of where the frame is: /** Finds the preferred <code>GraphicsConfiguration</code> object for the system. This object can then be used to create the Canvas3D objet for this system. @param window the window in which the Canvas3D will reside * @return The best <code>GraphicsConfiguration</code> object for the system. */ public static GraphicsConfiguration getPreferredConfiguration(Window window) { GraphicsDevice device = window.getGraphicsConfiguration().getDevice(); GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D(); String stereo; // Check if the user has set the Java 3D stereo option. // Getting the system properties causes appletviewer to fail with a // security exception without a try/catch. stereo = (String) java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { public Object run() { return System.getProperty("j3d.stereo"); } }); // update template based on properties. if (stereo != null) { if (stereo.equals("REQUIRED")) template.setStereo(GraphicsConfigTemplate.REQUIRED); else if (stereo.equals("PREFERRED")) template.setStereo(GraphicsConfigTemplate.PREFERRED); } // Return the GraphicsConfiguration that best fits our needs. return device.getBestConfiguration(template); }
        Hide
        paasiala added a comment -

        The method actually could come in three variations

        getPreferredConfiguration()
        getPreferredConfiguration(Window)
        getPreferredConfiguration(GraphicsDevice)

        The first two would call the last one.

        Show
        paasiala added a comment - The method actually could come in three variations getPreferredConfiguration() getPreferredConfiguration(Window) getPreferredConfiguration(GraphicsDevice) The first two would call the last one.
        Hide
        kcr added a comment -

        Created an attachment (id=53)
        Test program for issue

        Show
        kcr added a comment - Created an attachment (id=53) Test program for issue
        Hide
        kcr added a comment -

        Please ignore the TetCanvasPanel.java attachment. It was supposed to be attached
        to another bug.

        Show
        kcr added a comment - Please ignore the TetCanvasPanel.java attachment. It was supposed to be attached to another bug.
        Hide
        kcr added a comment -

        Lowering to P4 reflecting the priority for 1.3.2. This would be a great
        community project if someone wants to volunteer.

        Show
        kcr added a comment - Lowering to P4 reflecting the priority for 1.3.2. This would be a great community project if someone wants to volunteer.
        Hide
        jada added a comment -

        Encourage community participation. Downgrade to P5 and mark as owner-needed.

        Show
        jada added a comment - Encourage community participation. Downgrade to P5 and mark as owner-needed.

          People

          • Assignee:
            java3d-issues
            Reporter:
            paasiala
          • Votes:
            4 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: