Archive for bubble

java.util.logging (jdk14 logging) oddities explained (and fixed)

// April 1st, 2012 // 3 Comments » // bubble, design

Usually when you add logging to your application you create a java.util.logging.Logger that has the same name as the class you use the Logger in. Your code might look like this:

package some.test;

import java.util.logging.Logger;

public class Main {
  private static Logger log = Logger.getLogger(Main.class.getName());

  public static void main(final String[] args) {
    log.info("test");
  }
}

This works well and you get something like this as the log output:

01.04.2012 19:10:39 some.test.Main main
INFO: test

Now we can easily change the configuration of this logger and change the Loglevel. So for instance when we don’t like any logging we can disable logging for this class either using a configuration file or do it directly from code like so:

Logger.getLogger("some.test").setLevel(Level.OFF);

and the class will not log anymore.

Sometimes doing this in Nifty and using the name “de.lessvoid.nifty” for instance to shut off the logging refused to work. Some classes simply didn’t stop logging at all. What’s going on?

After a long headache we’ve finally found out!

Nifty used some special logger names for eventbus and inputevent logging. Both loggers used special names that did not relate to any class because there where several classes that would need to log those events. So a special name, like “NiftyEventBusLog” made sense for me.

In some places we had code like that:

package some.test;

import java.util.logging.Logger;

public class Main {
  private static Logger differentLog = Logger.getLogger("SpecialLog");

  public static void main(final String[] args) {
    differentLog.info("test");
  }
}

I somehow expected the loggername in the log to be “SpecialLog” since it’s the name of the logger. But in fact we get something else:

01.04.2012 19:24:41 some.test.Main main
INFO: test

O_o

The information still shows “some.test.Main” since this is the class that actually logged!

If you now try to disable logging for this class, like we’ve seen above:

Logger.getLogger("some.test").setLevel(Level.OFF);

YOU WOULD STILL SEE THE LINE IN THE LOG – even though you’ve disabled it (kinda) :-)

Of course to fix this you would need to disable the “SpecialLog” additionaly to “some.test.Main” but that’s pretty odd since you usually don’t know the exact names of all loggers beforehand.

So to make a long story short Nifty now (current git) removed all the special loggers and always only uses the logger with the name of the current class. When you now disable a logger you should be pretty sure that you really disable any output with that name ;-)

void

Tygron Serious Gaming supports Nifty GUI!

// October 16th, 2011 // No Comments » // bubble

Everything started when I was answering a question on the regular jMonkeyEngine3 Nifty GUI support forum and some questions somewhere in the comment section of this Nifty GUI blog. Someone had build a converter to convert Java Swing GUIs into Nifty GUI XML files. Interesting!

As it turned out these posts were related to each other and were both coming from the same gaming company Tygron Serious Gaming located in The Hague, The Netherlands. A couple of emails later we’ve identified some things that they’d like to be improved as well as other things to be added to Nifty. Since some of their existing game assets relied on the direct display of HTML data – which Nifty did not supported – they were especially interested in adding basic HTML support to Nifty.

Everything was very friendly and they especially made it clear from the very beginning that they had no interest in messing with Niftys “openness” in any way. That means that everything we’d change or add to Nifty will still be available for free without any added restrictions. I think this is not something that you can take for granted when dealing with a corporation. So in general that is a very nice attitude! Kudos for them for this!

To discuss all of this in more detail they’ve invited me to The Hague and suddenly I was sitting in a train to the Netherlands to meet everyone involved in the project. Travelling to discuss Nifty related things in a meeting! Amazing!
:D

As expected everybody was nice and friendly. Marieke – their Office Manager – did an excellent job in organizing my travel and Raymond made sure that I’ve ended up at the right place.

Here is a little group photo they did. Look for me in a dark gray shirt in the middle of the picture.

Tygron Nifty GUI Meeting

It was really amazing to see Nifty being used in commercial software running on their big screen in the conference room! And seeing the Java Swing to Nifty GUI converter in action was quite amazing as well!
:D

So what do you, as a Nifty User, get out of this collaboration? Basically two things:

- Niftys memory overhead has been greatly reduced. Nifty is now a lot more GC friendly (improved FPS too)
- The HTML Module is now available and will be a part of Nifty 1.3.1. This adds basic HTML support to Nifty which allows you to generate Nifty elements from basic (!) HTML data.

Well, exciting times for Nifty GUI!

So, I’d like to take this opportunity to (again) thank Maxim, Jeroen and especially Raymond and William for the invitation and of course Marieke for the whole organisation!

Thank you Tygron!
void

About Tygron Serious Gaming

Tygron Serious Gaming is a serious game developer located in The Hague, The Netherlands. It specializes in bringing real-life complex management challenges that have multiple actors with unique tasks and different interests into a ‘multiplayer serious game’, making use of modern game technology.

Nifty User zozo64 creates Basis Drag and Drop Demo!

// June 28th, 2010 // 1 Comment » // bubble, demo, design

See! This is what I’ve meant! :)

Nifty gives you an easy to use framework that you can extend with your own ideas. Just like Nifty user zozo64 did. Nifty is missing drag and drop support? No problem! He created his own! :D

To be honest, he found some bugs too :) but all of that improved Niftys core systems. So that’s a good thing. We’ll probably bring his work as a standard drag and drop control into the standard controls project soon.

For the moment you can take a look at the code. It’s part of the nifty examples project:

http://nifty-gui.svn.sourceforge.net/viewvc/nifty-gui/nifty-examples/trunk/src/main/java/de/lessvoid/nifty/examples/dragndrop/

And here is a first preview of zozo64 work:

Nifty Basic Drag and Drop from void on Vimeo.

Nightly Builds Available

// May 14th, 2010 // No Comments » // bubble, docs

Nifty will now build each midnight automatically. Well, at least when this computer here is running at this time which, erm, should be often :)

Hudson will svn checkout all relevant nifty projects and will then “mvn clean deploy” them to the nifty maven repository at sf.net. This means that all projects that are already being build with maven and have this in their pom.xml:

<repositories>
    <repository>
      <id>nifty-maven-repo.sourceforge.net</id>
      <url>http://nifty-gui.sourceforge.net/nifty-maven-repo</url>
    </repository>
</repositories>

will automatically get the latest nifty builds!

Currently this means 1.2-SNAPSHOT for Nifty as well as the Nifty Default Controls and the black Style projects and 1.0-SNAPSHOT for the new Nifty Renderer Projects.

Currently the following projects are build each night.

Nifty
http://nifty-gui.sourceforge.net/nifty-maven-repo/lessvoid/nifty/
http://nifty-gui.sourceforge.net/nifty-maven-repo/lessvoid/nifty-default-controls/
http://nifty-gui.sourceforge.net/nifty-maven-repo/lessvoid/nifty-style-black/

Nifty Renderer
http://nifty-gui.sourceforge.net/nifty-maven-repo/lessvoid/nifty-lwjgl-slick-renderer/
http://nifty-gui.sourceforge.net/nifty-maven-repo/lessvoid/nifty-lwjgl-renderer/
http://nifty-gui.sourceforge.net/nifty-maven-repo/lessvoid/nifty-slick-renderer/
http://nifty-gui.sourceforge.net/nifty-maven-repo/lessvoid/nifty-java2d-renderer/

The JME2 Renderer currently has some weird problems being automatically build. So this is not yet available – still working on it:
http://nifty-gui.sourceforge.net/nifty-maven-repo/lessvoid/nifty-jme-renderer/

If you’re not using Maven you should still be able to get the SNAPSHOT jars from the URLs mentioned above. Just find the sub directory 1.2-SNAPSHOT or 1.0-SNAPSHOT and get the latest JAR from there. Don’t mind the name of the jar tho. It’s automatically generated by Maven and it’s just named with the build date and time.

Good luck!
void

Dynamically Changing Button Text/Width and the Centerlayout

// February 21st, 2010 // 1 Comment » // bubble, design

Jattra tries to dynamically change button text from within Java and he needs a Button that automatically resizes according to the width of the changed text.

You can follow both threads at the Nifty Help Forum at sf.net:

Read the complete blog post for details.
(more…)

New Feature – Keyframes for Nifty Effects

// October 27th, 2009 // No Comments » // bubble, design

Well, I’m currently rewriting the old Nifty Introduction Demonstration that somehow didn’t survive my last blog server switch :( It was posted right here but the jnlp disappear. The demo explained some basic concepts of Nifty and it was written in Nifty :) I’m rewritting it now to update it to the current Nifty Standards.

In the process I just want a moving Nifty GUI Logo like this one

So the logo should resize while fading in and keep on resizing while fading out.

(more…)

So and what’s next?

// August 29th, 2009 // No Comments » // bubble

Well, Nifty 1.0 should be quite stable now. It’s probably not perfect yet but you already get a whole lot to play with already :)

So, what’s next with Nifty?

Write more Documentation:

  • Programmers Manual / Introduction to Nifty as a little PDF book is planned. Looking forward to this! :)
  • Reference Wiki for all the Effects and Element Attributes and so on

Make it more usable:

  • Allow another “language” to define the GUI in (besides XML). Maybe a DSL in groovy or scala or something else :)
  • Fix bugs and other issues
  • Improve the Layout Part and make this more easy and accessible

Make it more modular:

  • Nifty now depends on Slick for Sound and Image handling. Some people reported that they don’t want to be forced to be dependent on Slick. So to have Slick as an Option would be a plus (this is already prepared for but was too much work to finish for 1.0 :)
  • Make even better Slick integration xD
  • Split Nifty into even more modules so that you can only use the part you need (effects for instance could be another jar)

And that’s the current plan!

Have fun!

1.0 – RC 1

// March 29th, 2009 // No Comments » // bubble

I’ve just commited some final changes to the loader to svn.

Finally everything is in place again. Changing the loading code was a lot more work than expected. But adding a preprocessing step was the key to solve all the issues and get the code much cleaner.

As an additional benefit nifty now knows for every attribute from which style it came from. So removing a style and replacing it with another one on the fly is supported :)

We’re now testing the current version in svn with an actual game. When everything works ok the 1.0 release of nifty gui will be available soon – for real this time ;)

In the meantime you can follow nifty development at twitter

Updated Slick and Lwjgl Library Versions + More Maven Love

// March 14th, 2009 // No Comments » // bubble, docs

I’ve now updated the Nifty Dependencies in SVN (for the Nifty 1.0 Release) to the following Versions:

  • Slick #239
  • Lwjgl 2.0.1

Besides that I realized that I’ve already had setup a Nifty Maven Repository at Sourceforge. This was meant to store Nifty releases to allow other Projects that use Maven and Nifty to easily access the Nifty libs. So for instance you just need to add:

<repositories>
  <repository>
    <id>nifty-maven-repo.sourceforge.net</id>
    <url>http://nifty-gui.sourceforge.net/nifty-maven-repo</url>
  </repository>
</repositories>

to your applications pom.xml and it will automatically find the Nifty dependency :) So far so good.

BUT

Today I realized that I could use the same approach to get Lwjgl and Slick2D easily under Maven control. So when switching the Versions to Slick #239 und Lwjgl 2.0.1 I deployed both libs to the Nifty Maven Repo at Sourceforge! :D

So what does this mean for you?

It means just one thing. It’s now easier then ever to build Nifty! Just “svn co” it from Sourceforge and execute “mvn package” and it should automatically download all required libs without any changes!

Nifty! :D

Improved support for dynamically created Controls

// March 9th, 2009 // No Comments » // bubble

Nifty was meant to read everything from XML files. But sometimes this is not enough because you need to decide from within your code what needs to be created.

This was possible in older versions of Nifty but was kinda tricky.

With Nifty 1.0 (currently available in svn) this has been improved. There are now special classes available to create and configure the build-in elements like Panel, Text, Label and Image.

Example use:

CreatePanel createPanel = new CreatePanel();
createPanel.setChildLayout("horizontal");
createPanel.setHeight("8px");
createPanel.create(nifty, screen, parent);

There is now even support to dynamically create your controls with a CreateCustomControl class.

Nifty stuff :)