@Test public void testWriteStyle() throws IOException { XmlWriter writer = mock( XmlWriter.class ); ElementStyleSheet style = mock( ElementStyleSheet.class ); handler.writeStyle( writer, style ); verify( writer, never() ).writeTag( anyString(), anyString(), any( AttributeList.class ), anyBoolean() ); doReturn( true ).when( style ).isLocalKey( SparklineStyleKeys.HIGH_COLOR ); doReturn( true ).when( style ).isLocalKey( SparklineStyleKeys.MEDIUM_COLOR ); doReturn( true ).when( style ).isLocalKey( SparklineStyleKeys.LOW_COLOR ); doReturn( true ).when( style ).isLocalKey( SparklineStyleKeys.LAST_COLOR ); doReturn( Color.BLACK ).when( style ).getStyleProperty( SparklineStyleKeys.HIGH_COLOR ); doReturn( Color.BLUE ).when( style ).getStyleProperty( SparklineStyleKeys.MEDIUM_COLOR ); doReturn( Color.GRAY ).when( style ).getStyleProperty( SparklineStyleKeys.LOW_COLOR ); doReturn( Color.YELLOW ).when( style ).getStyleProperty( SparklineStyleKeys.LAST_COLOR ); ArgumentCaptor<AttributeList> attrsCaptor = ArgumentCaptor.forClass( AttributeList.class ); doNothing().when( writer ).writeTag( anyString(), anyString(), attrsCaptor.capture(), anyBoolean() ); handler.writeStyle( writer, style ); verify( writer ).writeTag( anyString(), anyString(), any( AttributeList.class ), anyBoolean() ); assertThat( attrsCaptor.getValue().getAttribute( NAMESPACE, "high-color" ), is( equalTo( "black" ) ) ); assertThat( attrsCaptor.getValue().getAttribute( NAMESPACE, "medium-color" ), is( equalTo( "blue" ) ) ); assertThat( attrsCaptor.getValue().getAttribute( NAMESPACE, "low-color" ), is( equalTo( "gray" ) ) ); assertThat( attrsCaptor.getValue().getAttribute( NAMESPACE, "last-color" ), is( equalTo( "yellow" ) ) ); }
public void writeStyle( final XmlWriter writer, final ElementStyleSheet style ) throws IOException { final AttributeList bandStyleAtts = new AttributeList(); if ( style.isLocalKey( SparklineStyleKeys.HIGH_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.HIGH_COLOR ); bandStyleAtts.setAttribute( SparklineModule.NAMESPACE, "high-color", ColorValueConverter.colorToString( value ) ); } if ( style.isLocalKey( SparklineStyleKeys.MEDIUM_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.MEDIUM_COLOR ); bandStyleAtts .setAttribute( SparklineModule.NAMESPACE, "medium-color", ColorValueConverter.colorToString( value ) ); } if ( style.isLocalKey( SparklineStyleKeys.LOW_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.LOW_COLOR ); bandStyleAtts.setAttribute( SparklineModule.NAMESPACE, "low-color", ColorValueConverter.colorToString( value ) ); } if ( style.isLocalKey( SparklineStyleKeys.LAST_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.LAST_COLOR ); bandStyleAtts.setAttribute( SparklineModule.NAMESPACE, "last-color", ColorValueConverter.colorToString( value ) ); } if ( bandStyleAtts.isEmpty() == false ) { writer.writeTag( SparklineModule.NAMESPACE, "spark-styles", bandStyleAtts, XmlWriter.CLOSE ); } }
SparklineStyleSetWriteHandler implements BundleStyleSetWriteHandler { public void writeStyle( final XmlWriter writer, final ElementStyleSheet style ) throws IOException { final AttributeList bandStyleAtts = new AttributeList(); if ( style.isLocalKey( SparklineStyleKeys.HIGH_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.HIGH_COLOR ); bandStyleAtts.setAttribute( SparklineModule.NAMESPACE, "high-color", ColorValueConverter.colorToString( value ) ); } if ( style.isLocalKey( SparklineStyleKeys.MEDIUM_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.MEDIUM_COLOR ); bandStyleAtts .setAttribute( SparklineModule.NAMESPACE, "medium-color", ColorValueConverter.colorToString( value ) ); } if ( style.isLocalKey( SparklineStyleKeys.LOW_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.LOW_COLOR ); bandStyleAtts.setAttribute( SparklineModule.NAMESPACE, "low-color", ColorValueConverter.colorToString( value ) ); } if ( style.isLocalKey( SparklineStyleKeys.LAST_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.LAST_COLOR ); bandStyleAtts.setAttribute( SparklineModule.NAMESPACE, "last-color", ColorValueConverter.colorToString( value ) ); } if ( bandStyleAtts.isEmpty() == false ) { writer.writeTag( SparklineModule.NAMESPACE, "spark-styles", bandStyleAtts, XmlWriter.CLOSE ); } } }
SparklineStyleSetWriteHandler implements BundleStyleSetWriteHandler { public void writeStyle( final XmlWriter writer, final ElementStyleSheet style ) throws IOException { final AttributeList bandStyleAtts = new AttributeList(); if ( style.isLocalKey( SparklineStyleKeys.HIGH_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.HIGH_COLOR ); bandStyleAtts.setAttribute( SparklineModule.NAMESPACE, "high-color", ColorValueConverter.colorToString( value ) ); } if ( style.isLocalKey( SparklineStyleKeys.MEDIUM_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.MEDIUM_COLOR ); bandStyleAtts .setAttribute( SparklineModule.NAMESPACE, "medium-color", ColorValueConverter.colorToString( value ) ); } if ( style.isLocalKey( SparklineStyleKeys.LOW_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.LOW_COLOR ); bandStyleAtts.setAttribute( SparklineModule.NAMESPACE, "low-color", ColorValueConverter.colorToString( value ) ); } if ( style.isLocalKey( SparklineStyleKeys.LAST_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.LAST_COLOR ); bandStyleAtts.setAttribute( SparklineModule.NAMESPACE, "last-color", ColorValueConverter.colorToString( value ) ); } if ( bandStyleAtts.isEmpty() == false ) { writer.writeTag( SparklineModule.NAMESPACE, "spark-styles", bandStyleAtts, XmlWriter.CLOSE ); } } SparklineStyleSetWriteHandler(); }
SparklineStyleSetWriteHandler implements BundleStyleSetWriteHandler { public void writeStyle( final XmlWriter writer, final ElementStyleSheet style ) throws IOException { final AttributeList bandStyleAtts = new AttributeList(); if ( style.isLocalKey( SparklineStyleKeys.HIGH_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.HIGH_COLOR ); bandStyleAtts.setAttribute( SparklineModule.NAMESPACE, "high-color", ColorValueConverter.colorToString( value ) ); } if ( style.isLocalKey( SparklineStyleKeys.MEDIUM_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.MEDIUM_COLOR ); bandStyleAtts .setAttribute( SparklineModule.NAMESPACE, "medium-color", ColorValueConverter.colorToString( value ) ); } if ( style.isLocalKey( SparklineStyleKeys.LOW_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.LOW_COLOR ); bandStyleAtts.setAttribute( SparklineModule.NAMESPACE, "low-color", ColorValueConverter.colorToString( value ) ); } if ( style.isLocalKey( SparklineStyleKeys.LAST_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.LAST_COLOR ); bandStyleAtts.setAttribute( SparklineModule.NAMESPACE, "last-color", ColorValueConverter.colorToString( value ) ); } if ( bandStyleAtts.isEmpty() == false ) { writer.writeTag( SparklineModule.NAMESPACE, "spark-styles", bandStyleAtts, XmlWriter.CLOSE ); } } SparklineStyleSetWriteHandler(); void writeStyle( final XmlWriter writer, final ElementStyleSheet style ); }
SparklineStyleSetWriteHandler implements BundleStyleSetWriteHandler { public void writeStyle( final XmlWriter writer, final ElementStyleSheet style ) throws IOException { final AttributeList bandStyleAtts = new AttributeList(); if ( style.isLocalKey( SparklineStyleKeys.HIGH_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.HIGH_COLOR ); bandStyleAtts.setAttribute( SparklineModule.NAMESPACE, "high-color", ColorValueConverter.colorToString( value ) ); } if ( style.isLocalKey( SparklineStyleKeys.MEDIUM_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.MEDIUM_COLOR ); bandStyleAtts .setAttribute( SparklineModule.NAMESPACE, "medium-color", ColorValueConverter.colorToString( value ) ); } if ( style.isLocalKey( SparklineStyleKeys.LOW_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.LOW_COLOR ); bandStyleAtts.setAttribute( SparklineModule.NAMESPACE, "low-color", ColorValueConverter.colorToString( value ) ); } if ( style.isLocalKey( SparklineStyleKeys.LAST_COLOR ) ) { final Color value = (Color) style.getStyleProperty( SparklineStyleKeys.LAST_COLOR ); bandStyleAtts.setAttribute( SparklineModule.NAMESPACE, "last-color", ColorValueConverter.colorToString( value ) ); } if ( bandStyleAtts.isEmpty() == false ) { writer.writeTag( SparklineModule.NAMESPACE, "spark-styles", bandStyleAtts, XmlWriter.CLOSE ); } } SparklineStyleSetWriteHandler(); void writeStyle( final XmlWriter writer, final ElementStyleSheet style );  }