我在下面编写了一个测试类,但我无法将其添加到com.smartgwt.client.widgets.Window中。
任何人都可以帮我这个吗?提前谢谢!
package com.smartgwt.sample.showcase.client;
import pl.tecna.gwt.connectors.client.ConnectionPoint; import pl.tecna.gwt.connectors.client.Connector; import pl.tecna.gwt.connectors.client.Diagram; import pl.tecna.gwt.connectors.client.SectionDecoration; import pl.tecna.gwt.connectors.client.Shape;
import com.google.gwt.user.client.ui.AbsolutePanel; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Image; import com.smartgwt.client.widgets.Label;
公共类NetworkMap {
public NetworkMap(){ AbsolutePanel widget = new AbsolutePanel();
final Diagram diagram = new Diagram(widget);
final Label label = new Label("LABEL");
最终图片图片=新图片(“http://code.google.com/images/code_sm.png”); image.setPixelSize(153,55);
widget.add(label,50,250); widget.add(image,200,300);
Shape shapeForLabel = new Shape(label); shapeForLabel.showOnDiagram(图);
Shape shapeForImage = new Shape(image); shapeForImage.showOnDiagram(图);
ConnectionPoint labelConnectionPoint = shapeForLabel.connectionPoints [Shape.E]; ConnectionPoint imageConnectionPoint = shapeForImage.connectionPoints [Shape.W];
Connector label2image = new Connector
(labelConnectionPoint.getAbsoluteLeft(),
labelConnectionPoint.getAbsoluteTop(),
imageConnectionPoint.getAbsoluteLeft(),
imageConnectionPoint.getAbsoluteTop(),
null,
new SectionDecoration(SectionDecoration.DECORATE_ARROW));
label2image.startEndPoint.glueToConnectionPoint(labelConnectionPoint);
label2image.endEndPoint.glueToConnectionPoint(imageConnectionPoint);
label2image.showOnDiagram(diagram);
/* // Create boundary panel
AbsolutePanel boundaryPanel = new AbsolutePanel();
initWidget(boundaryPanel); boundaryPanel.setSize(“700px”,“700px”); RootPanel.get()。add(boundaryPanel,10,10);
final Diagram diagram = new Diagram(boundaryPanel);
boundaryPanel.add(new Label(“GWT 1.7的连接器示例”),10,2);
//添加一些可以连接的元素 最终标签标签=新标签(“LABEL”); 最终图像图像=新图像(“http://code.google.com/images/code_sm.png”); image.setPixelSize(153,55);
boundaryPanel.add(label,50,250); boundaryPanel.add(image,200,300);
Shape shapeForLabel = new Shape(label); shapeForLabel.showOnDiagram(图);
Shape shapeForImage = new Shape(image); shapeForImage.showOnDiagram(图);
//连接标签和图片 ConnectionPoint labelConnectionPoint = shapeForLabel.connectionPoints [Shape.E]; ConnectionPoint imageConnectionPoint = shapeForImage.connectionPoints [Shape.W];
Connector label2image = new Connector
(labelConnectionPoint.getAbsoluteLeft(),
labelConnectionPoint.getAbsoluteTop(),
imageConnectionPoint.getAbsoluteLeft(),
imageConnectionPoint.getAbsoluteTop(),
null,
new SectionDecoration(SectionDecoration.DECORATE_ARROW));
label2image.startEndPoint.glueToConnectionPoint(labelConnectionPoint);
label2image.endEndPoint.glueToConnectionPoint(imageConnectionPoint);
label2image.showOnDiagram(diagram);
*/
}
}
答案 0 :(得分:0)
据我所知,您正在尝试将NetworkMap放入Window小部件中。 NetworkMap类需要实现Composite接口,以便将其视为窗口小部件并显示在Window,Panel等中......一旦实现了Composite接口,您需要通过提供主面板调用initWidget()函数/在您的NetworkMap类中包含您的小部件的布局(您已完成此操作)。因此你需要写;
public class NetworkMap extends Composite { ... }