Reputation: 75
I'm beginner for Eclipse plug-in development.
I had developed some Eclipse plug-in using Nebula that provide extended view component such as graphs, table, etc.
I wanna draw three components in the view (using MeterFigure, List of SWT, XYGraph).
However, when I created three components, there is blank in the view!
So, I inspect my code, but I couldn't find where is problem.
This is capture of blank (see the space between figure and text).
This is code for creating three components.
@Override
public void createPartControl(Composite parent) {
...
GridLayout layout = new GridLayout(1, true);
parent.setLayout(layout);
parent.setLayoutData(new GridData(GridData.GRAB_VERTICAL));
merterFigure = new merterFigureClass(parent, SWT.NONE);
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
merterFigure.setLayoutData(gridData);
list = new ListClass(parent, SWT.NONE);
gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
list.setLayoutData(gridData);
list.initialize();
graph = new GraphClass(parent, SWT.NONE);
gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
graph.setLayoutData(gridData);
list.setGraph(graph);
}
This is MeterFigureClass.
public class MeterFigureClass extends Canvas {
private MeterFigure meterFigure;
public MeterFigureClass(Composite parent, int style) {
super(parent, style);
LightweightSystem lws = new LightweightSystem(this);
meterFigure = new MeterFigure();
meterFigure.setBackgroundColor(XYGraphMediaFactory.getInstance().getColor(255, 255, 255));
meterFigure.setValueLabelVisibility(true);
meterFigure.setRange(0, 100);
meterFigure.setLoLevel(35);
meterFigure.setLoloLevel(20);
meterFigure.setHiLevel(85);
meterFigure.setHihiLevel(70);
meterFigure.setMajorTickMarkStepHint(80);
lws.setContents(readabilityScore);
}
public void setValue(double value) {
this.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
meterFigure.setValue(value);
}
});
}
}
This is ListClass.
public class ListClass extends Canvas {
private org.eclipse.swt.widgets.List list;
private List<Data> dataList;
private GraphClass graph;
public ListClass(Composite parent, int style) {
super(parent, style);
list = new org.eclipse.swt.widgets.List(parent, SWT.V_SCROLL | SWT.H_SCROLL);
dataList = new ArrayList<Data>();
...
GridData gridData = new GridData();
gridData.horizontalAlignment = SWT.FILL;
gridData.verticalAlignment = SWT.FILL;
list.setLayoutData(gridData);
}
....
public void setGraph(GraphClass Graph) {
this.Graph = Graph;
}
....
}
This is GraphClass.
ublic class MatrixGraph extends Canvas {
private char count;
private XYGraph matrixGraph;
private LightweightSystem lws;
public MatrixGraph(Composite parent, int style) {
super(parent, style);
addPaintListener(new PaintListener() {
@Override
public void paintControl(org.eclipse.swt.events.PaintEvent e) {
MatrixGraph.this.paintControl(e);
}
});
}
public void paintControl(PaintEvent e) {
if (count < 1)
count++;
else {
lws = new LightweightSystem(this);
matrixGraph = new XYGraph();
setGraphProperties();
}
}
...
}
Upvotes: 1
Views: 98
Reputation: 111217
In your GridData
layout you are specifying:
gridData.grabExcessVerticalSpace = true;
This is telling the layout to grab as much vertical space as possible even though it may only be blank. Since you are specifying this for multiple controls the extra space is divided between the controls.
If you don't want the blank space use
gridData.grabExcessVerticalSpace = false;
or just omit this as it is the default.
Also try not using FILL for the vertical alignment, TOP would probably be better:
gridData.verticalAlignment = SWT.TOP;
Upvotes: 2