Results 1 to 16 of 16
 04032012, 05:26 PM #1
scaling of negative values in graph
hi,
my project submission date is tomorrow, so please reply as soon as possible (thanks for reading this line)
I've drawn the graph, and I've given a scrollbar for xaxis values.
this is because, I know how many xvalues are there, so I've set the graph resolution to the number of xvalues.
now my yvalue need to be scaled
my yvalue maximum value is 0.05299999999917244 and minimum value is 2.147483647E9 (obtained using print statement inside my coding)
How do I scale them?
(without scaling, my graph doesn't show accurate all the time)
I tried this scaling:
Java Code:private double getMax() { double max = Integer.MAX_VALUE; for(int i = 0; i < this.yArray.length; i++) { if(this.fftofyArray[i] > max) max = this.fftofyArray[i]; } return (max); }
Java Code:final int PAD=30; int h = getHeight(); double scale = (double)(h  2*PAD)/getMax();
Java Code:for(int i = 1; i < this.yArray.length1; i++) { double x1 = PAD + i; double y1 = h  PAD  scale*((this.fftofyArray[i])); double x2 = PAD + (i+1); double y2 = h  PAD  scale*((this.fftofyArray[i+1])); g2.draw(new Line2D.Double(x1, y1, x2, y2)); }
xvalues are working fine, but yvalues negative values are hidden in the graph
Could you suggest me a different scaling for showing negative values
Edited to add: fftofyArray[] consists of the yvalues
regards
dhilipLast edited by noobplus; 04032012 at 05:30 PM.
 04032012, 06:06 PM #2
Re: scaling of negative values in graph
How do I scale them?
Then use division and addition to map from one range into the other.
lowest in one to 0 in the other, max in one to max in the other.If you don't understand my response, don't ignore it, ask a question.
 04032012, 06:12 PM #3
Re: scaling of negative values in graph
thanks, and is it possible to add a tooltip to the graph, so it makes easy for me..
I'm using paintComponent() of JPanel to draw the graph. Could we add a tooltip to each point on the graph?
edited to add: I mean, I've 63,375 values, so difficult to plot on paper , that's what, thanks
regards
dhilipLast edited by noobplus; 04032012 at 06:16 PM.
 04032012, 06:21 PM #4
Re: scaling of negative values in graph
hi,
but I know my maximum and minimum values . maximum value is 0.05299999999917244 and minimum value is 2.147483647E9. I got it by using getMax() and getMin() methods.
regards
dhilip
 04032012, 06:22 PM #5
Re: scaling of negative values in graph
What have you tried to do with the JToolTip class?
If you don't understand my response, don't ignore it, ask a question.
 04032012, 06:26 PM #6
Re: scaling of negative values in graph
 04032012, 07:00 PM #7
Re: scaling of negative values in graph
Have you tried it?
If you don't understand my response, don't ignore it, ask a question.
 04032012, 07:09 PM #8
Re: scaling of negative values in graph
yep, I tried..
Java Code:for(int i = 1; i < this.yArray.length1; i++) { double x1 = PAD + i/**xInc*/; double y1 = PAD + 500*((this.fftofyArray[i])); double x2 = PAD + (i+1)/**xInc*/; double y2 = PAD + 500*((this.fftofyArray[i+1])); g2.draw(new Line2D.Double(x1, 9*y1, x2, 9*y2)); setToolTipText(Double.toString(this.fftofyArray[i])); }ToolTipManager.sharedInstance().registerComponent( this); ToolTipManager.sharedInstance().setInitialDelay(0) ;
but the tooltip i got in output is only the final yvalue as a tooltip everywhere
I need some way to know, which point on the graph has what value
regards
dhilip
 04032012, 07:14 PM #9
Re: scaling of negative values in graph
The call to a method in a loop will continually replace the last value with the current value. At the end of the loop only the last value will be there. The other, earlier values will all have been replaced.
Does the tooltip class have a way to get the mouse click location and set the text based on that?If you don't understand my response, don't ignore it, ask a question.
 04032012, 07:18 PM #10
Re: scaling of negative values in graph
 04032012, 07:21 PM #11
Re: scaling of negative values in graph
Then you may have to use a mouse listener and draw your own label at the mouse click location.
If you don't understand my response, don't ignore it, ask a question.
 04032012, 07:24 PM #12
Re: scaling of negative values in graph
 04032012, 07:28 PM #13
Re: scaling of negative values in graph
a way to scale the graphIf you don't understand my response, don't ignore it, ask a question.
 04032012, 07:46 PM #14
Re: scaling of negative values in graph
hi,
i've calculated the maximum value of positive values, and minimum of negative value, and added the modulus of two values, and got a new maxvalue..
Java Code:private double getMax() { double max = Integer.MAX_VALUE; for(int i = 0; i < this.yArray.length; i++) { if(this.fftofyArray[i] > max) max = this.fftofyArray[i]; } double min=Integer.MAX_VALUE; for(int i = 0; i < this.yArray.length; i++) { if(this.fftofyArray[i] < min) min = this.fftofyArray[i]; } return (maxmin); }
Java Code:double scale = (double)(h  2*PAD)/getMax();//int h = getHeight();//h is the height of the graph, and PAD is initialized to 20 for bordering
Java Code:double y1 = hPAD  scale*((this.fftofyArray[i]));
Java Code:double y2 = hPAD  scale*((this.fftofyArray[i+1]));
I don't get negative values yet on the graph, Could you tell me what's wrong with my scaling
regards
dhilip
 04032012, 07:51 PM #15
Re: scaling of negative values in graph
An example:
data range: 1000 to 1000 (2000 items)
graph range: 0 to 99 (100 items)
Plot 1000 at 0 (1000  (1000) = 0)
plot 1000 at 99
plot 0 at 50If you don't understand my response, don't ignore it, ask a question.
 04072012, 06:37 AM #16
Re: scaling of negative values in graph
Similar Threads

Double with no negative values.
By vahini in forum New To JavaReplies: 11Last Post: 05052011, 09:07 AM 
Help with Polynomial Graph Plotter and its scaling
By sojharo in forum Java 2DReplies: 0Last Post: 01232011, 10:14 PM 
Negative one for illegal/default values
By diablo84 in forum New To JavaReplies: 1Last Post: 08082010, 07:58 PM 
scaling image
By OmerHalit in forum Advanced JavaReplies: 3Last Post: 05072010, 01:30 AM 
scaling images
By willemjav in forum Java AppletsReplies: 7Last Post: 06192008, 09:54 AM
Bookmarks