Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 复制的带注释的时间线GWT_Java_Gwt - Fatal编程技术网

Java 复制的带注释的时间线GWT

Java 复制的带注释的时间线GWT,java,gwt,Java,Gwt,我正在开发一个在GWT框架下编写的GUI。然而,我注意到一个故障,我不知道原因可能是什么。这个想法是打印一组类似的标签。每个选项卡都包含一个水平面板,右侧将带注释的TimeLine对象与适当的数据集成在一起。绘制选项卡的代码如下所示: for(String sBuilding : lsBuildings){ if(sBuilding.equals(BuildingCodes.getsTucBuildingCode())){ tabLayoutPanel.add(pri

我正在开发一个在GWT框架下编写的GUI。然而,我注意到一个故障,我不知道原因可能是什么。这个想法是打印一组类似的标签。每个选项卡都包含一个水平面板,右侧将带注释的TimeLine对象与适当的数据集成在一起。绘制选项卡的代码如下所示:

for(String sBuilding : lsBuildings){
    if(sBuilding.equals(BuildingCodes.getsTucBuildingCode())){  
        tabLayoutPanel.add(printScreen.printScreen(hmTucData, hmMonthTucData, "TUC"), "TUC offices", true);
    }
    else if(sBuilding.equals(BuildingCodes.getsCartifBuildingCode())){
        tabLayoutPanel.add(printScreen.printScreen(hmCartifData, hmMonthCartifData, "CARTIF"), "CARTIF offices", true);
    }
    else if(sBuilding.equals(BuildingCodes.getsZubBuildingCode())){
        tabLayoutPanel.add(printScreen.printScreen(hmZubData, hmMonthZubData, "ZUB"), "ZUB offices", true);
    }
    else if(sBuilding.equals(BuildingCodes.getsSierraBuildingCode())){
        tabLayoutPanel.add(printScreen.printScreen(hmSierraData, hmMonthSierraData, "SIERRA"), "Sierra Elvira School", true);
    }
}
如您所见,我根据要显示的数据(即hmXXXXData和HMMONTHXXDATA)添加了一个选项卡。在printScreen方法中,我打印带注释的时间线,如下所示:

//If the data is not collected, no graph should be displayed
    if(hmMonthData.size() > 0){

        //Get the list of values of the sensors in the Zone visible in the stack panel
        final Map<String, Map<String,String>> hmSensorsByZone = hmMonthData.get(sSelectedZone);

        //Get the list of sensors associated to the Zone selected
        Object[] asSensors = hmSensorsByZone.keySet().toArray();

        //Only if the length of sensors is upper than 0
        if(asSensors.length > 0){

            final List<String> lsSensors = new ArrayList<String>();

            for(int i = 0; i < asSensors.length; i++){
                lsSensors.add(asSensors[i].toString());
            }

            // Chart for printing the trends of the last month for the variable
            Runnable onLoadCallback = new Runnable() {
                public void run() {             
                    DataTable data = DataTable.create();
                    //Columnas a mostrar, la primera para el eje de abscisas (fecha) y la segunda para
                    //los valores en el eje de ordenadas
                    data.addColumn(ColumnType.DATE, "Date");

                    for(String sSensor : lsSensors){
                        data.addColumn(ColumnType.NUMBER, sSensor);
                    }

                    DateTimeFormat dtf = DateTimeFormat.getFormat("dd/MM/yy hh:mm:ss");

                    //Se añaden los valores y los puntos para dibujar la gráfica
                    for(int j = 0; j < lsSensors.size(); j++){
                        //Delete all the rows related to the sensor j

                        Map<String,String> hmValues = hmSensorsByZone.get(lsSensors.get(j));

                        //Only if the size of the values is upper than 0
                        if(hmValues.size() > 0){

                            Object[] asTimestamps = (Object[]) hmValues.keySet().toArray(); 
                            Object[] asValues = (Object[]) hmValues.values().toArray(); 

                            if(data.getNumberOfRows() < asTimestamps.length)
                                data.addRows(asTimestamps.length - data.getNumberOfRows()); 

                            for(int i = 0; i < asTimestamps.length; i++){
                                String sTimestamp = asTimestamps[i].toString();
                                String sValue = asValues[i].toString();
                                Double dValue = Double.valueOf(sValue);

                                data.setValue(i, 0, dtf.parse(sTimestamp)); 
                                data.setValue(i, j+1, dValue);
                            }
                        }
                    }       
                    //Opciones de graficado
                    AnnotatedTimeLine.Options options = AnnotatedTimeLine.Options.create();
                    options.setDisplayAnnotations(true);
                    options.setDisplayZoomButtons(true);
                    options.setScaleType(AnnotatedTimeLine.ScaleType.ALLMAXIMIZE);
                    options.setLegendPosition(AnnotatedTimeLine.AnnotatedLegendPosition. NEW_ROW);
                    AnnotatedTimeLine atl = new AnnotatedTimeLine(data, options,"475px", "310px");
                    atlHorizontalPanel.add(atl);
                }

            };
            //The APO for visualization is loaded in order to show the graph
            VisualizationUtils.loadVisualizationApi(onLoadCallback,AnnotatedTimeLine.PACKAGE);
        }
    }
//如果未收集数据,则不应显示任何图形
如果(hmMonthData.size()>0){
//获取堆栈面板中可见区域中传感器的值列表
最终地图hmSensorsByZone=hmMonthData.get(sSelectedZone);
//获取与选定区域关联的传感器列表
Object[]asSensors=hmSensorsByZone.keySet().toArray();
//仅当传感器的长度大于0时
如果(asSensors.length>0){
最终列表lsSensors=new ArrayList();
对于(int i=0;i0){
Object[]asTimestamps=(Object[])hmValues.keySet().toArray();
对象[]asValues=(对象[])hmValues.values().toArray();
if(data.getNumberOfRows()
我发现第一个选项卡打印图形,但是其余选项卡根本不加载图形。你知道是什么原因导致这种不良行为吗

提前非常感谢

有一个可能与此相关的开放式网站

我认为不可能在一个隐藏的容器内绘制/创建一个图表,然后使容器可见

只有在连接到
DOM
的可见容器中绘制/创建图表时,图表才会正确呈现

选项卡面板
有一个变通方法:

@UiHandler("tabPanel")
void handleSelect(SelectionEvent<Integer> e) {
    /* redraw only when switching to tab that contains visualization */
    if (e.getSelectedItem() == 1) {
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {
            @Override
            public void execute() {
                drawVisualization();
            }
        });
    }
}
@UiHandler(“tabPanel”)
无效手柄选择(SelectionEvent e){
/*仅在切换到包含可视化的选项卡时重新绘制*/
如果(如getSelectedItem()==1){
Scheduler.get().ScheduledDeferred(新的ScheduledCommand(){
@凌驾
public void execute(){
绘图可视化();
}
});
}
}

我还建议使用非官方包装,而不是过时的官方
gwt可视化
包装。这将解决所有问题,并正确调整图表的大小。

非常感谢!因此,如果我理解正确,我应该打印第一个选项卡,然后在TabPanel对象中包含一个事件处理程序,以便在所选选项卡更改时重新打印屏幕,对吗?是的,您应该解决您的问题,或者使用
gwt图表
,它应该处理此问题。