aspose file tools*
The moose likes Java in General and the fly likes Passing objects to different methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Passing objects to different methods" Watch "Passing objects to different methods" New topic
Author

Passing objects to different methods

Eric Tan
Ranch Hand

Joined: Oct 11, 2006
Posts: 72
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

Joined: Aug 16, 2005
Posts: 14345
    
  22

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?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Ådne Brunborg
Ranch Hand

Joined: Aug 05, 2005
Posts: 208
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 ]

Entia non sunt multiplicanda praeter necessitatem
Eric Tan
Ranch Hand

Joined: Oct 11, 2006
Posts: 72
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

Joined: Aug 05, 2005
Posts: 208
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

Joined: Oct 11, 2006
Posts: 72
yeah. correct. what you said is my problem
Ådne Brunborg
Ranch Hand

Joined: Aug 05, 2005
Posts: 208
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing objects to different methods