• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

graph plotting

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm new here and impressed from your forum. I'm quite new in Java and i need some help regarding the Frame and Graphics classes in java.

I have written 3 classes (function, parabola and polynomial), which represent functions with a variable . I want to extend my function class with a method named public void plot(double xmin, double xmax), which opens a frame with the graph of determined function. the parameter xmin and xmax give the x-area, where the graph should be drawn. A labeld coordinate axis must also appear in the frame. Can you help me?

Here are my classes :





 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some useful FAQ links that may have some bearing on your post:

ShowSomeEffort
DoYourOwnHomework
BeForthrightWhenCrossPostingToOtherSites
the last refers to this link and possibly others: graph-plotting.html

and the general FAQ: HowToAskQuestionsOnJavaRanch

Hope this helps.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The PlotTest and PlotSineCurve examples in the CodeBarn may provide some inspiration: http://faq.javaranch.com/java/CodeBarnIntermediateJava
 
Sirine Sirin
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i thought this forum is to help beginners I can find myself such codes on internet, it's not difficult Anyway, thanks for your help. I think, your view about helping is only showing the existing codes which are actually not concerned with my questions.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i thought this forum is to help beginners


It is. But that does not include going through 200+ lines of code, and trying to figure out how they might be adapted to what you're asking. That's simply too much to ask for. You'll have better success if you describe what thoughts you have had on the problem, and where exactly you're stuck implementing those.

The examples codes mentioned above do much of what you're asking. Have you looked at them, and thought about how they might be adapted to your case?
 
Sirine Sirin
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:

i thought this forum is to help beginners


It is. But that does not include going through 200+ lines of code, and trying to figure out how they might be adapted to what you're asking. That's simply too much to ask for. You'll have better success if you describe what thoughts you have had on the problem, and where exactly you're stuck implementing those.

The examples codes mentioned above do much of what you're asking. Have you looked at them, and thought about how they might be adapted to your case?



if i had known how it's working, i hadn't asked for it here. I don't figure out, how i can fit the example code to plot(double xmin, double xmax). That's my problem.
 
Sirine Sirin
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a short explanation : my name is Sirine (means sweety, in turkish) and my surname is sirin (means sweet, also in turkish)

My parents gave me this name cos they found me too sweety. But sirine is a quite normally turkish name I don't know why my name violates the naming policies

and concerning my problem i would like to ask some further questions.

How can i read the x-values from the function class (with the map-methode) in the plot-method?
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sirine Sirin wrote:a short explanation : my name is Sirine (means sweety, in turkish) and my surname is sirin (means sweet, also in turkish)

My parents gave me this name cos they found me too sweety. But sirine is a quite normally turkish name I don't know why my name violates the naming policies


As I told you per PM, it just looked so very suspicious. But it's all resolved now.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sirine Sirin wrote:How can i read the x-values from the function class (with the map-methode) in the plot-method?



The x values are generally the independent variables, from which the y values are calculated. So you don't read the x values, you generate them. So you might do something like:


You may have to put some thought into what range of x values you want to plot.
reply
    Bookmark Topic Watch Topic
  • New Topic