• 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

Drawing a Chart.

 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
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
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Request you to please reply to this post. How will I draw directed arrows in Swing.


Thanks.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Arrows and directions usually indicate a graph
Check out JGraph
 
Rakesh Jhamb
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic