开发者

Best approach on custom graphics in Java

I had asked a question a few days ago here on how to draw some custom graphics. As I talk about it with various people they suggested not to draw my graphics by coding but use png files instead. So I would like to know what my options are and what is commonly used in the industry.

A quick explanation to my problem: I'm making a texas hold'em poker odds calculator for training mostly. I want when I click a card, a circular dialog appearing where I could select the suit and value of the card. Imagine a circle in the middle cut in 4 with the suite options and a ring around that circle with the 13 possible card values.

Options I have thought of:

  • Making png for every possible combination (1 empty, 13 for card开发者_StackOverflow only selections, 4 for suite only selections, 52 for every possible combination of suite and value)
  • Making independent png for suite and value (1 empty suite, 4 for selected suite, 1 empty value, 13 for values) and layer those.
  • Make selected/deselected png for suite and value and render the text on them (1 selected suite, 1 deselected suite, 1 selected value, 1 deselected value)

Of course the 3rd option seems more appealing but is it the right way to go? What size should I make those png be, because they are going to be static I guess...


Myself I've used Playing Card images that are in the public domain. For example Playing Cards. I've also posted a comment on your previous post, for what it's worth.


To be honest the suit idea of the wheel is good but I would probably not want a wheel with 13 options on it, perhaps a radio choice, or a simple slider (where you write your own event listener to show the value above so that you can have j,q,k,a etc...), or more likely a simple list: http://download.oracle.com/javase/tutorial/uiswing/components/list.html.

Unless its going to be extremely professional there is likely no point in making images. I will be honest png, is useful if your not great with programming it is very easy to draw a nice picture; however, if your good with programming you make nice gradients and very nice selector without any pngs....

It really depends on what are you better at designing. I personally presume that the png might be more difficult for a wheel, but for me its more difficult, as I have spent time to draw gradients etc....

Here is a good link for gradients and polished apps: http://nadeausoftware.com/node/82. Keep in mind btw you can draw suit symbols in ascii, or in paint, look over here for some examples: http://www.java-forums.org/java-2d/25333-drawing-heart-valentine.html (some more complicated than others to get an idea of what you might be up against).

The standard professional suit of applications is usually to use png simply because, they have graphic designers on staff. The upside of pngs is that they generally are easier to create and add. The upside to programming is the ease to alter them programmatically, meaning when selected to change the color etc.... Which is still possible with a png, but not always easier.

Btw, also look here for an example of how to make a nice radial gradient as you might need something like this whether you choose to use a png or not.

Long story short, I would draw it via coding though thats subjective, and finally I would make a different chooser for value and for suit.


I'd use a (possibly hierarchical) context menu, as discussed in How to Use Menus: Bringing Up a Popup Menu. Action, also mentioned there, would make keyboard alternatives particularly easy. In a menu, you could probably use the appropriate Miscellaneous Symbols, which can be scaled and colored as shown here.

If you go with the circular JComponent, there's an example of the relevant geometry here.

Addendum:

I wanted to go with something more graphic…

Then the choice boils down to adding components to a custom layout or doing hit-testing in a custom component.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜