You are here

function pSpring::addNode in Visitors 7

Same name and namespace in other branches
  1. 7.2 pChart/class/pSpring.class.php \pSpring::addNode()

File

pChart/class/pSpring.class.php, line 161

Class

pSpring

Code

function addNode($NodeID, $Settings = "") {

  /* if the node already exists, ignore */
  if (isset($this->Data[$NodeID])) {
    return 0;
  }
  $Name = isset($Settings["Name"]) ? $Settings["Name"] : "Node " . $NodeID;
  $Connections = isset($Settings["Connections"]) ? $Settings["Connections"] : NULL;
  $R = isset($Settings["R"]) ? $Settings["R"] : $this->Default["R"];
  $G = isset($Settings["G"]) ? $Settings["G"] : $this->Default["G"];
  $B = isset($Settings["B"]) ? $Settings["B"] : $this->Default["B"];
  $Alpha = isset($Settings["Alpha"]) ? $Settings["Alpha"] : $this->Default["Alpha"];
  $BorderR = isset($Settings["BorderR"]) ? $Settings["BorderR"] : $this->Default["BorderR"];
  $BorderG = isset($Settings["BorderG"]) ? $Settings["BorderG"] : $this->Default["BorderG"];
  $BorderB = isset($Settings["BorderB"]) ? $Settings["BorderB"] : $this->Default["BorderB"];
  $BorderAlpha = isset($Settings["BorderAlpha"]) ? $Settings["BorderAlpha"] : $this->Default["BorderAlpha"];
  $Surrounding = isset($Settings["Surrounding"]) ? $Settings["Surrounding"] : $this->Default["Surrounding"];
  $BackgroundR = isset($Settings["BackgroundR"]) ? $Settings["BackgroundR"] : $this->Default["BackgroundR"];
  $BackgroundG = isset($Settings["BackgroundG"]) ? $Settings["BackgroundG"] : $this->Default["BackgroundG"];
  $BackgroundB = isset($Settings["BackgroundB"]) ? $Settings["BackgroundB"] : $this->Default["BackgroundB"];
  $BackgroundAlpha = isset($Settings["BackgroundAlpha"]) ? $Settings["BackgroundAlpha"] : $this->Default["BackgroundAlpha"];
  $Force = isset($Settings["Force"]) ? $Settings["Force"] : $this->Default["Force"];
  $NodeType = isset($Settings["NodeType"]) ? $Settings["NodeType"] : $this->Default["NodeType"];
  $Size = isset($Settings["Size"]) ? $Settings["Size"] : $this->Default["Size"];
  $Shape = isset($Settings["Shape"]) ? $Settings["Shape"] : $this->Default["Shape"];
  $FreeZone = isset($Settings["FreeZone"]) ? $Settings["FreeZone"] : $this->Default["FreeZone"];
  if ($Surrounding != NULL) {
    $BorderR = $R + $Surrounding;
    $BorderG = $G + $Surrounding;
    $BorderB = $B + $Surrounding;
  }
  $this->Data[$NodeID]["R"] = $R;
  $this->Data[$NodeID]["G"] = $G;
  $this->Data[$NodeID]["B"] = $B;
  $this->Data[$NodeID]["Alpha"] = $Alpha;
  $this->Data[$NodeID]["BorderR"] = $BorderR;
  $this->Data[$NodeID]["BorderG"] = $BorderG;
  $this->Data[$NodeID]["BorderB"] = $BorderB;
  $this->Data[$NodeID]["BorderAlpha"] = $BorderAlpha;
  $this->Data[$NodeID]["BackgroundR"] = $BackgroundR;
  $this->Data[$NodeID]["BackgroundG"] = $BackgroundG;
  $this->Data[$NodeID]["BackgroundB"] = $BackgroundB;
  $this->Data[$NodeID]["BackgroundAlpha"] = $BackgroundAlpha;
  $this->Data[$NodeID]["Name"] = $Name;
  $this->Data[$NodeID]["Force"] = $Force;
  $this->Data[$NodeID]["Type"] = $NodeType;
  $this->Data[$NodeID]["Size"] = $Size;
  $this->Data[$NodeID]["Shape"] = $Shape;
  $this->Data[$NodeID]["FreeZone"] = $FreeZone;
  if ($Connections != NULL) {
    if (is_array($Connections)) {
      foreach ($Connections as $Key => $Value) {
        $this->Data[$NodeID]["Connections"][] = $Value;
      }
    }
    else {
      $this->Data[$NodeID]["Connections"][] = $Connections;
    }
  }
}