Package javax.swing.text

Examples of javax.swing.text.StyledDocument


        textPane.setText(theVal);
        if (commentedOut) {
            textPane.setText("// " + textPane.getText());
        }
//        textPane.setSize(textPane.getPreferredSize());
        StyledDocument doc = textPane.getStyledDocument();
//        doc.setParagraphAttributes(0, doc.getLength(), linespacingStyle, false);
        resetStyles(doc);

        if (selected) {
            doc.setParagraphAttributes(0, doc.getLength(), selectionForeground, false);
        }
        else {
            doc.setParagraphAttributes(0, doc.getLength(), foreground, false);
        }

        if (commentedOut) {
            doc.setParagraphAttributes(0, doc.getLength(), commentedOutStyle, false);
            return;
        }
        else if (inferred) {

        }

        if (strikeThrough) {
            doc.setParagraphAttributes(0, doc.getLength(), strikeOutStyle, false);
        }
       
        // set the results styles
        if(anytimeResults.isNewAddedObject((OWLObject) value)){
          doc.setParagraphAttributes(0, doc.getLength(), newAddedEntityStyle, false);
        }
       
        if(anytimeResults.isConfirmedObject((OWLObject) value)){
          doc.setParagraphAttributes(0, doc.getLength(), confirmedEntityStyle, false);
        }
       
        if(anytimeResults.isRevisedObject((OWLObject) value)){
          doc.setParagraphAttributes(0, doc.getLength(), revisedEntityStyle, false);
        }

        if (ontology != null) {
            if (OWLRendererPreferences.getInstance().isHighlightActiveOntologyStatements() && getOWLModelManager().getActiveOntology().equals(
                    ontology)) {
                doc.setParagraphAttributes(0, doc.getLength(), boldStyle, false);
            }
            else {
                doc.setParagraphAttributes(0, doc.getLength(), nonBoldStyle, false);
            }
        }
        else {
            textPane.setFont(plainFont);
        }
View Full Code Here


    private Style strikeOutStyle;

    private Style fontSizeStyle;

    private void prepareStyles() {
        StyledDocument doc = textPane.getStyledDocument();
        Map<String, Color> keyWordColorMap = owlEditorKit.getWorkspace().getKeyWordColorMap();
        for (String keyWord : keyWordColorMap.keySet()) {
            Style s = doc.addStyle(keyWord, null);
            Color color = keyWordColorMap.get(keyWord);
            StyleConstants.setForeground(s, color);
            StyleConstants.setBold(s, true);
        }
        plainStyle = doc.addStyle("PLAIN_STYLE", null);
//        StyleConstants.setForeground(plainStyle, Color.BLACK);
        StyleConstants.setItalic(plainStyle, false);
        StyleConstants.setSpaceAbove(plainStyle, 0);
//        StyleConstants.setFontFamily(plainStyle, textPane.getFont().getFamily());

        boldStyle = doc.addStyle("BOLD_STYLE", null);
        StyleConstants.setBold(boldStyle, true);


        nonBoldStyle = doc.addStyle("NON_BOLD_STYLE", null);
        StyleConstants.setBold(nonBoldStyle, false);

        selectionForeground = doc.addStyle("SEL_FG_STYPE", null);
        StyleConstants.setForeground(selectionForeground, SELECTION_FOREGROUND);

        foreground = doc.addStyle("FG_STYLE", null);
        StyleConstants.setForeground(foreground, FOREGROUND);

        linkStyle = doc.addStyle("LINK_STYLE", null);
        StyleConstants.setForeground(linkStyle, Color.BLUE);
        StyleConstants.setUnderline(linkStyle, true);

        inconsistentClassStyle = doc.addStyle("INCONSISTENT_CLASS_STYLE", null);
        StyleConstants.setForeground(inconsistentClassStyle, Color.RED);

        focusedEntityStyle = doc.addStyle("FOCUSED_ENTITY_STYLE", null);
        StyleConstants.setForeground(focusedEntityStyle, Color.BLACK);
        StyleConstants.setBackground(focusedEntityStyle, new Color(220, 220, 250));
       
        newAddedEntityStyle = doc.addStyle("NEWADDED_ENEITY_STYLE", null);
        StyleConstants.setForeground(newAddedEntityStyle, Color.GRAY);
       
        confirmedEntityStyle = doc.addStyle("CONFIRMED_ENTITY_STYLE", null);
        StyleConstants.setForeground(confirmedEntityStyle, Color.BLACK);
        StyleConstants.setBold(confirmedEntityStyle, true);
       
        revisedEntityStyle = doc.addStyle("REVISED_ENEITY_STYLE", null);
        StyleConstants.setForeground(revisedEntityStyle, Color.BLUE);
        StyleConstants.setStrikeThrough(revisedEntityStyle, true);
        StyleConstants.setBold(revisedEntityStyle, false);

//        linespacingStyle = doc.addStyle("LINE_SPACING_STYLE", null);
//        StyleConstants.setLineSpacing(linespacingStyle, 0.0f);

        annotationURIStyle = doc.addStyle("ANNOTATION_URI_STYLE", null);
        StyleConstants.setForeground(annotationURIStyle, Color.BLUE);
        StyleConstants.setItalic(annotationURIStyle, true);

        ontologyURIStyle = doc.addStyle("ONTOLOGY_URI_STYLE", null);
        StyleConstants.setForeground(ontologyURIStyle, Color.GRAY);

        commentedOutStyle = doc.addStyle("COMMENTED_OUT_STYLE", null);
        StyleConstants.setForeground(commentedOutStyle, Color.GRAY);
        StyleConstants.setItalic(commentedOutStyle, true);

        strikeOutStyle = doc.addStyle("STRIKE_OUT", null);
        StyleConstants.setStrikeThrough(strikeOutStyle, true);
        StyleConstants.setBold(strikeOutStyle, false);

        fontSizeStyle = doc.addStyle("FONT_SIZE", null);
        StyleConstants.setFontSize(fontSizeStyle, 40);
    }
View Full Code Here

       
        FindReplaceUtility.registerTextComponent(this);
    }

    public int getNumberOfPages() {
        StyledDocument doc = (StyledDocument)getDocument();
       
        Paper paper = PAGE_FORMAT.getPaper();
       
        numPages =
            (int)Math.ceil(getSize().getHeight() / paper.getImageableHeight());
View Full Code Here

    }
   
    public int print(Graphics graphics, PageFormat pageFormat, int page)
        throws PrinterException {
        if (page < numPages) {
            StyledDocument doc = (StyledDocument)getDocument();
            Paper paper = pageFormat.getPaper();

            // initialize the PRINT_PANE (need this so that wrapping
            // can take place)
            PRINT_PANE.setDocument(getDocument());
View Full Code Here

    Style outputStyle;
    private GroovyShell shell;
    int counter;

    protected void addStylesToDocument(JTextPane outputArea) {
        StyledDocument doc = outputArea.getStyledDocument();

        Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);

        Style regular = doc.addStyle("regular", def);
        StyleConstants.setFontFamily(def, "Monospaced");

        promptStyle = doc.addStyle("prompt", regular);
        StyleConstants.setForeground(promptStyle, Color.BLUE);

        commandStyle = doc.addStyle("command", regular);
        StyleConstants.setForeground(commandStyle, Color.MAGENTA);

        outputStyle = doc.addStyle("output", regular);
        StyleConstants.setBold(outputStyle, true);
    }
View Full Code Here

    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        JTextPane errorPane = new JTextPane();
        errorPane.setEditable(false);

        StyledDocument errorDoc = errorPane.getStyledDocument();
        addStyles(errorDoc);
        insertStyledString(errorDoc, "bold", "Debugging & Error Log (" + phase + "):\n");


        JTextPane outputTextPane = new JTextPane();
        //outputTextPane.setDragEnabled(true);
        makeUndoable(outputTextPane);
        //outputTextArea.setEditable(false);

        StyledDocument outputDoc = outputTextPane.getStyledDocument();
        addStyles(outputDoc);
        insertStyledString(outputDoc, "bold", "Action log (" + phase + "):\n");

        JSplitPane splitPane = new JSplitPane();
        splitPane.setLeftComponent(new JScrollPane(errorPane));
View Full Code Here

        final File rule = settings.getRuleFile();
        DataObject c = (DataObject) activatedNodes[0].getCookie(DataObject.class);
       
       
        EditorCookie editor = (EditorCookie) c.getCookie(EditorCookie.class);
        final StyledDocument doc = editor.getDocument();
       
        NbDocument.runAtomic(doc,new Runnable(){
            public void run() {
                try {
                    String input = doc.getText(0,doc.getLength());
                    StringWriter output = new StringWriter();
                   
                    Jalopy jal = new Jalopy();
                    if (rule!=null && rule.exists() && rule.isFile()){
                        try {
                            jal.setConvention(rule);
                        } catch (IOException ex) {
                            ex.printStackTrace();
                        }
                    }
                    jal.setInput(input,"what is this?");
                    jal.setOutput(output);
                    jal.format();
                    doc.remove(0,doc.getLength());
                    doc.insertString(0,output.getBuffer().toString(),null);
                } catch (BadLocationException ex) {
                    ex.printStackTrace();
                }
            }
           
View Full Code Here

        DataObject dataObject = getDataObject(url);
        if (dataObject != null) {
            EditorCookie ec = dataObject.getLookup().lookup(EditorCookie.class);
            if (ec != null) {
                try {
                    StyledDocument doc = ec.openDocument();
                    JEditorPane[] eps = ec.getOpenedPanes();
                    if (eps != null && eps.length > 0) {
                        JumpList.addEntry(eps[0], NbDocument.findLineOffset(doc, l.getLineNumber()) + column);
                    }
                } catch (java.io.IOException ioex) {
View Full Code Here

    private String getSelectedMethodName_() {
        JEditorPane ep = contextDispatcher.getCurrentEditor();
        if (ep == null) {
            return "";
        }
        StyledDocument doc = (StyledDocument) ep.getDocument();
        if (doc == null) {
            return "";
        }
        int offset = ep.getCaret().getDot();
        String t = null;
//        if ( (ep.getSelectionStart () <= offset) &&
//             (offset <= ep.getSelectionEnd ())
//        )   t = ep.getSelectedText ();
//        if (t != null) return t;

        int line = NbDocument.findLineNumber(
                doc,
                offset);
        int col = NbDocument.findLineColumn(
                doc,
                offset);
        try {
            javax.swing.text.Element lineElem =
                    org.openide.text.NbDocument.findLineRootElement(doc).
                    getElement(line);

            if (lineElem == null) {
                return "";
            }
            int lineStartOffset = lineElem.getStartOffset();
            int lineLen = lineElem.getEndOffset() - lineStartOffset;
            // t contains current line in editor
            t = doc.getText(lineStartOffset, lineLen);

            int identStart = col;
            while (identStart > 0 &&
                    Character.isJavaIdentifierPart(
                    t.charAt(identStart - 1))) {
View Full Code Here

        }
        EditorCookie ec = (EditorCookie) dataObject.getLookup().lookup(EditorCookie.class);
        if (ec == null) {
            return "";
        }
        StyledDocument doc;
        try {
            doc = ec.openDocument();
        } catch (IOException ex) {
            ErrorManager.getDefault().notify(ex);
            return "";
View Full Code Here

TOP

Related Classes of javax.swing.text.StyledDocument

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.