JavaFX

From BITPlan can4eve Wiki
Revision as of 21:28, 17 July 2019 by Wf (talk | contribs) (→‎javafx install script)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

JavaFx on Raspberry PI

javafx install script

#!/bin/bash
# install javafx on raspberry PI
# WF 2019-01-13
src=/usr/local/src
ext=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/lib/ext
javafx=armv6hf-sdk

#ansi colors
#http://www.csc.uvic.ca/~sae/seng265/fall04/tips/s265s047-tips/bash-using-colors.html
blue='\033[0;34m'
red='\033[0;31m'
green='\033[0;32m' # '\e[1;32m' is too bright for white bg.
endColor='\033[0m'

#
# a colored message 
#   params:
#     1: l_color - the color of the message
#     2: l_msg - the message to display
#
color_msg() {
  local l_color="$1"
  local l_msg="$2"
  echo -e "${l_color}$l_msg${endColor}"
}

#
# show the given error message on stderr and exit
#
#   params:
#     1: l_msg - the error message to display
#
error() {
	  local l_msg="$1"
	    # use ansi red for error
	      color_msg $red "Error:" 1>&2
	        color_msg $red "\t$l_msg" 1>&2
		  exit 1
	  }
#
# error
#
# show the given error message on stderr and exit
#
#   params:
#     1: l_msg - the error message to display
#
error() {
  local l_msg="$1"
  # use ansi red for error
  color_msg $red "Error:" 1>&2
  color_msg $red "\t$l_msg" 1>&2
  exit 1
}

color_msg $blue "Trying to install javafx"
if [ ! -d $ext ]
then
  error "directory $ext does not exists - was expecting a java installation"
fi

if [ ! -d $src ]
then
  error "directory $src is missing - was expecting it"
fi
cd $src 

if [ ! -f $javafx.zip ]
then
  color_msg $blue "downloading $javafx.zip"
  sudo curl -L https://gluonhq.com/download/javafx-embedded-sdk/ -o $javafx.zip
else
  color_msg $green "$javafx.zip already downloaded"
fi

if [ ! -d $javafx ]
then
  color_msg $blue "extracting" $javafx.zip
  sudo unzip $javafx.zip
else
  color_msg $green "$javafx already extracted"
fi

cd $ext
color_msg $blue "creating symlinks"
for path in rt/lib/arm rt/lib/ext/jfxrt.jar lib/javafx-mx.jar lib7JFX rt/lib/jfxswt.jar
do
  from=$src/$javafx/$path
  b=$(basename $from)
  if [ -L $b ]
  then
   color_msg $green "symbolic link $b already exists"
  else
   sudo ln -s $src/$javafx/$path .
  fi
done

Medusa Gauge Library

https://github.com/HanSolo/Medusa/wiki/Gauge-Skins

SwingNode not useable on Raspberry PI

The following code needs Swing and doesn't run properly on a raspberry PI even if JavaFX support is enabled.

/**
   * update the given tab with the given panel
   * 
   * @param tab
   * @param panel
   */
  public void updateTab(Tab tab, JPanel panel) {
    if (panel != null) {
      final SwingNode swingNode = new SwingNode();
      swingNode.setContent(panel);
      tab.setContent(swingNode);
    }
  }

Links