本文整理了Java中javax.swing.JEditorPane.getUI()
方法的一些代码示例,展示了JEditorPane.getUI()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JEditorPane.getUI()
方法的具体详情如下:
包路径:javax.swing.JEditorPane
类名称:JEditorPane
方法名:getUI
暂无
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) throws Exception {
System.setProperty("java.awt.headless", "true");
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
Rectangle bounds = new Rectangle(255, 255);
BufferedImage image = new BufferedImage(
bounds.width, bounds.height, BufferedImage.TYPE_INT_RGB);
Graphics2D d = image.createGraphics();
d.setClip(bounds);
for (int i = 0; i < 1000; i++) {
JEditorPane renderHelper = new JEditorPane(
"text/html", "<html><body>This is my text.</body></html>");
HTMLDocument document = (HTMLDocument) renderHelper.getDocument();
document.getStyleSheet().addRule("foo{color:black;}");
View rootView = renderHelper.getUI().getRootView(renderHelper);
rootView.paint(d, bounds);
}
}
});
}
代码示例来源:origin: markiewb/nb-codeoutline
/**
* Convert a y-coordinate in the NaviView co-ordinate space to a line number
* in the document.
*/
private int yViewToDocument(int vpos)
{
View view = editorPane.getUI().getRootView(editorPane);
Insets insets = getInsets();
vpos -= insets.top + frw;
int myHeight = Math.max(getHeight() - insets.top - insets.bottom - frw*2, 1);
if (prefViewHeight > myHeight) {
vpos = vpos * prefViewHeight / myHeight;
}
Bias [] breturn = new Bias[1];
int pos = view.viewToModel(0, vpos, new Rectangle(5,Integer.MAX_VALUE), breturn);
return pos;
}
代码示例来源:origin: markiewb/nb-codeoutline
View view = editorPane.getUI().getRootView(editorPane);
代码示例来源:origin: nroduit/Weasis
public static Shape getPageShape(int pageStartY, int pageWidth, int pageHeight, JEditorPane sourcePane) {
Area result = new Area(new Rectangle(0, 0, pageWidth, pageHeight));
View rootView = sourcePane.getUI().getRootView(sourcePane);
Rectangle last = new Rectangle();
for (int x = 1; x < pageWidth; x++) {
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-lexer-editorbridge
public void install(JEditorPane pane) {
super.install(pane);
TextUI ui = pane.getUI();
if (ui instanceof BaseTextUI) {
((BaseTextUI)ui).getEditorUI().addLayer(new LexerLayer(pane), LexerLayer.VISIBILITY);
}
}
代码示例来源:origin: nroduit/Weasis
public void doPagesLayout() {
setLayout(null);
removeAll();
this.rootView = sourcePane.getUI().getRootView(sourcePane);
sourcePane.setSize(pageWidth - margins.top - margins.bottom, Integer.MAX_VALUE);
Dimension d = sourcePane.getPreferredSize();
sourcePane.setSize(pageWidth - margins.top - margins.bottom, d.height);
calculatePageInfo();
int count = pages.size();
this.setPreferredSize(new Dimension(pageWidth * 2 + 50, PAGE_SHIFT + count * (pageHeight + PAGE_SHIFT)));
}
代码示例来源:origin: stackoverflow.com
MouseListener sentenceCollapse = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
JEditorPane src = (JEditorPane)e.getSource();
View v = src.getUI().getRootView(src);
Insets ins = src.getInsets();
int x = ins.left;
int y = ins.top;
Point p = e.getPoint();
p.translate(-x, -y);
Rectangle alloc = new Rectangle(0,0,Short.MAX_VALUE,Short.MAX_VALUE);
while (v != null && !(v instanceof SentenceView)) {
View vChild = null;
int n = v.getViewCount();
for (int i = 0; i < n; i++) {
Rectangle r = v.getChildAllocation(i, alloc).getBounds();
if (r.contains(p)) {
vChild = v.getView(i);
alloc = (Rectangle) r.clone();
}
}
v = vChild;
}
if (v != null && v instanceof SentenceView) {
<<< unfold or fold the Sentence View >>>
src.repaint();
}
};
代码示例来源:origin: markiewb/nb-codeoutline
/**
* Notify the NaviView that the document has changed (vertical) length. Normally
* this is called by NaviviewView.
*/
public void documentChangedLength()
{
View view = editorPane.getUI().getRootView(editorPane);
int newPrefHeight = (int) view.getPreferredSpan(View.Y_AXIS);
Insets insets = getInsets();
int yoffs = insets.top + frw;
if (! scrollBar.isVisible()) {
// If the scrollbar is invisible, and the document height changes,
// we need to repaint the view border
int rpHeight = Math.max(newPrefHeight,prefViewHeight) + yoffs + frw;
repaint(0, 0, getWidth(), rpHeight);
}
else {
repaint(0, Math.min(newPrefHeight, prefViewHeight) + yoffs,
getWidth(),
Math.abs(newPrefHeight - prefViewHeight) + frw);
}
prefViewHeight = newPrefHeight;
}
代码示例来源:origin: org.gephi/ui-components
@Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) {
boolean last = false;
try {
View rootView = displayPane.getUI().getRootView(displayPane);
double scaleX = pageFormat.getImageableWidth() / displayPane.getMinimumSize().getWidth();
scaleX = Math.min(scaleX, 1.0);
double scaleY = scaleX;
int end = (int) (pageIndex * ((1.0f / scaleY) * (double) pageFormat.getImageableHeight()));
Rectangle allocation = new Rectangle(0,
-end,
(int) pageFormat.getImageableWidth(),
(int) pageFormat.getImageableHeight());
((Graphics2D) graphics).scale(scaleX, scaleY);
graphics.setClip((int) (pageFormat.getImageableX() / scaleX),
(int) (pageFormat.getImageableY() / scaleY),
(int) (pageFormat.getImageableWidth() / scaleX),
(int) (pageFormat.getImageableHeight() / scaleY));
((Graphics2D) graphics).translate(((Graphics2D) graphics).getClipBounds().getX(),
((Graphics2D) graphics).getClipBounds().getY());
rootView.paint(graphics, allocation);
last = end > displayPane.getUI().getPreferredSize(displayPane).getHeight();
if ((last)) {
return Printable.NO_SUCH_PAGE;
}
} catch (Exception e) {
Exceptions.printStackTrace(e);
}
return Printable.PAGE_EXISTS;
}
代码示例来源:origin: nz.ac.waikato.cms.weka.thirdparty/bounce
/**
* Return true when a Wrapped View is used.
*
* @see Scrollable#getScrollableTracksViewportWidth()
*/
public boolean getScrollableTracksViewportWidth() {
View view = editor.getUI().getRootView( editor).getView(0);
if ( view instanceof WrappedPlainView) {
return true;
} else if ( getParent() instanceof JViewport) {
return (((JViewport)getParent()).getWidth() > getPreferredSize().width);
}
return false;
}
代码示例来源:origin: nroduit/Weasis
public static View getLeafViewAtPoint(Point p, View root, JEditorPane sourcePane) {
int pos = sourcePane.viewToModel(p);
View v = sourcePane.getUI().getRootView(sourcePane);
while (v.getViewCount() > 0) {
int i = v.getViewIndex(pos, Position.Bias.Forward);
v = v.getView(i);
}
Shape alloc = getAllocation(root, sourcePane);
if (alloc.contains(p)) {
return v;
}
return null;
}
代码示例来源:origin: igniterealtime/Spark
JEditorPane.validate();
rootView = JEditorPane.getUI().getRootView(JEditorPane);
内容来源于网络,如有侵权,请联系作者删除!