[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Relative sizing and scaling with a FormLayout
|
- From: adam.preble@xxxxxxxxx (Adam Preble)
- Date: Sun, 29 Jun 2008 17:48:37 +0000 (UTC)
- Newsgroups: eclipse.platform.swt
- Organization: Eclipse
- User-agent: NewsPortal/0.36 (http://florian-amrhein.de/newsportal)
I have been doing some charting with canvases. Right now, most of the
chart is done in its own composite, with the x-axis hanging on outside of
that. The idea is eventually I might have two charts sharing one x-axis,
so that's why I have it excluded. But this is making drawing the final
chart a little strange to me. I'm still new to my layouts, so keep that
in mind.
Here's the snippet doing the work:
FormLayout chartLayout = new FormLayout();
Composite chart1Comp = new Composite(shell, SWT.PUSH);
Composite xAxis = new Composite(shell, SWT.PUSH);
// chart1 and bottom are set here
chart1 = new FinancialLineChart(this, chart1Comp, display, data);
bottom = new XAxis(0, data[0].size(), xAxis, display);
FormData chart1Form = new FormData();
chart1Form.top = new FormAttachment(0, 0);
chart1Form.bottom = new FormAttachment(0, 299);
chart1Form.left = new FormAttachment(0, 0);
chart1Form.right = new FormAttachment(100, 0);
chart1Comp.setLayoutData(chart1Form);
FormData xAxisForm = new FormData();
xAxisForm.top = new FormAttachment(chart1Comp, 0);
xAxisForm.bottom = new FormAttachment(0, 399);
xAxisForm.left = new FormAttachment(0, 99);
xAxisForm.right = new FormAttachment(100, -150);
xAxis.setLayoutData(xAxisForm);
shell.setLayout(chartLayout);
So the x-axis starts 300 pixels down and a little bit indented on either
side since it only draws across the actual plotting area. This is one
reason I was using a FormLayout. The other was the x-axis doesn't have to
be as large as the charting body, which the layouts that do vertical
scaling like to keep equal.
If I expand the window to the right, everything scales fine. If I try to
expand vertically, nothing scales. My listener for the chart is called
but it cannot expand since it doesn't get a larger drawing area. It seems
like my x-axis there is pinning it in. Is there a way to get the layout
to appropriately scale everything? I don't want the x-axis to get larger
vertically, rather the chart body should expand. Or do I have to code a
PaintListener for this object?