Erwin Müller Blog http://www.mueller-public.de Sun, 02 Oct 2016 16:51:06 +0000 en-US hourly 1 http://wordpress.org/?v=4.2.2 StartSSL Free Class 1 Certificate with Java Keystore http://www.mueller-public.de/2016/10/startssl-free-class-1-certificate-with-java-keystore/ http://www.mueller-public.de/2016/10/startssl-free-class-1-certificate-with-java-keystore/#comments Sun, 02 Oct 2016 16:50:47 +0000 http://www.mueller-public.de/?p=721 Recently I switched to the StartSSL free class 1 certificate for my sites because for one obvious reason: it is free. So, after a long pause, I started to work on my Java software projects again and my SimpleRest (a simple library that allows access to various REST APIs like for Owncloud and Oanda, based…

]]>

Recently I switched to the StartSSL free class 1 certificate for my sites because for one obvious reason: it is free. So, after a long pause, I started to work on my Java software projects again and my SimpleRest (a simple library that allows access to various REST APIs like for Owncloud and Oanda, based on Apache Http Components and FasterXML Jackson) Java project threw SSLHandshakeException when trying to connect to my site to run some tests. I though that is likely because the StartSSL CA was not included in the JDK keystore. But since I am running Debian Sid the StartSSL certificates are included.

keytool -list -trustcacerts -keystore "$JAVA_HOME/jre/lib/security/cacerts" -storepass "mypass"|grep start

debian:startcom_certification_authority_g2.pem, Jun 23, 2016, trustedCertEntry, 
debian:startcom_certification_authority_2.pem, Jun 23, 2016, trustedCertEntry, 
debian:startcom_certification_authority.pem, Jun 23, 2016, trustedCertEntry,

It turns out that we need also the StartCom Class 1 DV Server CA certificate so that the free Class 1 certificate is validated. We can do that by downloading the server CA certificate and add it to the keystore (the store password mypass needs to be replaced with the actual password).

wget -O "/tmp/startssl_sca.server1.crt" "https://www.startssl.com/certs/sca.server1.crt" && sudo keytool -import -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass "mypass" -alias startcom.sca.server1 -file "/tmp/startssl_sca.server1.crt"

After that, everything should work fine. My guess is that Debian did not included the Class 1 certificate for the reason that it is free and thus is less secure than the for-pay certificates.

References

]]>
http://www.mueller-public.de/2016/10/startssl-free-class-1-certificate-with-java-keystore/feed/ 0
Setup and Configure Zsh, Bash-Completion, Autojump http://www.mueller-public.de/2016/05/setup-and-configure-zsh-bash-completion-autojump/ http://www.mueller-public.de/2016/05/setup-and-configure-zsh-bash-completion-autojump/#comments Wed, 25 May 2016 11:51:40 +0000 http://www.mueller-public.de/?p=705 Zsh is an interactive shell that is mostly compatible with Bash, Bash-Completion enhances the shell with automatic and programmable commands and arguments completions. It works also on Windows and Mac OS X systems because it depends only on the Bash shell; Autojump stores the last visited directories and allows for fast navigation in the file…

]]>


Setup and Configure Zsh, Bash-Completion, Autojump

  • Zsh is an interactive shell that is mostly compatible with Bash,
  • Bash-Completion enhances the shell with automatic and programmable commands and arguments completions. It works also on Windows and Mac OS X systems because it depends only on the Bash shell;
  • Autojump stores the last visited directories and allows for fast navigation in the file system. It works also on Windows and Mac OS X systems because it uses Python.

All three together are really useful tools that are going to increase the productivity of any console-user immensely, although the Zsh shell should only by used for the console and not for scripts, because of portability and interoperability issues. This article will describe how install and configure those tools on a Debian Jessie system (but it should be the same on any other GNU/Linux system). Basically, everything is contained in the Makefile and the simple command make will install and configure those tools. The make targets will use optional environment variables and arguments to customize the tools.

Usage

Download the archive from Github devent/zsh-setup, unpack the archive somewhere, open a console inside the directory where the archive was unpacked and run make.

wget https://github.com/devent/zsh-setup/archive/master.zip -O zsh-setup.zip
unzip zsh-setup.zip
cd zsh-setup-master
make

The following files and directories are created by the default make target.

  • /etc/sudoers.d/08proxy
  • /etc/apt/apt.conf.d/08proxy
  • /etc/profile.d/proxy.sh only if any proxy environment variables were set;
  • .user_rc the file is not removed or changed and is suppose to have user specific aliases and functions;
  • .user_zshrc the file is not removed or changed and is suppose to have user specific Zsh settings;
  • .zshrc
  • /opt/oh-my-zsh

Environment Variables

  • http_proxy
  • https_proxy
  • ftp_proxy
  • no_proxy, if those environment variables are present, the make targets will configure sudoers, apt and Zsh to use the environment variables.

http_proxy="http://myproxy:8080"; https_proxy="http://myproxy:8080"; ftp_proxy="http://myproxy:8080"; no_proxy="localhost,127.0.0.1"; make

Arguments

  • WORK sets the work directory, defaults to the user home directory;
  • THEME sets the oh-my-zsh theme, defaults to “gentoo”;
  • PLUGINS sets the plugins to load, defaults to “”;
  • REMOTE_EDITOR sets the remote editor to use, defaults to “emacs”;
  • LOCAL_EDITOR sets the local editor to use, defaults to “emacs”;

Additional Targets

  • clean removes the generated files:
    • /etc/sudoers.d/08proxy
    • /etc/apt/apt.conf.d/08proxy
    • /etc/profile.d/proxy.sh
    • .zshrc

Test

Using Vagrant a test system can be installed in VirtualBox to test and preview the tools. The target will install Debian Jessie image in VirtualBox, run make and enter the system via ssh. The proxy environment variables mentioned above are passed to the system. After the user reviewed and exit the system, the system is removed.

make test

License

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

]]>
http://www.mueller-public.de/2016/05/setup-and-configure-zsh-bash-completion-autojump/feed/ 0
Productive Windows for Developers http://www.mueller-public.de/2016/05/productive-windows-for-developers/ http://www.mueller-public.de/2016/05/productive-windows-for-developers/#comments Tue, 17 May 2016 10:21:55 +0000 http://www.mueller-public.de/?p=626 translate to: This article will describe how to change Windows into a productive environment to software developers. The changes here described are not for everyone but primarily for software developers. As a software developer I have special needs to make me as productive as possible and on a GNU/Linux System those changes are already available…

]]>

translate to:
Deutsch Русский

Windows 7

This article will describe how to change Windows into a productive environment to software developers. The changes here described are not for everyone but primarily for software developers. As a software developer I have special needs to make me as productive as possible and on a GNU/Linux System those changes are already available but on Windows those changes are hidden and are only available with some additional software. Those changes below the article will describe, and the difficulty level will also be described as in “+” for easy, as in “++” for medium and as in “+++” for hard,

  • deactivate all animations (+);
  • deactivate transparencies (+);
  • change keyboard to English layout (+);
  • change the caps-lock key to the control-key (++);
  • customize keyboard (+);
  • customize the task bar (+);
  • scroll window under the mouse cursor (++);
  • clipboard with a history and context menu (++);
  • show known file extensions (+);
  • install software (++);
  • install Debian in VirtualBox (+++);

Deactivate All Animations (+)

Animations are nice to look at but they do slow down the work-flow simply because the user have to wait for the animation to finish. Animations are a distraction with no benefit, too. We can simple deactivate all animations in Windows via the system configuration.

  • Deutsch: Systemsteuerung\Alle Systemsteuerungselemente, “anima” suchen, Unnötige Animationen deaktivieren,
    • [x] Alle nicht erforderlichen Animationen deaktivieren.

Systemsteuerung\Alle Systemsteuerungselemente\Center für erleichterte Bedienung\Erkennen von Bildschirmobjekten erleichtern

2. Systemsteuerung\Alle Systemsteuerungselemente\Center für erleichterte Bedienung\Erkennen von Bildschirmobjekten erleichtern

Systemsteuerung\Alle Systemsteuerungselemente, "anima" suchen, Unnötige Animationen deaktivieren.

1. Systemsteuerung\Alle Systemsteuerungselemente, “anima” suchen, Unnötige Animationen deaktivieren.


Deactivate Transparencies (+)

Like the animations, transparencies are a distraction and offer no real benefit and we should deactivate them.

  • Deutsch: Systemsteuerung\Alle Systemsteuerungselemente, “anpasss” suchen,
    • Anpassung,
      • Windows 7-Basis auswählen.

Windows 7-Basis auswählen.

2. Windows 7-Basis auswählen.

Systemsteuerung\Alle Systemsteuerungselemente, "anpasss" suchen, Anpassung,

1. Systemsteuerung\Alle Systemsteuerungselemente, “anpasss” suchen, Anpassung,


Change Keyboard to English Layout (+)

As a software developer the English layout is beneficial because the different parenthesis “()[]<>{}” and the semicolon “;” are very easy accessible. We can of course leave the native keyboard layout in place and we can switch to it by pressing Alt+Shift, but our main layout should be English.

  • Deutsch: Systemsteuerung\Alle Systemsteuerungselemente, “region” suchen,
    • Region und Sprache
      • Tastaturen und Sprache
        • Tastaturen ändern…
          • Hinzufügen…, Englisch (USA) – US Tastatur hinzufügen,
          • Standardeingabesprache, Englisch (USA) – US auswählen.

Tastaturen und Sprache, Tastaturen ändern...

2. Tastaturen und Sprache, Tastaturen ändern…

Systemsteuerung\Alle Systemsteuerungselemente, "region" suchen,

1. Systemsteuerung\Alle Systemsteuerungselemente, “region” suchen,

Hinzufügen..., Englisch (USA) - US Tastatur hinzufügen,

3. Hinzufügen…, Englisch (USA) – US Tastatur hinzufügen,


Change The Caps-Lock Key to the Control-Key (++)

The normal keyboard have a Caps-Lock key that can be used to enter CAPITALIZED WORDS. As a software developer (and actually for all other people) this function of the Caps-Lock key is rather useless. We can map the Caps-Lock key to the Control (Ctrl) key to have an easy access to the most common key shortcuts like Ctrl+Q, Ctrl+A, Ctrl+S, Ctrl+W, etc. Windows can’t do that in any graphical system settings, but we must change the Windows registry. Likely, there are already predefined registry hacks for download to do exactly that.

The web site above contains the registry files to disable or to re-map the Caps-Lock key to the Shift or to the Control key. The registry file needs to be downloaded and as the administrator imported into the Windows registry.

Change The Caps-Lock Key to the Control-Key

Change The Caps-Lock Key to the Control-Key


Customize Keyboard (+)

This is just to increase the speed of the keyboard. For some reason, the delay between keys is always increased to an unbearable delay.

  • Deutsch: Systemsteuerung\Alle Systemsteuerungselemente, “keyb” suchen,
    • Tastatur,
      • Geschwindingkeit, Verzögerung auf Kurz stellen.

2. Geschwindingkeit, Verzögerung auf Kurz stellen.

2. Geschwindingkeit, Verzögerung auf Kurz stellen.

1. Systemsteuerung\Alle Systemsteuerungselemente, "keyb" suchen.

1. Systemsteuerung\Alle Systemsteuerungselemente, “keyb” suchen.


Customize the Task Bar (+)

The default task bar is not really usable because it shows only the symbols and groups tasks/applications together. The solution is to deactivate the grouping of applications.

  • Deutsch: Rechts auf die Taskbar klicken,
    • Schaltfläche der Taskleiste: Nie gruppieren,
      • Infobereich: Anpassen…
        • [ ] Immer alle Symbole und Benachrichtigungen auf der Taskleiste anzeigen.

2. [] Immer alle Symbole und Benachrichtigungen auf der Taskleiste anzeigen.

2. [] Immer alle Symbole und Benachrichtigungen auf der Taskleiste anzeigen.

1. Schaltfläche der Taskleiste: Nie gruppieren.

1. Schaltfläche der Taskleiste: Nie gruppieren.


Scroll Window Under the Mouse Cursor (++)

One difference between the desktop of a Linux system and a Windows system is how the mouse can be used, in Linux the mouse can scroll any window under the cursor regardless if the window is currently focused or not. That helps immense if multiple windows at the same time are used because there is no need anymore to click on the window that should be scrolled. Windows does not support this function, but luckily an additional application can add this functionality.

KatMouse developed by Eduard Hiti can be downloaded and supports Windows 7 and later. It is an application that can be accessed from the tray icon in the task bar and doesn’t need any configuration.


The prime purpose of the KatMouse utility is to enhance the functionality of mice with a scroll wheel, offering “universal” scrolling: moving the mouse wheel will scroll the window directly beneath the mouse cursor (not the one with the keyboard focus, which is default on Windows). This is a major increase in the usefullness of the mouse wheel.

Another (optional) feature involves the wheel button. Since the wheel button is not consistently used in Windows, KatMouse can use it for a kind of task switching: with a click of the wheel button you can push a window to the buttom of the stack of windows that is your desktop, making a recovered window the active window.

KatMouse

Katmouse Tray Icon

Katmouse Tray Icon


Clipboard With a History and Context Menu (++)

A clipboard with a history is very useful for a software developer and also for a office user. Instead of just replacing the text of the clipboard, a history is maintained so that previous copied text can be retrieved and put in the clipboard. Furthermore, a context menu will show the history at the current position of the mouse cursor and a search input field will allow to search the history for a text.

Windows does not have such functionality, but there are multiple applications that can add such a clipboard. One such tool is Ditto It is even possible to assign the Win key to show the context menu. I’m always assign the keyboard shortcut Win+V to show the context menu. Ditto can be configured from the tray icon in the task bar.


Ditto is an extension to the standard windows clipboard. It saves each item placed on the clipboard allowing you access to any of those items at a later time. Ditto allows you to save any type of information that can be put on the clipboard, text, images, html, custom formats.
Ditto

Ditto Tastaturkürzel

Ditto Tastaturkürzel

Ditto Tray Icon

Ditto Tray Icon

Ditto Context-Menu

Ditto Context-Menu


Show Known File Extensions (+)

Since Windows XP Microsoft decided to hide the file extensions from the user, which caused lots of trouble with malware and viruses that named the files something like “picture.jpg.exe” so that Windows will hide the “.exe” extension and the user is left in the belief that the file is a picture and not an executable. As a software developer this is also annoying because many files do not have any extension like “Makefile”, “README”, etc. and it is not possible in the file manager to create such files. Luckily we can change the behavior.

  • Deutsch: Systemsteuerung\Alle Systemsteuerungselemente, “file” suchen,
  • Ordneroptionen
    • [ ] Erweiterungen bei bekannten Dateitypen ausblenden.

2. [ ] Erweiterungen bei bekannten Dateitypen ausblenden.

2. [ ] Erweiterungen bei bekannten Dateitypen ausblenden.

1. Systemsteuerung\Alle Systemsteuerungselemente, "file" suchen.

1. Systemsteuerung\Alle Systemsteuerungselemente, “file” suchen.


Install Software (++)

Here is an incomplete list of useful software for Windows.


Install Debian in VirtualBox (+++)

Of course the best system and environment for software developers is GNU/Linux and KDE, and we can install GNU/Linux in Windows by using VirtualBox. I prefer Debian Jessie with KDE as the desktop environment.

VirtualBox

VirtualBox

VirtualBox Guest Additions

We need the Guest Additions to have the best experience and have scaled and seamless mode available.

  • https://www.virtualbox.org/manual/ch04.html
  • dkms
  • linux-headers-3.16.0-4-amd64

Additional Packages

  • git
  • yakuake
  • gtk2-engines-oxygen
  • gtk3-engines-oxygen
  • kde-config-gtk-style
  • zsh
  • autojump
]]>
http://www.mueller-public.de/2016/05/productive-windows-for-developers/feed/ 0
Start New X Session Under GNU/Linux http://www.mueller-public.de/2016/04/start-new-x-session-under-gnulinux/ http://www.mueller-public.de/2016/04/start-new-x-session-under-gnulinux/#comments Sat, 30 Apr 2016 18:01:27 +0000 http://www.mueller-public.de/?p=606 The X server under GNU/Linux is responsible for displaying the graphical user interface and the desktop environment. The X server is a separate client application that is not inside the kernel, which is different from the model of Microsoft Windows. Multiple X sessions can be started under GNU/Linux under which different desktop environment can be…

]]>

X.Org_Logo https://en.opensuse.org/File:X.Org_Logo.png

X.Org_Logo https://en.opensuse.org/File:X.Org_Logo.png

The X server under GNU/Linux is responsible for displaying the graphical user interface and the desktop environment. The X server is a separate client application that is not inside the kernel, which is different from the model of Microsoft Windows. Multiple X sessions can be started under GNU/Linux under which different desktop environment can be started and the graphical applications are isolated from each other.

What is the advantage of starting a new X session? A new X session can start applications that will not interfere with the applications already running on the original X session, that is useful to run either games, video, music or other applications that need the whole desktop to run. One example are automated graphical user interface tests like Java FEST or AssertJ Swing that are based on the Java Robot API. The tests are usually taking control of the mouse and keyboard to simulate user input and thus the computer can’t be used during the tests. One option is to setup a server to run those tests, aka a continues integration server. But if such a server is not available, a new X session can offer the solution.

X Session Script

A new X session can be started from the command line by using the startx command. We will use a simple script to setup the screen resolution and start the lightweight desktop environment OpenBox

#!/bin/bash 
#
compton -b --backend xrender --vsync opengl & 
xrandr --output HDMI1 --auto --output LVDS1 --off &
exec '/usr/bin/openbox'

  • compton will enable vsync, which is useful for games;
  • xrandr will change the output and screen resolution to the main monitor;
  • exec will start the desktop environment, but can also be any other application.

After the startx-openbox.sh was created, we can now start a new X session with Openbox.

$ startx ./startx-openbox.sh


X.Org X Server 1.16.4
Release Date: 2014-12-20
X Protocol Version 11, Revision 0
Build Operating System: Linux 3.16.0-4-amd64 x86_64 Debian
Current Operating System: Linux emvostro 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2 (2016-04-08) x86_64
Kernel command line: BOOT_IMAGE=/vmlinuz-3.16.0-4-amd64 root=/dev/mapper/linux-debian--root ro initrd=/install/gtk/initrd.gz quiet
Build Date: 11 February 2015  12:32:02AM
xorg-server 2:1.16.4-1 (http://www.debian.org/support) 
Current version of pixman: 0.32.6
        Before reporting problems, check http://wiki.x.org
        to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.1.log", Time: Fri Apr 29 23:59:49 2016
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
(II) AIGLX: Suspending AIGLX clients for VT switch
(II) AIGLX: Suspending AIGLX clients for VT switch
(II) AIGLX: Suspending AIGLX clients for VT switch
(II) AIGLX: Suspending AIGLX clients for VT switch

If the command startx returns with the error that the user is not authorized to run the X server (see below) then the configuration in the /etc/X11/Xwrapper.config file must be changed to allow other users than root to run the X server.

X: user not authorized to run the X server, aborting.

To change the configuration, either the file /etc/X11/Xwrapper.config can directly be changed by modifying the value of allowed_users=anybody, or the command dpkg-reconfigure x11-common can be user.

# dpkg-reconfigure x11-common

dpkg-reconfigure x11-common

dpkg-reconfigure x11-common

Switching Between Sessions

The newly started X session is available on one of the virtual terminals that can be switched via the Ctrl+Alt+F1...F12 keys, i.e. Ctrl+Alt+F1 the first virtual terminal, Ctrl+Alt+F2 the second, etc. On my Debian Jessie system the new X session is on the 2. virtual terminal and the original X session is on the 7. virtual terminal. After the X session is started, Openbox is available. A right click on the empty desktop will show the main menu and a terminal can be started. Inside the Openbox, the games, applications or the tests can be run and the user is free to return to the original desktop via Ctrl+Alt+F7 key.

Openbox Menu

Openbox Menu

Sources

]]>
http://www.mueller-public.de/2016/04/start-new-x-session-under-gnulinux/feed/ 0
Compress Pdf files for email http://www.mueller-public.de/2016/04/compress-pdf-files-for-email/ http://www.mueller-public.de/2016/04/compress-pdf-files-for-email/#comments Wed, 06 Apr 2016 09:56:49 +0000 http://www.mueller-public.de/?p=597 From Latex generated Pdf files that contain pictures are usually very large, for example, my résumé that contains my profile picture and pictures of my certificates is about 4.0 MByes big. That size is usually too large to send per email for an online job application. The solution is obviously to compress the Pdf to…

]]>

From Latex generated Pdf files that contain pictures are usually very large, for example, my résumé that contains my profile picture and pictures of my certificates is about 4.0 MByes big. That size is usually too large to send per email for an online job application. The solution is obviously to compress the Pdf to an acceptable size. But it is considered bad practice if we use Zip or Tar.gz archives, because then the receiver is expected to decompress my application first. Not everyone is fluent in computer and it’s also just an extra step for the application receiver. Office applications like LibreOffice, OpenOffice, Microsoft Office, etc. can usually compress the pictures before creating the Pdf. So, how can we do the same with Latex.

We can use the gs Ghostscript command, that is available on Linux, to compress a Pdf file for different image qualities and DPI. Those below are the available quality settings.

-dPDFSETTINGS=/screen   (screen-view-only quality, 72 dpi images)
-dPDFSETTINGS=/ebook    (low quality, 150 dpi images)
-dPDFSETTINGS=/printer  (high quality, 300 dpi images)
-dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs)
-dPDFSETTINGS=/default  (almost identical to /screen)

We can wrap that in a nice Bash script and also in a make file script so we can easily compress the generated résumé files to acceptable sizes. Furthermore, we can use the pdftk command to keep the Pdf meta data, like title, author, etc. because plain gs will generate a new Pdf file with new meta data.

With compress-pdf.sh and makefile in the same directory as the Pdf files we have now two commands available.

  • make compress will compress all of the résumé files. The compressed files will have the _print postfix attached;
  • make bewerbung will compress all only the application letter. The compressed file will have the _print postfix attached.

Alternatives

  • pdfsizeopt is a project on Github that compresses Pdf files.

compress-pdf.sh

#!/bin/bash
INPUTPDF="$1"
OUTPUTPDF="$2"
TMPPDF=$(mktemp)
METADATA=$(mktemp)

# save metadata
pdftk "$INPUTPDF" dump_data_utf8 > "$METADATA"

# compress
gs                       \
    -q                     \
    -sOutputFile="$TMPPDF" \
    -sDEVICE=pdfwrite      \
    -dNOPAUSE              \
    -dBATCH                \
    -dPDFSETTINGS=/ebook   \
    "$INPUTPDF"

# restore metadata
pdftk "$TMPPDF" update_info_utf8 "$METADATA" output "$OUTPUTPDF"

# clean up
rm -f "$TMPPDF" "$METADATA"

makefile

OUTPUTS = Erwin-Mueller-Lebenslauf-2006.pdf \
	Erwin-Mueller-Lebenslauf-Beraterprofil-Projektliste-Zeugnisse-2006.pdf \
	Erwin-Mueller-Lebenslauf-Beraterprofil-Projektliste-2006.pdf \
	Erwin-Mueller-Lebenslauf-Zeugnisse-2006.pdf \
	Erwin-Mueller-Zeugnisse-2006.pdf

BEWERBUNG = embewerbung-r1.pdf

compress: $(OUTPUTS)
	        for i in $(OUTPUTS); do \
			outputFile="`basename $$i .pdf`_print.pdf";\
			inputFile="$$i";\
			echo -n "$$outputFile..."; \
			./compress-pdf.sh "$$inputFile" "$$outputFile"; \
			echo "done"; \
		done

bewerbung: $(BEWERBUNG)
	        for i in $(BEWERBUNG); do \
			outputFile="`basename $$i .pdf`_print.pdf";\
			inputFile="$$i";\
			echo -n "$$outputFile..."; \
			./compress-pdf.sh "$$inputFile" "$$outputFile"; \
			echo "done"; \
		done

Sources

  • http://tex.stackexchange.com/questions/18987/how-to-make-the-pdfs-produced-by-pdflatex-smaller
  • http://tex.stackexchange.com/questions/14429/pdftex-reduce-pdf-size-reduce-image-quality
]]>
http://www.mueller-public.de/2016/04/compress-pdf-files-for-email/feed/ 0
Redfox Plot http://www.mueller-public.de/2016/02/redfox-plot/ http://www.mueller-public.de/2016/02/redfox-plot/#comments Wed, 17 Feb 2016 15:24:19 +0000 http://www.mueller-public.de/?p=545 Downloads Redfox Plot User Manual Introduction Gnuplot is a very popular command-line application that can plot two- and three-dimensional plots of data and data fits. It is mostly used in the scientific community for publication-quality graphics and education. It runs on all popular computer systems, like GNU/Linux, Unix, Microsoft Windows, Mac OS X. It uses…

]]>

redfoxplot_title_reflection_1_en

Downloads

Introduction

Gnuplot is a very popular command-line application that can plot two- and three-dimensional plots of data and data fits. It is mostly used in the scientific community for publication-quality graphics and education. It runs on all popular computer systems, like GNU/Linux, Unix, Microsoft Windows, Mac OS X. It uses a C like syntax to setup plot options, like the title and the axis ranges, load the data and plot the data. The distinct feature is the many options to export the plotted data, for example as Png, Svg, but also as LaTeX source.

gnuplot_example_layout_4_en

gnuplot_example_mgr_8_en

gnuplot_example_polar_9_en

gnuplot_example_simple_1_en

gnuplot_example_surface1_16_en

The limitations of Gnuplot are twofold. Firstly, Gnuplot have only three possible data sources.

  • from text file;
  • from binary file;
  • read from standard input;

The text file is expected have a simple comma separated values (CSV) format for the columns and rows, the binary file is platform dependent and contains the values as a matrix of rows and columns. Those limitations are tolerated in the scientific community for publication-quality graphics and education, but are a hindrance for average users. The average user is using more user friendly spreadsheet application like Excel, OpenOffice and LibreOffice and is using spreadsheet file formats like XLS, XLSX and ODS. Secondly, as a command line application Gnuplot have no graphical user interface to easy and fast create basic plots.

The Redfox Plot project is a graphical user interface for Gnuplot that aims to remedy both of the limitations mentioned above. It will provide easy access to spreadsheet file formats, databases and calculated data and provide users with the option to create common plot types easy and fast like in spreadsheet applications. Further, it will allow users to leverage a high level template engine and programming language to generate complex Gnuplot scripts.

set title "Simple Plots" font ",20"
set key left box
set samples 50
set style data points
plot [-10:10] sin(x),atan(x),cos(atan(x))

Vision of the Solution

Vision Statement

The Redfox Plot will give a graphical frontend for Gnuplot to allow the average users to create plots easy and fast, and allows use of spreadsheet file formats, databases and calculated data. Redfox Plot is aiming to broaden the user base of Gnuplot to the average user.

Major Features

F1. Setup Assistant,

(also known as a wizard) to open a spreadsheet file, database or calculated data to be used as a data source, to set up the plots and plot options;

F2. Usage of Spreadsheet File Formats,

opens OpenDocument ODS and Microsoft Excel XSL and XSLT file formats to provide the plot data;

F3. Load Data from Database,

connect to a database via JDBC and retrrieve the data with a select statement;

F4. Calculated Data,

use high level programming language for numerical computations, like Octave or MATLAB, to provide the plot data;

F5. Template Engine,

use a template engine like StringTemplate to generate the Gnuplot script;

F6. General Purpose Programming Language,

provide the power of a general purpose programming language to generate the Gnuplot script;

Dependencies

The Redfox Plot relies on the following technologies and dependencies.

D1. Java Swing,

the underlying technology of the project;

D2. Gnuplot,

the underlying technology to plot the data;

D3. JDBC,

to connect to and retrieve data from a database;

D4. jOpenDocument,

to load OpenDocument spreadsheet files;

D5. SVG-Salamander,

to show a preview of the plot;

Related Projects

There are many projects that use Gnuplot to plot data, like GNU Octave and statist, but there are not many graphical frontends to Gnuplot.

JGNUplot

jgnuplot-2

is a Java based graphical frontend to Gnuplot is JGNUplot with the latest update was from 2013-04-16. JGNUplot is basically a graphical user interface that exposes the most used Gnuplot script statements to the user and thus have the same limitations as Gnuplot itself.

]]>
http://www.mueller-public.de/2016/02/redfox-plot/feed/ 0
Simple REST Library http://www.mueller-public.de/2016/02/simple-rest-library/ http://www.mueller-public.de/2016/02/simple-rest-library/#comments Tue, 02 Feb 2016 14:22:11 +0000 http://www.mueller-public.de/?p=567 Update 28/02/2016 Introduction The library provides a high level API to the REST interfaces of various services. simpleREST Documentation Source code git@anrisoftware.com:simplerest.git Source code git@github.com:devent/simplerest.git Roadmap Issues License The simpleREST library is released under the GNU Lesser General Public License LGPLv3 license Owncloud OCS Overview Report Download Access to the Owncloud OCS REST API functions,…

]]>

simpelrest-logo
  • Update 28/02/2016

Introduction

The library provides a high level API to the REST interfaces of various services.


License

The simpleREST library is released under the GNU Lesser General Public License LGPLv3 license

Owncloud OCS

Overview

Access to the Owncloud OCS REST API functions,

status,
requests the status of the Owncloud server;
upload,
uploads a file to the Owncloud server;
shares,
retrieves information about shares;
create share,
creates a new share;

OwncloudStatus

Requests the status of the Owncloud server. Use the factory OwncloudOcsStatusFactory to create the request and call the call() method to do the request. The factory require the following arguments.

  • OwncloudOcsStatusFactory#create(OwncloudAccount account)
  • OwncloudOcsStatusFactory#create(OwncloudAccount account,CloseableHttpClient httpClient)
account,
the Owncloud account;
httpClient,
optionally, the pooled client;

DefaultOwncloudAccountFactory accountFactory;
account = accountFactory.create(new URI(account))
OwncloudOcsStatusFactory statusFactory;
status = statusFactory.create(account);
status.call();
status.getInstalled();

DefaultOwncloudAccountFactory accountFactory;
account = accountFactory.create(new URI(account))
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
CloseableHttpClient httpclient = HttpClients.custom().setConnectionManager(cm).build();

public void run() {
     OwncloudOcsStatusFactory statusFactory;
     status = statusFactory.create(account, httpclient);
     status.call();
     status.getInstalled()
}

On success, the following information is returned.

getInstalled(),
true if the server is installed;
getVersionString(),
the version of the server;
getVersion(),
the version of the server;
getEdition(),
the edition of the server.

OwncloudUploadFile

Use the factory OwncloudOcsUploadFileFactory to create the request and call the call() method to do the request to upload the file. The factory require the following arguments.

  • OwncloudOcsUploadFileFactory#create(OwncloudAccount account, File file, String remotePath,ContentType contentType)
  • OwncloudOcsUploadFileFactory#create(OwncloudAccount account, File file, String remotePath,ContentType contentType, CloseableHttpClient httpClient)
account,
the Owncloud account;
file,
the file to upload;
remotePath
the destination path;
contentType
the content type of the file;
httpClient,
optionally, the pooled client;

Optionally the following parameters can be set.

setRequiredEtag()
sets the e-tag;

DefaultOwncloudAccountFactory accountFactory;
account = accountFactory.create(new URI(account))
OwncloudOcsUploadFileFactory uploadFileFactory;
OwncloudUploadFile upload;
file = new File("test.txt");
remotePath = "Public/test.txt";
upload = uploadFileFactory.create(account, file, remotePath, ContentType.create('text/plain', 'UTF-8'))
upload.call();

DefaultOwncloudAccountFactory accountFactory;
account = accountFactory.create(new URI(account))
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
CloseableHttpClient httpclient = HttpClients.custom().setConnectionManager(cm).build();

public void run() {
     OwncloudOcsUploadFileFactory uploadFileFactory;
     OwncloudUploadFile upload;
     file = new File("test.txt");
     remotePath = "Public/test.txt";
     upload = uploadFileFactory.create(account, file, remotePath, ContentType.create('text/plain', 'UTF-8'), httpclient)
     upload.call();
}

OwncloudShares

Use the factory OwncloudOcsSharesFactory to create the request and call the call() method to do the request to retrieve information about shares. The factory require the following arguments.

  • OwncloudOcsSharesFactory#create(OwncloudAccount account)
  • OwncloudOcsSharesFactory#create(OwncloudAccount account, CloseableHttpClient httpClient)
account,
the Owncloud account;
httpClient,
optionally, the pooled client;

Optionally the following parameters can be set.

setPath()
sets path of the folder or file;
setReshares()
sets to true to return re-shares;
setSubfiles()
sets to true to return sub-files;

DefaultOwncloudAccountFactory accountFactory;
account = accountFactory.create(new URI(account))
OwncloudOcsSharesFactory sharesFactory;
OwncloudOcsShares shares = sharesFactory.create(account);
SharesMessage message = shares.call();

DefaultOwncloudAccountFactory accountFactory;
account = accountFactory.create(new URI(account))
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
CloseableHttpClient httpclient = HttpClients.custom().setConnectionManager(cm).build();

public void run() {
     OwncloudOcsSharesFactory sharesFactory;
     OwncloudOcsShares shares = sharesFactory.create(account, httpclient);
     SharesMessage message = shares.call();
}

On success, the SharesMessage information is returned containing the ShareData for each share.

OwncloudCreateShare

Use the factory OwncloudOcsCreateShareFactory to create the request and call the call() method to do the request and to create the share. The factory require the following arguments.

  • OwncloudOcsCreateShareFactory#create(OwncloudAccount account, String path, ShareType type, String shareWith, Boolean publicUpload, String password, Integer permissions)
  • OwncloudOcsCreateShareFactory#create(OwncloudAccount account, String path, ShareType type, String shareWith, Boolean publicUpload, String password, Integer permissions, CloseableHttpClient httpClient)
account,
the Owncloud account;
path,
the path to the folder or file;
type,
type of the share;
shareWith,
the user or group name, can be null;
publicUpload,
set to true to allow public upload, can be null;
password,
set the password of the share, can be null;
permissions,
the permissions of the share, can be null;
httpClient,
optionally, the pooled client;

DefaultOwncloudAccountFactory accountFactory;
account = accountFactory.create(new URI(account))
OwncloudOcsCreateShareFactory createShareFactory;
String path = "Public/test.txt";
ShareType type = ShareType.link;
OwncloudOcsCreateShare share = createShareFactory.create(account, path, type, shareWith, publicUpload, password, permissions);
ShareResultMessage message = share.call();

DefaultOwncloudAccountFactory accountFactory;
account = accountFactory.create(new URI(account))
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
CloseableHttpClient httpclient = HttpClients.custom().setConnectionManager(cm).build();

public void run() {
     OwncloudOcsCreateShareFactory createShareFactory;
     String path = "Public/test.txt";
     ShareType type = ShareType.link;
     OwncloudOcsCreateShare share = createShareFactory.create(account, path, type, shareWith, publicUpload, password, permissions, httpclient);
     ShareResultMessage message = share.call();
}

On success, the ShareResultMessage information is returned containing the ShareResult of the share.

]]>
http://www.mueller-public.de/2016/02/simple-rest-library/feed/ 0
Planetary Systems Compared with Our Solar System http://www.mueller-public.de/2015/07/planetary-systems-compared-with-our-solar-system/ http://www.mueller-public.de/2015/07/planetary-systems-compared-with-our-solar-system/#comments Sat, 04 Jul 2015 23:12:09 +0000 http://www.mueller-public.de/?p=501 There are over 2000 confirmed discovered exoplanets, that is, planets that orbit other star systems than ours. I was researching the exoplanetary systems that are available in the various open catalogs, like the listed below. The Open Exoplanet Catalogue The Exoplanet Orbit Database The Extrasolar Planets Encyclopaedia NASA Exoplanet Archive The article compares the semi-major…

]]>

There are over 2000 confirmed discovered exoplanets, that is, planets that orbit other star systems than ours. I was researching the exoplanetary systems that are available in the various open catalogs, like the listed below.

The article compares the semi-major axis of the discovered planets with the orbits of our solar system planets. Depicted are the orbits of the solar system planets, their names, masses and radii are noted in the legend bottom left, and the semi-major axis of the discovered planets, their names, masses and radii (if known) are noted in the upper right corner. To help identifying the systems, the smaller system have a gray circle as background. All of the graphs have the same scale, from -70 to 70 AU.

Gliese 667 C

Gliese 667 [openexoplanetcatalogue.com]


“The planetary system Gliese 667 hosts at least 7 planets. Note that the system is a multiple star system. It hosts at least 3 stellar components.”


The star Gliese 667 C is about 22 ly away. All the planets listed are closer to the host star than the Earth. The method of discovery was the radial-velocity method, that explains why only the closest planets are discovered. The system Gliese 667 have probably more planets in a more Jupiter like orbits.

Sol Gliese 667 C

Sol Gliese 667 C

HD 10180

HD 10180 [openexoplanetcatalogue.com]


“The planetary system HD 10180 hosts at least 9 planets. […] The age of the star is 7.3 Gigayears.”


The star HD 10180 is about 128 ly away. All the planets listed are closer to the host star than Jupiter. The method of discovery was the radial-velocity method, that explains why only the closest planets are discovered. The system HD 10180 have probably more outer planets.

Sol HD 10180

Sol HD 10180

Kepler-90

Kepler-90 [openexoplanetcatalogue.com]


“The planetary system Kepler-90 hosts at least 7 planets.”


The star Kepler-90 is about 2,722 ly away. All the planets listed are closer to the host star than Mars. The method of discovery was the transit photometry method. The system Kepler-90 have probably more outer planets, but the transit period is too long for us to observe (Jupiter have an orbital period of about 12 years and Saturn an orbital period of about 29 years).

Sol Kepler-90

Sol Kepler-90

HR 8799

HR 8799 [openexoplanetcatalogue.com]


“The planetary system HR 8799 hosts at least 4 planets.”


The star HR 8799 is about 39 ly away. The method of discovery was the direct imaging method. Probably we can only see the outer planets because of the method used. Smaller planets would be not visible due to the light of the star. In the graphic the gray background circle indicates the orbit of Neptune, because HR 8799 b’s semi-major axis is 68 AU, way outside of the orbit of Neptune.

Sol HR 8799

Sol HR 8799

47 Uma

47 Uma [openexoplanetcatalogue.com]


“The planetary system 47 Uma hosts at least 3 planets.”


The star 47 Uma is about 46 ly away. The method of discovery was the radial-velocity method. Probably we can only see the outer planets because of the method used. The discovered planets of 47 Uma have Jupter-like masses and thus have a detectable wobble effect on the star. Lighter inner planets would not have a strong wobble effect.

Sol 47 Uma

Sol 47 Uma

HU Aqr

HU Aqr [openexoplanetcatalogue.com]


“The planetary system HU Aqr hosts at least 3 planets. Note that the system is a multiple star system. It hosts at least 2 stellar components.”


The method of discovery was the transit-timing variation method.

Sol HU Aqr

Sol HU Aqr

55 Cancri

55 Cancri [openexoplanetcatalogue.com]


“The planetary system 55 Cancri hosts at least 5 planets. Note that the system is a multiple star system. It hosts at least 2 stellar components.”


The star 55 Cancri is about 40 ly away. The method of discovery for the planets b, c, d and f was the radial-velocity method and the planet 55 Cnc e was discovered via the transit-timing variation method.

Sol 55 Cancri

Sol 55 Cancri

Upsilon Andromedae

Upsilon Andromedae [openexoplanetcatalogue.com]


“The planetary system Upsilon Andromedae hosts at least 4 planets. Note that the system is a multiple star system. It hosts at least 2 stellar components.”


The star Upsilon Andromedae is about 44 ly away. The method of discovery for the planets was the radial-velocity method.

Sol Upsilon Andromedae

Sol Upsilon Andromedae

HD 141399

HD 141399 [openexoplanetcatalogue.com]


“The planetary system HD 141399 hosts at least 4 planets.”


The star HD 141399 is about 118 ly away. The method of discovery for the planets was the radial-velocity method.

Sol HD 141399

Sol HD 141399

Solar System

The graphic bellow shows our solar system, based on the data of the aphelion and perihelion in AU, and the radii of the planets scaled to the radii of Jupiter.

Solar System

Solar System

]]>
http://www.mueller-public.de/2015/07/planetary-systems-compared-with-our-solar-system/feed/ 0
Resources Management Project http://www.mueller-public.de/2015/06/resources-management-project/ http://www.mueller-public.de/2015/06/resources-management-project/#comments Tue, 30 Jun 2015 11:12:02 +0000 http://www.mueller-public.de/?p=438 The project addresses the need for an application to manage text, image and binary resources. Text resources are usually the names and labels of a user interface, image resources hold logos and icons that are used in the user interface, and other images that are presented to the user. Binary resources are arbitrary resources like…

]]>

Natural Resources (Log Processor by David Stanley https://www.flickr.com/photos/davidstanleytravel/6051024483/)

Natural Resources (Log Processor by David Stanley https://www.flickr.com/photos/davidstanleytravel/6051024483/)

The project addresses the need for an application to manage text, image and binary resources. Text resources are usually the names and labels of a user interface, image resources hold logos and icons that are used in the user interface, and other images that are presented to the user. Binary resources are arbitrary resources like music and sounds. Those resources must be available in different contexts and to different parts of the application. Furthermore, different content must be delivered for the same resource identifiers based on the user locale.

Library Position Statement

For Application developers;
The resources management project Is an application programming interface (API) and application library.
That Enabled the management application resources, with the possibility of the same resource identifier returning different resources based on the user locale.

User Description

It is an application programming interface (API) and application library so it targets application developers.

Library Overview

Resources System Context Diagram

Resources System Context Diagram

The resource management library leverages the Java JDK ResourceBundle and in particular the PropertyResourceBundle API to retrieve the resources based on the user locale. It also extends the resource bundle API for caching and to image and binary resources.

The resources project contains those main components:

Features

  • Retrieving resources with a resource identifier;
  • Retrieving binary resources;
  • Retrieving text resources;
  • Retrieving images resources;
  • Retrieving templates resources;
  • Caching of resources;

License GNU Lesser General Public License v3 (LGPL-3)

Copyright 2012-2015 Erwin Müller .

Resources Management Library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with resources-templates. If not, see .

User Manual

All resources (binary, texts, templates and images) follow the same pattern because they all use the same interface and patterns and leverage ResourceBundle of the Java JDK. The resources storage is retrieved using the ResourceBundle#getBundle() method, and stored in the bundle cache. The resource with the specified identifier and locale is then retrieved from the bundle and stored in the resources cache. The resource is then available to the user. If the user requests the same resource, it can be retrieved from the cache.

The default cache is a simple HashMap, but different cache implementations can be added, for example Ehcache.

Binary Resources

Binary resources are generalized binary data resources and can be for example be sound, music or other files.

Resources Binary Class Diagram

Resources Binary Class Diagram

Class Use Case
BinariesFactory Create a new binaries resources bundle
Binaries Retrieve binary resource
BinaryResource Retrieve the binary data from the resource

Binary Resources Use Cases

Binary Resources Use Cases

Use Case: Create a new binaries resources bundle

  • Description

Creates a new binaries resources bundle from a specified resource bundle base name and optional class loader and optional resource bundle control.

  • Preconditions

The resource bundle is created pointing to binary resources;

  • Postconditions

The binaries resources bundle is available;

  • Basic Course of Actions

Under the resources directory, usually src/main/resources should be a resource bundle property file created that have the base name as the file name. That is, if the base name is MyResource, the following properties should be created:

  • MyResource_de_DE.properties
  • MyResource_en_US.properties
  • MyResource_en.properties

The content of those resources bundle properties file should be name := path entries, the name being the identifier of the resource, and the path the path of the resource.

foo = com/anrisoftware/project/resources/binaries/de/foo.wav
bar = com/anrisoftware/project/resources/binaries/de/bar.wav
baz  = com/anrisoftware/project/resources/binaries/de/baz.wav

The binaries resources bundle can then be created with the factory method.

Use Case: Retrieve binary resource

  • Description

Retrieves a binary resource from the binaries resources bundle.

  • Preconditions

The resource bundle is created pointing to binary resources;

  • Postconditions

The binary resource is available;

  • Basic Course of Actions

Use the resource getter method to retrieve the binary resource with the specified name and optionally the specified locale.

Use Case: Retrieve the binary data from the resource

  • Description

Retrieves the binary data from the resource.

  • Preconditions

The binary resources was retrieved;

  • Postconditions

The binary data is available;

  • Basic Course of Actions:

Use the getter method of the binary resource to retrieve the binary data.

Use Case: Discard binary data

  • Description

Discards the binary data from the binary resource, freeing the associated memory.

  • Preconditions

The binary resources was retrieved;

  • Postconditions

The binary data is discarded;

  • Basic Course of Actions

Use the discard method to discard the binary data.

Binary Resources Examples

Full example using the Guice injector method:

public class AppParent {

    public static void doApp() {
		Injector injector = Guice.createInjector(...);
		App app = injector.getInstance(App.class);
    }
}

public class App {

    private BinaryResource fooResource;

    private BinaryResource fooResource;

    private BinaryResource fooResource;

    @Inject
    final setBinaryResources(BinariesFactory factory) {
		Binaries bundle = factory.create("MyResource");
		this.fooResource = bundle.getResource("foo");
		this.barResource = bundle.getResource("bar");
		this.bazResource = bundle.getResource("baz");
    }
    
    public byte[] getFoo() {
		return fooResource.getBinary();
    }
    
    public byte[] getBar() {
		return barResource.getBinary();
    }
    
    public byte[] getBaz() {
		return bazResource.getBinary();
    }
}

Text Resources

Text resources are any kind of text resources and can be for example single words, line or whole block of text.

Resources Texts Class Diagram

Resources Texts Class Diagram

Class Use Case
TextsFactory Create a new texts resources bundle
Texts Retrieve text resource
TextResource Retrieve the text data from the resource

Text Resources Use Cases

Text Resources Use Cases

Use Case: Create a new texts resources bundle

  • Description

Creates a new texts resources bundle from a specified resource bundle base name and optional class loader and optional resource bundle control.

  • Preconditions

The resource bundle is created pointing to text resources;

  • Postconditions

The texts resources bundle is available;

  • Basic Course of Actions

Under the resources directory, usually src/main/resources should be a resource bundle property file created that have the base name as the file name. That is, if the base name is MyResource, the following properties should be created:

  • MyResource_de_DE.properties
  • MyResource_en_US.properties
  • MyResource_en.properties

The content of those resources bundle properties file should be name := path entries, the name being the identifier of the resource, and the path the path of the resource.

foo = com/anrisoftware/project/resources/texts/de/foo.txt
bar = com/anrisoftware/project/resources/texts/de/bar.txt
baz  = com/anrisoftware/project/resources/texts/de/baz.txt

The texts resources bundle can then be created with the factory method.

Use Case: Retrieve text resource

  • Description

Retrieves a text resource from the texts resources bundle.

  • Preconditions

The resource bundle is created pointing to text resources;

  • Postconditions

The text resource is available;

  • Basic Course of Actions

Use the resource getter method to retrieve the text resource with the specified name and optionally the specified locale.

Use Case: Retrieve the text from the resource

  • Description

Retrieves the text from the resource.

  • Preconditions

The text resources was retrieved;

  • Postconditions

The text is available;

  • Basic Course of Actions:

Use the getter method of the text resource to retrieve the text.

Text Resources Examples

Full example using the Guice injector method:

public class AppParent {

    public static void doApp() {
		Injector injector = Guice.createInjector(...);
		App app = injector.getInstance(App.class);
    }
}

public class App {

    private TextResource fooResource;

    private TextResource fooResource;

    private TextResource fooResource;

    @Inject
    final setTextResources(TextsFactory factory) {
		Texts bundle = factory.create("MyResource");
		this.fooResource = bundle.getResource("foo");
		this.barResource = bundle.getResource("bar");
		this.bazResource = bundle.getResource("baz");
    }
    
    public String getFoo() {
		return fooResource.getText();
    }
    
    public String getBar() {
		return barResource.getText();
    }
    
    public String getBaz() {
		return bazResource.getText();
    }
}

Central Text Resources

Since Java Swing action names, mnemonics and accelerator keys are also text resources, the library offers an interface to retrieve those properties from text resources.

Resources Texts Central Class Diagram

Resources Texts Central Class Diagram

Class Use Case
TextsResources Set resources bundles
TextsResources Retrieve the text from the resource
Retrieve action name
Retrieve label mnemonic
Retrieve accelerator key

Text Resources Central Use Cases

Text Resources Central Use Cases

Use Case: Set resources bundles

  • Description

Sets the resources bundles for texts resources, action names texts resources, mnemonic texts resources and accelerator key texts resources.

  • Preconditions

The resource bundles are created pointing to the text resources;

  • Postconditions

The texts are available;

  • Basic Course of Actions

Under the resources directory, usually src/main/resources, should be the resource bundle property files created for the texts resources, the action names texts resources, the mnemonic texts resources and the accelerator key texts resources. The default resource bundle names are Texts, Actions, ActionMnemonics and ActionAccelerators, but the resource bundle names could have the same name.

  • Texts_de_DE.properties
  • Texts_en_US.properties
  • Texts_en.properties
  • Actions_de_DE.properties
  • Actions_en_US.properties
  • Actions_en.properties
  • ActionMnemonics_de_DE.properties
  • ActionMnemonics_en_US.properties
  • ActionMnemonics_en.properties
  • ActionAccelerators_de_DE.properties
  • ActionAccelerators_en_US.properties
  • ActionAccelerators_en.properties

The content of those resources bundle properties file should be name := path entries, the name being the identifier of the resource, and the path the path of the resource.

foo = com/anrisoftware/project/resources/texts/de/foo.txt
bar = com/anrisoftware/project/resources/texts/de/bar.txt
baz  = com/anrisoftware/project/resources/texts/de/baz.txt

foo = com/anrisoftware/project/resources/actions/de/foo.txt
bar = com/anrisoftware/project/resources/actions/de/bar.txt
baz  = com/anrisoftware/project/resources/actions/de/baz.txt

The texts can then be created with the factory method with the specified properties, or just injected in the object.

Central Text Resources Examples

Full example using the Guice injector method:

public class AppParent {

    public static void doApp() {
		Injector injector = Guice.createInjector(...);
		App app = injector.getInstance(App.class);
    }
}

public class App {

	@Inject
	private TextsResources textsResources;

	public App createApp() {
		menuFoo.setAction(textsResources.getAction("foo"));
		menuFoo.setMnemonic(textsResources.getMnemonic("foo"));
		menuFoo.setAccelerator(textsResources.getAccelerator("foo"));
	}
}

Image Resources

Image resources are any kind of image resources and can be for example an icon or an image.

Resources Images Class Diagram

Resources Images Class Diagram

Class Use Case
ImagesFactory Create a new images resources bundle
Images Retrieve image resource
ImageScalingWorker Resize image
ImageResource Retrieve the image data from the resource

Image Resources Use Cases

Image Resources Use Cases

Use Case: Create a new images resources bundle

  • Description

Creates a new images resources bundle from a specified resource bundle base name and optional class loader and optional resource bundle control.

  • Preconditions

The resource bundle is created pointing to image resources;

  • Postconditions

The images resources bundle is available;

  • Basic Course of Actions

Under the resources directory, usually src/main/resources should be a resource bundle property file created that have the base name as the file name. That is, if the base name is MyImages, the following property file should be created:

  • MyImages.properties

The content of the resources bundle property file should be name := path entries, the name being the identifier of the resource, and the path the path of the resource. Images can be stored in multiple resolutions, compatible to mipmaps, that is, pre-calculated, optimized sequences of images. If the image is available in the pre-calculated resolution, the image is returned. Otherwise, the image is resized from the image that is available in the closest resolution. The resolutions are divided into the following sets:

  • xhdp, for extra high resolution,
  • hdp, for high resolution,
  • mdp, for medium resolution,
  • ldp, for low resolution.

The path inside the property file can contain the placeholder %s that is replaced with the resolution set name.

foo = com/anrisoftware/project/resources/images/%s/foo.png
bar = com/anrisoftware/project/resources/images/%s/bar.png
baz  = com/anrisoftware/project/resources/images/%s/baz.png

The images resources bundle can then be created with the factory method.

Use Case: Retrieve image resource

  • Description

Retrieves a image resource from the images resources bundle.

  • Preconditions

The resource bundle is created pointing to image resources;

  • Postconditions

The image resource is available;

  • Basic Course of Actions

Use the resource getter method to retrieve the image resource with the specified name and optionally the specified locale.

Use Case: Retrieve the image from the resource

  • Description

Retrieves the image from the resource.

  • Preconditions

The image resources was retrieved;

  • Postconditions

The image is available;

  • Basic Course of Actions:

Use the getter method of the image resource to retrieve the image.

Image Resources Examples

Full example using the Guice injector method:

public class AppParent {

    public static void doApp() {
		Injector injector = Guice.createInjector(...);
		App app = injector.getInstance(App.class);
    }
}

public class App {

    private ImageResource fooResource;

    private ImageResource fooResource;

    private ImageResource fooResource;

    @Inject
    final setImageResources(ImagesFactory factory) {
		Images bundle = factory.create("MyImages");
		this.fooResource = bundle.getResource("foo");
		this.barResource = bundle.getResource("bar");
		this.bazResource = bundle.getResource("baz");
    }
    
    public Image getFoo() {
		return fooResource.getImage();
    }
    
    public Image getBar() {
		return barResource.getImage();
    }
    
    public Image getBaz() {
		return bazResource.getImage();
    }
}

Template Resources

Template resources are processed with a given data. The processed template is cached and the same text is returned for the same data. Different template engines can be used to parse the template resources.

Resources Templates Class Diagram

Resources Templates Class Diagram

Class Use Case
TemplatesFactory Create a new templates resources bundle
Templates Retrieve template resource
TemplateResource Retrieve the template data from the resource
TemplateResource Invalidate template text

Template Resources Use Cases

Template Resources Use Cases

Use Case: Create a new templates resources bundle

  • Description

Creates a new templates resources bundle from a specified resource bundle base name and optional class loader, optional templates attributes and optional resource bundle control.

  • Preconditions

The resource bundle is created pointing to template resources;

  • Postconditions

The templates resources bundle is available;

  • Basic Course of Actions

Under the resources directory, usually src/main/resources should be a resource bundle property file created that have the base name as the file name. That is, if the base name is MyResource, the following properties should be created:

  • MyResource_de_DE.properties
  • MyResource_en_US.properties
  • MyResource_en.properties

The content of those resources bundle properties file should be name := path entries, the name being the identifier of the resource, and the path the path of the resource.

foo = com/anrisoftware/project/resources/templates/de/foo.stg
bar = com/anrisoftware/project/resources/templates/de/bar.stg
baz  = com/anrisoftware/project/resources/templates/de/baz.stg

The templates resources bundle can then be created with the factory method.

Use Case: Retrieve template resource

  • Description

Retrieves a template resource from the templates resources bundle.

  • Preconditions

The resource bundle is created pointing to template resources;

  • Postconditions

The template resource is available;

  • Basic Course of Actions

Use the resource getter method to retrieve the template resource with the specified name and optionally the specified locale.

Use Case: Retrieve the template text from the resource

  • Description

Retrieves the template text from the resource.

  • Preconditions

The template resource is available;

  • Postconditions

The template is available;

  • Basic Course of Actions:

Use the getter method of the template resource to retrieve the text.

Use Case: Invalidate template text

  • Description

Invalidates the cached text in the template resource.

  • Preconditions

The template resource is available;

  • Postconditions

The template text is invalidated and need to be reparsed by tha template engine;

  • Basic Course of Actions:

Use the invalidate method of the template resource to invalidate the cached text.

Template Resources Examples

Full example using the Guice injector method:

public class AppParent {

    public static void doApp() {
		Injector injector = Guice.createInjector(...);
		App app = injector.getInstance(App.class);
    }
}

public class App {

    private TemplateResource fooResource;

    private TemplateResource fooResource;

    private TemplateResource fooResource;

    @Inject
    final setTemplateResources(TemplatesFactory factory) {
		Templates bundle = factory.create("MyResource");
		this.fooResource = bundle.getResource("foo");
		this.barResource = bundle.getResource("bar");
		this.bazResource = bundle.getResource("baz");
    }
    
    public String getFoo() {
		return fooResource.getText();
    }
    
    public String getBar() {
		return barResource.getText();
    }
    
    public String getBaz() {
		return bazResource.getText();
    }
}

]]>
http://www.mueller-public.de/2015/06/resources-management-project/feed/ 0
POSIX Locale for Java http://www.mueller-public.de/2015/06/posix-locale-for-java/ http://www.mueller-public.de/2015/06/posix-locale-for-java/#comments Wed, 10 Jun 2015 17:01:09 +0000 http://www.mueller-public.de/?p=427 The Locale class in Java is very powerful and useful, but it is different from the locale that is used on POSIX systems. The POSIX locale is described to contain the language, country and the code set, which translates to Java as the Locale class and the Charset class. My globalpomutils-core module offers now in…

]]>

The Locale class in Java is very powerful and useful, but it is different from the locale that is used on POSIX systems. The POSIX locale is described to contain the language, country and the code set, which translates to Java as the Locale class and the Charset class. My globalpomutils-core module offers now in the 2.6 version the class PosixLocale that maps POSIX locale language, country and the code set as a Java class. In addition, the class PosixLocaleFormat can parse the format language[_territory][.codeset] of the given POSIX locale.

Examples

The factory class PosixLocaleFactory can be used to create a new POSIX locale object as described below.

public class Builder {

    public void build() {
        Injector injector = Guice.createInjector(new PosixLocaleModule());
        Foo foo = injector.getInstance(Foo.class);
        PosixLocale locale = foo.getLocale();
    }
}

public class Foo {

    @Inject
    private PosixLocaleFactory factory;

    public PosixLocale getLocale() {
        return factory.create(locale, charset);
    }
}

The POSIX locale can be parsed and formatted via the PosixLocaleFormat class. The PosixLocaleFormatModule provides various factory methods to create the POSIX locale format.

import static com.anrisoftware.globalpom.posixlocale.PosixLocaleFormatModule.getPosixLocaleFormatFactory;

PosixLocaleFormat format = getPosixLocaleFormatFactory();
format.parse(string);
format.format(locale);

]]>
http://www.mueller-public.de/2015/06/posix-locale-for-java/feed/ 0