lphystudio.app.graphicalmodelpanel.viewer.ArrayLabel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lphy-studio Show documentation
Show all versions of lphy-studio Show documentation
The GUI for LPhy language.
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();
}
}