package aanimation.examples;
import aanimation.AnimationComponent;
import aanimation.AnimationEngine;
import aanimation.AnimationList;
import aanimation.painter.CachablePaintBoard;
import aanimation.painter.Component;
import aanimation.painter.ComponentImpl;
import aanimation.painter.ContainerImpl;
import aanimation.painter.PaintBoard;
import aanimation.script.ManhatinAnimation;
/**
* simple example help you to use the package
* @author asalehi
*
*/
public class Painter {
public static void main(String[] args) {
// create PaintBoard for component
PaintBoard paintBoard1 = new CachablePaintBoard(false, new Dimension(
50, 50)) {
public void paintComponent(Graphics graphics) {
graphics.setColor(Color.ORANGE);
graphics.drawLine(0, getHeight(), getHeight(), 0);
graphics.fillOval(0, 0, getWidth(), getHeight());
// System.out.println("paint");
}
};
// create PaintBoard for container
PaintBoard paintBoardForContainer = new CachablePaintBoard(false,
new Dimension(200, 200)) {
public void paintComponent(Graphics graphics) {
graphics.setColor(Color.white);
graphics.fillRect(0, 0, getWidth(), getHeight());
}
};
// create Container
ContainerImpl container = new ContainerImpl(paintBoardForContainer);
// create Component
Component component1 = new ComponentImpl(paintBoard1, 0, 0);
// add Component to Container with a name
container.addComponent("Alaa1", component1);
// you can use the same paint Board for many component you want
Component component2 = new ComponentImpl(paintBoard1, 50, 50);
container.addComponent("Alaa2", component2);
Component component3 = new ComponentImpl(paintBoard1, 100, 100);
container.addComponent("Alaa3", component3);
// create JFrame
JFrame frame = new JFrame();
// add the Container to JFrame
frame.add(container);
frame.setSize(300, 300);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}