laFabrique : Multiline String

logo_wHi,

Inside laFabrique library a multiline string has been created. It is useful, for instance, to create dynamic and generated OpenGL shader.

An example of use :

the result is :

To use it, just download from laFabrique download page.

 

JavaFX : JfxFrame

Hi all,

I have developed a JfxFrame for JavaFX for my own needs. Now you can have your JavaFX code without a JavaFX application. I share it as it might interest others. Please find below a small code sample.

 

To use it you have to download Ermine.jar

Of course you can create several frames, just by allocating and displaying several instances.

At first glance, it looks like the old Swing or AWT frame, but it is a bit different as it is coming with a callback method which is executed inside the correct JavaFX Thread. I have created such frame not by nostalgia but for having a class containing main without JavaFX application. This way you can use JavaFX everywhere inside your own architecture and not only from a class with JavaFX’s main.

In my opinion the JavaFx code should be a leaf in architecture as other application parts like data processing, database access, network server etc..

To create this frame, I had to add a method known by Swing coder invokeAndWait that might also interest some JavaFX coders :

Next time I will present you new features of RefPointLayout.

Cheers.

Mik

 

 

 

JavaFX layout

Hi,

At last, I have started to work on JavaFX. For my first development, I share with you a new Layout named RefPointLayout. It’s principal is simple as you define one node position or two points node relatively to some reference points.

With one point you can set only the node position. With two points you can set the node position and size. The below diagram shows you the main key points of this layout :

refpoint

Let’s see together an example with scaled node and fixed size node. The HMI contains two scalable list views and two fixed size buttons. For the list view of the left side, its top left corner is relative to the top left parent reference point and the bottom right corner is relative to the bottom centre parent reference point. This way it is following window resize with a constant delta x and y. For the two buttons their position is set relatively to the middle centre reference point.

RefPointLayoutThe code to create the above HMi is the following :

In order to compile the above code, you need to download Ermine.jar. The layout is also available as a pane. Personally I quite like it as an independent layout interface. In the future, I might improve it by adding some customed reference points.

Cheers,

Mik

 

capcaval_logo_small Ermine_logo_small

 

New Java library : laFabrique

 

logo_w

Je suis heureux de vous annoncer la création de ma dernière librairie Java : laFabrique. Ce nouvel outil est une usine d’application Java de type open source. Elle permet de :

  • créer, de compiler vos projets,
  • mettre en forme vos livraisons en Jar ou Zip,
  • lancer facilement vos applications,
  • gérer simplement les paramètres et les propriétés de vos applications,
  • fournir aux utilisateurs de vos applications un mécanisme d’auto-documentation avec logo en ASCII.

Ces fonctions sont réalisées via du code descriptif en Java. Cela a pour avantage d’être utilisable dans n’importe quel outil Java, comme dans un IDE tel qu’Eclipse.
En synthèse «laFabrique» est une sorte de ANT ou de Gradle mais en Java et cela simplifie votre vie de développeur et ainsi améliore votre productivité.

Plus d’informations : http://lafabrique.capcaval.org

 

I am proud to anounce the first release of my latest open source Java library named lafabrique.

I am proud to announce the first release of “laFabrique”, which is a Java application factory. It provides the ability to :

  • create and compile project,
  • pack application in jar or zip,
  • simply launch your application on Linux and on Windows OS,
  • handle application properties and parameters in a simple manner,
  • provide to your application user an automatic documentation and an ASCII logo.

All these features are easy to use as it is mainly done with descriptive Java code. This is an advantage because it can be used inside any Java Tools such as Eclipse IDE.

In conclusion, laFabrique is a kind of ANT or Gradle but in 100% pure Java. It also comes with an architecture aspect within the whole CapCaval architecture.

Read more at http://lafabrique.capcaval.org

Architecte logiciel

Jeudi 26 Septembre à l’ENIB, j’ai présenté pour le FinistJUG mon retour d’expérience du métier d’architecte logiciel. Vous trouverez, ci-dessous, une description de la présentation et à la fin le lien vers celle-ci :

ArchitecteMener à bien un développement logiciel est une tâche très difficile et cela pour de multiple raisons. Une majorité de projets rencontrent des problèmes importants sur la qualité, les coûts, les délais, les performances etc… L’architecte logiciel peut avoir un impact direct ou indirect sur ces enjeux.

Malheureusement, le terme architecte logiciel est très souvent galvaudé par une vision simpliste du poste. A contrario, connaître sa richesse permet d’améliorer, de manière importante, la bonne marche des projets.

Ensemble nous allons voir les principaux enjeux de la production logicielle et comment l’architecte peut apporter sa plus-value. Plusieurs exemples concrets viendront illustrer ces problématiques.

Pour finir une méthode de travail, centrée sur l’architecte, sera exposée de manière chronologique, cela aidant à la maîtrise de la création de logiciel.

Les planches, au format “pdf”, sont disponibles ici.

 

JOGL GL3 sample

triangle

I had some difficulties to find some full sample of JOGL code for the version GL3. As I have managed to produce one, I decided to share it on my blog. This sample is highly inspired from the following link  : http://www.lighthouse3d.com/cg-topics/code-samples/opengl-3-3-glsl-1-5-sample/

The source is made of in three files : one for java and two for shaders.

I have to admit that it is a big step between GL1/GL2 and GL3/GL4 version. GL3 provides less graphical abstractions and more processing ones with shaders. For sure it is more powerful but the price of it is to write more line of code.

In order to avoid display flickering just add “-Dsun.awt.noerasebackground=true” parameter on the java options.

 

 

Control your software application with C³

is a Java library providing a component abstraction capacity, as its main feature. The use of components and a component model is highly recommended to structure your software. Before defining your software’s component structure, you need to define what the users of your application will be able to do and how they will be able to do it. In order to enable this definition, provides an Application class, whose presentation and description is the subject of this article.

An application can be seen as a black box, created by a “coder” and used by a “user”. Their needs are different. The coder wants to write the simplest program that renders the requested functions. The user wants to be able to configure the application easily and to have access to a decent documentation. A very simple example is used throughout this article, the famous “HelloWorld” application, whose functionality is simply to perform greetings. Let us see together what might provide for such an application.

Application class provides the following features :

– application state-machine : the software coder can benefit from the simple C³ application state machine. Let’s us start with only two states “Running” and “Closed”. By sub-classing the abstract Application class, the compiler will force you to implement the events. At run-time, your events will be called before each state change,

– application property : the application shall be configurable by the software user with Java properties (other configuration type might be added in future version). The annotation called @AppProperty handles simply this functionality in a declarative manner and C³ does the plumbing for you.

– generic help with auto-documented mechanism : no plumbing code needs to be added to display the application name, the “about” information and the properties. C³ discovers automatically all the application features and displays them, when the software user adds the “-help” parameter to its software launch command.

Application annotation

C³ provides an application annotation mechanism in which the version can be set and an “about” text added. This information will be accessible to the software user.

 

Application state machine

For our simple example, C³ provides an application state-machine with only two states: “Running” and “Closed”. Just before reaching one of the two states, C³ will notify you with the corresponding event: notifyApplicationToBeRun or notifyApplicationToBeClosed.
The first event is called when all AppProperties are ready, and when the components are created. A future paper will focus on components. Basically, this event has to be used to configure and to start your application.
The second event is called when the application is stopped. C³ detects, for you, that your application is closing and notifies this. The Event can be used to properly close resources such as a socket, a database, a file, etc.

AppProperty annotation

Java language provides system property that can be set either on Java command line with “-D” prefix or by loading a property file. A property is a key/value pair, where each value is accessed through the associated key.

C³ provides annotations in order to automatically link a property to your class application member. The principle is basic, by being declarative. This way the code is more functional and less technical. What you have to do is to add, as class member, the needed configuration inside your application class. For instance, let’s say that an application needs to be configured with a name to greet. All you have to do is to add, inside your own Application’s sub class, a member like :

The above piece of code can be read as: this is a property called “name” and its default value is “world”. Automatically the “name” system property is available to configure your application.

Min and max value can be added for some numerical properties

Application member types supported are listed in the following table :

Extra types can be easily added by implementing the generic interface ObjectFactoryFromStringValue which shall return the defined generic type from a string. When the factory is written just add it with the following method at your application creation.

Application command line

C³ provides default command parameters such as the keyword “-help”, “-h”, “–help” or “–h”. When called with one of this parameters, C³ writes on the system output :

  • the application name of the application,
  • “about” information,
  • version of the application
  • the list of properties, with their types.

You can either use your own code typed from the samples or download the ready to use classes

At http://c3.capcaval.org/download.html download :

  • C3.jar
  • HelloWorldApplication.zip

Unzip the file, and go inside the root directory. You need to run with a Java7 jre. After launch the following command line :

with the following result

line 1 : application first state
line 2 : greetings with the default value
line 3 : application last state

In order to know the available application properties used the -help parameter as follows :

the result should be :

line 2 : application name
line 3 : application version
line 4 : application information
line 7-9 : description of the “name” property

Configure your application

Of course the default value, “world” in our case can be changed by using the “name” property. Just type the following command line:

The result should be :

line 1 : application first state
line 2 : greetings with the configured value
line 3 : application last state

you can also download the pdf version, here.
Thanks to Laurent, Yannick and Olivier for their review.