Package net.sf.jpluck.plucker

Examples of net.sf.jpluck.plucker.Document$Index


        String name = jxlDocument.getName();
        if (jxlDocument.isRemoveAccents()) {
          name = Database.convertToDatabaseName(name);
        }
        Document document = new Document(name, ClientConfiguration.getDefault().getCompression());

        Date date = jxlDocument.getDate();
        if (date != null) {
          document.setCreationDate(date);
          document.setModificationDate(date);
        }
        spider = new Spider(document, jxlDocument, httpCache, cookieStore, maxConnections,
                  Spider.DEFAULT_MAX_PARSE_THREADS, httpTimeout);
        try {
          for (Iterator iterator = spiderListenerList.iterator(); iterator.hasNext();) {
            SpiderListener spiderListener = (SpiderListener) iterator.next();
            spider.addSpiderListener(spiderListener);
          }
          if (!running) {
            break;
          }
          spider.run();
        } finally {
          for (Iterator iterator = spiderListenerList.iterator(); iterator.hasNext();) {
            SpiderListener spiderListener = (SpiderListener) iterator.next();
            spider.removeSpiderListener(spiderListener);
          }
        }

        boolean success = false;
        if (!running) {
          break;
        }

        String uri = jxlDocument.getStartingURI().toString();
        if (document.contains(uri)) {
          try {
            document.setHome(uri);
            document.setOutputEncoding(jxlDocument.getOutputEncoding());
            document.setIncludeImageAltText(jxlDocument.isIncludeAltText());
            document.setCategories(jxlDocument.getCategories());
            document.setDefaultLinkColor(jxlDocument.getLinkColor());
            document.setUnresolvedLinkColor(jxlDocument.getUnresolvedLinkColor());
            document.setRemoveUnresolvedLinks(jxlDocument.isRemoveUnresolvedLinks());
            document.setIncludeURIInfo(jxlDocument.isIncludeURIInfo());
            document.setBackup(jxlDocument.isSetBackupBit());
            document.setEncoding(jxlDocument.getOutputEncoding());
            // Sort bookmarks for sites
            if (jxlDocument instanceof Site) {
              Site site = (Site) jxlDocument;
              if (site.isSortBookmarks()) {
                document.sortBookmarks();
              }
            }

            fireGenerationStarted(jxlDocument);
            for (Iterator it = recordListenerList.iterator(); it.hasNext();) {
              document.addRecordListener((RecordListener) it.next());
            }
            document.setFilename(jxlDocument.getFilename());
            long size = destination.write(document);
            jxlDocument.converted(size);
            fireGenerationCompleted(jxlDocument);
            logger.info("Completed conversion: " + jxlDocument.getName());
            success = true;
          } catch (Exception e) {
            logger.severe("Could not generate document: " + e.getClass() + " " + e.getMessage());
            e.printStackTrace();
          } finally {
            for (Iterator it = recordListenerList.iterator(); it.hasNext();) {
              document.removeRecordListener((RecordListener) it.next());
            }
          }
        } else {
          logger.severe(jxlDocument.getName() + ": could not load starting URI " + jxlDocument.getUri() +
                  ". Document cannot be generated.");
View Full Code Here


        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        for (int bytesRead; (bytesRead = System.in.read(buf)) != -1; ) {
          baos.write(buf, 0, bytesRead);
        }
        byte[] data = baos.toByteArray();
        Document document = new Document();
        if (mimeType.equals("text/html")) {
      Resource resource = new Resource("http://127.0.0.1/", null, new ContentType(mimeType), data, 0, false);
      org.w3c.dom.Document dom = resource.parseHTML();
      TextRecord textRecord = new TextRecord("http://127.0.0.1/");
      Transformer transformer = TransformerFactory.newInstance().newTransformer();
      TextRecordResult result = new TextRecordResult(textRecord, new URIRewriter(), 100, false, document);
      transformer.transform(new DOMSource(dom), result);
      document.addRecord(textRecord);
        } else if (mimeType.startsWith("image/")) {
      BufferedImage image = ImageIO.read(new ByteArrayInputStream(data));
      CompositeBitmap compositeBitmap = CompositeBitmap.create(image, bpp);
      String[] uris = new String[compositeBitmap.getRows()];
      for (int j = 0, n = compositeBitmap.getRows(); j < n; j++) {
        uris[j] = "http://127.0.0.1/-" + j;
        document.addRecord(new ImageRecord(uris[j], compositeBitmap.getBitmapAt(j, 0)));
      }
      document.addRecord(new CompositeImageRecord("http://127.0.0.1/", uris, 1));
        }

        if (name.length() > 31) {
            name = name.substring(0, 31).trim();
        }
        LogUtil logUtil = new LogUtil(LogUtil.DEFAULT_LOGGER_NAMES);
        logUtil.setLevel(Level.OFF);
        document.setName(name);
        document.setHome("http://127.0.0.1/");
        document.setCompression(Document.ZLIB_COMPRESSION);
        document.setIncludeURIInfo(false);
        document.write(System.out);
    }
View Full Code Here

import net.sf.jpluck.plucker.TextRecord;

public class BookmarkTest {

  public static void main(String[] args) throws Exception {
    Document document = new Document("Bookmark Test");
    for (int i = 1; i <= 10; i++) {
      String uri = "page" + i;
      TextRecord page = new TextRecord(uri);
      String name = "Page " + i;
      page.addParagraph().addFontH1().addText(name).addAnchor("anchor");
     
      document.addBookmark(name, uri + "#anchor");
      document.addRecord(page);
    }
    document.setIncludeURIInfo(true);
    document.setHome("page1");
    document.write(new File(args[0]));   
  }
View Full Code Here

    cell = row.addCell();
        cell.addText("sw");
        cell = row.addCell();
        cell.addText("se");

        Document document = new Document("Table test");
        document.setCompression(Document.NO_COMPRESSION);
        document.addRecord(home);
        document.setHome(home);
        document.addRecord(table);
        document.write(new File(args[0]));

    }
View Full Code Here

      maxHeight = Integer.parseInt(cl.getOptionValue("maxheight"));
    }
   
    boolean noBookmarks = cl.hasOption("nobookmarks");

    Document document = new Document(name, Document.ZLIB_COMPRESSION);
    String category = null;
    if (cl.hasOption("category")) {
      category = cl.getOptionValue("category");
      if (category.length() > 15) {
        category = category.substring(0, 15).trim();
      }
      document.setCategories(new String[] { category });
    }
   
    TextRecord home=new TextRecord("home");
    home.addParagraph().addFontH1().addText(name).addFontRegular();    

    for (int i = 1; i < arguments.length; i++) {
      System.out.println(arguments[i] + " (" + i + "/" + (arguments.length-1) + ")");
      File file = new File(arguments[i]);
      if (!file.isFile()) {
        throw new IOException("Not a file: " + file.getAbsolutePath());
      }
      BufferedImage image = ImageIO.read(file);

      int width = image.getWidth();
      int height = image.getHeight();
      image = ImageConverter.rescale(image, ((maxWidth > 0) ? maxWidth : width),
                   ((maxHeight > 0) ? maxHeight : height));

      CompositeBitmap compositeBitmap = CompositeBitmap.create(image, bpp);
      String uri = file.toURI().toString();     
      home.addParagraph(2).addText(i + " ").addLinkStart(uri).addText(file.getName()).addLinkEnd();
     
      String[] uris = new String[compositeBitmap.getRows()];
      for (int j = 0, n = compositeBitmap.getRows(); j < n; j++) {
        uris[j] = uri + "-" + j;
        document.addRecord(new ImageRecord(uris[j], compositeBitmap.getBitmapAt(j, 0)));
      }
      document.addRecord(new CompositeImageRecord(uri, uris, 1));
      if (!noBookmarks) {
        document.addBookmark(file.getName(), uri);
      }
    }

    document.addRecord(home);
    document.setHome(home);

    System.out.println("Writing " + pdbFile.getAbsolutePath());
    document.write(pdbFile);
    System.out.println("Done!");
  }
View Full Code Here

    return String.valueOf(characters, index++, len);
  }

  @Override
  public Index getIndex(int bookmark) {
    return new Index(bookmark, index);
  }
View Full Code Here

    int ni = shape[0];
    int nj = shape[1];
    int nk = shape[2];

    array = new ArrayDouble.D3(ni, nj, nk);
    Index index = array.getIndex();

    for (int i = 0; i < ni; i++) {
      for (int j = 0; j < nj; j++) {
        for (int k = 0; k < nk; k++) {
          index.set(i, j, k);
          double d = pertArray.getDouble(index)
              + baseArray.getDouble(index);
          if (isZStag) {
            d = d / 9.81//convert geopotential to height
          }
View Full Code Here

      IndexChunker.printl(" dataStrides=", dataStrides);
      IndexChunker.printa(" wantStride=", resultStrides);
      System.out.println(" indexChunks=" + Index.computeSize(shape));
    }
    dataIndex = new IndexLong(shape, dataStrides);
    resultIndex = new Index(shape, resultStrides);

    if (debugDetail) {
      System.out.println(" dataIndex="+ dataIndex.toString());
      System.out.println(" resultIndex="+ resultIndex.toStringDebug());
    }
View Full Code Here

    Array data = v.read();
    int[] shape = data.getShape();
    assert shape[0] == 1000;
    assert shape[1] == 20;

    Index ima = data.getIndex();
    for (int i = 0; i < 1000; i++)
      for (int j = 0; j < 20; j++) {
        int val = data.getInt(ima.set(i, j));
        assert val == i + j : val + " != " + (i + j);
      }

  }
View Full Code Here

        Array dataArray =
            Array.factory(v2.getDataType().getPrimitiveClassType(),
                          section.getShape());

        Index dataIndex = dataArray.getIndex();

        if (varname.equals("latitude") || varname.equals("longitude")) {
            double[][] pixel = new double[2][1];
            double[][] latLon;
            double[][][] latLonValues =
                new double[geoXRange.length()][geoYRange.length()][2];

            // Use Range object, which calculates requested i, j
            // values and incorporates stride
            for (int i = 0; i < geoXRange.length(); i++) {
                for (int j = 0; j < geoYRange.length(); j++) {
                    pixel[0][0] = (double) geoXRange.element(i);
                    pixel[1][0] = (double) geoYRange.element(j);
                    latLon      = nav.toLatLon(pixel);

                    if (varname.equals("lat")) {
                        dataArray.setFloat(dataIndex.set(j, i),
                                           (float) (latLon[0][0]));
                    } else {
                        dataArray.setFloat(dataIndex.set(j, i),
                                           (float) (latLon[1][0]));
                    }
                }
            }
        }

        if (varname.equals("image")) {
            try {
                int[][] pixelData = new int[1][1];
                if (bandRange != null) {
                    for (int k = 0; k < bandRange.length(); k++) {
                        int bandIndex = bandRange.element(k) + 1// band numbers in McIDAS are 1 based
                        for (int j = 0; j < geoYRange.length(); j++) {
                            for (int i = 0; i < geoXRange.length(); i++) {
                                pixelData = af.getData(geoYRange.element(j),
                                        geoXRange.element(i), 1, 1,
                                        bandIndex);
                                dataArray.setInt(dataIndex.set(0, k, j, i),
                                        (pixelData[0][0]));
                            }
                        }
                    }

                } else {
                    for (int j = 0; j < geoYRange.length(); j++) {
                        for (int i = 0; i < geoXRange.length(); i++) {
                            pixelData = af.getData(geoYRange.element(j),
                                    geoXRange.element(i), 1, 1);
                            dataArray.setInt(dataIndex.set(0, j, i),
                                             (pixelData[0][0]));
                        }
                    }

                }
View Full Code Here

TOP

Related Classes of net.sf.jpluck.plucker.Document$Index

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.