3DViewer: Better 3D for JavaFX

JavaFX has long had basic 3D capabilities, although you might not guess it as some outdated package descriptions still only speak of “two-dimensional geometry.” Oracle offers an online tutorial for JavaFX 3D, and JavaFX by Example devotes a chapter to it. Here’s a brief overview: Package javafx.geometry defines a 3D bounding box and a fairly … Continue reading “3DViewer: Better 3D for JavaFX”

Programming .NET without Visual Studio

Back in 2013 I wrote about Programming .NET 4.5 without VS2012. The reason was that Microsoft had yanked its free compilers from the free Windows SDK, yet Visual Studio at the time did not offer a reasonable free option. The first point still holds, the second does not. You can now simply download the free … Continue reading “Programming .NET without Visual Studio”

Beware of Java’s inconsistent MIN_VALUE

An astute user of my Tektosyne library noticed that I had made a simple but disastrous copy-paste mistake regarding the floating-point versions of some basic algorithms, such as finding the maximum of an array of numbers. The integral versions initialize the return value to e.g. Integer.MIN_VALUE and then check for any greater values. I copied … Continue reading “Beware of Java’s inconsistent MIN_VALUE”

Catching Java Assertion Errors

The Java assert statement can be used for conditionally checking program invariants. Assertions are enabled or disabled with the desired level of granularity by Java Virtual Machine flags, as described in the linked guide. So far, so similar to assertion facilities in other languages. However, whereas .NET Debug/Trace.Assert shows and logs a message by default, … Continue reading “Catching Java Assertion Errors”

JavaFX Chart Coloring

Working on a Java(FX) port of my hoplite simulator Myriarch, I ran into an unexpected problem with the history chart. This part of the “Simulation Report” dialog shows how each faction’s unit count changes over the course of the simulation. You can see a screenshot from the current build below. The control is a standard … Continue reading “JavaFX Chart Coloring”

Compiling Java Code

This post is a quick introduction aimed at programmers experienced with C# or other languages who are new to Java. It is intended as a companion piece to my article Java for C# Programmers which focuses on language differences. See the “Further Reading” section at the top of that article for the official Oracle tutorials … Continue reading “Compiling Java Code”

JavaFX Snapshot Scaling

If you try taking image snapshots of a JavaFX Node on a high-DPI system, you’ll find that the result is strangely blurry. This is an unfortunate side effect of the JavaFX DPI scaling introduced in Java SE 8u60. At resolutions greater than 120 DPI, JavaFX automatically treats all coordinates as abstract “layout pixels” with a … Continue reading “JavaFX Snapshot Scaling”

JavaFX Pane Clipping

Most JavaFX layout containers (base class Region) automatically position and size their children, so clipping any child contents that might protrude beyond the container’s layout bounds is never an issue. The big exception is Pane, a direct subclass of Region and the base class for all layout containers with publicly accessible children. Unlike its subclasses … Continue reading “JavaFX Pane Clipping”

JavaFX Spinner for Numbers

The JavaFX version of the popular up-down control is called Spinner. Like its Swing progenitor JSpinner, this control is much more flexible than a typical numerical up-down control. Spinner is designed for arbitrary sequences of objects, with number ranges constituting merely a special case. This has some unfortunate consequences when you do wish to make … Continue reading “JavaFX Spinner for Numbers”