1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
class Program
{
public static void main(String[] args)
{
// WebCam => Filter => Recorder
Module m1 = new WebCam(null);
Module m2 = new Filter(m1);
Module m3 = new Recorder(m2,(Sizer)m1);
m1.start(); m2.start(); m3.start();
}
}
interface Sizer
{
public int getWidth();
public int getHeight();
}
class WebCam extends Module implements Sizer
{
static int width = 320 ;
static int height = 320 ;
public WebCam(Module parent) { super(parent); }
public int getWidth() { return width; }
public int getHeight() { return height; }
}
class Recorder extends Module
{
Sizer _sizer ;
public Recorder(Module parent,Sizer sizer) { super(parent); _sizer = sizer ;}
//@overide
public void start()
{
//pour creer un avi on a besoin de la taille de la video !
int width = _sizer.getWidth();
System.out.println("Width found : " + width );
}
} |
Partager