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

lphystudio.app.graphicalmodelpanel.viewer.ArrayLabel Maven / Gradle / Ivy

The newest version!
package lphystudio.app.graphicalmodelpanel.viewer;

import lphy.core.model.Value;

import javax.swing.*;

public class ArrayLabel extends JLabel {

    public ArrayLabel(Value values) {
        this(values.value());
    }

    public ArrayLabel(T[] values) {

        StringBuilder builder = new StringBuilder();
        builder.append("[");
        if (values.length > 0) // not empty array
            builder.append(valueToString(values[0]));
        for (int i = 1; i < values.length; i++) {
            if (builder.length()-builder.lastIndexOf("
") > 80) { builder.append(",
"); } else { builder.append(", "); } builder.append(valueToString(values[i])); } builder.append("]"); String str = builder.toString(); setText(str); } public String valueToString(T rawValue) { return rawValue.toString(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy