com.planet_ink.coffee_mud.Libraries.layouts
Class DefaultLayoutNode

java.lang.Object
  extended by com.planet_ink.coffee_mud.Libraries.layouts.DefaultLayoutNode
All Implemented Interfaces:
AreaGenerationLibrary.LayoutNode

public class DefaultLayoutNode
extends java.lang.Object
implements AreaGenerationLibrary.LayoutNode


Field Summary
 Room associatedRoom
           
 long[] coord
           
 java.util.Map<java.lang.Integer,AreaGenerationLibrary.LayoutNode> links
           
 
Constructor Summary
DefaultLayoutNode(long[] coord)
           
DefaultLayoutNode(long x, long y)
           
 
Method Summary
 long[] coord()
          Returns x,y coordinates of this node.
 void crossLink(AreaGenerationLibrary.LayoutNode to)
          Uses this nodes coordinates, as well as the coordinates of the given connected node, this method will create a link between them of the appropriate direction see delLink(LayoutNode)
 void deLink()
          Removes all links from other nodes to this one, and removes all links from this node to others.
 void delLink(AreaGenerationLibrary.LayoutNode linkNode)
          Removes all directional links between this node and the given node.
 void flag(AreaGenerationLibrary.LayoutFlags flag)
          Flags this node with one of the visual layout flags, telling whether it is at an intersection, or on a corner, or something like that.
 void flagRun(AreaGenerationLibrary.LayoutRuns run)
          Flags this node as being part of a street-like run.
 java.lang.String getColorRepresentation(char roomChar, int line)
          Returns one line of a 3x3 character representation.
 AreaGenerationLibrary.LayoutRuns getFlagRuns()
          Return whether this node is flagged as being part of a street-like run.
 AreaGenerationLibrary.LayoutNode getLink(int d)
          Returns a link from this node in the given direction.
 boolean isFlagged(AreaGenerationLibrary.LayoutFlags flag)
          Returns whether this node is flagged with one of the visual layout flags, telling whether it is an intersectino, or on a corner, or something like that.
 boolean isStreetLike()
          Returns true if the first two linked nodes to this node are in the same general direction, this making this node look like a street node.
 java.util.Map<java.lang.Integer,AreaGenerationLibrary.LayoutNode> links()
          Returns a map of directions to other layoutnodes.
 void reType(AreaGenerationLibrary.LayoutTypes type)
          Sets the layout type flag that this node represents, denoting whether it is a leaf, a street, or some other role.
 Room room()
          Returns the room object assigned to this node.
 void setExits(int[] dirs)
          Sets the exit available link directions, without setting the nodes they are linked to -- what good is this? Well, it sets the LayoutTags.NODEEXITS string, which makes some sense I guess.
 void setRoom(Room room)
          Sets the room object assigned to this node.
 java.util.Map<AreaGenerationLibrary.LayoutTags,java.lang.String> tags()
          Returns comma-delimited values of each LayoutTag type, through a may of layouttag to string mapping.
 java.lang.String toString()
           
 AreaGenerationLibrary.LayoutTypes type()
          Returns the layout type flag that this node represents, denoting whether it is a leaf, a street, or some other role.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

coord

public long[] coord

associatedRoom

public Room associatedRoom

links

public java.util.Map<java.lang.Integer,AreaGenerationLibrary.LayoutNode> links
Constructor Detail

DefaultLayoutNode

public DefaultLayoutNode(long[] coord)

DefaultLayoutNode

public DefaultLayoutNode(long x,
                         long y)
Method Detail

room

public Room room()
Description copied from interface: AreaGenerationLibrary.LayoutNode
Returns the room object assigned to this node.

Specified by:
room in interface AreaGenerationLibrary.LayoutNode
Returns:
the room object assigned to this node.
See Also:
AreaGenerationLibrary.LayoutNode.setRoom(Room)

setRoom

public void setRoom(Room room)
Description copied from interface: AreaGenerationLibrary.LayoutNode
Sets the room object assigned to this node.

Specified by:
setRoom in interface AreaGenerationLibrary.LayoutNode
Parameters:
room - the room object assigned to this node.
See Also:
AreaGenerationLibrary.LayoutNode.room()

coord

public long[] coord()
Description copied from interface: AreaGenerationLibrary.LayoutNode
Returns x,y coordinates of this node. These are generated by the layout manager.

Specified by:
coord in interface AreaGenerationLibrary.LayoutNode
Returns:
x,y coordinates of this node

tags

public java.util.Map<AreaGenerationLibrary.LayoutTags,java.lang.String> tags()
Description copied from interface: AreaGenerationLibrary.LayoutNode
Returns comma-delimited values of each LayoutTag type, through a may of layouttag to string mapping.

Specified by:
tags in interface AreaGenerationLibrary.LayoutNode
Returns:
the map of layouttags to strings
See Also:
AreaGenerationLibrary.LayoutTags

links

public java.util.Map<java.lang.Integer,AreaGenerationLibrary.LayoutNode> links()
Description copied from interface: AreaGenerationLibrary.LayoutNode
Returns a map of directions to other layoutnodes. These being the established links between nodes. crossLink must have been called for there to be any links. see crossLink(LayoutNode) see delLink(LayoutNode)

Specified by:
links in interface AreaGenerationLibrary.LayoutNode
Returns:
the map of links
See Also:
AreaGenerationLibrary.LayoutNode.deLink(), AreaGenerationLibrary.LayoutNode.getLink(int)

crossLink

public void crossLink(AreaGenerationLibrary.LayoutNode to)
Description copied from interface: AreaGenerationLibrary.LayoutNode
Uses this nodes coordinates, as well as the coordinates of the given connected node, this method will create a link between them of the appropriate direction see delLink(LayoutNode)

Specified by:
crossLink in interface AreaGenerationLibrary.LayoutNode
Parameters:
to - the node to connect this one to.
See Also:
AreaGenerationLibrary.LayoutNode.getLink(int), AreaGenerationLibrary.LayoutNode.links(), AreaGenerationLibrary.LayoutNode.deLink()

isFlagged

public boolean isFlagged(AreaGenerationLibrary.LayoutFlags flag)
Description copied from interface: AreaGenerationLibrary.LayoutNode
Returns whether this node is flagged with one of the visual layout flags, telling whether it is an intersectino, or on a corner, or something like that. see flag(LayoutFlags)

Specified by:
isFlagged in interface AreaGenerationLibrary.LayoutNode
Parameters:
flag - the flag to check for
Returns:
true if this node is flagged, false otherwise

getFlagRuns

public AreaGenerationLibrary.LayoutRuns getFlagRuns()
Description copied from interface: AreaGenerationLibrary.LayoutNode
Return whether this node is flagged as being part of a street-like run.

Specified by:
getFlagRuns in interface AreaGenerationLibrary.LayoutNode
Returns:
the direction of the run, or null
See Also:
AreaGenerationLibrary.LayoutRuns

delLink

public void delLink(AreaGenerationLibrary.LayoutNode linkNode)
Description copied from interface: AreaGenerationLibrary.LayoutNode
Removes all directional links between this node and the given node. see crossLink(LayoutNode)

Specified by:
delLink in interface AreaGenerationLibrary.LayoutNode
Parameters:
linkNode - the node to de-link from.
See Also:
AreaGenerationLibrary.LayoutNode.getLink(int), AreaGenerationLibrary.LayoutNode.links(), AreaGenerationLibrary.LayoutNode.deLink()

getLink

public AreaGenerationLibrary.LayoutNode getLink(int d)
Description copied from interface: AreaGenerationLibrary.LayoutNode
Returns a link from this node in the given direction. crossLink must have already been called to establish the link. see crossLink(LayoutNode) see delLink(LayoutNode)

Specified by:
getLink in interface AreaGenerationLibrary.LayoutNode
Parameters:
d - the direction code
Returns:
the node in the given direction
See Also:
AreaGenerationLibrary.LayoutNode.links(), AreaGenerationLibrary.LayoutNode.deLink()

isStreetLike

public boolean isStreetLike()
Description copied from interface: AreaGenerationLibrary.LayoutNode
Returns true if the first two linked nodes to this node are in the same general direction, this making this node look like a street node.

Specified by:
isStreetLike in interface AreaGenerationLibrary.LayoutNode
Returns:
true if this node is part of a street.

deLink

public void deLink()
Description copied from interface: AreaGenerationLibrary.LayoutNode
Removes all links from other nodes to this one, and removes all links from this node to others. crossLink must have been called for there to be any links. see crossLink(LayoutNode) see delLink(LayoutNode)

Specified by:
deLink in interface AreaGenerationLibrary.LayoutNode
See Also:
AreaGenerationLibrary.LayoutNode.links(), AreaGenerationLibrary.LayoutNode.getLink(int)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

flag

public void flag(AreaGenerationLibrary.LayoutFlags flag)
Description copied from interface: AreaGenerationLibrary.LayoutNode
Flags this node with one of the visual layout flags, telling whether it is at an intersection, or on a corner, or something like that.

Specified by:
flag in interface AreaGenerationLibrary.LayoutNode
Parameters:
flag - the flag to set.

flagRun

public void flagRun(AreaGenerationLibrary.LayoutRuns run)
Description copied from interface: AreaGenerationLibrary.LayoutNode
Flags this node as being part of a street-like run.

Specified by:
flagRun in interface AreaGenerationLibrary.LayoutNode
Parameters:
run - the direction of the run
See Also:
AreaGenerationLibrary.LayoutRuns

type

public AreaGenerationLibrary.LayoutTypes type()
Description copied from interface: AreaGenerationLibrary.LayoutNode
Returns the layout type flag that this node represents, denoting whether it is a leaf, a street, or some other role.

Specified by:
type in interface AreaGenerationLibrary.LayoutNode
Returns:
the type of this node
See Also:
AreaGenerationLibrary.LayoutTypes

setExits

public void setExits(int[] dirs)
Description copied from interface: AreaGenerationLibrary.LayoutNode
Sets the exit available link directions, without setting the nodes they are linked to -- what good is this? Well, it sets the LayoutTags.NODEEXITS string, which makes some sense I guess.

Specified by:
setExits in interface AreaGenerationLibrary.LayoutNode
Parameters:
dirs - the array of Direction codes to set.

reType

public void reType(AreaGenerationLibrary.LayoutTypes type)
Description copied from interface: AreaGenerationLibrary.LayoutNode
Sets the layout type flag that this node represents, denoting whether it is a leaf, a street, or some other role.

Specified by:
reType in interface AreaGenerationLibrary.LayoutNode
Parameters:
type - the type of this node
See Also:
AreaGenerationLibrary.LayoutTypes

getColorRepresentation

public java.lang.String getColorRepresentation(char roomChar,
                                               int line)
Description copied from interface: AreaGenerationLibrary.LayoutNode
Returns one line of a 3x3 character representation. Each call returns 3 characters, with the middle being the roomchar, and the rest depending on the links. Call this three times with 0, 1, and 2, to get all three lines.

Specified by:
getColorRepresentation in interface AreaGenerationLibrary.LayoutNode
Parameters:
roomChar - the char to use for this room
line - which line, 0, 1, or 2
Returns:
the 3 character string for this line.