public abstract class AbstractGutterHandler extends java.lang.Object implements GutterHandler
GutterHandler
which allows to:
private class MyGutterHandler extends AbstractGutterHandler { public boolean handleClick(Gutter gutter, int mouseButton, int x, int y) { if (mouseButton == MouseEvent.BUTTON3) { JPopupMenu menu = new JPopupMenu(); int number = gutter.getLineNumber(y); menu.add(new JMenuItem("An Action on " + number)); menu.show(gutter, x, y); return true; } else { return false; } } public void handleMoved(Gutter gutter, int x, int y) { int number = gutter.getLineNumber(y); if (isPainting(number)) { this.showTooltip("The tooltip on line" + number); } else { this.hideTooltip(); } } }
Constructor and Description |
---|
AbstractGutterHandler() |
AbstractGutterHandler(Gutter gutter)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addImage(int lineNumber,
java.lang.String imageName)
Add a binding between a line number and an image resource name.
|
boolean |
addImageResource(java.lang.String name,
java.net.URL url)
Add an image resource.
|
boolean |
addImageResource(java.lang.String name,
java.net.URL url,
int offsetX,
int offsetY)
Add an image resource.
|
void |
clear()
Clear the relationship between image names and line numbers.
|
Gutter |
getGutter()
Rturn the Gutter.
|
java.lang.String |
getImageName(int lineNumber)
Return the image resource name binding for a specified line number.
|
protected void |
hideTooltip()
Hide the tooltip.
|
boolean |
isPainting(int lineNumber)
Return true if the GutterHandler should paint a specific element on the gutter for a line number.
|
void |
paint(java.awt.Graphics gfx,
int line,
int x,
int y)
Paint a specific image on the gutter for a line number.
|
void |
setGutter(Gutter gutter)
Set the Gutter.
|
protected void |
showTooltip(java.lang.String text)
Show the tooltip.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handleChangeWidth, handleClick, handleMoved
protected Gutter gutter
public AbstractGutterHandler()
public AbstractGutterHandler(Gutter gutter)
gutter
- the Gutterpublic void setGutter(Gutter gutter)
gutter
- the Gutterpublic Gutter getGutter()
public void clear()
public boolean addImage(int lineNumber, java.lang.String imageName)
lineNumber
- the line numberimageName
- the image resource namepublic boolean isPainting(int lineNumber)
isPainting
in interface GutterHandler
lineNumber
- the line numberpublic java.lang.String getImageName(int lineNumber)
lineNumber
- the line numberpublic boolean addImageResource(java.lang.String name, java.net.URL url)
addImageResource(java.lang.String, java.net.URL, int, int)
method with the following values for the offsetX
and offsetY
arguments:
name
- the binding nameurl
- the resource URLpublic boolean addImageResource(java.lang.String name, java.net.URL url, int offsetX, int offsetY)
name
- the binding nameurl
- the resource URLoffsetX
- the X offset to use for the painting of the imageoffsetY
- the Y offset to use for the painting of the imageprotected void hideTooltip()
GutterHandler.handleMoved(org.jeditor.gui.Gutter, int, int)
method.protected void showTooltip(java.lang.String text)
GutterHandler.handleMoved(org.jeditor.gui.Gutter, int, int)
method.
For example:
public void handleMoved(Gutter gutter, int x, int y) { int number = gutter.getLineNumber(y); if (isPainting(number)) { this.showTooltip("The tooltip on line" + number); } else { this.hideTooltip(); } } }
text
- the tooltip textpublic void paint(java.awt.Graphics gfx, int line, int x, int y)
paint
in interface GutterHandler
gfx
- the Graphicsline
- the line numberx
- the x position of the line numbery
- the y position of the line numberCopyright © 2016, 2017, 2018, 2019, 2023 Herve Girod. All Rights Reserved. Documentation and source under the MIT licence