In Wisedraw2Converter.java I have commented out the pod code but when the step is transferred to otml, it's empty and just looks like this below
<OTGenericOTrunkStep />
I noticed there was code utilizing a URL to insert the data into the step.
URL podURL = addToArchive("drawing.otml", otmlInput);
step.setAuthoredDataURL(podURL);
It creates a "drawing.otml" file and then sets the step to point to it but this utilizes pods and throws a nullpointer.
Trying this
step.setTarget(drawingTool);
accomplishes nothing as well.
How can I insert the data into the step?
Here's the code in the Wisedraw2Converter.java after commenting out the pod stuff.
public PasStep getTypedPasStep() {
OTrunkStep step = new OTrunkStep();
/*
* The java code below creates this xml file
*
<otrunk>
<imports>
<import class="org.concord.otrunk.OTSystem"/>
<import class="org.concord.otrunk.view.OTViewEntry"/>
<import class="org.concord.otrunk.view.OTViewService"/>
<import class="org.concord.graph.util.state.OTDrawingTool"/>
<import class="org.concord.otrunk.view.document.OTCompoundDoc"/>
</imports>
<objects>
<OTSystem>
<services>
<OTViewService>
<viewEntries>
<OTViewEntry
objectClass="org.concord.graph.util.state.OTDrawingTool"
viewClass="org.concord.datagraph.state.OTDataDrawingToolView"/>
<OTViewEntry
objectClass="org.concord.otrunk.view.document.OTDocument"
viewClass="org.concord.otrunk.view.document.OTDocumentView"/>
</viewEntries>
</OTViewService>
</services>
<root>
<OTCompoundDoc>
<bodyText>
Hello World<br/>
<object refid="${drawing1}"/>
</bodyText>
<documentRefs>
<OTDrawingTool local_id="drawing1"/>
</documentRefs>
</OTCompoundDoc>
</root>
</OTSystem>
</objects>
</otrunk>
*/
// Need to create the OTrunk state here
OTDatabase otDb = new XMLDatabase();
OTDrawingTool drawingTool = null;
try {
OTrunk otrunk = new OTrunkImpl(otDb);
OTSystem system = (OTSystem)otrunk.createObject(OTSystem.class);
otrunk.setRoot(system);
OTObjectList bundles = system.getBundles();
OTViewBundle viewBundle =
(OTViewBundle) otrunk.createObject(OTViewBundle.class);
bundles.add(viewBundle);
OTViewEntry viewEntry;
// Create drawing tool view mapping
viewEntry = (OTViewEntry)otrunk.createObject(OTViewEntry.class);
viewEntry.setObjectClass(OTDrawingTool.class.getName());
viewEntry.setViewClass(OTDataDrawingToolView.class.getName());
viewBundle.getViewEntries().add(viewEntry);
// Create document view mapping
viewEntry = (OTViewEntry)otrunk.createObject(OTViewEntry.class);
viewEntry.setObjectClass(OTCompoundDoc.class.getName());
viewEntry.setViewClass(OTDocumentView.class.getName());
viewBundle.getViewEntries().add(viewEntry);
OTCompoundDoc compoundDoc =
(OTCompoundDoc)otrunk.createObject(OTCompoundDoc.class);
system.setRoot(compoundDoc);
drawingTool =
(OTDrawingTool)otrunk.createObject(OTDrawingTool2.class);
Map<String, URI> backgrounds = getNamedUris("backgrounds");
Set<Entry<String, URI>> entries = backgrounds.entrySet();
if(entries.size() > 0) {
Entry<String, URI> entry = entries.iterator().next();
URL backgroundURL = entry.getValue().toURL();
// This is a hack because there isn't a better way yet
BlobResource blobResource = new BlobResource(backgroundURL);
OTDataObject drawingToolDO =
otDb.getOTDataObject(null, drawingTool.getGlobalId());
drawingToolDO.setResource("backgroundImage", blobResource);
}
List<URI> stamps = getUris("stamps");
for (URI uri : stamps) {
URL url = uri.toURL();
OTDrawingStamp stamp =
(OTDrawingStamp)otrunk.createObject(OTDrawingStamp.class);
drawingTool.getStamps().add(stamp);
stamp.setAlwaysOn(true);
// This is a hack because there isn't a better way yet
BlobResource blobResource = new BlobResource(url);
OTDataObject stampDO =
otDb.getOTDataObject(null, stamp.getGlobalId());
stampDO.setResource("src", blobResource);
}
String instructionText = getInstructionText();
// Strip off the header
instructionText =
instructionText.replaceFirst("(?s).*<body>(.*)</body>.*", "$1");
instructionText += "<object refid=\"" +
drawingTool.otExternalId() + "\"/>";
compoundDoc.setBodyText(instructionText);
// now we need to write out this database to a file and then
// refer to that file url
File outputFile = File.createTempFile("drawing", "otml");
ExporterJDOM.export(outputFile, otDb.getRoot(), otDb);
InputStream otmlInput = new FileInputStream(outputFile);
// URL podURL = addToArchive("drawing.otml", otmlInput);
//
// step.setAuthoredDataURL(podURL);
//
// // Setup the icons for this step
// URL iconUrl;
// BeanIcons icons = new BeanIcons();
//
// iconUrl = PasStepIconProvider.getIconUrl("draw", BeanInfo.ICON_COLOR_16x16);
// if(iconUrl != null){
// InputStream iconInput = iconUrl.openStream();
// URL podUrl = addToArchive(iconUrl.getFile(), iconInput);
// icons.setColor16x16(podUrl);
// }
// iconUrl = PasStepIconProvider.getIconUrl("draw", BeanInfo.ICON_COLOR_32x32);
// if(iconUrl != null){
// InputStream iconInput = iconUrl.openStream();
// URL podUrl = addToArchive(iconUrl.getFile(), iconInput);
// icons.setColor32x32(podUrl);
// }
// iconUrl = PasStepIconProvider.getIconUrl("draw", BeanInfo.ICON_MONO_16x16);
// if(iconUrl != null){
// InputStream iconInput = iconUrl.openStream();
// URL podUrl = addToArchive(iconUrl.getFile(), iconInput);
// icons.setMono16x16(podUrl);
// }
// iconUrl = PasStepIconProvider.getIconUrl("draw", BeanInfo.ICON_MONO_32x32);
// if(iconUrl != null){
// InputStream iconInput = iconUrl.openStream();
// URL podUrl = addToArchive(iconUrl.getFile(), iconInput);
// icons.setMono32x32(podUrl);
// }
} catch (Exception e){
e.printStackTrace();
}
//
// // FIXME need to take care of the introduction html
// // can try putting it in OTDocument later
// // step.setIntroductionHtml(getInstructionText());
//
//
// Rim<byte[]> rim = new Rim<byte[]>();
//
// //rim.setShape(String.class);
// rim.setShape(byte[].class);
// rim.setName("otrunk_drawing");
// step.setWorkRim(rim);
// getPod().add(rim);
//the stuff below here is Geoff trying to get the drawing data into the step and not part of the original converter
try {
//step.setAuthoredDataURL(new URL("hello"));
} catch(Exception e) {
e.printStackTrace();
}
//step.setTarget(drawingTool);
return step;
}
I've been extending the previous converter so that they can share the same code when needed.
Thanks,
Geoff