Java Code Examples for org.fife.ui.rsyntaxtextarea.RSyntaxTextArea#getParent()

The following examples show how to use org.fife.ui.rsyntaxtextarea.RSyntaxTextArea#getParent() . 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: ClassViewer.java    From bytecode-viewer with GNU General Public License v3.0 5 votes vote down vote up
public static int getMaxViewLine(RSyntaxTextArea area) {
    Container parent = area.getParent();
    if (parent instanceof JViewport) {
        JViewport viewport = (JViewport) parent;
        int y = viewport.getViewSize().height - viewport.getExtentSize().height;
        int lineHeight = area.getLineHeight();
        return y >= lineHeight ? y / lineHeight : 0;
    }
    return 0;
}
 
Example 2
Source File: ClassViewer.java    From bytecode-viewer with GNU General Public License v3.0 5 votes vote down vote up
public static int getViewLine(RSyntaxTextArea area) {
    Container parent = area.getParent();
    if (parent instanceof JViewport) {
        JViewport viewport = (JViewport) parent;
        Point point = viewport.getViewPosition();
        int lineHeight = area.getLineHeight();
        return point.y >= lineHeight ? point.y / lineHeight : 0;
    }
    return 0;
}
 
Example 3
Source File: ClassViewer.java    From bytecode-viewer with GNU General Public License v3.0 5 votes vote down vote up
public static void setViewLine(RSyntaxTextArea area, int line) {
    Container parent = area.getParent();
    if (parent instanceof JViewport) {
        JViewport viewport = (JViewport) parent;
        int maxLine = ClassViewer.getMaxViewLine(area);
        line = line < maxLine ? line : maxLine;
        viewport.setViewPosition(new Point(0, line * area.getLineHeight()));
    }
}