2

I'm using JChart2D for visualization. I would like to make the X and Y axis equal in terms of pixels. By doing so its much easier to see how far the points are from each other in euclidean distance (see image). As it is now, the x-axis is more stretched out. They already have the same range in terms of values.

The framesize defines the pixel values right now, i.e: jFrame.setSize(800,600);. Everything then dynamically fits inside the frame where the Chart2D resize itself to make space. I find the pixels manually, but that seems stupid. Also, if i have a scenario with a lot of clusters, the legends line will wrap and thus resize the chart.

I've googled a lot and looked at the documentation, but I've been unable to find a solution.

So how do i set the chart to a fixed size, that's independent from the other items in the frame?

Image example:

Bjerrum
  • 108
  • 6

2 Answers2

1

What do you expect if you would make it and still insist on the JFrame to be non-rectanguar to be displayed in the remaining 200 px in x range? The void grey?

You could achieve this e.g. by setting a GridBagLayout to the JFrame.getContentPane() and define a grid of two vertical cells - one grid to take 600px x 600px and the second to take 200px x 600px. But then you have the void in the 2nd pane. HTH, Achim

yacc
  • 2,915
  • 4
  • 19
  • 33
0

By doing so its much easier to see how far the points are from each other in euclidean distance

not really, the Euclidean Distance requires at the end the position of the 2 points you are calculating and you have it... otherwise you wouldnt be able to plot anything in the canvas..

another aproach that you can use is implement a ViewPort over the canvas but that makes sense only for zoom in/out images and tht is not your case...

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
  • "not really, the Euclidean Distance requires at the end the position of the 2 points you are calculating and you have it... otherwise you wouldnt be able to plot anything in the canvas.." I think you misunderstood me. I use this for visualization. Each point conceptually have an invisible circle around them where i count the amount of points within the circle. Calculation wise that's no issue, but if the axes does not represent the same euclidean distance pr pixel, then its confusing for humans. Then i'm looking at an ellipse that actually is a circle. Hope it makes sense :) – Bjerrum Sep 13 '16 at 15:51