Java Code Examples for javax.swing.text.StyleConstants#setLeftIndent()
The following examples show how to use
javax.swing.text.StyleConstants#setLeftIndent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OurConsole.java From org.alloytools.alloy with Apache License 2.0 | 6 votes |
static MutableAttributeSet style(String fontName, int fontSize, boolean boldness, boolean italic, boolean strike, Color color, int leftIndent) { fontName = AlloyGraphics.matchBestFontName(fontName); MutableAttributeSet s = new SimpleAttributeSet(); StyleConstants.setFontFamily(s, fontName); StyleConstants.setFontSize(s, fontSize); StyleConstants.setLineSpacing(s, -0.2f); StyleConstants.setBold(s, boldness); StyleConstants.setItalic(s, italic); StyleConstants.setForeground(s, color); StyleConstants.setLeftIndent(s, leftIndent); StyleConstants.setStrikeThrough(s, strike); return s; }
Example 2
Source File: SummaryCellRenderer.java From netbeans with Apache License 2.0 | 4 votes |
private Style createNoindentStyle (JTextPane textPane) { Style noindentStyle = textPane.addStyle("noindent", null); //NOI18N StyleConstants.setLeftIndent(noindentStyle, 0); return noindentStyle; }
Example 3
Source File: JavaSourceDocument.java From spotbugs with GNU Lesser General Public License v2.1 | 4 votes |
public JavaSourceDocument(String title, Reader in, SourceFile theSource) throws IOException { doc = new DefaultStyledDocument(); this.title = title; this.sourceFile = theSource; Debug.println("Created JavaSourceDocument for " + title); try { dek.read(in, doc, 0); } catch (BadLocationException e) { throw new RuntimeException(e); } in.close(); doc.putProperty(Document.TitleProperty, title); // root = doc.getDefaultRootElement(); Toolkit toolkit = Toolkit.getDefaultToolkit(); FontMetrics fontMetrics = toolkit.getFontMetrics(sourceFont); TabStop[] tabs = new TabStop[50]; float width = fontMetrics.stringWidth(" "); int tabSize = GUISaveState.getInstance().getTabSize(); for (int i = 0; i < tabs.length; i++) { tabs[i] = new TabStop(width * (tabSize + tabSize * i)); } TAB_SET = new TabSet(tabs); StyleConstants.setTabSet(commentAttributes, TAB_SET); StyleConstants.setTabSet(javadocAttributes, TAB_SET); StyleConstants.setTabSet(quotesAttributes, TAB_SET); StyleConstants.setTabSet(keywordsAttributes, TAB_SET); StyleConstants.setTabSet(commentAttributes, TAB_SET); StyleConstants.setTabSet(whiteAttributes, TAB_SET); StyleConstants.setFontFamily(whiteAttributes, sourceFont.getFamily()); StyleConstants.setFontSize(whiteAttributes, sourceFont.getSize()); StyleConstants.setLeftIndent(whiteAttributes, NumberedParagraphView.NUMBERS_WIDTH); doc.setParagraphAttributes(0, doc.getLength(), whiteAttributes, true); JavaScanner parser = new JavaScanner(new DocumentCharacterIterator(doc)); while (parser.next() != JavaScanner.EOF) { int kind = parser.getKind(); switch (kind) { case JavaScanner.COMMENT: doc.setCharacterAttributes(parser.getStartPosition(), parser.getLength(), commentAttributes, true); break; case JavaScanner.KEYWORD: doc.setCharacterAttributes(parser.getStartPosition(), parser.getLength(), keywordsAttributes, true); break; case JavaScanner.JAVADOC: doc.setCharacterAttributes(parser.getStartPosition(), parser.getLength(), javadocAttributes, true); break; case JavaScanner.QUOTE: doc.setCharacterAttributes(parser.getStartPosition(), parser.getLength(), quotesAttributes, true); break; default: break; } } }