Most of my time on this has been spent trying to learn Java

, how JFreeChart is written and how I should incorporate the triangular support. I have done some very very basic stuff so far, before I ran into a little trouble.

My approach is that the triangular diagrams are nothing but XYPlots. So I added:

XYPlot field- Code: Select all
` /**`

* True if triangular XYPlot should be drawn

*/

private boolean ternaryPlot = false;

If it is ternary I want to change the coordinates for the values. I take the calculated coordinates and transform them further:

XYLineAndShapeRenderer.drawPrimaryLine(...)- Code: Select all
` double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation);`

double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation);

if (plot.isTernary()) {

transX0 = domainAxis.transXValueToTriangular(transX0, transY0, dataArea);

transY0 = rangeAxis.transYValueToTriangular(transY0, dataArea);

}

double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);

double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);

if (plot.isTernary()) {

transX1 = domainAxis.transXValueToTriangular(transX1, transY1, dataArea);

transY1 = rangeAxis.transYValueToTriangular(transY1, dataArea);

}

This is just the transform:

ValueAxis methods- Code: Select all
` /**`

* Converts a regular Java2D x coordinate to triangular

* @param xCoord the regular Java2D x coordinate.

* @param yCoord the regular Java2D y coordinate.

* @param area the area for plotting the data.

*

* @return The Java2D triangular x coordinate.

*

*/

public double transXValueToTriangular(double xCoord, double yCoord, Rectangle2D area) {

double xOrigin = area.getMaxX();

double yOrigin = area.getMaxY();

return xCoord + (yOrigin - yCoord)*0.5;

}

/**

* Converts a regular Java2D y coordinate to triangular

* @param yCoord the regular Java2D y coordinate.

* @param area the area for plotting the data.

*

* @return The Java2D triangular y coordinate.

*

*/

public double transYValueToTriangular(double yCoord, Rectangle2D area) {

double yOrigin = area.getMaxY();

return yOrigin - (yOrigin - yCoord)*0.8660254; // cos(30)=0.8660254

}

I am aware of that I need to add these changes in more places.

Now the plot will be drawn with triangular coordinates in a regular cartesian plot so now I have to take care of the axes and background. My thought to continue from here is to add some new "RectangleEdges" in JCommon (however they will not be particularly rectangular), and move on from there:

RectangleEdge.java- Code: Select all
` /** Left triangle. */`

public static final RectangleEdge LEFT_TRIANGLE

= new RectangleEdge("RectangleEdge.LEFT_TRIANGLE");

/** Right triangle. */

public static final RectangleEdge RIGHT_TRIANGLE

= new RectangleEdge("RectangleEdge.RIGHT_TRIANGLE");

But now I realized that I can't control the aspect ratios of the lengths (in pixels) of the axes, nor can I by default control the size of the dataarea. I want the triangular diagrams equilateral all the time, and the user must be able to resize the window, so I have to be able to do that. It turned out that

paradoxoff has released a patch that enables you to control the size of the data area, however that approach shows unexpected behavior because the JFrame does not respect the resizing ChartPanel so the size on screen will not automatically be what you want it to be. Then we have the aspect ratio control, which Dave himself

found to be tricky to implement.

So now two essential features are missing and people much more experienced in java than I am find them difficult to implement. Did you hear that sound of me hitting a wall?

What to do?