KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > RasterizerTaskSVGConverterController


1 /*
2
3    Copyright 2001-2002 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18
19 package org.apache.tools.ant.taskdefs.optional;
20
21
22 // -- Batik classes ----------------------------------------------------------
23
import org.apache.batik.transcoder.Transcoder;
24 import org.apache.batik.apps.rasterizer.SVGConverterController;
25 import org.apache.batik.apps.rasterizer.SVGConverterSource;
26
27 // -- Ant classes ------------------------------------------------------------
28
import org.apache.tools.ant.Task;
29
30 // -- Java SDK classes -------------------------------------------------------
31
import java.io.File JavaDoc;
32 import java.util.Vector JavaDoc;
33 import java.util.Map JavaDoc;
34
35
36 /**
37  * Implements simple controller for the <code>SVGConverter</code> operation.
38  *
39  * <p>This is almost the same as the
40  * {@link org.apache.batik.apps.rasterizer.DefaultSVGConverterController DefaultSVGConverterController}
41  * except this produces error message when the conversion fails.</p>
42  *
43  * <p>See {@link SVGConverterController} for the method documentation.</p>
44  *
45  * @see SVGConverterController SVGConverterController
46  * @see org.apache.batik.apps.rasterizer.DefaultSVGConverterController DefaultSVGConverterController
47  *
48  * @author <a HREF="mailto:ruini@iki.fi">Henri Ruini</a>
49  * @version $Id: RasterizerTaskSVGConverterController.java,v 1.3 2004/08/18 07:11:29 vhardy Exp $
50  */

51 public class RasterizerTaskSVGConverterController implements SVGConverterController {
52
53     // -- Variables ----------------------------------------------------------
54
/** Ant task that is used to log messages. */
55     protected Task executingTask = null;
56
57
58     // -- Constructors -------------------------------------------------------
59
/**
60      * Don't allow public usage.
61      */

62     protected RasterizerTaskSVGConverterController() {
63     }
64
65     /**
66      * Sets the given Ant task to receive log messages.
67      *
68      * @param task Ant task. The value can be <code>null</code> when log messages won't be written.
69      */

70     public RasterizerTaskSVGConverterController(Task task) {
71         executingTask = task;
72     }
73
74
75     // -- Public interface ---------------------------------------------------
76
public boolean proceedWithComputedTask(Transcoder transcoder,
77                                            Map JavaDoc hints,
78                                            Vector JavaDoc sources,
79                                            Vector JavaDoc dest){
80         return true;
81     }
82     
83     public boolean proceedWithSourceTranscoding(SVGConverterSource source,
84                                                 File JavaDoc dest) {
85         return true;
86     }
87     
88     public boolean proceedOnSourceTranscodingFailure(SVGConverterSource source,
89                                                      File JavaDoc dest,
90                                                      String JavaDoc errorCode){
91         if(executingTask != null) {
92             executingTask.log("Unable to rasterize image '"
93                 + source.getName() + "' to '"
94                 + dest.getAbsolutePath() + "': " + errorCode);
95         }
96         return true;
97     }
98
99     public void onSourceTranscodingSuccess(SVGConverterSource source,
100                                            File JavaDoc dest){
101     }
102
103 }
104
Popular Tags