Well, this took me awhile. But it was a pain not being able to load images from within my CSS file. The problem lies because the absolute path is different when you test it compared with the result when deployed.

Let us say this is how I want my button to look like:

When you run it in your local development environment, you wonder why the image would not load. Try to call this within your code

and you will see why. In my case, the result was something like E:/folder/build/classes/images/bullet_black.png

Now, for it to work if you call it from within the CSS file, you would have to do it like this:

The problem then is when you deploy it, there is no drive E from inside the JAR file. So what is the solution then?

Do it programmatically. This is how I did it within my Button class

If only we could use the @- keyword to make it look like this:

But we cannot as it is a Java FX limitation and this keyword is ignored.

I have to admit, you need to dig in a little Math here. Drawing an equilateral triangle in a Canvas is possible using a Path object or use vertices to set up the 3 points.

However, to do automatic calculation, the best possible way to do this would be to either input 2 points and have the method calculate the 3rd point. In my case, I was able to create a method using only 1 point and specifying the distance.

Remember, an equilateral triangle has the same length on all 3 sides so my method’s other parameter entails having to declare the size per side.

And I was able to make a method where the middle point will be calculated depending on the desired location of the developer.

This is the result of the triangle that the method generates. It returns a Path object where, depending on the direction that you choose will point to that direction.

You may notice there is a 3rd parameter of type Direction. It is just an enum class that I created. You can change it if you want. But if you want to use the same class, here is the code for the Direction enum class.

If you want to create a triangle that faces downward like in the 3rd image above with the number 9, you can do it like this.

Stealth startup Path has finally launched after months of hype, speculation and rumors; in many ways, it is the anti-social network. Calling itself The Personal Network because it is determined to go against the example set by Twitter’s follower model: you are limited to just 50 friends on Path.

It chose the 50 number based on the theories of Oxford professor of evolutionary psychology Robin Dunbar, who claims that 150 is the maximum number of social relationships any human can handle.

Path has received a lot of attention because of its founding team: former Facebook senior platform manager Dave Morin, Macster co-creator Dustin Mierau and Napster co-founder Shawn Fanning. But will this be a success. We will soon find out. Maybe users will still use this for very personal purposes considering that even I believe that all accounts in Facebook contain some friends who are not really close to the account owner.

Users may still use Path due to the power of exclusivity. But what exactly is it? It is a suite of applications (starting today with the iPhone) focused on intimate photo sharing. All you do is share pictures and three pieces of information to give them context: people, places and things. Pretty limited but then again, it is not a good idea to share everything to the public. Some things are just worth kept only to a select few.

Related Posts Plugin for WordPress, Blogger...