it.polito.elite.visualization.ontoviewer.tools
Class Relation3DObject

java.lang.Object
  extended by it.polito.elite.visualization.ontoviewer.tools.Relation3DObject

public class Relation3DObject
extends java.lang.Object

This class offers an utility to draw relations as a building block for scenes.It exposes a dummy constructor, a group of set methods in order to explicitly set characteristics as transparency, the radius of line.. It provides also a set of method createRelationXXX (as createISARelation..) which return a java 3D TransformGroup that will be included by the scene itself. An example of its use is: TransformGroup tgx.... Relation3DObject relation = new Relation3DObject(); relation.setRadiusOfCylinderLine(.004f); relation.setTransparency(.3f); BranchGroup branchGroup = relation.createISARelation(relationEnd); tgx.addChild(branchGroup);

Author:
alessio.bosca@polito.it

Field Summary
private  javax.vecmath.Color3f black
           
private static java.util.Hashtable<java.lang.String,java.awt.Color> coloredRelations
           
private  boolean isCardinalityConstrained
           
private  boolean isDatatype
           
private  javax.vecmath.Color3f relationColor
           
private  LinkDirectionEnum relationDirection
           
private  GraphicalLinkTypeEnum relationType
           
private  javax.vecmath.Vector3f relativeEndingOBJPosition
           
private  java.util.HashSet<RelationData> setOfRelationData
           
private  float sourceElementSize
           
private  javax.vecmath.Vector3f translationVector
           
private  float transparency
           
private  java.lang.String uriOfPickableEndingOBJ
           
 
Constructor Summary
Relation3DObject()
          Void constructor.
 
Method Summary
private  void addComplementOf(javax.media.j3d.TransformGroup tgx)
           
private  void addDataTypeRange(javax.media.j3d.TransformGroup tgx)
           
private  void addEnumerationRange(javax.media.j3d.TransformGroup tgx)
           
private  void addIntersectionRange(javax.media.j3d.TransformGroup tgx)
           
private  void addNamedConceptRange(javax.media.j3d.TransformGroup tgx)
           
private  void addNamedIndividualRange(javax.media.j3d.TransformGroup tgx)
           
private  void addRestrictionRange(javax.media.j3d.TransformGroup tgx)
           
private  void addUnionRange(javax.media.j3d.TransformGroup tgx)
           
private  float computeConePositionScale()
          represents the position (between 0 origin and 1 end position) where the cone should be placed
private  javax.media.j3d.Transform3D computeOrientation(javax.vecmath.Vector3f finalPos, float scale, boolean invertDirection, boolean isCone)
           
private  javax.media.j3d.Appearance createArrowHeadAppearance(boolean isMultipleRelation)
          Metodhs that adjusts graphics setting for the appearance of the components and returns a proper appearance
 javax.media.j3d.BranchGroup createCurvedArrowRelation(java.util.HashSet<RelationData> relations, javax.vecmath.Vector3f relativeEndingPosition, float curvefactor, LinkDirectionEnum dir)
           
 javax.media.j3d.BranchGroup createInstanceCurvedArrowRelation(java.util.Hashtable<java.lang.String,RelationType> relations, javax.vecmath.Vector3f relativeEndingPosition, float curvefactor, LinkDirectionEnum dir)
           
 javax.media.j3d.BranchGroup createInstanceSelfLoopRelation(java.util.Hashtable<java.lang.String,RelationType> relations, float sourceSphereRadius, javax.vecmath.AxisAngle4f angle)
           
 javax.media.j3d.BranchGroup createInstanceStraightRelation(java.util.Hashtable<java.lang.String,RelationType> relations, javax.vecmath.Vector3f relativeEndingPosition, float sourceSphereRadius, LinkDirectionEnum dir)
           
 javax.media.j3d.BranchGroup createISARelation(javax.vecmath.Vector3f relativeEndingPosition)
          Draws a plain ISA relation to the specified relative position
private  javax.media.j3d.Appearance createLineAppearance()
          Metodhs that adjusts graphics setting for the appearance of the components and returns a proper appearance
private  javax.media.j3d.Appearance createRangeItemAppearance(javax.vecmath.Color3f itemColor)
           
private  javax.media.j3d.Appearance createRangeItemAppearance(javax.vecmath.Color3f itemColor, float transparence)
          Metodhs that adjusts graphics setting for the appearance of the components and returns a proper appearance
private  javax.media.j3d.BranchGroup createRelationBG()
          Creates a proper BranchGroup
private  javax.media.j3d.TransformGroup createRelationTG()
          Creates a proper TransformGroup
 javax.media.j3d.BranchGroup createRelationWithRange(RelationData rdata, javax.vecmath.Vector3f relativeRangePosition, LinkDirectionEnum direction)
          Creates a relation with an ending 3D icon that represents the range of the relation
 javax.media.j3d.BranchGroup createRelationWithRange(java.lang.String relation, NodeTypeAbstraction range, javax.vecmath.Vector3f relativeRangePosition, LinkDirectionEnum direction)
          Creates a relation with an ending 3D icon that represents the range of the relation
 javax.media.j3d.BranchGroup createRelationWithSetOfElements(java.lang.String relation, java.lang.String groupingID, java.util.HashSet<java.lang.String> ranges, javax.vecmath.Vector3f relativeRangePosition, LinkDirectionEnum direction, boolean isConcept)
          Creates a relation with an ending 3D icon that represents the Set of the ranges
 javax.media.j3d.BranchGroup createSelfLoopRelation(java.util.HashSet<RelationData> relations, float sourceSphereRadius, javax.vecmath.AxisAngle4f angle)
           
 javax.media.j3d.BranchGroup createSideRelations(java.util.Hashtable<java.lang.String,java.util.HashSet<NodeTypeAbstraction>> relationsNotOnScreen, javax.vecmath.Vector3f relativeRangePosition, LinkDirectionEnum direction)
          Creates a relation with an ending 3D icon that represents the Set of the ranges
 javax.media.j3d.BranchGroup createStraightRelation(java.util.HashSet<RelationData> relations, javax.vecmath.Vector3f relativeEndingPosition, float sourceSphereRadius, LinkDirectionEnum dir)
          It draws a plain (not an ISA) relation
private  javax.media.j3d.BranchGroup drawArrowedLine()
          Draws the line (cylinder + cone)
private  javax.media.j3d.BranchGroup drawArrowedLoop(javax.vecmath.AxisAngle4f angle)
           
private  javax.media.j3d.TransformGroup drawArrowHeadCone(javax.media.j3d.Transform3D where, java.util.HashSet<RelationData> relLabelSet)
           
private  javax.media.j3d.BranchGroup drawCurvedArrow(float scale)
           
private  javax.media.j3d.BranchGroup drawLabel(java.lang.String relationLabel)
          Creates a 3D label object
private  void drawRangeLabel(javax.media.j3d.TransformGroup tgx, java.lang.String rangeLAbel, javax.vecmath.Color3f rangeLabelColor)
           
private  javax.media.j3d.BranchGroup drawRelationWithNamedEntities(java.lang.String groupingID, java.util.HashSet<java.lang.String> ranges, boolean isConcept)
           
private  javax.media.j3d.BranchGroup drawRelationWithPlaceHolder(NodeTypeAbstraction myRange)
          Draws a relation (arrowed line) and an ending Pickable object
private  javax.media.j3d.BranchGroup drawRelationWithPlaceHolder(RelationData rdata)
           
static java.awt.Color getRelationColor(java.lang.String relationURI)
           
static void removeRelationColor(java.lang.String relationURI)
           
static void setColorToRelation(java.awt.Color c, java.lang.String relationURI)
           
 void setFullURI(java.lang.String fullURI)
           
 void setRelationType(GraphicalLinkTypeEnum relationType)
           
 void setTransparency(float transparency)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

black

private final javax.vecmath.Color3f black

coloredRelations

private static java.util.Hashtable<java.lang.String,java.awt.Color> coloredRelations

isCardinalityConstrained

private boolean isCardinalityConstrained

isDatatype

private boolean isDatatype

relationColor

private javax.vecmath.Color3f relationColor

relationDirection

private LinkDirectionEnum relationDirection

relationType

private GraphicalLinkTypeEnum relationType

relativeEndingOBJPosition

private javax.vecmath.Vector3f relativeEndingOBJPosition

setOfRelationData

private java.util.HashSet<RelationData> setOfRelationData

sourceElementSize

private float sourceElementSize

translationVector

private javax.vecmath.Vector3f translationVector

transparency

private float transparency

uriOfPickableEndingOBJ

private java.lang.String uriOfPickableEndingOBJ
Constructor Detail

Relation3DObject

public Relation3DObject()
Void constructor. It does notingh. To draw relation, one of the createRelation function must be used

Method Detail

addComplementOf

private void addComplementOf(javax.media.j3d.TransformGroup tgx)

addDataTypeRange

private void addDataTypeRange(javax.media.j3d.TransformGroup tgx)

addEnumerationRange

private void addEnumerationRange(javax.media.j3d.TransformGroup tgx)

addIntersectionRange

private void addIntersectionRange(javax.media.j3d.TransformGroup tgx)

addNamedConceptRange

private void addNamedConceptRange(javax.media.j3d.TransformGroup tgx)

addNamedIndividualRange

private void addNamedIndividualRange(javax.media.j3d.TransformGroup tgx)

addRestrictionRange

private void addRestrictionRange(javax.media.j3d.TransformGroup tgx)

addUnionRange

private void addUnionRange(javax.media.j3d.TransformGroup tgx)

computeConePositionScale

private float computeConePositionScale()
represents the position (between 0 origin and 1 end position) where the cone should be placed

Returns:
the correct scale for the cone in the different relations templates

computeOrientation

private javax.media.j3d.Transform3D computeOrientation(javax.vecmath.Vector3f finalPos,
                                                       float scale,
                                                       boolean invertDirection,
                                                       boolean isCone)

createArrowHeadAppearance

private javax.media.j3d.Appearance createArrowHeadAppearance(boolean isMultipleRelation)
Metodhs that adjusts graphics setting for the appearance of the components and returns a proper appearance

Returns:
the desired Appearance

createCurvedArrowRelation

public javax.media.j3d.BranchGroup createCurvedArrowRelation(java.util.HashSet<RelationData> relations,
                                                             javax.vecmath.Vector3f relativeEndingPosition,
                                                             float curvefactor,
                                                             LinkDirectionEnum dir)

createInstanceCurvedArrowRelation

public javax.media.j3d.BranchGroup createInstanceCurvedArrowRelation(java.util.Hashtable<java.lang.String,RelationType> relations,
                                                                     javax.vecmath.Vector3f relativeEndingPosition,
                                                                     float curvefactor,
                                                                     LinkDirectionEnum dir)

createInstanceSelfLoopRelation

public javax.media.j3d.BranchGroup createInstanceSelfLoopRelation(java.util.Hashtable<java.lang.String,RelationType> relations,
                                                                  float sourceSphereRadius,
                                                                  javax.vecmath.AxisAngle4f angle)

createInstanceStraightRelation

public javax.media.j3d.BranchGroup createInstanceStraightRelation(java.util.Hashtable<java.lang.String,RelationType> relations,
                                                                  javax.vecmath.Vector3f relativeEndingPosition,
                                                                  float sourceSphereRadius,
                                                                  LinkDirectionEnum dir)

createISARelation

public javax.media.j3d.BranchGroup createISARelation(javax.vecmath.Vector3f relativeEndingPosition)
Draws a plain ISA relation to the specified relative position

Parameters:
relativeEndingPosition - The position has to be equal to the difference between the parent and the son absolute positions
Returns:
a BranchGroup containing the relation line

createLineAppearance

private javax.media.j3d.Appearance createLineAppearance()
Metodhs that adjusts graphics setting for the appearance of the components and returns a proper appearance

Returns:
The desired Appearance

createRangeItemAppearance

private javax.media.j3d.Appearance createRangeItemAppearance(javax.vecmath.Color3f itemColor)

createRangeItemAppearance

private javax.media.j3d.Appearance createRangeItemAppearance(javax.vecmath.Color3f itemColor,
                                                             float transparence)
Metodhs that adjusts graphics setting for the appearance of the components and returns a proper appearance

Returns:
the desired Appearance

createRelationBG

private javax.media.j3d.BranchGroup createRelationBG()
Creates a proper BranchGroup

Returns:
a new BranchGroup

createRelationTG

private javax.media.j3d.TransformGroup createRelationTG()
Creates a proper TransformGroup

Returns:
a new TransformGroup

createRelationWithRange

public javax.media.j3d.BranchGroup createRelationWithRange(RelationData rdata,
                                                           javax.vecmath.Vector3f relativeRangePosition,
                                                           LinkDirectionEnum direction)
Creates a relation with an ending 3D icon that represents the range of the relation

Returns:
a BranchGroup containing the line and the 3d icon complete with labels

createRelationWithRange

public javax.media.j3d.BranchGroup createRelationWithRange(java.lang.String relation,
                                                           NodeTypeAbstraction range,
                                                           javax.vecmath.Vector3f relativeRangePosition,
                                                           LinkDirectionEnum direction)
Creates a relation with an ending 3D icon that represents the range of the relation

Parameters:
range - The set of range elements
relation - URI of the relation
relativeRangePosition - The position of the ending object
direction - The direction of the relation (Must be LinkTypeEnum.in or LinkTypeEnum.out)
Returns:
a BranchGroup containing the line and the 3d icon complete with labels

createRelationWithSetOfElements

public javax.media.j3d.BranchGroup createRelationWithSetOfElements(java.lang.String relation,
                                                                   java.lang.String groupingID,
                                                                   java.util.HashSet<java.lang.String> ranges,
                                                                   javax.vecmath.Vector3f relativeRangePosition,
                                                                   LinkDirectionEnum direction,
                                                                   boolean isConcept)
Creates a relation with an ending 3D icon that represents the Set of the ranges

Parameters:
ranges - The set of range elements
relation - URI of the relation
relativeRangePosition - The position of the ending object
direction - The direction of the relation (Must be LinkTypeEnum.in or LinkTypeEnum.out)
Returns:
a BranchGroup containing the line and the 3d icon complete with labels

createSelfLoopRelation

public javax.media.j3d.BranchGroup createSelfLoopRelation(java.util.HashSet<RelationData> relations,
                                                          float sourceSphereRadius,
                                                          javax.vecmath.AxisAngle4f angle)

createSideRelations

public javax.media.j3d.BranchGroup createSideRelations(java.util.Hashtable<java.lang.String,java.util.HashSet<NodeTypeAbstraction>> relationsNotOnScreen,
                                                       javax.vecmath.Vector3f relativeRangePosition,
                                                       LinkDirectionEnum direction)
Creates a relation with an ending 3D icon that represents the Set of the ranges

Returns:
a BranchGroup containing the line and the 3d icon complete with labels

createStraightRelation

public javax.media.j3d.BranchGroup createStraightRelation(java.util.HashSet<RelationData> relations,
                                                          javax.vecmath.Vector3f relativeEndingPosition,
                                                          float sourceSphereRadius,
                                                          LinkDirectionEnum dir)
It draws a plain (not an ISA) relation

Returns:
a BranchGroup containing the relation line

drawArrowedLine

private javax.media.j3d.BranchGroup drawArrowedLine()
Draws the line (cylinder + cone)

Returns:
a BranchGroup containing the line

drawArrowedLoop

private javax.media.j3d.BranchGroup drawArrowedLoop(javax.vecmath.AxisAngle4f angle)

drawArrowHeadCone

private javax.media.j3d.TransformGroup drawArrowHeadCone(javax.media.j3d.Transform3D where,
                                                         java.util.HashSet<RelationData> relLabelSet)

drawCurvedArrow

private javax.media.j3d.BranchGroup drawCurvedArrow(float scale)

drawLabel

private javax.media.j3d.BranchGroup drawLabel(java.lang.String relationLabel)
Creates a 3D label object

Parameters:
relationLabel - The label to draw
Returns:
a BranchGroup containing the 3D object containing the label

drawRangeLabel

private void drawRangeLabel(javax.media.j3d.TransformGroup tgx,
                            java.lang.String rangeLAbel,
                            javax.vecmath.Color3f rangeLabelColor)

drawRelationWithNamedEntities

private javax.media.j3d.BranchGroup drawRelationWithNamedEntities(java.lang.String groupingID,
                                                                  java.util.HashSet<java.lang.String> ranges,
                                                                  boolean isConcept)

drawRelationWithPlaceHolder

private javax.media.j3d.BranchGroup drawRelationWithPlaceHolder(NodeTypeAbstraction myRange)
Draws a relation (arrowed line) and an ending Pickable object

Returns:
a new BranchGroup containing the relation and the sphere

drawRelationWithPlaceHolder

private javax.media.j3d.BranchGroup drawRelationWithPlaceHolder(RelationData rdata)

getRelationColor

public static java.awt.Color getRelationColor(java.lang.String relationURI)

removeRelationColor

public static void removeRelationColor(java.lang.String relationURI)

setColorToRelation

public static void setColorToRelation(java.awt.Color c,
                                      java.lang.String relationURI)

setFullURI

public void setFullURI(java.lang.String fullURI)
Parameters:
fullURI - The fullURI to set.

setRelationType

public void setRelationType(GraphicalLinkTypeEnum relationType)

setTransparency

public void setTransparency(float transparency)
Parameters:
transparency - The transparency to set.