@Override public void setStyle(JRFont font, Attributes atts) { JRDesignFont designFont = (JRDesignFont)font; String styleName = atts.getValue(JRXmlConstants.ATTRIBUTE_reportFont); if (styleName != null) { JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2); Map<String,JRStyle> stylesMap = jasperDesign.getStylesMap(); if (stylesMap.containsKey(styleName)) { JRStyle style = stylesMap.get(styleName); designFont.setStyle(style); } else { designFont.setStyleNameReference(styleName); } } }
@Override public JRFont getFont() { int i = 0; JRChart chart = null; while (chart == null && i < digester.getCount()) { Object obj = digester.peek(i); chart = obj instanceof JRChart ? (JRChart)obj : null; i++; } return new JRDesignFont(chart); }
@Override public void setStyle(JRFont font, Attributes atts) { JRDesignFont designFont = (JRDesignFont)font; // if ( // designFont.getStyle() == null // && designFont.getStyleNameReference() == null // ) // { String styleName = atts.getValue(JRXmlConstants.ATTRIBUTE_reportFont); if (styleName != null) { JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2); Map<String,JRStyle> stylesMap = jasperDesign.getStylesMap(); if (stylesMap.containsKey(styleName)) { JRStyle style = stylesMap.get(styleName); designFont.setStyle(style); } else { designFont.setStyleNameReference(styleName); } } // } }
@Override public JRFont getFont() { int i = 0; JRComponentElement component = null; while (component == null && i < digester.getCount()) { Object obj = digester.peek(i); component = obj instanceof JRComponentElement ? (JRComponentElement)obj : null; i++; } return new JRDesignFont(component); }
protected void createComponent(Composite parent) { mfont = new MFont(new JRDesignFont(null)); group = section.getWidgetFactory().createSection(parent, pDescriptor.getDisplayName(), true, 3); final FontNamePropertyDescriptor pd = (FontNamePropertyDescriptor) mfont .getPropertyDescriptor(JRBaseStyle.PROPERTY_FONT_NAME); fontName = new ComboMenuViewer(group, ComboMenuViewer.NO_IMAGE, "SampleSampleSample"); fontName.setToolTipText(pd.getDescription()); fontName.addSelectionListener(new ComboItemAction() { @Override public void exec() { propertyChange(section, JRBaseFont.PROPERTY_FONT_NAME, fontName.getSelectionValue() != null ? fontName.getSelectionValue().toString() : null, pd); } }); final RWComboBoxPropertyDescriptor pd1 = (RWComboBoxPropertyDescriptor) mfont .getPropertyDescriptor(JRBaseStyle.PROPERTY_FONT_SIZE); Composite fontSizeLayout = new Composite(group, SWT.NONE); GridData fontSizeData = new GridData(); fontSizeData.widthHint = 65; fontSizeData.minimumWidth = 65; fontSizeLayout.setLayout(new GridLayout(1,false)); fontSizeLayout.setLayoutData(fontSizeData); fontSize = section.getWidgetFactory().createCombo(fontSizeLayout, SWT.FLAT); fontSize.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fontSize.setItems(pd1.getItems()); fontSize.addModifyListener(new ModifyListener() { private int time = 0; public void modifyText(ModifyEvent e) { if (e.time - time > 100) { String value = fontSize.getText(); if (IntegerCellEditorValidator.instance().isValid(value) == null) changeProperty(section, pDescriptor.getId(), pd1.getId(), value); } time = e.time; } }); fontSize.setToolTipText(pd1.getDescription()); /* *Button to increment\decrment the font size */ new SPChartButtom(group, section, pd1, mfont, pDescriptor.getId().toString()); ToolBar toolBar = new ToolBar(group, SWT.FLAT | SWT.WRAP | SWT.LEFT); GridData gd = new GridData(); gd.horizontalSpan = 3; toolBar.setLayoutData(gd); boldButton = createItem(toolBar, JRBaseStyle.PROPERTY_BOLD, "icons/resources/edit-bold.png"); italicButton = createItem(toolBar, JRBaseStyle.PROPERTY_ITALIC, "icons/resources/edit-italic.png"); underlineButton = createItem(toolBar, JRBaseStyle.PROPERTY_UNDERLINE, "icons/resources/edit-underline.png"); strikeTroughtButton = createItem(toolBar, JRBaseStyle.PROPERTY_STRIKE_THROUGH, "icons/resources/edit-strike.png"); }