oComputations = new PlotWith2DAxes(ids, (ChartWithAxes) cmRunTime, rtc);
try { oComputations = new PlotWith2DAxes(ids, (ChartWithAxes) cmRunTime, rtc); } catch (Exception e) { throw new GenerationException(e); }
    public final GeneratedChartState build(IDisplayServer ids, Chart cmDesignTime,        Scriptable scParent, Bounds bo, RunTimeContext rtc) throws GenerationException    {        if (ids == null || cmDesignTime == null || bo == null)        {            throw new GenerationException(                "exception.illegal.null.value", //$NON-NLS-1$                 ResourceBundle.getBundle(                    Messages.ENGINE,                     Locale.getDefault() // LOCALE?                )            );        }                // CREATE A CONTEXT IF NEEDED        if (rtc == null)        {            rtc = new RunTimeContext();        }        // UPDATE THE CONTEXT WITH A LOCALE IF IT IS UNDEFINED        final Chart cmRunTime = (Chart) EcoreUtil.copy(cmDesignTime);        if (rtc.getLocale() == null)        {            rtc.setLocale(Locale.getDefault());        }        // 3D CHARTS ARE NOT YET SUPPORTED        if (cmDesignTime.getDimension() == ChartDimension.THREE_DIMENSIONAL_LITERAL)        {            throw new GenerationException(                new UnsupportedFeatureException(                    "exception.no3d.support", //$NON-NLS-1$                     ResourceBundle.getBundle(                        Messages.ENGINE,                         rtc.getLocale()                    )                )            );         }        // INITIALIZE THE SCRIPT HANDLER        final String sScriptContent = cmRunTime.getScript();        ScriptHandler sh = rtc.getScriptHandler();        if (sh == null && sScriptContent != null) // NOT PREVIOUSLY DEFINED BY REPORTITEM ADAPTER        {            sh = new ScriptHandler();            try            {                sh.init(scParent);                sh.setRunTimeModel(cmRunTime);                rtc.setScriptHandler(sh);                sh.register(sScriptContent);            }            catch (ScriptException sx )            {                throw new GenerationException(sx);            }        }        else if (sh != null) // COPY SCRIPTS FROM DESIGNTIME TO RUNTIME INSTANCE        {            rtc.setScriptHandler(sh);        }        rtc.setScriptHandler(sh);        // SETUP THE COMPUTATIONS        ScriptHandler.callFunction(sh, ScriptHandler.START_GENERATION, cmRunTime);        int iChartType = UNDEFINED;        Object oComputations = null;        if (cmRunTime instanceof ChartWithAxes)        {            iChartType = WITH_AXES;            oComputations = new PlotWith2DAxes(ids, (ChartWithAxes) cmRunTime, rtc);        }        else if (cmRunTime instanceof ChartWithoutAxes)        {            iChartType = WITHOUT_AXES;            oComputations = new PlotWithoutAxes(ids, (ChartWithoutAxes) cmRunTime, rtc);        }        if (oComputations == null)        {            throw new GenerationException(                "exception.unsupported.chart.model", //$NON-NLS-1$                new Object[] { cmRunTime },                ResourceBundle.getBundle(                    Messages.ENGINE,                     rtc.getLocale()                )            ); // i18n_CONCATENATIONS_REMOVED        }        // OBTAIN THE RENDERERS        final ILogger il = DefaultLoggerImpl.instance();        final LinkedHashMap lhmRenderers = new LinkedHashMap();        BaseRenderer[] brna = null;        try        {            brna = BaseRenderer.instances(cmRunTime, rtc, oComputations);            for (int i = 0; i < brna.length; i++)            {                lhmRenderers.put(brna[i].getSeries(), new LegendItemRenderingHints(brna[i], BoundsImpl.create(0, 0, 0,                    0)));            }        }        catch (Exception ex )        {            ex.printStackTrace();            throw new GenerationException(ex);        }        // PERFORM THE BLOCKS' LAYOUT        Block bl = cmRunTime.getBlock();        final LayoutManager lm = new LayoutManager(bl);        ScriptHandler.callFunction(sh, ScriptHandler.BEFORE_LAYOUT, cmRunTime);        try        {            lm.doLayout_tmp(ids, cmRunTime, bo, rtc);        }        catch (OverlapException oex )        {            throw new GenerationException(oex);        }        ScriptHandler.callFunction(sh, ScriptHandler.AFTER_LAYOUT, cmRunTime);        // COMPUTE THE PLOT AREA        Bounds boPlot = cmRunTime.getPlot().getBounds();        Insets insPlot = cmRunTime.getPlot().getInsets();        boPlot = boPlot.adjustedInstance(insPlot);        ScriptHandler.callFunction(sh, ScriptHandler.BEFORE_COMPUTATIONS, cmRunTime, oComputations);        long lTimer = System.currentTimeMillis();        if (iChartType == WITH_AXES)        {            PlotWith2DAxes pwa = (PlotWith2DAxes) oComputations;            try            {                pwa.compute(boPlot);            }            catch (Exception ex )            {                ex.printStackTrace();                throw new GenerationException(ex);            }        }        else if (iChartType == WITHOUT_AXES)        {            PlotWithoutAxes pwoa = (PlotWithoutAxes) oComputations;            try            {                pwoa.compute(boPlot);            }            catch (Exception ex )            {                throw new GenerationException(ex);            }        }        ScriptHandler.callFunction(sh, ScriptHandler.AFTER_COMPUTATIONS, cmRunTime, oComputations);        final Collection co = lhmRenderers.values();        final LegendItemRenderingHints[] lirha = (LegendItemRenderingHints[]) co.toArray(EMPTY_LIRHA);        final int iSize = lhmRenderers.size();        BaseRenderer br;        for (int i = 0; i < iSize; i++)        {            br = lirha[i].getRenderer();            br.set(brna);            br.set(ids);            br.set(rtc);            try            {                if (br.getComputations() instanceof PlotWithoutAxes)                {                    br.set(((PlotWithoutAxes) br.getComputations()).getSeriesRenderingHints(br.getSeries()));                }                else                {                    br.set(((PlotWith2DAxes) br.getComputations()).getSeriesRenderingHints(br.getSeriesDefinition(), br.getSeries()));                }                ScriptHandler.callFunction(sh, ScriptHandler.BEFORE_COMPUTE_SERIES, br.getSeries());                br.compute(bo, cmRunTime.getPlot(), br.getSeriesRenderingHints());                ScriptHandler.callFunction(sh, ScriptHandler.AFTER_COMPUTE_SERIES, br.getSeries());            }            catch (Exception ex )            {                throw new GenerationException(ex);            }        }        il.log(ILogger.INFORMATION,             Messages.getString(                "info.compute.elapsed.time.without.axes", //$NON-NLS-1$                new Object[] { new Long(System.currentTimeMillis() - lTimer) },                rtc.getLocale()            )         ); // i18n_CONCATENATIONS_REMOVED                final GeneratedChartState gcs = new GeneratedChartState(ids, cmRunTime, lhmRenderers, rtc, oComputations);        if (sh != null)        {            sh.setGeneratedChartState(gcs);            ScriptHandler.callFunction(sh, ScriptHandler.FINISH_GENERATION, gcs);        }        return gcs;    }