<commit_before>/**
 * Created by sam on 30.01.2015.
 */
import d3 = require('d3');
import $ = require('jquery');
import C = require('../caleydo_core/main');
import multiform = require('../caleydo_core/multiform');
import geom = require('../caleydo_core/geom');
import idtypes = require('../caleydo_core/idtype');
import behaviors = require('../caleydo_core/behavior');
import events = require('../caleydo_core/event');
import layout = require('../caleydo_core/layout');
import link_m = require('../caleydo_links/link');
import layouts = require('../caleydo_d3/layout_d3util');
import datatypes = require('../caleydo_core/datatype');
import prov = require('../caleydo_provenance/main');
import ranges = require('../caleydo_core/range');

//guess initial vis method
function guessInitial(desc):any {
  if (desc.type === 'matrix') {
    return 'caleydo-vis-heatmap';
  }
  if (desc.type === 'vector' && desc.value.type === 'int' && desc.name.toLowerCase().indexOf('daystodeath') >= 0) {
    return 'caleydo-vis-kaplanmeier';
  }
  if (desc.type === 'vector') {
    return desc.value.type === 'categorical' ? 'caleydo-vis-mosaic' : 'caleydo-vis-heatmap1d';
  }
  if (desc.type === 'stratification') {
    return 'caleydo-vis-mosaic';
  }
  return -1;
}

//create a manager for all columns
export const manager = new idtypes.ObjectManager<Column>('_column', 'Column');


function createColumn(inputs, parameter, graph) {
  var stratomex = inputs[0].value,
    partitioning = ranges.parse(parameter.partitioning),
    index = parameter.hasOwnProperty('index') ? parameter.index : -1 ;
  return inputs[1].v.then(function (data) {
    var c = new Column(stratomex, data, partitioning, {
      width: (data.desc.type === 'stratification') ? 80 : 160
    });
    var r = prov.ref(c, 'Column of ' + data.desc.name, prov.cat.visual);
    c.changeHandler = function (event, to, from) {
      if (from) { //have a previous one so not the default
        console.log('fire change vis');
        graph.push(createChangeVis(r, to.id, from ? from.id : null));
      }
    };
    c.optionHandler = function (event, name, value, bak) {
      graph.push(createSetOption(r, name, value, bak));
    };
    c.on('changed', c.changeHandler);
    c.on('option', c.optionHandler);

    return stratomex.addColumn(r, index).then(() => {
      return {
        created: [r],
        inverse: createRemoveCmd(inputs[0], r)
      };
    });
  });
}
function removeColumn(inputs, parameter, graph) {
  var column = inputs[1].value
  return inputs[0].value.removeColumn(inputs[1]).then((index) => {
    const inv = createColumnCmd(inputs[0], graph.findObject(column.data), column.range.toString(), index);<commit_msg>styling<commit_after>/**
 * Created by sam on 30.01.2015.
 */
import d3 = require('d3');
import $ = require('jquery');
import C = require('../caleydo_core/main');
import multiform = require('../caleydo_core/multiform');
import geom = require('../caleydo_core/geom');
import idtypes = require('../caleydo_core/idtype');
import behaviors = require('../caleydo_core/behavior');
import events = require('../caleydo_core/event');
import layout = require('../caleydo_core/layout');
import link_m = require('../caleydo_links/link');
import layouts = require('../caleydo_d3/layout_d3util');
import datatypes = require('../caleydo_core/datatype');
import prov = require('../caleydo_provenance/main');
import ranges = require('../caleydo_core/range');

//guess initial vis method
function guessInitial(desc):any {
  if (desc.type === 'matrix') {
    return 'caleydo-vis-heatmap';
  }
  if (desc.type === 'vector' && desc.value.type === 'int' && desc.name.toLowerCase().indexOf('daystodeath') >= 0) {
    return 'caleydo-vis-kaplanmeier';
  }
  if (desc.type === 'vector') {
    return desc.value.type === 'categorical' ? 'caleydo-vis-mosaic' : 'caleydo-vis-heatmap1d';
  }
  if (desc.type === 'stratification') {
    return 'caleydo-vis-mosaic';
  }
  return -1;
}

//create a manager for all columns
export const manager = new idtypes.ObjectManager<Column>('_column', 'Column');


function createColumn(inputs, parameter, graph) {
  var stratomex = inputs[0].value,
    partitioning = ranges.parse(parameter.partitioning),
    index = parameter.hasOwnProperty('index') ? parameter.index : -1 ;
  return inputs[1].v.then(function (data) {
    var c = new Column(stratomex, data, partitioning, {
      width: (data.desc.type === 'stratification') ? 80 : 160
    });
    var r = prov.ref(c, 'Column of ' + data.desc.name, prov.cat.visual);
    c.changeHandler = function (event, to, from) {
      if (from) { //have a previous one so not the default
        console.log('fire change vis');
        graph.push(createChangeVis(r, to.id, from ? from.id : null));
      }
    };
    c.optionHandler = function (event, name, value, bak) {
      graph.push(createSetOption(r, name, value, bak));
    };
    c.on('changed', c.changeHandler);
    c.on('option', c.optionHandler);

    return stratomex.addColumn(r, index).then(() => {
      return {
        created: [r],
        inverse: createRemoveCmd(inputs[0], r)
      };
    });
  });
}
function removeColumn(inputs, parameter, graph) {
  var column = inputs[1].value;
  return inputs[0].value.removeColumn(inputs[1]).then((index) => {
    const inv = createColumnCmd(inputs[0], graph.findObject(column.data), column.range.toString(), index);
{'fraction_non_alphanumeric': 0.17658027223568898, 'fraction_numerical': 0.0104419168375909, 'mean_word_length': 3.7935656836461127, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '29834', 'n_tokens_mistral': 1827, 'n_tokens_neox': 1751, 'n_words': 377}