Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Drawing a Chart.

 
Rakesh Jhamb
Ranch Hand
Posts: 154
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a swing application already developed and running. I am not a seasoned swings developer, but understand the basics.

My query
We have XML config file that has information flow configuration. For example if information flows from A - > B -> C.

I want to extend this swing application and draw a chart at runtime by reading this config file that will diagramatically show that information is flowing from A to B to C.

Maybe drawing can be like 3 circles connected with Arrows.

I want to know what all technologies will be required within Swings space which I should look at and what options I have to draw something at runtime using information from the config file. Any 3rd party frameworks if required, please tell that as well.


Thank You
 
Rob Spoor
Sheriff
Pie
Posts: 20380
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can extend a regular JPanel, override its paintComponent method* and do any custom painting on the supplied Graphics object. It's (almost?) always an instance of Graphics2D, so if you need any methods specific to that class you can cast the argument. Use instanceof to avoid any ClassCastExceptions.

* Please be careful:
1) the first statement inside the overridden method should be super.paintComponent(g)
2) keep the method protected
 
Rakesh Jhamb
Ranch Hand
Posts: 154
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your quick reply. This would mean I would have to write code to draw widgets. For example, the challenge with this approach is:

For example, how do I draw a directed arrow. Is there any inbuilt widget in API to do that.

That is why, I wanted to know some framework or API that can be used in conjunction with Swings to draw beautiful diagrams.

Thanks
 
Rakesh Jhamb
Ranch Hand
Posts: 154
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Request you to please reply to this post. How will I draw directed arrows in Swing.


Thanks.
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two possible ways:

Search the web for a free or commercial package that provides an API for drawing arrows
or
Write one yourself.
 
Rakesh Jhamb
Ranch Hand
Posts: 154
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we see tools like eclipse, there are various plugins that draw beautiful class diagrams or dependency diagrams. Is that done using raw code inside the plugin, or there is some standard api / library to do this.

I am not able to find something suitable, hence thought of asking swing experts. If you know one, please let me know.

Thanks
 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arrows and directions usually indicate a graph
Check out JGraph
 
Rakesh Jhamb
Ranch Hand
Posts: 154
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Manish,

Thanks for your reply. This is exactly what I am looking for. But this is a commercial version, do you know any free utility with basic arrow and circle figures would suffice for my purpose actually.

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic