multivalent.std.span

Class HyperlinkSpan

public class HyperlinkSpan extends Span

This is the familiar point-to-point link. Note that it's not built in -- you can add new link types easily. Elaborately commented to serve as a simple example of translating Multivalent protocols into Java methods; also see ClipProvenance.

Version: $Revision: 1.9 $ $Date: 2003/03/05 08:42:07 $

See Also: ActionSpan ScriptSpan

Field Summary
static byteACTIVE
Link state.
static StringATTR_URI
static byteHOVER
Link state.
static byteLINK
Link state.
static StringMSG_COPY_LINK
Copy link URI to clipboard.
protected bytestate_
Current state of the link--normal, seen, cursor hovering above, mouse clicked on-- show we can show visually.
protected Objecttarget_
Target of link can be given as a String or URL.
static byteVISITED
Link state.
Method Summary
booleanappearance(Context cx, boolean all)
Spans are ContextListener's, which are behaviors that compose together to determine the Context display properties at every point in the document.
voidevent(AWTEvent e)
Once we set the grab, subsequent events go directly to here, not to eventBefore/eventAfter.
booleaneventAfter(AWTEvent e, Point rel, Node n)
On a mouse button down, directly receive all furture low-level events by setting a grab in Browser, until a mouse button up.
intgetPriority()
Prefer for style sheet to set appearance.
bytegetState()
Run-of-the-mill field getter.
ObjectgetTarget()
Run-of-the-mill field getter.
URIgetURI()
Run-of-the-mill field getter.
voidgo()
Override this for special action when hyperlink is clicked.
voidrestore(ESISNode n, Map<String,Object> attr, Layer layer)
Restore almost always invokes its superclass, which when it chains up to Behavior sets the behavior's attributes and adds it to the passed layer.
ESISNodesave()
booleansemanticEventAfter(SemanticEvent se, String msg)
Catch "copyLink" sent in semanticEventBefore.
booleansemanticEventBefore(SemanticEvent se, String msg)
Add to the DOCPOPUP menu--the menu that pops up when the alternative mouse button is clicked over some part of the document (as opposed to the menubar) and the click is not short-circuited out by some behavior.
voidsetMessage(String msg)
Message to show when mouse hovers over link.
voidsetSeen(boolean seen)
Run-of-the-mill field setter.
protected voidsetState(byte state)
Run-of-the-mill field setter.
voidsetTarget(Object o)
Sets target that isn't String or URI or URL.
voidsetURI(String txt)
Computes full, canonical URL from a relative specification.
StringtoString()

Field Detail

ACTIVE

public static final byte ACTIVE
Link state.

ATTR_URI

public static final String ATTR_URI

HOVER

public static final byte HOVER
Link state.

LINK

public static final byte LINK
Link state.

MSG_COPY_LINK

public static final String MSG_COPY_LINK
Copy link URI to clipboard.

"copyLink".

state_

protected byte state_
Current state of the link--normal, seen, cursor hovering above, mouse clicked on-- show we can show visually.

target_

protected Object target_
Target of link can be given as a String or URL.

VISITED

public static final byte VISITED
Link state.

Method Detail

appearance

public boolean appearance(Context cx, boolean all)
Spans are ContextListener's, which are behaviors that compose together to determine the Context display properties at every point in the document. For instance, a document will usually determine the font family, size, style, and foreground and background colors, among many other properties, of a piece of text with a combination of ContextListeners reporesenting the influence of style sheet settings, built-in span settings, and perhaps lenses. Here, the generic hyperlink hardcodes the action of coloring the text and gives it an underline, choosing either blue or red. The HTML media adaptor overrides this method to have no action, as the hyperlink appearance is dictated entirely by style sheets, either one linked to the particular web page or failing that the default HTML style sheet.

event

public void event(AWTEvent e)
Once we set the grab, subsequent events go directly to here, not to eventBefore/eventAfter.

eventAfter

public boolean eventAfter(AWTEvent e, Point rel, Node n)
On a mouse button down, directly receive all furture low-level events by setting a grab in Browser, until a mouse button up. Also, take the synthesized events (that is, generated by a multivalent.* class as opposed to a java.* class) corresponding to entering and exiting the span, at which time change the cursor and perhaps the colors to indicate that the link is active. As a Span, the hyperlink receives low-level events in the region of the document it spans without additional registering. This is eventAfter rather than eventBefore because the rule of thumb is to build in before so it's available to other behaviors, and to take action in after if some other behavior hasn't short-circuited you.

getPriority

public int getPriority()
Prefer for style sheet to set appearance.

getState

public byte getState()
Run-of-the-mill field getter.

getTarget

public Object getTarget()
Run-of-the-mill field getter.

getURI

public URI getURI()
Run-of-the-mill field getter. Same as getTarget, but more convenient if target type known to be URL.

go

public void go()
Override this for special action when hyperlink is clicked. Defaults to sending MSG_OPEN semantic event to target_. If target is a SemanticEvent, then it is fired.

restore

public void restore(ESISNode n, Map<String,Object> attr, Layer layer)
Restore almost always invokes its superclass, which when it chains up to Behavior sets the behavior's attributes and adds it to the passed layer. Many behaviors also set default parameters and set fields from attributes in the attribute hash table that all behaviors have. See Behavior's superclass, VObject, to examine the various attribute accessor methods.

save

public ESISNode save()

semanticEventAfter

public boolean semanticEventAfter(SemanticEvent se, String msg)
Catch "copyLink" sent in semanticEventBefore. The pair of MSG_OPEN are handled by another behavior. Many subclasses have various parameters or attributes, such as URL here or annotation text elsewhere, and the Span class supports editing by catching MSG_EDIT and throwing up an associated HTML document with a FORM in a note window. When that window is closed, it sends MSG_FORM_DATA. semantic event with the name-value pairs of the form as a parameter.

semanticEventBefore

public boolean semanticEventBefore(SemanticEvent se, String msg)
Add to the DOCPOPUP menu--the menu that pops up when the alternative mouse button is clicked over some part of the document (as opposed to the menubar) and the click is not short-circuited out by some behavior. Similarly to ClipProvenance, add MSG_EDIT if the span is in an editable layer (e.g., if link comes from the HTML sent by a random server, it isn't editable, whereas link annotations you added are), "copyLink", "open in new window", and "open in shared window".

setMessage

public void setMessage(String msg)
Message to show when mouse hovers over link.

setSeen

public void setSeen(boolean seen)
Run-of-the-mill field setter.

setState

protected void setState(byte state)
Run-of-the-mill field setter. Checks seen_ flag to see if link seen before.

setTarget

public void setTarget(Object o)
Sets target that isn't String or URI or URL.

setURI

public void setURI(String txt)
Computes full, canonical URL from a relative specification. The canonical URL is used in the table of links already seen.

toString

public String toString()