@Override public Object createObject(Attributes atts) { int seriesIndex = -1; Color color = null; String seriesNumber = atts.getValue(JRXmlConstants.ATTRIBUTE_seriesOrder); if (seriesNumber != null && seriesNumber.length() > 0) { seriesIndex = Integer.valueOf(seriesNumber).intValue(); } String colorName = atts.getValue(JRXmlConstants.ATTRIBUTE_color); if (colorName != null && colorName.length() > 0) { color = JRColorUtil.getColor(colorName, null); } return new JRBaseChartPlot.JRBaseSeriesColor(seriesIndex, color); }
public Object getPropertyValue(Object id) { JRBaseChartPlot jrElement = (JRBaseChartPlot) getValue(); if (id.equals(JRBaseChartPlot.PROPERTY_BACKCOLOR)) return Colors.getSWTRGB4AWTGBColor(jrElement.getOwnBackcolor()); if (id.equals(JRBaseChartPlot.PROPERTY_BACKGROUND_ALPHA)) return jrElement.getBackgroundAlphaFloat(); if (id.equals(JRBaseChartPlot.PROPERTY_FOREGROUND_ALPHA)) return jrElement.getForegroundAlphaFloat(); if (id.equals(JRBaseChartPlot.PROPERTY_ORIENTATION)) { if (jrElement.getOrientationValue() == null) return 0; if (jrElement.getOrientationValue() == PlotOrientationEnum.HORIZONTAL) return 1; else return 2; } if (id.equals(JRBaseChartPlot.PROPERTY_SERIES_COLORS)) return jrElement.getSeriesColors(); return null; }
@Override public void setValue(Object value) { JRChart oldObject = (JRChart) getValue(); JRChart newObject = (JRChart) value; if (oldObject != null) { ((JRBaseChartPlot) oldObject.getPlot()).getEventSupport().removePropertyChangeListener(this); if (oldObject.getLegendFont() != null) ((JRBaseFont) oldObject.getLegendFont()).getEventSupport().removePropertyChangeListener(this); if (oldObject.getSubtitleFont() != null) ((JRBaseFont) oldObject.getSubtitleFont()).getEventSupport().removePropertyChangeListener(this); if (oldObject.getTitleFont() != null) ((JRBaseFont) oldObject.getTitleFont()).getEventSupport().removePropertyChangeListener(this); } if (newObject != null) { ((JRBaseChartPlot) newObject.getPlot()).getEventSupport().addPropertyChangeListener(this); if (newObject.getLegendFont() != null) ((JRBaseFont) newObject.getLegendFont()).getEventSupport().addPropertyChangeListener(this); if (newObject.getSubtitleFont() != null) ((JRBaseFont) newObject.getSubtitleFont()).getEventSupport().addPropertyChangeListener(this); if (newObject.getTitleFont() != null) ((JRBaseFont) newObject.getTitleFont()).getEventSupport().addPropertyChangeListener(this); } super.setValue(value); }
/** * */ public void visitChart(JRChart chart) { if (chart.getChartType() == JRChart.CHART_TYPE_MULTI_AXIS) { node = new MultiAxisChartElementNode(jasperDesign, (JRDesignChart)chart, doLkp); } else { node = new ElementNode(jasperDesign, (JRDesignChart)chart,doLkp); } node.setIconBaseWithExtension(ICON_CHART); ((JRBaseChartPlot)((JRDesignChart)chart).getPlot()).getEventSupport() .addPropertyChangeListener((PropertyChangeListener)node); }
@SuppressWarnings("unchecked") private void updateSeriesColors() { if (isInit()) return; DefaultListModel dtm = ((DefaultListModel)jList1.getModel()); lastSeries.clear(); seriescolors.clear(); for (int i=0; i<dtm.size(); ++i) { JRBaseChartPlot.JRBaseSeriesColor sc = new JRBaseChartPlot.JRBaseSeriesColor(i, (java.awt.Color)dtm.get(i)); seriescolors.add(sc); lastSeries.add( (java.awt.Color)dtm.get(i) ); } }
@Override public Object getValue() { List list = new ArrayList(); if (settings.getSeriesColorSequence() != null) { for(int i = 0; i < settings.getSeriesColorSequence().size(); i++) { list.add( new JRBaseChartPlot.JRBaseSeriesColor(i, ((ColorProvider)settings.getSeriesColorSequence().get(i)).getColor()) ); } } return list; }
public void createCommon(Composite parent) { Composite group = getWidgetFactory().createComposite(parent); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; group.setLayoutData(gd); group.setLayout(new GridLayout(3, false)); getWidgetFactory().createCLabel(group, Messages.MChartPlot_backcolor); createWidget4Property(group, JRBaseChartPlot.PROPERTY_BACKCOLOR, false) .getControl().setLayoutData(gd); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; createWidget4Property(group, JRBaseChartPlot.PROPERTY_FOREGROUND_ALPHA) .getControl().setLayoutData(gd); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; createWidget4Property(group, JRBaseChartPlot.PROPERTY_BACKGROUND_ALPHA) .getControl().setLayoutData(gd); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; createWidget4Property(group, JRBaseChartPlot.PROPERTY_SERIES_COLORS) .getControl().setLayoutData(gd); gd = new GridData(); gd.horizontalSpan = 2; createWidget4Property(group, JRBaseChartPlot.PROPERTY_ORIENTATION) .getControl().setLayoutData(gd); ; }
@Override protected void initializeProvidedProperties() { super.initializeProvidedProperties(); addProvidedProperties(JRBaseChartPlot.PROPERTY_BACKCOLOR, Messages.MChartPlot_backcolor); addProvidedProperties(JRBaseChartPlot.PROPERTY_FOREGROUND_ALPHA, Messages.MChartPlot_foreground_alpha_percent); addProvidedProperties(JRBaseChartPlot.PROPERTY_BACKGROUND_ALPHA, Messages.MChartPlot_background_alpha_percent); addProvidedProperties(JRBaseChartPlot.PROPERTY_SERIES_COLORS, Messages.MChartPlot_series_colors); addProvidedProperties(JRBaseChartPlot.PROPERTY_ORIENTATION, Messages.MChartPlot_orientation); }
@Override public void createPropertyDescriptors(List<IPropertyDescriptor> desc, Map<String, Object> defaultsMap) { ColorPropertyDescriptor backcolorD = new ColorPropertyDescriptor(JRBaseChartPlot.PROPERTY_BACKCOLOR, Messages.MChartPlot_backcolor, NullEnum.INHERITED); backcolorD.setDescription(Messages.MChartPlot_backcolor_description); desc.add(backcolorD); FloatPropertyDescriptor backAlphaD = new TransparencyPropertyDescriptor(JRBaseChartPlot.PROPERTY_BACKGROUND_ALPHA, Messages.MChartPlot_background_alpha_percent); backAlphaD.setDescription(Messages.MChartPlot_background_alpha_percent_description); desc.add(backAlphaD); FloatPropertyDescriptor foreAlphaD = new TransparencyPropertyDescriptor(JRBaseChartPlot.PROPERTY_FOREGROUND_ALPHA, Messages.MChartPlot_foreground_alpha_percent); foreAlphaD.setDescription(Messages.MChartPlot_foreground_alpha_percent_description); desc.add(foreAlphaD); orientationD = new JSSEnumPropertyDescriptor(JRBaseChartPlot.PROPERTY_ORIENTATION, Messages.MChartPlot_orientation, com.jaspersoft.studio.components.chart.model.enums.PlotOrientationEnum.class, NullEnum.NULL); orientationD.setDescription(Messages.MChartPlot_orientation_description); desc.add(orientationD); SeriesColorPropertyDescriptor scpd = new SeriesColorPropertyDescriptor(JRBaseChartPlot.PROPERTY_SERIES_COLORS, Messages.MChartPlot_series_colors); scpd.setDescription(Messages.MChartPlot_series_colors_description); desc.add(scpd); scpd.setHelpRefBuilder(new HelpReferenceBuilder("net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#seriesColor")); defaultsMap.put(JRBaseChartPlot.PROPERTY_BACKGROUND_ALPHA, null); defaultsMap.put(JRBaseChartPlot.PROPERTY_FOREGROUND_ALPHA, null); setHelpPrefix(desc, "net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#plot"); }
public void setPropertyValue(Object id, Object value) { JRBaseChartPlot jrElement = (JRBaseChartPlot) getValue(); if (id.equals(JRBaseChartPlot.PROPERTY_BACKCOLOR)) { if (value instanceof AlfaRGB) jrElement.setBackcolor(Colors.getAWT4SWTRGBColor((AlfaRGB) value)); } else if (id.equals(JRBaseChartPlot.PROPERTY_BACKGROUND_ALPHA)) { jrElement.setBackgroundAlpha((Float) value); } else if (id.equals(JRBaseChartPlot.PROPERTY_FOREGROUND_ALPHA)) { jrElement.setForegroundAlpha((Float) value); } else if (id.equals(JRBaseChartPlot.PROPERTY_ORIENTATION)) { switch ((Integer) value) { case 0: jrElement.setOrientation((PlotOrientationEnum) null); break; case 1: jrElement.setOrientation(PlotOrientationEnum.HORIZONTAL); break; case 2: jrElement.setOrientation(PlotOrientationEnum.VERTICAL); break; } // jrElement.setOrientation((PlotOrientationEnum) orientationD // .getEnumValue(value)); } else if (id.equals(JRBaseChartPlot.PROPERTY_SERIES_COLORS)) { jrElement.setSeriesColors((Collection<JRSeriesColor>) value); // jrElement.clearSeriesColors(); // if (value instanceof SortedSet) { // SortedSet<JRSeriesColor> set = (SortedSet<JRSeriesColor>) value; // for (JRSeriesColor sc : set) { // jrElement.addSeriesColor(sc); // } // } } }
@SuppressWarnings("unchecked") public PlotSeriesColorsProperty(JRBaseChartPlot element) { super(JRBaseChartPlot.PROPERTY_SERIES_COLORS, "Series Colors", "Series Colors"); this.element = element; }
public JRDesignChartWidget(AbstractReportObjectScene scene, JRDesignChart element) { super(scene, element); ((JRBaseChartPlot)element.getPlot()).getEventSupport().addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { JRDesignChartWidget.this.revalidate(true); //JRDesignChartWidget.this.repaint(); JRDesignChartWidget.this.getScene().validate(); } }); }
@SuppressWarnings("unchecked") public PlotSeriesColorsProperty(PlotSettings settings) { super(JRBaseChartPlot.PROPERTY_SERIES_COLORS, "Series Colors", "Series Colors"); this.settings = settings; }
/** * Get the ChartElement properties... */ public static List<Sheet.Set> getPropertySets(JRDesignChart element, JasperDesign jd) { JRDesignDataset dataset = ModelUtils.getElementDataset(element, jd); List<Sheet.Set> list = new ArrayList<Sheet.Set>(); Sheet.Set propertySet = Sheet.createPropertiesSet(); propertySet.setName("CHART_ELEMENT_PROPERTIES"); propertySet.setDisplayName("Common chart properties"); propertySet.put(new ImageEvaluationTimeProperty( element,dataset)); propertySet.put(new EvaluationGroupProperty( element,dataset)); propertySet.put(new TitleExpressionProperty(element,dataset)); propertySet.put(new TitleFontProperty(element, jd)); propertySet.put(new TitleColorProperty(element)); propertySet.put(new TitlePositionProperty(element)); propertySet.put(new SubtitleExpressionProperty(element,dataset)); propertySet.put(new SubtitleFontProperty(element, jd)); propertySet.put(new SubtitleColorProperty(element)); propertySet.put(new ShowLegendProperty(element)); propertySet.put(new LegendFontProperty(element, jd)); propertySet.put(new LegendColorProperty(element)); propertySet.put(new LegendBackgroundColorProperty(element)); propertySet.put(new LegendPositionProperty(element)); propertySet.put(new CustomizerClassProperty(element)); propertySet.put(new RenderTypeProperty(element)); propertySet.put(new ThemeProperty(element)); // Common plot properties JRBaseChartPlot plot = (JRBaseChartPlot)element.getPlot(); propertySet.put(new PlotBackgroundAlphaProperty(plot)); propertySet.put(new PlotForegroundAlphaProperty(plot)); propertySet.put(new PlotLabelRotationProperty(plot)); propertySet.put(new PlotSeriesColorsProperty(plot)); propertySet.put(new OrientationProperty(plot)); list.add(propertySet); list.add(getPlotProperties(plot,element,jd,dataset)); return list; }
public PlotBackgroundProperty(JRBaseChartPlot plot) { super(plot); this.plot = plot; }
@Override public String getName() { return JRBaseChartPlot.PROPERTY_BACKCOLOR; }
public OrientationProperty(JRBaseChartPlot plot) { super(plot); this.plot = plot; }
@Override public String getName() { return JRBaseChartPlot.PROPERTY_ORIENTATION; }
public PlotBackgroundAlphaProperty(JRBaseChartPlot plot) { super(plot); this.plot = plot; }
@Override public String getName() { return JRBaseChartPlot.PROPERTY_BACKGROUND_ALPHA; }
public PlotLabelRotationProperty(JRBaseChartPlot plot) { super(plot); this.plot = plot; }
@Override public String getName() { return JRBaseChartPlot.PROPERTY_LABEL_ROTATION; }
public PlotForegroundAlphaProperty(JRBaseChartPlot plot) { super(plot); this.plot = plot; }
@Override public String getName() { return JRBaseChartPlot.PROPERTY_FOREGROUND_ALPHA; }
@SuppressWarnings("unchecked") private void setPropertyValue(Object val) { if (val instanceof List) { List oldValue = (List)settings.getSeriesColorSequence(); List colors = new ArrayList(); if (oldValue == val) return; if (oldValue == null && val == null) return; // Check for changes... if (val != null) { boolean update = false; if (oldValue ==null || oldValue.size() != ((List)val).size()) { update = true; } else { ; for(int idx = 0; !update && idx < ((List)val).size(); ++idx) { Color c1 = ((JRBaseChartPlot.JRBaseSeriesColor)((List)val).get(idx)).getColor(); Color c2 = ((ColorProvider)oldValue.get(idx)).getColor(); if (c1 == null && c1 != c2) { update = true; } else if (c1 != null && !c1.equals(c2)) { update = true; } } } if (!update) return; for(Iterator it = ((List)val).iterator(); it.hasNext();) { colors.add(new ColorProvider(((JRBaseChartPlot.JRBaseSeriesColor)it.next()).getColor())); } } settings.setSeriesColorSequence(colors); ObjectPropertyUndoableEdit urob = new ObjectPropertyUndoableEdit( settings, "SeriesColorSequence", List.class, oldValue,colors); // Find the undoRedo manager... IReportManager.getInstance().addUndoableEdit(urob); } }