Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Java Image.

Posted on 2001-08-01
7
Medium Priority
?
250 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 200 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

926 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