public ReportElement create() { final Element element = new Element(); element.setElementType( this ); return element; }
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; }
/** * Constructs an element. * <p/> * The element inherits the element's defined default ElementStyleSheet to provide reasonable default values for * common stylekeys. When the element is added to the band, the bands stylesheet is set as parent to the element's * stylesheet. * <p/> * A datasource is assigned with this element is set to a default source, which always returns null. */ public Element() { treeLock = new InstanceID(); datasource = Element.NULL_DATASOURCE; style = new InternalElementStyleSheet( this ); attributes = new ReportAttributeMap<Object>(); setElementType( LegacyType.INSTANCE ); }
/** * Creates the resource field element based on the set properties. * * @return the generated element. * @see org.pentaho.reporting.engine.classic.core.elementfactory.ElementFactory#createElement() */ public Element createElement() { final Element element = super.createElement(); element.setElementType( new ResourceFieldType() ); element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.RESOURCE_IDENTIFIER, getResourceBase() ); return element; }
public static Element generateDetailsElement( final String fieldName, final ElementType targetType ) { final Element detailsElement = new Element(); detailsElement.getStyle().setStyleProperty( ElementStyleKeys.DYNAMIC_HEIGHT, Boolean.TRUE ); detailsElement.setElementType( targetType ); detailsElement.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD, fieldName ); detailsElement.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ALLOW_METADATA_STYLING, Boolean.TRUE ); detailsElement.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ALLOW_METADATA_ATTRIBUTES, Boolean.TRUE ); return detailsElement; }
/** * 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; }
/** * 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 VerticalLineType() ); return element; } }
/** * 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 EllipseType() ); return element; } }
public static Element generateHeaderElement( final String fieldName ) { final Element headerElement = new Element(); headerElement.getStyle().setStyleProperty( ElementStyleKeys.DYNAMIC_HEIGHT, Boolean.TRUE ); headerElement.setElementType( new LabelType() ); headerElement.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.LABEL_FOR, fieldName ); headerElement.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ALLOW_METADATA_STYLING, Boolean.TRUE ); headerElement.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ALLOW_METADATA_ATTRIBUTES, Boolean.TRUE ); return headerElement; }
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() ); }
/** * 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 RectangleType() ); element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.ARC_WIDTH, arcWidth ); element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.ARC_HEIGHT, arcHeight ); return element; }
/** * 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 ContentType() ); if ( content != null ) { element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, content ); } if ( baseURL != null ) { element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.CONTENT_BASE, baseURL ); } return element; } }
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; }
/** * Creates the label element. * * @return the generated label. * @throws IllegalStateException * if the text is not defined. * @see org.pentaho.reporting.engine.classic.core.elementfactory.ElementFactory#createElement() */ public Element createElement() { final Element element = new Element(); element.setElementType( new LabelType() ); applyElementName( element ); applyStyle( element.getStyle() ); element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, getText() ); element.setAttribute( AttributeNames.Excel.NAMESPACE, AttributeNames.Excel.FIELD_FORMULA, getExcelFormula() ); return element; }
private Element createLabel( final String text, float width ) { final Element element = new Element(); element.setElementType( LabelType.INSTANCE ); element.getElementType().configureDesignTimeDefaults( element, Locale.getDefault() ); element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, text ); element.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, width ); element.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 20f ); return element; } }
public static Element createDataItem( final String text, final float width, final float height ) { final Element label = new Element(); label.setElementType( LabelType.INSTANCE ); label.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, text ); label.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, width ); label.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, height ); return label; }
/** * Creates the message text element based on the defined settings. Undefined properties will not be set in the * generated element. * * @return the generated numeric text element * @see org.pentaho.reporting.engine.classic.core.elementfactory.ElementFactory#createElement() */ public Element createElement() { final Element element = new Element(); applyElementName( element ); applyStyle( element.getStyle() ); element.setElementType( new MessageType() ); element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE, getNullString() ); element .setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.MESSAGE_NULL_VALUE, getMessageNullString() ); element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, getFormatString() ); return element; }
private Element process( final javax.swing.text.Element textElement ) throws BadLocationException { if ( textElement.isLeaf() ) { final int endOffset = textElement.getEndOffset(); final int startOffset = textElement.getStartOffset(); final String text = textElement.getDocument().getText( startOffset, endOffset - startOffset ); final Element result = new Element(); result.setElementType( LabelType.INSTANCE ); result.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, text ); configureStyle( textElement.getAttributes(), result ); return result; } final Band band = new Band(); configureStyle( textElement.getAttributes(), band ); configureBand( textElement, band ); final int size = textElement.getElementCount(); for ( int i = 0; i < size; i++ ) { final Element element = process( textElement.getElement( i ) ); band.addElement( element ); } return band; }
@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 ); }
@Test public void testCSSConversionDefault() { final Element element = new Element(); 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 ); RichTextHtmlStyleBuilderFactory richTextBuilder = new RichTextHtmlStyleBuilderFactory(); String codeCss = richTextBuilder.produceTextStyle( null, new SimpleStyleSheet( resolverTarget ) ).toString(); String expected = "color: black; font-size: 10pt; font-family: serif; font-weight: normal; font-style: normal; " + "text-decoration: none; text-align: left; word-spacing: 0pt; letter-spacing: 0pt; white-space: pre"; assertEquals( expected, codeCss ); }