Commit 6e32a658 authored by Guilhelm Savin's avatar Guilhelm Savin

Merge branch 'master' of github.com:graphstream/gs-ui

parents 1e0ec86a 73f94f7e
......@@ -17,9 +17,13 @@ We are interested in any suggestion to improve this renderer, and your use cases
Building and jars
-----------------
Building the Scala renderer requires to install the Scala compiler and library. The process of creating a jar maybe fastidious, therefore pre-made jars are available in the `lib/` directory. The `gs-ui-bin.jar` contains only the set of classes of the renderer. It requires the Scala library in the class-path to work. If you work with Scala, and have it installed an available in your class-path you can use this jar. The `gs-ui.jar` is a standalone jar that contains the `gs-ui-bin.jar` plus the parts of the Scala Library used by the Scala viewer (and only these parts, this does not include the complete Scala library).
Building the Scala renderer requires to install the Scala compiler and library, but this can be made easier with the help of maven.
In addition to the Scala library, this renderer only depends on the `gs-core` module.
To compile gs-ui, enter this directory and simply enter :
mvn package
If all went well, you will find a gs-ui-X.Y.jar or a gs-ui-X.Y-git.jar in the "target" directory. This jar is a stand-alone jar that will include the scala clases needed to work.
I you plan to build the Scala renderer by yourself, you can have a look at the `compile.sh` script (for a Bash shell). It needs to be edited and is really basic, but should give you an idea of what is needed. An easier solution could probably be to install the Scala IDE plug-in for Eclipse or the one for NetBeans. The `gs-ui-bin.jardesc` allows to build a jar of the renderer under eclipse provided you have the Scala plugin. This is how the `gs-ui-bin.jar` is created. The `gs-ui.jar` file is created using the ProGuard tool that allows to put in a jar only the classes that are really needed.
......
#!/bin/bash
DIR=/home/antoine/Documents/Programs/
DIR=/Users/antoine/Documents/Programs/
UIDIR=$DIR/gs-ui/
FILES=`find $UIDIR -iname "*.scala"`
......
......@@ -90,6 +90,16 @@ class ConnectorSkeleton extends Skeleton with AttributeUtils {
private[this] var isALoop = false
private[this] var ptsRef:AnyRef = null // used to avoid recomputing the point set
override def toString():String = "CtorSkel(%s, {%s})".format(kindString, points.toString)
def kindString():String = {
kind match {
case EdgeShapeKind.POLYLINE => "polyline"
case EdgeShapeKind.CURVE => "curve"
case _ => "line"
}
}
/** If true the edge shape is a polyline made of size points. */
def isPoly = kind == EdgeShapeKind.POLYLINE
......
......@@ -196,8 +196,8 @@ trait Connector {
if(element.hasAttribute("ui.points")) {
skel.setPoly(element.getAttribute[AnyRef]("ui.points"))
} else {
positionForLinesAndCurves( skel, element.from.getStyle, element.from.getX, element.from.getY,
element.to.getX, element.to.getY, element.multi, element.getGroup )
positionForLinesAndCurves( skel, element.from.getStyle, element.from,
element.to, element.multi, element.getGroup )
}
}
......@@ -252,8 +252,8 @@ trait Connector {
}
/** Give the position of the origin and destination points. */
private[this] def positionForLinesAndCurves( skel:ConnectorSkeleton, style:Style, xFrom:Double, yFrom:Double, xTo:Double, yTo:Double ) {
positionForLinesAndCurves( skel, style, xFrom, yFrom, xTo, yTo, 0, null ) }
private[this] def positionForLinesAndCurves( skel:ConnectorSkeleton, style:Style, from:GraphicNode, to:GraphicNode) {
positionForLinesAndCurves( skel, style, from, to, 0, null ) }
/**
* Give the position of the origin and destination points, for multi edges.
......@@ -263,25 +263,24 @@ trait Connector {
* since we do not know the curves). This is important since arrows and sprites can be attached to edges.
* </p>
*/
private[this] def positionForLinesAndCurves( skel:ConnectorSkeleton, style:Style, xFrom:Double, yFrom:Double, xTo:Double, yTo:Double, multi:Int, group:GraphicEdge#EdgeGroup ) {
private[this] def positionForLinesAndCurves( skel:ConnectorSkeleton, style:Style, from:GraphicNode, to:GraphicNode, multi:Int, group:GraphicEdge#EdgeGroup ) {
//skel.points(0).set( xFrom, yFrom )
//skel.points(3).set( xTo, yTo )
if( group != null ) {
if( xFrom == xTo && yFrom == yTo ) {
positionEdgeLoop(skel, xFrom, yFrom, multi)
if( from == to ) {
positionEdgeLoop(skel, from.getX, from.getY, multi)
} else {
positionMultiEdge(skel, xFrom, yFrom, xTo, yTo, multi, group)
positionMultiEdge(skel, from.getX, from.getY, to.getX, to.getY, multi, group)
}
} else {
if( xFrom == xTo && yFrom == yTo ) {
positionEdgeLoop(skel, xFrom, yFrom, 0)
if( from == to) {
positionEdgeLoop(skel, from.getX, from.getY, 0)
} else {
// This does not mean the edge is not a curve, this means
// that with what we know actually it is not a curve.
// The style mays indicate a curve.
skel.setLine(xFrom, yFrom, 0, xTo, yTo, 0)
skel.setLine(from.getX, from.getY, 0, to.getX, to.getY, 0)
// XXX we will have to mutate the skel into a curve later.
}
}
......
......@@ -607,13 +607,14 @@ class FreePlaneEdgeShape extends LineConnectorShape {
make(camera, 0, 0, 0, 0)
}
protected def make(camera: Camera, sox: Double, soy: Double, swx: Double, swy: Double) {
protected def make(camera: Camera, sox: Double, soy: Double, swx: Double, swy: Double) {
if (skel.multi > 1 || skel.isLoop) // is a loop or a multi edge
makeMultiOrLoop(camera, sox, soy, swx, swy)
else makeSingle(camera, sox, soy, swx, swy) // is a single edge.
}
protected def makeSingle(camera: Camera, sox: Double, soy: Double, swx: Double, swy: Double) {
try {
var fromx = skel.from.x + sox
val fromy = skel.from.y + soy - theSourceSize.y / 2
var tox = skel.to.x + sox
......@@ -655,6 +656,9 @@ class FreePlaneEdgeShape extends LineConnectorShape {
c2x, c2y, 0,
tox, toy, 0)
}
} catch {
case e:Exception => { Console.err.println("FOUND") }
}
}
protected def makeMultiOrLoop(camera: Camera, sox: Double, soy: Double, swx: Double, swy: Double) {
......
......@@ -55,4 +55,6 @@ class EdgePoints(n:Int) {
def apply(i:Int):Point3 = points(i)
def update(i:Int, coos:Point3) = points(i) = new Point3(coos.x, coos.y, coos.z)
override def toString():String = "pts(%s):%d".format(points.mkString(","), points.size)
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment