function showUmlImage($json) { $title = "View As UML Image"; $icon = "png.png"; ?> <html> <head> <title> <?php echo $title; ?> </title> <link rel="shortcut icon" href=<?php echo $icon; ?> type="image/x-icon" /> </head> </html> <?php header("Content-type: image/png"); require_once "canvas.php"; $canvas = new Canvas(950, 350); $diagram = $canvas->createDiagram(); $classIds = array(); foreach ($json->umpleClasses as $umpleClass) { $umplePosition = $umpleClass->position; $classEntity = new ClassEntity($umpleClass->name, new Position($umplePosition->x, $umplePosition->y, $umplePosition->width, $umplePosition->height)); $classIds[$umpleClass->id] = $classEntity; $classEntity->draw($diagram); } foreach ($json->umpleAssociations as $umpleAssociation) { $classEntity1 = $classIds[$umpleAssociation->classOneId]; $classEntity2 = $classIds[$umpleAssociation->classTwoId]; $mult1 = new MultiplicityEnd($classEntity1); $mult2 = new MultiplicityEnd($classEntity2); $association = new Association($mult1, $mult2); $c1Position = $classEntity1->getPosition(); $c1Offset = $umpleAssociation->offsetOnePosition; $c2Position = $classEntity2->getPosition(); $c2Offset = $umpleAssociation->offsetTwoPosition; $p1 = new Point($c1Position->getX() + $c1Offset->x, $c1Position->getY() + $c1Offset->y); $p2 = new Point($c2Position->getX() + $c2Offset->x, $c2Position->getY() + $c2Offset->y); $association->addConnector($p1); $association->addConnector($p2); $association->draw($diagram); } ImagePng($diagram); ImageDestroy($diagram); }