0N/A/*
2362N/A * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/Apackage javax.swing.text;
0N/A
0N/Aimport java.awt.Color;
0N/Aimport java.awt.Graphics;
0N/Aimport java.awt.Shape;
0N/A
0N/A/**
0N/A * An interface for an object that allows one to mark up the background
0N/A * with colored areas.
0N/A *
0N/A * @author Timothy Prinzing
0N/A */
0N/Apublic interface Highlighter {
0N/A
0N/A /**
0N/A * Called when the UI is being installed into the
0N/A * interface of a JTextComponent. This can be used
0N/A * to gain access to the model that is being navigated
0N/A * by the implementation of this interface.
0N/A *
0N/A * @param c the JTextComponent editor
0N/A */
0N/A public void install(JTextComponent c);
0N/A
0N/A /**
0N/A * Called when the UI is being removed from the
0N/A * interface of a JTextComponent. This is used to
0N/A * unregister any listeners that were attached.
0N/A *
0N/A * @param c the JTextComponent editor
0N/A */
0N/A public void deinstall(JTextComponent c);
0N/A
0N/A /**
0N/A * Renders the highlights.
0N/A *
0N/A * @param g the graphics context.
0N/A */
0N/A public void paint(Graphics g);
0N/A
0N/A /**
0N/A * Adds a highlight to the view. Returns a tag that can be used
0N/A * to refer to the highlight.
0N/A *
0N/A * @param p0 the beginning of the range >= 0
0N/A * @param p1 the end of the range >= p0
0N/A * @param p the painter to use for the actual highlighting
0N/A * @return an object that refers to the highlight
0N/A * @exception BadLocationException for an invalid range specification
0N/A */
0N/A public Object addHighlight(int p0, int p1, HighlightPainter p) throws BadLocationException;
0N/A
0N/A /**
0N/A * Removes a highlight from the view.
0N/A *
0N/A * @param tag which highlight to remove
0N/A */
0N/A public void removeHighlight(Object tag);
0N/A
0N/A /**
0N/A * Removes all highlights this highlighter is responsible for.
0N/A */
0N/A public void removeAllHighlights();
0N/A
0N/A /**
0N/A * Changes the given highlight to span a different portion of
0N/A * the document. This may be more efficient than a remove/add
0N/A * when a selection is expanding/shrinking (such as a sweep
0N/A * with a mouse) by damaging only what changed.
0N/A *
0N/A * @param tag which highlight to change
0N/A * @param p0 the beginning of the range >= 0
0N/A * @param p1 the end of the range >= p0
0N/A * @exception BadLocationException for an invalid range specification
0N/A */
0N/A public void changeHighlight(Object tag, int p0, int p1) throws BadLocationException;
0N/A
0N/A /**
0N/A * Fetches the current list of highlights.
0N/A *
0N/A * @return the highlight list
0N/A */
0N/A public Highlight[] getHighlights();
0N/A
0N/A /**
0N/A * Highlight renderer.
0N/A */
0N/A public interface HighlightPainter {
0N/A
0N/A /**
0N/A * Renders the highlight.
0N/A *
0N/A * @param g the graphics context
0N/A * @param p0 the starting offset in the model >= 0
0N/A * @param p1 the ending offset in the model >= p0
0N/A * @param bounds the bounding box for the highlight
0N/A * @param c the editor
0N/A */
0N/A public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c);
0N/A
0N/A }
0N/A
0N/A public interface Highlight {
0N/A
0N/A /**
0N/A * Gets the starting model offset for the highlight.
0N/A *
0N/A * @return the starting offset >= 0
0N/A */
0N/A public int getStartOffset();
0N/A
0N/A /**
0N/A * Gets the ending model offset for the highlight.
0N/A *
0N/A * @return the ending offset >= 0
0N/A */
0N/A public int getEndOffset();
0N/A
0N/A /**
0N/A * Gets the painter for the highlighter.
0N/A *
0N/A * @return the painter
0N/A */
0N/A public HighlightPainter getPainter();
0N/A
0N/A }
0N/A
0N/A};