ArrayList alSeries;
List alSeries;
	static final StackedSeriesLookup create( ChartWithAxes cwa,			RunTimeContext rtc ) throws ChartException,			IllegalArgumentException	{		if ( cwa == null ) // NPE CHECK		{			return null;		}		final StackedSeriesLookup ssl = new StackedSeriesLookup( rtc );		final Axis axBase = cwa.getBaseAxes( )[0];		final Axis[] axaOrthogonal = cwa.getOrthogonalAxes( axBase, true );		EList el;		ArrayList alSeries;		int iSeriesCount;		StackGroup sg, sgSingle;		Series se;		boolean bStackedSet;		SeriesDefinition sd;		int iSharedUnitIndex, iSharedUnitCount, iDataSetCount;		ArrayList alSGCopies;		DataSetIterator dsi = null;		for ( int i = 0; i < axaOrthogonal.length; i++ ) // EACH AXIS		{			iSharedUnitIndex = 0;			iSharedUnitCount = 0;			sgSingle = null; // RESET PER AXIS			el = axaOrthogonal[i].getSeriesDefinitions( );			alSGCopies = new ArrayList( 4 );			iSharedUnitCount = 0;			for ( int j = 0; j < el.size( ); j++ ) // EACH SERIES DEFINITION			{				sd = (SeriesDefinition) el.get( j );				alSeries = (ArrayList) sd.getRunTimeSeries( );				iSeriesCount = alSeries.size( );				if ( iSeriesCount > 1 )				{					bStackedSet = false;					sg = null;					for ( int k = 0; k < iSeriesCount; k++ ) // EACH SERIES					{						se = (Series) alSeries.get( k );						dsi = new DataSetIterator( se.getDataSet( ) );						iDataSetCount = dsi.size( );						if ( ssl.iCachedUnitCount == 0 )						{							ssl.iCachedUnitCount = iDataSetCount;						}						else if ( ssl.iCachedUnitCount != iDataSetCount )						{							throw new IllegalArgumentException( MessageFormat.format( ResourceBundle.getBundle( Messages.ENGINE,									rtc.getLocale( ) )									.getString( "exception.runtime.dataset.count.mismatch" ), //$NON-NLS-1$									new Object[]{											new Integer( ssl.iCachedUnitCount ),											new Integer( iDataSetCount )									} )							);						}						if ( se.canBeStacked( ) )						{							if ( !se.isSetStacked( ) )							{								throw new ChartException( ChartEnginePlugin.ID,										ChartException.UNDEFINED_VALUE,										"exception.unset.series.stacked.property", //$NON-NLS-1$										new Object[]{											se										},										ResourceBundle.getBundle( Messages.ENGINE,												rtc.getLocale( ) ) );							}							if ( se.canShareAxisUnit( ) )							{								if ( se.isStacked( ) )								{									if ( k > 0 && !bStackedSet )									{										throw new IllegalArgumentException( MessageFormat.format( ResourceBundle.getBundle( Messages.ENGINE,												rtc.getLocale( ) )												.getString( "exception.stacked.unstacked.mix.series" ), //$NON-NLS-1$ 												new Object[]{													sd												} )										);									}									if ( k == 0 ) // ONE GROUP FOR ALL STACKED									// SERIES									{										sg = new StackGroup( iSharedUnitIndex++ );										alSGCopies.add( sg );										iSharedUnitCount++;									}									bStackedSet = true;									ssl.htSeriesToStackGroup.put( se, sg );									sg.addSeries( se ); // REQUIRE REVERSE									// LOOKUP								}								else								{									if ( k > 0 && bStackedSet )									{										throw new IllegalArgumentException( MessageFormat.format( ResourceBundle.getBundle( Messages.ENGINE,												rtc.getLocale( ) )												.getString( "exception.stacked.unstacked.mix.series" ), //$NON-NLS-1$ 												new Object[]{													sd												} )										);									}									sg = new StackGroup( iSharedUnitIndex++ ); // NEW									// GROUP									// FOR									// EACH									// UNSTACKED									// SERIES									alSGCopies.add( sg );									iSharedUnitCount++;									ssl.htSeriesToStackGroup.put( se, sg );									sg.addSeries( se ); // REQUIRE REVERSE									// LOOKUP								}							}							else							{								if ( se.isStacked( ) )								{									if ( k > 0 && !bStackedSet )									{										throw new IllegalArgumentException( MessageFormat.format( ResourceBundle.getBundle( Messages.ENGINE,												rtc.getLocale( ) )												.getString( "exception.stacked.unstacked.mix.series" ), //$NON-NLS-1$ 												new Object[]{													sd												} )										);									}									if ( k == 0 ) // ONE GROUP FOR ALL STACKED									// SERIES									{										sg = new StackGroup( -1 ); // UNSET										// BECAUSE										// DOESNT										// SHARE AXIS										// UNITS										alSGCopies.add( sg );									}									bStackedSet = true;									ssl.htSeriesToStackGroup.put( se, sg );									sg.addSeries( se ); // REQUIRE REVERSE									// LOOKUP								}								else								{									if ( k > 0 && bStackedSet )									{										throw new IllegalArgumentException( MessageFormat.format( ResourceBundle.getBundle( Messages.ENGINE,												rtc.getLocale( ) )												.getString( "exception.stacked.unstacked.mix.series" ), //$NON-NLS-1$ 												new Object[]{													sd												} )										);									}									sg = new StackGroup( -1 ); // NEW GROUP FOR									// EACH UNSTACKED									// SERIES									alSGCopies.add( sg );									ssl.htSeriesToStackGroup.put( se, sg );									sg.addSeries( se ); // REQUIRE REVERSE									// LOOKUP								}							}						}						else						// e.g. each custom series in its own stack (not stacked						// but						{							sg = new StackGroup( -1 ); // ONE PER UNSTACKED							// SERIES (SHARED INDEX							// IS UNSET)							alSGCopies.add( sg );							ssl.htSeriesToStackGroup.put( se, sg );							sg.addSeries( se ); // REQUIRE REVERSE LOOKUP						}					}				}				else				// ONE OR LESS SERIES USE THE SINGLE STACK GROUP				{					for ( int k = 0; k < iSeriesCount; k++ ) // EACH SERIES					// (iSeriesCount					// SHOULD BE ONE)					{						se = (Series) alSeries.get( k );						dsi = new DataSetIterator( se.getDataSet( ) );						iDataSetCount = dsi.size( );						if ( ssl.iCachedUnitCount == 0 )						{							ssl.iCachedUnitCount = iDataSetCount;						}						else if ( ssl.iCachedUnitCount != iDataSetCount )						{							throw new IllegalArgumentException( MessageFormat.format( ResourceBundle.getBundle( Messages.ENGINE,									rtc.getLocale( ) )									.getString( "exception.runtime.dataset.count.mismatch" ), //$NON-NLS-1$									new Object[]{											new Integer( ssl.iCachedUnitCount ),											new Integer( iDataSetCount )									} )							);						}						if ( se.canBeStacked( ) )						{							if ( se.canShareAxisUnit( ) )							{								if ( se.isStacked( ) )								{									if ( sgSingle == null )									{										sgSingle = new StackGroup( iSharedUnitIndex++ );										alSGCopies.add( sgSingle );										iSharedUnitCount++;									}									ssl.htSeriesToStackGroup.put( se, sgSingle );									sgSingle.addSeries( se ); // REQUIRE																// REVERSE									// LOOKUP								}								else								{									sg = new StackGroup( iSharedUnitIndex++ ); // ONE									// PER									// UNSTACKED									// SERIES									// (SHARED									// INDEX									// IS									// SET)									iSharedUnitCount++;									alSGCopies.add( sg );									ssl.htSeriesToStackGroup.put( se, sg );									sg.addSeries( se ); // REQUIRE REVERSE									// LOOKUP								}							}							else							// e.g. each line series in its own stack							{								sg = new StackGroup( -1 ); // ONE PER UNSTACKED								// SERIES (SHARED								// INDEX IS UNSET)								alSGCopies.add( sg );								ssl.htSeriesToStackGroup.put( se, sg );								sg.addSeries( se ); // REQUIRE REVERSE LOOKUP							}						}						else						// e.g. each custom series in its own stack (not stacked						// but						{							sg = new StackGroup( -1 ); // ONE PER UNSTACKED							// SERIES (SHARED INDEX							// IS UNSET)							alSGCopies.add( sg );							ssl.htSeriesToStackGroup.put( se, sg );							sg.addSeries( se ); // REQUIRE REVERSE LOOKUP						}					}				}			}			if ( iSharedUnitCount < 1 )				iSharedUnitCount = 1;			for ( int j = 0; j < alSGCopies.size( ); j++ )			{				sg = (StackGroup) alSGCopies.get( j );				// if (sg.getSharedIndex() >= 0)				{					sg.updateCount( iSharedUnitCount );				}			}			ssl.htAxisToStackGroups.put( axaOrthogonal[i], alSGCopies );		}		return ssl;	}