All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.fge.grappa.debugger.javafx.JavafxUtils Maven / Gradle / Ivy

The newest version!
package com.github.fge.grappa.debugger.javafx;

import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.control.TableColumn;
import javafx.scene.paint.Color;

import java.util.function.Function;

public final class JavafxUtils
{
    public static final Color FILL_COLOR_1
        = Color.rgb(78, 164, 78);
    public static final Color FILL_COLOR_2
        = Color.rgb(234, 160, 41);
    public static final Color FILL_COLOR_3
        = Color.rgb(224, 97, 49);
    public static final Color FILL_COLOR_4
        = Color.rgb(72, 164, 192);


    @SuppressWarnings("ProhibitedExceptionThrown")
    private JavafxUtils()
    {
        throw new Error("nice try!");
    }

    @SuppressWarnings("AutoBoxing")
    public static String nanosToString(final long nanos)
    {
        long value = nanos;
        final long nrNanoseconds = value % 1000;
        value /= 1000;
        final long nrMicroseconds = value % 1000;
        value /= 1000;

        return String.format("%d ms, %03d.%03d µs", value, nrMicroseconds,
            nrNanoseconds);
    }

    public static  void setColumnValue(final TableColumn column,
        final Function f)
    {
        column.setCellValueFactory(
            param -> new SimpleObjectProperty()
            {
                @Override
                public T get()
                {
                    return f.apply(param.getValue());
                }
            }
        );
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy