jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java
changeset 39553 965a62655c4c
parent 30462 507bcb03c954
child 39554 12687019f2b9
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java	Mon Jul 04 17:10:29 2016 +0530
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java	Tue Jul 05 09:26:34 2016 +0300
@@ -60,6 +60,17 @@
     }
 
     /**
+     * Returns the tab size set for the document, defaulting to 8.
+     *
+     * @implSpec This implementation calls {@link #getTabSize() getTabSize()}.
+     *
+     * @return the tab size
+     */
+    protected float getFractionalTabSize() {
+        return getTabSize();
+    }
+
+    /**
      * Renders a line of text, suppressing whitespace at the end
      * and expanding any tabs.  This is implemented to make calls
      * to the methods <code>drawUnselectedText</code> and
@@ -93,6 +104,28 @@
         }
     }
 
+    /**
+     * Renders a line of text, suppressing whitespace at the end
+     * and expanding any tabs.  This is implemented to make calls
+     * to the methods {@code drawUnselectedText} and
+     * {@code drawSelectedText} so that the way selected and
+     * unselected text are rendered can be customized.
+     *
+     * @implSpec This implementation calls
+     * {@link #drawLine(int, Graphics, int, int)
+     * drawLine(lineIndex, (Graphics)g, (int) x, (int) y)}.
+     *
+     * @param lineIndex the line to draw {@code >= 0}
+     * @param g the {@code Graphics} context
+     * @param x the starting X position {@code >= 0}
+     * @param y the starting Y position {@code >= 0}
+     * @see #drawUnselectedText
+     * @see #drawSelectedText
+     */
+    protected void drawLine(int lineIndex, Graphics2D g, float x, float y) {
+        drawLine(lineIndex, (Graphics)g, (int) x, (int) y);
+    }
+
     private int drawElement(int lineIndex, Element elem, Graphics g, int x, int y) throws BadLocationException {
         int p0 = elem.getStartOffset();
         int p1 = elem.getEndOffset();
@@ -157,6 +190,27 @@
     }
 
     /**
+     * Renders the given range in the model as normal unselected
+     * text.  Uses the foreground or disabled color to render the text.
+     *
+     * @implSpec This implementation calls
+     * {@link #drawUnselectedText(Graphics, int, int, int, int)
+     * drawUnselectedText((Graphics)g, (int) x, (int) y, p0, p1)}.
+     *
+     * @param g the graphics context
+     * @param x the starting X coordinate {@code >= 0}
+     * @param y the starting Y coordinate {@code >= 0}
+     * @param p0 the beginning position in the model {@code >= 0}
+     * @param p1 the ending position in the model {@code >= 0}
+     * @return the X location of the end of the range {@code >= 0}
+     * @exception BadLocationException if the range is invalid
+     */
+    protected float drawUnselectedText(Graphics2D g, float x, float y,
+                                       int p0, int p1) throws BadLocationException {
+        return drawUnselectedText((Graphics)g, (int) x, (int) y, p0, p1);
+    }
+
+    /**
      * Renders the given range in the model as selected text.  This
      * is implemented to render the text in the color specified in
      * the hosting component.  It assumes the highlighter will render
@@ -182,6 +236,30 @@
     }
 
     /**
+     * Renders the given range in the model as selected text.  This
+     * is implemented to render the text in the color specified in
+     * the hosting component.  It assumes the highlighter will render
+     * the selected background.
+     *
+     * @implSpec This implementation calls
+     * {@link #drawSelectedText(Graphics, int, int, int, int)
+     * drawSelectedText((Graphics)g, (int) x, (int) y, p0, p1)}.
+     *
+     * @param g the graphics context
+     * @param x the starting X coordinate {@code >= 0}
+     * @param y the starting Y coordinate {@code >= 0}
+     * @param p0 the beginning position in the model {@code >= 0}
+     * @param p1 the ending position in the model {@code >= 0}
+     * @return the location of the end of the range
+     * @exception BadLocationException if the range is invalid
+     */
+
+    protected float drawSelectedText(Graphics2D g, float x,
+                                     float y, int p0, int p1) throws BadLocationException {
+        return drawSelectedText((Graphics)g, (int) x, (int) y, p0, p1);
+    }
+
+    /**
      * Gives access to a buffer that can be used to fetch
      * text from the associated document.
      *