Windows GDI vs. Java Graphics

This is a discussion on Windows GDI vs. Java Graphics within the Windows Programming forums, part of the Platform Specific Boards category; I never thought I'd be posting in this board, but... I'm going to be writing some custom software (targeted for ...

  1. #1
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640

    Windows GDI vs. Java Graphics

    I never thought I'd be posting in this board, but...

    I'm going to be writing some custom software (targeted for windows) which, among other things, needs to display graphs of large data-sets. My preference would be to write this in Java since it would be very quick and easy, however it's looking like some other parts of the app might need to be written in C or C++. This leaves me with two choices:

    • Write the app in Java and integrate the C++ parts with JNI.
    • Write the whole app in C++.


    I'm leaning towards the first option, but I have some beefs with it that I won't bother explaining (not really relevent to the question).

    My beef with number 2 brings me to the question in this thread. I know I can build everything very easily in Java, I'm not so sure about using GDI. I don't want to depend on uncommon libs like SDL or Allegro, and I don't want to the software to require things like OpenGL or DX. Thus leaves windows GDI.

    Anyone have opinions on GDI for rendering something like a scrollable graph of a large dataset? Anyone have experience with both GDI and Java Graphics care to contrast the two?


    (by graph here, i mean a 2D, x vs. y plot of data. By large i mean too big to render all at once, but small enough to fit into memory)

    I also need to ability to have interactions with the graph, such as marking points, retreiving data from mouse clicks, etc...

  2. #2
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,262
    It's possible, but quite awkward vs Java. I mean, with GDI you'd have to come up with all the bar drawing stuff yourself whereas in Java it's pretty much waiting to be declared. GDI+ gives you the option of some effects too but still it's a bit of an undertaking.

    If you're more comfortable with Java, use it. Doing the JNI stuff shows that you're dead clever and can make different languages work together.

  3. #3
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    well, if you intend to display the entire graph in the window at once, you can just generate a BMP in memory then use StretchBlit to paint it to the DC. if the graph will be larger than the window, just create a window with scroll bar properties, then use BitBlit to render the image. Or you could just use the GDI drawing functions for makign the lines and points, btu I never realy bothered with those so I dont know how they perform.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  4. #4
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Generating a BMP would make interacting with the graph awkward. I'm leaning even more to the Java side. Thanks for the replies.

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    A company I had an internship at used Java as the frontend for a C++ simulation program. They had the interesting experience that JNI turned out to be slower than writing two separate programs that communicate through pipes.
    Just saying - you might want to hold the option open and profile the two.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  6. #6
    Registered User pronecracker's Avatar
    Join Date
    Oct 2006
    Location
    netherlands
    Posts
    158
    Quote Originally Posted by abachler View Post
    well, if you intend to display the entire graph in the window at once, you can just generate a BMP in memory then use StretchBlit to paint it to the DC. if the graph will be larger than the window, just create a window with scroll bar properties, then use BitBlit to render the image. Or you could just use the GDI drawing functions for makign the lines and points, btu I never realy bothered with those so I dont know how they perform.
    • It's BitBlt and StretchBlt, not "Blit" ;P
    • Generating a bitmap of something complex and then stretching it will give you dreadful results. But this doesn't mean that GDI is crap and does not have an appropriate way to do this.

      What you can do is create a metafile. This is just as easy as creating a bitmap to draw on, but it stores not pixels but vector graphics (the drawing commands). You can then draw it to your window using any dimensions, Windows will just execute the drawing commands you compiled. I'm quite sure Java doesn't have such a functionality.

  7. #7
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    whether the BMP is simple or complex is irrelevant, but stretchblt does technically run a bit slower than bitblt. Then again if your rendering thread is the cpu hog in your app I assume you would switch to DirectX
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  8. #8
    Registered User pronecracker's Avatar
    Join Date
    Oct 2006
    Location
    netherlands
    Posts
    158
    Quote Originally Posted by abachler View Post
    whether the BMP is simple or complex is irrelevant, but stretchblt does technically run a bit slower than bitblt.
    Was that a reply to my statement? What do you mean by that? I guess you don't get my point at all.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Windows GDI graphics - help pls!
    By Gamemaniac in forum Game Programming
    Replies: 1
    Last Post: 02-23-2005, 12:26 PM
  2. brought over from the c++ board... windows graphics help.
    By uvacow in forum Windows Programming
    Replies: 1
    Last Post: 08-11-2003, 07:02 PM
  3. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  4. Graphics in a window in windows
    By Korn1699 in forum C++ Programming
    Replies: 2
    Last Post: 06-16-2002, 12:59 AM
  5. Windows Graphics
    By Neandrake in forum Windows Programming
    Replies: 3
    Last Post: 01-16-2002, 04:25 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21