edu.upc.dama.dex.core
Interface Export


public interface Export

Export to external formats.

It is possible to export a Graph to a diferent fortmats. Nowadays, these are the available formats:

Next table shows which variables (marked as 'X') can be exported for each export type and the default value for each export variable.

YGRAPHML GRAPHVIZ GRAPHML DEFAULT VALUE
Node label X X null
Node shape X Export.NodeExport.Shape.BOX
Node color X 0xa5c3f6
Node label color X Color.BLACK
Node label font size X 10
Node width X 25
Node height X 25
Fit node size X true
Edge label X X null
Edge direction X Export.EdgeExport.Direction.DIRECTED
Edge color X Color.LIGHT_GRAY
Edge label color X Color.BLACK
Edge label font size X 10
Edge width X 5

Default export:

Example As an example, we show the code of the DefaultExport (the Export implementation which is used when the user do not implements any). In the example, default values are used for nodes and edges and overwrites the definition given for the types. In those cases, the label is set with the OID of the node or edge.
 
 
   private final class DefaultExport implements Export {

      private GraphExport gExp = new GraphExport();
 
      private NodeExport nExp = new NodeExport();

      private EdgeExport eExp = new EdgeExport();

      private Graph graph = null;

      public void prepare(Graph graph) {
          this.graph = graph;
      }

      public void release() {
      }

       public GraphExport getGraph() {
          gExp.setLabel(graph.getGraphPool().getAlias());
          return gExp;
      }

       public NodeExport getNodeType(int type) {
          return nExp;
      }
      
       public EdgeExport getEdgeType(int type) {
          return eExp;
      }
      
       public NodeExport getNode(long node) {
          nExp.setLabel("" + node);
          return nExp;
      }

       public EdgeExport getEdge(long edge) {
          eExp.setColor(Color.LIGHT_GRAY);
          eExp.setLabel("" + edge);
          int t = graph.getType(edge);
          if (graph.isEdgeTypeDirected(t)) {
              eExp.setDirection(EdgeExport.Direction.DIRECTED);
          } else {
              eExp.setDirection(EdgeExport.Direction.UNDIRECTED);
          }
          return eExp;
      }

      public boolean enableType(int type) {
          return true;
      }
  }
 
 
 

Author:
Sparsity Technologies

Nested Class Summary
static class Export.EdgeExport
          Stores edge exporting values.
static class Export.GraphExport
          Stores the graph exporting values.
static class Export.NodeExport
          Stores the node exporting values.
static class Export.Type
          Export type.
 
Method Summary
 boolean enableType(int type)
          Gets whether a node or edge type must be exported or not.
 Export.EdgeExport getEdge(long edge)
          Gets the edge export definition.
 Export.EdgeExport getEdgeType(int type)
          Gets the edge export definition of the type.
Export#getEdge(long) has more priority than this function.
Only if Export#getEdge(int) return null the Export.EdgeExport of this function is used.
 Export.GraphExport getGraph()
          Gets the graph export definition.
 Export.NodeExport getNode(long node)
          Gets the node export definition.
 Export.NodeExport getNodeType(int type)
          Gets the node export definition of the type.
Export#getNode(long) has more priority than this function.
Only if Export#getNode(long) return null the Export.NodeExport of this function is used.
 void prepare(Graph graph)
          Prepares the graph for the export process.
 void release()
          Ends the export process.
 

Method Detail

prepare

void prepare(Graph graph)
Prepares the graph for the export process.

It is called once before the export process.

Parameters:
graph - Graph to be exported.

release

void release()
Ends the export process.

It is called once after the export process.


getGraph

Export.GraphExport getGraph()
Gets the graph export definition.

Returns:
The Export.GraphExport which defines how to export the graph.

getNodeType

Export.NodeExport getNodeType(int type)
Gets the node export definition of the type.
Export#getNode(long) has more priority than this function.
Only if Export#getNode(long) return null the Export.NodeExport of this function is used.

Parameters:
type - Node type identifier
Returns:
The Export.NodeExport which defines how to export the nodes of the given type.

getEdgeType

Export.EdgeExport getEdgeType(int type)
Gets the edge export definition of the type.
Export#getEdge(long) has more priority than this function.
Only if Export#getEdge(int) return null the Export.EdgeExport of this function is used.

Parameters:
type - Edge type identifier
Returns:
The Export.EdgeExport which defines how to export the edges of the given type.

getNode

Export.NodeExport getNode(long node)
Gets the node export definition.

Parameters:
node - Node to be exported.
Returns:
The Export.NodeExport which defines how to export the node.

getEdge

Export.EdgeExport getEdge(long edge)
Gets the edge export definition.

Parameters:
edge - Edge to be exported.
Returns:
The Export.EdgeExport which defines how to export the edge.

enableType

boolean enableType(int type)
Gets whether a node or edge type must be exported or not.

Parameters:
type - Node or edge type.
Returns:
If true all objects of the given type will be exported, otherwise they will not be exported.