嗨,我正在开发一个项目,我需要生成时间线之类的东西,我需要根据条件将图像动态放置在水平线上。图像实例会根据数据库中的条件而有所不同,并且实例的数量也会有所不同。我使用绝对面板来执行此操作,并将图像放置在水平轴之间 40 的差异处,以保持 y 轴不变。这些图像来自一个扩展 Client Bundle 的类,如下所示。
public interface TimeLineWidgetResources extends ClientBundle {
TimeLineWidgetResources INSTANCE = GWT
.create(TimeLineWidgetResources.class);
@Source("application-connection-point_big.png")
ImageResource getApplicationConnectionPointImage();
@Source("business-connection-point_big.png")
ImageResource getBusinessConnectionPointImage();
@Source("monitor_small.png")
ImageResource getMonitorImage();
}
我在这里只放了 3 张,但在我的资源文件中我有将近 15 张图片。时间线在 IE、Chrome 和 Safari 中的 jetty 服务器上看起来很完美。但是当我创建一个战争并将其部署在 tomcat 中时,它在 Chrome 和 safari 中看起来很完美,但所有图像都会出现并显示在 IE 的屏幕上。如果我创建它的 5 个实例,那么它将创建 5*15 = 75 个这些图像的实例。任何人都可以帮我解决这个问题。我在这里做错了什么?让我在这里也发布绝对面板代码。
/** The method to build Time Line using an absolute Panel */
public void buildNewTimeLine(GWTTimeLine timeLine) {
absolutePanel.setPixelSize((Window.getClientWidth() * 3) / 4, 200);
absolutePanel.getElement().getStyle().setOverflow(Overflow.AUTO);
String startDate = timeLine.getStartDate();
String endDate = timeLine.getEndDate();
List<GWTTimeLineComponent> timeLineComponents = new ArrayList<GWTTimeLineComponent>();
timeLineComponents = timeLine.getComponents();
buildTimeLineEvents(timeLineComponents);
int i = 0;
for (i = 0; i < timeLineComponents.size(); i++) {
if (i == 0) {
Image startImage = new Image();
startImage
.setUrl(resources.getVerticalLineImage().getSafeUri());
absolutePanel.add(startImage, 48, 70);
}
if (i == (timeLineComponents.size() - 1)) {
Image continueImage = new Image();
continueImage
.setUrl(resources.getLineArrowImage().getSafeUri());
absolutePanel.add(continueImage, horizontalImageXAxis + 80, 70);
}
GWTTimeLineComponent timeLineComponent = new GWTTimeLineComponent();
timeLineComponent = timeLineComponents.get(i);
String icon = timeLineComponent.getIcon();
int id = timeLineComponent.getId();
String logicalId = timeLineComponent.getLogicalId();
List<GWTTimeLineEvent> timeLineEvents = new ArrayList<GWTTimeLineEvent>();
timeLineEvents = timeLineComponent.getEvents();
if (icon.startsWith("infor.engine.monitor")) {
if (isAbove == true) {
isAbove = false;
isBelow = true;
Image monitorImage = new Image();
monitorImage.setUrl(resources.getMonitorImage()
.getSafeUri());
monitorImage.setTitle(timeLineComponent.getLogicalId());
String downOrUpOrBiDirectionalArrow = "up";
buildTimeLineComponents(downOrUpOrBiDirectionalArrow,
monitorImage, id, logicalId);
}
else if (isBelow == true) {
isAbove = true;
isBelow = false;
Image monitorImage = new Image();
monitorImage.setUrl(resources.getMonitorImage()
.getSafeUri());
monitorImage.setTitle(timeLineComponent.getLogicalId());
String downOrUpOrBiDirectionalArrow = "down";
buildTimeLineComponents(downOrUpOrBiDirectionalArrow,
monitorImage, id, logicalId);
}
} else if (icon.startsWith("infor.database")) {
if (isAbove == true) {
isAbove = false;
isBelow = true;
Image databaseImage = new Image();
databaseImage.setUrl(resources
.getDatabaseConnectionPointImage().getSafeUri());
databaseImage.setTitle(timeLineComponent.getLogicalId());
String downOrUpOrBiDirectionalArrow = "up";
buildTimeLineComponents(downOrUpOrBiDirectionalArrow,
databaseImage, id, logicalId);
}
else if (isBelow == true) {
isAbove = true;
isBelow = false;
Image databaseImage = new Image();
databaseImage.setUrl(resources
.getDatabaseConnectionPointImage().getSafeUri());
databaseImage.setTitle(timeLineComponent.getLogicalId());
String downOrUpOrBiDirectionalArrow = "down";
buildTimeLineComponents(downOrUpOrBiDirectionalArrow,
databaseImage, id, logicalId);
}
} else if (icon.startsWith("infor.jms")) {
if (isAbove == true) {
isAbove = false;
isBelow = true;
Image jmsImage = new Image();
jmsImage.setUrl(resources.getJmsQueueConnectionPointImage()
.getSafeUri());
jmsImage.setTitle(timeLineComponent.getLogicalId());
String downOrUpOrBiDirectionalArrow = "up";
buildTimeLineComponents(downOrUpOrBiDirectionalArrow,
jmsImage, id, logicalId);
}
else if (isBelow == true) {
isAbove = true;
isBelow = false;
Image jmsImage = new Image();
jmsImage.setUrl(resources.getJmsQueueConnectionPointImage()
.getSafeUri());
jmsImage.setTitle(timeLineComponent.getLogicalId());
String downOrUpOrBiDirectionalArrow = "down";
buildTimeLineComponents(downOrUpOrBiDirectionalArrow,
jmsImage, id, logicalId);
}
} else if (icon.startsWith("infor.ws")) {
if (isAbove == true) {
isAbove = false;
isBelow = true;
Image webServiceImage = new Image();
webServiceImage.setUrl(resources
.getWebServiceConnectionPointImage().getSafeUri());
webServiceImage.setTitle(timeLineComponent.getLogicalId());
String downOrUpOrBiDirectionalArrow = "up";
buildTimeLineComponents(downOrUpOrBiDirectionalArrow,
webServiceImage, id, logicalId);
}
else if (isBelow == true) {
isAbove = true;
isBelow = false;
Image webServiceImage = new Image();
webServiceImage.setUrl(resources
.getWebServiceConnectionPointImage().getSafeUri());
webServiceImage.setTitle(timeLineComponent.getLogicalId());
String downOrUpOrBiDirectionalArrow = "down";
buildTimeLineComponents(downOrUpOrBiDirectionalArrow,
webServiceImage, id, logicalId);
}
} else if (icon.startsWith("infor.sap")) {
if (isAbove == true) {
isAbove = false;
isBelow = true;
Image sapImage = new Image();
sapImage.setUrl(resources.getBusinessConnectionPointImage()
.getSafeUri());
sapImage.setTitle(timeLineComponent.getLogicalId());
String downOrUpOrBiDirectionalArrow = "up";
buildTimeLineComponents(downOrUpOrBiDirectionalArrow,
sapImage, id, logicalId);
}
else if (isBelow == true) {
isAbove = true;
isBelow = false;
Image sapImage = new Image();
sapImage.setUrl(resources.getBusinessConnectionPointImage()
.getSafeUri());
sapImage.setTitle(timeLineComponent.getLogicalId());
String downOrUpOrBiDirectionalArrow = "down";
buildTimeLineComponents(downOrUpOrBiDirectionalArrow,
sapImage, id, logicalId);
}
}
else if (icon.startsWith("infor.bod")) {
Image horizontalLine = new Image();
horizontalLine.setUrl(resources.getHorizontalLineImage()
.getSafeUri());
Image bodImage = new Image();
bodImage.setUrl(resources.getBodImage().getSafeUri());
addBodImageClickHandlers(bodImage,
searchEvent.getSelectedMessageId());
bodImageXAxis = horizontalImageXAxis + 40;
horizontalImageXAxis = horizontalImageXAxis + 20;
bodImageYAxis = 65;
absolutePanel.add(bodImage, bodImageXAxis, bodImageYAxis);
}
}
}
/** The method to build Time Line components */
public void buildTimeLineComponents(String downOrUpOrBiDirectionalArrow,
Image connectionPointImage, int id, String logicalId) {
Image horizontalLine = new Image();
horizontalLine.setUrl(resources.getHorizontalLineImage().getSafeUri());
Image arrow = new Image();
if (downOrUpOrBiDirectionalArrow.equals("down")) {
arrow.setUrl(resources.getDownArrowImage().getSafeUri());
connectionPointImageYAxis = 95;
arrowImageYAxis = 72;
}
if (downOrUpOrBiDirectionalArrow.equals("up")) {
arrow.setUrl(resources.getUpArrowImage().getSafeUri());
connectionPointImageYAxis = 10;
arrowImageYAxis = 46;
}
addConnectionPointImageClickHandlers(connectionPointImage, id,
logicalId);
horizontalImageXAxis = horizontalImageXAxis + widthBetweenTImages;
absolutePanel.add(horizontalLine, horizontalImageXAxis,
horizontalImageYAxis);
connectionPointImageXAxis = horizontalImageXAxis + 7;
arrowImageXAxis = horizontalImageXAxis + 15;
absolutePanel.add(connectionPointImage, connectionPointImageXAxis,
connectionPointImageYAxis);
absolutePanel.add(arrow, arrowImageXAxis, arrowImageYAxis);
}
请帮忙。