本文整理汇总了PHP中Line类的典型用法代码示例。如果您正苦于以下问题:PHP Line类的具体用法?PHP Line怎么用?PHP Line使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Line类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: isOverlap
/**
* Return true if the given line intersect/overlap
*
* @param Line $line
* @return bool
*/
public function isOverlap(Line $line)
{
$nvA = $this->getNormalVector();
$nvB = $line->getNormalVector();
// line equation 1
$a1 = $nvA->getX();
$b1 = $nvA->getY();
$c1 = $nvA->getX() * $this->a->getX() + $nvA->getY() * $this->a->getY();
// line equation 2
$a2 = $nvB->getX();
$b2 = $nvB->getY();
$c2 = $nvB->getX() * $line->a->getX() + $nvB->getY() * $line->a->getY();
// Calculation cheat: http://www.thelearningpoint.net/computer-science/c-program-solving-simultaneous-equations-in-two-variables
if ($a1 * $b2 - $a2 * $b1 != 0 && $b1 * $a2 - $b2 * $a1 != 0) {
// we have a unique solution
$x = ($c1 * $b2 - $c2 * $b1) / ($a1 * $b2 - $a2 * $b1);
$y = ($c1 * $a2 - $c2 * $a1) / ($b1 * $a2 - $b2 * $a1);
// they intersect so let's check if that intersection point is on the line section
return $this->hasPoint(new Point($x, $y));
} elseif ($a1 * $b2 - $a2 * $b1 == 0 && $b1 * $a2 - $b2 * $a1 == 0 && $c1 * $b2 - $c2 * $b1 == 0 && $c1 * $a2 - $c2 * $a1 == 0) {
// infinite solutions
return true;
}
// no solution: the lines don't intersect each other
return false;
}
开发者ID:janoist1,项目名称:battleships,代码行数:32,代码来源:Line.php
示例2: testFormat_returnsString_ifFormatIsText
/**
* format() should return string if format is html
*/
public function testFormat_returnsString_ifFormatIsText()
{
$word = new Line();
$expected = "\n";
$actual = $word->format('text');
$this->assertEquals($expected, $actual);
return;
}
开发者ID:jstewmc,项目名称:rtf,代码行数:11,代码来源:LineTest.php
示例3: validateLine
protected function validateLine($line)
{
if (!$line instanceof Line) {
$line = new Line((string) $line);
}
if ($line->getLength() != $this->getWidth()) {
throw new \InvalidArgumentException(sprintf('All lines in a batch file must be %d chars wide this line is %d chars wide.', $this->getWidth(), strlen($line)));
}
return $line;
}
开发者ID:SaveYa,项目名称:FixedWidth,代码行数:10,代码来源:AbstractFile.php
示例4: testDefine
/**
* @dataProvider dataProviderTestDefine
*/
public function testDefine($string, $isDefine, $getDefineKey, $getDefineWord)
{
$line = new Line($string);
$this->assertSame($isDefine, $line->isDefine());
$this->assertSame($getDefineKey, $line->getDefineKey());
if (is_null($getDefineWord)) {
$this->assertNull($line->getDefineWord());
} else {
$word = $line->getDefineWord();
$this->assertInstanceOf('\\Inml\\Text\\Word', $word);
$this->assertSame($getDefineWord, $word->getWord());
}
}
开发者ID:ptrofimov,项目名称:inml,代码行数:16,代码来源:LineTest.php
示例5: addToCart
function addToCart($itemId, $itemName, $qtty, $price, $itemCode, $remarks)
{
$cart = $_SESSION['cart'];
$line = new Line();
if (!isset($cart)) {
$line->addNewLine(1, $itemId, $itemName, $qtty, $price, $itemCode, $remarks);
$_SESSION['cart'][1] = $line;
return;
}
$pos = count($_SESSION['cart']) + 1;
$line->addNewLine($pos, $itemId, $itemName, $qtty, $price, $itemCode, $remarks);
$_SESSION['cart'][$pos] = $line;
return;
}
开发者ID:nitzanb,项目名称:letseat,代码行数:14,代码来源:cart.php
示例6: show
/**
* Show the prompt to user and return the answer.
*
* @return mixed
*/
public function show()
{
/**
* Ask for a number and validate it.
*/
do {
$valid = true;
$number = parent::show();
if ($number === "" && !$this->allowEmpty) {
$valid = false;
} elseif ($number === "") {
$number = null;
} elseif (!is_numeric($number)) {
$this->getConsole()->writeLine("{$number} is not a number\n");
$valid = false;
} elseif (!$this->allowFloat && round($number) != $number) {
$this->getConsole()->writeLine("Please enter a non-floating number, i.e. " . round($number) . "\n");
$valid = false;
} elseif ($this->max !== null && $number > $this->max) {
$this->getConsole()->writeLine("Please enter a number not greater than " . $this->max . "\n");
$valid = false;
} elseif ($this->min !== null && $number < $this->min) {
$this->getConsole()->writeLine("Please enter a number not smaller than " . $this->min . "\n");
$valid = false;
}
} while (!$valid);
/**
* Cast proper type
*/
if ($number !== null) {
$number = $this->allowFloat ? (double) $number : (int) $number;
}
return $this->lastResponse = $number;
}
开发者ID:idwsdta,项目名称:INIT-frame,代码行数:39,代码来源:Number.php
示例7: drawGraph
static function drawGraph($obj=NULL,$parent=NULL)
{
$link = $GLOBALS['GRAPHITE_URL'].'/render/?';
$lines = Line::findAll($obj->getGraphId());
foreach($lines as $line) {
$link .= 'target=';
$target = 'alias(' . $line->getTarget() . '%2C%22' . $line->getAlias() . '%22)';
if ($line->getColor() != '') {
$target = 'color(' . $target . '%2C%22' . $line->getColor() . '%22)';
}
$link .= $target .'&';
}
if (!is_null($parent)) {
$link .= 'width=' . $parent->getGraphWidth() .'&';
$link .= 'height=' . $parent->getGraphHeight() .'&';
if ($obj->getVtitle() != '') {
$link .= 'vtitle=' . $obj->getVtitle() .'&';
}
if ($obj->getName() != '') {
$link .= 'title=' . $obj->getName() .'&';
}
if ($obj->getArea() != 'none') {
$link .= 'areaMode=' . $obj->getArea() .'&';
}
if ($obj->getTime_Value() != '' && $obj->getUnit() != '') {
$link .= 'from=-' . $obj->getTime_Value() . $obj->getUnit() . '&';
}
if ($obj->getCustom_Opts() != '') {
$link .= $obj->getCustom_Opts() . '&';
}
}
return $link;
}
开发者ID:nleskiw,项目名称:Graphite-Tattle,代码行数:33,代码来源:Graph.php
示例8: addBuffer
/**
* @param LineBuffer $buffer
* @param int $indent
* @param string $firstPrefix
*/
public function addBuffer(LineBuffer $buffer, $indent = 0, $firstPrefix = '')
{
$first = true;
foreach ($buffer->getLines() as $line) {
$newline = null;
if ($first) {
$first = false;
$newline = new Line($line->hasMatched(), $firstPrefix . $line->getText(), $line->getMarker());
$newline->setExtraIndent(max(0, $indent - strlen($firstPrefix)));
} else {
$newline = $line;
$newline->setExtraIndent($indent);
}
$this->lines[] = $newline;
}
}
开发者ID:robteifi,项目名称:differencer,代码行数:21,代码来源:LineBuffer.php
示例9: merge
/**
* @inheritDoc
*/
public function merge($base, $remote, $local)
{
// Skip merging if there is nothing to do.
if ($merged = PhpMergeBase::simpleMerge($base, $remote, $local)) {
return $merged;
}
// First try the built in xdiff_string_merge3.
$merged = xdiff_string_merge3($base, $remote, $local, $error);
// if ($error) {
// // Try it the other way around.
// $error = null;
// $merged = xdiff_string_merge3($base, $local, $remote, $error);
// }
if ($error) {
// So there might be a merge conflict.
$baseLines = $this->base = Line::createArray(array_map(function ($l) {
return [$l, 0];
}, explode("\n", $base)));
// Get patch strings and transform them to Hunks.
$remotePatch = xdiff_string_diff($base, $remote, 0);
$localPatch = xdiff_string_diff($base, $local, 0);
// Note that patching $remote with $localPatch will work only in
// some cases because xdiff patches differently than git and will
// apply the same change twice.
$remote_hunks = self::interpretDiff($remotePatch);
$local_hunks = self::interpretDiff($localPatch);
// Merge Hunks and detect conflicts the same way PhpMerge does.
$conflicts = [];
$merged = PhpMerge::mergeHunks($baseLines, $remote_hunks, $local_hunks, $conflicts);
if ($conflicts) {
throw new MergeException('A merge conflict has occured.', $conflicts, $merged);
}
}
return $merged;
}
开发者ID:bircher,项目名称:php-merge,代码行数:38,代码来源:XdiffMerge.php
示例10: tokenize
/**
* Tokenize a line
*
* @param net.daringfireball.markdown.Line $l The line
* @param net.daringfireball.markdown.Node $target The target node to add nodes to
* @return net.daringfireball.markdown.Node The target
*/
public function tokenize(Line $line, Node $target)
{
$safe = 0;
$l = $line->length();
while ($line->pos() < $l) {
$t = '';
$c = $line->chr();
if ('\\' === $c) {
$t = $line[$line->pos() + 1];
$line->forward(2);
// Skip escape, don't tokenize next character
} else {
if (isset($this->tokens[$c])) {
if (!$this->tokens[$c]($line, $target, $this)) {
$t = $c;
// Push back
$line->forward();
}
}
}
// Optimization: Do not create empty text nodes
if ('' !== ($t .= $line->until($this->span))) {
$target->add(new Text($t));
}
if ($safe++ > $l) {
throw new \lang\IllegalStateException('Endless loop detected');
}
}
return $target;
}
开发者ID:xp-forge,项目名称:markdown,代码行数:37,代码来源:Context.class.php
示例11: CheckIsAllWordsRepeateableAtLines
/**
* checks is word repeatable at different lines
* @param Line $line - each line object
* @return boolean
*/
private function CheckIsAllWordsRepeateableAtLines(Line $line)
{
$temp_words = array();
foreach ($this->repeatableWordsInfo as $key => $value) {
$temp_words[] = $key;
}
$flag = 0;
$amount = count($temp_words);
foreach ($line->GetRepeatableWords() as $word) {
foreach ($temp_words as $item) {
if ($item == $word->GetContent()) {
$flag++;
}
}
}
if ($flag != $amount) {
return false;
} else {
return true;
}
}
开发者ID:AlexandrKozyr,项目名称:plariummorphy,代码行数:26,代码来源:TextAnalizator.class.php
示例12: __construct
/**
* Constructor
*
* @param string $string String to parse
*/
public function __construct($string)
{
$this->rawString = $string;
$parts = explode(Line::SEPARATOR, $string);
foreach ($parts as $item) {
$line = new Line($item);
if ($line->isStyle()) {
$this->styles = array_merge($this->styles, $line->getStyles());
} elseif ($line->isDefine()) {
$this->defines[$line->getDefineKey()] = $line->getDefineWord();
} elseif (!$line->isEmpty()) {
$this->lines[] = $line;
}
}
}
开发者ID:ptrofimov,项目名称:inml,代码行数:20,代码来源:Paragraph.php
示例13: cloneLine
public static function cloneLine($line_id, $ignore_clone_name = FALSE, $graph_id = NULL)
{
$line_to_clone = new Line($line_id);
if (empty($graph_id)) {
$graph_id = $line_to_clone->getGraphId();
}
$line = new Line();
if ($ignore_clone_name) {
$clone_alias = $line_to_clone->getAlias();
} else {
$clone_alias = 'Clone of ' . $line_to_clone->getAlias();
// If it's too long, we truncate
if (strlen($clone_alias) > 255) {
$clone_alias = substr($clone_alias, 0, 255);
}
}
$line->setAlias($clone_alias);
$line->setTarget($line_to_clone->getTarget());
$line->setColor($line_to_clone->getColor());
$line->setGraphId($graph_id);
$line->setWeight($line_to_clone->getWeight());
$line->store();
}
开发者ID:nagyist,项目名称:Tattle,代码行数:23,代码来源:Line.php
示例14: getLegendLineStyle
/**
* Get the line type
*
* @return NULL
*/
function getLegendLineStyle()
{
return $this->line->getStyle();
}
开发者ID:ber5ien,项目名称:www.jade-palace.co.uk,代码行数:9,代码来源:MathPlot.class.php
示例15: drawFilledTriangleHorizontally
private function drawFilledTriangleHorizontally(awGradient $gradient, awPolygon $polygon)
{
list($xMin, $xMax) = $polygon->getBoxXRange();
$this->init($gradient, $xMax - $xMin);
// Get the triangle line we will draw our lines from
$fromLine = NULL;
$lines = $polygon->getLines();
$count = count($lines);
// Pick the side of the triangle going all the way
// from the left side to the right side of the surrounding box
for ($i = 0; $i < $count; $i++) {
if ($lines[$i]->isLeftToRight($polygon)) {
list($fromLine) = array_splice($lines, $i, 1);
break;
}
}
// If for some reason the three points are aligned,
// $fromLine will still be NULL
if ($fromLine === NULL) {
return;
}
$fillLine = NULL;
for ($x = round($xMin); $x < round($xMax); $x++) {
$fromY = floor($fromLine->getYFrom($x));
$toY = array();
foreach ($lines as $line) {
$yValue = $line->getYFrom($x);
if (!is_null($yValue)) {
$toY[] = floor($yValue);
}
}
if (count($toY) === 1) {
$fillLine = new Line(new Point($x, $fromY), new Point($x, $toY[0]));
} else {
$line1 = new Line(new Point($x, $fromY), new Point($x, $toY[0]));
$line2 = new Line(new Point($x, $fromY), new Point($x, $toY[1]));
if ($line1->getSize() < $line2->getSize()) {
$fillLine = $line1;
} else {
$fillLine = $line2;
}
}
$color = $this->color($x - $xMin);
if ($fillLine->isPoint()) {
$this->driver->point($color, $fillLine->p1);
} elseif ($fillLine->getSize() >= 1) {
$this->driver->line($color, $fillLine);
}
unset($color);
}
}
开发者ID:greench,项目名称:prestashop,代码行数:51,代码来源:gd.class.php
示例16: rectangle
/**
* Draw a colored rectangle
*
* @param $color Rectangle color
* @param $line Rectangle diagonale
* @param $p2
*/
function rectangle($color, $line)
{
list($p1, $p2) = $line->getLocation();
// Get Red, Green, Blue and Alpha values for the line
list($r, $g, $b, $a) = $this->getColor($color);
// Calculate the coordinates of the two other points of the rectangle
$p3 = new Point($p1->x, $p2->y);
$p4 = new Point($p2->x, $p1->y);
$side = new Line($p1, $p2);
// Draw the four sides of the rectangle, clockwise
if ($p1->x <= $p2->x and $p1->y <= $p2->y or $p1->x >= $p2->x and $p1->y >= $p2->y) {
$side->setLocation($p1, $p4);
$this->line($color, $side);
$side->setLocation($p4, $p2);
$this->line($color, $side);
$side->setLocation($p2, $p3);
$this->line($color, $side);
$side->setLocation($p3, $p1);
$this->line($color, $side);
} else {
$side->setLocation($p1, $p3);
$this->line($color, $side);
$side->setLocation($p3, $p2);
$this->line($color, $side);
$side->setLocation($p2, $p4);
$this->line($color, $side);
$side->setLocation($p4, $p1);
$this->line($color, $side);
}
}
开发者ID:rhertzog,项目名称:lcs,代码行数:37,代码来源:ming.class.php
示例17: postLineEdit
public function postLineEdit($LineId)
{
$rules = array('name' => 'required|min:2|unique:line,name,' . $LineId, 'code' => 'required|unique:line,code,' . $LineId);
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('branch/line-edit/' . $LineId)->withErrors($validator)->withInput();
}
$line = Line::find($LineId);
$line->name = Input::get('name');
$line->code = Input::get('code');
$line->save();
return Redirect::to('branch/line')->with('success', '线路更新成功!');
}
开发者ID:huanghua581,项目名称:erp,代码行数:13,代码来源:BranchController.php
示例18: createStandardRequest
function createStandardRequest($calc, $products, $sign = 1)
{
if (!class_exists('TaxServiceSoap')) {
require VMAVALARA_CLASS_PATH . DS . 'TaxServiceSoap.class.php';
}
if (!class_exists('DocumentType')) {
require VMAVALARA_CLASS_PATH . DS . 'DocumentType.class.php';
}
if (!class_exists('DetailLevel')) {
require VMAVALARA_CLASS_PATH . DS . 'DetailLevel.class.php';
}
if (!class_exists('Line')) {
require VMAVALARA_CLASS_PATH . DS . 'Line.class.php';
}
if (!class_exists('ServiceMode')) {
require VMAVALARA_CLASS_PATH . DS . 'ServiceMode.class.php';
}
if (!class_exists('Line')) {
require VMAVALARA_CLASS_PATH . DS . 'Line.class.php';
}
if (!class_exists('GetTaxRequest')) {
require VMAVALARA_CLASS_PATH . DS . 'GetTaxRequest.class.php';
}
if (!class_exists('GetTaxResult')) {
require VMAVALARA_CLASS_PATH . DS . 'GetTaxResult.class.php';
}
if (!class_exists('Address')) {
require VMAVALARA_CLASS_PATH . DS . 'Address.class.php';
}
if (is_object($calc)) {
$calc = get_object_vars($calc);
}
$request = new GetTaxRequest();
$origin = new Address();
//In Virtuemart we have not differenct warehouses, but we have a shipment address
//So when the vendor has a shipment address, we assume that it is his warehouse
//Later we can combine products with shipment addresses for different warehouse (yehye, future music)
//But for now we just use the BT address
if (!class_exists('VirtueMartModelVendor')) {
require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
}
$userId = VirtueMartModelVendor::getUserIdByVendorId($calc['virtuemart_vendor_id']);
$userModel = VmModel::getModel('user');
$virtuemart_userinfo_id = $userModel->getBTuserinfo_id($userId);
// this is needed to set the correct user id for the vendor when the user is logged
$userModel->getVendor($calc['virtuemart_vendor_id']);
$vendorFieldsArray = $userModel->getUserInfoInUserFields('mail', 'BT', $virtuemart_userinfo_id, FALSE, TRUE);
$vendorFields = $vendorFieldsArray[$virtuemart_userinfo_id];
$origin->setLine1($vendorFields['fields']['address_1']['value']);
$origin->setLine2($vendorFields['fields']['address_2']['value']);
$origin->setCity($vendorFields['fields']['city']['value']);
$origin->setCountry($vendorFields['fields']['virtuemart_country_id']['country_2_code']);
$origin->setRegion($vendorFields['fields']['virtuemart_state_id']['state_2_code']);
$origin->setPostalCode($vendorFields['fields']['zip']['value']);
$request->setOriginAddress($origin);
//Address
if (isset($this->addresses[0])) {
$destination = $this->addresses[0];
} else {
return FALSE;
}
if (!class_exists('calculationHelper')) {
require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
}
$calculator = calculationHelper::getInstance();
$request->setCurrencyCode($calculator->_currencyDisplay->_vendorCurrency_code_3);
//CurrencyCode
$request->setDestinationAddress($destination);
//Address
$request->setCompanyCode($calc['company_code']);
// Your Company Code From the Dashboard
$request->setDocDate(date('Y-m-d'));
//date, checked
$request->setCustomerCode(self::$vmadd['customer_number']);
//string Required
if (isset(self::$vmadd['tax_usage_type'])) {
$request->setCustomerUsageType(self::$vmadd['tax_usage_type']);
//string Entity Usage
}
if (isset(self::$vmadd['tax_exemption_number'])) {
$request->setExemptionNo(self::$vmadd['tax_exemption_number']);
//string if not using ECMS which keys on customer code
}
if (isset(self::$vmadd['taxOverride'])) {
$request->setTaxOverride(self::$vmadd['taxOverride']);
avadebug('I set tax override ', self::$vmadd['taxOverride']);
}
$setAllDiscounted = false;
if (isset($products['discountAmount'])) {
if (!empty($products['discountAmount'])) {
//$request->setDiscount($sign * $products['discountAmount'] * (-1)); //decimal
$request->setDiscount($sign * $products['discountAmount']);
//decimal
vmdebug('We sent as discount ' . $request->getDiscount());
$setAllDiscounted = true;
}
unset($products['discountAmount']);
}
$request->setDetailLevel('Tax');
//Summary or Document or Line or Tax or Diagnostic
//.........这里部分代码省略.........
开发者ID:sam-akopyan,项目名称:hamradio,代码行数:101,代码来源:avalara.php
示例19: _newLine
/**
* Makes a Line object from a product item object
*
* @param Mage_Sales_Model_Order_Invoice_Item|Mage_Sales_Model_Order_Creditmemo_Item $item
* @param bool $credit
* @return null
*/
protected function _newLine($item, $credit = false)
{
if ($this->isProductCalculated($item->getOrderItem())) {
return false;
}
if ($item->getQty() == 0) {
return false;
}
$line = new Line();
$storeId = $this->_retrieveStoreIdFromItem($item);
$price = $item->getBaseRowTotal();
if ($this->_getTaxDataHelper()->priceIncludesTax($storeId)) {
$line->setTaxIncluded(true);
$price = $item->getBaseRowTotalInclTax();
}
if ($this->_getTaxDataHelper()->applyTaxAfterDiscount($storeId)) {
$price -= $item->getBaseDiscountAmount();
}
if ($credit) {
//@startSkipCommitHooks
$price *= -1;
//@finishSkipCommitHooks
}
$line->setNo(count($this->_lines));
$line->setItemCode($this->_getCalculationHelper()->getItemCode($this->_getProductForItemCode($item), $storeId, $item));
$line->setDescription($item->getName());
$line->setQty($item->getQty());
$line->setAmount($price);
$line->setDiscounted((double) $item->getBaseDiscountAmount() && $this->_getTaxDataHelper()->applyTaxAfterDiscount($storeId));
$productData = $this->_getLineProductData($item, $storeId);
$line->setTaxCode($productData->getTaxCode());
$line->setRef1($productData->getRef1());
$line->setRef2($productData->getRef2());
$this->_lineToItemId[count($this->_lines)] = $item->getOrderItemId();
$this->_lines[] = $line;
}
开发者ID:onepica,项目名称:avatax,代码行数:43,代码来源:Invoice.php
示例20: addLine
/**
* @param Line $line
* @return VTrendLines
*/
public function addLine(Line $line)
{
$this->lines[] = $line->getXML();
return $this;
}
开发者ID:deoliveiralucas,项目名称:fusion-charts-api,代码行数:9,代码来源:VTrendLines.php
注:本文中的Line类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论