01: /*
02:
03: Licensed to the Apache Software Foundation (ASF) under one or more
04: contributor license agreements. See the NOTICE file distributed with
05: this work for additional information regarding copyright ownership.
06: The ASF licenses this file to You under the Apache License, Version 2.0
07: (the "License"); you may not use this file except in compliance with
08: the License. You may obtain a copy of the License at
09:
10: http://www.apache.org/licenses/LICENSE-2.0
11:
12: Unless required by applicable law or agreed to in writing, software
13: distributed under the License is distributed on an "AS IS" BASIS,
14: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: See the License for the specific language governing permissions and
16: limitations under the License.
17:
18: */
19:
20: package org.apache.tools.ant.taskdefs.optional;
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;
32: import java.util.Map;
33: import java.util.List;
34:
35: /**
36: * Implements simple controller for the <code>SVGConverter</code> operation.
37: *
38: * <p>This is almost the same as the
39: * {@link org.apache.batik.apps.rasterizer.DefaultSVGConverterController DefaultSVGConverterController}
40: * except this produces error message when the conversion fails.</p>
41: *
42: * <p>See {@link SVGConverterController} for the method documentation.</p>
43: *
44: * @see SVGConverterController SVGConverterController
45: * @see org.apache.batik.apps.rasterizer.DefaultSVGConverterController DefaultSVGConverterController
46: *
47: * @author <a href="mailto:ruini@iki.fi">Henri Ruini</a>
48: * @version $Id: RasterizerTaskSVGConverterController.java 479617 2006-11-27 13:43:51Z dvholten $
49: */
50: public class RasterizerTaskSVGConverterController implements
51: SVGConverterController {
52:
53: // -- Variables ----------------------------------------------------------
54: /** Ant task that is used to log messages. */
55: protected Task executingTask = null;
56:
57: // -- Constructors -------------------------------------------------------
58: /**
59: * Don't allow public usage.
60: */
61: protected RasterizerTaskSVGConverterController() {
62: }
63:
64: /**
65: * Sets the given Ant task to receive log messages.
66: *
67: * @param task Ant task. The value can be <code>null</code> when log messages won't be written.
68: */
69: public RasterizerTaskSVGConverterController(Task task) {
70: executingTask = task;
71: }
72:
73: // -- Public interface ---------------------------------------------------
74: public boolean proceedWithComputedTask(Transcoder transcoder,
75: Map hints, List sources, List dest) {
76: return true;
77: }
78:
79: public boolean proceedWithSourceTranscoding(
80: SVGConverterSource source, File dest) {
81: return true;
82: }
83:
84: public boolean proceedOnSourceTranscodingFailure(
85: SVGConverterSource source, File dest, String errorCode) {
86: if (executingTask != null) {
87: executingTask.log("Unable to rasterize image '"
88: + source.getName() + "' to '"
89: + dest.getAbsolutePath() + "': " + errorCode);
90: }
91: return true;
92: }
93:
94: public void onSourceTranscodingSuccess(SVGConverterSource source,
95: File dest) {
96: }
97:
98: }
|