private boolean isInlineElement( final Element element ) { if ( element instanceof Band ) { if ( "inline".equals( element.getStyle().getStyleProperty( BandStyleKeys.LAYOUT, "inline" ) ) ) { return true; } return false; } return true; }
/** * Returns the currently set link target for this element. * * @return the link target. */ public String getHRefTarget() { return (String) getStyle().getStyleProperty( ElementStyleKeys.HREF_TARGET ); }
public String getLayout() { return (String) getStyle().getStyleProperty( BandStyleKeys.LAYOUT ); }
/** * Returns the value of a parameter. * * @param name * the parameter name. * @return The value. */ public Object getParameter( final String name ) { final StyleKey key = keyfactory.getStyleKey( name ); if ( key == null ) { throw new IllegalArgumentException( "There is no handler for the stylekey: " + name ); } return styleSheet.getStyleProperty( key ); }
/** * Returns a string representation of the band, useful mainly for debugging purposes. * * @return a string representation of this band. */ public String toString() { final StringBuilder b = new StringBuilder( 100 ); b.append( this.getClass().getName() ); b.append( "={name=\"" ); b.append( getName() ); b.append( "\", size=\"" ); b.append( getElementCount() ); b.append( "\", layout=\"" ); b.append( getStyle().getStyleProperty( BandStyleKeys.LAYOUT ) ); b.append( "\"}" ); return b.toString(); }
/** * Returns a string representation of the band, useful mainly for debugging purposes. * * @return a string representation of this band. */ public String toString() { final StringBuilder b = new StringBuilder( 100 ); b.append( this.getClass().getName() ); b.append( "={name=\"" ); b.append( getName() ); b.append( "\", size=\"" ); b.append( getElementCount() ); b.append( "\", layout=\"" ); b.append( getStyle().getStyleProperty( BandStyleKeys.LAYOUT ) ); b.append( "\"}" ); return b.toString(); }
default Object rotate( final ReportElement element, final Object value, final ExpressionRuntime runtime ) { if ( element != null && value != null && isRotationSupported( runtime ) ) { final ElementStyleSheet style = element.getStyle(); if ( style != null ) { final Object styleProperty = style.getStyleProperty( TextStyleKeys.TEXT_ROTATION, null ); if ( styleProperty instanceof TextRotation ) { final TextRotation rotation = (TextRotation) styleProperty; return new RotatedTextDrawable( String.valueOf( value ), rotation ); } } } return value; }
public static void writeRotationStyles( final XmlWriter writer, final ElementStyleSheet style ) throws IOException { if ( writer == null ) { throw new NullPointerException(); } if ( style == null ) { throw new NullPointerException(); } final AttributeList bandStyleAtts = new AttributeList(); if ( style.isLocalKey( TextStyleKeys.TEXT_ROTATION ) ) { final Object value = style.getStyleProperty( TextStyleKeys.TEXT_ROTATION ); bandStyleAtts.setAttribute( BundleNamespaces.STYLE, "rotation", value.toString() ); } if ( bandStyleAtts.isEmpty() == false ) { writer.writeTag( BundleNamespaces.STYLE, "rotation-styles", bandStyleAtts, XmlWriterSupport.CLOSE ); } } }
private static void assertEverySecondKey( ElementStyleSheet sheet, List<StyleKey> keys ) { for ( int i = 0; i < keys.size(); i += 2 ) { StyleKey key = keys.get( i ); Object property = sheet.getStyleProperty( key ); Object expected = valueFor( key ); assertEquals( String.format( "Key[%d]: %s", i, key.name ), expected, property ); } } }
public void initialize( final CrosstabSpecification crosstabSpecification, final CrosstabGroup group, final int crosstabGroupIndex ) { this.crosstabSpecification = crosstabSpecification; this.crosstabGroupIndex = crosstabGroupIndex; computeGroupCounts( group ); CrosstabDetailMode detailMode = group.getDetailsMode(); if ( detailMode == null ) { detailMode = CrosstabDetailMode.last; } this.detailMode = detailMode; this.generateMeasureHeaders = !( Boolean.FALSE.equals( group.getAttribute( AttributeNames.Crosstab.NAMESPACE, AttributeNames.Crosstab.PRINT_DETAIL_HEADER ) ) ); this.generateColumnTitleHeaders = !( Boolean.FALSE.equals( group.getAttribute( AttributeNames.Crosstab.NAMESPACE, AttributeNames.Crosstab.PRINT_COLUMN_TITLE_HEADER ) ) ); this.tableLayout = (TableLayout) group.getStyle().getStyleProperty( BandStyleKeys.TABLE_LAYOUT, TableLayout.fixed ); }
public void setStyleProperty( final StyleKey key, final Object value ) { final long l = getChangeTracker(); final Object oldValue; if ( super.isLocalKey( key ) ) { oldValue = super.getStyleProperty( key ); } else { oldValue = null; } super.setStyleProperty( key, value ); if ( l != getChangeTracker() ) { element.notifyNodePropertiesChanged( new StyleChange( key, oldValue, value ) ); } } }
@Test public void getStyleProperty_OnIntactSheet() { List<StyleKey> keys = StyleKey.getDefinedStyleKeysList(); ElementStyleSheet sheet = new ElementStyleSheet(); final Float val = 123f; Object property = sheet.getStyleProperty( keys.get( 0 ), val ); assertEquals( "When nothing has been changed, default value should be returned", val, property ); }
public void testSetHRefTarget() { Element elem = new Element(); elem.setHRefTarget( "test_target" ); assertEquals( "test_target", elem.getStyle().getStyleProperty( ElementStyleKeys.HREF_TARGET ) ); }
@Test public void getStyleProperty_ReturnsSetValue() { List<StyleKey> keys = StyleKey.getDefinedStyleKeysList(); StyleKey key = keys.get( 0 ); ElementStyleSheet sheet = new ElementStyleSheet(); sheet.setStyleProperty( key, valueFor( key ) ); Object property = sheet.getStyleProperty( key, 2f ); assertEquals( valueFor( key ), property ); }
@Test public void addInherited_ElementSheet() { List<StyleKey> keys = StyleKey.getDefinedStyleKeysList(); ElementStyleSheet sheet = new ElementStyleSheet(); setEveryInheritableKey( sheet, keys ); ElementStyleSheet another = new ElementStyleSheet(); another.addInherited( sheet ); for ( int i = 0; i < keys.size(); i++ ) { StyleKey key = keys.get( i ); if ( key.isInheritable() ) { Object property = another.getStyleProperty( key ); assertEquals( String.format( "Key[%d]: %s", i, key.name ), defaultValues.get( key.getValueType() ), property ); assertFalse( "addInherited() doesn't add properties as local", another.isLocalKey( key ) ); } } }
private void testAmountMod4IsN( int n ) { final int toAdd = 4 - ( defaultKeysAmount % 4 ) + n; for ( int i = 0; i < toAdd; i++ ) { //noinspection deprecation StyleKey syntheticKey = StyleKey.addTestKey( "syntheticKey_" + i, String.class, false, false ); testKeys.add( syntheticKey ); } assertEquals( "Default key list's size % 4 should be equal " + ( n % 4 ), n % 4, StyleKey.getDefinedStyleKeysList().size() % 4 ); ElementStyleSheet sheet = new ElementStyleSheet(); for ( StyleKey key : testKeys ) { sheet.setStyleProperty( key, key.name ); } for ( StyleKey key : testKeys ) { assertEquals( key.name, sheet.getStyleProperty( key ) ); assertTrue( sheet.isLocalKey( key ) ); } } }
@Test public void clearsCorrectly() { List<StyleKey> keys = StyleKey.getDefinedStyleKeysList(); ElementStyleSheet sheet = new ElementStyleSheet(); setEverySecondKey( sheet, keys ); sheet.clear(); assertEquals( 0, sheet.getModificationCount() ); assertEquals( 0, sheet.getChangeTrackerHash() ); for ( int i = 0; i < keys.size(); i += 2 ) { StyleKey key = keys.get( i ); Object property = sheet.getStyleProperty( key ); assertNull( property ); } }
@Test public void copyFrom_OnIntactSheet_SameAsClearing() { List<StyleKey> keys = StyleKey.getDefinedStyleKeysList(); ElementStyleSheet sheet = new ElementStyleSheet(); setEverySecondKey( sheet, keys ); sheet.copyFrom( new ElementStyleSheet() ); assertEquals( 0, sheet.getModificationCount() ); assertEquals( 0, sheet.getChangeTrackerHash() ); for ( int i = 0; i < keys.size(); i += 2 ) { StyleKey key = keys.get( i ); Object property = sheet.getStyleProperty( key ); assertNull( property ); } }
@Test public void addInherited_SimpleSheet() { List<StyleKey> keys = StyleKey.getDefinedStyleKeysList(); ElementStyleSheet sheet = new ElementStyleSheet(); setEveryInheritableKey( sheet, keys ); SimpleStyleSheet simpleStyleSheet = new SimpleStyleSheet( new ElementStyleSheet() ); sheet.addInherited( simpleStyleSheet ); for ( int i = 0; i < keys.size(); i++ ) { StyleKey key = keys.get( i ); if ( key.isInheritable() ) { Object property = sheet.getStyleProperty( key ); assertNull( "Previous values should be overriden", property ); assertFalse( "addInherited() doesn't add properties as local", sheet.isLocalKey( key ) ); } } }
@Test public void setStyleProperty_NullValuesAreTreatedAsAbsent() { List<StyleKey> keys = StyleKey.getDefinedStyleKeysList(); StyleKey key = keys.get( 0 ); ElementStyleSheet sheet = new ElementStyleSheet(); sheet.setStyleProperty( key, valueFor( key ) ); sheet.setStyleProperty( key, null ); assertEquals( valueFor( key ), sheet.getStyleProperty( key, valueFor( key ) ) ); assertFalse( sheet.isLocalKey( key ) ); }