1# $Id: compositeExample.xotcl,v 1.1 2004/05/23 22:50:39 neumann Exp $
2# include the pattern
3source composite.xotcl
4
5Class Graphic
6@ @File {
7  description {
8    Simple Graphics example of the composite pattern taken from the paper 
9    'Filters as a Language Support for Design Patterns in
10    Object-Oriented Scripting Languages'. They demonstrate instfilters,
11    filter chains and filter inheritance.
12  }
13}
14
15
16Graphic instproc draw {} {
17    puts "in--- draw  SELF: [self]   CLASS: [self class]"
18}
19  
20Composite Picture -superclass Graphic
21Class Line -superclass Graphic
22Class Rectangle -superclass Graphic
23
24
25Picture addOperations draw
26#Picture removeOperations draw
27
28Picture aPicture
29Picture aPicture::bPicture
30Line aPicture::aLine
31Rectangle aPicture::aRect
32Line aPicture::bPicture::aLine
33Rectangle aPicture::bPicture::aRect
34Picture aPicture::bPicture::cPicture
35Picture aPicture::bPicture::dPicture
36Line aPicture::bPicture::cPicture::cLine
37
38# draw eines Composites
39puts "DRAW im Composite: aPicture"
40aPicture draw
41