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 byte | ACTIVE |
static String | ATTR_URI |
static byte | HOVER |
static byte | LINK |
static String | MSG_COPY_LINK
Copy link URI to clipboard.
|
protected byte | state_
Current state of the link--normal, seen, cursor hovering above, mouse clicked on--
show we can show visually. |
protected Object | target_ Target of link can be given as a String or URL. |
static byte | VISITED |
Method Summary |
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.
|
void | event(AWTEvent e)
Once we set the grab, subsequent events go directly to here, not to eventBefore/eventAfter. |
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. |
int | getPriority() Prefer for style sheet to set appearance. |
byte | getState() Run-of-the-mill field getter. |
Object | getTarget() Run-of-the-mill field getter. |
URI | getURI() Run-of-the-mill field getter. |
void | go()
Override this for special action when hyperlink is clicked.
|
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. |
ESISNode | save() |
boolean | semanticEventAfter(SemanticEvent se, String msg)
Catch "copyLink" sent in semanticEventBefore .
|
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. |
void | setMessage(String msg) Message to show when mouse hovers over link. |
void | setSeen(boolean seen) Run-of-the-mill field setter. |
protected void | setState(byte state) Run-of-the-mill field setter. |
void | setTarget(Object o) Sets target that isn't String or URI or URL. |
void | setURI(String txt)
Computes full, canonical URL from a relative specification.
|
String | toString() |
public static final byte ACTIVE
public static final String ATTR_URI
public static final byte HOVER
public static final byte LINK
public static final String MSG_COPY_LINK
Copy link URI to clipboard.
"copyLink".
protected byte state_
Current state of the link--normal, seen, cursor hovering above, mouse clicked on--
show we can show visually.
protected Object target_
Target of link can be given as a String or URL.
public static final byte VISITED
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.
public void event(AWTEvent e)
Once we set the grab, subsequent events go directly to here, not to eventBefore/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.
public int getPriority()
Prefer for style sheet to set appearance.
public byte getState()
Run-of-the-mill field getter.
public Object getTarget()
Run-of-the-mill field getter.
public URI getURI()
Run-of-the-mill field getter. Same as getTarget, but more convenient if target type known to be URL.
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.
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.
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.
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".
public void setMessage(String msg)
Message to show when mouse hovers over link.
public void setSeen(boolean seen)
Run-of-the-mill field setter.
protected void setState(byte state)
Run-of-the-mill field setter. Checks seen_ flag to see if link seen before.
public void setTarget(Object o)
Sets target that isn't String or URI or URL.
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.
public String toString()