1
我是Eclipse插件開發的初學者。如何刪除Eclipse插件中的空白空間?
我已經開發了一些Eclipse插件使用星雲在於提供擴展視圖分量例如圖形,表格等
我想繪製在視圖中三種組分(使用MeterFigure,SWT的列表,XYGraph)。
但是,當我創建三個組件時,視圖中有空白!
所以,我檢查我的代碼,但我找不到問題在哪裏。
這是創建三個組件的代碼。
@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);
}
這是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);
}
});
}
}
這是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;
}
....
}
這是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();
}
}
...
}
非常感謝你。爲了你的回答,我試了你的答案,但它仍然存在。它只是減少空白的大小.... – user3649231
嘗試更改垂直對齊以及 - 看到更新的答案。我沒有安裝所有的東西,所以我無法測試它。但是您需要了解更多關於GridLayout的知識,並查看每個組件的佈局。 –
嗯......謝謝你的建議。我將開始學習GridLayout。而且,在我的GridData版本中,沒有TOP屬性。庫的版本是3.105.0。你能推薦我學習GridLayout的網站嗎? – user3649231