<commit_before>/**
 *
 *  Copyright 2016 Netflix, Inc.
 *
 *     Licensed under the Apache License, Version 2.0 (the "License");
 *     you may not use this file except in compliance with the License.
 *     You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *     Unless required by applicable law or agreed to in writing, software
 *     distributed under the License is distributed on an "AS IS" BASIS,
 *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *     See the License for the specific language governing permissions and
 *     limitations under the License.
 *
 */
/* global __HIDE_DATA__ */
import {
  each, filter, get, map, sum
} from 'lodash';
import * as THREE from 'three';
import numeral from 'numeral';

import GlobalDefinitions from '../globalDefinitions';
import GlobalStyles from '../globalStyles';
import NodeView from '../base/nodeView';
import NodeNameView from '../base/nodeNameView';
import ShapeParent from '../base/shapes/ShapeParent';

const Console = console;

const arcMeterWidth = 15;

function generateDisplayValue (value, format) {
  value = value || 0;

  let displayValue = value;
  if (format) { displayValue = numeral(value).format(format); }

  // If we're hiding data, don't need to hide percentages
  if (__HIDE_DATA__ && displayValue.indexOf('%') === -1) {
    displayValue = displayValue.replace(/[0-9]/g, '#');
  }
  return displayValue;
}

const zAxis = new THREE.Vector3(0, 0, 1);

class FocusedNodeView extends NodeView {
  constructor (service) {
    super(service);

    this.surfaceDepth = 10;

    this.borderColor = GlobalStyles.rgba.colorPageBackground;
    this.borderColorThree = new THREE.Color(this.borderColor.r, this.borderColor.g, this.borderColor.b);
    this.donutMaterial = new THREE.MeshBasicMaterial({ color: this.borderColorThree, transparent: true, opacity: this.borderColor.a });
    this.innerBorderMaterial = new THREE.MeshBasicMaterial({ color: this.borderColorThree, transparent: true, opacity: this.borderColor.a });
    this.donutGraphSegments = [];
    this.arcMeterSegments = [];

    this.radius = this.object.size;
    this.curveSegments = 32; // Eventually, use shape to select this, e.g. 32 for circle, 4 for square, etc.
    this.innerRadius = this.radius * 0.8;

    this.meshes.outerBorder = this.addChildElement(ShapeParent.getOuterBorderGeometry(this.radius, this.curveSegments), this.borderMaterial);
    this.meshes.innerCircle = this.addChildElement(ShapeParent.getInnerCircleGeometry(this.radius, this.curveSegments), this.innerCircleMaterial);
    this.meshes.innerCircle.position.setZ(-10);
    this.meshes.donut = this.addChildElement(NodeView.getDonutGeometry(this.radius, this.innerRadius), this.donutMaterial, 'donut');
    this.meshes.innerBorder = this.addChildElement(NodeView.getInnerBorderGeometry(this.innerRadius), this.borderMaterial);
    this.meshes.innerBorder.position.setZ(100);

    // Add the service name
    if ((this.object.graphRenderer === 'global' && !this.object.isEntryNode())
        || this.object.graphRenderer === 'region') {
      this.nameView = new NodeNameView(this, this.object.graphRenderer === 'global');
      this.showLabel(this.object.options.showLabel);
    }

    this.canvasWidth = this.innerRadius * 2;
    this.canvasHeight = this.canvasWidth * 0.53;
    this.metricSpacing = this.canvasHeight * 0.1;
    this.headerFontSize = (this.canvasHeight - this.metricSpacing) * 0.2;
    this.metricFontSize = (this.canvasHeight - this.metricSpacing) * 0.3;
    this.addText();

    if (!this.object.loaded) {
      this.setupLoadingAnimation();
    }

    this.updateDetailedMode();

    // check if we have arc meters...
    const hasArcMeter = this.detailed.arc && this.detailed.arc.data;
    if (hasArcMeter) {
      // arc background
      const { mesh } = this.addArcSlice(0, 1, GlobalStyles.rgba.colorArcBackground, true);
      this.meshes.arcBackground = mesh;<commit_msg>Show label for all nodes with displayName (#117)<commit_after>/**
 *
 *  Copyright 2016 Netflix, Inc.
 *
 *     Licensed under the Apache License, Version 2.0 (the "License");
 *     you may not use this file except in compliance with the License.
 *     You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *     Unless required by applicable law or agreed to in writing, software
 *     distributed under the License is distributed on an "AS IS" BASIS,
 *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *     See the License for the specific language governing permissions and
 *     limitations under the License.
 *
 */
/* global __HIDE_DATA__ */
import {
  each, filter, get, map, sum
} from 'lodash';
import * as THREE from 'three';
import numeral from 'numeral';

import GlobalDefinitions from '../globalDefinitions';
import GlobalStyles from '../globalStyles';
import NodeView from '../base/nodeView';
import NodeNameView from '../base/nodeNameView';
import ShapeParent from '../base/shapes/ShapeParent';

const Console = console;

const arcMeterWidth = 15;

function generateDisplayValue (value, format) {
  value = value || 0;

  let displayValue = value;
  if (format) { displayValue = numeral(value).format(format); }

  // If we're hiding data, don't need to hide percentages
  if (__HIDE_DATA__ && displayValue.indexOf('%') === -1) {
    displayValue = displayValue.replace(/[0-9]/g, '#');
  }
  return displayValue;
}

const zAxis = new THREE.Vector3(0, 0, 1);

class FocusedNodeView extends NodeView {
  constructor (service) {
    super(service);

    this.surfaceDepth = 10;

    this.borderColor = GlobalStyles.rgba.colorPageBackground;
    this.borderColorThree = new THREE.Color(this.borderColor.r, this.borderColor.g, this.borderColor.b);
    this.donutMaterial = new THREE.MeshBasicMaterial({ color: this.borderColorThree, transparent: true, opacity: this.borderColor.a });
    this.innerBorderMaterial = new THREE.MeshBasicMaterial({ color: this.borderColorThree, transparent: true, opacity: this.borderColor.a });
    this.donutGraphSegments = [];
    this.arcMeterSegments = [];

    this.radius = this.object.size;
    this.curveSegments = 32; // Eventually, use shape to select this, e.g. 32 for circle, 4 for square, etc.
    this.innerRadius = this.radius * 0.8;

    this.meshes.outerBorder = this.addChildElement(ShapeParent.getOuterBorderGeometry(this.radius, this.curveSegments), this.borderMaterial);
    this.meshes.innerCircle = this.addChildElement(ShapeParent.getInnerCircleGeometry(this.radius, this.curveSegments), this.innerCircleMaterial);
    this.meshes.innerCircle.position.setZ(-10);
    this.meshes.donut = this.addChildElement(NodeView.getDonutGeometry(this.radius, this.innerRadius), this.donutMaterial, 'donut');
    this.meshes.innerBorder = this.addChildElement(NodeView.getInnerBorderGeometry(this.innerRadius), this.borderMaterial);
    this.meshes.innerBorder.position.setZ(100);

    // Add the service name
    if ((this.object.graphRenderer === 'global' && !this.object.isEntryNode())
        || this.object.graphRenderer === 'region' || this.object.displayName) {
      this.nameView = new NodeNameView(this, this.object.graphRenderer === 'global');
      this.showLabel(this.object.options.showLabel);
    }

    this.canvasWidth = this.innerRadius * 2;
    this.canvasHeight = this.canvasWidth * 0.53;
    this.metricSpacing = this.canvasHeight * 0.1;
    this.headerFontSize = (this.canvasHeight - this.metricSpacing) * 0.2;
    this.metricFontSize = (this.canvasHeight - this.metricSpacing) * 0.3;
    this.addText();

    if (!this.object.loaded) {
      this.setupLoadingAnimation();
    }

    this.updateDetailedMode();

    // check if we have arc meters...
    const hasArcMeter = this.detailed.arc && this.detailed.arc.data;
    if (hasArcMeter) {
      // arc background
      const { mesh } = this.addArcSlice(0, 1, GlobalStyles.rgba.colorArcBackground, true);
      this.meshes.arcBackground = mesh;
{'fraction_non_alphanumeric': 0.12123849788609799, 'fraction_numerical': 0.011315593136035812, 'mean_word_length': 3.793206197854589, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6621726', 'n_tokens_mistral': 2460, 'n_tokens_neox': 2360, 'n_words': 607}