/*
 * CellAnimationEffect.java
 *
 * Created on January 24, 2006, 5:21 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package it.businesslogic.ireport.crosstab.gui;

import it.businesslogic.ireport.crosstab.CrosstabCell;
import java.awt.Color;
import java.awt.Graphics2D;

/**
 *
 * @author gtoffoli
 */
public class CellAnimationEffect implements Runnable {
    
    private CrosstabEditorPanel editor = null;
    private CrosstabCell noDataCell = null;
    /** Creates a new instance of CellAnimationEffect */
    public CellAnimationEffect() {
    }

    public CrosstabEditorPanel getEditor() {
        return editor;
    }

    public void setEditor(CrosstabEditorPanel editor) {
        this.editor = editor;
    }
    
    public void run()
    {
         Graphics2D g = (Graphics2D)editor.getGraphics();
         g.setColor(new Color(255,168,0,20));
         
         
         System.out.println(editor.getZoomedDim(getNoDataCell().getTop())+","+editor.getZoomedDim(getNoDataCell().getLeft()));
         
         
         for (int j=1; j<=20; ++j)
         {
             g.setColor(new Color(255,168,0,j));
             int i=10;
             g.fillRect(editor.getZoomedDim(getNoDataCell().getLeft())-i+10, editor.getZoomedDim(getNoDataCell().getTop())-i+10,
                        editor.getZoomedDim(getNoDataCell().getWidth())+(i*2), i);

             g.fillRect(editor.getZoomedDim(getNoDataCell().getLeft())-i+10, editor.getZoomedDim(getNoDataCell().getTop())+10,
                       i, editor.getZoomedDim(getNoDataCell().getHeight()));

             g.fillRect(editor.getZoomedDim(getNoDataCell().getLeft())+10-i, editor.getZoomedDim(getNoDataCell().getTop())+editor.getZoomedDim(getNoDataCell().getHeight())+10,
                       editor.getZoomedDim(getNoDataCell().getWidth())+(i*2), i);
             
             g.fillRect(editor.getZoomedDim(getNoDataCell().getLeft())+editor.getZoomedDim(getNoDataCell().getWidth())+10, editor.getZoomedDim(getNoDataCell().getTop())+10,
                       i, editor.getZoomedDim(getNoDataCell().getHeight()));

            try {
             Thread.sleep(20);
            } catch (Exception ex){}
            
            
         }
          
         getNoDataCell().setPaintSelection(true);
         getNoDataCell().drawCellBox(g,editor.getZoomFactor(),false,false);
    }

    public CrosstabCell getNoDataCell() {
        return noDataCell;
    }

    public void setNoDataCell(CrosstabCell noDataCell) {
        this.noDataCell = noDataCell;
    }
}
