Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8675343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:55:37+00:00 2026-06-12T19:55:37+00:00

I made a desktop app with the NetBeans platform using Java Swing technology. In

  • 0

I made a desktop app with the NetBeans platform using Java Swing technology. In that app I do image processing on a 3D image using PointArray[] objects.

When my app runs on a PC which has windows 7, a graphics card, and good RAM capacity (4GB RAM), my 3D image is created and displayed within 5 to 6 sec after clicking on the 3DImage button. But when my app runs on a Windows XP, low graphics configuration PC, my 3D image takes up to three minutes to render or some time it doesn’t display image. So how can I solve that problem?

My code is below.

import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
import com.sun.j3d.utils.behaviors.mouse.MouseWheelZoom;
import com.sun.j3d.utils.universe.SimpleUniverse;
import java.awt.BorderLayout;
import java.awt.GraphicsConfiguration;
import java.awt.image.BufferedImage;
import javax.media.j3d.Appearance;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;
import javax.media.j3d.ColoringAttributes;
import javax.media.j3d.GeometryArray;
import javax.media.j3d.PointArray;
import javax.media.j3d.PointAttributes;
import javax.media.j3d.Shape3D;
import javax.media.j3d.TransformGroup;
import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
import javax.vecmath.Point3f;


public final class FinalDImage extends JPanel {

    private static int s = 0, count = 0, r = 0, g = 0, b = 0, medHeight = 0, medWidth = 0;
    private static float divisior1 = 300000.0f;
    private static Shape3D plShape;
    private static TransformGroup objRotate;
    private static BranchGroup scene;
    private static JButton btn;
    private static Canvas3D canvas3D;
    private static SimpleUniverse simpleU;
    private static GraphicsConfiguration gc;
    private static BufferedImage histImage;
    private static JPanel jPanel1 = new JPanel();

    public FinalDImage(BufferedImage histImage) {
        FinalDImage.histImage = histImage;
        medWidth = (int) (histImage.getWidth() / 2.0f);
        medHeight = (int) (histImage.getHeight() / 2.0f);
        this.add(jPanel1);
        initComponents();
    }

    public void initComponents() {
        setLayout(new BorderLayout());
        btn = new JButton("Intensity");
        gc = SimpleUniverse.getPreferredConfiguration();
        canvas3D = new Canvas3D(gc);//See the added gc? this is a preferred config
        add("Center", canvas3D);
        add(btn, BorderLayout.SOUTH);
        scene = createSceneGraph(FinalDImage.histImage);
        scene.setCapability(BranchGroup.ALLOW_DETACH);
        scene.compile();
        simpleU = new SimpleUniverse(canvas3D);
        simpleU.getViewingPlatform().setNominalViewingTransform();
        simpleU.addBranchGraph(scene);
    }

    public BranchGroup createSceneGraph(BufferedImage histImage) {
        count = 0;
        BranchGroup lineGroup = new BranchGroup();
        Appearance app = new Appearance();
        ColoringAttributes ca = new ColoringAttributes(new Color3f(204.0f, 204.0f, 204.0f), ColoringAttributes.SHADE_FLAT);
        app.setColoringAttributes(ca);

        Point3f plaPts;
        Color3f color;
        PointArray pla = new PointArray(histImage.getWidth() * histImage.getHeight(), GeometryArray.COLOR_3 | GeometryArray.COORDINATES);

        if (histImage.getType() == 11) {
            for (int i = histImage.getWidth() - 3; i >= 3; i--) {
                for (int j = histImage.getHeight() - 3; j >= 3; j--) {
                    s = histImage.getRaster().getSample(i, j, 0);
                    plaPts = new Point3f((medWidth - i) / 1500.0f,
                                         (medHeight - j) / 1500.0f,
                                         s / divisior1);
                    color = new Color3f(s / 60000.0f, s / 60000.0f, s / 60000.0f);
                    pla.setCoordinate(count, plaPts);
                    pla.setColor(count, color);
                    count++;
                }
            }
        } else {
            for (int i = 2; i < histImage.getWidth() - 2; i++) {
                for (int j = 2; j < histImage.getHeight() - 2; j++) {
                    r = histImage.getRaster().getSample(i, j, 0);
                    g = histImage.getRaster().getSample(i, j, 1);
                    b = histImage.getRaster().getSample(i, j, 2);
                    s = (r + g + b) / 3;
                    plaPts = new Point3f((medWidth - i) / 1200.0f,
                                         (medHeight - j) / 1200.0f,
                                         s / (divisior1/600.0f));
                    color = new Color3f(r / 300.0f, g / 300.0f, b / 300.0f);
                    pla.setCoordinate(count, plaPts);
                    pla.setColor(count, color);
                    count++;
                }
            }
        }


        PointAttributes a_point_just_bigger = new PointAttributes();
        a_point_just_bigger.setPointSize(4.0f);//10 pixel-wide point
        a_point_just_bigger.setPointAntialiasingEnable(true); //now points are sphere-like (not a cube)
        app.setPointAttributes(a_point_just_bigger);
        plShape = new Shape3D(pla,app);
        objRotate = new TransformGroup();
        objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        objRotate.addChild(plShape);
        lineGroup.addChild(objRotate);
        MouseRotate myMouseRotate = new MouseRotate();
        myMouseRotate.setFactor(0.015, 0.015);
        myMouseRotate.setTransformGroup(objRotate);
        myMouseRotate.setSchedulingBounds(new BoundingSphere());
        myMouseRotate.setSchedulingBounds(new BoundingSphere(
                new Point3d(0.0, 0.0, 0.0), 100));

        lineGroup.addChild(myMouseRotate);
        MouseWheelZoom mz = new MouseWheelZoom();
        mz.setFactor(0.01);
        mz.setTransformGroup(objRotate);
        mz.setSchedulingBounds(new BoundingSphere());
        lineGroup.addChild(mz);
        return lineGroup;
    }

    public static void main(String[] args) {
        PlanarImage plImg3 = JAI.create("fileload", "E:\\Data\\office\\teeth3.tiff");
        BufferedImage histImage = plImg3.getAsBufferedImage();
        JFrame frame = new JFrame();
        frame.add(new JScrollPane(new FinalDImage(histImage)));
        frame.setSize(800, 700);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:55:38+00:00Added an answer on June 12, 2026 at 7:55 pm

    it is java3D version problem. my code is ok. but i install java3d is not well for that OS’s graphics configuration.now i install other java3d with Diretecx and its works well and faster.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made Desktop App in netbeans platform in Java Swing. Now, how can i
I made an iphone app to capture image from camera and to set that
I've made this nice python app that runs when i use python main.py in
We have a Flash app (AS3). This is a desktop application that runs in
I'm using jQuery Mobile for my application that runs mainly on desktop browsers. The
A desktop app (made in Delphi) is started by User A. Let's call it
I made a very very simple small app to take screenshot of the desktop
I've made desktop app, and i want it to work also as an web
I have a Swing app written in Scala in a .jar file. I made
I know that apple made the app store to, among other things, discourage web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.