@Test public void testGetDesignValue() { ExpressionRuntime runtime = mock( ExpressionRuntime.class ); ReportElement element = mock( ReportElement.class ); Object result = barType.getDesignValue( runtime, element ); assertThat( result, is( instanceOf( BarSparklinesWrapper.class ) ) ); BarSparklinesWrapper wrap = (BarSparklinesWrapper) result; assertThat( wrap.getBackend(), is( instanceOf( BarGraphDrawable.class ) ) ); BarGraphDrawable dr = (BarGraphDrawable) wrap.getBackend(); assertThat( dr.getData(), is( equalTo( new Number[] { 10, 5, 6, 3, 1, 2, 7, 9 } ) ) ); assertThat( dr.getSpacing(), is( equalTo( 2 ) ) ); }
public Object getDesignValue( final ExpressionRuntime runtime, final ReportElement element ) { final Object value = ElementTypeUtils.queryStaticValue( element ); Number[] numbers = ElementTypeUtils.getData( value ); if ( numbers == null ) { numbers = new Number[] { new Integer( 10 ), new Integer( 5 ), new Integer( 6 ), new Integer( 3 ), new Integer( 1 ), new Integer( 2 ), new Integer( 7 ), new Integer( 9 ) }; } final int spacing = ElementTypeUtils.getIntAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING, 2 ); final BarGraphDrawable drawable = new BarGraphDrawable(); drawable.setData( numbers ); drawable.setSpacing( spacing ); return new BarSparklinesWrapper( drawable ); }
BarSparklineType extends ContentType { public Object getDesignValue( final ExpressionRuntime runtime, final ReportElement element ) { final Object value = ElementTypeUtils.queryStaticValue( element ); Number[] numbers = ElementTypeUtils.getData( value ); if ( numbers == null ) { numbers = new Number[] { new Integer( 10 ), new Integer( 5 ), new Integer( 6 ), new Integer( 3 ), new Integer( 1 ), new Integer( 2 ), new Integer( 7 ), new Integer( 9 ) }; } final int spacing = ElementTypeUtils.getIntAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING, 2 ); final BarGraphDrawable drawable = new BarGraphDrawable(); drawable.setData( numbers ); drawable.setSpacing( spacing ); return new BarSparklinesWrapper( drawable ); } }
BarSparklineType extends ContentType { public Object getDesignValue( final ExpressionRuntime runtime, final ReportElement element ) { final Object value = ElementTypeUtils.queryStaticValue( element ); Number[] numbers = ElementTypeUtils.getData( value ); if ( numbers == null ) { numbers = new Number[] { new Integer( 10 ), new Integer( 5 ), new Integer( 6 ), new Integer( 3 ), new Integer( 1 ), new Integer( 2 ), new Integer( 7 ), new Integer( 9 ) }; } final int spacing = ElementTypeUtils.getIntAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING, 2 ); final BarGraphDrawable drawable = new BarGraphDrawable(); drawable.setData( numbers ); drawable.setSpacing( spacing ); return new BarSparklinesWrapper( drawable ); } BarSparklineType(); }
BarSparklineType extends ContentType { public Object getDesignValue( final ExpressionRuntime runtime, final ReportElement element ) { final Object value = ElementTypeUtils.queryStaticValue( element ); Number[] numbers = ElementTypeUtils.getData( value ); if ( numbers == null ) { numbers = new Number[] { new Integer( 10 ), new Integer( 5 ), new Integer( 6 ), new Integer( 3 ), new Integer( 1 ), new Integer( 2 ), new Integer( 7 ), new Integer( 9 ) }; } final int spacing = ElementTypeUtils.getIntAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING, 2 ); final BarGraphDrawable drawable = new BarGraphDrawable(); drawable.setData( numbers ); drawable.setSpacing( spacing ); return new BarSparklinesWrapper( drawable ); } BarSparklineType(); Object getValue( final ExpressionRuntime runtime, final ReportElement element ); Object getDesignValue( final ExpressionRuntime runtime, final ReportElement element ); void configureDesignTimeDefaults( final ReportElement element, final Locale locale ); }
BarSparklineType extends ContentType { public Object getDesignValue( final ExpressionRuntime runtime, final ReportElement element ) { final Object value = ElementTypeUtils.queryStaticValue( element ); Number[] numbers = ElementTypeUtils.getData( value ); if ( numbers == null ) { numbers = new Number[] { new Integer( 10 ), new Integer( 5 ), new Integer( 6 ), new Integer( 3 ), new Integer( 1 ), new Integer( 2 ), new Integer( 7 ), new Integer( 9 ) }; } final int spacing = ElementTypeUtils.getIntAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING, 2 ); final BarGraphDrawable drawable = new BarGraphDrawable(); drawable.setData( numbers ); drawable.setSpacing( spacing ); return new BarSparklinesWrapper( drawable ); } BarSparklineType(); Object getValue( final ExpressionRuntime runtime, final ReportElement element ); Object getDesignValue( final ExpressionRuntime runtime, final ReportElement element ); void configureDesignTimeDefaults( final ReportElement element, final Locale locale ); static final BarSparklineType INSTANCE; }