javax.swing.JEditorPane.viewToModel()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中javax.swing.JEditorPane.viewToModel()方法的一些代码示例,展示了JEditorPane.viewToModel()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JEditorPane.viewToModel()方法的具体详情如下:
包路径:javax.swing.JEditorPane
类名称:JEditorPane
方法名:viewToModel

JEditorPane.viewToModel介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2

public int getPosition(int x, int y) {
  Point p = new Point(x, y);
  return editorPane.viewToModel(p);
}

代码示例来源:origin: stackoverflow.com

public void mouseClicked(MouseEvent e) {
  JEditorPane editor = (JEditorPane) e.getSource();
  Point pt = new Point(e.getX(), e.getY());
  int pos = editor.viewToModel(pt);
  // whatever you need to do here
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-languages

public void mouseMoved (MouseEvent e) {
  JEditorPane c = (JEditorPane) e.getComponent ();
  final NbEditorDocument doc = (NbEditorDocument) c.getDocument ();
  if (highlight != null) highlight.remove ();
  highlight = null;
  runnable = null;
  if (((e.getModifiers() | e.getModifiersEx()) & InputEvent.CTRL_DOWN_MASK) != InputEvent.CTRL_DOWN_MASK) {
    return;
  }
  int offset = c.viewToModel (e.getPoint ());
  highlight (doc, offset);
  c.repaint ();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2

int pos = editorPane.viewToModel(p);

代码示例来源:origin: freeplane/freeplane

@Override
public void mouseClicked(final MouseEvent ev) {
  if (textfield != null && (ev.getModifiers() & MouseEvent.CTRL_MASK) != 0) {
    final String linkURL = HtmlUtils.getURLOfExistingLink((HTMLDocument) textfield.getDocument(), textfield.viewToModel(ev.getPoint()));
    if (linkURL != null) {
      try {
        LinkController.getController().loadURI(nodeView.getModel(), new URI(linkURL));
      } catch (Exception e) {
        LogUtils.warn(e);
      }
    }
  }
}

代码示例来源:origin: freeplane/freeplane

@Override
public void mouseClicked(final MouseEvent ev) {
  if (Compat.isPlainEvent(ev)) {
    final String linkURL = HtmlUtils.getURLOfExistingLink((HTMLDocument) tip.getDocument(), tip.viewToModel(ev.getPoint()));
    if (linkURL != null) {
      try {
        NodeView nodeView = (NodeView) SwingUtilities.getAncestorOfClass(NodeView.class, component);
        LinkController.getController().loadURI(nodeView.getModel(), new URI(linkURL));
      } catch (Exception e) {
        LogUtils.warn(e);
      }
    }
  }
}

代码示例来源:origin: stackoverflow.com

final Point relativePoint = new Point((int) (p.getX() - r.x), (int) (p.getY() - r.y));
final int pos = pane.viewToModel(relativePoint);
if (pos >= 0) {
  final Document doc = pane.getDocument();

代码示例来源: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: freeplane/freeplane

@Override
public void mouseMoved(final MouseEvent ev) {
  final String link = HtmlUtils.getURLOfExistingLink((HTMLDocument) tip.getDocument(), tip.viewToModel(ev.getPoint()));
  boolean followLink = link != null;
  Controller currentController = Controller.getCurrentController();
  final int requiredCursor;
  if(followLink){
    currentController.getViewController().out(link);
    requiredCursor = Cursor.HAND_CURSOR;
  }
  else{
    requiredCursor = Cursor.DEFAULT_CURSOR;
  }
  if (tip.getCursor().getType() != requiredCursor) {
    tip.setCursor(requiredCursor != Cursor.DEFAULT_CURSOR ? new Cursor(requiredCursor) : null);
  }
}

代码示例来源:origin: stackoverflow.com

int pos = textPane.viewToModel(pt);
if (pos >= 0) {
  HTMLDocument hdoc = (HTMLDocument) textPane.getDocument();

代码示例来源:origin: freeplane/freeplane

int pos = document.getLength();
if(mouseEventPoint != null)
  pos = textfield.viewToModel(mouseEventPoint);
textfield.setCaretPosition(pos);

相关文章

JEditorPane类方法