1 package fr.ove.openmath.jome.formaters.om;
2
3 import fr.ove.utils.*;
4 import fr.ove.openmath.jome.model.*;
5 import fr.ove.openmath.jome.formaters.om.*;
6
7 /***
8 * Formats the formula tree structure as its corresponding OpenMath object.<BR>
9 * Format the complex polar element.
10 *
11 * @author © 2000 DIRAT Laurent
12 * @version 1.0 25/02/2000
13 */
14 public class ComplexPolarFormater implements Formater {
15 /***
16 * Returns the specified object formatted as a string.
17 * @param formatedObject the formatted object (for structured object, could represents the beginning).
18 * @param formaterRepository where the different other formaters are.
19 * @param obj the object to format.
20 */
21 public String format(String formatedObject, FormaterRepository formaterRepository, Object obj) {
22 OpenMathFormater omFormater = (OpenMathFormater) formaterRepository;
23 KaryOperator fts = (KaryOperator) obj;
24
25 formatedObject += omFormater.writeStartApplication();
26
27
28
29
30 String objectId = fts.getTheOperator();
31 objectId = objectId.substring(0, objectId.length()-1);
32 formatedObject += omFormater.writeSymbol(objectId);
33
34 Formater formater = null;
35
36 FormulaTreeStructure imaginay = (FormulaTreeStructure) fts.getChild(0);
37 imaginay = (FormulaTreeStructure) imaginay.getChild(0);
38 FormulaTreeStructure realPart = (FormulaTreeStructure) imaginay.getChild(0);
39 imaginay = (FormulaTreeStructure) imaginay.getChild(1);
40 imaginay = (FormulaTreeStructure) imaginay.getChild(1);
41 imaginay = (FormulaTreeStructure) imaginay.getChild(0);
42 imaginay = (FormulaTreeStructure) imaginay.getChild(1);
43
44 objectId = realPart.getResourceIdentifier();
45 formater = formaterRepository.getFormater(objectId);
46 formatedObject = formater.format(formatedObject, formaterRepository, realPart);
47
48 objectId = imaginay.getResourceIdentifier();
49 formater = formaterRepository.getFormater(objectId);
50 formatedObject = formater.format(formatedObject, formaterRepository, imaginay);
51
52 formatedObject += omFormater.writeEndApplication();
53
54 return formatedObject;
55 }
56 }