Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing objects to different methods

 
Eric Tan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As you can see that
"public static IntervalCategoryDataset createDataset()" want to get the data and attributes from storeStartDate and storeEndDate methods. i have class files, StartDate and EndDate that contains all the accessor methods. after i have store the relevant attributes, i want to call it out in the "public static IntervalCategoryDataset createDataset()" method to manipulate it.

i hope that my question doesn't confuse you all. hope that you all can guide me on this. Thank you


 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15279
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i hope that my question doesn't confuse you all. hope that you all can guide me on this. Thank you

In fact, it does confuse me, because you're not asking a question at all. So, what's your question?
 
Ådne Brunborg
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eric Tan:
As you can see that
"public static IntervalCategoryDataset createDataset()" want to get the data and attributes from storeStartDate and storeEndDate methods.


A static method wants to call non-static methods. Could be difficult.

It seems you are using "static" keyword somewhat excessive. I suggest a redesign, might clarify a few things (such as what you want to do and how to do it).

And also, your question is somewhat unclear, and you include overly much code. Makes it hard to decipher what the problem is.
[ November 29, 2006: Message edited by: �dne Brunborg ]
 
Eric Tan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
really sorry about that.

ok, let's get to the point

createDataset() method wants to generate a graph. but it needs values.
StartDate() and EndDate() is the methods to extract out the necessary values to be used in the createDataset(), surely i will need a loop. can anyone help me or guide me on the getting values with the loop into createDataset()?
 
Ådne Brunborg
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I will try to break down the problem to see if I have understood it.

You want to create a Gantt Chart. This is a graph consisting of horizontal bars, one per task, each with a start and end date. Furthermore, as "advanced options", these can have predecessors (meaning that a task cannot start until its predecessors have finished), tasks can also be grouped, and tasks can be split. However, for now, these "advanced options" will be ignored.

So, the problem is to read tasks stored in a database (which all should have an id, a start date and an end date, and a name as a minimum) and print these out in a diagram.

Have I understood the problem correctly?
 
Eric Tan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah. correct. what you said is my problem
 
Ådne Brunborg
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, here's my suggestion:

Create a GanttEntry. This class is to contain info about one entry.



Create a GanttChart class. This should contain info about the whole chart you want to create:



This should give you the Gantt chart as an Image. Note that there is no setImage medhod, as you want the image to be drawn based on your data.

You might want to draw the image every time getImage is called, or only if image == null, or redraw if ganntEntries have changed since last entry - up to you. You probably need to use some ImageWriter - I konw next to nothing about details of image manipulation in Java.



To get the data from the database, use any of a multitude of methods (SQL over JDBC, Hibernate, EJB 1.0, EJB 2.x, whatever your choice may be), but you should retrieve it as a Collection of GanntEntry objects:



And, finally, your client could be something like



And yes - I know. I can never make up my mind if Gannt is spelled Gantt or not. Maybe you could use "Gnat"
[ November 30, 2006: Message edited by: �dne Brunborg ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic