/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PaintablePanel.java
 *
 * Created on Feb 7, 2009, 12:12:55 PM
 */

package com.jaspersoft.ireport.designer.jrtx;

import java.awt.Graphics;
import java.awt.Graphics2D;

/**
 *
 * @author gtoffoli
 */
public class PaintablePanel extends javax.swing.JPanel {

    private PaintDelegated painter = null;

    /** Creates new form PaintablePanel */
    public PaintablePanel() {
        initComponents();
    }

    @Override
    public void paintComponent(Graphics g) {

        super.paintComponent(g);
        if (getPainter() != null)
        {
            getPainter().paintComponent(this,(Graphics2D) g);
        }
    }




    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @return the painter
     */
    public

    PaintDelegated getPainter() {
        return painter;
    }

    /**
     * @param painter the painter to set
     */
    public void setPainter(PaintDelegated painter) {
        this.painter = painter;
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

}
