org.fenfire.loom
Class WheelView

java.lang.Object
  |
  +--org.fenfire.loom.WheelView
All Implemented Interfaces:
View
Direct Known Subclasses:
SundewWheelView

public class WheelView
extends java.lang.Object
implements View

A simple wheel view. Example:

          neg1 |
        neg2 \   / pos1
      neg3 - focus - pos2
        neg4 /    \ pos3
          neg5 |
  


Field Summary
static boolean dbg
           
protected  int gapx
           
protected  int gapy
           
protected  int maxDepth
          How deeply should the structure be shown.
protected  double maxrota
          Maximum rotation angle.
protected  Vob negConn
           
protected  Vob negStub
           
protected  NodeView nodeView
          The view used to show the individual nodes.
protected  Vob posConn
          Connection and Stub vobs for both two directions.
protected  Vob posStub
           
protected  int radius
           
protected  int sizex
          Dimensions XXX gapy has currently no effect, should be used to determine the minimum rotation angle.
protected  int sizey
          Dimensions XXX gapy has currently no effect, should be used to determine the minimum rotation angle.
 
Constructor Summary
WheelView(NodeView nodeView)
           
WheelView(NodeView nodeView, int maxDepth)
          WheelView
 
Method Summary
protected  java.util.Collection getNodes(Cursor c, int dir)
           
protected  java.util.Collection getNodes(Cursor c, Resource node, int dir)
          Get pairs of nodes and their properties in given direction
protected  double getRotationAngle(Cursor c, java.util.Collection nodes, double angle, int depth)
          Calculates rotation angle for a collection of nodes.
protected  int getSubNodeCount(Cursor c, java.util.Collection nodes, int depth)
          Recursive function to calculate all the subconnections in some direction.
 void render(VobScene sc, int into, Cursor c)
          View render function
protected  void renderDepth(VobScene sc, int into, int focusCs, Cursor c, Pair focus, Pair oldFocus, int dir, double starta, double rota, float r, int midx, int midy, int depth)
          Determines how the next depth should be drawn and finally calls renderSomewardConnections.
 void renderSomewardConnections(VobScene sc, int into, int focusCs, Cursor c, Pair focus, Pair oldFocus, java.util.Collection nodes, int before, int dir, double starta, double rota, float r, int midx, int midy, int depth)
          Render either posward or negward connections (or onward, maybe).
protected  int x(double angle, float radius)
          Calculates x from the origo.
protected  int y(double angle, float radius)
          Calculates y from the origo.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbg

public static boolean dbg

nodeView

protected NodeView nodeView
The view used to show the individual nodes.


posConn

protected final Vob posConn
Connection and Stub vobs for both two directions. Actually only PinStub vob should be different for both directions. The Length of PinStub vob is currently 1/3 of the distance between constructor parameter points after transformations.


negConn

protected final Vob negConn

posStub

protected final Vob posStub

negStub

protected final Vob negStub

sizex

protected int sizex
Dimensions XXX gapy has currently no effect, should be used to determine the minimum rotation angle.


sizey

protected int sizey
Dimensions XXX gapy has currently no effect, should be used to determine the minimum rotation angle.


gapx

protected int gapx

gapy

protected int gapy

radius

protected int radius

maxDepth

protected int maxDepth
How deeply should the structure be shown.


maxrota

protected double maxrota
Maximum rotation angle.

Constructor Detail

WheelView

public WheelView(NodeView nodeView,
                 int maxDepth)
WheelView

Parameters:
nodeView - The view used to show the individual nodes.
maxDepth - How deeply should the structure be shown. Equal or greater than zero.

WheelView

public WheelView(NodeView nodeView)
Method Detail

renderSomewardConnections

public void renderSomewardConnections(VobScene sc,
                                      int into,
                                      int focusCs,
                                      Cursor c,
                                      Pair focus,
                                      Pair oldFocus,
                                      java.util.Collection nodes,
                                      int before,
                                      int dir,
                                      double starta,
                                      double rota,
                                      float r,
                                      int midx,
                                      int midy,
                                      int depth)
Render either posward or negward connections (or onward, maybe).

Parameters:
sc - VobScene to draw the view into.
into - The parent coordinate system transformation to use.
focusCs - The CS transformation used to place the focuced node of the previous drawing depth.
c - The main cursor, set to the globally focused node of the view.
focus - Pair containing the focused cell of current drawing depth and property, which connects its to the previously locally focused node.
oldFocus - Pair containing the focused node of the previous drawing depth and property, which connects its to the currently locally focused node.
nodes - Collection, which contains pairs of all the nodes and their properties to be drawn on this depth. One exception: drawing of the oldFocus pair is skipped and an empty place is left instead.
before - How many nodes should be drawn before the selected one.
dir - Is the current collection of nodes located to either positive or negative direction from the focused node.
starta - The angle between focused node and the selected node of current nodes collection.
rota - The rotation angle between drawn nodes in curren collection.
r - The radius of drawn nodes from the coordinate (midx, midy).
midx - The x coordinate of the center of the wheel.
midy - The y coordinate of the center of the wheel.
depth - The Current drawing depth. Depth is increased by one, when proceeding deeper. When maxDepth is achieved, stubs are drawn instead of nodes in the current collection.

renderDepth

protected void renderDepth(VobScene sc,
                           int into,
                           int focusCs,
                           Cursor c,
                           Pair focus,
                           Pair oldFocus,
                           int dir,
                           double starta,
                           double rota,
                           float r,
                           int midx,
                           int midy,
                           int depth)
Determines how the next depth should be drawn and finally calls renderSomewardConnections. This is the most usual function to be overwritten in other WheelViews.

Parameters:
sc - VobScene to draw the view into.
into - The parent coordinate system transformation to use.
focusCs - The CS transformation used to place the focuced node of the previous drawing depth.
c - The main cursor, set to the globally focused node of the view.
focus - Pair containing the focused cell of current drawing depth and property, which connects its to the previously locally focused node.
oldFocus - Pair containing the focused node of the previous drawing depth and property, which connects its to the currently locally focused node.
dir - Is the current collection of nodes located to either positive or negative direction from the focused node.
starta - The angle between focused node and the selected node of curren nodes collection.
rota - The rotation angle between drawn nodes in curren collection.
r - The radius of drawn nodes from the coordinate (midx, midy).
midx - The x coordinate of the center of the wheel.
midy - The y coordinate of the center of the wheel.
depth - The Current drawing depth. Depth is increased by one, when proceeding deeper.

render

public void render(VobScene sc,
                   int into,
                   Cursor c)
View render function

Specified by:
render in interface View
Parameters:
sc - VobScene to draw the view into.
into - The parent coordinate system transformation to use.
c - The main cursor, set to the globally focused node of the view.

getRotationAngle

protected double getRotationAngle(Cursor c,
                                  java.util.Collection nodes,
                                  double angle,
                                  int depth)
Calculates rotation angle for a collection of nodes.

Parameters:
c - The main cursor, set to the globally focused node of the view.
nodes - Collection, which contains pairs of all the nodes and their properties to be drawn on this depth.
angle - The angle of space available for all the nodes in current collection.
depth - The Current drawing depth. Depth is increased by one, when proceeding deeper.
Returns:
Returns the proposed rotation angle, or -1 if amount of nodes in the given collection is zero.

getNodes

protected java.util.Collection getNodes(Cursor c,
                                        Resource node,
                                        int dir)
Get pairs of nodes and their properties in given direction

Parameters:
c - The main cursor, set to the globally focused node of the view.
node - The resource reprecenting the focused node.
dir - The direction from the given node to fetch connected nodes. Zero is interpreted as the both directions.
Returns:
Returns a collection of all the nodes from the given node in the given direction.

getNodes

protected java.util.Collection getNodes(Cursor c,
                                        int dir)

getSubNodeCount

protected int getSubNodeCount(Cursor c,
                              java.util.Collection nodes,
                              int depth)
Recursive function to calculate all the subconnections in some direction.

Parameters:
c - The main cursor, set to the globally focused node of the view.
nodes - Collection, which contains pairs of all the nodes and their properties to be drawn on this depth.
depth - The Current drawing depth. Depth is increased by one, when proceeding deeper.
Returns:
Returns the total amount of subnodes.

x

protected int x(double angle,
                float radius)
Calculates x from the origo.


y

protected int y(double angle,
                float radius)
Calculates y from the origo.