Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/francy/js/packages/francy-core/src/render/   (Algebra von RWTH Aachen Version 4.15.1©)  Datei vom 17.3.2023 mit Größe 3 kB image not shown  

Quelle  base.js   Sprache: JAVA

 
import DataHandler from '../util/data-handler';
import {Decorators} from '../decorator/factory';
import {Exception} from '../util/exception';
import {Logger} from '../util/logger';

/**
 * Base is the base of renderers and contains multiple utility methods.
 *
 * @extends {DataHandler}
 */

export default class BaseRenderer extends DataHandler {

  /**
   * Base constructor
   *
   * @typedef {Object} options
   * @property {String} options.appendTo - where the generated html/svg components will be attached to, default body
   * @property {Function} options.callbackHandler - this handler will be used to invoke actions from the menu, default console.log
   * @property {Object} context - the context of the application, usually a configuration and a rendering manager instance
   */

  constructor({appendTo = 'body', callbackHandler}, context = {}) {
    super();
    /**
     * @typedef {Object} Options
     * @property {Boolean} appendTo where the generated html/svg components will be attached to, default body
     * @property {Function} callbackHandler this handler will be used to invoke actions from the menu, default console.log
     */

    this.options = undefined;
    this.settings({appendTo: appendTo, callbackHandler: callbackHandler});
    this.context = context;
  }

  /**
   * Returns the parent element of this class
   *
   * @return {object} a d3 object
   * @public
   */

  get parent() {
    return this.options.appendTo.element;
  }

  /**
   * Returns the parent class of this class
   *
   * @return {Renderer} the {Renderer} or {Composite} parent of this class
   * @public
   */

  get parentClass() {
    return this.options.appendTo;
  }

  /**
   * Generic error handler.
   * Will log the error and rethrow if error is unknown.
   *
   * @param {Error} error - an error instance
   * @public
   */

  static handleErrors(error) {
    if (error instanceof Exception) {
      // well, most of these are just informative
      Logger.debug(error.message);
      return;
    }
    Logger.error(error.message);
    throw error;
  }

  /**
   * Saves the settings in an internal options object.
   *
   * @typedef {Object} options
   * @property {Boolean} options.appendTo - where the generated html/svg components will be attached to, default body
   * @property {Function} options.callbackHandler - this handler will be used to invoke actions from the menu, default console.log
   * @returns {object} this instance
   * @public
   */

  settings({appendTo, callbackHandler}) {
    this.options = this.options || {};
    if (!this.options.callbackHandler && !callbackHandler) {
      throw new Error('A Callback Handler must be provided! This will be used to trigger events from the graphics produced...');
    }
    if (!this.options.appendTo && !appendTo) {
      throw new Error('Missing an element or id to append the graphics to!');
    }
    if (appendTo && !appendTo.element) {
      appendTo = {element: d3.select(appendTo)};
    }
    this.options.appendTo = appendTo || this.options.appendTo;
    this.options.callbackHandler = callbackHandler || this.options.callbackHandler;
    return this;
  }

  /**
   * Returns the current mouse position.
   *
   * @protected
   */

  getMousePosition(e) {
    return [Number(e && e.layerX || 0), Number(e && e.layerY || 0)];
  }

  /**
   * Generic Promise handler.
   * This will show the Loader/Spinner on the application while processing.
   *
   * @param {Promise} promise - a promise to execute
   * @return {Object} the result of the promise
   * @public
   */

  handlePromise(promise) {
    let loader = Decorators.Loader.withContext(this).show();
    return promise
      .then(data => data)
      .catch(error => BaseRenderer.handleErrors(error))
      .finally(() => loader.hide());
  }

}

Messung V0.5
C=91 H=91 G=90

¤ Dauer der Verarbeitung: 0.15 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.