org.fife.ui.rsyntaxtextarea.parser.ToolTipInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rsyntaxtextarea Show documentation
Show all versions of rsyntaxtextarea Show documentation
RSyntaxTextArea is the syntax highlighting text editor for Swing applications. Features include syntax highlighting for 40+ languages, code folding, code completion, regex find and replace, macros, code templates, undo/redo, line numbering and bracket matching.
/*
* 07/29/2009
*
* ToolTipInfo.java - A tool tip's text and hyperlink listener.
*
* This library is distributed under a modified BSD license. See the included
* LICENSE file for details.
*/
package org.fife.ui.rsyntaxtextarea.parser;
import java.net.URL;
import javax.swing.event.HyperlinkListener;
/**
* Wrapper for a tool tip and a listener for hyperlink events in the tool
* tip (assuming the tip is HTML). If the {@code RSyntaxTextArea} instance
* has {@link org.fife.ui.rsyntaxtextarea.focusabletip.FocusableTip}s enabled,
* and the user clicks on a hyperlink in the tool tip, the specified
* {@link HyperlinkListener} will be called.
*
* @author Robert Futrell
* @version 1.0
*/
public class ToolTipInfo {
private String text;
private HyperlinkListener listener;
private URL imageBase;
/**
* Constructor.
*
* @param text The tool tip text, or null
for none.
* @param listener The hyperlink listener, or null
for none.
*/
public ToolTipInfo(String text, HyperlinkListener listener) {
this(text, listener, null);
}
/**
* Constructor.
*
* @param text The tool tip text, or null
for none.
* @param l The hyperlink listener, or null
for none.
* @param imageBase The base URL for images in the HTML text
,
* or null
for the default.
*/
public ToolTipInfo(String text, HyperlinkListener l, URL imageBase) {
this.text = text;
this.listener = l;
this.imageBase = imageBase;
}
/**
* Returns the listener to call when hyperlinks are clicked in the tool
* tip.
*
* @return The listener, or null
for none.
*/
public HyperlinkListener getHyperlinkListener() {
return listener;
}
/**
* Returns the base URL that any images in the HTML tool tip live in.
* This allows you to reference images in a jar file in your
* {@link org.fife.ui.rsyntaxtextarea.focusabletip.FocusableTip}s.
* Note that if what {@link #getToolTipText()} returns isn't HTML, this
* value is effectively ignored.
*
* @return The image base, or null
for the default.
*/
public URL getImageBase() {
return imageBase;
}
/**
* Returns the tool tip text to display.
*
* @return The tool tip text, or null
for none.
*/
public String getToolTipText() {
return text;
}
}