Exemplo n.º 1
0
/**
 * Function: main
 * 
 * Reads a graph view XML file and creates HTML on the fly,
 * ie. without creating a graph and model for it.
 */
function main()
{
    // Reads the XML representation of a graph_view_! If you need to
    // create an image for a graph_model_ then use the following code:
    //
    // $doc = mxUtils::parseXml($xml);
    // $dec = new mxCodec($doc);
    // $dec->decode($doc->documentElement, $graph->getModel());
    //
    // $image = $graph->createImage(null, "#FFFFFF");
    $filename = "diagrams/graphview.xml";
    //echo mxGraphViewHtmlReader::convertFile($filename);
    // Creates a PNG representation of the file
    $image = mxGraphViewImageReader::convertFile($filename, "#FFFFFF");
    // Creates an interlaced image for better loading in the browser
    //imageInterlace($image, 1);
    // Marks background color as being transparent
    //imageColorTransparent($image, imageColorAllocate($image, 255, 255, 255));
    header("Content-Type: image/png");
    echo mxUtils::encodeImage($image);
}
Exemplo n.º 2
0
    $xml = addslashes(htmlentities(str_replace("\n", "
", $xmlNode->ownerDocument->saveXML($xmlNode))));
    // Loads the template into a single string
    $template = mxUtils::readFile("template.html");
    // Replaces the placeholder in the template with the XML data
    // which is then parsed into the graph model. Note: In a production
    // environment you should use a template engine instead.
    $page = str_replace("%graph%", $xml, $template);
    // Makes sure there is no caching on the client side
    header("Pragma: no-cache");
    // HTTP 1.0
    header("Cache-control: private, no-cache, no-store");
    header("Expires: 0");
    echo $page;
}
// Uses a local font so that all examples work on all platforms. This can be
// changed to vera on Mac or arial on Windows systems.
mxConstants::$DEFAULT_FONTFAMILY = "ttf/verah.ttf";
// If you can't get the fonts to render try using one of the following:
//mxConstants::$DEFAULT_FONTFAMILY = "C:\WINDOWS\Fonts\arial.ttf";
//mxConstants::$DEFAULT_FONTFAMILY = "verah"; putenv("GDFONTPATH=".realpath("./ttf"));
//mxConstants::$TTF_ENABLED = false;
// Handles save image request
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $xml = urldecode($_POST["xml"]);
    // Creates a PNG representation of the file
    $image = mxGraphViewImageReader::convert($xml, "#FFFFFF");
    header("Content-Type: image/png");
    echo mxUtils::encodeImage($image);
} else {
    main();
}
 /**
  * Function: convertFile
  *
  * Creates the image for the given display XML file.
  */
 static function convertFile($filename, $background = null)
 {
     $viewReader = new mxGraphViewImageReader($background);
     $viewReader->readFile($filename);
     $image = $viewReader->canvas->getImage();
     return $image;
 }
Exemplo n.º 4
0
 /**
  * Class: mxGraphViewHtmlReader
  *
  * A display XML to HTML converter. This allows to create an image of a graph
  * without having to parse and create the graph model using the XML file
  * created for the mxGraphView object in the thin client.
  * 
  * Constructor: mxGraphViewHtmlReader
  *
  * Constructs a new HTML graph view reader.
  */
 function mxGraphViewHtmlReader()
 {
     parent::mxGraphViewImageReader();
 }