use of com.lowagie.text.Chapter in project vcell by virtualcell.
the class ITextWriter method writeBioModel.
public void writeBioModel(BioModel bioModel, FileOutputStream fos, PageFormat pageFormat, PublishPreferences preferences) throws Exception {
if (bioModel == null || fos == null || pageFormat == null || preferences == null) {
throw new IllegalArgumentException("One or more null params while publishing BioModel.");
}
try {
createDocument(pageFormat);
createDocWriter(fos);
// Add metadata before you open the document...
String name = bioModel.getName().trim();
String userName = "Unknown";
if (bioModel.getVersion() != null) {
userName = bioModel.getVersion().getOwner().getName();
}
document.addTitle(name + "[owned by " + userName + "]");
document.addCreator("Virtual Cell");
document.addCreationDate();
// writeWatermark(document, pageFormat);
writeHeaderFooter("BioModel: " + name);
document.open();
//
Section introSection = null;
int chapterNum = 1;
if (preferences.includePhysio()) {
Chapter physioChapter = new Chapter("Physiology For " + name, chapterNum++);
introSection = physioChapter.addSection("General Info", physioChapter.numberDepth() + 1);
String freeTextAnnotation = bioModel.getVCMetaData().getFreeTextAnnotation(bioModel);
writeMetadata(introSection, name, freeTextAnnotation, userName, "BioModel");
writeModel(physioChapter, bioModel.getModel());
document.add(physioChapter);
}
if (preferences.includeApp()) {
SimulationContext[] simContexts = bioModel.getSimulationContexts();
if (simContexts.length > 0) {
Chapter simContextsChapter = new Chapter("Applications For " + name, chapterNum++);
if (introSection == null) {
introSection = simContextsChapter.addSection("General Info", simContextsChapter.numberDepth() + 1);
String freeTextAnnotation = bioModel.getVCMetaData().getFreeTextAnnotation(bioModel);
writeMetadata(introSection, name, freeTextAnnotation, userName, "BioModel");
}
for (int i = 0; i < simContexts.length; i++) {
writeSimulationContext(simContextsChapter, simContexts[i], preferences);
}
document.add(simContextsChapter);
} else {
System.err.println("Bad Request: No applications to publish for Biomodel: " + bioModel.getName());
}
}
document.close();
} catch (DocumentException e) {
System.err.println("Unable to publish BioModel.");
e.printStackTrace();
throw e;
}
}
use of com.lowagie.text.Chapter in project vcell by virtualcell.
the class ITextWriter method writeGeometry.
// for now, the preferences for a geometry is a dummy.
public void writeGeometry(Geometry geom, FileOutputStream fos, PageFormat pageFormat, PublishPreferences preferences) throws Exception {
if (geom == null || fos == null || pageFormat == null || preferences == null) {
throw new IllegalArgumentException("One or more null params while publishing Geometry.");
}
try {
createDocument(pageFormat);
createDocWriter(fos);
// Add metadata before you open the document...
String name = geom.getName().trim();
String userName = "Unknown";
if (geom.getVersion() != null) {
userName = geom.getVersion().getOwner().getName();
}
document.addTitle(name + "[owned by " + userName + "]");
document.addCreator("Virtual Cell");
document.addCreationDate();
// writeWatermark(document, pageFormat);
writeHeaderFooter("Geometry: " + name);
document.open();
//
Section introSection = null;
int chapterNum = 1;
Chapter geomChapter = new Chapter("Geometry", chapterNum++);
introSection = geomChapter.addSection("General Info", geomChapter.numberDepth() + 1);
writeMetadata(introSection, name, geom.getDescription(), userName, "Geometry");
// title?
Section geomSection = geomChapter.addSection("Geometry", geomChapter.numberDepth() + 1);
writeGeom(geomSection, geom, null);
document.add(geomChapter);
document.close();
} catch (DocumentException e) {
System.err.println("Unable to publish BioModel.");
e.printStackTrace();
throw e;
}
}
use of com.lowagie.text.Chapter in project vcell by virtualcell.
the class ITextWriter method writeMathModel.
public void writeMathModel(MathModel mathModel, FileOutputStream fos, PageFormat pageFormat, PublishPreferences preferences) throws Exception {
if (mathModel == null || fos == null || pageFormat == null || preferences == null) {
throw new IllegalArgumentException("One or more null params while publishing MathModel.");
}
try {
createDocument(pageFormat);
createDocWriter(fos);
// Add metadata before you open the document...
String name = mathModel.getName().trim();
String userName = "Unknown";
if (mathModel.getVersion() != null) {
userName = mathModel.getVersion().getOwner().getName();
}
document.addTitle(name + "[owned by " + userName + "]");
document.addCreator("Virtual Cell");
document.addCreationDate();
// writeWatermark(document, pageFormat);
writeHeaderFooter("MathModel: " + name);
document.open();
//
int chapterNum = 1;
Section introSection = null;
if (preferences.includeMathDesc()) {
MathDescription mathDesc = mathModel.getMathDescription();
Chapter mathDescChapter = new Chapter("Math Description", chapterNum++);
introSection = mathDescChapter.addSection("General Info", mathDescChapter.numberDepth() + 1);
writeMetadata(introSection, name, mathModel.getDescription(), userName, "MathModel");
writeMathDescAsText(mathDescChapter, mathDesc);
document.add(mathDescChapter);
}
if (preferences.includeSim()) {
// unlike biomodels, simulations are chapters, not chapter sections.
Simulation[] sims = mathModel.getSimulations();
if (sims != null) {
Chapter simChapter = new Chapter("Simulations", chapterNum++);
if (introSection == null) {
introSection = simChapter.addSection("General Info", simChapter.numberDepth() + 1);
writeMetadata(introSection, name, mathModel.getDescription(), userName, "MathModel");
}
for (int i = 0; i < sims.length; i++) {
writeSimulation(simChapter, sims[i]);
}
document.add(simChapter);
} else {
System.err.println("Bad Request: No simulations to publish for Mathmodel: " + name);
}
}
if (preferences.includeGeom()) {
// unlike biomodels, geometry is a chapter, not a chapter section.
Geometry geom = mathModel.getMathDescription().getGeometry();
if (geom != null) {
Chapter geomChapter = new Chapter("Geometry", chapterNum++);
if (introSection == null) {
introSection = geomChapter.addSection("General Info", geomChapter.numberDepth() + 1);
writeMetadata(introSection, name, mathModel.getDescription(), userName, "MathModel");
}
writeGeom(geomChapter, geom, null);
document.add(geomChapter);
} else {
System.err.println("Bad Request: No geometry to publish for Mathmodel: " + name);
}
}
document.close();
} catch (DocumentException e) {
System.err.println("Unable to publish MathModel.");
e.printStackTrace();
throw e;
}
}
Aggregations