Simple 2d graphing in web page - where to begin

Discussion in 'Java' started by James Harris, Jan 29, 2007.

  1. James Harris

    James Harris Guest

    My Googling has let me down here - maybe because when it comes to Java
    I don't really know which type I need! If someone could point me in
    the right direction I'd appreciate it.

    My requirement is simple: to display a 2-d graph within a web page
    where the X and Y values are taken from a database (residing on the
    server hosting the web pages). The GUI is to allow panning forwards
    and backwards over time (the X values are 32-bit timestamps) and
    zooming in and out. That's about it. It would be a bonus if there were
    a time display of the cursor position as it is moved over the image.

    Java noob question: what /type/ of Java would I need? I see there are
    applets, servlets, beans and swing components... oh and Javascript
    thrown in to the equation. I don't know where to begin!

    I notice that IE warns about the security of some embedded components
    but not others. Anyone know what makes the difference?

    Is there any existing code that will do the 2-d graphing, as above,
    that I could modify? Is there an existing package that will do all of
    what I want? It seems a pretty basic requirement.

    Lastly, and thanks for staying with me, could you recommend any books
    that would provide suitable source code - e.g. a Java or Javascript
    cookbook?


    --
    TIA,
    James
     
    James Harris, Jan 29, 2007
    #1
    1. Advertising

  2. James Harris

    Daniel Pitts Guest

    On Jan 28, 5:14 pm, "James Harris" <>
    wrote:
    > My Googling has let me down here - maybe because when it comes to Java
    > I don't really know which type I need! If someone could point me in
    > the right direction I'd appreciate it.
    >
    > My requirement is simple: to display a 2-d graph within a web page
    > where the X and Y values are taken from a database (residing on the
    > server hosting the web pages). The GUI is to allow panning forwards
    > and backwards over time (the X values are 32-bit timestamps) and
    > zooming in and out. That's about it. It would be a bonus if there were
    > a time display of the cursor position as it is moved over the image.
    >
    > Java noob question: what /type/ of Java would I need? I see there are
    > applets, servlets, beans and swing components... oh and Javascript
    > thrown in to the equation. I don't know where to begin!
    >
    > I notice that IE warns about the security of some embedded components
    > but not others. Anyone know what makes the difference?
    >
    > Is there any existing code that will do the 2-d graphing, as above,
    > that I could modify? Is there an existing package that will do all of
    > what I want? It seems a pretty basic requirement.
    >
    > Lastly, and thanks for staying with me, could you recommend any books
    > that would provide suitable source code - e.g. a Java or Javascript
    > cookbook?
    >
    > --
    > TIA,
    > James


    This really sounds like a good place for a multi-tier solution. You
    would have a server or servlet application that access the database,
    and a client side application (maybe using Applet or Java Web Start)
    that renders the graphs.

    It might actually be better to make the front-end a Flash file if you
    are more concerned with "pretty rendering" than business logic on the
    front end. If the display were more static, you might consider using
    a servlet to render it server side, and not worry about client-side
    applications.

    There are really a lot of options for this. I personally would
    probably start with a pure servlet/jsp implementation, which rendered
    an html page and a PNG image using java imageio. Mostly because thats
    what I already know.

    Hope this helps,
    Daniel
     
    Daniel Pitts, Jan 29, 2007
    #2
    1. Advertising

  3. James Harris

    -Lost Guest

    "James Harris" <> wrote in message
    news:...

    > My requirement is simple: to display a 2-d graph within a web page
    > where the X and Y values are taken from a database (residing on the
    > server hosting the web pages). The GUI is to allow panning forwards
    > and backwards over time (the X values are 32-bit timestamps) and
    > zooming in and out. That's about it. It would be a bonus if there were
    > a time display of the cursor position as it is moved over the image.
    >
    > Java noob question: what /type/ of Java would I need? I see there are
    > applets, servlets, beans and swing components... oh and Javascript
    > thrown in to the equation. I don't know where to begin!


    Well, I believe either approach is theoretically possible. I know firsthand I have seen
    applets (class files) performing that type of thing here:

    http://www.analyzemath.com/Calculators.html

    As such, rather than begin learning a slew of DHTML, I would recommend you take this
    question to:

    comp.lang.java

    Also, avoid multiposting. It is lazy (and rude?) and people would respond to you thusly

    > I notice that IE warns about the security of some embedded components
    > but not others. Anyone know what makes the difference?


    After updating to SP2 in Windows XP I get the:

    "Internet Explorer has restricted this file from showing active content that could access
    your computer."

    ....whether I am running a JavaScript, a VBScript, ActiveX, or Java applet.

    > Is there any existing code that will do the 2-d graphing, as above,
    > that I could modify? Is there an existing package that will do all of
    > what I want? It seems a pretty basic requirement.


    If there is, Google would surely find it for you.

    > Lastly, and thanks for staying with me, could you recommend any books
    > that would provide suitable source code - e.g. a Java or Javascript
    > cookbook?



    http://www.oreillynet.com/pub/au/156

    David Flanagan's "JavaScript: The Definitive Guide 5th Edition" seems to be the wisest
    choice. Had I the money this is the book I would upgrade my 3rd Edition to.

    Hope this helps a bit.

    -Lost
     
    -Lost, Jan 29, 2007
    #3
  4. James Harris

    James Harris Guest

    On 29 Jan, 01:36, "Daniel Pitts" <> wrote:
    ....
    > JamesThis really sounds like a good place for a multi-tier solution. You
    > would have a server or servlet application that access the database,
    > and a client side application (maybe using Applet or Java Web Start)
    > that renders the graphs.


    I guess keeping the database with the web server would allow just two
    tiers and thus keep it simpler. My overriding goal at the mo! I can
    add features later. Never heard of Java Web Start but it sounds
    promising.

    > It might actually be better to make the front-end a Flash file if you
    > are more concerned with "pretty rendering" than business logic on the
    > front end. If the display were more static, you might consider using
    > a servlet to render it server side, and not worry about client-side
    > applications.


    All I need is a rectangle and some ways to influence what the
    rectangle displays. The simpler the better.

    > There are really a lot of options for this. I personally would
    > probably start with a pure servlet/jsp implementation, which rendered
    > an html page and a PNG image using java imageio. Mostly because thats
    > what I already know.


    Wow! JSP is another option, then? I guess there are just too many
    options. When I wrote some stuff in Java years ago I spent most of the
    time looking for and learning how to work with what other people had
    written than writing code myself. I guess that's even more the need
    now!
     
    James Harris, Jan 29, 2007
    #4
  5. James Harris wrote:
    > My Googling has let me down here - maybe because when it comes to Java
    > I don't really know which type I need! If someone could point me in
    > the right direction I'd appreciate it.
    >
    > My requirement is simple: to display a 2-d graph within a web page
    > where the X and Y values are taken from a database (residing on the
    > server hosting the web pages). The GUI is to allow panning forwards
    > and backwards over time (the X values are 32-bit timestamps) and
    > zooming in and out. That's about it. It would be a bonus if there were
    > a time display of the cursor position as it is moved over the image.
    >
    > Java noob question: what /type/ of Java would I need? I see there are
    > applets, servlets, beans and swing components... oh and Javascript
    > thrown in to the equation. I don't know where to begin!
    >
    > I notice that IE warns about the security of some embedded components
    > but not others. Anyone know what makes the difference?
    >
    > Is there any existing code that will do the 2-d graphing, as above,
    > that I could modify? Is there an existing package that will do all of
    > what I want? It seems a pretty basic requirement.


    If you want to use Java, then I would suggest:
    * JSP page with IMG tag that refers to a servlet
    * the servlet gets the data from the database and
    outputs the graphics (I can recommend JFreeChart
    for the purpose)

    Arne
     
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=, Jan 29, 2007
    #5
  6. James Harris wrote:
    > I guess keeping the database with the web server would allow just two
    > tiers and thus keep it simpler.


    Most people would still call it 3 tier, because
    it could potentially be on 3 boxes.

    Arne
     
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=, Jan 29, 2007
    #6
  7. James Harris

    Lew Guest

    Arne Vajhøj wrote:
    > If you want to use Java, then I would suggest:
    > * JSP page with IMG tag that refers to a servlet
    > * the servlet gets the data from the database and
    > outputs the graphics (I can recommend JFreeChart
    > for the purpose)


    To elaborate on that excellent suggestion:

    A servlet that simply streams the bytes out from an image to the response
    OutputStream can act as a URL for <image src="" ...>. For more better finer
    you add mime type headers, etc., to the servlet's output.

    After perusing <http://www.jfree.org/jfreechart/index.html> I see that
    JFreeChart has done this for us.

    -Lew
     
    Lew, Jan 29, 2007
    #7
  8. On Jan 29, 1:00 pm, "James Harris" <>
    wrote:
    > On 29 Jan, 01:36, "Daniel Pitts" <> wrote:
    > ...
    >
    > > JamesThis really sounds like a good place for a multi-tier solution. You
    > > would have a server or servlet application that access the database,
    > > and a client side application (maybe using Applet or Java Web Start)
    > > that renders the graphs.

    ...
    > I guess keeping the database with the web server would allow just two
    > tiers and thus keep it simpler. My overriding goal at the mo! I can
    > add features later. Never heard of Java Web Start but it sounds
    > promising.


    Arne and Lew pointed out the path of JFreeChart and
    servlets to produce a web-application that does what
    you need, without *any* plug-ins on the client side.

    Another path to take is JFreeChart combined with either
    applets or a web-start applet/application, as mentioned
    by Daniel.

    Of the two (web page applet/web-start app.), you will have
    far fewer problems with the latter.

    The first route requires a Java enabled site, whereas
    the second requires the end-user to have a suitbale
    Java Plug-In installed.

    For some examples of web-start, see..
    <http://www.physci.org/jws/>

    HTH

    Andrew T.
     
    Andrew Thompson, Jan 29, 2007
    #8
  9. James Harris

    James Harris Guest

    On 29 Jan, 06:07, "Andrew Thompson" <> wrote:
    ....
    > Arne and Lew pointed out the path of JFreeChart and
    > servlets to produce a web-application that does what
    > you need, without *any* plug-ins on the client side.
    >
    > Another path to take is JFreeChart combined with either
    > applets or a web-start applet/application, as mentioned
    > by Daniel.


    JFreeChart looks good, even at the price(!)

    > Of the two (web page applet/web-start app.), you will have
    > far fewer problems with the latter.


    Would there need to be something running on the client to report to
    the user the X-value of the mouse pointer. Would that need an applet
    or would that be a Javascript function... or would either do? Still
    confused... can you tell? I now understand there is no connection
    between Java and Javascript (other than a heritage from C) so maybe
    either would do.

    In my mind there would be an Applet running on the PC (within the
    browser) using JDBC to read the database on the webserver. It would
    connect under a userid that had read-rights only. If I have to write a
    server component also (a servlet?) doesn't that make things more
    complex rather than simpler?

    > The first route requires a Java enabled site, whereas
    > the second requires the end-user to have a suitbale
    > Java Plug-In installed.


    I thought there was a JVM (is this the same as the Java plug-in you
    mention) included with IE, Firefox etc? Or is it that each browser
    will interpret Javascript? I'm honestly finding it difficult to work
    out how these things hang together so bear with me, and many thanks
    for the help.
     
    James Harris, Jan 29, 2007
    #9
  10. Andrew Thompson wrote:
    > Arne and Lew pointed out the path of JFreeChart and
    > servlets to produce a web-application that does what
    > you need, without *any* plug-ins on the client side.
    >
    > Another path to take is JFreeChart combined with either
    > applets or a web-start applet/application, as mentioned
    > by Daniel.
    >
    > Of the two (web page applet/web-start app.), you will have
    > far fewer problems with the latter.
    >
    > The first route requires a Java enabled site, whereas
    > the second requires the end-user to have a suitbale
    > Java Plug-In installed.


    I do not quite understand why you think it is less problematic
    ti have all users install a java plugin than setting up a
    servlet engine.

    The server side solution is under your control. The client
    side solution is easy to get 80% or 90% maybe even 95%, but
    then it can become very problematic. It is not fun to act
    as helpdesk on peoples various PC problems to get Java
    working.

    Arne
     
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=, Jan 30, 2007
    #10
  11. On Jan 30, 1:37 pm, Arne Vajhøj <> wrote:
    > Andrew Thompson wrote:
    > > Arne and Lew pointed out the path of JFreeChart and
    > > servlets to produce a web-application that does what
    > > you need, without *any* plug-ins on the client side.

    >
    > > Another path to take is JFreeChart combined with either
    > > applets or a web-start applet/application, as mentioned
    > > by Daniel.

    >
    > > Of the two (web page applet/web-start app.), you will have
    > > far fewer problems with the latter.

    >
    > > The first route requires a Java enabled site, whereas
    > > the second requires the end-user to have a suitbale
    > > Java Plug-In installed.

    >
    > I do not quite understand why you think it is less problematic
    > ti have all users install a java plugin than setting up a
    > servlet engine.


    I don't. After rereading my words, I can see I was
    not very clear.

    The 'servlet engine' feeding raw HTML and images
    would be easiest in terms of maintenance. Since
    it only requires the user to have an 'image enabled'
    browser, it should be 'low support'.

    If the OP folows the path of supplying a Java
    applet or JWS based applet/application, the
    easier deployment option is web-start.

    Note though, that after reading the OP's latest
    response, it seems he is thinking of a more
    'active' experience on the user side than can
    be delivered with pure HTML and images, and
    might need to use JS to achieve the effects
    required.

    As soon as 'JS' enters the picture, I think that
    makes the maintenance (for the end user) to be
    higher again, and I would tend to prefer the JWS
    option.

    Andrew T.
     
    Andrew Thompson, Jan 30, 2007
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kylin
    Replies:
    1
    Views:
    397
  2. k0mp
    Replies:
    7
    Views:
    272
  3. Ashish\\

    interactive graphing web controls

    Ashish\\, Feb 14, 2004, in forum: ASP .Net Web Controls
    Replies:
    5
    Views:
    183
    Work'a'holic
    Jul 15, 2004
  4. Bill Atkins

    Simple Graphing Library

    Bill Atkins, Jan 7, 2005, in forum: Ruby
    Replies:
    8
    Views:
    122
    Austin Ziegler
    Jan 9, 2005
  5. James Harris
    Replies:
    7
    Views:
    89
    James Harris
    Jan 29, 2007
Loading...

Share This Page