Package com.lowagie.tools.swing.treenodes

Source Code of com.lowagie.tools.swing.treenodes.StreamTreeNode

/*
* $Id: StreamTreeNode.java 49 2007-05-19 19:24:42Z chammer $
* Copyright (c) 2005-2007 Carsten Hammer, Bruno Lowagie
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

/*
* This class was originally published under the MPL by Carsten Hammer.
* It was a part of iText, a Java-PDF library. You can now use it under
* the MIT License; for backward compatibility you can also use it under
* the MPL version 1.1: http://www.mozilla.org/MPL/
* A copy of the MPL license is bundled with the source code FYI.
*/
package com.lowagie.tools.swing.treenodes;

import java.io.IOException;

import javax.swing.Icon;
import javax.swing.ImageIcon;

import com.lowagie.text.pdf.PRStream;
import com.lowagie.text.pdf.PdfObject;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.tools.swing.interfaces.UpdateNodeView;

public class StreamTreeNode extends AbstractTreeNode {

  /** a serial version id. */
  private static final long serialVersionUID = -4383073664537340974L;

  /** a PDF object. */
  protected PdfObject contents;

  /** A marker. */
  protected String marker;

    /**
     * Constructs a textpane tree node
     *
     * @param contents PdfObject
     * @param marker String
     */
    public StreamTreeNode(PdfObject contents, String marker) {
    super(contents, false);
    this.contents = contents;
    this.marker = marker;
  }

  public void updateview(UpdateNodeView updateobject) {
    if (contents.isStream()) {
      PRStream content_stream = (PRStream) contents;
      try {
        byte content[] = PdfReader.getStreamBytes(content_stream);
        updateobject.showtext(new String(content));
      } catch (IOException ex) {
      }
    }
  }

    /**
     * Returns the marker.
     *
     * @return String
     */
    public String toString() {
    return marker;
  }

    /**
     * Shows the icon for a String.
     *
     * @return Icon
     */
    public Icon getIcon() {
    return new ImageIcon(StreamTreeNode.class
        .getResource("string.gif"));
  }

}
TOP

Related Classes of com.lowagie.tools.swing.treenodes.StreamTreeNode

TOP
Copyright © 2018 www.massapi.com. 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.