Java Code Examples for org.pentaho.reporting.engine.classic.core.Element#getStyle()
The following examples show how to use
org.pentaho.reporting.engine.classic.core.Element#getStyle() .
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: TextAlignmentCenterAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Invoked when an action occurs. */ public void actionPerformed( final ActionEvent e ) { final DocumentContextSelectionModel model = getSelectionModel(); if ( model == null ) { return; } final List<Element> visualElements = model.getSelectedElementsOfType( Element.class ); final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>(); for ( Element element : visualElements ) { final ElementStyleSheet styleSheet = element.getStyle(); undos.add( StyleEditUndoEntry.createConditional( element, ElementStyleKeys.ALIGNMENT, ElementAlignment.CENTER ) ); styleSheet.setStyleProperty( ElementStyleKeys.ALIGNMENT, ElementAlignment.CENTER ); element.notifyNodePropertiesChanged(); } getActiveContext().getUndo().addChange( ActionMessages.getString( "TextAlignmentCenterAction.UndoName" ), new CompoundUndoEntry( undos.toArray( new UndoEntry[ undos.size() ] ) ) ); }
Example 2
Source File: BoldAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Invoked when an action occurs. */ public void actionPerformed( final ActionEvent e ) { final DocumentContextSelectionModel model = getSelectionModel(); if ( model == null ) { return; } final List<Element> visualElements = model.getSelectedElementsOfType( Element.class ); Boolean value = null; final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>(); for ( Element element : visualElements ) { final ElementStyleSheet styleSheet = element.getStyle(); if ( value == null ) { if ( styleSheet.getBooleanStyleProperty( TextStyleKeys.BOLD ) ) { value = Boolean.FALSE; } else { value = Boolean.TRUE; } } undos.add( StyleEditUndoEntry.createConditional( element, TextStyleKeys.BOLD, value ) ); styleSheet.setStyleProperty( TextStyleKeys.BOLD, value ); } getActiveContext().getUndo().addChange( ActionMessages.getString( "BoldAction.UndoName" ), new CompoundUndoEntry( undos.toArray( new UndoEntry[ undos.size() ] ) ) ); }
Example 3
Source File: KeepAspectRatioAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected void updateSelection() { super.updateSelection(); final DocumentContextSelectionModel model = getSelectionModel(); if ( model == null ) { return; } final List<Element> visualElements = model.getSelectedElementsOfType( Element.class ); if ( visualElements.isEmpty() ) { setSelected( false ); return; } final Element element = visualElements.get( 0 ); final ElementStyleSheet styleSheet = element.getStyle(); setSelected( styleSheet.getBooleanStyleProperty( ElementStyleKeys.KEEP_ASPECT_RATIO ) ); }
Example 4
Source File: TextAlignmentRightAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected void updateSelection() { super.updateSelection(); final DocumentContextSelectionModel model = getSelectionModel(); if ( model == null ) { return; } final List<Element> visualElements = model.getSelectedElementsOfType( Element.class ); if ( visualElements.isEmpty() ) { setSelected( false ); return; } final Element element = visualElements.get( 0 ); final ElementStyleSheet styleSheet = element.getStyle(); setSelected( ElementAlignment.RIGHT.equals( styleSheet.getStyleProperty( ElementStyleKeys.ALIGNMENT ) ) ); }
Example 5
Source File: TextAlignmentJustifyAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Invoked when an action occurs. */ public void actionPerformed( final ActionEvent e ) { final DocumentContextSelectionModel model = getSelectionModel(); if ( model == null ) { return; } final List<Element> visualElements = model.getSelectedElementsOfType( Element.class ); final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>(); for ( Element element : visualElements ) { final ElementStyleSheet styleSheet = element.getStyle(); undos .add( StyleEditUndoEntry.createConditional( element, ElementStyleKeys.ALIGNMENT, ElementAlignment.JUSTIFY ) ); styleSheet.setStyleProperty( ElementStyleKeys.ALIGNMENT, ElementAlignment.JUSTIFY ); element.notifyNodePropertiesChanged(); } getActiveContext().getUndo().addChange( ActionMessages.getString( "TextAlignmentJustifyAction.UndoName" ), new CompoundUndoEntry( undos.toArray( new UndoEntry[ undos.size() ] ) ) ); }
Example 6
Source File: TextAlignmentJustifyAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected void updateSelection() { super.updateSelection(); final DocumentContextSelectionModel model = getSelectionModel(); if ( model == null ) { return; } final List<Element> visualElements = model.getSelectedElementsOfType( Element.class ); if ( visualElements.isEmpty() ) { setSelected( false ); return; } final Element element = visualElements.get( 0 ); final ElementStyleSheet styleSheet = element.getStyle(); setSelected( ElementAlignment.JUSTIFY.equals( styleSheet.getStyleProperty( ElementStyleKeys.ALIGNMENT ) ) ); }
Example 7
Source File: TextAlignmentCenterAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected void updateSelection() { super.updateSelection(); final DocumentContextSelectionModel model = getSelectionModel(); if ( model == null ) { return; } final List<Element> visualElements = model.getSelectedElementsOfType( Element.class ); if ( visualElements.isEmpty() ) { setSelected( false ); return; } final Element element = visualElements.get( 0 ); final ElementStyleSheet styleSheet = element.getStyle(); setSelected( ElementAlignment.CENTER.equals( styleSheet.getStyleProperty( ElementStyleKeys.ALIGNMENT ) ) ); }
Example 8
Source File: TextAlignmentLeftAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected void updateSelection() { super.updateSelection(); final DocumentContextSelectionModel model = getSelectionModel(); if ( model == null ) { return; } final List<Element> visualElements = model.getSelectedElementsOfType( Element.class ); if ( visualElements.isEmpty() ) { setSelected( false ); return; } final Element element = visualElements.get( 0 ); final ElementStyleSheet styleSheet = element.getStyle(); setSelected( ElementAlignment.LEFT.equals( styleSheet.getStyleProperty( ElementStyleKeys.ALIGNMENT ) ) ); }
Example 9
Source File: ScaleAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Invoked when an action occurs. */ public void actionPerformed( final ActionEvent e ) { final DocumentContextSelectionModel model = getSelectionModel(); if ( model == null ) { return; } final List<Element> visualElements = model.getSelectedElementsOfType( Element.class ); final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>(); Boolean value = null; for ( Element element : visualElements ) { final ElementStyleSheet styleSheet = element.getStyle(); if ( value == null ) { if ( styleSheet.getBooleanStyleProperty( ElementStyleKeys.SCALE ) ) { value = Boolean.FALSE; } else { value = Boolean.TRUE; } } undos.add( StyleEditUndoEntry.createConditional( element, ElementStyleKeys.SCALE, value ) ); styleSheet.setStyleProperty( ElementStyleKeys.SCALE, value ); } getActiveContext().getUndo().addChange( ActionMessages.getString( "ScaleAction.UndoName" ), new CompoundUndoEntry( undos.toArray( new UndoEntry[ undos.size() ] ) ) ); }
Example 10
Source File: ApplyFontSizeAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Invoked when an action occurs. */ public void actionPerformed( final ActionEvent e ) { final Object o = comboBox.getSelectedItem(); if ( o instanceof Integer == false ) { return; } final Integer fontSize = (Integer) o; final DocumentContextSelectionModel model = getSelectionModel(); if ( model == null ) { return; } final List<Element> visualElements = model.getSelectedElementsOfType( Element.class ); final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>(); for ( Element visualElement : visualElements ) { final ElementStyleSheet styleSheet = visualElement.getStyle(); undos.add( StyleEditUndoEntry.createConditional( visualElement, TextStyleKeys.FONTSIZE, fontSize ) ); styleSheet.setStyleProperty( TextStyleKeys.FONTSIZE, fontSize ); visualElement.notifyNodePropertiesChanged(); } getActiveContext().getUndo().addChange( ActionMessages.getString( "ApplyFontSizeAction.UndoName" ), new CompoundUndoEntry( undos.toArray( new UndoEntry[ undos.size() ] ) ) ); }
Example 11
Source File: DefaultReportElementDragHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected Element createElement( final ElementMetaData elementMetaData, final String fieldName, final ReportDocumentContext context ) throws InstantiationException { final ElementType type = elementMetaData.create(); final Element visualElement = (Element) type.create(); final ElementStyleSheet styleSheet = visualElement.getStyle(); styleSheet.setStyleProperty( ElementStyleKeys.MIN_WIDTH, DEFAULT_WIDTH ); styleSheet.setStyleProperty( ElementStyleKeys.MIN_HEIGHT, DEFAULT_HEIGHT ); type.configureDesignTimeDefaults( visualElement, Locale.getDefault() ); if ( elementMetaData.getAttributeDescription( AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD ) != null ) { visualElement.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD, fieldName ); } configureWizardProperties( fieldName, context, visualElement ); return visualElement; }
Example 12
Source File: UnderlineAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Invoked when an action occurs. */ public void actionPerformed( final ActionEvent e ) { final DocumentContextSelectionModel model = getSelectionModel(); if ( model == null ) { return; } final List<Element> visualElements = model.getSelectedElementsOfType( Element.class ); Boolean value = null; final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>(); for ( Element element : visualElements ) { final ElementStyleSheet styleSheet = element.getStyle(); if ( value == null ) { if ( styleSheet.getBooleanStyleProperty( TextStyleKeys.UNDERLINED ) ) { value = Boolean.FALSE; } else { value = Boolean.TRUE; } } undos.add( StyleEditUndoEntry.createConditional( element, TextStyleKeys.UNDERLINED, value ) ); styleSheet.setStyleProperty( TextStyleKeys.UNDERLINED, value ); element.notifyNodePropertiesChanged(); } getActiveContext().getUndo().addChange( ActionMessages.getString( "UnderlineAction.UndoName" ), new CompoundUndoEntry( undos.toArray( new UndoEntry[ undos.size() ] ) ) ); }
Example 13
Source File: StrikethroughAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Invoked when an action occurs. */ public void actionPerformed( final ActionEvent e ) { final DocumentContextSelectionModel model = getSelectionModel(); if ( model == null ) { return; } final List<Element> visualElements = model.getSelectedElementsOfType( Element.class ); final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>(); Boolean value = null; for ( Element element : visualElements ) { final ElementStyleSheet styleSheet = element.getStyle(); if ( value == null ) { if ( styleSheet.getBooleanStyleProperty( TextStyleKeys.STRIKETHROUGH ) ) { value = Boolean.FALSE; } else { value = Boolean.TRUE; } } undos.add( StyleEditUndoEntry.createConditional( element, TextStyleKeys.STRIKETHROUGH, value ) ); styleSheet.setStyleProperty( TextStyleKeys.STRIKETHROUGH, value ); element.notifyNodePropertiesChanged(); } getActiveContext().getUndo().addChange( ActionMessages.getString( "StrikethroughAction.UndoName" ), new CompoundUndoEntry( undos.toArray( new UndoEntry[ undos.size() ] ) ) ); }
Example 14
Source File: PasteFormatAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void undo( final ReportDocumentContext renderContext ) { final Element target = (Element) ModelUtility.findElementById( renderContext.getReportDefinition(), element ); final ElementStyleSheet styleSheet = target.getStyle(); final StyleKey[] keys = StyleKey.getDefinedStyleKeys(); for ( int i = 0; i < oldStyleData.length; i++ ) { final Object o = oldStyleData[ i ]; if ( o != null ) { styleSheet.setStyleProperty( keys[ i ], o ); } } final String[] namespaces = oldAttributes.getNameSpaces(); for ( int i = 0; i < namespaces.length; i++ ) { final String namespace = namespaces[ i ]; final String[] names = oldAttributes.getNames( namespace ); for ( int j = 0; j < names.length; j++ ) { final String name = names[ j ]; target.setAttribute( namespace, name, oldAttributes.getAttribute( namespace, name ), false ); } } target.notifyNodePropertiesChanged(); }
Example 15
Source File: AlignmentUtilities.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void resizeProportional() { final float originalPageWidth = originalPageDefinition.getWidth(); final float currentPageWidth = currentPageDefinition.getWidth(); final float scaleFactor = currentPageWidth / originalPageWidth; for ( Element element : visualElements ) { // Resize the element. final CachedLayoutData cachedLayoutData = ModelUtility.getCachedLayoutData( element ); final double elementWidth = StrictGeomUtility.toExternalValue( cachedLayoutData.getWidth() ); final ElementStyleSheet styleSheet = element.getStyle(); styleSheet.setStyleProperty( ElementStyleKeys.MIN_WIDTH, new Float( elementWidth * scaleFactor ) ); // Reposition the element. final double origin = StrictGeomUtility.toExternalValue( cachedLayoutData.getX() ); final double destination = scaleFactor * origin; final int theShift = (int) ( destination - origin ); final List<Element> elementsCarrier = new ArrayList<Element>( 1 ); elementsCarrier.add( element ); align( theShift, elementsCarrier ); } registerChanges(); }
Example 16
Source File: ReportDescriptionWriter.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
private void writeStyleInfo( final Element band ) throws IOException, ReportWriterException { final XmlWriter writer = getXmlWriter(); final ElementStyleSheet styleSheet = band.getStyle(); if ( isStyleSheetEmpty( styleSheet ) == false ) { writer.writeTag( ExtParserModule.NAMESPACE, AbstractXMLDefinitionWriter.STYLE_TAG, XmlWriterSupport.OPEN ); final StyleWriter styleWriter = new StyleWriter( getReportWriter(), band.getStyle(), writer ); styleWriter.write(); writer.writeCloseTag(); } final Map<StyleKey, Expression> styleExpressions = band.getStyleExpressions(); if ( styleExpressions.isEmpty() == false ) { final FunctionsWriter fnWriter = new FunctionsWriter( getReportWriter(), writer ); for ( final Map.Entry<StyleKey, Expression> entry : styleExpressions.entrySet() ) { final StyleKey key = entry.getKey(); final Expression ex = entry.getValue(); fnWriter.writeStyleExpression( ex, key ); } } }
Example 17
Source File: AbstractMouseDragOperation.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
protected boolean isCanvasElement( final Element reportElement ) { final ElementStyleSheet styleSheet = reportElement.getStyle(); final Object o = styleSheet.getStyleProperty( BandStyleKeys.LAYOUT ); if ( BandStyleKeys.LAYOUT_CANVAS.equals( o ) ) { return true; } if ( o != null ) { return false; } return true; }
Example 18
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 19
Source File: StyleTableModel.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
protected Object computeInheritValue( final StyleMetaData metaData, final int rowIndex ) { final DefaultStyleDataBackend dataBackend1 = getDataBackend(); final Object[] inheritValues = dataBackend1.getInheritValues(); final Object o = inheritValues[ rowIndex ]; if ( o == StyleDataBackend.NULL_INDICATOR ) { return null; } if ( o != null ) { return o; } boolean allLocalKeys = true; boolean allInheritedKeys = true; final Element[] elements = dataBackend1.getData(); if ( elements.length > 0 ) { final Element element = elements[ 0 ]; final ElementStyleSheet styleSheet = element.getStyle(); final boolean localKey = styleSheet.isLocalKey( metaData.getStyleKey() ); allLocalKeys = allLocalKeys & localKey; allInheritedKeys = ( localKey == false ); } final Object retval; if ( allLocalKeys == true && allInheritedKeys == true ) { retval = null; } else if ( allInheritedKeys == true ) { retval = Boolean.TRUE; } else if ( allLocalKeys == true ) { retval = Boolean.FALSE; } else { retval = null; } if ( retval == null ) { inheritValues[ rowIndex ] = StyleDataBackend.NULL_INDICATOR; } else { inheritValues[ rowIndex ] = retval; } return retval; }
Example 20
Source File: RelationalAutoGeneratorPreProcessor.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
protected void generate( final AbstractReportDefinition definition, final DefaultFlowController flowController ) throws ReportProcessingException { final GroupDataBody groupDataBody = (GroupDataBody) definition.getChildElementByType( GroupDataBodyType.INSTANCE ); if ( groupDataBody == null ) { return; } final Band details = AutoGeneratorUtility.findGeneratedContent( groupDataBody.getItemBand() ); final Band header = AutoGeneratorUtility.findGeneratedContent( groupDataBody.getDetailsHeader() ); final Band footer = AutoGeneratorUtility.findGeneratedContent( groupDataBody.getDetailsFooter() ); final ProcessingContext reportContext = flowController.getReportContext(); final DefaultDataAttributeContext dac = new DefaultDataAttributeContext( reportContext.getOutputProcessorMetaData(), reportContext .getResourceBundleFactory().getLocale() ); final DataRow dataRow = flowController.getMasterRow().getGlobalView(); final DataSchema dataSchema = flowController.getMasterRow().getDataSchema(); // final Locale locale = reportContext.getResourceBundleFactory().getLocale(); final AutoGeneratorFieldDescription[] fieldDescriptions = computeFields( dataRow, dataSchema, dac ); if ( fieldDescriptions == null || fieldDescriptions.length == 0 ) { // there are no fields, so what's the point of continuing .. return; } if ( details != null ) { details.clear(); details.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, "row" ); } if ( header != null ) { header.clear(); header.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, "row" ); } if ( footer != null ) { footer.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, "row" ); footer.clear(); } final float[] widths = computeFieldWidths( fieldDescriptions, definition.getPageDefinition().getWidth() ); for ( int i = 0; i < fieldDescriptions.length; i++ ) { final AutoGeneratorFieldDescription fieldDescription = fieldDescriptions[i]; if ( header != null ) { final Element headerElement = AutoGeneratorUtility.generateHeaderElement( fieldDescription.getFieldName() ); final ElementStyleSheet headerStyle = headerElement.getStyle(); headerStyle.setStyleProperty( ElementStyleKeys.MIN_WIDTH, new Float( widths[i] ) ); header.addElement( headerElement ); } if ( details != null ) { final Element detailsElement = AutoGeneratorUtility.generateDetailsElement( fieldDescription.getFieldName(), fieldDescription .getTargetType() ); if ( Boolean.TRUE.equals( fieldDescription.getHideDuplicateValues() ) ) { detailsElement.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ONLY_SHOW_CHANGING_VALUES, Boolean.TRUE ); } final ElementStyleSheet detailsStyle = detailsElement.getStyle(); detailsStyle.setStyleProperty( ElementStyleKeys.MIN_WIDTH, new Float( widths[i] ) ); details.addElement( detailsElement ); } } }