private void DeterminePhysicalAxesToDraw(Rectangle bounds, Axis xAxis1, Axis xAxis2, Axis yAxis1, Axis yAxis2,
out PhysicalAxis pXAxis1, out PhysicalAxis pXAxis2, out PhysicalAxis pYAxis1, out PhysicalAxis pYAxis2)
{
Rectangle cb = bounds;
pXAxis1 = new PhysicalAxis(xAxis1, new Point(cb.Left, cb.Bottom), new Point(cb.Right, cb.Bottom));
pYAxis1 = new PhysicalAxis(yAxis1, new Point(cb.Left, cb.Bottom), new Point(cb.Left, cb.Top));
pXAxis2 = new PhysicalAxis(xAxis2, new Point(cb.Left, cb.Top), new Point(cb.Right, cb.Top));
pYAxis2 = new PhysicalAxis(yAxis2, new Point(cb.Right, cb.Bottom), new Point(cb.Right, cb.Top));
int bottomIndent = m_padding;
if (!pXAxis1.Axis.Hidden)
{
// evaluate its bounding box
Rectangle bb = pXAxis1.GetBoundingBox();
// finally determine its indentation from the bottom
bottomIndent = bottomIndent + bb.Bottom - cb.Bottom;
}
int leftIndent = m_padding;
if (!pYAxis1.Axis.Hidden)
{
// evaluate its bounding box
Rectangle bb = pYAxis1.GetBoundingBox();
// finally determine its indentation from the left
leftIndent = leftIndent - bb.Left + cb.Left;
}
int topIndent = m_padding;
float scale = DetermineScaleFactor(bounds.Width, bounds.Height);
int titleHeight;
if (AutoScaleTitle)
{
titleHeight = Utils.ScaleFont(m_titleFont, scale).Height;
}
else
{
titleHeight = m_titleFont.Height;
}
//count number of new lines in title.
int nlCount = 0;
for (int i = 0; i < m_title.Length; ++i)
{
if (m_title[i] == '\n')
nlCount += 1;
}
titleHeight = (int)(((float)nlCount * 0.75 + 1.0f) * (float)titleHeight);
if (!pXAxis2.Axis.Hidden)
{
// evaluate its bounding box
Rectangle bb = pXAxis2.GetBoundingBox();
topIndent = topIndent - bb.Top + cb.Top;
// finally determine its indentation from the top
// correct top indendation to take into account plot title
if (m_title != "")
{
topIndent += (int)(titleHeight * 1.3f);
}
}
int rightIndent = m_padding;
if (!pYAxis2.Axis.Hidden)
{
// evaluate its bounding box
Rectangle bb = pYAxis2.GetBoundingBox();
// finally determine its indentation from the right
rightIndent = (int)(rightIndent + bb.Right - cb.Right);
}
// now we have all the default calculated positions and we can proceed to
// "move" the axes to their right places
// primary axes (bottom, left)
pXAxis1.PhysicalMin = new Point(cb.Left + leftIndent, cb.Bottom - bottomIndent);
pXAxis1.PhysicalMax = new Point(cb.Right - rightIndent, cb.Bottom - bottomIndent);
pYAxis1.PhysicalMin = new Point(cb.Left + leftIndent, cb.Bottom - bottomIndent);
pYAxis1.PhysicalMax = new Point(cb.Left + leftIndent, cb.Top + topIndent);
// secondary axes (top, right)
pXAxis2.PhysicalMin = new Point(cb.Left + leftIndent, cb.Top + topIndent);
pXAxis2.PhysicalMax = new Point(cb.Right - rightIndent, cb.Top + topIndent);
pYAxis2.PhysicalMin = new Point(cb.Right - rightIndent, cb.Bottom - bottomIndent);
pYAxis2.PhysicalMax = new Point(cb.Right - rightIndent, cb.Top + topIndent);
}