Code Search for Developers
 
 
  

SimpleView.java from gzz at Krugle


Show SimpleView.java syntax highlighted

/*
SimpleView.java
 *
 *    Copyright (c) 2003 by Benja Fallenstein
 *
 *    This file is part of Gzz.
 *    
 *    Gzz is free software; you can redistribute it and/or modify it under
 *    the terms of the GNU Lesser General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *    
 *    Gzz is distributed in the hope that it will be useful, but WITHOUT
 *    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 *    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
 *    Public License for more details.
 *    
 *    You should have received a copy of the GNU Lesser General
 *    Public License along with Gzz; if not, write to the Free
 *    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 */
/*
 * Written by Benja Fallenstein
 */
package gzz.loom;
import gzz.client.*;
import gzz.vob.*;
import gzz.vob.vobs.*;

import java.util.*;
import com.hp.hpl.mesa.rdf.jena.model.*;

/** A very simple view of an RDF graph.
 *  Example:
 *  <pre>
 *      neg1 \
 *      neg2 \       / pos1
 *      neg3 - focus - pos2
 *      neg4 /       \ pos3
 *      neg5 /
 *  </pre>
 */
public class SimpleView implements View {

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

    protected final Vob conn = new SimpleConnection(1,.5f,0,.5f);

    public SimpleView(NodeView nodeView) {
	this.nodeView = nodeView;
    }

    protected int sizex = 250, sizey = 20;
    protected int gapx = 50, gapy = 30;

    public void render(VobScene sc, int into, Cursor c) {
	int midx = sc.size.width/2, midy = sc.size.height/2;
	int cs = sc.orthoBoxCS(into, c.focus, 0, midx-sizex/2, midy-sizey/2, 
			       1, 1, sizex, sizey);
	nodeView.render(sc, cs, c.focus, 0);
	
	int before = c.getRotationIndex(1);
	
	int x = midx + gapx + sizex/2, 
	    y = midy - sizey/2 - before*(gapy+sizey);
	
	for(Iterator j=c.getConnections(1).iterator(); j.hasNext();) {
	    RDFNode node = (RDFNode)j.next();
	    int cs2 = sc.orthoBoxCS(into, node, 0, x, y, 1, 1, sizex, sizey);
	    nodeView.render(sc, cs2, node, 1);
	    sc.map.put(conn, cs, cs2);
	    y += sizey + gapy;
	}

	before = c.getRotationIndex(-1);
	x = midx - gapx - sizex - sizex/2; 
	y = midy - sizey/2 - before*(gapy+sizey);

	for(Iterator j=c.getConnections(-1).iterator(); j.hasNext();) {
	    RDFNode node = (RDFNode)j.next();
	    int cs2 = sc.orthoBoxCS(into, node, 0, x, y, 1, 1, sizex, sizey);
	    nodeView.render(sc, cs2, node, -1);
	    sc.map.put(conn, cs2, cs);
	    y += sizey + gapy;
	}
    }
}




See more files for this project here

gzz

An implementation of Ted Nelson's ZZstructure. ZZstructure is a new type of programming platform for structured data.

Project homepage: http://savannah.nongnu.org/projects/gzz
Programming language(s): C++,Java,Python
License: lgpl21

  Cursor.java
  Loom.java
  NodeView.java
  SimpleView.java
  View.java
  WheelView.java