Solved

Java Image.

Posted on 2001-08-01
7
226 Views
Last Modified: 2012-06-27
I am generating technical charts for stocks. Here i need to draw weekly, monthly and yearly graphs. I am taking different width and height for each of graph because of easy calculation and also i am restricted to take widht and height as integers.

Later, i am trying to make each of graph of in same size, using Image.getScaledInstance(widht,height,hints). But i am not getting proper visible results. If i take SCALE_SMOOTH as hints, its very slow in perforamance, also not satisyfing result.

Can any one guide me what to do, for getting clear, equal size, graphs?

0
Comment
Question by:vinaykn
  • 3
  • 3
7 Comments
 
LVL 1

Accepted Solution

by:
lawrie earned 50 total points
ID: 6341431
Hello

It would sound to me that you have 3 choices

1) Draw all of the graphs the correct size initially, by making them resizable and accept the slightly more difficult calculations for drawing them (The best option in my opinion, because you could make them completely resizable in the process)

2) Accept the not so good native scaling in Java as you mention above.

3) Run it through some other image processing library to do the resize. This will use up more processing time though .. always a trade off between procedssing time and quality.

Hope this helps
0
 

Author Comment

by:vinaykn
ID: 6342949
Thanks for responding.

The second choice is not applicable in this case.

So first one, I am ready to for any kinda difficult calculation. But here i found, its not allowing me as its allowing only integers for height and widht. I need every decimal value for my graph. I found i am restricted to take height and widht in integers as it represents number of pixels..I will try to explain..

On x-axis i need to take 300 values, can i put 100 as widhth? How can i represent 3 values per one pixel???

If its the third choice, can you suggest me any oher image processing library?  I am new to this.

Keep writing..
0
 
LVL 3

Expert Comment

by:Sendoh
ID: 6343340
hi !!
think u can try out the AWT default strecth abilities by call graphics.drawImage() with x,y,width,height...

hope this helps...:)

regards
Sendoh
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 1

Expert Comment

by:lawrie
ID: 6346128
Hello

I still think Option 1 is the best .. it would be better for you to decide how to display 3 values on one pixel, than trusting to an image compression algorithm, which would almost certainly create a blurry inaccurate image.

It takes a bit of though, but once working will be worth it. When I have been faced with this kind of data / size problem, I take a look at what I want to display. If the peaks are important, choose the biggest of the three overlapping points and show that, or you could go for the smallest of the 3, average, mean etc. It will depend on your data, but if you create a scaling algorithm that you like for your data, you should be able to reuse it, and that will make it easier to display

Something like:

public double[] convertData(double[] input, requiredPoints);

where the size of the result array will be what you specified, and the data is compressed / expanded based on what you decided above.

Hope this helps
0
 

Author Comment

by:vinaykn
ID: 6347148
Thanks lawrie

I need to represent each and every value. I think i need to take it should have its own pixel to represent so my picture width will be depending on its nuber of values.

yeah, when i compress its giving blurry inaccurate picture. So what to do get images of same size everytime?

I have gone through finance.yahoo.com.  There he is getting images of same size all the time.  I dont know what kinda image processing he is doing??

Can you suggest anything more?

0
 

Author Comment

by:vinaykn
ID: 6362816
Suggest me if anything comes new to you regarding this image processing...

Thank you very much...
0
 
LVL 1

Expert Comment

by:lawrie
ID: 6373581
perhaps check out the Java2D imaging techniques on the following page:
http://java.sun.com/products/java-media/2D/samples/suite/index.html

This includes more advanced scaling algorithms

0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how do i compare an object based on two fields 6 53
jar file executable 12 51
Oracle SQL syntax check  without executing 6 50
servlet example issue 6 38
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to implement Singleton Design Pattern in Java.

806 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question