Add support for multi-argument widgets' attribute methods

This commit is contained in:
2022-11-23 16:28:29 +01:00
parent 95c11e5375
commit 3b62d7c06b
5 changed files with 105 additions and 55 deletions

View File

@@ -7,4 +7,5 @@ import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
public @interface Attribute {
String value();
String separator() default "|";
}

View File

@@ -24,13 +24,9 @@ public class FPSMonitor extends BaseComponent {
background.setRGBA(0x444444AA);
}
@Attribute("monitor")
public void setMonitor(Integer[] options) {
if (options.length != 2) {
throw new IllegalArgumentException("Expected 2 parameters: batch size and number of samples");
}
this.fpsProfiler = FPSProfiler.create(options[0], options[1]);
@Attribute(value = "monitor", separator = ",")
public void setMonitor(Integer batchSize, Integer samples) {
this.fpsProfiler = FPSProfiler.create(batchSize, samples);
}
public void setColor(Integer hex) {