<!-- Begin

// Copyright (c) 2007-2008 Hydrix except otherwise noted. All rights reserved
// www.hydrix.com

// ---------------------------------------------------------------------------
// GraphWindow1D OBJECT
// ---------------------------------------------------------------------------

// Constructor.
function GraphWindow1D()
{	// Base data.
	this.scale = new Scale125();
}

// Base setters.
GraphWindow1D.prototype.setSize = function(size_px, reversed)
{
	this.scale.setSize(size_px, reversed);
}
GraphWindow1D.prototype.setCenter = function(center_u)
{
	this.scale.setCenter(center_u);
}
GraphWindow1D.prototype.setScaleIndex = function(scale_index)
{
	this.scale.setScaleIndex(scale_index);
}
GraphWindow1D.prototype.setScale = function(scale)
{
	this.scale.setScale(scale);
}
GraphWindow1D.prototype.setBorders = function(min, max)
{
	this.scale.setBorders(min, max);
}
// Copy constructor.
function GraphWindow1DCopy(gw)
{
	var gw2 = new GraphWindow1D();
	gw2.scale = Scale125Copy(gw.scale);
	return gw2;
}

// Round a coordinate in units to the closest middle of pixel.
GraphWindow1D.prototype.roundUnitsToScale = function (u)
{
	return this.scale.roundUnitsToScale(u);
}

GraphWindow1D.prototype.getUnitPerPixel = function()
{
	return this.scale.unit_per_point;
}
GraphWindow1D.prototype.getMin = function()
{
	return this.scale.getMin();
}
GraphWindow1D.prototype.getMax = function()
{
	return this.scale.getMax();
}

// Coordinate in units -> Pixel in viewer (not rounded!).
GraphWindow1D.prototype.unitsToPixels = function(u)
{
	return this.scale.unitsToPoints(u);
}
// Pixel in viewer -> Coordinate in units.
GraphWindow1D.prototype.pixelsToUnits = function(p)
{
	return this.scale.pointsToUnits(p);
}

// Positive increment = zoom out.
GraphWindow1D.prototype.zoom = function(increment)
{
	this.scale.zoom(increment);
}
// t>0 -> Towards max.
GraphWindow1D.prototype.translatePixels = function(t_px)
{
	this.scale.translatePoints(t_px);
}
GraphWindow1D.prototype.centerAtPixel = function(px)
{
	this.scale.centerAtPoint(px);
}
GraphWindow1D.prototype.centerAndZoom = function(px, increment)
{
	this.scale.centerAndZoom(px, increment);
}
GraphWindow1D.prototype.reset = function()
{
	this.scale.reset();
}

// ---------------------------------------------------------------------------
// GraphWindow OBJECT
// ---------------------------------------------------------------------------

function GraphWindow()
{
	this.x = new GraphWindow1D();
	this.y = new GraphWindow1D();
	this.x.setSize(VIEWER_WIDTH, false);
	this.y.setSize(VIEWER_HEIGHT, true);
}
GraphWindow.prototype.setBorders = function(xmin, xmax, ymin, ymax)
{
	this.x.setBorders(xmin, xmax);
	this.y.setBorders(ymin, ymax);
}
function GraphWindowCopy(gw)
{
	n = new GraphWindow();
	n.x.setCenter(gw.x.scale.center);
	n.x.setScaleIndex(gw.x.scale.scale_index);
	n.y.setCenter(gw.y.scale.center);
	n.y.setScaleIndex(gw.y.scale.scale_index);
	return n;
}

GraphWindow.prototype.unitsToPixels = function(x_u, y_u)
{
	return { x_px: this.x.unitsToPixels(x), y_px: this.y.unitsToPixels(y) };
}
GraphWindow.prototype.pixelsToUnits = function(x_px, y_px)
{
	return { x_u: this.x.pixelsToUnits(x_px), y_u: this.y.pixelsToUnits(y_px) };
}

GraphWindow.prototype.zoom = function(increment)
{
	this.x.zoom(increment);
	this.y.zoom(increment);
}
// tx>0 -> To the right.
GraphWindow.prototype.translatePixels = function(tx_px, ty_px)
{
	this.x.translatePixels(tx_px);
	this.y.translatePixels(ty_px);
}
GraphWindow.prototype.center = function(x_px, y_px)
{
	this.x.centerAtPixel(x_px);
	this.y.centerAtPixel(y_px);
}
GraphWindow.prototype.centerAndZoom = function(x_px, y_px, increment)
{
	this.x.centerAndZoom(x_px, increment);
	this.y.centerAndZoom(y_px, increment);
}
GraphWindow.prototype.reset = function()
{
	this.x.reset();
	this.y.reset();
}
