Skip to main content

Article: Gantt Charts With JXTreeTable

24 replies [Last post]
uhilger
Offline
Joined: 2003-12-31

Hi everyone,

today I published an article "Gantt Charts With JXTreeTable" at http://articles.lightdev.com/gantt/gantt_article.pdf

It describes how to utilize a custom tree cell renderer to implement display and manipulation of gantt charts with JXTreeTable. It also shows a way to customize date editing, explains how to build a custom data model for JXTreeTable and applies drag and drop to JXTreeTable.

The article is accompanied with source codes and a working binary.

Have fun
Ulrich

PS: I'd be glad if you could include a link to the article at the SwingX Documentation (http://swinglabs.org/docs.jsp) and Demo (http://swinglabs.org/demos.jsp) pages too.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
uhilger
Offline
Joined: 2003-12-31

though, when thinking about it, class GanttBar could be a component which could be accompanied by its required classes GanttTableCellRenderer, Activity and TimeFrameProvider. Is this what you thought about?

Ulrich

Patrick Wright

Just jumping in: there is an incomplete (not started :)) effort to
have "optional" components that are useful but not part of the main
SwingX distribution. So there's always the option (if you like) of
first donating the code to the project, and then asking for help
migrating (and documenting, etc.) the components to the optional
component list.

Regards
Patrick

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Kalyan Vaidyanathan

Hi,
Can anybody comment on one the issue of printing? Has anybody attempted
to extend the default printing capability of JTable such that a cell can be
split and printed across multiple pages? From the notes in the
TablePrintable.java it seems like this is a known limitation. Just
wondering if anybody has developed a workaround for this limitation.

thanks,
-kalyan
[att1.html]

evickroy
Offline
Joined: 2004-07-23

> Erik,
> the SwingX library is now updated, can you test,
> whether or not it now works on Mac OS X?
> Thanks
> Ulrich

Works great! Very nice!

Erik

uhilger
Offline
Joined: 2003-12-31

...one more comment on:

>> can you resize by dragging?

> the demo allows to set start and and
> end for an activity using the date
> picker only (clicking on a date column
> inside the JXTreeTable).

I find it more accurate to change the duration by setting the number of days to the desired value simply by typing into the days column than to resize by dragging BTW

Ulrich

Patrick Wright

Hi Ulrich

This looks nice--one problem I have noticed is that only the first
column (activity) is resizable, and the second date column is in most
rows cut off. Any reason the date columns are not resizable? I have
tried this on JDK 1.5 (6) and Mustang.

Nice work!

Thanks
Patrick

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

uhilger
Offline
Joined: 2003-12-31

Hi Patrick,

> any reason the date columns
> are not resizable?

yes, I did set a number of fixed column widths in method buildUI of class GanttDemo: [code] treeTable.getColumnModel().getColumn(ActivityTreeTableModel.COL_START).setMinWidth(60);
treeTable.getColumnModel().getColumn(ActivityTreeTableModel.COL_START).setMaxWidth(60);
treeTable.getColumnModel().getColumn(ActivityTreeTableModel.COL_END).setMinWidth(60);
treeTable.getColumnModel().getColumn(ActivityTreeTableModel.COL_END).setMaxWidth(60);
treeTable.getColumnModel().getColumn(ActivityTreeTableModel.COL_DAYS).setMinWidth(40);
treeTable.getColumnModel().getColumn(ActivityTreeTableModel.COL_DAYS).setMaxWidth(40);[/code]

I did not bother much with ColumnModel, is there a way to set a specific column width, keep that width until the UI is realized and still have the column sizeable?

Ulrich

Message was edited by: uhilger

Kalyan Vaidyanathan

Hi Ulrich,
Nice component. Also, a couple of questions.
1. When I tried to add printing capabilities to the gantt that I created,
using the default printing capabilities of JDK 1.5, it is difficult to print
the gantt cell especially if the cell has to span multiple pages. Have you
solved that or do u believe you have a solution for that
2. Do u have pan/zoom capabilities?

As an fyi, I have a simple gantt table that I have developed on top of
JXTreeTable as well. I have a couple of features that I can share with you
if you want to incorporate it into your component. If you want, we can both
join and enhance the component?
1. The gantt cell renderer can render weekends in a different color. Right
now, it assumes sat/sun as weekends, but that can be easily configured if
needed
2. The gantt cell renderer
3. I have a special renderer for the gantt header which can render 2 rows
with the minor and major times definable. For example, the minor time can
be day and major a week.
[att1.html]

uhilger
Offline
Joined: 2003-12-31

Hi Kalyan,

thanks a lot for your comments, I think there are plenty of ways to extend the basic gantt component introduced in the article, some of which you mentioned.

Unfortunately I am quite busy in the moment which is why I had no plans to do any particular extension for the time being. Nevertheless, the reason for the article was to share what I have in order to let others build own extensions as required.

Please feel free to use and extend GanttDemo. I am also interested in the extensions you might already have (as others sure might be too), so I'd be happy to look at your code. Only I won't be able to go into a 'Gantt Project' right now unfortunately.

Best regards
Ulrich

evickroy
Offline
Joined: 2004-07-23

Any thoughts on submitting the component to the SwingX project? ;)

Erik

uhilger
Offline
Joined: 2003-12-31

Hi Erik,

> Any thoughts on submitting the component
> to the SwingX project?

Would you say that the demo is/contains a component in the sense of JXTable, JXTree, etc.? Which class from the demo would that be? I would have rather thought that it is, well, a demo for JXTreeTable...?

Ulrich

Kleopatra

jdnc-interest@javadesktop.org wrote:
>
> today I published an article "Gantt Charts With JXTreeTable" at http://articles.lightdev.com/gantt/gantt_article.pdf
>
> It describes how to utilize a custom tree cell renderer to implement display and manipulation of gantt charts with JXTreeTable. It also shows a way to customize date editing, explains how to build a custom data model for JXTreeTable and applies drag and drop to JXTreeTable.
>
> The article is accompanied with source codes and a working binary.
>

Great!

>
>
> PS: I'd be glad if you could include a link to the article at the SwingX Documentation (http://swinglabs.org/docs.jsp) and Demo (http://swinglabs.org/demos.jsp) pages too.

besides that (you already have Romain's attention, so I think that will
be done as soon as they emerge from their j1 preparation) you can add
links to article, code whatever to the SwingLabs wiki:

http://wiki.java.net/bin/view/Javadesktop/SwingLabs

either there directly in the Sightings section or follow the link to the
SwingX realm and there under the articles.

Thanks
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

uhilger
Offline
Joined: 2003-12-31

thank you, Jeanette, I posted a link at both locations (SwingX Sightings and the articles list of the SwingX realm)

uhilger
Offline
Joined: 2003-12-31

...and I've added Web Start support for the demo at
http://articles.ligtdev.com/gantt/GanttDemo.jnlp

uhilger
Offline
Joined: 2003-12-31
evickroy
Offline
Joined: 2004-07-23

Please check the JNLP file. The codebase attribute doesn't appear to be valid.
Should it be "http://articles.lightdev.com/gantt"?

Erik

uhilger
Offline
Joined: 2003-12-31

Hi Erik,

I have changed the codebase, thank you for that.

Ulrich

Shai Almog

The original URL is also incorrect it should have been:
http://articles.lightdev.com/gantt/GanttDemo.jnlp instead of:
http://articles.ligtdev.com/gantt/GanttDemo.jnlp

(missing h in lightdev).

Very nice demo (I'm still reading the article) I don't fully understand how
Drag and Drop is supported here (can you resize by dragging?). Also I get
this exception:
UIDefaults.getUI() failed: no ComponentUI class for:
org.jdesktop.swingx.JXHyperlink[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=
0.0
,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=null,paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=false,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=,defaultCapable=true]
java.lang.Error
at javax.swing.UIDefaults.getUIError(Unknown Source)
at javax.swing.MultiUIDefaults.getUIError(Unknown Source)
at javax.swing.UIDefaults.getUI(Unknown Source)
at javax.swing.UIManager.getUI(Unknown Source)
at javax.swing.JButton.updateUI(Unknown Source)
at javax.swing.AbstractButton.init(Unknown Source)
at javax.swing.JButton.(Unknown Source)
at javax.swing.JButton.(Unknown Source)
at javax.swing.JButton.(Unknown Source)
at org.jdesktop.swingx.JXHyperlink.(JXHyperlink.java:76)
at org.jdesktop.swingx.JXDatePicker$TodayPanel.(JXDatePicker.java
:610)
at org.jdesktop.swingx.JXDatePicker.(JXDatePicker.java:129)
at org.jdesktop.swingx.JXDatePicker.(JXDatePicker.java:74)
at com.lightdev.demo.gantt.DateCellEditor.(DateCellEditor.java:60)
at com.lightdev.demo.gantt.GanttDemo.buildUi(GanttDemo.java:125)
at com.lightdev.demo.gantt.GanttDemo.(GanttDemo.java:84)
at com.lightdev.demo.gantt.GanttDemo.main(GanttDemo.java:102)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

--
Shai Almog
vPrise
http://www.vprise.com/
[att1.html]

uhilger
Offline
Joined: 2003-12-31

Hello Shai

> Very nice demo

thank you

> I don't fully understand how
> Drag and Drop is supported here

an activity (and all its children, if any) can be moved to another activity to have that activity as the parent with drag and drop.

> can you resize by dragging?

the demo allows to set start and and end for an activity using the date picker only (clicking on a date column inside the JXTreeTable).

> UIDefaults.getUI() failed:
> no ComponentUI class for: etc.

the SwingX library that accompanies the demo lacks class JXHyperlink, but that does not affect its functionality (apart from the exception).

Ulrich

evickroy
Offline
Joined: 2004-07-23

Ulrich,
Any chance that you could update your SwingX library to prevent the above exception? Unfortunately, any attempted access to System.out or System.err on the latest Java 5 VM on Mac OS X throws a permissions exception so the demo won't run.

Thanks
Erik

uhilger
Offline
Joined: 2003-12-31

Erik,
the SwingX library is now updated, can you test, whether or not it now works on Mac OS X?
Thanks
Ulrich

evickroy
Offline
Joined: 2004-07-23

> Erik,
> the SwingX library is now updated, can you test,
> whether or not it now works on Mac OS X?
> Thanks
> Ulrich

Great thanks! I'll give this another try as soon as I get home.

Erik

Romain Guy

Wow! Excellent! Rich and I have been talking quite a bit about writing a
Gantt chart component... Well I guess we can tick this one off our list :))

Thanks,

jdnc-interest@javadesktop.org wrote:
> Hi everyone,
>
> today I published an article "Gantt Charts With JXTreeTable" at http://articles.lightdev.com/gantt/gantt_article.pdf
>
> It describes how to utilize a custom tree cell renderer to implement display and manipulation of gantt charts with JXTreeTable. It also shows a way to customize date editing, explains how to build a custom data model for JXTreeTable and applies drag and drop to JXTreeTable.
>
> The article is accompanied with source codes and a working binary.
>
> Have fun
> Ulrich
>
>
> PS: I'd be glad if you could include a link to the article at the SwingX Documentation (http://swinglabs.org/docs.jsp) and Demo (http://swinglabs.org/demos.jsp) pages too.
> [Message sent by forum member 'uhilger' (uhilger)]
>
> http://forums.java.net/jive/thread.jspa?messageID=100391
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
> For additional commands, e-mail: jdnc-help@jdnc.dev.java.net
>

--
Romain GUY
http://jroller.com/page/gfx
http://weblogs.java.net/blog/gfx/
http://www.progx.org
http://www.jext.org

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

uhilger
Offline
Joined: 2003-12-31

Hi Romain,

> Wow! Excellent! Rich and I have been talking quite a
> bit about writing a
> Gantt chart component...

just in time development in this case...:)

> Thanks

thanks to the tremendous work the team already spent on SwingX it was a pleasure ;)