javax.swing.JComponent.getMousePosition()方法的使用及代码示例

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

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

JComponent.getMousePosition介绍

暂无

代码示例

代码示例来源:origin: edu.stanford.protege/protege-editor-owl

private void setupLinkedObjectComponent(JComponent component, Rectangle cellRect) {
  renderLinks = false;
  linkedObjectComponent = null;
  if (cellRect == null) {
    return;
  }
  if (component instanceof LinkedObjectComponent && OWLRendererPreferences.getInstance().isRenderHyperlinks()) {
    linkedObjectComponent = (LinkedObjectComponent) component;
    Point mouseLoc = component.getMousePosition(true);
    if (mouseLoc == null) {
      linkedObjectComponent.setLinkedObject(null);
      return;
    }
    renderLinks = cellRect.contains(mouseLoc);
  }
}

代码示例来源:origin: protegeproject/protege

private void setupLinkedObjectComponent(JComponent component, Rectangle cellRect) {
  renderLinks = false;
  linkedObjectComponent = null;
  if (cellRect == null) {
    return;
  }
  if (component instanceof LinkedObjectComponent && OWLRendererPreferences.getInstance().isRenderHyperlinks()) {
    linkedObjectComponent = (LinkedObjectComponent) component;
    Point mouseLoc = component.getMousePosition();
    if (mouseLoc == null) {
      linkedObjectComponent.setLinkedObject(null);
      return;
    }
    renderLinks = cellRect.contains(mouseLoc);
  }
}

代码示例来源:origin: edu.stanford.protege/org.protege.editor.owl

private void setupLinkedObjectComponent(JComponent component, Rectangle cellRect) {
  renderLinks = false;
  linkedObjectComponent = null;
  if (cellRect == null) {
    return;
  }
  if (component instanceof LinkedObjectComponent && OWLRendererPreferences.getInstance().isRenderHyperlinks()) {
    linkedObjectComponent = (LinkedObjectComponent) component;
    Point mouseLoc = component.getMousePosition(true);
    if (mouseLoc == null) {
      linkedObjectComponent.setLinkedObject(null);
      return;
    }
    renderLinks = cellRect.contains(mouseLoc);
  }
}

代码示例来源:origin: org.protege/protege-editor-owl

private void setupLinkedObjectComponent(JComponent component, Rectangle cellRect) {
  renderLinks = false;
  linkedObjectComponent = null;
  if (cellRect == null) {
    return;
  }
  if (component instanceof LinkedObjectComponent && OWLRendererPreferences.getInstance().isRenderHyperlinks()) {
    linkedObjectComponent = (LinkedObjectComponent) component;
    Point mouseLoc = component.getMousePosition(true);
    if (mouseLoc == null) {
      linkedObjectComponent.setLinkedObject(null);
      return;
    }
    renderLinks = cellRect.contains(mouseLoc);
  }
}

代码示例来源:origin: antlr/intellij-plugin-v4

public static int getMouseOffset(Editor editor) {
  Point mousePosition = editor.getContentComponent().getMousePosition();
  LogicalPosition pos=editor.xyToLogicalPosition(mousePosition);
  int offset = editor.logicalPositionToOffset(pos);
  return offset;
}

代码示例来源:origin: protegeproject/protege

private void updateCursor() {
  if(component == null) {
    return;
  }
  Point pos = component.getMousePosition();
  if (pos == null) {
    return;
  }
  for (LinkBox pageLink : pageLinks) {
    if (pageLink.contains(pos.x, pos.y)) {
      component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      return;
    }
  }
  component.setCursor(Cursor.getDefaultCursor());
}

代码示例来源:origin: edu.stanford.protege/protege-editor-owl

private void updateCursor() {
  if(component == null) {
    return;
  }
  Point pos = component.getMousePosition();
  if (pos == null) {
    return;
  }
  for (LinkBox pageLink : pageLinks) {
    if (pageLink.contains(pos.x, pos.y)) {
      component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      return;
    }
  }
  component.setCursor(Cursor.getDefaultCursor());
}

代码示例来源:origin: edu.stanford.protege/org.protege.editor.owl

private void updateCursor() {
  if(component == null) {
    return;
  }
  Point pos = component.getMousePosition();
  if (pos == null) {
    return;
  }
  for (LinkBox pageLink : pageLinks) {
    if (pageLink.contains(pos.x, pos.y)) {
      component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      return;
    }
  }
  component.setCursor(Cursor.getDefaultCursor());
}

代码示例来源:origin: edu.stanford.protege/protege-editor-owl

private void checkForLinkClick(MouseEvent event) {
  if(component == null) {
    return;
  }
  Point pos = component.getMousePosition();
  if (pos == null) {
    return;
  }
  if (component instanceof JList) {
    JList list = (JList) component;
    int index = list.locationToIndex(pos);
    if(index != -1) {
      component.paintImmediately(list.getCellBounds(index, index));
    }
  }
  for(LinkBox link : pageLinks) {
    if(link.contains(pos.x, pos.y)) {
      link.getLink().activate(component, event);
    }
  }
}

代码示例来源:origin: protegeproject/protege

private void checkForLinkClick(MouseEvent event) {
  if(component == null) {
    return;
  }
  Point pos = component.getMousePosition();
  if (pos == null) {
    return;
  }
  if (component instanceof JList) {
    JList list = (JList) component;
    int index = list.locationToIndex(pos);
    if(index != -1) {
      component.paintImmediately(list.getCellBounds(index, index));
    }
  }
  for(LinkBox link : pageLinks) {
    if(link.contains(pos.x, pos.y)) {
      link.getLink().activate(component, event);
    }
  }
}

代码示例来源:origin: edu.stanford.protege/org.protege.editor.owl

private void checkForLinkClick(MouseEvent event) {
  if(component == null) {
    return;
  }
  Point pos = component.getMousePosition();
  if (pos == null) {
    return;
  }
  if (component instanceof JList) {
    JList list = (JList) component;
    int index = list.locationToIndex(pos);
    if(index != -1) {
      component.paintImmediately(list.getCellBounds(index, index));
    }
  }
  for(LinkBox link : pageLinks) {
    if(link.contains(pos.x, pos.y)) {
      link.getLink().activate(component, event);
    }
  }
}

代码示例来源:origin: protegeproject/protege

@Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    page.setLocation(getInsets().left, getInsets().top);
    Point mousePos = component.getMousePosition();
    if(mousePos != null) {
      int pageRelativeX = mousePos.x - page.getX() - getX();
      int pageRelativeY = mousePos.y - page.getY() - getY();
//            page.handleMouseMoved(new MouseEvent(component, 0, System.currentTimeMillis(), 0, pageRelativeX, pageRelativeY, 0, false, 0));
    }
    page.draw(g2);
    Rectangle clip = g.getClipBounds();
    clip.translate(getX(), getY());
    manager.clear(clip);
    manager.setCurrentPage(page, getX(), getY());
    for(LinkBox pageLink : page.getLinks()) {
      manager.add(pageLink.translate(getX(), getY()));
    }

  }
}

代码示例来源:origin: edu.stanford.protege/org.protege.editor.owl

@Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    page.setLocation(getInsets().left, getInsets().top);
    Point mousePos = component.getMousePosition();
    if(mousePos != null) {
      int pageRelativeX = mousePos.x - page.getX() - getX();
      int pageRelativeY = mousePos.y - page.getY() - getY();
//            page.handleMouseMoved(new MouseEvent(component, 0, System.currentTimeMillis(), 0, pageRelativeX, pageRelativeY, 0, false, 0));
    }
    page.draw(g2);
    Rectangle clip = g.getClipBounds();
    clip.translate(getX(), getY());
    manager.clear(clip);
    manager.setCurrentPage(page, getX(), getY());
    for(LinkBox pageLink : page.getLinks()) {
      manager.add(pageLink.translate(getX(), getY()));
    }

  }
}

代码示例来源:origin: antlr/intellij-plugin-v4

Point mousePosition = editor.getContentComponent().getMousePosition();
if ( mousePosition!=null ) {
  LogicalPosition pos = editor.xyToLogicalPosition(mousePosition);

代码示例来源:origin: edu.stanford.protege/protege-editor-owl

@Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    page.setLocation(getInsets().left, getInsets().top);
    Point mousePos = component.getMousePosition();
    if(mousePos != null) {
      int pageRelativeX = mousePos.x - page.getX() - getX();
      int pageRelativeY = mousePos.y - page.getY() - getY();
//            page.handleMouseMoved(new MouseEvent(component, 0, System.currentTimeMillis(), 0, pageRelativeX, pageRelativeY, 0, false, 0));
    }
    page.draw(g2);
    Rectangle clip = g.getClipBounds();
    clip.translate(getX(), getY());
    manager.clear(clip);
    manager.setCurrentPage(page, getX(), getY());
    for(LinkBox pageLink : page.getLinks()) {
      manager.add(pageLink.translate(getX(), getY()));
    }

  }
}

相关文章

JComponent类方法