Solved

Java Image.

Posted on 2001-08-01
7
224 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 1

Expert Comment

by:lawrie
Comment Utility
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
Comment Utility
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
Comment Utility
Suggest me if anything comes new to you regarding this image processing...

Thank you very much...
0
 
LVL 1

Expert Comment

by:lawrie
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now