private Element createLiNumElement( final String _liNum ) { final Element linum = new Element(); linum.setName( "point" ); linum.setElementType( LabelType.INSTANCE ); linum.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, _liNum ); return linum; }
.setAttributeExpression( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, bshExpression ); imageElement.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.IMAGE_ENCODING_QUALITY, "9" ); imageElement.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.IMAGE_ENCODING_TYPE, "PNG" );
public void testElementAttributeCopyOnWrite2() { final Element e = new Element(); final Element clone = e.clone(); clone.setAttribute( "namespace", "name", "value" ); assertNull( e.getAttribute( "namespace", "name" ) ); }
public ReportElement create() { final Element element = new Element(); element.setElementType( this ); return element; }
public void testCloneAttributeOrder() throws Exception { final Element e = new Element(); e.setAttribute( "Namespace1", "Attr1", "Value1" ); e.setAttribute( "Namespace1", "Attr2", "Value1" ); e.setAttribute( "Namespace1", "Attr3", "Value1" ); e.setAttribute( "Namespace2", "Attr1", "Value1" ); e.setAttribute( "Namespace2", "Attr2", "Value1" ); e.setAttribute( "Namespace2", "Attr3", "Value1" ); final Element e2 = (Element) e.clone(); final String[] attributeNamespaces = e2.getAttributeNamespaces(); assertEquals( Arrays.asList( attributeNamespaces ), Arrays.asList( e.getAttributeNamespaces() ) ); for ( int i = 0; i < attributeNamespaces.length; i++ ) { final String namespace = attributeNamespaces[i]; final String[] names = e2.getAttributeNames( namespace ); assertEquals( Arrays.asList( names ), Arrays.asList( e.getAttributeNames( namespace ) ) ); } }
public void copyInto( final Element target ) { final ElementMetaData metaData = getMetaData(); final String[] attributeNamespaces = getAttributeNamespaces(); for ( int i = 0; i < attributeNamespaces.length; i++ ) { final String namespace = attributeNamespaces[i]; final String[] attributeNames = getAttributeNames( namespace ); for ( int j = 0; j < attributeNames.length; j++ ) { final String name = attributeNames[j]; target.setAttribute( namespace, name, getAttribute( namespace, name ), false ); final String[] attrExprNamespaces = getAttributeExpressionNamespaces(); for ( int i = 0; i < attrExprNamespaces.length; i++ ) { final String namespace = attrExprNamespaces[i]; final String[] attributeNames = getAttributeExpressionNames( namespace ); for ( int j = 0; j < attributeNames.length; j++ ) { final String name = attributeNames[j]; target.setAttributeExpression( namespace, name, getAttributeExpression( namespace, name ) ); final ElementStyleSheet styleSheet = getStyle(); final StyleKey[] styleKeys = styleSheet.getDefinedPropertyNamesArray(); for ( int i = 0; i < styleKeys.length; i++ ) { final StyleKey styleKey = styleKeys[i]; if ( styleKey != null ) { target.getStyle().setStyleProperty( styleKey, styleSheet.getStyleProperty( styleKey ) ); final Set<Map.Entry<StyleKey, Expression>> styleExpressionEntries = getStyleExpressions().entrySet(); for ( final Map.Entry<StyleKey, Expression> entry : styleExpressionEntries ) { target.setStyleExpression( entry.getKey(), entry.getValue() );
public static Element generateFooterElement( final Class aggregationType, final ElementType targetType, final String group, final String fieldName ) { if ( aggregationType == null ) { final Element footerValueElement = new Element(); footerValueElement.setElementType( new LabelType() ); footerValueElement.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, "" ); footerValueElement.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ALLOW_METADATA_STYLING, Boolean.TRUE ); footerValueElement.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ALLOW_METADATA_ATTRIBUTES, Boolean.FALSE ); return footerValueElement; } final Element element = generateDetailsElement( fieldName, targetType ); element.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.AGGREGATION_TYPE, aggregationType ); element.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.AGGREGATION_GROUP, group ); return element; }
final ElementMetaData metaData = element.getElementType().getMetaData(); final String[] attributeNamespaces = element.getAttributeNamespaces(); for ( int i = 0; i < attributeNamespaces.length; i++ ) { final String namespace = attributeNamespaces[i]; final String[] attributeNames = element.getAttributeNames( namespace ); for ( int j = 0; j < attributeNames.length; j++ ) { final String name = attributeNames[j]; final Object value = element.getAttribute( namespace, name ); if ( value == null ) { continue;
/** * Creates a new drawable field element based on the defined properties. * * @return the generated elements * @throws IllegalStateException * if the field name is not set. * @see ElementFactory#createElement() */ public Element createElement() { final Element element = new Element(); applyElementName( element ); applyStyle( element.getStyle() ); element.setElementType( new HorizontalLineType() ); return element; }
public void testElementMethods() { final Element e = new Element(); assertTrue( e.isVisible() ); e.setVisible( false ); assertTrue( e.isVisible() == false ); e.setVisible( true ); assertTrue( e.isVisible() ); try { e.setDataSource( null ); fail(); } catch ( NullPointerException npe ) { // expected, ignored } e.toString(); }
@Test public void testRichTextParsing() { HtmlRichTextConverter richTextConverter = new HtmlRichTextConverter(); final Element element = new Element(); element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, RICHTEXT ); element.setElementType( new LabelType() ); final Object o = richTextConverter.convert( element, RICHTEXT ); final Element elementlist = new Element(); elementlist.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, RICHTEXT ); elementlist.setElementType( new LabelType() ); final SimpleStyleResolver styleResolver = new SimpleStyleResolver( true ); final ResolverStyleSheet resolverTarget = new ResolverStyleSheet(); styleResolver.resolve( element, resolverTarget ); elementlist.setComputedStyle( new SimpleStyleSheet( resolverTarget ) ); final Band o2 = (Band) richTextConverter.convert( elementlist, LISTTEXT ); ReportElement[] re = o2.getChildElementsByName( "point" ); assertTrue( re.length == 13 ); System.out.println( re.length ); System.out.println( o ); }
final ResourceKey contentBase = element.getContentBase(); if ( contentBase == null ) { return; final ResourceKey defSource = element.getDefinitionSource(); if ( defSource == null ) { final ResourceManager resourceManager = state.getMasterReport().getResourceManager(); final ElementType type = element.getElementType(); final ElementMetaData data = type.getMetaData(); final AttributeMetaData[] datas = data.getAttributeDescriptions(); final Object attValue = element.getAttribute( attributeMetaData.getNameSpace(), attributeMetaData.getName() ); if ( attValue == null ) { continue;
final ResourceKey contentBase = reportElement.getContentBase(); final ResourceKey elementSource = reportElement.getDefinitionSource(); if ( attributeValue instanceof ResourceKey ) { final ResourceKey path = (ResourceKey) attributeValue;
public void testCopyInto() { Element e1 = new Element(); e1.setElementType( LabelType.INSTANCE ); Element e2 = new Element(); e2.setElementType( NumberFieldType.INSTANCE ); e2.copyInto( e1 ); Assert.assertEquals( LabelType.INSTANCE, e1.getElementType() ); Assert.assertEquals( NumberFieldType.INSTANCE, e2.getElementType() ); }
if ( handler.getKey() != null ) { final Expression expression = handler.getExpression(); element.setStyleExpression( key, expression ); final AttributeExpressionReadHandler handler = attributeExpressions.get( i ); final Expression expression = handler.getExpression(); element.setAttributeExpression( handler.getNamespace(), handler.getName(), expression ); element.setAttribute( expressionReadHandler.getAttributeNameSpace(), expressionReadHandler.getAttributeName(), expressionReadHandler.getObject() );
result.getStyle().setStyleProperty( TextStyleKeys.FONT, String.valueOf( fontFamily ) ); result.getStyle().setStyleProperty( TextStyleKeys.FONTSIZE, Math.round( parseLength( String.valueOf( fontSize ) ) ) ); if ( fontWeight != null ) { String fontWeightStr = String.valueOf( fontWeight ); result.getStyle().setStyleProperty( TextStyleKeys.BOLD, fontWeightStr.toLowerCase().equals( "bold" ) ); if ( fontStyle != null ) { String fontStyleStr = String.valueOf( fontStyle ); result.getStyle().setStyleProperty( TextStyleKeys.ITALIC, fontStyleStr.toLowerCase().equals( "italic" ) ); result.getStyle().setStyleProperty( TextStyleKeys.X_OPTIMUM_LETTER_SPACING, parseLength( String.valueOf( letterSpacing ) ) ); result.getStyle().setStyleProperty( TextStyleKeys.WORD_SPACING, parseLength( String.valueOf( wordSpacing ) ) ); result.getStyle().setStyleProperty( TextStyleKeys.LINEHEIGHT, parseLength( String.valueOf( lineHeight ) ) ); result.getStyle().setStyleProperty( ElementStyleKeys.ALIGNMENT, ReportParserUtil.parseHorizontalElementAlignment( String.valueOf( textAlign ), null ) ); } catch ( ParseException e ) { if ( textDecoration != null ) { final String[] strings = StringUtils.split( String.valueOf( textDecoration ) ); result.getStyle().setStyleProperty( TextStyleKeys.STRIKETHROUGH, Boolean.FALSE ); result.getStyle().setStyleProperty( TextStyleKeys.UNDERLINED, Boolean.FALSE ); result.getStyle().setStyleProperty( TextStyleKeys.STRIKETHROUGH, Boolean.TRUE );
/** * Defines the Xml-ID of this element. This ID is unique within the report-definition, but is not a internal * object-instance ID but a user-defined string. * * @param id * the element id. */ public void setId( final String id ) { setAttribute( AttributeNames.Xml.NAMESPACE, AttributeNames.Xml.ID, id ); }
public void testGetId() { Element elem = new Element(); elem.setAttribute( AttributeNames.Xml.NAMESPACE, AttributeNames.Xml.ID, "id_0" ); assertEquals( "id_0", elem.getId() ); }
public void testGetFirstAttribute() { Element elem = new Element(); elem.setAttribute( "namespace_0", "test_name", "test_value_0" ); elem.setAttribute( "namespace_1", "test_name", "test_value_1" ); assertNotNull( elem.getFirstAttribute( "test_name" ) ); assertEquals( "test_value_0", elem.getFirstAttribute( "test_name" ) ); }