Package simtools.ui

Examples of simtools.ui.HTMLWriter


        // Write toc_jsynoptic.html
        try{
            File indexFile = new File(outputDirectory, TOC_FILE_NAME);
            FileWriter writeFile= new FileWriter(indexFile);
            BufferedWriter writeBuf = new BufferedWriter(writeFile);   
            HTMLWriter writer = new HTMLWriter(writeBuf);
            writer.writeHtmlBegin();
            writer.writeBodyBegin();
           
            writer.writeHeadBegin();
            writer.writeTitle("JSynoptic Help");
            writer.writeHeadEnd();
           
            writer.writeH1("JSynoptic Help", null);

            // write the help index of contents
            createIndexOfContentsHTMLFiles(helpContents, writer);

            writer.writeBodyEnd();
            writer.writeHtmlEnd();
            writeBuf.close();
            writeFile.close();
            _logger.fine("File "+ TOC_FILE_NAME  + " successfully created at " + outputDirectory);

        } catch (IOException  e){
            _logger.severe("Cannot write index.html content. Reason is \n" + e.getMessage());
        }
       
       
        // Write jsynoptic.html
        try{
            File entryxFile = new File(outputDirectory, ENTRY_FILE_NAME);
            FileWriter writeFile= new FileWriter(entryxFile);
            BufferedWriter writeBuf = new BufferedWriter(writeFile);   
            HTMLWriter writer = new HTMLWriter(writeBuf);
            writer.writeHtmlBegin();

            writer.writeHeadBegin();
            writer.writeTitle("JSynoptic Help");
            writer.writeHeadEnd();
           
            writer.writeFrameSetBegin("33%,*");
            writer.writeFrame(TOC_FRAME_NAME, TOC_FILE_NAME);
            writer.writeFrame(CONTENT_FRAME_NAME, CONTENT_FIRST_PAGE_NAME);
           
            writer.writeNoframesBegin();
            writer.writeBodyBegin();
            writer.writeP("You must use a FRAME available browser");
            writer.writeBodyEnd();
            writer.writeNoframesEnd();
           
           
            writer.writeFrameSetEnd();

            writer.writeHtmlEnd();
            writeBuf.close();
            writeFile.close();
            _logger.fine("File "+ ENTRY_FILE_NAME  + " successfully created at " + outputDirectory);

        } catch (IOException  e){
View Full Code Here


    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
View Full Code Here

TOP

Related Classes of simtools.ui.HTMLWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.