Dendrogram is not a regular diagram. Should I use any component from javax.swing.* library, or just draw it with java.awt.Graphics?
Might also be worth checking: yWorks and JGraph
I don't think there is a standard component for this. Unless some component vendor has done one, you should go the Java 2D way...
If you don't want to do the hard work, perhaps one of the above mentioned libraries might help you. Otherwise, GraphViz is good at making this kind of diagram, and has a Java API (untested...).
Another possible way is to use some physics to let the nodes arrange themselves in an harmonious way. That's how Aharef's HTML graph works...
Netbeans Graphing API
By far the easiest and most intuitive API of the lot.
Related
I'm programming my first game in LibGDX and part of the gameplay has a mixing logic between elements (similar to Doodle God or Little Alchemy). By reading and watching guides, I've attempted to design this logic using LibGDX classes Stage, Actor (for the elements) and Group(for organising elements), but then I realised I would need an actor for each element. Since I intend to have over 150 of them, creating a java class for each one really doesn't feel optimal. Neither do I know an efficient way to store all the logic so I can look for combinations with a single call (I don't want to write a million if statements in a method).
I would like to know if there's a simple and elegant way for doing that. Thanks in advance!
P.S.: The only differences between elements are their textures, the groups they go into and the elements they combine with.
There is indeed a pattern that is currently well used for doing what you expect. It's called entity-component-system (or ECS).
It requires a shift in thinking how to develop games, but it's worth it, especially for its modularity and reusability.
Wikipedia has a much detailed article about it.
And it's a good thing that libgdx has Ashley, their ECS implementation.
If you can, reuse Actors maybe?
If we talk about logic.
You can group logics and write a function for every group.
Don't use ifs, use switch and enums.
Maybe if you tell us more then we can come with something innovative.
I am currently involved in a medium-scale (300-400k lines) project written in Apache Wicket. At this time, majority of it's source code is not really reusable, breaks a lot of wicket's "best practices" (like passing raw objects instead of models or passing whole components/pages to other components), it's prone to all kinds of errors and does not handle extending functionality well. As far as Wicket's documentation goes, it is great way to scratch the surface, but I can not really say it's sufficient source of information for projects of this scale. What I am interested in is, how large scale applications are actually written in Wicket? Are there any sources/examples you could recommend?
And as for something specific, I also have few questions:
How to handle communication between several components? Are events preferred over abstract/no-op methods or vice versa?
Are anonymous implementations considered bad practice? How to establish a boundary on what should stay in a component and what should go into services (ie. when overriding onClick())?
How to properly encapsulate component functionality, if it depends on other components?
How to avoid conditional adding of componenta (ie. if(...) add.(A) else add(B))? Is there any other way around this except setting either one to visible=false?
I would really wish to dig deeper into wicket and take few more steps to mastering it, but I feel like there is not much to learn from.
Thank you in advance for your answers, anything will be appreciated :)
I start with example:
Let's imagine that I have some application similar to PowerDesigner. It have class Table, which has some parameters.
I would like to make visual representation of object derived from Table on some background. It should be drag and drop in the same way like in PowerDesigner.
Is there some (CDDL) library for this purpose?
Thanks for replies.
You should try the Java Swing Framework.
This tutorial shows you how to get started and has a chapter on drag-and-drop.
I found some tutorial which seems like exactly what I want.
http://platform.netbeans.org/tutorials/nbm-visual_library.html
but still, i would like to prefer some library where I can use predefined objects and make it more easy.
Does anyone knows a good 2D engine for Java with sprites, animations and collisions handling?
JGame is probably what you're looking for.
You might also want to check out this question ( https://stackoverflow.com/questions/293079/java-2d-game-frameworks ) that has a list of Engines out there and a bit of feedback on some of them. Hope it's helpful.
Slick2D seems to be a pretty solid choice.
It's widely used and it is based on OpenGL (via LWJGL) so you can get some pretty good performance if you need it.
Greenfoot, from the makers of BlueJ, would be a good choice if it is your first time with game-development in Java. It is not even an easy-to-learn API, but also comes with a development-environment with fully integrated Greenfoot surface.
The game-environment is the greenfoot.World while every element in the game is a greenfoot.Actor instance. The Actor class provides a method for true bitmap-intersection (greeenfoot.Actor.intersects()).
jGame
Arianne
Tangent: You'd be better off branching away from Java. The game development industry is C++/Python heavy, with C# in third.
I know how to draw basic objects using JOGL or LWJGL to connect to OpenGL. What I would like is something that can generate some kind of geometry for trees, similar to what SpeedTree is famous for. Obviously I don't expect the same quality as SpeedTree.
I want the trees to not look repetitive. Speed is not a concern, I do not expect to need more than 100 trees on screen at one time.
Are there free tree-drawing libraries available in Java? Or sample code or demos?
Is there anything in other languages which I could port or learn from?
http://arbaro.sourceforge.net/
http://www.propro.ru/go/Wshop/povtree/povtree.html
Non java: http://www.aust-manufaktur.de/austt.html
There are thousands of methods. A better question would define 'best' in a more confined way. Are we talking 'best' as in speed of drawing (suitable for thousands or millions of trees)? Best as in best-looking? etc.
2D or 3D?
In 2D, a common way is to use L-systems.
I also tried an OO approach, defining objects for trunk, branches, leaves, all extending an abstract class and implementing a Genotype interface (to vary the kind of trees).
Not sure if it is efficient (lot of objects created, particularly if I animate the tree) but interesting to do.
Here are a couple resources that may be helpful:
gamedev thread on the subject - contains some useful advice/suggestions
ngPlant - an open-source procedural plant generation tool. It is not written in Java, but you may be able to find ideas in its algorithms.
If you are using eclipse/SWT, try Draw 2D.
If you're serious about getting good-looking, fast trees, there's a commercial C++ library SpeedTree. Lots of big-time games use it (e.g., GTA, Elder Scrolls).
A combination of OpenSceneGraph and SpeedTree has worked for me.
I know of two libraries that enable the usage of OpenGl with java.
LWJGL (Light Weight Java Gaming Library), which imo is the better one due to its simplicity and its similarity to using opengl with c/c++.
JOGL If you want to mix swing components with opengl this may be the better choice, I've never used it but several years ago it was known to be pretty buggy, I don't know if its matured since then.
As for drawing trees, there are many ways to do so like the other poster said, you might want to be more specific.
edit: I guess I misunderstood the question a bit, oh well : / You can load in a 3d model of a tree and display that.
http://www.codeplex.com/LTrees has some source code on that. it's c++ though.