Java 类net.sf.jasperreports.engine.design.JRDesignStyle 实例源码

项目:jasperreports    文件:JRStyleFactory.java   
@Override
protected void setParentStyle(JRDesignStyle currentStyle, String parentStyleName)
{
    JasperDesign jasperDesign = (JasperDesign) digester.peek(digester.getCount() - 2);
    Map<String,JRStyle> stylesMap = jasperDesign.getStylesMap();

    if (stylesMap.containsKey(parentStyleName))
    {
        JRStyle parent = stylesMap.get(parentStyleName);
        currentStyle.setParentStyle(parent);
    }
    else
    {
        currentStyle.setParentStyleNameReference(parentStyleName);
    }
}
项目:jasperreports    文件:JRAbstractStyleFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRDesignStyle style = new JRDesignStyle();

    // get style name
    style.setName(atts.getValue(JRXmlConstants.ATTRIBUTE_name));

    String isDefault = atts.getValue(JRXmlConstants.ATTRIBUTE_isDefault);
    if (isDefault != null && isDefault.length() > 0)
    {
        style.setDefault(Boolean.valueOf(isDefault).booleanValue());
    }

    // get parent style
    if (atts.getValue(JRXmlConstants.ATTRIBUTE_style) != null)
    {
        setParentStyle(style, atts.getValue(JRXmlConstants.ATTRIBUTE_style));
    }

    // set common style attributes
    setCommonStyle(style, atts);

    return style;
}
项目:jasperreports    文件:JRPrintStyleFactory.java   
@Override
protected void setParentStyle(JRDesignStyle currentStyle, String parentStyleName)
{
    JRPrintXmlLoader printXmlLoader = (JRPrintXmlLoader) digester.peek(digester.getCount() - 1);
    JasperPrint jasperPrint = (JasperPrint) digester.peek(digester.getCount() - 2);
    Map<String,JRStyle> stylesMap = jasperPrint.getStylesMap();

    if (!stylesMap.containsKey(parentStyleName))
    {
        printXmlLoader.addError(
            new JRRuntimeException(
                EXCEPTION_MESSAGE_KEY_UNKNOWN_REPORT_STYLE,
                new Object[]{parentStyleName}
            )
        );
    }

    JRStyle parent = stylesMap.get(parentStyleName);
    currentStyle.setParentStyle(parent);
}
项目:PDFReporter-Studio    文件:ApplyCrosstabStyleAction.java   
/**
 * Extract the list of styles actually used on the crosstab 
 * 
 * @return the list of styles actually used in the cells of the crosstab in this order 
 * crosstab header, group, total and detail
 */
public JRDesignStyle[] getStylesFromCrosstab(){
    JRDesignCrosstab crosstab = (JRDesignCrosstab)getElement();
    List<JRDesignCellContents> contents = ModelUtils.getAllCells(crosstab);
    JRDesignStyle[] stylesArray = new JRDesignStyle[4];
    for (JRDesignCellContents content : contents)
    {
        if (content == null) continue;
        JRStyle actualStyle = content.getStyle();
        if (actualStyle != null && actualStyle instanceof JRDesignStyle){
            int index = getBackgroundIndex(crosstab, content.getOrigin());
            if (index != -1) stylesArray[index] = (JRDesignStyle)actualStyle;
        }
    }
    return stylesArray;
}
项目:PDFReporter-Studio    文件:ApplyTableStyleAction.java   
/**
 * 
 * Apply the list of styles to the cell of the table. The styles are first set to null and then at
 * the style value, to force a graphical update (the style are not update if the name is the same)
 * 
 * @param styleList list of styles that will be applied on the table, the order is important
 * and it should be: Table Style (unused), Table Header, Column Header and Detail. 
 */
private void setCellStyles(List<JRDesignStyle> styleList){
    StandardTable table = getStandardTable(getElement());
    List<BaseColumn> columns = TableUtil.getAllColumns(table);
    for(BaseColumn col : columns){
        setColumnStyles(col, styleList);
    }

    for(BaseColumn baseCol : table.getColumns()){
        if (baseCol instanceof StandardColumnGroup){
            StandardColumnGroup columnGroup = (StandardColumnGroup)baseCol;
            setColumnStyles(columnGroup,styleList);
        }
    }

}
项目:PDFReporter-Studio    文件:ApplyTableStyleAction.java   
/**
 * Extract the list of styles actually used on the table 
 * 
 * @return the list of styles actually used in the cells of the table in this order 
 * null (for retrocompatibility), Table Header, Column Header and Detail.
 */
public JRDesignStyle[] getStylesFromTable(){
    StandardTable jrTable = getStandardTable(getElement());
    List<BaseColumn> columns = TableUtil.getAllColumns(jrTable);
    JRDesignStyle[] stylesArray = new JRDesignStyle[4];
    if (columns.size()>0){
        BaseColumn standardCol = columns.get(0);
        if (standardCol.getColumnFooter() != null) stylesArray[2] = (JRDesignStyle)standardCol.getColumnFooter().getStyle();
        if (standardCol.getColumnHeader() != null) stylesArray[2] = (JRDesignStyle)standardCol.getColumnFooter().getStyle();
        if (standardCol.getTableHeader() != null) stylesArray[1] = (JRDesignStyle)standardCol.getTableHeader().getStyle();
        if (standardCol.getTableFooter() != null) stylesArray[1] = (JRDesignStyle)standardCol.getTableFooter().getStyle();
        if (standardCol instanceof StandardColumn){
            DesignCell detCell = (DesignCell) ((StandardColumn)standardCol).getDetailCell();
            if (detCell != null)  stylesArray[3] = (JRDesignStyle)detCell.getStyle();
        }
    }
    return stylesArray;
}
项目:PDFReporter-Studio    文件:StyleSection.java   
public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) {
    super.createControls(parent, tabbedPropertySheetPage);

    parent.setLayout(new GridLayout(2, false));

    if (!(getElement() instanceof MConditionalStyle))
        createWidget4Property(parent, JRDesignStyle.PROPERTY_NAME);

    createWidget4Property(parent, JRDesignStyle.PROPERTY_PARENT_STYLE);

    GridData gd = new GridData();
    gd.horizontalSpan = 2;
    if (!(getElement() instanceof MConditionalStyle))
        createWidget4Property(parent, JRDesignStyle.PROPERTY_DEFAULT, false).getControl().setLayoutData(gd);

    createWidget4Property(parent, JRDesignStyle.PROPERTY_BLANK_WHEN_NULL);

    createWidget4Property(parent, JRDesignStyle.PROPERTY_PATTERN);

    createWidget4Property(parent, JRBaseStyle.PROPERTY_FILL);
    createWidget4Property(parent, JRBaseStyle.PROPERTY_RADIUS);
    createWidget4Property(parent, JRBaseStyle.PROPERTY_SCALE_IMAGE);
}
项目:PDFReporter-Studio    文件:StylesListSection.java   
/**
 * Print the attributes of all the styles of the element
 * 
 * @param styles
 *          List of styles
 * @param parent
 *          composite of the main widget
 */
private void printStyles(LinkedList<MStyle> styles, Composite parent) {
    ListIterator<MStyle> itr = styles.listIterator();
    boolean hasDefaultStyleInGerarchy = false;
    while (itr.hasNext()) {
        MStyle style = itr.next();
        printStyleAttribute(parent, style,
                Messages.StylesSectionList_Inherited_From_Style + style.getPropertyValue(JRDesignStyle.PROPERTY_NAME),
                "", elementAttributes, true); //$NON-NLS-1$
        if (style == defaultStyle)
            hasDefaultStyleInGerarchy = true;
    }
    if (!hasDefaultStyleInGerarchy && defaultStyle != null && defaultStyle != getElement())
        printStyleAttribute(
                parent,
                defaultStyle,
                Messages.StylesListSection_Inherited_From_Default_Style.concat(defaultStyle.getPropertyValue(
                        JRDesignStyle.PROPERTY_NAME).toString()), "", elementAttributes, true); //$NON-NLS-1$ //$NON-NLS-2$
}
项目:PDFReporter-Studio    文件:MConditionalStyle.java   
@Override
public void createPropertyDescriptors(List<IPropertyDescriptor> desc, Map<String, Object> defaultsMap) {
    super.createPropertyDescriptors(desc, defaultsMap);

    Set<IPropertyDescriptor> toRemove = new HashSet<IPropertyDescriptor>();
    // remove name, defaults
    for (IPropertyDescriptor d : desc) {
        if (d.getId().equals(JRDesignStyle.PROPERTY_NAME))
            toRemove.add(d);
        else if (d.getId().equals(JRDesignStyle.PROPERTY_DEFAULT))
            toRemove.add(d);
    }
    desc.removeAll(toRemove);

    JRExpressionPropertyDescriptor conditionalExpressionD = new JRExpressionPropertyDescriptor(
            JRDesignConditionalStyle.PROPERTY_CONDITION_EXPRESSION, Messages.MConditionalStyle_conditional_expression);
    conditionalExpressionD.setCategory(Messages.MConditionalStyle_properties_category);
    conditionalExpressionD.setDescription(Messages.MConditionalStyle_conditional_expression_description);
    desc.add(conditionalExpressionD);

}
项目:PDFReporter-Studio    文件:MStyles.java   
/**
 * When something that can change the default styles changes it check
 * if the default style is changed, and if yes it is updated in the
 * jasperdesign and the redrwan of the elements is requested
 */
public void updateDefaulStyle(){
    JasperDesign jd = getJasperDesign();
    if (jd != null){
        JRStyle oldDefault = jd.getDefaultStyle();
        JRStyle newDefault = getDefaultStyle(getChildren());
        if (oldDefault != newDefault){
            //remove the flag from the old style, but only if it is an internal style
            if (oldDefault != null && jd.getStylesList().contains(oldDefault)){
                //If the style is internal by setting the default value will cause already the refresh of the elements
                ((JRDesignStyle)oldDefault).setDefault(false);
            } else {
                //If the style is external must be refresh all the elements
                fireUpdateForElements();
            }
            jd.setDefaultStyle(newDefault);
        }
    }
}
项目:PDFReporter-Studio    文件:DeleteStyleCommand.java   
@Override
public void execute() {
    elementPosition = jrDesign.getStylesList().indexOf(jrStyle);
    jrDesign.removeStyle(jrStyle);
    elementsUsingStyle = new ArrayList<JRDesignElement>();
    for(JRDesignElement element : ModelUtils.getAllElements(jrDesign)){
        if (jrStyle.equals(element.getStyle())){
            elementsUsingStyle.add(element);
            element.setStyle(null);
        }
    }
    stylesUsingStyle = new ArrayList<JRDesignStyle>();
    for(JRStyle style : jrDesign.getStyles()){
        if (jrStyle.equals(style.getStyle()) && style instanceof JRDesignStyle){
            JRDesignStyle baseStyle = (JRDesignStyle)style;
            stylesUsingStyle.add(baseStyle);
            baseStyle.setParentStyle(null);
        }
    }
}
项目:PDFReporter-Studio    文件:DeleteStyleCommand.java   
@Override
public void undo() {
    try {
        if (elementPosition < 0 || elementPosition > jrDesign.getStylesList().size())
            jrDesign.addStyle(jrStyle);
        else
            jrDesign.addStyle(elementPosition, jrStyle);
        for(JRDesignElement element : elementsUsingStyle){
            element.setStyle(jrStyle);
        }
        for(JRDesignStyle style : stylesUsingStyle){
            style.setParentStyle(jrStyle);
        }
        elementsUsingStyle = null;
    } catch (JRException e) {
        e.printStackTrace();
    }
}
项目:PDFReporter-Studio    文件:MFont.java   
@Override
public HashMap<String, Object> getStylesDescriptors() {
    HashMap<String, Object> result = new HashMap<String, Object>();
    if (getValue() == null)
        return result;
    JRFont element = (JRFont) getValue();
    result.put(JRDesignStyle.PROPERTY_FONT_NAME, element.getOwnFontName());
    result.put(JRDesignStyle.PROPERTY_FONT_SIZE, element.getOwnFontsize());
    result.put(JRDesignStyle.PROPERTY_PDF_ENCODING, element.getOwnPdfEncoding());
    result.put(JRDesignStyle.PROPERTY_PDF_FONT_NAME, element.getOwnPdfFontName());
    result.put(JRDesignStyle.PROPERTY_BOLD, element.isOwnBold());
    result.put(JRDesignStyle.PROPERTY_ITALIC, element.isOwnItalic());
    result.put(JRDesignStyle.PROPERTY_UNDERLINE, element.isOwnUnderline());
    result.put(JRDesignStyle.PROPERTY_PDF_EMBEDDED, element.isOwnPdfEmbedded());
    result.put(JRDesignStyle.PROPERTY_STRIKE_THROUGH, element.isOwnStrikeThrough());
    return result;
}
项目:PDFReporter-Studio    文件:UpdateStyleCommand.java   
@Override
public void execute() {
    oldStyle = jrElement.getStyle() != null ? jrElement.getStyle().getName() : null;;
    String styleName = newStyleTemplate.getDescription();
    JRStyle previousStyle = checkIfExist(styleName);
    if (previousStyle == null){
     JRDesignStyle previousDesignStyle = new JRDesignStyle();
     previousDesignStyle.setName(createStyleName(styleName));
     copyTextStyleToStyle(previousDesignStyle);
     CreateStyleCommand command = new CreateStyleCommand(elementModel.getJasperDesign(), previousDesignStyle);
     styleCreted = true;
     command.execute();
     previousStyle = previousDesignStyle;
    }
    elementModel.setPropertyValue(JRDesignElement.PROPERTY_PARENT_STYLE, previousStyle.getName());
}
项目:PDFReporter-Studio    文件:TextualContributionItem.java   
public void widgetSelected(SelectionEvent e) {
    if (!refreshing){
        List<Object> selection = getSelectionForType(MTextElement.class);
        if (selection.isEmpty())
            return;
        String value = fontName.getText();
        JSSCompoundCommand cc = new JSSCompoundCommand(null);
        for(Object textElement : selection){
            Command changeValueCmd = createCommand(textElement, value, JRDesignStyle.PROPERTY_FONT_NAME);
            if (changeValueCmd != null) {
                cc.add(changeValueCmd);
                cc.setReferenceNodeIfNull(textElement);
            }
        }
        getCommandStack().execute(cc);
    }
}
项目:PDFReporter-Studio    文件:TextualContributionItem.java   
/**
 * Create a single button into the toolbar
 * 
 * @param increment true if the button should be used for increment, false otherwise
 */
private ToolItem createFontSizeButton(final boolean increment, ToolBar buttons){
    Image imageValue;
    String message;
    if (increment){
        imageValue = JaspersoftStudioPlugin.getInstance().getImage("/icons/resources/edit-size-up.png");
        message = MessageFormat.format(Messages.SPButon_Size_Increment, new Object[]{factor.toString()});
    } else {
        imageValue = JaspersoftStudioPlugin.getInstance().getImage("/icons/resources/edit-size-down.png");
        message = MessageFormat.format(Messages.SPButon_Size_Decrement, new Object[]{factor.toString()});
    }
    ToolItem button = new ToolItem(buttons, SWT.PUSH);
    button.setImage(imageValue);
    button.setToolTipText(message);     
    button.setData(JRDesignStyle.PROPERTY_FONT_SIZE);
    button.setWidth(25);
    button.addSelectionListener(fontSizeButtonSelect);
    return button;
}
项目:PDFReporter-Studio    文件:StyleTemplateImportWizard.java   
/**
 * We will initialize file contents with the imported styles
 */
@Override
protected InputStream openContentStream() {
    try {
        JRSimpleTemplate tmp = new JRSimpleTemplate();
        if (stylesToImport == null || stylesToImport.isEmpty()){
            JRDesignStyle jrDesignStyle = new JRDesignStyle();
            jrDesignStyle.setName("SimpleStyle"); //$NON-NLS-1$
            tmp.addStyle(jrDesignStyle);
        } else {
            for(JRStyle style : stylesToImport){
                tmp.addStyle(style);
            }
        }
        String contents = JRXmlTemplateWriter.writeTemplate(tmp);
        return new ByteArrayInputStream(contents.getBytes());
    } catch (JRException e) {
        e.printStackTrace();
    }
    return null;
}
项目:ireport-fork    文件:TableObjectScene.java   
private void updateStyleListeners()
{
    if (getJasperDesign() != null)
    {
        List styles = getJasperDesign().getStylesList();
        for (int i=0; i<styles.size(); ++i)
        {
            if (styles.get(i) instanceof JRDesignStyle)
            {
                ((JRDesignStyle)styles.get(i)).getEventSupport().removePropertyChangeListener(stylesChangeListener);
                ((JRDesignStyle)styles.get(i)).getEventSupport().addPropertyChangeListener(stylesChangeListener);
            }
        }
    }


}
项目:ireport-fork    文件:AbstractStyleProperty.java   
@Override
public List getTagList() 
{
    List tags = new ArrayList();
    tags.add(new Tag( null , ""));
    List styles = jasperDesign.getStylesList();
    for (int i=0; i<styles.size(); ++i)
    {
        JRDesignStyle style = (JRDesignStyle)styles.get(i);
        tags.add(new Tag( style , style.getName()));
        style.getEventSupport().addPropertyChangeListener(
            WeakListeners.propertyChange(this, style.getEventSupport())
            );
    }

    // Add all the references too...
    JRReportTemplate[] templates = jasperDesign.getTemplates();
    for (int i=0; i<templates.length; ++i)
    {
        tags.addAll(getStyleInTemplate(templates[i]));
    }

    return tags;
}
项目:jasperreports    文件:StyleUpdater.java   
@Override
public JasperDesign update(JasperDesign jasperDesign)
{
    JRDesignStyle style = (JRDesignStyle)jasperDesign.getStyles()[0];
    style.setForecolor(Color.BLUE);
    style.setFontSize(14f);
    style.setBold(Boolean.TRUE);
    return jasperDesign;
}
项目:jasperreports    文件:JRTemplateStyleFactory.java   
@Override
protected void setParentStyle(JRDesignStyle currentStyle, String parentStyleName)
{
    JRSimpleTemplate template = (JRSimpleTemplate) digester.peek(digester.getCount() - 1);
    JRStyle parent = template.getStyle(parentStyleName);

    if (parent == null)
    {
        currentStyle.setParentStyleNameReference(parentStyleName);
    }
    else
    {
        currentStyle.setParentStyle(parent);
    }
}
项目:jasperreports    文件:JRConditionalStyleFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRDesignConditionalStyle style = new JRDesignConditionalStyle();
    JRDesignStyle parentStyle = (JRDesignStyle) digester.peek();

    style.setParentStyle(parentStyle);
    parentStyle.addConditionalStyle(style);

    return style;
}
项目:PDFReporter-Studio    文件:ApplyCrosstabStyleAction.java   
/**
 * 
 * Apply the list of styles to the cell of the crosstab. The styles are first set to null and then at
 * the style value, to force a graphical update (the style are not update if the name is the same)
 * 
 * @param styleList list of styles that will be applied on the crosstab, the order is important
 * and it should be: crosstab header, group, total and detail
 */
private void setCellStyles(List<JRDesignStyle> styleList) {
    JRDesignCrosstab crosstab = (JRDesignCrosstab) getElement();
    List<JRDesignCellContents> contents = ModelUtils.getAllCells(crosstab);
    for (JRDesignCellContents content : contents) 
    {
        if (content == null) continue;
        JRDesignStyle style = getCellBackgroundColor(crosstab, content.getOrigin(), styleList);
        if (style != null) {
            try {
                content.setStyle(null);
                content.setStyle(style);
                content.setMode(ModeEnum.OPAQUE);
                // Set the text white if the background color its color is
                // too similar to the background
                Color backGround = style.getBackcolor();
                int luminance = (30 * backGround.getRed() + 59
                        * backGround.getGreen() + 11 * backGround.getBlue()) / 255;
                if (luminance < 50) {
                    JRElement[] elements = content.getElements();
                    for (int i = 0; i < elements.length; ++i) {
                        if (elements[i] instanceof JRDesignTextElement) {
                            ((JRDesignTextElement) elements[i])
                                    .setForecolor(Color.WHITE);
                        }
                    }
                }
            } catch (NullPointerException e) {
            }
        }
    }
}
项目:PDFReporter-Studio    文件:UpdateCrosstabStyleCommand.java   
@Override
public void undo() {
    ArrayList<JRDesignStyle> styles =  new ArrayList<JRDesignStyle>(Arrays.asList(oldStyles));
    ApplyCrosstabStyleAction applyAction = new ApplyCrosstabStyleAction(styles, crosstab.getValue()); 
    //Restore the new style, if the update has created new styles they will be also removed
    applyAction.updateStyle(crosstab.getJasperDesign(), styles, false, true);
    oldStyles = null;
    crosstab.setChangedProperty(true);
}
项目:PDFReporter-Studio    文件:CreateColumnGroupAction.java   
@Override
public void run() {
    super.run();
    MCrosstab crosstab = null;
    Object selected = getSelectedObjects().get(0);
    if (selected instanceof EditPart) {
        EditPart part = (EditPart) selected;
        if (part.getModel() instanceof MCrosstab) crosstab = (MCrosstab)part.getModel();
    } 
    if (crosstab != null){
        ApplyCrosstabStyleAction applyStyle = new ApplyCrosstabStyleAction(new ArrayList<JRDesignStyle>(), crosstab.getValue());
        applyStyle.rebuildStylesFromCrosstab();
        applyStyle.applayStyle(crosstab.getJasperDesign());
    }
}
项目:PDFReporter-Studio    文件:CreateRowGroupAction.java   
@Override
public void run() {
    super.run();
    MCrosstab crosstab = null;
    Object selected = getSelectedObjects().get(0);
    if (selected instanceof EditPart) {
        EditPart part = (EditPart) selected;
        if (part.getModel() instanceof MCrosstab) crosstab = (MCrosstab)part.getModel();
    } 
    if (crosstab != null){
        ApplyCrosstabStyleAction applyStyle = new ApplyCrosstabStyleAction(new ArrayList<JRDesignStyle>(), crosstab.getValue());
        applyStyle.rebuildStylesFromCrosstab();
        applyStyle.applayStyle(crosstab.getJasperDesign());
    }
}
项目:PDFReporter-Studio    文件:RemoveCrosstabStylesAction.java   
/**
 * Create the command to remove the style from a single cell and to delete the style 
 * itself if the deleteStyle flag is enabled and if the command to delete the style
 * was not already generated
 * 
 * @param cell the cell from where the style must be removed 
 * @param container compound command where the new commands will be stored
 */
protected void createCommand(JRCellContents cell, JSSCompoundCommand container){
    if (cell != null && cell instanceof JRDesignCellContents){
        container.add(new RemoveStyleCommand((JRDesignCellContents)cell));
        if (deleteStyles && cell.getStyle() != null){
            JRStyle style = cell.getStyle();
            if (!deletedStyles.contains(style.getName())){
                deletedStyles.add(style.getName());
                container.add(new DeleteStyleCommand(design, (JRDesignStyle)style));
            }
        }
    }
}
项目:PDFReporter-Studio    文件:TableTemplateEngine.java   
/**
 * From an array of JRDesignStyle try to find the style to apply to the table. The styles searched must have 
 * a specific name: Table, Table_TH, Table_CH, Table_TD. If all this four styles are found then a List with 
 * their references is returned, otherwise some default styles will be generated and returned
 * 
 * @param styleArray the array of JRDesignStyle
 * @return a list of style that will be applied to the table
 */
private List<JRDesignStyle> buildStylesList(JasperDesign jd){
    JRStyle[] styleArray = jd.getStyles();
    JRDesignStyle[] result = new JRDesignStyle[4];
    for(JRStyle style : styleArray){
        if(style instanceof JRDesignStyle){
            //if (style.getName().equals("Table")) result[0] = (JRDesignStyle)style; else
            if (style.getName().equals("Table_TH")) result[1] = (JRDesignStyle)style; //$NON-NLS-1$
            else if (style.getName().equals("Table_CH")) result[2] = (JRDesignStyle)style; //$NON-NLS-1$
            else if (style.getName().equals("Table_TD")) result[3] = (JRDesignStyle)style; //$NON-NLS-1$
        }
    }
    if (result[1] == null || result[2] == null || result[3] == null ) {
        //Styles missing, generating default styles
        TableStyle defaultPattern = new TableStyle(AlfaRGB.getFullyOpaque(ColorConstants.white.getRGB()), ColorSchemaGenerator.SCHEMAS.PALE, 
                                                        BorderStyleEnum.FULL, AlfaRGB.getFullyOpaque(ColorConstants.black.getRGB()), false);
        ApplyTableStyleAction stylesGenerator = new ApplyTableStyleAction(defaultPattern, null);
        List<JRDesignStyle> defaultStyles = stylesGenerator.createStyles(jd);
        defaultStyles.get(1).setBackcolor(Color.white);
        defaultStyles.get(2).setBackcolor(Color.white);
        defaultStyles.get(3).setBackcolor(Color.white);
        if (result[1] == null) result[1] = defaultStyles.get(1);
        if (result[2] == null) result[2] = defaultStyles.get(2);
        if (result[3] == null) result[3] = defaultStyles.get(3);
    }
    return new ArrayList<JRDesignStyle>(Arrays.asList(result));
}
项目:PDFReporter-Studio    文件:TableTemplateEngine.java   
/**
 * Get a JasperDesign and check if that JasperDesign can be used as Template and processed
 * by this engine. 
 * 
 * @param design the design to check
 * @return a List of founded error, the list is void if no error are found
 */
public static List<String> validateJasperDesig(JasperDesign design){

    List<String> errorsList = new ArrayList<String>();

    boolean[] foundedStyles = {false, false,false};

    JRStyle[] styleArray = design.getStyles();
    for(JRStyle style : styleArray){
        if(style instanceof JRDesignStyle){
            if (style.getName().equals("Table_TH")) foundedStyles[0] = true;  //$NON-NLS-1$
            else if (style.getName().equals("Table_CH")) foundedStyles[1] = true; //$NON-NLS-1$
            else if (style.getName().equals("Table_TD")) foundedStyles[2] = true; //$NON-NLS-1$
        }
    }
    if (!foundedStyles[0]) errorsList.add(Messages.TableTemplateEngine_missingStyleTH);
    if (!foundedStyles[1]) errorsList.add(Messages.TableTemplateEngine_missingStyleCH);
    if (!foundedStyles[2]) errorsList.add(Messages.TableTemplateEngine_missingStyleD);

    JRDesignComponentElement tableComponent = getTable(design);
    if (tableComponent == null) errorsList.add(Messages.TableTemplateEngine_missingTable);
    else{
        StandardTable table = (StandardTable)tableComponent.getComponent();

        if (table.getColumns().size()>1 || table.getColumns().size() < 1) {
            errorsList.add(Messages.TableTemplateEngine_oneColumnError); 
        } else {
            if (findStaticTextElement(table, TEXT_MARKER) == null) errorsList.add(Messages.TableTemplateEngine_missingStaticText); //$NON-NLS-1$
            if (findTextFieldElement(table, FIELD_MARKER) == null) errorsList.add(Messages.TableTemplateEngine_missingTextField); //$NON-NLS-1$
        }
    }

    return errorsList;
}
项目:PDFReporter-Studio    文件:ApplyTableStyleAction.java   
/**
 * Generate the styles and apply them to the cells of the table
 * 
 * @param design the jasperdesign
 */
@Override
public void applayStyle(JasperDesign design) 
{   
    List<JRDesignStyle> styleList = createStyles(design); 
    setCellStyles(styleList);
}
项目:PDFReporter-Studio    文件:UpdateStyleCommand.java   
@Override
public void undo() {
    ArrayList<JRDesignStyle> styles =  new ArrayList<JRDesignStyle>(Arrays.asList(oldStyles));
    ApplyTableStyleAction applyAction = new ApplyTableStyleAction(styles, table.getValue()); 
    //Restore the new style, if the update has created new styles they will be also removed
    applyAction.updateStyle(table.getJasperDesign(), styles, false, true);
    oldStyles = null;
    table.setChangedProperty(true);
}
项目:PDFReporter-Studio    文件:TableWizard.java   
/**
 * Set all the borders of a JR style to a precise width
 * 
 * @param element a JR style
 * @param lineWidth the width
 */
private void setBorderWidth(JRDesignStyle element, float lineWidth){
    JRLineBox box = element.getLineBox();
    box.getPen().setLineWidth(lineWidth);
    box.getLeftPen().setLineWidth(lineWidth);
    box.getRightPen().setLineWidth(lineWidth);
    box.getBottomPen().setLineWidth(lineWidth);
    box.getTopPen().setLineWidth(lineWidth);
}
项目:PDFReporter-Studio    文件:TableWizard.java   
/**
 * Set all the borders of a JR style to a precise color
 * 
 * @param element a JR style
 * @param lineWidth the width
 */
private void setBorderColor(JRDesignStyle element, Color lineColor){
    JRLineBox box = element.getLineBox();
    box.getPen().setLineColor(lineColor);
    box.getLeftPen().setLineColor(lineColor);
    box.getRightPen().setLineColor(lineColor);
    box.getBottomPen().setLineColor(lineColor);
    box.getTopPen().setLineColor(lineColor);
}
项目:PDFReporter-Studio    文件:RemoveTableStylesAction.java   
/**
 * Create the command to remove the style from a single cell and to delete the style 
 * itself if the deleteStyle flag is enabled and if the command to delete the style
 * was not already generated
 * 
 * @param cell the cell from where the style must be removed 
 * @param container compound command where the new commands will be stored
 */
protected void createCommand(Cell cell, JSSCompoundCommand container){
    if (cell != null && cell instanceof DesignCell){
        container.add(new RemoveStyleCommand((DesignCell)cell));
        if (deleteStyles && cell.getStyle() != null){
            JRStyle style = cell.getStyle();
            if (!deletedStyles.contains(style.getName())){
                deletedStyles.add(style.getName());
                container.add(new DeleteStyleCommand(design, (JRDesignStyle)style));
            }
        }
    }
}
项目:PDFReporter-Studio    文件:StyleSection.java   
@Override
protected void initializeProvidedProperties() {
    super.initializeProvidedProperties();
    addProvidedProperties(JRDesignStyle.PROPERTY_NAME, Messages.common_name);
    addProvidedProperties(JRDesignStyle.PROPERTY_PARENT_STYLE, Messages.common_parent_style);
    addProvidedProperties(JRDesignStyle.PROPERTY_DEFAULT, Messages.MStyle_default_style);
    addProvidedProperties(JRDesignStyle.PROPERTY_BLANK_WHEN_NULL, Messages.common_blank_when_null);
    addProvidedProperties(JRDesignStyle.PROPERTY_PATTERN, Messages.common_pattern);
    addProvidedProperties(JRBaseStyle.PROPERTY_FILL, Messages.common_fill);
    addProvidedProperties(JRBaseStyle.PROPERTY_RADIUS, Messages.common_radius);
    addProvidedProperties(JRBaseStyle.PROPERTY_SCALE_IMAGE, Messages.MStyle_scale);
}
项目:PDFReporter-Studio    文件:StylesListSection.java   
/**
 * Add the external list to the styles map, but only those with a different name from the one already added
 * 
 * @param stylesList
 */
private void recursiveReadStyles(List<INode> stylesList, MStyleTemplate parentReference, JRStyle defaultValue) {
    for (INode style : stylesList) {
        if (style instanceof MStyle) {
            MStyle element = (MStyle) style;
            String name = element.getPropertyValue(JRDesignStyle.PROPERTY_NAME).toString();
            if (element.getValue() == defaultValue) defaultStyle = element;
            styleMaps.put(name, new StyleContainer(element, parentReference));
        } else if (style instanceof MStyleTemplate) {
            recursiveReadStyles(style.getChildren(), (MStyleTemplate) style, defaultValue);
        }
    }
}
项目:PDFReporter-Studio    文件:TextFieldSection.java   
@Override
protected void initializeProvidedProperties() {
    super.initializeProvidedProperties();
    addProvidedProperties(JRDesignTextField.PROPERTY_EXPRESSION, Messages.common_expression);
    addProvidedProperties(JRDesignTextField.PROPERTY_EVALUATION_TIME, Messages.common_evaluation_time);
    addProvidedProperties(JRDesignStyle.PROPERTY_BLANK_WHEN_NULL, Messages.common_blank_when_null);
    addProvidedProperties(JRBaseTextField.PROPERTY_STRETCH_WITH_OVERFLOW, Messages.MTextField_stretch_with_overflow);
    addProvidedProperties(JRDesignStyle.PROPERTY_PATTERN, Messages.common_pattern);
    addProvidedProperties(JRDesignTextField.PROPERTY_PATTERN_EXPRESSION, Messages.MTextField_patternExpressionTitle);
}
项目:PDFReporter-Studio    文件:MGraphicElement.java   
@Override
public HashMap<String, Object> getStylesDescriptors() {
    HashMap<String, Object> result = new HashMap<String, Object>();
    if (getValue() == null)
        return result;
    JRDesignElement element = (JRDesignElement) getValue();
    result.put(JRDesignStyle.PROPERTY_BACKCOLOR, element.getOwnBackcolor());
    result.put(JRDesignStyle.PROPERTY_FORECOLOR, element.getOwnForecolor());
    result.put(JRDesignStyle.PROPERTY_MODE, element.getOwnModeValue());
    return result;
}
项目:PDFReporter-Studio    文件:StyleTemplateFactory.java   
public static ANode createNode(ANode parent, Object obj, int index, IFile file, JRSimpleTemplate jrst) {
    if (obj instanceof JRDesignStyle) {
        index += jrst.getIncludedTemplatesList().size();
        return new MStyle(parent, (JRDesignStyle) obj, index);
    }
    if (obj instanceof JRTemplateReference) {
        ANode n = new MStyleTemplateReference(parent, (JRTemplateReference) obj, index);
        createTemplateReference(n, ((JRTemplateReference) obj).getLocation(), -1, new HashSet<String>(), false, file);
    }
    return null;
}
项目:PDFReporter-Studio    文件:MStyle.java   
public HashMap<String, Object> getStylesDescriptors() {
    HashMap<String, Object> result = new HashMap<String, Object>();
    if (getValue() == null)
        return result;
    JRStyle element = (JRStyle) getValue();
    result.put(JRDesignStyle.PROPERTY_BACKCOLOR, element.getOwnBackcolor());
    result.put(JRDesignStyle.PROPERTY_FORECOLOR, element.getOwnForecolor());
    result.put(JRDesignStyle.PROPERTY_FILL, element.getOwnFillValue());
    result.put(JRDesignStyle.PROPERTY_FONT_NAME, element.getOwnFontName());
    result.put(JRDesignStyle.PROPERTY_FONT_SIZE, element.getOwnFontsize());
    result.put(JRDesignStyle.PROPERTY_BOLD, element.isOwnBold());
    result.put(JRDesignStyle.PROPERTY_ITALIC, element.isOwnItalic());
    result.put(JRDesignStyle.PROPERTY_UNDERLINE, element.isOwnUnderline());
    result.put(JRDesignStyle.PROPERTY_STRIKE_THROUGH, element.isOwnStrikeThrough());
    result.put(JRDesignStyle.PROPERTY_HORIZONTAL_ALIGNMENT, element.getOwnHorizontalAlignmentValue());
    result.put(JRDesignStyle.PROPERTY_MARKUP, element.getOwnMarkup());
    result.put(JRDesignStyle.PROPERTY_MODE, element.getOwnModeValue());
    result.put(JRDesignStyle.PROPERTY_PATTERN, element.getOwnPattern());
    result.put(JRDesignStyle.PROPERTY_RADIUS, element.getOwnRadius());
    result.put(JRDesignStyle.PROPERTY_ROTATION, element.getOwnRotationValue());
    result.put(JRDesignStyle.PROPERTY_SCALE_IMAGE, element.getOwnScaleImageValue());
    result.put(JRDesignStyle.PROPERTY_VERTICAL_ALIGNMENT, element.getOwnVerticalAlignmentValue());
    result.put(JRDesignStyle.PROPERTY_BLANK_WHEN_NULL, element.isOwnBlankWhenNull());
    result.put(PARAGRAPH, getPropertyValue(PARAGRAPH));
    MLinePen linePen = (MLinePen) getPropertyValue(LINE_PEN);
    result.put(LINE_PEN, linePen);
    MLineBox lineBox = (MLineBox) getPropertyValue(LINE_BOX);
    result.put(LINE_BOX, lineBox);
    return result;
}