@Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    
    // antialiased text rendering
    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

    // draws the tube image
    g.drawImage(tubeImage, 0, 48, this);

    // do blending
    float alpha = (float)(1.0 - component.getSvO2()) * 2;
    if (alpha < 0.0f) {
      alpha = 0.0f;
    }
    else if (alpha > 1.0f) {
      alpha = 1.0f;
    }
    Composite oldComp = g2.getComposite();
    Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
    g2.setComposite(alphaComp);

    // draws the image
    g.drawImage(image, 176, 1, this);
    
    // draws the venous image
    g.drawImage(venousImage, 0, 48, this);

    // Restore the old composite.
    g2.setComposite(oldComp);
    
    // draw the bubbles
    if (component.isArterialBubbles()) {
      if ((((System.nanoTime()) / 200000000) % 3) == 0) {
        g.drawImage(bubbleDot1Image, 350, 95, this);      
      } 
      else if ((((System.nanoTime()) / 200000000) % 3) == 1) {
        g.drawImage(bubbleDot2Image, 350, 95, this);
      } 
      else {
        g.drawImage(bubbleDot3Image, 350, 95, this);
      }
    }
    if (component.isVenousBubbles()) {
      if ((((System.nanoTime()) / 200000000) % 3) == 0) {
        g.drawImage(bubbleRect1Image, 301, 189, this);     
      } 
      else if ((((System.nanoTime()) / 200000000) % 3) == 1) {
        g.drawImage(bubbleRect2Image, 301, 189, this);
      } 
      else {
        g.drawImage(bubbleRect3Image, 301, 189, this);
      }
    }
        
    // draw what ECMO we are using
    g.setFont(g.getFont().deriveFont(Font.BOLD, 14f));
    g.setColor(Color.DARK_GRAY);
    g.drawString(component.getName(), 89, 10);
  }