コード例 #1
0
  /** Constructs a new Sceen with given height & width (in words) and amount of bits per word. */
  public ScreenComponent() {
    setOpaque(true);
    setBackground(Color.white);
    setBorder(BorderFactory.createEtchedBorder());
    Insets borderInsets = getBorder().getBorderInsets(this);
    int borderWidth = borderInsets.left + borderInsets.right;
    int borderHeight = borderInsets.top + borderInsets.bottom;
    setPreferredSize(
        new Dimension(
            Definitions.SCREEN_WIDTH + borderWidth, Definitions.SCREEN_HEIGHT + borderHeight));
    setSize(Definitions.SCREEN_WIDTH + borderWidth, Definitions.SCREEN_HEIGHT + borderHeight);

    data = new short[Definitions.SCREEN_SIZE];
    x = new int[Definitions.SCREEN_SIZE];
    y = new int[Definitions.SCREEN_SIZE];
    x[0] = borderInsets.left;
    y[0] = borderInsets.top;

    // updates pixels indice
    for (int i = 1; i < Definitions.SCREEN_SIZE; i++) {
      x[i] = x[i - 1] + Definitions.BITS_PER_WORD;
      y[i] = y[i - 1];
      if (x[i] == Definitions.SCREEN_WIDTH + borderInsets.left) {
        x[i] = borderInsets.left;
        y[i]++;
      }
    }

    timer = new Timer(STATIC_CLOCK_INTERVALS, this);
    timer.start();
  }
コード例 #2
0
 /** Stops the animation. */
 public void stopAnimation() {
   timer.setDelay(STATIC_CLOCK_INTERVALS);
 }
コード例 #3
0
 /** Starts the animation. */
 public void startAnimation() {
   timer.setDelay(ANIMATION_CLOCK_INTERVALS);
 }