示例#1
0
  protected synchronized void setOutput(byte[] b) {
    if (b != null && (output == null || !Arrays.equals(output, b))) {
      if (output == null) {
        if (b.length > max_length) {
          output = new byte[max_length];
        } else {
          output = new byte[b.length];
        }
        System.arraycopy(b, 0, output, 0, output.length);
      } else {
        try {
          // if new value(b) is greater than max_width, create largest output
          if (b.length > max_length) output = new byte[max_length];

          // if new value(b) is greater than output, create larger output
          else if (b.length > output.length) output = new byte[b.length];

          // if new value(b) is less than output, fill output with spaces
          else if (b.length < output.length) Arrays.fill(output, Char.SPACE);

          System.arraycopy(b, 0, output, 0, (b.length >= output.length) ? output.length : b.length);
        } catch (ArrayIndexOutOfBoundsException e) {
          System.out.println("BoundException: " + b.length + " - " + output.length);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      // invalidate this component so that it updates
      this.setInvalid();
    }
  }
示例#2
0
 public final void validate() {
   if (invalid && output != null) {
     if (erase) {
       Arrays.fill(output, Char.SPACE);
       display.setCursor(position.x, position.y);
       display.write(output);
       erase = false;
     }
     display.setCursor(position.x, position.y);
     display.write(output);
     this.setValid();
   }
 }