The Artima Developer Community
Sponsored Link

Java Answers Forum
Plotting an array of points, saving to file

9 replies on 1 page. Most recent reply: Aug 19, 2005 11:50 PM by Thomas SMETS

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 9 replies on 1 page
Michael Schwarz

Posts: 2
Nickname: coffeeboy
Registered: Aug, 2005

Plotting an array of points, saving to file Posted: Aug 2, 2005 8:29 AM
Reply to this message Reply
Advertisement
First off, let me apologize up-front about asking folks to "do my homework."

I've been programming for nearly 20 years, but the one completely closed book to me is graphics. I've been doing MIS or systems work my whole career and I simply haven't had to deal with it at any level beyond using GUI app frameworks.

I've got a task of synchronizing a palmOS application to a business system. I'm using jSyncManager and I've got everythink working except for one thing:

The PalmOS app has something called an "INK control." This comes down to me as (I'm simplifying to the essentials here):

height
width
point array size
point[]

Where the array is a list of "X,Y" coordinates that are to be rendered black (this is a two-color, black & white control meant mainly to capture signatures).

So I have a sparse array of points, and the height and width of the whole image.

I am *completely* ignorant of Java's 2D graphics features, and I'm looking for a quick nudge as to the shape (which classes and their relationship) I would have to use to get this working in a server context. I want to convert that input information into some sort of file on disk. Probably PNG, but any format appropriate to such high-contrast information that is reasonably compressed would do. I don't want to use something as wasteful of space as a BMP, although I would if I have to.

Any help would be appreciated.


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Plotting an array of points, saving to file Posted: Aug 3, 2005 6:47 AM
Reply to this message Reply
That's some advanced stuff man...

Anyways, for the image conversion what you're looking
for is the ava Advanced Imaging (JAI) API.

Examples of usage:

http://java.sun.com/developer/technicalArticles/Media/AdvancedImage/

For the Graphical conversion stuff I would suggest you

have a draw method in a Class that extends a JPanel
include a draw and paint method (I've used this before
for bar graphs), from there on its algorithmic.

Good luck.

Michael Schwarz

Posts: 2
Nickname: coffeeboy
Registered: Aug, 2005

Re: Plotting an array of points, saving to file Posted: Aug 3, 2005 7:17 AM
Reply to this message Reply
Thanks for the info. I will check it out. But bringing the whole of the GUI framework into a server daemon program seems like massive overkill for my problem to me. I will persue this because this is the only hint I have so far, but if I were willing to "shell out" to something like GNUplot, this would be a breeze. I'm really surprised that there isn't a simpler library for this...

Sorry, I'm not minimizing your help! It is very much appreciated. But if anyone else out there knows of a much smaller scale solution, please let me know!

Slager .

Posts: 16
Nickname: slager
Registered: May, 2003

Re: Plotting an array of points, saving to file Posted: Aug 3, 2005 2:34 PM
Reply to this message Reply
If you use java 1.4 or above it should not be too much of a problem I think? Maybe you can use BufferedImage to create an image and fill it via setRGB.
Then you can save the image easily via ImageIO. Something like ImageIO.write(image, "png", targetFile);

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: Plotting an array of points, saving to file Posted: Aug 16, 2005 5:51 AM
Reply to this message Reply
I am currently reviewing the possibility to draw graphs (for my current employer) with open libraries jFreeChart (see http://www.javaworld.com) or with jCharts look on the Forge.

JAI is of course the improved brincks that can be used to build nice and beautyfull graphics...

\T,

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Plotting an array of points, saving to file Posted: Aug 16, 2005 6:19 AM
Reply to this message Reply
Personal preferance, I have my own prewritten libraries in which you pass in stuff like:


graph(my_color, MyPanel, x, y, width height)


and it simply slaps the given graph on the appropriate JPanel with the given color.

I think that JAI stuff is way too complicated, if one were
to take the time to bother to write his/her own library,
it would make it much easier on his work, the only time
I would delve into looking at the JAI library is if I'm
in serious need to capture the image in a particular
format e.g. jpeg, other than that, unless you're doing
some advanced level stuff, I don't see why not take the
time to create something that in future will save you
time (who better to understand code than the author
himself)?

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: Plotting an array of points, saving to file Posted: Aug 16, 2005 11:44 AM
Reply to this message Reply
A few converteers from java.awt.Graphic to PNG, JPEG, ... are available in the servlet.jar ;)


\T,

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Plotting an array of points, saving to file Posted: Aug 16, 2005 11:34 PM
Reply to this message Reply
> A few converteers from java.awt.Graphic to PNG, JPEG, ...
> are available in the servlet.jar ;)
>
>
> \T,

Tx. That should make life easier. I'll work on
expanding my library with those.

probably include a capture_image.Format;

class.

Tx

wahyu komara

Posts: 1
Nickname: komara
Registered: Aug, 2005

need help Posted: Aug 19, 2005 3:26 PM
Reply to this message Reply
does any one have a java SWING source code which connect to Oracle 9, if any one had please send it to this email or pangulah@yahoo.com

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: need help Posted: Aug 19, 2005 11:50 PM
Reply to this message Reply
Swing and Oracle are like earth and air...
You can mix them but they have nothing to do toghether per se.
Now if you really are that lazy ... to not even hit google try : http://squirrel-sql.sourceforge.net

\T,

Flat View: This topic has 9 replies on 1 page
Topic: how to use jtapi Previous Topic   Next Topic Topic: Everyone, this is the real question. Pls help.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use