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

org.pepsoft.worldpainter.NoiseSettingsTableCellRenderer Maven / Gradle / Ivy

There is a newer version: 2.23.2
Show newest version
package org.pepsoft.worldpainter;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;

import static java.awt.Color.GRAY;

public class NoiseSettingsTableCellRenderer extends DefaultTableCellRenderer {
    public NoiseSettingsTableCellRenderer() {
        setHorizontalAlignment(TRAILING);
    }

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        if (value instanceof NoiseSettings) {
            if (! isSelected) {
                setForeground(table.getForeground());
            }
            NoiseSettings noiseSettings = (NoiseSettings) value;
            setText(noiseSettings.getRange() + ", " + Math.round(noiseSettings.getScale() * 100) + ", " + noiseSettings.getRoughness());
        } else {
            if (! isSelected) {
                setForeground(GRAY);
            }
            setText("no variation");
        }
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy