|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.xqhs.util.config.Config
net.xqhs.graphs.representation.RepresentationElement
net.xqhs.graphs.representation.text.TextRepresentationElement
public class TextRepresentationElement
The class contains the information that is necessary to represent one component of the graph represented by the
parent TextGraphRepresentation
, such as a node, an edge, a subgraph, a graph.
The class contains method for displaying a textual representation of the represented element (and its children) and for reading a textual representation of such an element and its children.
Nested Class Summary | |
---|---|
static class |
TextRepresentationElement.Symbol
An enumeration of the characters that may appear in a textual representation. |
static class |
TextRepresentationElement.Type
Enumeration containing the types of elements that may appear in a textual graph representation. |
Nested classes/interfaces inherited from class net.xqhs.util.config.Config |
---|
net.xqhs.util.config.Config.ConfigLockedException |
Field Summary | |
---|---|
(package private) java.util.List<TextRepresentationElement> |
content
The nested elements. |
static java.lang.String |
DEFAULT_INDENT
The indent for the default representation used in toString() . |
static java.lang.String |
DEFAULT_INDENT_INCREMENT
The indent increment for the default representation used in toString() . |
static int |
DEFAULT_INDENT_LIMIT
The limit to indent incrementing for the default representation used in toString() . |
(package private) boolean |
isFirstSubgraph
true if it is the first subgraph in the container. |
(package private) boolean |
isLastChild
true if it is the last child of the parent. |
(package private) boolean |
isOnlyChild
true if it is the only child of the parent. |
(package private) TextRepresentationElement.Type |
linkType
The type of the element (as one of TextRepresentationElement.Type ). |
(package private) int |
nestingLevel
Not currently used. |
Constructor Summary | |
---|---|
|
TextRepresentationElement(GraphRepresentation root,
TextRepresentationElement.Type type)
Creates a text representation for an element container (a level in a multi-level representation). |
|
TextRepresentationElement(GraphRepresentation root,
TextRepresentationElement.Type type,
boolean first)
Creates a text representation of a subgraph (connected part of a graph). |
|
TextRepresentationElement(GraphRepresentation root,
VisualizableGraphComponent representedNode,
TextRepresentationElement.Type type)
Creates a text representation of a graph node. |
|
TextRepresentationElement(GraphRepresentation root,
VisualizableGraphComponent representedEdge,
TextRepresentationElement.Type type,
int level,
boolean lastChild,
boolean alone)
Creates a text representation of a graph edge. |
protected |
TextRepresentationElement(GraphRepresentation root,
VisualizableGraphComponent representedElement,
TextRepresentationElement.Type type,
int level,
boolean lastChild,
boolean alone,
boolean firstSubgraph)
Constructor aggregating all the other constructors. |
Method Summary | |
---|---|
protected TextRepresentationElement |
addSub(java.util.List<TextRepresentationElement> subs)
Adds a list of subordinate elements to this representation element. |
protected TextRepresentationElement |
addSub(TextRepresentationElement sub)
Adds a subordinate element to this representation element. |
protected static int |
getFirstUnmatchedClosingSymbolIndex(java.lang.String input,
java.lang.String openingSymbol,
java.lang.String closingSymbol)
Considering the input contains various enclosures delimited by an opening symbol and a closing symbol, the methods gets the index of the first closing symbol which is not matched by an opening symbol appearing before it. |
protected static boolean |
isEdgeType(TextRepresentationElement.Type elementType)
True if the specified TextRepresentationElement.Type is a type of edge. |
protected static TextRepresentationElement |
readRepresentation(ContentHolder<java.lang.String> input,
TextGraphRepresentation root,
net.xqhs.util.logging.UnitComponent log)
Same as readRepresentation(String, TextGraphRepresentation, UnitComponent) , but using a content holder
and leaving all un-consumed input in the holder. |
protected static TextRepresentationElement |
readRepresentation(ContentHolder<java.lang.String> input,
TextRepresentationElement.Type type,
boolean firstSibling,
TextGraphRepresentation root,
net.xqhs.util.logging.UnitComponent log)
The method uses the input string to read the representation of an element, removing the representation from the input and leaving other calls of the method to read the rest (if any). |
protected static TextRepresentationElement |
readRepresentation(java.lang.String input,
TextGraphRepresentation root,
net.xqhs.util.logging.UnitComponent log)
The method reads the representation of a whole graph from the given text input. |
java.lang.String |
toString()
Creates a textual rendering of the current representation element, using default settings ( DEFAULT_INDENT , DEFAULT_INDENT_INCREMENT , DEFAULT_INDENT_LIMIT ). |
java.lang.String |
toString(java.lang.String indent,
java.lang.String indentIncrement,
int indentLimit,
boolean isBackwards)
The method creates a textual rendering of the current representation element, as well as of its children. |
Methods inherited from class net.xqhs.graphs.representation.RepresentationElement |
---|
getParentRepresentation, getRepresentedComponent, getRootRepresentation |
Methods inherited from class net.xqhs.util.config.Config |
---|
build, ensureLocked, lock, locked, lockedEx, makeDefaults |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_INDENT
toString()
. See
toString(String, String, int, boolean)
public static final java.lang.String DEFAULT_INDENT_INCREMENT
toString()
. See
toString(String, String, int, boolean)
.
public static final int DEFAULT_INDENT_LIMIT
toString()
. See
toString(String, String, int, boolean)
.
int nestingLevel
boolean isLastChild
true
if it is the last child of the parent.
boolean isOnlyChild
true
if it is the only child of the parent.
boolean isFirstSubgraph
true
if it is the first subgraph in the container.
TextRepresentationElement.Type linkType
TextRepresentationElement.Type
).
java.util.List<TextRepresentationElement> content
Constructor Detail |
---|
public TextRepresentationElement(GraphRepresentation root, TextRepresentationElement.Type type)
root
- - the root representation.type
- - must be TextRepresentationElement.Type.ELEMENT_CONTAINER
(otherwise an exception is thrown).public TextRepresentationElement(GraphRepresentation root, TextRepresentationElement.Type type, boolean first)
root
- - the root representation.type
- - must be TextRepresentationElement.Type.SUBGRAPH
(otherwise an exception is thrown).first
- - true
if it is the first subgraph in a series (otherwise, a separator will be included
in the representation).public TextRepresentationElement(GraphRepresentation root, VisualizableGraphComponent representedEdge, TextRepresentationElement.Type type, int level, boolean lastChild, boolean alone)
root
- - the root representation.representedEdge
- - the Edge
instance (must also implement VisualizableGraphComponent
.type
- - must be one of TextRepresentationElement.Type.EXTERNAL_LINK
, TextRepresentationElement.Type.INTERNAL_LINK
or TextRepresentationElement.Type.BRANCH
(otherwise an exception is thrown).level
- - currently not used // FIXMElastChild
- - true
it it is the last edge going out of its source node.alone
- - true
if it is the only outgoing edge of its source node.public TextRepresentationElement(GraphRepresentation root, VisualizableGraphComponent representedNode, TextRepresentationElement.Type type)
root
- - the root representation.representedNode
- - the Node
instance (must also implement VisualizableGraphComponent
.type
- - must be TextRepresentationElement.Type.NODE
(otherwise an exception is thrown).protected TextRepresentationElement(GraphRepresentation root, VisualizableGraphComponent representedElement, TextRepresentationElement.Type type, int level, boolean lastChild, boolean alone, boolean firstSubgraph)
root
- - the root representation.representedElement
- - the VisualizableGraphComponent
that is beign represented.type
- - the type of the element (as one of TextRepresentationElement.Type
).level
- - TODOlastChild
- - true
if it is the last child of the parent.alone
- - true
if it is the only child of the parent.firstSubgraph
- - true
if it is the first subgraph in the container.Method Detail |
---|
protected TextRepresentationElement addSub(TextRepresentationElement sub)
sub
- - the subordinate element to add.
protected TextRepresentationElement addSub(java.util.List<TextRepresentationElement> subs)
subs
- - the subordinate elements to add, as a List
.
public java.lang.String toString()
DEFAULT_INDENT
, DEFAULT_INDENT_INCREMENT
, DEFAULT_INDENT_LIMIT
).
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String indent, java.lang.String indentIncrement, int indentLimit, boolean isBackwards)
indent
- - this will precede each new element, before indentLimit
is reached. 'Only' children and
nodes will not be prexeded by indent.indentIncrement
- - will be added to the current increment every time the rendering advances one level, but no more than
indentLimit
times. It is not added to the indent when the next level contains only one
child.indentLimit
- - maximum times indentIncrement
is added to indent
. After this limit is
reached, no more indent will be displayed.isBackwards
- - true
if the representation should be 'backwards' (edges point to the left instead of
right).
String
representation of the element.protected static boolean isEdgeType(TextRepresentationElement.Type elementType)
TextRepresentationElement.Type
is a type of edge. True for TextRepresentationElement.Type.INTERNAL_LINK
,
TextRepresentationElement.Type.EXTERNAL_LINK
and TextRepresentationElement.Type.BRANCH
.
elementType
- - the type of element.
true
if the type is a type of edge.protected static TextRepresentationElement readRepresentation(java.lang.String input, TextGraphRepresentation root, net.xqhs.util.logging.UnitComponent log)
readRepresentation(ContentHolder, Type, boolean, TextGraphRepresentation, UnitComponent)
.
While the edges are placed correctly, they have no adjacent nodes. They will be filed in later, in
TextGraphRepresentation.readRepresentation(String)
. Basically, elements are currently correct with
respect to their labels and their placement in a textual layout (toString()
returns an apparently
correct representation). The actual, correct graph is build later.
input
- - the input, as a String
.root
- - the root representation that the read element belongs to.log
- - a UnitComponent
to use for logging messages.
TextRepresentationElement.Type.ELEMENT_CONTAINER
) of the representation.protected static TextRepresentationElement readRepresentation(ContentHolder<java.lang.String> input, TextGraphRepresentation root, net.xqhs.util.logging.UnitComponent log)
readRepresentation(String, TextGraphRepresentation, UnitComponent)
, but using a content holder
and leaving all un-consumed input in the holder.
input
- - the input, held be a ContentHolder
instance.root
- - the root representation that the read element belongs to.log
- - a UnitComponent
to use for logging messages.
TextRepresentationElement.Type.ELEMENT_CONTAINER
) of the representation.protected static TextRepresentationElement readRepresentation(ContentHolder<java.lang.String> input, TextRepresentationElement.Type type, boolean firstSibling, TextGraphRepresentation root, net.xqhs.util.logging.UnitComponent log)
If the representation contains any hyper nodes, it is mandatory that the representation f the graph is enclosed
between TextRepresentationElement.Symbol.ELEMENT_CONTAINER_IN
and TextRepresentationElement.Symbol.ELEMENT_CONTAINER_OUT
.
The input
argument is modified by using ContentHolder.set(Object)
.
input
- - the input, held be a ContentHolder
instance. It is assumed to be a non-empty, correct
representation.type
- - the type of element to read from the input, as one of TextRepresentationElement.Type
.firstSibling
- - true
if this is the first instance in a list of sibling instances (first child of a
parent).root
- - the root representation that the read element belongs to.log
- - a UnitComponent
to use for logging messages.
TextRepresentationElement
.protected static int getFirstUnmatchedClosingSymbolIndex(java.lang.String input, java.lang.String openingSymbol, java.lang.String closingSymbol)
In other words, the methods gets the index of the closing symbol that closes the current enclosure (that has been
opened before the beginning of input
.
Example, for opening and closing symbols '(' and ')', respectively: the returned index for the input
aaa ( bbb (ccc) b) (dd) aaaa) xxxx )
is the closing parenthesis after the group aaaa
.
input
- - the input string.openingSymbol
- - the opening symbol for enclosures.closingSymbol
- - the closing symbol for enclosures.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |