/[loom]/loom/org/fenfire/loom/SundewWheelView.java
ViewVC logotype

Diff of /loom/org/fenfire/loom/SundewWheelView.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by humppake, Wed Apr 9 14:44:52 2003 UTC revision 1.4 by humppake, Fri Apr 11 08:22:33 2003 UTC
# Line 33  import java.util.*; Line 33  import java.util.*;
33  import org.fenfire.util.Pair;  import org.fenfire.util.Pair;
34  import com.hp.hpl.mesa.rdf.jena.model.*;  import com.hp.hpl.mesa.rdf.jena.model.*;
35    
36  /** A sundew like simple wheel view.  /** A sundew like simple wheel view. */
  */  
37  public class SundewWheelView extends WheelView {  public class SundewWheelView extends WheelView {
38    
39      public static boolean dbg = false;      public static boolean dbg = false;
40      private static void p(String s) { System.out.println(s); }      private static void p(String s) { System.out.println(s); }
41    
42        /** SundewWheelView
43         * @param nodeView The view used to show the individual nodes.
44         */
45      public SundewWheelView(NodeView nodeView) {      public SundewWheelView(NodeView nodeView) {
46          super(nodeView);          super(nodeView);
47    
48          radius = (sizex + gapx) * 2;          radius = (sizex + gapx) * 2;
49          maxDepth = 2;          maxDepth = 2;
50      }      }
51        /**
52         * Determines how the next depth should be drawn and finally calls
53         * renderSomewardConnections. This is the most usual function to
54         * be overwritten in other WheelViews.
55         *
56         * @param sc VobScene to draw the view into.
57         * @param into The parent coordinate system transformation to use.
58         * @param focusCs The CS transformation used to place the focuced
59         *                node of the previous drawing depth.
60         * @param c The main cursor, set to the globally focused node of the view.
61         * @param focus Pair containing the focused cell of current drawing
62         *              depth and property, which connects its to the previously
63         *              locally focused node.
64         * @param oldFocus Pair containing the focused node of the previous
65         *                 drawing depth and property, which connects its to the
66         *                 currently locally focused node.
67         * @param dir Is the current collection of nodes located to either positive
68         *            or negative direction from the focused node.
69         * @param starta The angle between focused node and the selected node
70         *               of curren nodes collection.
71         * @param rota The rotation angle between drawn nodes in curren collection.
72         * @param r The radius of drawn nodes from the coordinate (midx, midy).
73         * @param midx The x coordinate of the center of the wheel.
74         * @param midy The y coordinate of the center of the wheel.
75         * @param depth The Current drawing depth. Depth is increased by one, when
76         *              proceeding deeper.
77         */
78      protected void renderDepth(VobScene sc, int into, int focusCs,      protected void renderDepth(VobScene sc, int into, int focusCs,
79                                 Cursor c, Pair focus, Pair oldFocus,                                 Cursor c, Pair focus, Pair oldFocus,
80                                 int dir, double cura, double rota,                                 int dir, double cura, double rota,
81                                 float r, int midx, int midy, int depth) {                                 float r, int midx, int midy, int depth) {
82            /** Only resources could have "children". */
83          if (((RDFNode)focus.first) instanceof Resource) {          if (((RDFNode)focus.first) instanceof Resource) {
84              oldFocus = new Pair(oldFocus.first, focus.second);              oldFocus = new Pair(oldFocus.first, focus.second);
85                            
86              Collection posNodes, negNodes;              /** Collects the nodes for both directions, because in the
87                 * wheel all nodes on the same level affects the rotation.
88              if (dir > 0) {               */
89                  posNodes = getNodes(c, (Resource)focus.first, 1);              Collection posNodes = getNodes(c, (Resource)focus.first, 1);
90                  negNodes = getNodes(c, (Resource)focus.first, -1);              Collection negNodes = getNodes(c, (Resource)focus.first, -1);
             } else {  
                 posNodes = getNodes(c, (Resource)focus.first, 1);  
                 negNodes = getNodes(c, (Resource)focus.first, -1);  
             }      
91                                            
92              double posRota = getRotationAngle(c, (Resource)focus.first, posNodes,              /** Calculate rotations for single directions. */
93                                                Math.PI, depth);              double posRota = getRotationAngle(c, posNodes, Math.PI, depth);
94              double negRota = getRotationAngle(c, (Resource)focus.first, negNodes,              double negRota = getRotationAngle(c, negNodes, Math.PI, depth);
                                               Math.PI, depth);  
95    
96                /** Selects the lesser rotation angle to avoid overlapping. */
97              double newRota = (posRota < negRota) ? posRota : negRota;              double newRota = (posRota < negRota) ? posRota : negRota;
98    
99                /** Though, getRotationAngle may return -1 if there are no nodes
100                 * at the given direction.
101                 */
102              if (posRota < 0) newRota = negRota;              if (posRota < 0) newRota = negRota;
103              else if (negRota < 0) newRota = posRota;              else if (negRota < 0) newRota = posRota;
104                            
105                /** Subnodes will be drawn from the local origo
106                 * (around the locally focused node).
107                 */
108              int x = midx+x(cura, r);              int x = midx+x(cura, r);
109              int y = midy+y(cura, r);              int y = midy+y(cura, r);
110    
111                /** If we are drawing only stubs the radius may be
112                 * greater than otherwise.
113                 */
114              if (depth == maxDepth) r = gapx + sizex;              if (depth == maxDepth) r = gapx + sizex;
115              else r = r/2;              else r = r/2;
116    
117                /** Initilize cursor for the current locally focused node with
118                 * the right selected node.
119                 */
120              Cursor curPosition = new Cursor(c.getSubjectOrder(), c.getObjectOrder(),              Cursor curPosition = new Cursor(c.getSubjectOrder(), c.getObjectOrder(),
121                                              c.getStatementSelector(), c.names,                                              c.getStatementSelector(), c.names,
122                                              (Resource)focus.first, dir*-1,                                              (Resource)focus.first, dir*-1,
123                                              (RDFNode)oldFocus.first);                                              (RDFNode)oldFocus.first);
124    
125                /** After the new cursor is initilized, the selected nodes (given as
126                 * before to the drawing function) could be fetched correctly.
127                 */
128              int posPosition = curPosition.getRotationIndex(1);              int posPosition = curPosition.getRotationIndex(1);
129              int negPosition = curPosition.getRotationIndex(-1);              int negPosition = curPosition.getRotationIndex(-1);
130                            
131                
132                /** Finally calls renderSomewardConnection. Nodes will be
133                 * always drawn from the local origo (around the locally focused node).
134                 */
135              if (dir > 0) {              if (dir > 0) {
136                  renderSomewardConnections(sc, into, focusCs, c, focus, null,                  renderSomewardConnections(sc, into, focusCs, c, focus, null,
137                                            posNodes, posPosition, 1, 0, newRota,                                            posNodes, posPosition, 1, 0, newRota,
# Line 103  public class SundewWheelView extends Whe Line 149  public class SundewWheelView extends Whe
149              }              }
150          }          }
151      }      }
       
     protected int x(double angle, float radius) {  
         return (int)(Math.cos(angle) * radius);  
     }  
   
     protected int y(double angle, float radius) {  
         return (int)(Math.sin(angle) * radius);  
     }  
152  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26