當前位置: 首頁>>代碼示例>>Java>>正文


Java TextUI類代碼示例

本文整理匯總了Java中javax.swing.plaf.TextUI的典型用法代碼示例。如果您正苦於以下問題:Java TextUI類的具體用法?Java TextUI怎麽用?Java TextUI使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TextUI類屬於javax.swing.plaf包,在下文中一共展示了TextUI類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setParent

import javax.swing.plaf.TextUI; //導入依賴的package包/類
public @Override void setParent(View parent) {
    if (parent != null) { // start listening
        JTextComponent component = (JTextComponent)parent.getContainer();
        TextUI tui = component.getUI();
        if (tui instanceof BaseTextUI){
            editorUI = ((BaseTextUI)tui).getEditorUI();
            if (editorUI!=null){
                editorUI.addPropertyChangeListener(this);
            }
        }
    }

    super.setParent(parent);
    
    if (parent == null) {
        if (editorUI!=null){
            editorUI.removePropertyChangeListener(this);
            editorUI = null;
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:DrawEngineDocView.java

示例2: paint

import javax.swing.plaf.TextUI; //導入依賴的package包/類
public @Override void paint(Graphics g, Shape allocation) {
    java.awt.Component c = getContainer();
    if (c instanceof javax.swing.text.JTextComponent){
        TextUI textUI = ((javax.swing.text.JTextComponent)c).getUI();
        if (textUI instanceof BaseTextUI){
            EditorUiAccessor.get().paint(((BaseTextUI) textUI).getEditorUI(), g);
        }
    }

    super.paint(g, allocation);

    // #114712 - set the color to foreground so that the JTextComponent.ComposedTextCaret.paint()
    // does not render white-on-white.
    if (c != null) {
        g.setColor(c.getForeground());
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:DrawEngineDocView.java

示例3: getYFromPos

import javax.swing.plaf.TextUI; //導入依賴的package包/類
private int getYFromPos(int offset) throws BadLocationException {
    TextUI ui = pane.getUI();
    int result;
    
    // For some reason the offset may become -1; uncomment following line to see that
    offset = Math.max(offset, 0);
    if (ui instanceof BaseTextUI) {
        result = ((BaseTextUI) ui).getYFromPos(offset);
    } else {
        Rectangle r = pane.modelToView(offset);
        
        result = r != null ? r.y : 0;
    }
    
    if (result == 0) {
        return -1;
    } else {
        return result;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:AnnotationView.java

示例4: actionPerformed

import javax.swing.plaf.TextUI; //導入依賴的package包/類
public void actionPerformed(ActionEvent evt) {
    // Find the right action for the corresponding editor kit
    JTextComponent component = getTextComponent(evt);
    if (component != null) {
        TextUI ui = component.getUI();
        if (ui != null) {
            EditorKit kit = ui.getEditorKit(component);
            if (kit != null) {
                Action action = EditorUtilities.getAction(kit, actionName);
                if (action != null) {
                    action.actionPerformed(evt);
                } else {
                    if (LOG.isLoggable(Level.FINE)) {
                        LOG.fine("Action '" + actionName + "' not found in editor kit " + kit + '\n'); // NOI18N
                    }
                }
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:PresenterEditorAction.java

示例5: findEditorKeys

import javax.swing.plaf.TextUI; //導入依賴的package包/類
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey, JTextComponent component) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        TextUI componentUI = component.getUI();
        Keymap km = component.getKeymap();
        if (componentUI != null && km != null) {
            EditorKit kit = componentUI.getEditorKit(component);
            if (kit instanceof BaseKit) {
                 Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        ret = keys;
                    }
                }
            }
        }
    }
    return ret;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:DocumentationScrollPane.java

示例6: computeBounds

import javax.swing.plaf.TextUI; //導入依賴的package包/類
public void computeBounds(JTextPane textPane, BoundsTranslator translator) {
    Rectangle tpBounds = textPane.getBounds();
    TextUI tui = textPane.getUI();
    this.bounds = new Rectangle[length];
    for (int i = 0; i < length; i++) {
        try {
            Rectangle startr = tui.modelToView(textPane, docstart[i], Position.Bias.Forward);
            Rectangle endr = tui.modelToView(textPane, docend[i], Position.Bias.Backward);
            if (startr == null || endr == null) {
                continue;
            }
            startr = startr.getBounds();
            endr = endr.getBounds();
            this.bounds[i] = new Rectangle(tpBounds.x + startr.x, startr.y, endr.x - startr.x, startr.height);
            //NOTE the textPane is positioned within a parent panel so the origin has to be modified too
            if (null != translator) {
                translator.correctTranslation(textPane, this.bounds[i]);
            }
        } catch (BadLocationException ex) { }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:VCSHyperlinkSupport.java

示例7: getCloserDifference

import javax.swing.plaf.TextUI; //導入依賴的package包/類
/**
 * In case of two neighboring DELETE differences which meet on the same line, this method returns a difference
 * which' annotation is closer (in y-axis) to the click-point
 * @param event event with the click-point
 * @param previous a difference reaching out from the previous line
 * @param next a difference reaching out from the next line
 * @return
 */
private Difference getCloserDifference(MouseEvent event, Difference previous, Difference next) {
    Difference returnedDiff = next;
    JTextComponent component = textComponent;
    if (component != null) {
        TextUI textUI = component.getUI();
        try {
            Rectangle rec = textUI.modelToView(component, textUI.viewToModel(component, new Point(0, event.getY())));
            if (rec != null && event.getY() < rec.getY() + rec.getHeight() / 2) {
                // previous difference is closer to the click
                returnedDiff = previous;
            }
        } catch (BadLocationException ex) {
            // not interested, default next is returned
        }
    }
    return returnedDiff;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:DiffSidebar.java

示例8: getLineFromMouseEvent

import javax.swing.plaf.TextUI; //導入依賴的package包/類
private int getLineFromMouseEvent(MouseEvent e){
    int line = -1;
    EditorUI editorUI = Utilities.getEditorUI(textComponent);
    if (editorUI != null) {
        try{
            JTextComponent component = editorUI.getComponent();
            if (component != null) {
                TextUI textUI = component.getUI();
                int clickOffset = textUI.viewToModel(component, new Point(0, e.getY()));
                line = Utilities.getLineOffset(document, clickOffset);
            }
        }catch (BadLocationException ble){
            LOG.log(Level.WARNING, "getLineFromMouseEvent", ble); // NOI18N
        }
    }
    return line;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:DiffSidebar.java

示例9: findEditorKeys

import javax.swing.plaf.TextUI; //導入依賴的package包/類
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey, JTextComponent component) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        TextUI componentUI = component.getUI();
        Keymap km = component.getKeymap();
        if (componentUI != null && km != null) {
            EditorKit kit = componentUI.getEditorKit(component);
            if (kit instanceof BaseKit) {
                Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        ret = keys;
                    }
                }
            }
        }
    }
    return ret;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:DocumentationScrollPane.java

示例10: paintComponent

import javax.swing.plaf.TextUI; //導入依賴的package包/類
/**
 * Paints the text area.
 *
 * @param g The graphics context with which to paint.
 */
@Override
protected void paintComponent(Graphics g) {

	//long startTime = System.currentTimeMillis();

	backgroundPainter.paint(g, getVisibleRect());

	// Paint the main part of the text area.
	TextUI ui = getUI();
	if (ui != null) {
		// Not allowed to modify g, so make a copy.
		Graphics scratchGraphics = g.create();
		try {
			ui.update(scratchGraphics, this);
		} finally {
			scratchGraphics.dispose();
		}
	}

	//long endTime = System.currentTimeMillis();
	//System.err.println(endTime-startTime);

}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:29,代碼來源:RTextAreaBase.java

示例11: addMarkAllHighlight

import javax.swing.plaf.TextUI; //導入依賴的package包/類
/**
 * Adds a special "marked occurrence" highlight.
 *
 * @param start
 * @param end
 * @param p
 * @return A tag to reference the highlight later.
 * @throws BadLocationException
 * @see #clearMarkAllHighlights()
 */
Object addMarkAllHighlight(int start, int end, HighlightPainter p)
		throws BadLocationException {
	Document doc = textArea.getDocument();
	TextUI mapper = textArea.getUI();
	// Always layered highlights for marked occurrences.
	HighlightInfoImpl i = new LayeredHighlightInfoImpl();
	i.setPainter(p);
	i.p0 = doc.createPosition(start);
	// HACK: Use "end-1" to prevent chars the user types at the "end" of
	// the highlight to be absorbed into the highlight (default Highlight
	// behavior).
	i.p1 = doc.createPosition(end-1);
	markAllHighlights.add(i);
	mapper.damageRange(textArea, start, end);
	return i;
}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:27,代碼來源:RTextAreaHighlighter.java

示例12: setUI

import javax.swing.plaf.TextUI; //導入依賴的package包/類
/**
 * Sets the UI used by this text area.  This is overridden so only the
 * right-click popup menu's UI is updated.  The look and feel of an
 * <code>RTextArea</code> is independent of the Java Look and Feel, and so
 * this method does not change the text area itself.  Subclasses (such as
 * <code>RSyntaxTextArea</code> can call <code>setRTextAreaUI</code> if
 * they wish to install a new UI.
 *
 * @param ui This parameter is ignored.
 */
@Override
public final void setUI(TextUI ui) {

	// Update the popup menu's ui.
	if (popupMenu!=null) {
		SwingUtilities.updateComponentTreeUI(popupMenu);
	}

	// Set things like selection color, selected text color, etc. to
	// laf defaults (if values are null or UIResource instances).
	RTextAreaUI rtaui = (RTextAreaUI)getUI();
	if (rtaui!=null) {
		rtaui.installDefaults();
	}

}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:27,代碼來源:RTextArea.java

示例13: addMarkedOccurrenceHighlight

import javax.swing.plaf.TextUI; //導入依賴的package包/類
/**
 * Adds a special "marked occurrence" highlight.
 *
 * @param start
 * @param end
 * @param p
 * @return A tag to reference the highlight later.
 * @throws BadLocationException
 * @see #clearMarkOccurrencesHighlights()
 */
Object addMarkedOccurrenceHighlight(int start, int end,
		SmartHighlightPainter p) throws BadLocationException {
	Document doc = textArea.getDocument();
	TextUI mapper = textArea.getUI();
	// Always layered highlights for marked occurrences.
	SyntaxLayeredHighlightInfoImpl i = new SyntaxLayeredHighlightInfoImpl();
	i.setPainter(p);
	i.setStartOffset(doc.createPosition(start));
	// HACK: Use "end-1" to prevent chars the user types at the "end" of
	// the highlight to be absorbed into the highlight (default Highlight
	// behavior).
	i.setEndOffset(doc.createPosition(end-1));
	markedOccurrences.add(i);
	mapper.damageRange(textArea, start, end);
	return i;
}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:27,代碼來源:RSyntaxTextAreaHighlighter.java

示例14: repaintNewCaret

import javax.swing.plaf.TextUI; //導入依賴的package包/類
void repaintNewCaret() {
    if (component != null) {
        TextUI mapper = component.getUI();
        Document doc = component.getDocument();
        if ((mapper != null) && (doc != null)) {
            Rectangle2D newLoc;
            try {
                newLoc = mapper.modelToView2D(component, this.dot, this.dotBias);
            } catch (BadLocationException e) {
                newLoc = null;
            }
            if (newLoc != null) {
                adjustVisibility(newLoc.getBounds());
                if (getMagicCaretPosition() == null) {
                    setMagicCaretPosition(new Point((int) newLoc.getX(),
                                                    (int) newLoc.getY()));
                }
            }
            damage(newLoc.getBounds());
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:CaretFloatingPointAPITest.java

示例15: paint

import javax.swing.plaf.TextUI; //導入依賴的package包/類
@Override
public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
	try {
		TextUI mapper = c.getUI();
		Rectangle p0 = mapper.modelToView(c, offs0);
		Rectangle p1 = mapper.modelToView(c, offs1);

		Color color = getColor();

		if (color == null) 
			g.setColor(c.getSelectionColor());
		else 
			g.setColor(color);

		if (sameLine(p0, p1)) {
			Rectangle r = p0.union(p1);
			underline(g, r);
		}
	} catch (BadLocationException e) {
	}
}
 
開發者ID:curiosag,項目名稱:ftc,代碼行數:22,代碼來源:UnderlineHighlightPainter.java


注:本文中的javax.swing.plaf.TextUI類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。