Exemplo n.º 1
0
 /**
  * Constructor of an dia object
  *
  * @param   string type
  * @param   string version default NULL
  * @param   string id default NULL
  * @throws  lang.IllegalArgumentException
  */
 public function __construct($type, $version = NULL, $id = NULL)
 {
     if (!isset($type)) {
         throw new IllegalArgumentException('Parameter "type" is required!');
     }
     $this->setNodeType($type);
     if (isset($version)) {
         $this->setVersion($version);
     }
     // set ID or get a new unique ID
     if (isset($id)) {
         $this->setId($id);
     } else {
         $this->setId(DiaDiagram::getId());
     }
     $this->initialize();
 }
Exemplo n.º 2
0
<?php

/* TEST script: 
 * - unmarshal diagram
 * 
 *
 */
require 'lang.base.php';
uses('util.cmd.Console', 'io.File', 'io.ZipFile', 'xml.dom.Document', 'org.dia.DiaDiagram', 'org.dia.DiaText', 'org.dia.DiaMarshaller', 'org.dia.DiaUnmarshaller');
// create new empty diagram:
$Dia = new DiaDiagram();
$BgLayer = $Dia->getChild('Background');
$BgLayer->addObject(new DiaText());
Console::writeLine($Dia->getSource());
exit(0);
//$Dia= &DiaMarshaller::marshal(array('object.TdocVertrag'), $recurse= 1, $depend= FALSE);
//print($Dia->getSource());
// read an existing diagram
$file = getcwd() . '/test-read.dia';
Console::writeLine("Using file: {$file}");
DiaUnmarshaller::unmarshal($file, array('org.dia.DiaDiagram', 'lang.Object'));
// try opening (zipped) file
// hint: ZipFile also handles unzipped files...
/*  try (); {
    $dia_file= &new ZipFile($file) &&
    $dia_file->open(FILE_MODE_READ);
  } if (catch('Exception', $e)) {
    $e->printStackTrace();
    exit(-1);
  }