xref: /haiku/src/libs/icon/transformer/TransformerFactory.cpp (revision e1c4049fed1047bdb957b0529e1921e97ef94770)
1 /*
2  * Copyright 2006-2007, Haiku.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Stephan Aßmus <superstippi@gmx.de>
7  */
8 
9 #include "TransformerFactory.h"
10 
11 #include "AffineTransformer.h"
12 #include "ContourTransformer.h"
13 #include "PerspectiveTransformer.h"
14 #include "Shape.h"
15 #include "StrokeTransformer.h"
16 
17 #ifdef ICON_O_MATIC
18 #include <Catalog.h>
19 #include <Message.h>
20 #endif
21 
22 
23 _USING_ICON_NAMESPACE
24 
25 
26 // TransformerFor
27 Transformer*
28 TransformerFactory::TransformerFor(uint32 type, VertexSource& source, Shape* shape)
29 {
30 	switch (type) {
31 		case AFFINE_TRANSFORMER:
32 			return new AffineTransformer(source);
33 		case PERSPECTIVE_TRANSFORMER:
34 			return new PerspectiveTransformer(source, shape);
35 		case CONTOUR_TRANSFORMER:
36 			return new ContourTransformer(source);
37 		case STROKE_TRANSFORMER:
38 			return new StrokeTransformer(source);
39 	}
40 
41 	return NULL;
42 }
43 
44 // TransformerFor
45 Transformer*
46 TransformerFactory::TransformerFor(BMessage* message, VertexSource& source, Shape* shape)
47 {
48 	switch (message->what) {
49 		case AffineTransformer::archive_code:
50 			return new AffineTransformer(source, message);
51 		case PerspectiveTransformer::archive_code:
52 			return new PerspectiveTransformer(source, shape, message);
53 		case ContourTransformer::archive_code:
54 			return new ContourTransformer(source, message);
55 		case StrokeTransformer::archive_code:
56 			return new StrokeTransformer(source, message);
57 	}
58 
59 	return NULL;
60 }
61 
62