import java.text.DecimalFormat; class TextWidget implements Drawable { int posX, posY; Object obj; PFont font; NumberFormat format; TextWidget(Object obj, int posX, int posY, PFont font) { this.obj = obj; this.posX = posX; this.posY = posY; this.font = font; this.format = new DecimalFormat("000.00"); } void draw() { String text; textMode(SCREEN); fill(0); textFont(font); if(obj instanceof String) { text = (String) obj; } else if (obj instanceof Sensor) { text = "" + format.format(((Sensor) obj).getValue()); } else { text = "undef"; } text(text, posX, posY); } }