ImageIO.write(bi,resources.getString("imageFileExtension"),_imageFile);
_htmlFile = new File(resources.getString("htmlFileName")).getCanonicalFile();
FileWriter writeFile= new FileWriter(_htmlFile);
BufferedWriter writeBuf = new BufferedWriter(writeFile);
HTMLWriter writer = new HTMLWriter(writeBuf);
writer.writeHtmlBegin();
try{
writer.writeTargetName("IMAGETARGET");
writer.writeH1(sheetInformationTitle, null);
// make links with descrition
String[][] targets = new String[sheet.size()][5];
for(int i=0;i<sheet.size();i++){
Object o = sheet.get(i);
if (o instanceof AbstractShape) {
AbstractShape shape = (AbstractShape)o;
// left-x, top-y, right-x, bottom-y
targets[i][0] = new Integer(shape.getBounds().x).toString();
targets[i][1] = new Integer(shape.getBounds().y).toString();
targets[i][2] = new Integer(shape.getBounds().x + CIRCLE_SIZE+4).toString();
targets[i][3] = new Integer(shape.getBounds().y + CIRCLE_SIZE+4).toString();
// target name
targets[i][4] = getShapeId(shape, i);
}
}
// Write image with links
writer.writeImage(_imageFile.getName(),resources.getString("imageFileTitle"), "IMAGEMAP", targets);
}catch (IOException e){
e.printStackTrace();
}
// Create sheet information
for(int i=0;i<sheet.size();i++){
Object o = sheet.get(i);
if (o instanceof AbstractShape) {
AbstractShape shape = (AbstractShape)o;
// Shape name
writer.writeTargetName(getShapeId(shape,i));
writer.writeH2(getShapeId(shape, i),null);
// Shape properties
String[] propertiesNames = shape.getPropertyNames();
ArrayList contents = new ArrayList();
if (propertiesNames!=null){
for(int j=0;j<propertiesNames.length;j++){
String[] property = new String[2];
property[0] = propertiesNames[j];
Object obj = shape.getPropertyValue(propertiesNames[j]);
if (obj!=null){
if (obj instanceof NamedProperties){
String[] objPropertiesNames = ((NamedProperties)obj).getPropertyNames();
String objToString="";
for(int k=0;k<objPropertiesNames.length;k++){
objToString+=objPropertiesNames[k] + " = " + ((NamedProperties)obj).getPropertyValue(objPropertiesNames[k]) + "\n";
}
property[1] = objToString;
}else if (obj instanceof DataSource){
property[1] = DataInfo.getAll(obj);
}else{
property[1] = obj.toString();
}
contents.add(property);
}
}
}
writer.writeTab(propertyTabTitles, contents);
writer.writeP(resources.getString("goBackToImage"), "IMAGETARGET");
writer.writeSeparator();
}
}
writer.writeHtmlEnd();
writeBuf.close();
writeFile.close();
// set html chooser for saving