Package javax.swing.text

Examples of javax.swing.text.DefaultStyledDocument$ChangeDesc


  private void setMetrics() {
    Font refFont = null;
  
    Document doc = this.textComponent.getDocument();
    if(doc instanceof DefaultStyledDocument) {
        DefaultStyledDocument myDoc = (DefaultStyledDocument)doc;
        refFont = myDoc.getFont(myDoc.getDefaultRootElement().getElement(0)
          .getAttributes());
    } else {
        refFont = this.textComponent.getFont();
    }
View Full Code Here


   *  Extract the text from a rtf file
   */
  public void getDocument(String ifile, IndexableDoc doc)
  {
    String bodyText = "";
    DefaultStyledDocument styledDoc = new DefaultStyledDocument();
    logger.info("Extracting text from RTF :" + ifile);
    try
     { new RTFEditorKit().read(new FileInputStream(new File(ifile)), styledDoc, 0);
       if (styledDoc != null)
        { bodyText = styledDoc.getText(0, styledDoc.getLength()); }
     }
    //*-- RTF Editor Kit throws array index out of bounds exception for some I18N files
    catch (ArrayIndexOutOfBoundsException e)
     { logger.error("Array out of Bounds: Could not extract text from RTF document " + ifile); }
    catch (OutOfMemoryError exc)
View Full Code Here

                // know??"
                text // regular "the tips text"
        };

        String[] initStyles = { "bold", "regular" };
        Document doc = new DefaultStyledDocument();
        taArea0.cut();
        // Insert text on the panel
        try {
            for (int i = 0; i < initString.length; i++) {
                doc.insertString(doc.getLength(), initString[i], taArea0
                        .getStyle(initStyles[i]));
            }
            taArea0.setDocument(doc);
        } catch (BadLocationException ble) {
            System.err.println("Couldn't insert initial text.");
View Full Code Here

    public Document[] parse(final MultiProtocolURI location, final String mimeType,
            final String charset, final InputStream source)
            throws Parser.Failure, InterruptedException {

        try
            final DefaultStyledDocument doc = new DefaultStyledDocument();
           
            final RTFEditorKit theRtfEditorKit = new RTFEditorKit();              
            theRtfEditorKit.read(source, doc, 0);           
           
            final String bodyText = doc.getText(0, doc.getLength());
           
            return new Document[]{new Document(
                    location,
                    mimeType,
                    "UTF-8",
View Full Code Here

* @author Thierry Templier
*/
public class DefaultRtfDocumentHandler extends AbstractTypeFileDocumentHandler {

  protected String extractText(InputStream inputStream) throws IOException {
    DefaultStyledDocument styledDoc = new DefaultStyledDocument();
    try {
      new RTFEditorKit().read(inputStream, styledDoc, 0);
      return styledDoc.getText(0, styledDoc.getLength());
    } catch(BadLocationException ex) {
      ex.printStackTrace();
    }
    return null;
  }
View Full Code Here

    public void parse(
            InputStream stream, ContentHandler handler,
            Metadata metadata, ParseContext context)
            throws IOException, SAXException, TikaException {
        try {
            DefaultStyledDocument sd = new DefaultStyledDocument();
            new RTFEditorKit().read(stream, sd, 0);

            XHTMLContentHandler xhtml =
                new XHTMLContentHandler(handler, metadata);
            xhtml.startDocument();
            xhtml.element("p", sd.getText(0, sd.getLength()));
            xhtml.endDocument();
        } catch (BadLocationException e) {
            throw new TikaException("Error parsing an RTF document", e);
        } catch (InternalError e) {
            throw new TikaException(
View Full Code Here

  }

  private String convert(InputStream rtfDocumentInputStream) throws IOException {
    RTFEditorKit aRtfEditorkit = new RTFEditorKit();

    StyledDocument styledDoc = new DefaultStyledDocument();

    String textDocument;

    try {
      aRtfEditorkit.read(rtfDocumentInputStream, styledDoc, 0);

      textDocument = styledDoc.getText(0, styledDoc.getLength());
    } catch (BadLocationException e) {
      throw new IOException("Error during parsing");
    }

    return textDocument;
View Full Code Here

  {
    super();

    // Special TextPane which catches for cut and paste, both L&F keys and
    // programmatic  behaviour
    text = new JTextPane( doc=new DefaultStyledDocument() )
    {
      public void  cut() {
        if (text.getCaretPosition() < cmdStart)  {
          super.copy();
        } else {
View Full Code Here

   */
  protected IRC (String login)
  {
    StyleContext styleContext = new StyleContext();
    style = styleContext.getStyle(StyleContext.DEFAULT_STYLE);
    styledDocument = new DefaultStyledDocument(styleContext);
   
    listModel = new DefaultListModel();
    listModel.addElement(login);
  }
View Full Code Here

    } else {
      throw new IllegalArgumentException("Parameter must be instance of byte[]");
    }
    String ret = null;
    //creating a default blank styled document
    DefaultStyledDocument styledDoc = new DefaultStyledDocument();

    //Creating a RTF Editor kit
    RTFEditorKit rtfKit = new RTFEditorKit();

    //Populating the contents in the blank styled document
    try {
      rtfKit.read(is, styledDoc, 0);

      // Getting the root document
      Document doc = styledDoc.getDefaultRootElement().getDocument();

      //Printing out the contents of the RTF document as plain text
      ret = doc.getText(0, doc.getLength());
    } catch (IOException e) {
      throw new CRException(e);
View Full Code Here

TOP

Related Classes of javax.swing.text.DefaultStyledDocument$ChangeDesc

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.