| 1 |
/* |
| 2 |
|
| 3 |
Licensed to the Apache Software Foundation (ASF) under one or more |
| 4 |
contributor license agreements. See the NOTICE file distributed with |
| 5 |
this work for additional information regarding copyright ownership. |
| 6 |
The ASF licenses this file to You under the Apache License, Version 2.0 |
| 7 |
(the "License"); you may not use this file except in compliance with |
| 8 |
the License. You may obtain a copy of the License at |
| 9 |
|
| 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 |
|
| 23 |
// -- Batik classes ---------------------------------------------------------- |
| 24 |
import org.apache.batik.transcoder.Transcoder; |
| 25 |
import org.apache.batik.apps.rasterizer.SVGConverterController; |
| 26 |
import org.apache.batik.apps.rasterizer.SVGConverterSource; |
| 27 |
|
| 28 |
// -- Ant classes ------------------------------------------------------------ |
| 29 |
import org.apache.tools.ant.Task; |
| 30 |
|
| 31 |
// -- Java SDK classes ------------------------------------------------------- |
| 32 |
import java.io.File; |
| 33 |
import java.util.Map; |
| 34 |
import java.util.List; |
| 35 |
|
| 36 |
|
| 37 |
/** |
| 38 |
* Implements simple controller for the <code>SVGConverter</code> operation. |
| 39 |
* |
| 40 |
* <p>This is almost the same as the |
| 41 |
* {@link org.apache.batik.apps.rasterizer.DefaultSVGConverterController DefaultSVGConverterController} |
| 42 |
* except this produces error message when the conversion fails.</p> |
| 43 |
* |
| 44 |
* <p>See {@link SVGConverterController} for the method documentation.</p> |
| 45 |
* |
| 46 |
* @see SVGConverterController SVGConverterController |
| 47 |
* @see org.apache.batik.apps.rasterizer.DefaultSVGConverterController DefaultSVGConverterController |
| 48 |
* |
| 49 |
* @author <a href="mailto:[email protected]">Henri Ruini</a> |
| 50 |
* @version $Id$ |
| 51 |
*/ |
| 52 |
public class RasterizerTaskSVGConverterController implements SVGConverterController { |
| 53 |
|
| 54 |
// -- Variables ---------------------------------------------------------- |
| 55 |
/** Ant task that is used to log messages. */ |
| 56 |
protected Task executingTask = null; |
| 57 |
|
| 58 |
|
| 59 |
// -- Constructors ------------------------------------------------------- |
| 60 |
/** |
| 61 |
* Don't allow public usage. |
| 62 |
*/ |
| 63 |
protected RasterizerTaskSVGConverterController() { |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Sets the given Ant task to receive log messages. |
| 68 |
* |
| 69 |
* @param task Ant task. The value can be <code>null</code> when log messages won't be written. |
| 70 |
*/ |
| 71 |
public RasterizerTaskSVGConverterController(Task task) { |
| 72 |
executingTask = task; |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
// -- Public interface --------------------------------------------------- |
| 77 |
public boolean proceedWithComputedTask(Transcoder transcoder, |
| 78 |
Map hints, |
| 79 |
List sources, |
| 80 |
List dest){ |
| 81 |
return true; |
| 82 |
} |
| 83 |
|
| 84 |
public boolean proceedWithSourceTranscoding(SVGConverterSource source, |
| 85 |
File dest) { |
| 86 |
return true; |
| 87 |
} |
| 88 |
|
| 89 |
public boolean proceedOnSourceTranscodingFailure(SVGConverterSource source, |
| 90 |
File dest, |
| 91 |
String errorCode){ |
| 92 |
if(executingTask != null) { |
| 93 |
executingTask.log("Unable to rasterize image '" |
| 94 |
+ source.getName() + "' to '" |
| 95 |
+ dest.getAbsolutePath() + "': " + errorCode); |
| 96 |
} |
| 97 |
return true; |
| 98 |
} |
| 99 |
|
| 100 |
public void onSourceTranscodingSuccess(SVGConverterSource source, |
| 101 |
File dest){ |
| 102 |
} |
| 103 |
|
| 104 |
} |