Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Java Graph

Name: OP 2012-11-16 10:10

I'm trying to make a graph to put into a JPanel or JFrame, but my coordinates are huge. The range on my x-axis are 0 - 1024 and the y axis range is 0 - 300.
I plotted it using a polyline, but that was a fucking disaster. How do you graph coordinates and then modify the graph to keep the points relative (so I could have a graph that's 500px X 500px that has 1024 points)?

Name: Anonymous 2012-11-16 10:32

Graph

Name: Anonymous 2012-11-16 11:45

That isn't huge at all.
Anyway, just scale it down.

Name: Anonymous 2012-11-16 15:35

x = x / 1024.0 * 500.0
y = y / 300.00 * 500.0
path.add(x,y)

Name: OP 2012-11-16 15:56

It's huge if each x value is taking up a pixel.
Won't scaling down either ignore values or cause redundant points?

Name: Anonymous 2012-11-16 16:14

>>5
Then make it not take up a pixel. Or use the magic powers that come with your computer and let the user zoom in and out

Name: OP 2012-11-16 21:18

>>6
I'm developing it as a part of a UI for a spectophotometry graph. It's for a job, so I don't get to just say "oh, just zoom in or out". Besides, it's in a JFrame, you'd have to have some OS utility to do that, and it would be a hassle.

How do I make it not take up a pixel?

I ended up dividing the values in half, but I think that might have been a bad idea.

>>4
I tried this to no avail. It made plateaux in the graph and made the graph look blocky.

Name: Anonymous 2012-11-17 0:15

You know, racket is a decent programming environment with professional plots, such as those in http://docs.racket-lang.org/plot/renderer2d.html

Name: Anonymous 2012-11-17 0:46

This is trivial in Javascript.

Name: Anonymous 2012-11-17 0:47

>>7
If doing integer arithmetic, put the multiplications first.
Or just switch to float literals!

Name: Anonymous 2012-11-17 0:57

Jews

Don't change these.
Name: Email:
Entire Thread Thread List