com.borland.primetime.editor
Class LineMark

java.lang.Object
  |
  +--com.borland.primetime.editor.LineMark
Direct Known Subclasses:
EditorPane.HighlightMark, GutterMark

public class LineMark
extends java.lang.Object

A LineMark is an object that represents a line position within a document. LineMarks are tracked by the document, and moved around as changes to the document occur. Someone interested in a LineMark can ask the mark for its markLine, which will return the line that it is on.

A LineMark can be constructed as a lightweight mark, in which case it does not store a reference to the document in which it exists, thus it cannot be asked what line it exists on. The purpose of a lightweight mark is to enable the same mark to exist in multiple places in the document (i.e. you can add a lightweight LineMark to the same document over and over again). The lightweight capability was originally created to display executable lines when running the debugger, but it can be used for other types of display-only markup as well.

See Also:
EditorDocument

Constructor Summary
LineMark()
          Create a new "heavyweight" LineMark.
LineMark(boolean lightweight)
          Create a new LineMark.
LineMark(boolean lightweight, javax.swing.text.Style style)
          Create a new LineMark that paints using the specified style.
LineMark(boolean lightweight, javax.swing.text.Style style, EditorPane editor)
          Create a new LineMark that paints using the specified style and make sure it will only be displayed in the specified editor.
LineMark(javax.swing.text.Style style)
          Create a new "heavyweight" LineMark that paints using the specified style.
 
Method Summary
 void addEditor(EditorPane editor)
          Normally linemarks are tied to a document and all editors that display that document will show the linemark.
 boolean displayInEditor(EditorPane editor)
          Should this line mark be displayed in the incoming editor? If this line mark is not editor specific, it can always be displayed in all editors, otherwise the incoming editor has to be one of the editors set by addEditor.
 int getDisplayPriority()
          Describes the logical priority this mark belongs to for ordering purposes.
protected  EditorDocument getDocument()
          Get the document that this mark is associated with.
 int getMarkLine()
          Get the current location of this mark.
 javax.swing.text.Style getStyle()
          Get the style to use when painting a line with this mark.
 boolean isLightweight()
          Check to see if this is a lightweight mark or not.
 void removeEditor()
          Remove all the ties that this line mark has to all editor panes.
 void removeEditor(javax.swing.text.Document doc)
          Remove all the ties that this line mark has to all editor panes belonging to this document.
 void removeEditor(EditorPane editor)
          Remove all the ties that this line mark has to the incoming editor pane.
protected  void setDisplayPriority(int priority)
          Set the logical priority this mark belongs to for ordering purposes.
 void setDocument(EditorDocument doc)
          This is called by the document when a mark is inserted.
protected  void setStyle(javax.swing.text.Style style)
          Set the style to use when painting a line with this mark.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineMark

public LineMark()
Create a new "heavyweight" LineMark.

LineMark

public LineMark(boolean lightweight)
Create a new LineMark.
Parameters:
lightweight - True if this is to be a lightweight mark.

LineMark

public LineMark(javax.swing.text.Style style)
Create a new "heavyweight" LineMark that paints using the specified style.
Parameters:
style - The style to use when painting a line with this mark.

LineMark

public LineMark(boolean lightweight,
                javax.swing.text.Style style)
Create a new LineMark that paints using the specified style.
Parameters:
lightweight - True if this is to be a lightweight mark.
style - The style to use when painting a line with this mark.

LineMark

public LineMark(boolean lightweight,
                javax.swing.text.Style style,
                EditorPane editor)
Create a new LineMark that paints using the specified style and make sure it will only be displayed in the specified editor.
Parameters:
lightweight - True if this is to be a lightweight mark.
style - The style to use when painting a line with this mark.
editor - The editor that should exclusively show this linemark.
Method Detail

isLightweight

public boolean isLightweight()
Check to see if this is a lightweight mark or not.
Returns:
True if this mark is a lightweight mark.

getStyle

public javax.swing.text.Style getStyle()
Get the style to use when painting a line with this mark.
Returns:
The style to use when painting a line with this mark. This may return null if no style is set.

setStyle

protected void setStyle(javax.swing.text.Style style)
Set the style to use when painting a line with this mark.
Parameters:
style - The style.

getDisplayPriority

public int getDisplayPriority()
Describes the logical priority this mark belongs to for ordering purposes. Marks with a higher priority paint over marks with a lower priority, if both are on the same line.

For reference, here are some of the defined priority values:

Returns:
An int value specifying the display priority of this mark.

setDisplayPriority

protected void setDisplayPriority(int priority)
Set the logical priority this mark belongs to for ordering purposes.
Parameters:
priority - An int value specifying the display priority of this mark.
See Also:
getDisplayPriority()

setDocument

public void setDocument(EditorDocument doc)
This is called by the document when a mark is inserted. This is required so that the mark can be used to look up its location, when asked. For lightweight marks, this has no effect.

getDocument

protected EditorDocument getDocument()
Get the document that this mark is associated with.

This is provided so that subclasses can manage themselves, if desired. A subclasses can get access to the document it are associated with so that it can remove itself from that document before placing itself somewhere else.


addEditor

public void addEditor(EditorPane editor)
Normally linemarks are tied to a document and all editors that display that document will show the linemark. Sometimes a linemark needs to be tied to an EditorPane so it is displayed in that editor, not in all editors tied to a document. You can tie a line mark to multiple EditorPanes (that either belong to the same document, or not) by calling this function multiple times with different EditorPanes. Use removeEditor to remove the tie between a line mark and an editor.
Parameters:
editor - The EditorPane that should be tied to this lineMark. This call does nothing if editor is null.

displayInEditor

public boolean displayInEditor(EditorPane editor)
Should this line mark be displayed in the incoming editor? If this line mark is not editor specific, it can always be displayed in all editors, otherwise the incoming editor has to be one of the editors set by addEditor.

removeEditor

public void removeEditor(EditorPane editor)
Remove all the ties that this line mark has to the incoming editor pane.
Parameters:
editor - The editor pane that should not be tied to this line mark anymore.

removeEditor

public void removeEditor(javax.swing.text.Document doc)
Remove all the ties that this line mark has to all editor panes belonging to this document.
Parameters:
doc - The document whose editors should not have any ties anymore to this linemark.

removeEditor

public void removeEditor()
Remove all the ties that this line mark has to all editor panes. This effectively turns this line mark into a mark that will be displayed in all editors.

getMarkLine

public int getMarkLine()
Get the current location of this mark.
Returns:
the current 1-based line number of this mark. -1 is returned if this mark does not exist in a document, or if this mark is lightweight.