text:
//networkChart.js

class networkChart {

  /**
   * Constructor for network chart
   * @param   data network data, including links and nodes.
   */
  constructor (data) {
      //403 node, 19488 links

      this.networkData = data;
      this.threshold = 15;
      this.nodes = this.networkData.nodes;
      this.initlinksData = this.networkData.links.filter((d)=>{
            return +d['value'] > this.threshold;
          })
      let targets = this.initlinksData.map((d)=>{
              return d.target;
            })
      let sources = this.initlinksData.map((d)=>{
              return d.source;
            })

      this.tagMap = new Map();

      this.initnodesData = this.networkData.nodes
              .filter((d)=>{
                this.tagMap.set(d.tag,d.groupid);
                return  targets.includes(d.tag) || sources.includes(d.tag);
              });

      this.margin = {top: 10, right: 20, bottom: 30, left: 20};
      let divnwChart = d3.select("#networkChart").classed("content", true);

      //fetch the svg bounds
      this.svgBounds = divnwChart.node().getBoundingClientRect();
      this.svgWidth = this.svgBounds.width - this.margin.left - this.margin.right;
      this.svgHeight = 600;

      //add the svg to the div
      this.svg = divnwChart.append("svg")
          .attr("width", this.svgWidth)
          .attr("height", this.svgHeight);

      //border of svg
      let border = this.svg.append("rect")
          .attr("x", 0)
          .attr("y", 0)
          .attr("height", this.svgHeight)
          .attr("width", this.svgWidth)
          //.style("stroke", 'Gray')
          .style("opacity", 0.8)
          .style("fill", "none")
          //.style("stroke-width", '3px');

      this.gAll = this.svg.append("g");
      this.gAll.attr("class", "everything");

      this.gAll.append("g")
        .attr("class", "links");
      this.gAll.append("g")
        .attr("class", "nodes");

      this.colorScale = d3.scaleOrdinal() //ten colors
                .domain(d3.range(0,9))
                .range(['#1f77b4','#d448ce','#edaf6d','#f492a8','#965628','#3e8934','#21c2ce','#070cc2','#70c32a','#e9272a']);
                //[blue, Magenta, olive, Teal, brown, dark green, purple, Navy, green, Red]21c2ce
      let max_r = d3.scaleLinear()
      .domain([350,920])
      .range([30, 58])(this.svgWidth);

      this.rScale = d3.scaleLinear()
      .domain([1,203])
      .range([5, 35]);

      this.circletip;

      this.switch = true;

      this.linksData;
      this.nodesData;
      this.threshold = 15;
      this.selectedTag = null;

      this.defaultForce = d3.scaleLinear()
      .domain([350,920])
      .range([-50, -100])(this.svgWidth);

      //console.log('defaultForce: '+this.defaultForce);
      this.forceParam = this.defaultForce;
      this.selectedYear = 0;

      let liall = d3.select('#YearSelection').selectAll('li').on('click',(d,i,object)=>{
          this.selectedYear = d3.select(object[i]).text();
          //console.log(this.selectedYear)
          d3.select('#showYear').text(this.selectedYear);
          if(this.selectedYear=='All')
            this.selectedYear = 0;
          this.selectYear();
      });
      //console.log('YearSelection li : ' + liall);
      this.resetData();

  };
  /**
   * [selectYear description]
   * @return {[type]} [description]
   */
  selectYear(){
    if(this.selectedTag == null){
      this.resetData();
      this.update();
    }
    else{
      this.selectOneNode(this.selectedTag,true);
    }
    //console.log('selected year: ' +year);
  }
  /**
   * Set data to the initial state, display links whose value are bigger than threshold
   * @return void call update in the end of function
   */
  resetData(){
     //this.selectedYear==0;
     d3.select('#showYear').text('All');
     d3.select('#yearbutton').classed('yearbutton',true);
     this.linksData = this.initlinksData;
     this.nodesData = this.initnodesData;
    /*
    else{
      let newlinksdata = this.networkData.links.reduce((filtered,d)=>{
              let v;
              let linkvalue = +d['year'][+this.selectedYear - 2001][this.selectedYear];

                v= {
                  "source":d.target,
                  "target":d.source,
                  "value":linkvalue
                }

              if(linkvalue>this.threshold && v!=undefined)
                filtered.push(v);
              return filtered;
            },[])
      this.linksData = newlinksdata;
      let targets = this.linksData.map((d)=>{
              return d.target;
            })
      let sources = this.linksData.map((d)=>{
              return d.source;
            })
      this.nodesData = this.networkData.nodes
              .filter((d)=>{
                return  targets.includes(d.tag) || sources.includes(d.tag);
              });
    }*/
  }
  /**
   * find data which are related to the selected tag.
   * @param  string tagName selected tag
   * @return void
   */
  //selectOneNode(tagName,x,y){
  selectOneNode(tagName,yearchange){
    if(this.selectedTag == tagName && yearchange==false){
      this.selectedTag = null;
      this.threshold = 15;
      this.forceParam = this.defaultForce;
      this.selectedYear = 0;

      this.switch = true;
      this.resetData();
    }
    else{
      if(this.forceParam==this.defaultForce){
        d3.select('#yearbutton').classed("yearbutton",false);
        this.switch = true;
      }
      else
        this.switch = false;

      this.threshold = 0;
      this.selectedTag = tagName;
      this.forceParam = -15;

      let newlinksdata = this.networkData.links.reduce((filtered,d)=>{
              let v;
              let linkvalue = this.selectedYear==0? d.value: d['year'][+this.selectedYear - 2001][this.selectedYear];
              if(d.target.tag==tagName){
                v= {
                  "source":tagName,
                  "target":d.source.tag,
                  "value":linkvalue,
                  "t_groupid":this.tagMap.get(d.source.tag),
                }
              }
              else if(d.source.tag==tagName){
                v= {
                  "source":tagName,
                  "target":d.target.tag,
                  "value":linkvalue,
                  "t_groupid":this.tagMap.get(d.target.tag),
                }
              }
              else if(d.target==tagName){
                v= {
                  "source":tagName,
                  "target":d.source,
                  "value":linkvalue,
                  "t_groupid":this.tagMap.get(d.source),
                }
              }
              else if(d.source==tagName){
                v = {
                  "source":tagName,
                  "target":d.target,
                  "value":linkvalue,
                  "t_groupid":this.tagMap.get(d.target),
                }

              }
              if(linkvalue>this.threshold && v!=undefined)
                filtered.push(v);
              return filtered;
            },[])

      newlinksdata.sort((a,b)=>{
        if(a.t_groupid!=b.t_groupid)
         return a.t_groupid - b.t_groupid;
        else
                if (a.target  b.target) {
                  return 1;
                }

      })

      let usedTags = newlinksdata.map((d)=>{
           if(d.target!=undefined && d.target.tag!=undefined)
                return d.target.tag;
            return d.target;
      })

      usedTags.push(tagName);

      let nodeWithEdge = this.networkData.nodes
              .filter((d)=>{
                return  usedTags.includes(d.tag);
              });

      nodeWithEdge.sort((a,b)=>{
          return a.groupid - b.groupid;
      });

      let groups = d3.nest()
          .key(function(d) { return d.t_groupid; })
          .rollup(function(v) {
            let sum = d3.sum(v,function(l){return l.value});
            let member = v.map((t)=>{
              return t.tag;
            }).sort();

            return {
              "valueToGroup":sum,
              "data":v,
            }

          })
          .entries(newlinksdata);

      //console.log(groups);

      let zoominGroup = [];
      groups.forEach( (d)=> {
        let groupid = "Group"+d.key;
        nodeWithEdge.push(
          {
            "tag":groupid,
            "groupid":d.key,
          }
        )
        zoominGroup.push(
          {
            "source":tagName,
            "target":groupid,
            "value":d.value.valueToGroup,
          }
        );
        let groupNode = d.value.data;
        groupNode.forEach( (e)=> {
            zoominGroup.push(
              {
                "source":groupid,
                "target":e.target,
                "value":e.value,
              }
            );
            nodeWithEdge.find((d)=>{return d.tag==e.target})['value'] = e.value;
        });

      });

      this.linksData = zoominGroup;
      this.nodesData = nodeWithEdge;
    }
    this.update();

  }
  /**
   * Renders the HTML content for tool tip.
   *
   * @param tooltip_data information that needs to be populated in the tool tip
   * @return text HTML content for tool tip
   */
  circle_tooltip_render(tooltip_data) {
      let text = "
" + tooltip_data.tag + "
";
      //text +=  "Group ID: " + tooltip_data.groupid;

      if(this.forceParam != -15){
        text += "
 Top 5 strong related tags:
";
        text += "
"
        tooltip_data.top5.forEach((row)=>{
            text += "
" + row.tag + ":" + row.value+ "
"
        });
        text += "
";
      }
      else if(tooltip_data.tag!=this.selectedTag){
        text += "co-occurrence: "+tooltip_data.value;
      }

      return text;
  }

  /**
   * Creates a chart with circles representing each election year, populates text content and other required elements for the Year Chart
   */
  update () {

    let divnwChart = d3.select("#tagCloud").node();
    //console.log(divnwChart);

    function dragstarted(d) {
    if (!d3.event.active) simulation.alphaTarget(0.3).restart();
    d.fx = d.x;
    d.fy = d.y;
  }

  function dragged(d) {
    d.fx = d3.event.x;
    d.fy = d3.event.y;
  }

  function dragended(d) {
    if (!d3.event.active) simulation.alphaTarget(0);
    d.fx = null;
    d.fy = null;
  }

  let simulation = d3.forceSimulation()
      .force("link", d3.forceLink()
                      .id(function(d) {
                      return d.tag; })
        )
      .force("charge", d3.forceManyBody()
                          .strength(this.forceParam)
                          .distanceMax(200)

        )
      .force("center", d3.forceCenter(this.svgWidth / 2, this.svgHeight / 2))
      .force('collision', d3.forceCollide().radius((d)=>{
        if(d.value!=undefined && d.value >0)
          return this.rScale(d.value);
        return 9
      }))

  this.gAll.select('.links').selectAll('line').remove();

  let lines = this.gAll.select('.links').selectAll('line')
                      .data(this.linksData);
  let newlines = lines.enter().append('line').style("opacity", 0);

      lines.exit()
            .style("opacity", 1)
            .transition()
            .duration(3000)
            .style("opacity", 0)
            .remove();

      lines = newlines.merge(lines);

      lines
      .transition().duration(2000)
      .style("opacity", 1)
      .attr("stroke-width", (d)=> { return Math.sqrt(d.value-this.threshold); });

      lines
      .transition().duration(2000)
      .style("opacity", 1)
      .attr("stroke-width", (d)=> { return Math.sqrt(d.value-this.threshold); });

      let circles;
      this.nodesData.sort((a,b)=>{
                if (a.tag  b.tag) {
                  return 1;
                }
      })
      if(this.switch){
        this.gAll.selectAll('.nodes').selectAll('circle').remove();
        circles = this.gAll.selectAll('.nodes').selectAll('circle')
                      .data(()=>{
                        if(this.forceParam==-15)
                          return this.nodes; //all 403 nodes
                        return this.nodesData;
                      });

        let newcircles = circles.enter().append('circle')
                                .style("opacity", (d)=>{
                                  if(this.forceParam==-15)
                                    return 0;
                                  else
                                    return 1;
                                })
                                .attr("r", (d)=>{
                                   if(this.forceParam!=-15)
                                    return 8
                                   if(d.value>0)
                                    return this.rScale(d.value);
                                   return 8
                                })
                                .classed("visible",(d)=>{
                                  if(this.forceParam==-15){
                                    if(this.nodesData.includes(d)){
                                        return true;
                                    }
                                    return false;
                                  }
                                  else
                                    return true;
                                });

        circles.exit()
            .style("opacity", 1)
            .transition()
            .duration(1500)
            .style("opacity", 0)
            .remove();

      circles =  newcircles.merge(circles);

      circles
      .transition().duration(3000)
      .attr("fill", (d)=> { return this.colorScale(d.groupid); })
      .style("opacity", (d)=>{
              if(this.forceParam==-15)
                  if(this.nodesData.includes(d))
                    return 1;
                  else
                    return 0;
              else
                return 1;
          });

      }
      else{
       circles = this.gAll.selectAll('.nodes').selectAll('circle');

        let i=0;
        circles.classed("visible",(d)=>{
                                  if(this.nodesData.includes(d)){
                                        i++;
                                        return true;
                                    }
                                    return false;
                                })
                .transition().duration(2000)
                .attr("r", (d)=>{
                   //if()
                   if( d.tag!=this.selectedTag && d.value>0){
                    return this.rScale(d.value);
                   }
                   return 8
                })
                .style("opacity", (d)=>{
                                  if(this.nodesData.includes(d))
                                    return 1;
                                  return 0;
                                });

      }

      this.svg.select('.centerTag').remove();
      if(this.forceParam==-15){
            this.svg.append('text')
                .attr('dy','2.0em')
                .attr("x", 20)
                .attr('y',10)
                .classed('centerTag',true)
                .text("Center: "+this.selectedTag);
      }

      circles
      .call(d3.drag()
        .on("start", dragstarted)
        .on("drag", dragged)
        .on("end", dragended));

  //tooltip
      d3.selectAll('.d3-tip').remove();
      this.circletip = d3.tip().attr('class', 'd3-tip')
              .direction((d)=>{
                return 'sw'
                //if(d['fromcloud']!=undefined) return 'sw'
                //return 'se'
              })
              .offset((d)=> {

                  if(d['fromcloud']!=undefined){
                    let headerHeight = d3.select("#header").node().getBoundingClientRect().height;
                    let topshift = d3.select("#networkChart").node().getBoundingClientRect();
                    let textshift = d3.select("#networkChart").select('h3').node().getBoundingClientRect();
                    //console.log('textshift: ' + textshift.height)
                    let cloudW = d3.select("#tagCloud").node().getBoundingClientRect().width;
                    //console.log('cloudW: ' + cloudW)
                    //console.log('d3.event.pageX: ' + d3.event.pageX);
                    //console.log('d3.event.pageY: ' + d3.event.pageY);
                    let radius = this.forceParam == -15? d.tag==this.selectedTag? 16:this.rScale(d.value)*2 :16;

                    let x = d.tag==this.selectedTag? this.svgWidth/2 - 8: d.x;
                    let y = d.tag==this.selectedTag? this.svgHeight/2: d.y;
                    let xshift = 500;
                    let offsetx = cloudW + x - d3.event.pageX + d['xshift'];
                    let offsety = radius + textshift.height + headerHeight + this.margin.top + y - d3.event.pageY - d['yshift'];
                    //console.log('y: ' + y);
                    //console.log('offsety: ' + offsety);
                    return [offsety,offsetx]//[d.x,d.y]
                  }
                  //*/
                  return [0,0]
              })
              .html((d)=>{
                let tooltip_data;
                let dvalue = d.value;
                if(this.forceParam != -15){
                  let relatedLine = this.linksData.filter((l)=>{
                    return l.source.tag == d.tag || l.target.tag == d.tag;
                  });
                  let rank = relatedLine.map((l)=>{
                      let tagName;
                      let gid;
                      if(l.source.tag==d.tag){
                        tagName = l.target.tag;
                        gid = l.target.groupid;
                      }
                      else{
                        tagName = l.source.tag;
                        gid = l.source.groupid;
                      }
                      return{
                        "tag": tagName,
                        "value":l.value,
                        "groupid":gid
                      }
                  });

                  rank.sort((a,b)=>{
                    return(b.value - a.value);
                  });
                  //console.log(rank);
                  let top5 = rank.slice(0,5);
                  //console.log(top5);

                  tooltip_data = {
                      "tag": d.tag,
                      "groupid":d.groupid,
                      "color":this.colorScale(d.groupid),
                      "top5":top5
                    };

                }
                else{
                  tooltip_data = {
                      "tag": d.tag,
                      "groupid":d.groupid,
                      "color":this.colorScale(d.groupid),
                      "value":d.value
                      /*
                      "result":[
                        {"nominee": d.D_Nominee_prop,"votecount": d.D_Votes,"percentage": d.D_Percentage,"party":"D"} ,
                        {"nominee": d.R_Nominee_prop,"votecount": d.R_Votes,"percentage": d.R_Percentage,"party":"R"} ,
                        {"nominee": d.I_Nominee_prop,"votecount": d.I_Votes,"percentage": d.I_Percentage,"party":"I"}
                       ]
                       */
                    };
                }
                return this.circle_tooltip_render(tooltip_data);
      });
      /*
      .style("left", ()=>{
        if(d['fromcloud']!=undefined)
          return d.x
        return 0;
      })
      .style("top", (d)=>{
        if(d['fromcloud']!=undefined)
          return d.y+400
      });*/

      this.svg.call(this.circletip);

      let clickstate = 1;
      let self = this;
      if(this.forceParam != -15){
          circles.on('mouseover', function(d){
                    d3.select(this).classed('selected',true)
                    .attr('r',(d)=>{
                      return 12;
                    });
                    self.circletip.show(d)
                  })
                  .on('mouseout', function(d){
                    d3.select(this).classed('selected',false)
                    .attr('r',(d)=>{
                      return 8;
                    })
                    self.circletip.hide(d)
                  })
                  .on('dblclick',(d)=>{
                    //console.log(d.tag);
                    clickstate = 0;
                     this.selectOneNode(d.tag,false);
                  })
                  .on('click',(d)=>{
                  // when click, add tag in to buttons
                  //console.log(d.tag);
                  clickstate=1;
                    setTimeout(()=>{
                      if(clickstate==1)
                        addButton(d.tag);
                      }, 400);

                  });
      }
      else{
           circles = this.gAll.selectAll('.nodes').selectAll('.visible')
                  .on('mouseover', function(d){
                    let rsize = d3.select(this).attr('r');
                    //console.log('rsize: '+rsize);
                    d3.select(this).classed('selected',true)
                    .attr('r',(d)=>{
                      return +rsize+4;
                    });
                    self.circletip.show(d)
                  })
                  .on('mouseout', function(d){
                    let rsize = d3.select(this).attr('r');
                    d3.select(this).classed('selected',false)
                    .attr('r',(d)=>{
                      return +rsize-4;
                    });
                    self.circletip.hide(d)
                  })
                  .on('dblclick',(d)=>{
                    //console.log(d.tag);
                    clickstate = 0;
                    this.selectOneNode(d.tag,false);
                  })
                  .on('click',(d)=>{
                  // when click, add tag in to buttons
                  clickstate=1;
                    setTimeout(()=>{
                      if(clickstate==1)
                        addButton(d.tag);
                      }, 400);
                  });
      }

      simulation
          .nodes(this.nodesData)
          .on("tick", ticked);

      simulation.force("link")
          .links(this.linksData);

      function ticked() {
        /*
        if(!self.switch){
        lines
            .attr("x1", function(d) { return d.source.x; })
            .attr("y1", function(d) { return d.source.y; })
            .attr("x2", function(d) { return d.target.x; })
            .attr("y2", function(d) { return d.target.y; });
            //.style("opacity", 1)
            //.attr("stroke-width", (d)=> { return Math.sqrt(d.value-self.threshold); });
        circles
            .attr("cx", function(d) { return d.x; })
            .attr("cy", function(d) { return d.y; });
        }
        else{
          */
          lines
            .attr("x1", function(d) { return d.source.x; })
            .attr("y1", function(d) { return d.source.y; })
            .attr("x2", function(d) { return d.target.x; })
            .attr("y2", function(d) { return d.target.y; });

        circles
            .attr("cx", function(d) { return d.x; })
            .attr("cy", function(d) { return d.y; });
        //}
      }

      /*
      //zoom capabilities
      let min_zoom = 0.5;
      let max_zoom = 7;
      var zoom_handler = d3.zoom()
          .on("zoom", zoom_actions);
      zoom_handler(this.svg);
      function zoom_actions(){
          //this.gAll
          //  .attr("transform", d3.event.transform)
      }
      */

}

textHoverOn(tagName,xshift,yshift){
    let circles = this.gAll.selectAll('.nodes').selectAll('.visible').filter((d)=>{
      return d.tag==tagName;
    })._groups;

    let circle = circles[0][0];
    if(circle!=undefined){
      let rsize = d3.select(circle).attr('r');

      d3.select(circle).classed('selected',true)
                    .attr('r',(d)=>{
                      return +rsize+4;
                    });
      let data = circle.__data__;

      data['fromcloud'] = true;
      data['xshift'] = xshift;
      data['yshift'] = yshift;
      this.circletip.show(data);
    }
}

textHoverOff(tagName){
    this.gAll.selectAll('.nodes').selectAll('.visible').classed('selected',false);
    let circle = this.gAll.selectAll('.nodes').selectAll('.visible').filter((d)=>{
      return d.tag==tagName;
    })._groups[0][0];
    if(circle!=undefined){
      let rsize = d3.select(circle).attr('r');

      d3.select(circle)
                    .attr('r',(d)=>{
                      return +rsize-4;
                    });
      delete circle.__data__['fromcloud'];
      delete circle.__data__['xshift'];
      delete circle.__data__['yshift'];
      this.circletip.hide(circle.__data__);
    }
}

};


text:
'-------------------------------------------------------------------------------------------'
' Inicio del codigo
'-------------------------------------------------------------------------------------------'
' Importando librerias
'-------------------------------------------------------------------------------------------'
Imports System.Data

'-------------------------------------------------------------------------------------------'
' Inicio de clase "fFicha_DatosClientes"
'-------------------------------------------------------------------------------------------'
Partial Class fFicha_DatosClientes
    Inherits vis2Formularios.frmReporte

    Dim loObjetoReporte As CrystalDecisions.CrystalReports.Engine.ReportDocument

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Try

            Dim loComandoSeleccionar As New StringBuilder()
            Dim lcTipo As String = goServicios.mObtenerCampoFormatoSQL(goEmpresa.pcCodigo & "Clientes")

			loComandoSeleccionar.AppendLine(" SELECT")
			loComandoSeleccionar.AppendLine(" 			Clientes.cod_cli,")
			loComandoSeleccionar.AppendLine(" 			Clientes.nom_cli,")
			loComandoSeleccionar.AppendLine(" 			CASE")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.Status = 'A' THEN 'Activo'")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.Status = 'I' THEN 'Inactivo'")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.Status = 'S' THEN 'Suspendido'")
			loComandoSeleccionar.AppendLine(" 			END AS Status,")
			loComandoSeleccionar.AppendLine(" 			Clientes.tip_cli,")
			loComandoSeleccionar.AppendLine(" 			CASE")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.crm_sec = 'P' THEN 'Producción'")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.crm_sec = 'C' THEN 'Comercio'")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.crm_sec = 'S' THEN 'Servicio'")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.crm_sec = 'G' THEN 'Gobierno'")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.crm_sec = 'O' THEN 'Otro'")
			loComandoSeleccionar.AppendLine(" 			END AS crm_sec,")
			loComandoSeleccionar.AppendLine(" 			Clientes.abc,")
			loComandoSeleccionar.AppendLine(" 			CASE")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.Sexo = 'X' THEN 'No Aplica'")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.Sexo = 'M' THEN 'Masculino'")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.Sexo = 'F' THEN 'Femenino'")
			loComandoSeleccionar.AppendLine(" 			END AS Sexo,")
			loComandoSeleccionar.AppendLine(" 			Clientes.tip_pag,")
			loComandoSeleccionar.AppendLine(" 			Clientes.nit,")
			loComandoSeleccionar.AppendLine(" 			Clientes.rif,")
			loComandoSeleccionar.AppendLine(" 			Clientes.movil,")
			loComandoSeleccionar.AppendLine(" 			Clientes.web,")
			loComandoSeleccionar.AppendLine(" 			Clientes.telefonos,")
			loComandoSeleccionar.AppendLine(" 			Clientes.fec_ini,")
			loComandoSeleccionar.AppendLine(" 			Clientes.cod_pos,")
			loComandoSeleccionar.AppendLine(" 			Clientes.fax,")
			loComandoSeleccionar.AppendLine(" 			Clientes.fec_fin,")
			loComandoSeleccionar.AppendLine(" 			Clientes.correo,")
			loComandoSeleccionar.AppendLine(" 			Clientes.contacto,")
			loComandoSeleccionar.AppendLine(" 			Clientes.cod_tip,")
			loComandoSeleccionar.AppendLine(" 			Clientes.cod_zon,")
			loComandoSeleccionar.AppendLine(" 			Clientes.cod_pai,")
			loComandoSeleccionar.AppendLine(" 			Clientes.cod_est,")
			loComandoSeleccionar.AppendLine(" 			Clientes.cod_ciu,")
			loComandoSeleccionar.AppendLine(" 			Clientes.cod_cla,")
			loComandoSeleccionar.AppendLine(" 			Clientes.cod_con,")
			loComandoSeleccionar.AppendLine(" 			Clientes.cod_per,")
			loComandoSeleccionar.AppendLine(" 			Clientes.cod_for,")
			loComandoSeleccionar.AppendLine(" 			Clientes.cod_ven,")
			loComandoSeleccionar.AppendLine(" 			Clientes.cod_tra,")
			loComandoSeleccionar.AppendLine(" 			Clientes.matriz,")
			loComandoSeleccionar.AppendLine(" 			Clientes.ciclo,")
			loComandoSeleccionar.AppendLine(" 			Clientes.dir_fis,")
			loComandoSeleccionar.AppendLine(" 			Clientes.dir_exa,")
			loComandoSeleccionar.AppendLine(" 			Clientes.dir_otr,")
			loComandoSeleccionar.AppendLine(" 			Clientes.dir_ent,")
			loComandoSeleccionar.AppendLine(" 			Clientes.actividad,")
			loComandoSeleccionar.AppendLine(" 			Clientes.are_neg,")
			loComandoSeleccionar.AppendLine(" 			Clientes.fec_nac,")
			loComandoSeleccionar.AppendLine(" 			Clientes.comentario,")
			loComandoSeleccionar.AppendLine(" 			Clientes.hor_caj,")
			loComandoSeleccionar.AppendLine(" 			Clientes.fiscal,")
			loComandoSeleccionar.AppendLine(" 			Clientes.nacional,")
			loComandoSeleccionar.AppendLine(" 			Clientes.mar_rec,")
			loComandoSeleccionar.AppendLine(" 			Clientes.crm_pos,")
			loComandoSeleccionar.AppendLine(" 			Clientes.pol_com,")
			loComandoSeleccionar.AppendLine(" 			Clientes.mon_sal,")
			loComandoSeleccionar.AppendLine(" 			Clientes.mon_cre,")
			loComandoSeleccionar.AppendLine(" 			Clientes.dia_cre,")
			loComandoSeleccionar.AppendLine(" 			Clientes.pro_pag,")
			loComandoSeleccionar.AppendLine(" 			Clientes.por_des,")
			loComandoSeleccionar.AppendLine(" 			Clientes.por_ali,")
			loComandoSeleccionar.AppendLine(" 			Clientes.por_int,")
			loComandoSeleccionar.AppendLine(" 			Clientes.por_pat,")
			loComandoSeleccionar.AppendLine(" 			Clientes.por_isl,")
			loComandoSeleccionar.AppendLine(" 			Clientes.por_ret,")
			loComandoSeleccionar.AppendLine(" 			Clientes.por_pat,")
			loComandoSeleccionar.AppendLine(" 			Clientes.por_otr,")
			loComandoSeleccionar.AppendLine(" 			Clientes.kilometros,")
			loComandoSeleccionar.AppendLine(" 			Clientes.generico,")
			loComandoSeleccionar.AppendLine(" 			CASE")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.tip_con = 'Formal' THEN 'Formal'")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.tip_con = 'Ordinario' THEN 'Ordinario'")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.tip_con = 'Especial' THEN 'Especial'")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.tip_con = 'Ocasional' THEN 'Ocasional'")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.tip_con = 'Otro_1' THEN 'Otro 1'")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.tip_con = 'Otro_2' THEN 'Otro 2'")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.tip_con = 'Otro_3' THEN 'Otro 3'")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.tip_con = 'Otro_4' THEN 'Otro 4'")
			loComandoSeleccionar.AppendLine(" 				WHEN Clientes.tip_con = 'Otro_5' THEN 'Otro 5'")
			loComandoSeleccionar.AppendLine(" 			END AS tip_con,")
			loComandoSeleccionar.AppendLine(" 			Clientes.tipo,")
			loComandoSeleccionar.AppendLine(" 			Clientes.clase,")
			loComandoSeleccionar.AppendLine(" 			Tipos_Clientes.Nom_Tip,")
			loComandoSeleccionar.AppendLine(" 			Zonas.Nom_Zon,")
			loComandoSeleccionar.AppendLine(" 			Paises.Nom_Pai,")
			loComandoSeleccionar.AppendLine(" 			Estados.Nom_Est,")
			loComandoSeleccionar.AppendLine(" 			Ciudades.Nom_Ciu,")
			loComandoSeleccionar.AppendLine(" 			Clases_Clientes.Nom_Cla,")
			loComandoSeleccionar.AppendLine(" 			Personas.Nom_Per,")
			loComandoSeleccionar.AppendLine(" 			Formas_Pagos.Nom_For,")
			loComandoSeleccionar.AppendLine(" 			Vendedores.Nom_Ven,")
			loComandoSeleccionar.AppendLine(" 			Transportes.Nom_Tra,")
			loComandoSeleccionar.AppendLine(" 			Conceptos.Nom_Con,")
			loComandoSeleccionar.AppendLine(" 			Contactos.Nom_Con	As Nom_Contacto,")
			loComandoSeleccionar.AppendLine(" 			Contactos.Cargo	As Cargo_Con,")
			loComandoSeleccionar.AppendLine(" 			Contactos.Telefonos As Tlf_Con,")
			loComandoSeleccionar.AppendLine(" 			Contactos.Correo As Mail_Con")
			loComandoSeleccionar.AppendLine(" FROM Clientes")
			loComandoSeleccionar.AppendLine(" JOIN Tipos_Clientes ON Tipos_Clientes.Cod_Tip = Clientes.Cod_Tip")
			loComandoSeleccionar.AppendLine(" JOIN Zonas ON Zonas.Cod_Zon = Clientes.Cod_Zon")
			loComandoSeleccionar.AppendLine(" JOIN Paises ON Paises.Cod_Pai = Clientes.Cod_Pai")
			loComandoSeleccionar.AppendLine(" LEFT JOIN Estados ON Estados.Cod_Est = Clientes.Cod_Est")
			loComandoSeleccionar.AppendLine(" LEFT JOIN Ciudades ON Ciudades.Cod_Ciu = Clientes.Cod_Ciu")
			loComandoSeleccionar.AppendLine(" JOIN Clases_Clientes ON Clases_Clientes.Cod_Cla = Clientes.Cod_Cla")
			loComandoSeleccionar.AppendLine(" JOIN Personas ON Personas.Cod_Per = Clientes.Cod_Per")
			loComandoSeleccionar.AppendLine(" JOIN Formas_Pagos ON Formas_Pagos.Cod_For = Clientes.Cod_For")
			loComandoSeleccionar.AppendLine(" JOIN Vendedores ON Vendedores.Cod_Ven = Clientes.Cod_Ven")
			loComandoSeleccionar.AppendLine(" JOIN Transportes ON Transportes.Cod_Tra = Clientes.Cod_Tra")
			loComandoSeleccionar.AppendLine(" JOIN Conceptos ON Conceptos.Cod_Con = Clientes.Cod_Con")
			loComandoSeleccionar.AppendLine(" LEFT JOIN Contactos ON Contactos.Tipo =" & lcTipo & " AND Contactos.Cod_Reg = Clientes.Cod_Cli")
			loComandoSeleccionar.AppendLine(" WHERE")
            loComandoSeleccionar.AppendLine("           " & cusAplicacion.goFormatos.pcCondicionPrincipal)

            Dim loServicios As New cusDatos.goDatos
            Dim laDatosReporte As DataSet = loServicios.mObtenerTodosSinEsquema(loComandoSeleccionar.ToString, "curReportes")

			'--------------------------------------------------'
			' Carga la imagen del logo en cusReportes          '
			'--------------------------------------------------'
			Me.mCargarLogoEmpresa(laDatosReporte.Tables(0), "LogoEmpresa")

			'-------------------------------------------------------------------------------------------------------
            ' Verificando si el select (tabla nº0) trae registros
            '-------------------------------------------------------------------------------------------------------

            If (laDatosReporte.Tables(0).Rows.Count <= 0) Then
                Me.WbcAdministradorMensajeModal.mMostrarMensajeModal("Información", _
                                          "No se Encontraron Registros para los Parámetros Especificados. ", _
						vis3Controles.wbcAdministradorMensajeModal.enumTipoMensaje.KN_Informacion, _
                                           "350px", _
                                           "200px")
            End If

            loObjetoReporte = cusAplicacion.goFormatos.mCargarInforme("fFicha_DatosClientes", laDatosReporte)
            Me.mTraducirReporte(loObjetoReporte)
            Me.mFormatearCamposReporte(loObjetoReporte)
            Me.crvfFicha_DatosClientes.ReportSource = loObjetoReporte

        Catch loExcepcion As Exception

            Me.WbcAdministradorMensajeModal.mMostrarMensajeModal("Error", _
                          "No se pudo Completar el Proceso: " & loExcepcion.Message, _
                           vis3Controles.wbcAdministradorMensajeModal.enumTipoMensaje.KN_Error, _
                           "auto", _
                           "auto")

        End Try

    End Sub

    Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload

        Try

            loObjetoReporte.Close()

        Catch loExcepcion As Exception

            Me.WbcAdministradorMensajeModal.mMostrarMensajeModal("Error", _
                          "No se pudo Completar el Proceso: " & loExcepcion.Message, _
                           vis3Controles.wbcAdministradorMensajeModal.enumTipoMensaje.KN_Error, _
                           "auto", _
                           "auto")

        End Try

    End Sub

End Class
'-------------------------------------------------------------------------------------------'
' Fin del codigo
'-------------------------------------------------------------------------------------------'
' CMS: 18/09/09 : Codigo inicial
'-------------------------------------------------------------------------------------------'
' CMS: 18/03/10: Se aplicaron los metodos carga de imagen y validacion de registro cero
'-------------------------------------------------------------------------------------------'
' MAT: 10/01/11: Ajuste de la vista de diseño y adición de nuevos campos al formato
'-------------------------------------------------------------------------------------------'

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>data</title>
<meta name="date" content="2015-06-30">
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Package

Next Package

Frames

No Frames

All Classes

Package data

Class Summary

Class
Description

Attribute

Constants

ContinuousAttribute

ContinuousItem

Data

DiscreteAttribute

DiscreteItem

Item

Tuple

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Package

Next Package

Frames

No Frames

All Classes


text:
package com.planet_ink.coffee_mud.Abilities.Spells;
import com.planet_ink.coffee_mud.core.interfaces.*;
import com.planet_ink.coffee_mud.core.*;
import com.planet_ink.coffee_mud.Abilities.interfaces.*;
import com.planet_ink.coffee_mud.Areas.interfaces.*;
import com.planet_ink.coffee_mud.Behaviors.interfaces.*;
import com.planet_ink.coffee_mud.CharClasses.interfaces.*;
import com.planet_ink.coffee_mud.Commands.interfaces.*;
import com.planet_ink.coffee_mud.Common.interfaces.*;
import com.planet_ink.coffee_mud.Exits.interfaces.*;
import com.planet_ink.coffee_mud.Items.interfaces.*;
import com.planet_ink.coffee_mud.Locales.interfaces.*;
import com.planet_ink.coffee_mud.MOBS.interfaces.*;
import com.planet_ink.coffee_mud.Races.interfaces.*;

import java.util.*;

@SuppressWarnings("unchecked")
public class Spell_MirrorImage extends Spell
{
	public String ID() { return "Spell_MirrorImage"; }
	public String name(){return "Mirror Image";}
	public String displayText(){return "(Mirror Image spell)";}
	public int abstractQuality(){return Ability.QUALITY_BENEFICIAL_SELF;}
	protected int canAffectCode(){return CAN_MOBS;}
	public int classificationCode(){ return Ability.ACODE_SPELL|Ability.DOMAIN_ILLUSION;}

	private	Random randomizer = new Random(System.currentTimeMillis());
	protected int numberOfImages = 0;
	protected boolean notAgain=false;

	public boolean okMessage(Environmental myHost, CMMsg msg)
	{
		if((affected==null)||(!(affected instanceof MOB)))
			return true;

		MOB mob=(MOB)affected;

		if((msg.amITarget(mob))
		&&(msg.targetMinor()==CMMsg.TYP_WEAPONATTACK)
		&&(mob!=msg.source()))
		{
			if(numberOfImages <= 0)
			{
				unInvoke();
				return true;
			}
			int numberOfTargets = numberOfImages + 1;
			if(randomizer.nextInt() % numberOfTargets == 0)
			{
				if(mob.location().show(mob,msg.source(),CMMsg.MSG_NOISYMOVEMENT,"<T-NAME> attack(s) a mirrored image!"))
					numberOfImages--;
				return false;
			}
		}
		return true;
	}
	public void executeMsg(Environmental myHost, CMMsg msg)
	{
		super.executeMsg(myHost,msg);

		if((affected==null)||(!(affected instanceof MOB)))
			return;

		if(notAgain) return;

		MOB mob=(MOB)affected;
		if(msg.amISource(mob))
		{
			if((
				(CMath.bset(msg.othersCode(),CMMsg.MASK_EYES))
				||(CMath.bset(msg.othersCode(),CMMsg.MASK_MOVE))
				||(CMath.bset(msg.othersCode(),CMMsg.MASK_MOUTH))
				||(CMath.bset(msg.othersCode(),CMMsg.MASK_HANDS)))
			&&(msg.othersMessage()!=null)
			&&(msg.targetMinor()!=CMMsg.TYP_DAMAGE)
			&&(msg.othersMessage().length()>0))
			{
				notAgain=true;
				if(numberOfImages<=0)
					unInvoke();
				else
					for(int x=0;x<numberOfImages;x++)
						msg.addTrailerMsg(CMClass.getMsg(mob,msg.target(),msg.tool(),CMMsg.MSG_OK_VISUAL,msg.othersMessage()));
			}
		}
		else
		if((msg.amITarget(mob.location())&&(!msg.amISource(mob))&&((msg.targetMinor()==CMMsg.TYP_LOOK)||(msg.targetMinor()==CMMsg.TYP_EXAMINE)))
		&&((CMLib.flags().canBeSeenBy(mob,msg.source()))&&(mob.displayText(msg.source()).length()>0)))
		{
			StringBuffer Say=new StringBuffer("");
            boolean compress=CMath.bset(msg.source().getBitmap(),MOB.ATT_COMPRESS);
			for(int i=0;i<numberOfImages;i++)
			{
				Say.append("^M");
                if(compress) Say.append(CMLib.flags().colorCodes(mob,mob)+"^M ");
                if(mob.displayText(msg.source()).length()>0)
                    Say.append(CMStrings.endWithAPeriod(CMStrings.capitalizeFirstLetter(mob.displayText(msg.source()))));
                else
                    Say.append(CMStrings.endWithAPeriod(CMStrings.capitalizeFirstLetter(mob.name())));
                if(!compress)
                    Say.append(CMLib.flags().colorCodes(mob,msg.source())+"^N\n\r");
                else
                    Say.append("^N");
			}
			if(Say.toString().length()>0)
			{
				CMMsg msg2=CMClass.getMsg(msg.source(),null,this,CMMsg.MSG_OK_VISUAL,Say.toString(),CMMsg.NO_EFFECT,null,CMMsg.NO_EFFECT,null);
				msg.addTrailerMsg(msg2);
			}
		}
		notAgain=false;
	}

	public void affectEnvStats(Environmental affected, EnvStats affectableStats)
	{
		super.affectEnvStats(affected,affectableStats);
		affectableStats.setArmor(affectableStats.armor() - 5-getXLEVELLevel(invoker()));
	}

	public void unInvoke()
	{
		// undo the affects of this spell
		if((affected==null)||(!(affected instanceof MOB)))
			return;
		MOB mob=(MOB)affected;
		if(canBeUninvoked())
			numberOfImages=0;
		super.unInvoke();

		if(canBeUninvoked())
			mob.tell("Your mirror images fade away.");
	}

	public boolean invoke(MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel)
	{
		MOB target=mob;
		if((auto)&&(givenTarget!=null)&&(givenTarget instanceof MOB))
			target=(MOB)givenTarget;
		if(target.fetchEffect(ID())!=null)
		{
			mob.tell(target,null,null,"<S-NAME> already <S-HAS-HAVE> mirror images.");
			return false;
		}

		// the invoke method for spells receives as
		// parameters the invoker, and the REMAINING
		// command line parameters, divided into words,
		// and added as String objects to a vector.
		if(!super.invoke(mob,commands,givenTarget,auto,asLevel))
			return false;

		boolean success=proficiencyCheck(mob,0,auto);

		if(success)
		{
			// it worked, so build a copy of this ability,
			// and add it to the affects list of the
			// affected MOB.  Then tell everyone else
			// what happened.
			invoker=mob;
			numberOfImages = CMLib.dice().roll(1,(int)(Math.round(CMath.div(adjustedLevel(mob,asLevel),3.0))),2);
			CMMsg msg=CMClass.getMsg(mob,target,this,verbalCastCode(mob,target,auto),(auto?"A spell forms around":"^S<S-NAME> incant(s) the reflective spell of")+" <T-NAME>, and suddenly " + numberOfImages + " copies appear.^?");
			if(mob.location().okMessage(mob,msg))
			{
				mob.location().send(mob,msg);
				beneficialAffect(mob,target,asLevel,0);
			}
		}
		else
		{
			numberOfImages = 0;
			return beneficialWordsFizzle(mob,target,"<S-NAME> speak(s) reflectively, but nothing more happens.");
		}
		// return whether it worked
		return success;
	}
}


text:
package com.thoughtworks.go.remote.work;

import com.thoughtworks.go.util.SystemEnvironment;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;

import java.util.concurrent.ScheduledThreadPoolExecutor;

import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
import static org.mockito.MockitoAnnotations.initMocks;

public class ConsoleOutputTransmitterTest {
    @Mock
    private ConsoleAppender consoleAppender;
    private ArgumentCaptor<String> requestArgumentCaptor;
    private ConsoleOutputTransmitter transmitter;

    @Before
    public void setup() throws Exception {
        initMocks(this);

        new SystemEnvironment().setProperty(SystemEnvironment.INTERVAL, "60"); // so the thread does not wake up

        requestArgumentCaptor = ArgumentCaptor.forClass(String.class);
        doNothing().when(consoleAppender).append(requestArgumentCaptor.capture());
        transmitter = new ConsoleOutputTransmitter(consoleAppender, 0, mock(ScheduledThreadPoolExecutor.class));
    }

    @After
    public void tearDown() {
        transmitter.stop();
    }

    @Test
    public void shouldFlushContentsInBufferToServerInOneGo() throws Exception {
        transmitter.consumeLine("first line");
        transmitter.consumeLine("second line");

        transmitter.flushToServer();

        verify(consoleAppender).append(any(String.class));
        assertThat(requestArgumentCaptor.getValue(), containsString("first line\n"));
        assertThat(requestArgumentCaptor.getValue(), containsString("second line\n"));
    }

    @Test
    public void shouldNotFlushToServerWhenBufferIsEmpty() throws Exception {
        transmitter.flushToServer();

        verify(consoleAppender, never()).append(any(String.class));
    }
}


text:
package loon.geom;

import loon.LSysException;
import loon.utils.StringKeyValue;
import loon.utils.StringUtils;
import loon.utils.TArray;

public class Polygon extends Shape implements BoxSize {
	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	public static class Polygon2i {}

	private boolean allowDups = false;

	private boolean closed = true;

	public Polygon(float[] points) {
		int length = points.length;

		this.points = new float[length];
		maxX = -Float.MIN_VALUE;
		maxY = -Float.MIN_VALUE;
		minX = Float.MAX_VALUE;
		minY = Float.MAX_VALUE;
		x = Float.MAX_VALUE;
		y = Float.MAX_VALUE;

		for (int i = 0; i < length; i++) {
			this.points[i] = points[i];
			if (i % 2 == 0) {
				if (points[i] > maxX) {
					maxX = points[i];
				}
				if (points[i] < minX) {
					minX = points[i];
				}
				if (points[i] < x) {
					x = points[i];
				}
			} else {
				if (points[i] > maxY) {
					maxY = points[i];
				}
				if (points[i] < minY) {
					minY = points[i];
				}
				if (points[i] < y) {
					y = points[i];
				}
			}
		}

		findCenter();
		calculateRadius();
		pointsDirty = true;
	}

	public Polygon() {
		points = new float[0];
		maxX = -Float.MIN_VALUE;
		maxY = -Float.MIN_VALUE;
		minX = Float.MAX_VALUE;
		minY = Float.MAX_VALUE;
	}

	public Polygon(float[] xpoints, float[] ypoints, int npoints) {
		if (npoints > xpoints.length || npoints > ypoints.length) {
			throw new LSysException("npoints > xpoints.length || "
					+ "npoints > ypoints.length");
		}
		if (npoints < 0) {
			throw new LSysException("npoints < 0");
		}
		points = new float[0];
		maxX = -Float.MIN_VALUE;
		maxY = -Float.MIN_VALUE;
		minX = Float.MAX_VALUE;
		minY = Float.MAX_VALUE;
		for (int i = 0; i < npoints; i++) {
			addPoint(xpoints[i], ypoints[i]);
		}
	}

	public Polygon(int[] xpoints, int[] ypoints, int npoints) {
		if (npoints > xpoints.length || npoints > ypoints.length) {
			throw new LSysException("npoints > xpoints.length || "
					+ "npoints > ypoints.length");
		}
		if (npoints < 0) {
			throw new LSysException("npoints < 0");
		}
		points = new float[0];
		maxX = -Float.MIN_VALUE;
		maxY = -Float.MIN_VALUE;
		minX = Float.MAX_VALUE;
		minY = Float.MAX_VALUE;
		for (int i = 0; i < npoints; i++) {
			addPoint(xpoints[i], ypoints[i]);
		}
	}

	public void setAllowDuplicatePoints(boolean allowDups) {
		this.allowDups = allowDups;
	}

	public void addPoint(float x, float y) {
		if (hasVertex(x, y) && (!allowDups)) {
			return;
		}
		int size = points.length;
		TArray<Float> tempPoints = new TArray<Float>();
		for (int i = 0; i < size; i++) {
			tempPoints.add(points[i]);
		}
		tempPoints.add(x);
		tempPoints.add(y);
		int length = tempPoints.size;
		this.points = new float[length];
		for (int i = 0; i < length; i++) {
			points[i] = tempPoints.get(i);
		}
		if (x > maxX) {
			maxX = x;
		}
		if (y > maxY) {
			maxY = y;
		}
		if (x < minX) {
			minX = x;
		}
		if (y < minY) {
			minY = y;
		}
		findCenter();
		calculateRadius();

		pointsDirty = true;
	}

	public Shape transform(Matrix3 transform) {
		checkPoints();

		Polygon resultPolygon = new Polygon();

		float result[] = new float[points.length];
		transform.transform(points, 0, result, 0, points.length / 2);
		resultPolygon.points = result;
		resultPolygon.findCenter();
		resultPolygon.closed = closed;

		return resultPolygon;
	}

	@Override
	public void setX(float x) {
		super.setX(x);
		pointsDirty = false;
	}

	@Override
	public void setY(float y) {
		super.setY(y);
		pointsDirty = false;
	}

	public void addVertex(float x, float y) {
		addPoint(x, y);
	}

	public void addVertex(Vector2f v) {
		addVertex(v.x, v.y);
	}

	public TArray<Vector2f> getVertices() {
		int size = points.length;
		TArray<Vector2f> vertices = new TArray<Vector2f>();
		for (int i = 0; i < size; i += 2) {
			vertices.add(new Vector2f(points[i], points[i + 1]));
		}
		return vertices;
	}

	@Override
	protected void createPoints() {

	}

	@Override
	public boolean closed() {
		return closed;
	}

	public void setClosed(boolean closed) {
		this.closed = closed;
	}

	public Polygon cpy() {
		float[] copyPoints = new float[points.length];
		System.arraycopy(points, 0, copyPoints, 0, copyPoints.length);
		return new Polygon(copyPoints);
	}

	@Override
	public void setWidth(float w) {
        this.maxX = w;
	}

	@Override
	public void setHeight(float h) {
	    this.maxY = h;
	}

	@Override
	public String toString() {
		StringKeyValue builder = new StringKeyValue("Polygon");
		builder.kv("points", "[" + StringUtils.join(',', points) + "]")
		.comma()
		.kv("center", "[" + StringUtils.join(',', center) + "]")
		.comma()
		.kv("rotation", rotation)
		.comma()
		.kv("minX", minX)
		.comma()
		.kv("minY", minY)
		.comma()
		.kv("maxX", maxX)
		.comma()
		.kv("maxY", maxY);
		return builder.toString();
	}
}


text:
OSPMapCSSBinaryOperator OSPMapCSSBinaryOperatorFromNSString(NSString *s)
{
    if ([s isEqualToString:@"="])
    {
        return OSPMapCSSBinaryOperatorEquals;
    }
    else if ([s isEqualToString:@"=~"])
    {
        return OSPMapCSSBinaryOperatorMatches;
    }
    else if ([s isEqualToString:@"!="])
    {
        return OSPMapCSSBinaryOperatorNotEquals;
    }
    else if ([s isEqualToString:@"<"])
    {
        return OSPMapCSSBinaryOperatorLessThan;
    }
    else if ([s isEqualToString:@">"])
    {
        return OSPMapCSSBinaryOperatorGreaterThan;
    }
    else if ([s isEqualToString:@"<="])
    {
        return OSPMapCSSBinaryOperatorLessThanOrEqual;
    }
    else
    {
        return OSPMapCSSBinaryOperatorGreaterThanOrEqual;
    }
}

NSString *NSStringFromOSPMapCSSBinaryOperator(OSPMapCSSBinaryOperator o)
{
    switch (o) {
        case OSPMapCSSBinaryOperatorEquals:
            return @"=";
        case OSPMapCSSBinaryOperatorMatches:
            return @"=~";
        case OSPMapCSSBinaryOperatorLessThan:
            return @"<";
        case OSPMapCSSBinaryOperatorNotEquals:
            return @"!=";
        case OSPMapCSSBinaryOperatorGreaterThan:
            return @">";
        case OSPMapCSSBinaryOperatorLessThanOrEqual:
            return @"<=";
        case OSPMapCSSBinaryOperatorGreaterThanOrEqual:
            return @">=";
    }
}

@implementation OSPMapCSSBinaryTest

@synthesize tagName;
@synthesize operator;
@synthesize value;

- (id)initWithSyntaxTree:(CPSyntaxTree *)syntaxTree
{
    self = [super initWithSyntaxTree:syntaxTree];

    if (nil != self)
    {
        [self setTagName:[[syntaxTree children][0] description]];
        [self setOperator:OSPMapCSSBinaryOperatorFromNSString([[[syntaxTree children][1] children][0] keyword])];
        CPToken *t = [[syntaxTree children][2] children][0];
        if ([t isKindOfClass:[CPIdentifierToken class]])
        {
            [self setValue:[(CPIdentifierToken *)t identifier]];
        }
        else if ([t isKindOfClass:[CPNumberToken class]])
        {
            [self setValue:[NSString stringWithFormat:@"%@", [(CPNumberToken *)t number]]];
        }
        else
        {
            [self setValue:[(CPQuotedToken *)t content]];
        }
    }

    return self;
}

- (NSString *)description
{
    return [NSString stringWithFormat:@"[%@ %@ \"%@\"]", [self tagName], NSStringFromOSPMapCSSBinaryOperator([self operator]), [self value]];
}

- (BOOL)matchesObject:(OSPAPIObject *)object
{
    NSString *objectValue = [object valueForTag:tagName];
    switch ([self operator])
    {
        case OSPMapCSSBinaryOperatorEquals:
            return [objectValue isEqualToString:value];
        case OSPMapCSSBinaryOperatorNotEquals:
            return ![objectValue isEqualToString:value];
        case OSPMapCSSBinaryOperatorMatches:
        {
            NSError *err = nil;
            NSRegularExpression *e = [NSRegularExpression regularExpressionWithPattern:value options:0 error:&err];
            return [e numberOfMatchesInString:objectValue options:NSMatchingAnchored range:NSMakeRange(0, [objectValue length])] > 0;
        }
        case OSPMapCSSBinaryOperatorLessThan:
            return [objectValue floatValue] < [value floatValue];
        case OSPMapCSSBinaryOperatorGreaterThan:
            return [objectValue floatValue] > [value floatValue];
        case OSPMapCSSBinaryOperatorLessThanOrEqual:
            return [objectValue floatValue] <= [value floatValue];
        case OSPMapCSSBinaryOperatorGreaterThanOrEqual:
            return [objectValue floatValue] >= [value floatValue];
    }
}

@end


text:
package main

import (
	"fmt"
	"strings"
)

var cmdQuery = &Command{
	Run:   runQuery,
	Usage: "query <soql statement> [output format]",
	Short: "Execute a SOQL statement",
	Long: `
Execute a SOQL statement

Examples:

  force query select Id, Name, Account.Name From Contact

  force query select Id, Name, Account.Name From Contact --format:csv

`,
}

func runQuery(cmd *Command, args []string) {
	force, _ := ActiveForce()
	if len(args) < 1 {
		cmd.printUsage()
	} else {
		format := "console"
		formatArg := args[len(args)-1]

		if strings.Contains(formatArg, "format:") {
			args = args[:len(args)-1]
			format = strings.SplitN(formatArg, ":", 2)[1]
		}

		soql := strings.Join(args, " ")
		records, err := force.Query(fmt.Sprintf("%s", soql))
		if err != nil {
			ErrorAndExit(err.Error())
		} else {
			if format == "console" {
				DisplayForceRecords(records)
			} else {
				DisplayForceRecordsf(records.Records, format)
			}
		}
	}
}


text:
<?php

namespace Apigee\Edge\Api\ApigeeX\Entity;

use Apigee\Edge\Api\Monetization\Entity\Property\DeveloperPropertyInterface;

interface DeveloperAcceptedRatePlanInterface extends AcceptedRatePlanInterface, DeveloperPropertyInterface
{
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
CBS Diversity Ser. (Utrecht) 7: 109 (2008)

#### Original name
Microsphaeropsis stellenboschensis Crous, M.J. Wingf. & Marincowitz

### Remarks
null


text:
from django.contrib.contenttypes.generic import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.db import models

from genericm2m.models import RelatedObjectsDescriptor

class RelatedBeverage(models.Model):
    food = models.ForeignKey('Food')
    beverage = models.ForeignKey('Beverage')

    class Meta:
        ordering = ('-id',)

class Food(models.Model):
    name = models.CharField(max_length=255)

    related = RelatedObjectsDescriptor()
    related_beverages = RelatedObjectsDescriptor(RelatedBeverage, 'food', 'beverage')

    def __unicode__(self):
        return self.name

class Beverage(models.Model):
    name = models.CharField(max_length=255)

    related = RelatedObjectsDescriptor()

    def __unicode__(self):
        return self.name

class Person(models.Model):
    name = models.CharField(max_length=255)

    related = RelatedObjectsDescriptor()

    def __unicode__(self):
        return self.name

class Boring(models.Model):
    name = models.CharField(max_length=255)

    def __unicode__(self):
        return self.name

class AnotherRelatedObject(models.Model):
    parent_type = models.ForeignKey(ContentType, related_name="child_%(class)s")
    parent_id = models.IntegerField(db_index=True)
    parent = GenericForeignKey(ct_field="parent_type", fk_field="parent_id")

    object_type = models.ForeignKey(ContentType, related_name="related_%(class)s")
    object_id = models.IntegerField(db_index=True)
    object = GenericForeignKey(ct_field="object_type", fk_field="object_id")

    alias = models.CharField(max_length=255, blank=True)
    description = models.TextField(blank=True)

    creation_date = models.DateTimeField(auto_now_add=True)

    class Meta:
        ordering = ('id',)

class Note(models.Model):
    content = models.TextField()

    related = RelatedObjectsDescriptor(AnotherRelatedObject)


text:
package yacht

import (
	"testing"
)

func TestScore(t *testing.T) {
	for _, testCase := range testCases {
		score := Score(testCase.dice, testCase.category)
		if testCase.expected != score {
			t.Fatalf("FAIL: %s\nScore %v as %s. expected %d, got %d",
				testCase.description, testCase.dice, testCase.category,
				testCase.expected, score)
		}
		t.Logf("PASS: %s", testCase.description)
	}
}

func BenchmarkScore(b *testing.B) {
	for i := 0; i < b.N; i++ {
		for _, testCase := range testCases {
			Score(testCase.dice, testCase.category)
		}
	}
}


text:
package unix

import (
	"syscall"
	"unsafe"
)

var _ syscall.Errno

// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT

func closedir(dir uintptr) (err error) {
	_, _, e1 := syscall_syscall(funcPC(libc_closedir_trampoline), uintptr(dir), 0, 0)
	if e1 != 0 {
		err = errnoErr(e1)
	}
	return
}

func libc_closedir_trampoline()

//go:linkname libc_closedir libc_closedir
//go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib"

// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT

func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) {
	r0, _, _ := syscall_syscall(funcPC(libc_readdir_r_trampoline), uintptr(dir), uintptr(unsafe.Pointer(entry)), uintptr(unsafe.Pointer(result)))
	res = Errno(r0)
	return
}

func libc_readdir_r_trampoline()

//go:linkname libc_readdir_r libc_readdir_r
//go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib"


text:
<?php

use Pagerfanta\Adapter\ArrayAdapter;
use Pagerfanta\Pagerfanta;
?>

<?php echo gen_getDico($route['_route']); ?>

            <?php echo $galleries->getGalleriesNav($galleries_base_route, $route); ?>

    <?php
    if ($route['style'] === 'last-minute' || $route['style'] === 'tt-collector') :
        $galleryID = $route['style'];
        $gallery = $galleries->getGallery($route['style']);

        if ($gallery) :

            $adapter = new ArrayAdapter($gallery);
            $pagerfanta = new Pagerfanta($adapter);
            $pagerfanta->setMaxPerPage($galleries_item_per_page);
            $pagerfanta->setCurrentPage($route['_page']);

            $pagination = $render->getPagination($pagerfanta, $galleries_base_route . "/" . $route['style']);
            $renderView = $pagerfanta->getCurrentPageResults();
            ?>

<?php echo $allProfileLabels[$galleryID][$render->getLang()]; ?>

                    <div class="<?php echo $display_galleries_cards_classes; ?>">
                        <?php foreach ($renderView as $item) : ?>
                            <?php include 'gallery-card.php'; ?>
                        <?php endforeach; ?>

<?php echo $pagination; ?>

        <?php else: ?>

                                <?php
                                if ('tt-collector' === $route['style']) {
                                    if (website_isLoggued()) {
                                        echo $allMsg['galleries_followed_noresult'][$render->getLang()];
                                    } else {
                                        echo $allMsg['error_notloggued']['long_'.$render->getLangCode()];
                                    }
                                } else {
                                    echo $allProfileLabels['search_members_noresult'][$render->getLang()];
                                }
                                ?>

        <?php endif; ?>

<?php else: ?>

<?php echo $allTattooStyles[$render->getStyleBySlug($route['style'])['id']][$render->getLang()]; ?>

    <?php echo $galleries->getGalleriesSubNav($galleries_base_route, $route); ?>

<?php endif; ?>


text:
module TableHelper
  def remove_dynamically_defined_all_method
    klasses = [Facemock::Database::Table,
               Facemock::Application,
               Facemock::User,
               Facemock::Permission,
               Facemock::AuthorizationCode ]
    klasses.each do |klass|
      remove_dynamically_defined_class_method(klass)
      remove_dynamically_defined_instance_method(klass)
    end
  end

  # テストで動的に定義したクラスメソッドを削除
  def remove_dynamically_defined_class_method(klass)
    klass.methods.each do |method_name|
      if method_name.to_s =~ /^find_by_/ || method_name.to_s =~ /^find_all_by_/
        klass.class_eval do
          class_variable_set(:@@target_method_name, method_name)
          class << self
            remove_method class_variable_get(:@@target_method_name)
          end
          remove_class_variable(:@@target_method_name)
        end
      end
    end
  end

  # テストで動的に定義したインスタンスメソッドを削除
  def remove_dynamically_defined_instance_method(klass)
    klass.column_names.each do |column_name|
      getter = column_name
      if klass.instance_methods.include?(getter)
        klass.class_eval { remove_method getter }
      end

      setter = (column_name.to_s + "=").to_sym
      if klass.instance_methods.include?(setter)
        klass.class_eval { remove_method setter }
      end
    end
  end

  # Tableクラスでテストするために、一時的にDB Tableを作成する
  def create_tables_table_for_test
    db = Facemock::Database.new
    db.connection.execute <<-SQL
      CREATE TABLE TABLES (
        id          INTEGER   PRIMARY KEY AUTOINCREMENT,
        text        TEXT      NOT NULL,
        active      BOOLEAN,
        number      INTEGER   NOT NULL,
        created_at  DATETIME  NOT NULL
      );
    SQL
    db.disconnect!
  end
end


text: java -cp build;%JBOSSCLIENT_PATH% Publisher %1


text:
Experimental terminal using the new PTY APIs from Microsoft. Written in C#, and heavily based on the native code examples.

## Status

Demonstrates the basic API calls required, but not intended for "real-world" usage.

## Resources

- [Introductory blog post from Microsoft](https://blogs.msdn.microsoft.com/commandline/2018/08/02/windows-command-line-introducing-the-windows-pseudo-console-conpty/)
- [MSDN Documentation](https://docs.microsoft.com/en-us/windows/console/creating-a-pseudoconsole-session)

## System Requirements

See the Introductory blog post from Microsoft for the full setup instructions. This project has been tested with:

- OS: Windows 10 Pro Build 17744
- SDK: Windows_InsiderPreview_SDK_en-us_17749


text:
NS_ASSUME_NONNULL_BEGIN

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation SDLSetDisplayLayoutResponse
#pragma clang diagnostic pop

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (instancetype)init {
    if (self = [super initWithName:SDLRPCFunctionNameSetDisplayLayout]) {
    }
    return self;
}
#pragma clang diagnostic pop

- (void)setDisplayCapabilities:(nullable SDLDisplayCapabilities *)displayCapabilities {
    [self.parameters sdl_setObject:displayCapabilities forName:SDLRPCParameterNameDisplayCapabilities];
}

- (nullable SDLDisplayCapabilities *)displayCapabilities {
    return [self.parameters sdl_objectForName:SDLRPCParameterNameDisplayCapabilities ofClass:SDLDisplayCapabilities.class error:nil];
}

- (void)setButtonCapabilities:(nullable NSArray<SDLButtonCapabilities *> *)buttonCapabilities {
    [self.parameters sdl_setObject:buttonCapabilities forName:SDLRPCParameterNameButtonCapabilities];
}

- (nullable NSArray<SDLButtonCapabilities *> *)buttonCapabilities {
    return [self.parameters sdl_objectsForName:SDLRPCParameterNameButtonCapabilities ofClass:SDLButtonCapabilities.class error:nil];
}

- (void)setSoftButtonCapabilities:(nullable NSArray<SDLSoftButtonCapabilities *> *)softButtonCapabilities {
    [self.parameters sdl_setObject:softButtonCapabilities forName:SDLRPCParameterNameSoftButtonCapabilities];
}

- (nullable NSArray<SDLSoftButtonCapabilities *> *)softButtonCapabilities {
    return [self.parameters sdl_objectsForName:SDLRPCParameterNameSoftButtonCapabilities ofClass:SDLSoftButtonCapabilities.class error:nil];
}

- (void)setPresetBankCapabilities:(nullable SDLPresetBankCapabilities *)presetBankCapabilities {
    [self.parameters sdl_setObject:presetBankCapabilities forName:SDLRPCParameterNamePresetBankCapabilities];
}

- (nullable SDLPresetBankCapabilities *)presetBankCapabilities {
    return [self.parameters sdl_objectForName:SDLRPCParameterNamePresetBankCapabilities ofClass:SDLPresetBankCapabilities.class error:nil];
}

@end

NS_ASSUME_NONNULL_END


text:
<?php
  session_start();
?>
<!DOCTYPE html>

    <meta charset="utf-8">
    <title>Sign in · EMIS</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <link href="/assets/css/bootstrap.css" rel="stylesheet">
    <link href="/assets/css/bootstrap-responsive.css" rel="stylesheet">

EMIS sign in

        <input type="text" class="input-block-level" placeholder="User Name" id="username">
        <input type="password" class="input-block-level" placeholder="Password" id="password">
        <button class="btn btn-large btn-primary" id="btnlogin" onclick="loginClicked()">Sign in</button>

       Failed to log in


text:
/* eslint-disable camelcase */
import 'core-js/stable';
import 'regenerator-runtime/runtime';

import React from 'react';
import ReactDom from 'react-dom';
import { Provider } from 'react-redux';

import config from '@fiora/config/client';
import setCssVariable from './utils/setCssVariable';
import App from './App';
import store from './state/store';
import getData from './localStorage';

// 注册 Service Worker
if (window.location.protocol === 'https:' && 'serviceWorker' in navigator) {
    window.addEventListener('load', () => {
        navigator.serviceWorker.register(`/service-worker.js`);
    });
}

// 如果配置了前端监控, 动态加载并启动监控
if (config.frontendMonitorAppId) {
    // @ts-ignore
    import(/* webpackChunkName: "frontend-monitor" */ 'wpk-reporter').then(
        (module) => {
            const WpkReporter = module.default;

            const __wpk = new WpkReporter({
                bid: config.frontendMonitorAppId,
                spa: true,
                rel: config.frontendMonitorAppId,
                uid: () => localStorage.getItem('username') || '',
                plugins: [],
            });

            __wpk.installAll();
        },
    );
}

// 更新 css variable
const { primaryColor, primaryTextColor } = getData();
setCssVariable(primaryColor, primaryTextColor);

// 请求 Notification 授权
if (
    window.Notification &&
    (window.Notification.permission === 'default' ||
        window.Notification.permission === 'denied')
) {
    window.Notification.requestPermission();
}

if (window.location.pathname !== '/') {
    const { pathname } = window.location;
    window.history.pushState({}, 'fiora', '/');
    if (pathname.startsWith('/invite/group/')) {
        const groupId = pathname.replace(`/invite/group/`, '');
        window.sessionStorage.setItem('inviteGroupId', groupId);
    }
}

ReactDom.render(
    <Provider store={store}>
        <App />
    </Provider>,
    document.getElementById('app'),
);