Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
JGraphX Swing Component - Java Graph Visualization Library
This is a binary & source redistribution of the original, unmodified JGraphX library originating from:
"http://downloads.jgraph.com/downloads/jgraphx/archive/jgraphx-2_0_0_1.zip".
The purpose of this redistribution is to make the library available to other Maven projects.
/**
* $Id: mxGdCodec.java,v 1.1 2010-08-25 08:36:59 gaudenz Exp $
* Copyright (c) 2010, Gaudenz Alder, David Benson
*/
package com.mxgraph.io;
import com.mxgraph.io.gd.mxGdDocument;
import com.mxgraph.io.gd.mxGdEdge;
import com.mxgraph.io.gd.mxGdNode;
import com.mxgraph.model.mxCell;
import com.mxgraph.model.mxGeometry;
import com.mxgraph.util.mxConstants;
import com.mxgraph.util.mxPoint;
import com.mxgraph.view.mxGraph;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Parses a GD .txt file and imports it in the given graph.
* This class depends from the classes contained in
* com.mxgraph.io.gd.
*/
public class mxGdCodec
{
/**
* Map with the vertex cells added in the addNode method.
*/
private static HashMap cellsMap = new HashMap();
/**
* Returns the coordinates of the left top corner of the node.
* @param node Node
* @return mxPoint that represent the coordinates.
*/
private static mxPoint getOriginPoint(mxGdNode node)
{
mxPoint coord = node.getCoordinates();
mxPoint dim = node.getDimentions();
double x = coord.getX() - dim.getX() / 2;
double y = coord.getY() - dim.getY() / 2;
return new mxPoint(x, y);
}
/**
* Adds a new vertex to the graph.
* @param graph Graph where the vertex is added.
* @param parent Parent of the vertex to add.
* @param node Node
* @return Returns the vertex added.
*/
private static mxCell addNode(mxGraph graph, Object parent, mxGdNode node)
{
mxPoint cordenates = getOriginPoint(node);
mxPoint dimentions = node.getDimentions();
//Set the node name as label.
String label = node.getName();
//Set the node name as ID.
String id = node.getName();
//Insert a new vertex in the graph
mxCell v1 = (mxCell) graph.insertVertex(parent, id, label,
cordenates.getX(), cordenates.getY(), dimentions.getX(),
dimentions.getY());
cellsMap.put(node.getName(), v1);
return v1;
}
/**
* Returns the string that represents the content of a given style map.
* @param styleMap Map with the styles values
* @return string that represents the style.
*/
private static String getStyleString(Map styleMap,
String asig)
{
String style = "";
Iterator