// Copyright 2018, University of Colorado Boulder

/**
 * Graph for the 'Explore' screen.
 *
 * @author Chris Malley (PixelZoom, Inc.)
 */
define( require => {
  'use strict';

  // modules
  const GQConstants = require( 'GRAPHING_QUADRATICS/common/GQConstants' );
  const GQGraphNode = require( 'GRAPHING_QUADRATICS/common/view/GQGraphNode' );
  const graphingQuadratics = require( 'GRAPHING_QUADRATICS/graphingQuadratics' );
  const QuadraticNode = require( 'GRAPHING_QUADRATICS/common/view/QuadraticNode' );

  class ExploreGraphNode extends GQGraphNode {

    /**
     * @param {GQModel} model
     * @param {ExploreViewProperties} viewProperties
     * @param {Object} [options]
     */
    constructor( model, viewProperties, options ) {

      options = options || {};

      const termNodeOptions = {
        lineWidth: GQConstants.QUADRATIC_TERMS_LINE_WIDTH
      };

      // constant term, y = bx
      const constantTermNode = new QuadraticNode(
        model.constantTermProperty,
        model.graph.xRange,
        model.graph.yRange,
        model.modelViewTransform,
        viewProperties.equationForm,
        viewProperties.equationsVisibleProperty,
        termNodeOptions );
      viewProperties.constantTermVisibleProperty.link( visible => { constantTermNode.visible = visible; } );

      // linear term, y = bx
      const linearTermNode = new QuadraticNode(
        model.linearTermProperty,
        model.graph.xRange,
        model.graph.yRange,
        model.modelViewTransform,
        viewProperties.equationForm,
        viewProperties.equationsVisibleProperty,
        termNodeOptions );
      viewProperties.linearTermVisibleProperty.link( visible => { linearTermNode.visible = visible; } );

      // quadratic term, y = ax^2
      const quadraticTermNode = new QuadraticNode(
        model.quadraticTermProperty,
        model.graph.xRange,
        model.graph.yRange,
        model.modelViewTransform,
        viewProperties.equationForm,
        viewProperties.equationsVisibleProperty,
        termNodeOptions );
      viewProperties.quadraticTermVisibleProperty.link( visible => { quadraticTermNode.visible = visible; } );

      assert && assert( !options.specialLines, 'ExploreGraphNode sets specialLines' );
      options.specialLines = [ constantTermNode, linearTermNode, quadraticTermNode ]; // rendered in this order

      super( model, viewProperties, options );
    }
  }

  return graphingQuadratics.register( 'ExploreGraphNode', ExploreGraphNode );
} );
@@ -879,24 +879,25 @@
      // 
-constant
+quadratic
  term, y
@@ -891,34 +891,36 @@
 ratic term, y = 
-bx
+ax%5E2
 %0A      const con
@@ -916,24 +916,25 @@
   const 
-constant
+quadratic
 TermNode
@@ -969,24 +969,25 @@
   model.
-constant
+quadratic
 TermProp
@@ -1216,24 +1216,25 @@
 perties.
-constant
+quadratic
 TermVisi
@@ -1264,24 +1264,25 @@
 le =%3E %7B 
-constant
+quadratic
 TermNode
@@ -1732,33 +1732,32 @@
 ;%0A%0A      // 
-quadratic
+constant
  term, y = a
@@ -1747,36 +1747,34 @@
 stant term, y = 
-ax%5E2
+bx
 %0A      const qua
@@ -1766,33 +1766,32 @@
       const 
-quadratic
+constant
 TermNode = n
@@ -1818,33 +1818,32 @@
       model.
-quadratic
+constant
 TermProperty
@@ -2064,33 +2064,32 @@
 wProperties.
-quadratic
+constant
 TermVisibleP
@@ -2111,33 +2111,32 @@
 isible =%3E %7B 
-quadratic
+constant
 TermNode.vis
@@ -2152,24 +2152,30 @@
 sible; %7D );%0A
+      
 %0A      asser

reorder instantiation of term nodes