org.pentaho.reporting.engine.classic.core.AttributeNames Java Examples
The following examples show how to use
org.pentaho.reporting.engine.classic.core.AttributeNames.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CrosstabEditSupport.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
private static String findTitle( final String field, final Band titleHeader ) { final MatcherContext context = new MatcherContext(); context.setMatchSubReportChilds( false ); NodeMatcher m = new AndMatcher( new ElementMatcher( LabelType.INSTANCE ), new AttributeMatcher( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.LABEL_FOR, field ) ); ReportElement match = ReportStructureMatcher.match( context, titleHeader, m ); if ( match == null ) { if ( titleHeader.getElementCount() > 0 ) { Element e = titleHeader.getElement( 0 ); if ( e.getElementType() instanceof LabelType ) { return e.getAttributeTyped( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, String.class ); } } return null; } return match.getAttributeTyped( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, String.class ); }
Example #2
Source File: HyperlinkFormulasIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void getFormulas() throws ResourceException { final URL url = getClass().getResource( "Prd-3883.prpt" ); assertNotNull( url ); final ResourceManager resourceManager = new ResourceManager(); resourceManager.registerDefaults(); final Resource directly = resourceManager.createDirectly( url, MasterReport.class ); final MasterReport report = (MasterReport) directly.getResource(); assertNotNull( report ); final ReportElement chart = findChart( report ); assertNotNull( chart ); final Expression attributeExpression = chart.getAttributeExpression( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE ); assertNotNull( attributeExpression ); assertTrue( attributeExpression instanceof ChartExpression ); ChartExpression chartExpression = (ChartExpression) attributeExpression; final String[] hyperlinkFormulas = chartExpression.getHyperlinkFormulas(); assertNotNull( hyperlinkFormulas ); assertEquals( 1, hyperlinkFormulas.length ); assertTrue( hyperlinkFormulas[ 0 ].startsWith( "=DRILLDOWN" ) ); }
Example #3
Source File: HtmlTextExtractor.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Prints a paragraph cell. This is a special entry point used by the processContent method and is never called from * elsewhere. This method assumes that the attributes of the paragraph have been processed as part of the table-cell * processing. * * @param box * the paragraph box * @throws IOException * if an IO error occured. */ protected void processInitialBox( final ParagraphRenderBox box ) throws IOException { if ( box.getStaticBoxLayoutProperties().isVisible() == false ) { return; } final StyleSheet styleSheet = box.getStyleSheet(); final String target = (String) styleSheet.getStyleProperty( ElementStyleKeys.HREF_TARGET ); if ( target != null ) { textExtractorHelper.handleLinkOnElement( styleSheet, target ); processStack = new HtmlTextExtractorState( processStack, true ); } else { processStack = new HtmlTextExtractorState( processStack, false ); } if ( Boolean.TRUE.equals( box.getAttributes().getAttribute( AttributeNames.Html.NAMESPACE, AttributeNames.Html.SUPPRESS_CONTENT ) ) == false ) { processParagraphChilds( box ); } if ( processStack.isWrittenTag() ) { xmlWriter.writeCloseTag(); } processStack = processStack.getParent(); }
Example #4
Source File: Prd4625Test.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Receives notification that report generation initializes the current run. <P> The event carries a * ReportState.Started state. Use this to initialize the report. * * @param event The event. */ public void reportInitialized( final ReportEvent event ) { // identifies the report we are working with. Useful for debugging! ReportStateKey subReportStateKey = event.getState().getProcessKey(); ReportStateKey parentReportStateKey = event.getState().getParentSubReportState().getProcessKey(); // System.out.println ("SubReport: " + subReportStateKey); // System.out.println ("Parent: " + parentReportStateKey); final ReportHeader reportHeader = event.getState().getReport().getReportHeader(); final Element element = reportHeader.getElement( 0 ); // this should be the chart assertEquals( "legacy-chart", element.getElementTypeName() ); final Expression attributeExpression = element.getAttributeExpression( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE ); assertNotNull( attributeExpression ); assertTrue( attributeExpression instanceof PieChartExpression ); final PieChartExpression pe = (PieChartExpression) attributeExpression; final String dataSource = pe.getDataSource(); final Expression[] expressions = event.getState().getFlowController().getMasterRow().getExpressionDataRow().getExpressions(); assertEquals( expressions.length, 2 ); // 2 expressions: One is the validate function, the other is the chart-dataset collector. // as the chart-dataset collector is added late (during report processing), our validate function // will always occupy spot 0. assertEquals( expressions[ 1 ].getName(), dataSource ); }
Example #5
Source File: NumberFieldType.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public Object getDesignValue( final ExpressionRuntime runtime, final ReportElement element ) { final Object staticValue = ElementTypeUtils.queryStaticValue( element ); if ( staticValue instanceof Number ) { Object formatStringRaw = element.getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.FORMAT_STRING ); if ( formatStringRaw == null || "".equals( formatStringRaw ) ) { // return the default behavior of BigDecimal.toString() but localized. formatStringRaw = NumberFieldType.DECIMALFORMAT_DEFAULT_PATTERN; } try { final Locale locale = runtime.getResourceBundleFactory().getLocale(); final FastDecimalFormat decimalFormat = new FastDecimalFormat( String.valueOf( formatStringRaw ), locale ); return rotate( element, decimalFormat.format( staticValue ), runtime ); } catch ( Exception e ) { // ignore .. fallback to show the fieldname } } final Object value = ElementTypeUtils.queryFieldName( element ); return rotate( element, value != null ? value : getId(), runtime ); }
Example #6
Source File: DynamicStyleKey.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public Map<InstanceID, StyleInfoCollection> collect( Band band, ExpressionRuntime runtime ) { ArgumentNullException.validate( "band", band ); ArgumentNullException.validate( "runtime", runtime ); this.runtime = runtime; dynamicTemplateInfo = (HashMap<InstanceID, StyleKey[]>) band.getAttribute( AttributeNames.Internal.NAMESPACE, AttributeNames.Internal.FAST_EXPORT_DYNAMIC_STASH ); if ( dynamicTemplateInfo == null ) { return Collections.emptyMap(); } styleInfo = new HashMap<InstanceID, StyleInfoCollection>(); inspectElement( band ); traverseSection( band ); return styleInfo; }
Example #7
Source File: ResourceMessageElementFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Generates the element based on the defined properties. * * @return the generated element. * @throws NullPointerException * if the resource class name is null. * @throws IllegalStateException * if the resource key is not defined. * @see ElementFactory#createElement() */ public Element createElement() { if ( getFormatKey() == null ) { throw new IllegalStateException( "ResourceKey is not set." ); } final Element element = new Element(); applyElementName( element ); applyStyle( element.getStyle() ); element.setElementType( new ResourceMessageType() ); element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.RESOURCE_IDENTIFIER, getResourceBase() ); element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, getFormatKey() ); element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE, getNullString() ); element .setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.MESSAGE_NULL_VALUE, getMessageNullString() ); return element; }
Example #8
Source File: SingleValueQueryFunctionIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testErrorHandlingBad() throws Exception { final URL url = getClass().getResource( "Prd-3985.prpt" ); final ResourceManager mgr = new ResourceManager(); final MasterReport report = (MasterReport) mgr.createDirectly( url, MasterReport.class ).getResource(); report.getReportConfiguration().setConfigProperty( "org.pentaho.reporting.engine.classic.core.FailOnAttributeExpressionErrors", "true" ); final FormulaExpression function = new FormulaExpression(); function.setName( "Test" ); function.setFormula( "=SINGLEVALUEQUERY(\"Bad\")" ); report.getReportHeader().setAttributeExpression( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NAME, function ); try { DebugReportRunner.createPDF( report ); Assert.fail(); } catch ( Exception e ) { } }
Example #9
Source File: RectangleType.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Returns the current value for the data source. * * @param runtime * the expression runtime that is used to evaluate formulas and expressions when computing the value of this * filter. * @param element * the element for which the data is computed. * @return the value. */ public Object getValue( final ExpressionRuntime runtime, final ReportElement element ) { if ( runtime == null ) { throw new NullPointerException( "Runtime must never be null." ); } if ( element == null ) { throw new NullPointerException( "Element must never be null." ); } final float arcWidth = parseArcParam( element, AttributeNames.Core.ARC_WIDTH ); final float arcHeight = parseArcParam( element, AttributeNames.Core.ARC_HEIGHT ); if ( arcWidth <= 0 || arcHeight <= 0 ) { return new Rectangle2D.Float( 0, 0, 100, 100 ); } return new RoundRectangle2D.Float( 0, 0, 100, 100, arcWidth, arcHeight ); }
Example #10
Source File: ElementReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Done parsing. * * @throws org.xml.sax.SAXException * if there is a parsing error. */ protected void doneParsing() throws SAXException { if ( dataSourceHandler != null ) { element.setDataSource( (DataSource) dataSourceHandler.getObject() ); } for ( int i = 0; i < styleExpressionHandlers.size(); i++ ) { final StyleExpressionHandler handler = (StyleExpressionHandler) styleExpressionHandlers.get( i ); final StyleKey key = handler.getKey(); if ( handler.getKey() != null ) { final Expression expression = handler.getExpression(); element.setStyleExpression( key, expression ); } } element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.SOURCE, getRootHandler().getSource() ); }
Example #11
Source File: HtmlRichTextProcessingTest.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
@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 ); }
Example #12
Source File: GroupReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Starts parsing. * * @param attrs * the attributes. * @throws org.xml.sax.SAXException * if there is a parsing error. */ protected void startParsing( final PropertyAttributes attrs ) throws SAXException { final String groupName = attrs.getValue( getUri(), GroupReadHandler.NAME_ATT ); if ( groupName != null ) { final AbstractReportDefinition report = (AbstractReportDefinition) getRootHandler().getHelperObject( ReportParserUtil.HELPER_OBJ_REPORT_NAME ); final Group maybeDefaultGroup = report.getGroupByName( groupName ); if ( maybeDefaultGroup instanceof RelationalGroup ) { group = (RelationalGroup) maybeDefaultGroup; } else { group = new RelationalGroup(); group.setName( groupName ); group.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.SOURCE, getRootHandler().getSource() ); } } else { group = new RelationalGroup(); group.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.SOURCE, getRootHandler().getSource() ); } }
Example #13
Source File: HtmlOutputProcessorMetaData.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Checks whether this element provides some extra content that is not part of the visible layout structure. This can * be embedded scripts, anchors etc. * * @param style * @param attributes * @return */ public boolean isExtraContentElement( final StyleSheet style, final ReportAttributeMap attributes ) { if ( isFeatureSupported( OutputProcessorFeature.DETECT_EXTRA_CONTENT ) == false ) { return false; } final Object o = attributes.getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.ELEMENT_TYPE ); if ( o instanceof MasterReportType ) { return false; } if ( super.isExtraContentElement( style, attributes ) ) { return true; } if ( StringUtils.isEmpty( (String) attributes.getAttribute( AttributeNames.Html.NAMESPACE, AttributeNames.Html.EXTRA_RAW_CONTENT ) ) == false ) { return true; } if ( StringUtils.isEmpty( (String) attributes.getAttribute( AttributeNames.Html.NAMESPACE, AttributeNames.Html.EXTRA_RAW_FOOTER_CONTENT ) ) == false ) { return true; } return false; }
Example #14
Source File: ReportDesignerSubReportRootHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Starts parsing. * * @param attrs the attributes. * @throws SAXException if there is a parsing error. */ protected void startParsing( final Attributes attrs ) throws SAXException { super.startParsing( attrs ); final Object maybeReport = getRootHandler().getHelperObject( ReportParserUtil.HELPER_OBJ_REPORT_NAME ); final SubReport report; if ( maybeReport instanceof SubReport == false ) { // replace it .. report = new SubReport(); report.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.SOURCE, getRootHandler().getSource() ); } else { report = (SubReport) maybeReport; } getRootHandler() .setHelperObject( ReportParserUtil.HELPER_OBJ_LEGACY_STYLES, new HashMap<String, ElementStyleSheet>() ); getRootHandler().setHelperObject( ReportParserUtil.HELPER_OBJ_REPORT_NAME, report ); this.report = report; }
Example #15
Source File: AbstractRenderComponent.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void editingStopped( final ChangeEvent e ) { List<Element> selectedElements = getRenderContext().getSelectionModel().getSelectedElementsOfType( Element.class ); final Element[] visualElements = selectedElements.toArray( new Element[ selectedElements.size() ] ); if ( visualElements.length > 0 ) { final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>(); for ( int i = 0; i < visualElements.length; i++ ) { final Object attribute = visualElements[ i ].getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE ); undos.add( new AttributeEditUndoEntry( visualElements[ i ].getObjectID(), AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, oldValues.get( i ), attribute ) ); } getRenderContext().getUndo().addChange( Messages.getString( "AbstractRenderComponent.InlineEditUndoName" ), new CompoundUndoEntry( (UndoEntry[]) undos.toArray( new UndoEntry[ undos.size() ] ) ) ); } removeEditor(); }
Example #16
Source File: BandReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Done parsing. * * @throws SAXException * if there is a parsing error. */ protected void doneParsing() throws SAXException { for ( int i = 0; i < elementHandlers.size(); i++ ) { final XmlReadHandler readHandler = elementHandlers.get( i ); final Element e = (Element) readHandler.getObject(); band.addElement( e ); } for ( int i = 0; i < styleExpressionHandlers.size(); i++ ) { final StyleExpressionHandler handler = styleExpressionHandlers.get( i ); if ( handler.getKey() != null ) { band.setStyleExpression( handler.getKey(), handler.getExpression() ); } } band.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.SOURCE, getRootHandler().getSource() ); super.doneParsing(); }
Example #17
Source File: Prd4634Test.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testReportFooter() throws Exception { final URL resource = getClass().getResource( "Prd-4634.prpt" ); assertNotNull( resource ); final ResourceManager mgr = new ResourceManager(); mgr.registerDefaults(); final MasterReport report = (MasterReport) mgr.createDirectly( resource, MasterReport.class ).getResource(); final GlobalAuthenticationStore globalAuthenticationStore = new GlobalAuthenticationStore(); final ReportRenderContext reportContext = new ReportRenderContext( report, report, null, globalAuthenticationStore ); final ReportFooter reportFooter = report.getReportFooter(); final TestRootBandRenderer r = new TestRootBandRenderer( reportFooter, reportContext ); final ValidateTextGraphics graphics2D = new ValidateTextGraphics( 468, 108 ); graphics2D.expectSentence( (String) reportFooter.getElement( 0 ).getAttribute ( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE ) ); assertTrue( graphics2D.hitClip( 10, 10, 1, 1 ) ); r.draw( graphics2D ); }
Example #18
Source File: ProcessState.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public boolean isSubReportExecutable() { final Expression expression = getReport().getAttributeExpression( AttributeNames.Core.NAMESPACE, AttributeNames.Core.SUBREPORT_ACTIVE ); if ( expression != null ) { // the master-report state will only be non-null for subreports. final InlineDataRowRuntime dataRowRuntime = new InlineDataRowRuntime(); dataRowRuntime.setState( this ); expression.setRuntime( dataRowRuntime ); try { final Object value = expression.getValue(); // the expression has to explicitly return false as a value to disable the report processing of // subreports. Just returning null or a non-boolean value is not enough. This is a safety measure // so that if in doubt we print more data than to little. if ( Boolean.FALSE.equals( value ) ) { return false; } if ( "false".equals( String.valueOf( value ) ) ) { return false; } return true; } finally { expression.setRuntime( null ); } } return true; }
Example #19
Source File: ExcelTableContentProducer.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected void collectSheetStyleData( final RenderBox box ) { super.collectSheetStyleData( box ); this.pageHeaderCenter = lookup( box, AttributeNames.Excel.PAGE_HEADER_CENTER, this.pageHeaderCenter ); this.pageHeaderLeft = lookup( box, AttributeNames.Excel.PAGE_HEADER_LEFT, this.pageHeaderLeft ); this.pageHeaderRight = lookup( box, AttributeNames.Excel.PAGE_HEADER_RIGHT, this.pageHeaderRight ); this.pageFooterCenter = lookup( box, AttributeNames.Excel.PAGE_FOOTER_CENTER, this.pageFooterCenter ); this.pageFooterLeft = lookup( box, AttributeNames.Excel.PAGE_FOOTER_LEFT, this.pageFooterLeft ); this.pageFooterRight = lookup( box, AttributeNames.Excel.PAGE_FOOTER_RIGHT, this.pageFooterRight ); final Integer freezeTop = (Integer) box.getAttributes().getAttribute( AttributeNames.Excel.NAMESPACE, AttributeNames.Excel.FREEZING_TOP_POSITION ); if ( this.freezeTop == null && freezeTop != null ) { this.freezeTop = freezeTop; } final Integer freezeLeft = (Integer) box.getAttributes().getAttribute( AttributeNames.Excel.NAMESPACE, AttributeNames.Excel.FREEZING_LEFT_POSITION ); if ( this.freezeLeft == null && freezeLeft != null ) { this.freezeLeft = freezeLeft; } }
Example #20
Source File: PdfLogicalPageDrawable.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected boolean drawPdfScript( final RenderNode box ) { final Object attribute = box.getAttributes().getAttribute( AttributeNames.Pdf.NAMESPACE, AttributeNames.Pdf.SCRIPT_ACTION ); if ( attribute == null ) { return false; } final String attributeText = String.valueOf( attribute ); final PdfAction action = PdfAction.javaScript( attributeText, writer, false ); final AffineTransform affineTransform = getGraphics().getTransform(); final float translateX = (float) affineTransform.getTranslateX(); final float leftX = translateX + (float) ( StrictGeomUtility.toExternalValue( box.getX() ) ); final float rightX = translateX + (float) ( StrictGeomUtility.toExternalValue( box.getX() + box.getWidth() ) ); final float lowerY = (float) ( globalHeight - StrictGeomUtility.toExternalValue( box.getY() + box.getHeight() ) ); final float upperY = (float) ( globalHeight - StrictGeomUtility.toExternalValue( box.getY() ) ); final PdfAnnotation annotation = new PdfAnnotation( writer, leftX, lowerY, rightX, upperY, action ); writer.addAnnotation( annotation ); return true; }
Example #21
Source File: SingleValueQueryFunctionIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testErrorHandlingGood() throws Exception { final URL url = getClass().getResource( "Prd-3985.prpt" ); final ResourceManager mgr = new ResourceManager(); final MasterReport report = (MasterReport) mgr.createDirectly( url, MasterReport.class ).getResource(); report.getReportConfiguration().setConfigProperty( "org.pentaho.reporting.engine.classic.core.FailOnAttributeExpressionErrors", "true" ); final FormulaExpression function = new FormulaExpression(); function.setName( "Test" ); function.setFormula( "=SINGLEVALUEQUERY(\"Good\")" ); report.getReportHeader().setAttributeExpression( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NAME, function ); try { DebugReportRunner.createPDF( report ); } catch ( Exception e ) { Assert.fail(); } }
Example #22
Source File: Prd3688IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public static Element createDataItem( final String text ) { final Element label = new Element(); label.setElementType( LabelType.INSTANCE ); label.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, text ); label.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 100f ); label.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f ); return label; }
Example #23
Source File: TableColumnGroupNode.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public TableColumnGroupNode( final StyleSheet styleSheet, final ReportAttributeMap attributes ) { super( RenderNode.HORIZONTAL_AXIS, RenderNode.VERTICAL_AXIS, styleSheet, new InstanceID(), BoxDefinition.EMPTY, AutoLayoutBoxType.INSTANCE, attributes, null ); final Integer colspan = (Integer) attributes.getAttribute( AttributeNames.Table.NAMESPACE, AttributeNames.Table.COLSPAN ); if ( colspan == null ) { this.colspan = 1; } else { this.colspan = colspan; } }
Example #24
Source File: DefaultAttributeCore.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
protected ResourceKey getDefinitionSource( final ReportElement element ) { final Object o = element.getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.SOURCE ); if ( o instanceof ResourceKey ) { return (ResourceKey) o; } final ReportElement parent = element.getParentSection(); if ( parent != null ) { return getDefinitionSource( parent ); } return null; }
Example #25
Source File: WizardProcessor.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
private void setupWatermark() { final WatermarkDefinition watermarkDefinition = wizardSpecification.getWatermarkDefinition(); if ( watermarkDefinition.isVisible() == false ) { return; } if ( watermarkDefinition.getSource() == null ) { return; } final Watermark watermark = definition.getWatermark(); final Band content = AutoGeneratorUtility.findGeneratedContent( watermark ); if ( content == null ) { // there is already some content, and we are not allowed to override it. return; } content.clear(); final Element watermarkImage = new Element(); watermarkImage.setElementType( new ContentType() ); watermarkImage.setAttribute ( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, watermarkDefinition.getSource() ); final ElementStyleSheet watermarkStyle = watermarkImage.getStyle(); watermarkStyle.setStyleProperty( ElementStyleKeys.POS_X, convertLength( watermarkDefinition.getX() ) ); watermarkStyle.setStyleProperty( ElementStyleKeys.POS_Y, convertLength( watermarkDefinition.getY() ) ); watermarkStyle.setStyleProperty( ElementStyleKeys.MIN_WIDTH, convertLength( watermarkDefinition.getWidth() ) ); watermarkStyle.setStyleProperty( ElementStyleKeys.MIN_HEIGHT, convertLength( watermarkDefinition.getHeight() ) ); watermarkStyle.setStyleProperty( ElementStyleKeys.KEEP_ASPECT_RATIO, watermarkDefinition.getKeepAspectRatio() ); watermarkStyle.setStyleProperty( ElementStyleKeys.SCALE, watermarkDefinition.getScale() ); content.addElement( watermarkImage ); }
Example #26
Source File: CellFormatFunction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
protected boolean evaluateElement( final ReportElement e ) { final DataSource source = e.getElementType(); if ( source instanceof RawDataSource ) { final ElementStyleSheet style = e.getStyle(); final String oldFormat = (String) style.getStyleProperty( ElementStyleKeys.EXCEL_DATA_FORMAT_STRING ); if ( oldFormat != null && oldFormat.length() > 0 ) { final Object attribute = e.getAttribute( AttributeNames.Internal.NAMESPACE, AttributeNames.Internal.EXCEL_CELL_FORMAT_AUTOCOMPUTE ); if ( Boolean.TRUE.equals( attribute ) == false ) { return false; } } final RawDataSource rds = (RawDataSource) source; if ( formatSpecification != null ) { formatSpecification.redefine( FormatSpecification.TYPE_UNDEFINED, null ); } formatSpecification = rds.getFormatString( getRuntime(), e, formatSpecification ); if ( formatSpecification != null ) { if ( formatSpecification.getType() == FormatSpecification.TYPE_DATE_FORMAT || formatSpecification.getType() == FormatSpecification.TYPE_DECIMAL_FORMAT ) { style.setStyleProperty( ElementStyleKeys.EXCEL_DATA_FORMAT_STRING, formatSpecification.getFormatString() ); e.setAttribute( AttributeNames.Internal.NAMESPACE, AttributeNames.Internal.EXCEL_CELL_FORMAT_AUTOCOMPUTE, Boolean.TRUE ); return true; } } } return false; }
Example #27
Source File: SortingIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testCrosstabSorting() { List<SortConstraint> sc = new ArrayList<SortConstraint>(); sc.add( new SortConstraint( "A", true ) ); sc.add( new SortConstraint( "B", true ) ); MasterReport report = new MasterReport(); report.setQuery( "default" ); report.setDataFactory( new ValidateDataFactory( "default", new DefaultTableModel( 10, 10 ), sc ) ); report.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.AUTOSORT, true ); RelationalGroup rootGroup = (RelationalGroup) report.getRootGroup(); rootGroup.setFields( Arrays.asList( "A", "B" ) ); int i = DebugReportRunner.execGraphics2D( report ); }
Example #28
Source File: TableCellSizingIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public Element createDataItem( final String text, final int x, final int y ) { final Element label = new Element(); label.setElementType( LabelType.INSTANCE ); label.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, "asajsdlkasjdalksdjalskdjalsdjalsdkjalsdajlsdjasldkajld" ); label.getStyle().setStyleProperty( ElementStyleKeys.HEIGHT, 20f ); return label; }
Example #29
Source File: AggregateFieldPreProcessor.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
private void configureRelationalAggreation( final ReportElement element, final AggregationFunction o ) { // relational element ... final String group = (String) element.getAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.AGGREGATION_GROUP ); if ( group != null ) { o.setGroup( group ); } else { final Group g = findGroup( element ); if ( g != null ) { o.setGroup( g.getGeneratedName() ); } } }
Example #30
Source File: ContentElementFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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; }