| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ConverterPlugin |
|
| 1.0;1 | ||||
| ConverterPlugin$DocumentWithDimension |
|
| 1.0;1 |
| 1 | /* | |
| 2 | * Copyright 2007 - 2008 JEuclid, http://jeuclid.sf.net | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | ||
| 17 | /* $Id: ConverterPlugin.java,v 70597ba9d706 2008/02/18 19:42:05 maxberger $ */ | |
| 18 | ||
| 19 | package net.sourceforge.jeuclid.converter; | |
| 20 | ||
| 21 | import java.awt.Dimension; | |
| 22 | import java.io.IOException; | |
| 23 | import java.io.OutputStream; | |
| 24 | ||
| 25 | import net.sourceforge.jeuclid.LayoutContext; | |
| 26 | ||
| 27 | import org.w3c.dom.Document; | |
| 28 | import org.w3c.dom.Node; | |
| 29 | ||
| 30 | /** | |
| 31 | * Describes an Image converter. | |
| 32 | * | |
| 33 | * @version $Revision: 70597ba9d706 $ | |
| 34 | */ | |
| 35 | public interface ConverterPlugin { | |
| 36 | /** | |
| 37 | * Write the given MathBase object with its rendering parameters into the | |
| 38 | * given output stream. | |
| 39 | * | |
| 40 | * @param doc | |
| 41 | * A JEuclid DocumentElement | |
| 42 | * @param outStream | |
| 43 | * Target output stream. | |
| 44 | * @param context | |
| 45 | * LayoutContext to use. | |
| 46 | * @return Rendering's dimension based on the spefic plugin's Graphics2D | |
| 47 | * implementation. | |
| 48 | * @throws IOException | |
| 49 | * if an I/O error occurred during write. | |
| 50 | */ | |
| 51 | Dimension convert(Node doc, LayoutContext context, OutputStream outStream) | |
| 52 | throws IOException; | |
| 53 | ||
| 54 | /** | |
| 55 | * Internal class describing an XML document and the dimensions of its | |
| 56 | * default view. | |
| 57 | */ | |
| 58 | class DocumentWithDimension { | |
| 59 | private final Document document; | |
| 60 | ||
| 61 | private final Dimension dimension; | |
| 62 | ||
| 63 | private final float baseline; | |
| 64 | ||
| 65 | public DocumentWithDimension(final Document doc, final Dimension dim, | |
| 66 | final float bline) { | |
| 67 | 418 | super(); |
| 68 | 418 | this.document = doc; |
| 69 | 418 | this.dimension = dim; |
| 70 | 418 | this.baseline = bline; |
| 71 | 418 | } |
| 72 | ||
| 73 | /** | |
| 74 | * @return the document resulting from this conversion, a suptype of | |
| 75 | * Document (e.g. SVGDocument) if possible. | |
| 76 | */ | |
| 77 | public Document getDocument() { | |
| 78 | 418 | return this.document; |
| 79 | } | |
| 80 | ||
| 81 | /** | |
| 82 | * @return The dimensions from this conversion | |
| 83 | */ | |
| 84 | public Dimension getDimension() { | |
| 85 | 627 | return this.dimension; |
| 86 | } | |
| 87 | ||
| 88 | /** | |
| 89 | * @return the position of the baseline in pixels from the bottom. | |
| 90 | */ | |
| 91 | public float getBaseline() { | |
| 92 | 0 | return this.baseline; |
| 93 | } | |
| 94 | ||
| 95 | } | |
| 96 | ||
| 97 | /** | |
| 98 | * Convert from the given Math Object to an XML DOM Document. | |
| 99 | * | |
| 100 | * @param doc | |
| 101 | * A JEuclid DocumentElement | |
| 102 | * @param context | |
| 103 | * LayoutContext to use. | |
| 104 | * @return an instance of DocumentWithDimension, containing a Document of | |
| 105 | * the appropriate subtype for this format (e.g. SVGDocument), if | |
| 106 | * available. If conversion is not supported by this plugin, it | |
| 107 | * may return null. | |
| 108 | */ | |
| 109 | DocumentWithDimension convert(final Node doc, final LayoutContext context); | |
| 110 | ||
| 111 | } |