Permalink
Browse files

Some changes

- Modify Licence (MIT)
- Add Tests
  • Loading branch information...
1 parent bc6de4c commit a36175d1c87fa49b5db95102036ceb244a760e24 @nfabre committed Feb 25, 2011
View
@@ -8,15 +8,10 @@
<mkdir dir="${basedir}/build/code-browser"/>
<mkdir dir="${basedir}/build/coverage"/>
<mkdir dir="${basedir}/build/logs"/>
+ <mkdir dir="${basedir}/build/tmp"/>
<mkdir dir="${basedir}/build/pdepend"/>
</target>
- <target name="phpab">
- <exec executable="phpab">
- <arg line='-o PHPUnit/Extensions/SeleniumTestCase/Autoload.php -c -t PHPUnit/Extensions/SeleniumTestCase/Autoload.php.in --indent " " PHPUnit' />
- </exec>
- </target>
-
<!-- Run unit tests and generate junit.xml and clover.xml -->
<target name="phpunit">
<exec executable="phpunit" failonerror="true"/>
@@ -1,38 +1,15 @@
<?php
-namespace Deepzoom;
-/**
-* Deep Zoom Tools
-*
-* Copyright (c) 2008-2010, OpenZoom <http://openzoom.org/>
-* Copyright (c) 2008-2010, Nicolas Fabre <nicolas.fabre@gmail.com>
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without modification,
-* are permitted provided that the following conditions are met:
-*
-* 1. Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-*
-* 2. Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-*
-* 3. Neither the name of OpenZoom nor the names of its contributors may be used
-* to endorse or promote products derived from this software without
-* specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+/*
+ * This file is part of the Deepzoom.php package.
+ *
+ * (c) Nicolas Fabre <nicolas.fabre@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Deepzoom;
/**
* Image Creator, generate pyramid
@@ -72,18 +49,4 @@ protected function _clamp($val, $min, $max) {
}
return $val;
}
-
- /**
- * Create directory if not exist
- *
- * @param string $pathname
- *
- * @return string
- */
- protected function _ensure($pathname) {
- if(!file_exists($pathname)) {
- mkdir($pathname, 0775, true);
- }
- return $pathname;
- }
}
@@ -1,42 +1,19 @@
<?php
+
+/*
+ * This file is part of the Deepzoom.php package.
+ *
+ * (c) Nicolas Fabre <nicolas.fabre@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
namespace Deepzoom;
use Deepzoom\StreamWrapper\StreamWrapperInterface;
/**
-* Deep Zoom Tools
-*
-* Copyright (c) 2008-2010, OpenZoom <http://openzoom.org/>
-* Copyright (c) 2008-2010, Nicolas Fabre <nicolas.fabre@gmail.com>
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without modification,
-* are permitted provided that the following conditions are met:
-*
-* 1. Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-*
-* 2. Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-*
-* 3. Neither the name of OpenZoom nor the names of its contributors may be used
-* to endorse or promote products derived from this software without
-* specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/**
* Descriptor
*
* @package Deepzoom
@@ -124,17 +101,22 @@ public function __construct(StreamWrapperInterface $streamWrapper,$width=null,$h
* @param string $source
*
* @return Deepzoom\Descriptor Fluent interface
- * @throw Deepzoom\Exception check pyramid level
+ * @throw InvalidArgumentExceptioncheck pyramid level
*/
public function open($source) {
if($this->_streamWrapper->exists($source)) {
- $xml = simplexml_load_string($this->_streamWrapper->getContents($source));
- $this->_width = (int)$xml->Size["Width"];
- $this->_height = (int)$xml->Size["Height"];
- $this->_tileSize = (int)$xml["TileSize"];
- $this->_tileOverlap = (int)$xml["Overlap"];
- $this->_tileFormat = (string)$xml["Format"];
- } else throw new Exception('File not found : '.$source);
+ /**
+ * @var $xml SimpleXMLElement
+ */
+ $xml = simplexml_load_string($this->_streamWrapper->getContents($source),null,LIBXML_NOERROR);
+ if($xml !== false) {
+ $this->_width = (int)$xml->Size["Width"];
+ $this->_height = (int)$xml->Size["Height"];
+ $this->_tileSize = (int)$xml["TileSize"];
+ $this->_tileOverlap = (int)$xml["Overlap"];
+ $this->_tileFormat = (string)$xml["Format"];
+ } else throw new Exception('Invalid Xml');
+ } else throw new \InvalidArgumentException('File not found : '.$source);
return $this;
}
@@ -181,22 +163,22 @@ public function getNumLevels() {
*
* @param int $level
* @return float
- * @throw Deepzoom\Exception check pyramid level
+ * @throw InvalidArgumentExceptioncheck pyramid level
*/
public function getScale($level) {
if(0 <= $level && $level < $this->getNumLevels()) {
$maxLevel = $this->getNumLevels() - 1 ;
return pow(0.5,$maxLevel - $level);
- } else throw new Exception("Invalid pyramid level (scale)");
+ } else throw new \InvalidArgumentException("Invalid pyramid level (scale)");
}
/**
* Dimensions of level (width, height)
*
* @param int $level
* @return array
- * @throw Deepzoom\Exception check pyramid level
+ * @throw InvalidArgumentExceptioncheck pyramid level
*/
public function getDimension($level) {
$key = $this->getDimensionKey($level);
@@ -206,7 +188,7 @@ public function getDimension($level) {
$width = (int)ceil($this->_width * $scale);
$height = (int)ceil($this->_height * $scale);
$this->_dimensions[$key] = array('width' => $width,'height' => $height);
- } else throw new Exception("Invalid pyramid level (dimension)");
+ } else throw new \InvalidArgumentException("Invalid pyramid level (dimension)");
}
return $this->_dimensions[$key];
@@ -217,7 +199,7 @@ public function getDimension($level) {
*
* @param int $level
* @return array
- * @throw Deepzoom\Exception check pyramid level
+ * @throw InvalidArgumentExceptioncheck pyramid level
*/
public function getNumTiles($level) {
if(0 <= $level and $level < $this->getNumLevels()) {
@@ -226,7 +208,7 @@ public function getNumTiles($level) {
$rows = (int)ceil(floatval($dimension['height']) / $this->_tileSize);
return array('columns' => $columns, 'rows' => $rows);
- } else throw new Exception("Invalid pyramid level (NumTiles)");
+ } else throw new \InvalidArgumentException("Invalid pyramid level (NumTiles)");
}
/**
@@ -237,7 +219,7 @@ public function getNumTiles($level) {
* @param int $row
*
* @return array (x,y,width,height)
- * @throw Deepzoom\Exception check pyramid level
+ * @throw InvalidArgumentExceptioncheck pyramid level
*/
public function getTileBounds($level, $column, $row) {
if(0 <= $level and $level < $this->getNumLevels()) {
@@ -250,7 +232,7 @@ public function getTileBounds($level, $column, $row) {
$newHeight = min($height, $dimension['height'] - $position['y']);
return array_merge($position,array( 'width' => $newWidth,'height' => $newHeight));
- } else throw new Exception("Invalid pyramid level (TileBounds)");
+ } else throw new \InvalidArgumentException("Invalid pyramid level (TileBounds)");
}
/**
@@ -1,38 +1,15 @@
<?php
-namespace Deepzoom;
-/**
-* Deep Zoom Tools
-*
-* Copyright (c) 2008-2010, OpenZoom <http://openzoom.org/>
-* Copyright (c) 2008-2010, Nicolas Fabre <nicolas.fabre@gmail.com>
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without modification,
-* are permitted provided that the following conditions are met:
-*
-* 1. Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-*
-* 2. Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-*
-* 3. Neither the name of OpenZoom nor the names of its contributors may be used
-* to endorse or promote products derived from this software without
-* specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+/*
+ * This file is part of the Deepzoom.php package.
+ *
+ * (c) Nicolas Fabre <nicolas.fabre@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Deepzoom;
/**
* Descriptor Interface
View
@@ -1,38 +1,15 @@
<?php
-namespace Deepzoom;
-/**
-* Deep Zoom Tools
-*
-* Copyright (c) 2008-2010, OpenZoom <http://openzoom.org/>
-* Copyright (c) 2008-2010, Nicolas Fabre <nicolas.fabre@gmail.com>
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without modification,
-* are permitted provided that the following conditions are met:
-*
-* 1. Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-*
-* 2. Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-*
-* 3. Neither the name of OpenZoom nor the names of its contributors may be used
-* to endorse or promote products derived from this software without
-* specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+/*
+ * This file is part of the Deepzoom.php package.
+ *
+ * (c) Nicolas Fabre <nicolas.fabre@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Deepzoom;
/**
* Exception
Oops, something went wrong.

0 comments on commit a36175d

Please sign in to comment.