/*    */ package DFT;
/*    */ 
/*    */ import java.awt.Color;
/*    */ import java.awt.Graphics;
/*    */ 
/*    */ public class Graph extends javax.swing.JPanel
/*    */ {
/*    */   private static final long serialVersionUID = 1L;
/*    */   private float[] dft;
/*    */   
/*    */   public Graph()
/*    */   {
/* 13 */     this.dft = new float[0];
/*    */   }
/*    */   
/*    */   public void update(float[] dft) {
/* 17 */     this.dft = dft;
/* 18 */     repaint();
/*    */   }
/*    */   
/*    */   public void paintComponent(Graphics g)
/*    */   {
/* 23 */     g.setColor(new Color(250, 250, 250));
/* 24 */     g.fillRect(0, 0, getWidth(), getHeight());
/*    */     
/*    */ 
/*    */ 
/* 28 */     float space = (getWidth() - 30) / this.dft.length;
/*    */     
/*    */ 
/* 31 */     float max = 0.0F;float indexMax = 0.0F;float tmp = 0.0F;
/* 32 */     for (int i = 0; i < this.dft.length; i++) {
/* 33 */       max = Math.max(max, this.dft[i]);
/* 34 */       if (max != tmp) {
/* 35 */         indexMax = i;
/* 36 */         tmp = max;
/*    */       }
/*    */     }
/* 39 */     float heightScale = (getHeight() - 50) / max;
/*    */     
/* 41 */     g.setColor(Color.RED);
/*    */     
/* 43 */     g.drawLine(18, getHeight() - 20, getWidth() - 10, getHeight() - 20);
/* 44 */     g.drawLine(getWidth() - 10, getHeight() - 20, getWidth() - 15, getHeight() - 15);
/* 45 */     g.drawLine(getWidth() - 10, getHeight() - 20, getWidth() - 15, getHeight() - 25);
/* 46 */     g.drawString("N", getWidth() - 10, getHeight() - 5);
/*    */     
/* 48 */     g.drawLine(18, getHeight() - 20, 18, 20);
/* 49 */     g.drawLine(18, 20, 13, 25);
/* 50 */     g.drawLine(18, 20, 23, 25);
/* 51 */     g.drawString("mag", 2, 15);
/* 52 */     //g.drawString((int)max, (int)(indexMax * space) + 25, getHeight() - (int)(max * heightScale) - 20);
/*    */     
/*    */ 
/*    */ 
/* 56 */     g.translate(20, -20);
/* 57 */     g.setColor(Color.BLACK);
/* 58 */     for (int i = 0; i < this.dft.length; i++) g.fillRect((int)(i * space), getHeight() - (int)(this.dft[i] * heightScale), 1, (int)(this.dft[i] * heightScale));
/* 59 */     g.translate(-20, 20);
/*    */   }
/*    */ }


/* Location:              F:\JAVA\WORKSPACE\chronoEditor_v2.3.jar!\DFT\Graph.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */