List of usage examples for org.jfree.chart.plot Plot getInsets
public RectangleInsets getInsets()
From source file:daylightchart.options.chart.PlotOptions.java
/** * {@inheritDoc}/* ww w .j av a 2 s. co m*/ * * @see BaseChartOptions#copyFromChart(org.jfree.chart.JFreeChart) */ @Override public void copyFromChart(final JFreeChart chart) { final Plot plot = chart.getPlot(); backgroundPaint = plot.getBackgroundPaint(); outlinePaint = plot.getOutlinePaint(); outlineStroke = plot.getOutlineStroke(); insets = plot.getInsets(); // // Update axes Axis domainAxis = null; if (plot instanceof CategoryPlot) { final CategoryPlot p = (CategoryPlot) plot; domainAxis = p.getDomainAxis(); } else if (plot instanceof XYPlot) { final XYPlot p = (XYPlot) plot; domainAxis = p.getDomainAxis(); } if (domainAxis != null) { domainAxisOptions.getAxisProperties(domainAxis); } Axis rangeAxis = null; if (plot instanceof CategoryPlot) { final CategoryPlot p = (CategoryPlot) plot; rangeAxis = p.getRangeAxis(); } else if (plot instanceof XYPlot) { final XYPlot p = (XYPlot) plot; rangeAxis = p.getRangeAxis(); } if (rangeAxis != null) { rangeAxisOptions.getAxisProperties(rangeAxis); } }
From source file:ch.zhaw.simulation.diagram.charteditor.DefaultPlotEditor.java
/** * Standard constructor - constructs a panel for editing the properties of * the specified plot./*from w w w. ja va2 s .c om*/ * <P> * In designing the panel, we need to be aware that subclasses of Plot will * need to implement subclasses of PlotPropertyEditPanel - so we need to * leave one or two 'slots' where the subclasses can extend the user * interface. * * @param plot * the plot, which should be changed. */ public DefaultPlotEditor(Plot plot) { this.plotInsets = plot.getInsets(); this.backgroundPaintSample = new PaintSample(plot.getBackgroundPaint()); this.outlineStrokeSample = new StrokeSample(plot.getOutlineStroke()); this.outlinePaintSample = new PaintSample(plot.getOutlinePaint()); // Disabled because makes no sense for us // if (plot instanceof CategoryPlot) { // this.plotOrientation = ((CategoryPlot) plot).getOrientation(); // } else if (plot instanceof XYPlot) { // this.plotOrientation = ((XYPlot) plot).getOrientation(); // } if (plot instanceof CategoryPlot) { CategoryItemRenderer renderer = ((CategoryPlot) plot).getRenderer(); if (renderer instanceof LineAndShapeRenderer) { LineAndShapeRenderer r = (LineAndShapeRenderer) renderer; this.drawLines = BooleanUtilities.valueOf(r.getBaseLinesVisible()); this.drawShapes = BooleanUtilities.valueOf(r.getBaseShapesVisible()); } } else if (plot instanceof XYPlot) { XYItemRenderer renderer = ((XYPlot) plot).getRenderer(); if (renderer instanceof StandardXYItemRenderer) { StandardXYItemRenderer r = (StandardXYItemRenderer) renderer; this.drawLines = BooleanUtilities.valueOf(r.getPlotLines()); this.drawShapes = BooleanUtilities.valueOf(r.getBaseShapesVisible()); } } setLayout(new BorderLayout()); this.availableStrokeSamples = new StrokeSample[4]; this.availableStrokeSamples[0] = new StrokeSample(null); this.availableStrokeSamples[1] = new StrokeSample(new BasicStroke(1.0f)); this.availableStrokeSamples[2] = new StrokeSample(new BasicStroke(2.0f)); this.availableStrokeSamples[3] = new StrokeSample(new BasicStroke(3.0f)); // create a panel for the settings... JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), plot.getPlotType() + localizationResources.getString(":"))); JPanel general = new JPanel(new BorderLayout()); general.setBorder(BorderFactory.createTitledBorder(localizationResources.getString("General"))); JPanel interior = new JPanel(new LCBLayout(7)); interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); interior.add(new JLabel(localizationResources.getString("Outline_stroke"))); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (StrokeSample s : this.availableStrokeSamples) { model.addElement(s.getStroke()); } this.cbOutlineStroke = new JComboBox(model); this.cbOutlineStroke.setSelectedItem(this.outlineStrokeSample.getStroke()); this.cbOutlineStroke.setRenderer(new StrokeComboboxRenderer()); interior.add(this.cbOutlineStroke); interior.add(new JLabel()); interior.add(new JLabel(localizationResources.getString("Outline_Paint"))); JButton button = new JButton(localizationResources.getString("Select...")); button.setActionCommand("OutlinePaint"); button.addActionListener(this); interior.add(this.outlinePaintSample); interior.add(button); interior.add(new JLabel(localizationResources.getString("Background_paint"))); button = new JButton(localizationResources.getString("Select...")); button.setActionCommand("BackgroundPaint"); button.addActionListener(this); interior.add(this.backgroundPaintSample); interior.add(button); // Disabled because makes no sense for us // if (this.plotOrientation != null) { // boolean isVertical = // this.plotOrientation.equals(PlotOrientation.VERTICAL); // int index = isVertical ? ORIENTATION_VERTICAL : // ORIENTATION_HORIZONTAL; // interior.add(new // JLabel(localizationResources.getString("Orientation"))); // this.orientationCombo = new JComboBox(orientationNames); // this.orientationCombo.setSelectedIndex(index); // this.orientationCombo.setActionCommand("Orientation"); // this.orientationCombo.addActionListener(this); // interior.add(this.orientationCombo); // interior.add(new JPanel()); // } if (this.drawLines != null) { interior.add(new JLabel(localizationResources.getString("Draw_lines"))); this.drawLinesCheckBox = new JCheckBox(); this.drawLinesCheckBox.setSelected(this.drawLines.booleanValue()); this.drawLinesCheckBox.setActionCommand("DrawLines"); this.drawLinesCheckBox.addActionListener(this); interior.add(new JPanel()); interior.add(this.drawLinesCheckBox); } if (this.drawShapes != null) { interior.add(new JLabel(localizationResources.getString("Draw_shapes"))); this.drawShapesCheckBox = new JCheckBox(); this.drawShapesCheckBox.setSelected(this.drawShapes.booleanValue()); this.drawShapesCheckBox.setActionCommand("DrawShapes"); this.drawShapesCheckBox.addActionListener(this); interior.add(new JPanel()); interior.add(this.drawShapesCheckBox); } general.add(interior, BorderLayout.NORTH); JPanel appearance = new JPanel(new BorderLayout()); appearance.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); appearance.add(general, BorderLayout.NORTH); JTabbedPane tabs = new JTabbedPane(); tabs.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); Axis domainAxis = null; if (plot instanceof CategoryPlot) { domainAxis = ((CategoryPlot) plot).getDomainAxis(); } else if (plot instanceof XYPlot) { domainAxis = ((XYPlot) plot).getDomainAxis(); } this.domainAxisPropertyPanel = DefaultAxisEditor.getInstance(domainAxis); if (this.domainAxisPropertyPanel != null) { this.domainAxisPropertyPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); tabs.add(localizationResources.getString("Domain_Axis"), this.domainAxisPropertyPanel); } Axis rangeAxis = null; if (plot instanceof CategoryPlot) { rangeAxis = ((CategoryPlot) plot).getRangeAxis(); } else if (plot instanceof XYPlot) { rangeAxis = ((XYPlot) plot).getRangeAxis(); } this.rangeAxisPropertyPanel = DefaultAxisEditor.getInstance(rangeAxis); if (this.rangeAxisPropertyPanel != null) { this.rangeAxisPropertyPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); tabs.add(localizationResources.getString("Range_Axis"), this.rangeAxisPropertyPanel); } tabs.add(localizationResources.getString("Appearance"), appearance); panel.add(tabs); add(panel); }
From source file:org.operamasks.faces.render.graph.ChartRenderer.java
protected void setChartStyles(JFreeChart chart, UIChart comp) { Plot plot = chart.getPlot(); RectangleInsets insets = plot.getInsets(); Double tm = comp.getTopMargin(); Double lm = comp.getLeftMargin(); Double bm = comp.getBottomMargin(); Double rm = comp.getRightMargin(); if (tm == null || tm < 0) tm = insets.getTop();/* w w w .j a va2 s.c om*/ if (lm == null || lm < 0) lm = insets.getLeft(); if (bm == null || bm < 0) bm = insets.getBottom(); if (rm == null || rm < 0) rm = insets.getRight(); plot.setInsets(new RectangleInsets(tm, lm, bm, rm)); Paint color = comp.getBackgroundColor(); if (color != null) { chart.setBackgroundPaint(color); } Image image = loadImage(comp.getBackgroundImage()); if (image != null) { chart.setBackgroundImage(image); chart.setBackgroundImageAlignment(getImageAlign(comp.getBackgroundImagePosition())); chart.setBackgroundImageAlpha(comp.getBackgroundImageAlpha()); } color = comp.getPlotColor(); if (color != null) { plot.setBackgroundPaint(color); } Float alpha; if ((alpha = comp.getBackgroundAlpha()) != null) { plot.setBackgroundAlpha(alpha); } if ((alpha = comp.getForegroundAlpha()) != null) { plot.setForegroundAlpha(alpha); } image = loadImage(comp.getPlotImage()); if (image != null) { plot.setBackgroundImage(image); plot.setBackgroundImageAlignment(getImageAlign(comp.getPlotImagePosition())); plot.setBackgroundImageAlpha(comp.getBackgroundImageAlpha()); } Paint[] colorPalette = comp.getColorPalette(); if (colorPalette != null) { plot.setDrawingSupplier(new CustomDrawingSupplier(colorPalette)); } else { plot.setDrawingSupplier(new CustomDrawingSupplier()); } }
From source file:org.toobsframework.pres.chart.ChartBuilder.java
private Plot configurePlot(IRequest componentRequest, String id, org.toobsframework.pres.chart.config.Plot plotDef, Map params) throws ChartException { Plot plot = null;//ww w.j a va2 s .c o m if (plotDef.getSubPlotCount() > 0) { boolean is3D = (ParameterUtil.resolveParam(componentRequest, plotDef.getIs3D(), params, "false")[0] .equals("false") ? false : true); int plotType = ChartUtil.getSupportedPlots().get( ParameterUtil.resolveParam(componentRequest, plotDef.getType(), params, "multiCategory")[0]); PlotOrientation orientation = (ParameterUtil.resolveParam(componentRequest, plotDef.getOrientation(), params, "vertical")[0].equals("horizontal") ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL); switch (plotType) { case ChartUtil.PLOT_MULTICATEGORY_TYPE: plot = new MultiCategoryPlot(); for (int p = 0; p < plotDef.getSubPlotCount(); p++) { ((MultiCategoryPlot) plot).add((CategoryPlot) this.configurePlot(componentRequest, id, plotDef.getSubPlot(p), params, true, plotType, plotDef)); } ((MultiCategoryPlot) plot).setOrientation(orientation); ((MultiCategoryPlot) plot).setGap(plotDef.getGap()); if (plotDef.getInsets() != null) { plot.setInsets(ChartUtil.getRectangle(componentRequest, plotDef.getInsets(), params)); } break; case ChartUtil.PLOT_COMBINEDDOMAINCATEGORY_TYPE: CategoryAxis domainAxis = ChartUtil.createCategoryAxis(componentRequest, plotDef.getDomainAxisDef(), params, is3D); plot = new CombinedDomainCategoryPlotEx(domainAxis); for (int p = 0; p < plotDef.getSubPlotCount(); p++) { ((CombinedDomainCategoryPlotEx) plot).add((CategoryPlot) this.configurePlot(componentRequest, id, plotDef.getSubPlot(p), params, true, plotType, plotDef)); } ((CombinedDomainCategoryPlotEx) plot).setOrientation(orientation); ((CombinedDomainCategoryPlotEx) plot).setGap(plotDef.getGap()); if (plotDef.getInsets() != null) { plot.setInsets(ChartUtil.getRectangle(componentRequest, plotDef.getInsets(), params)); } break; case ChartUtil.PLOT_COMBINEDRANGECATEGORY_TYPE: ValueAxis rangeAxis = createValueAxis(componentRequest, plotDef.getRangeAxisDef(), params, is3D); plot = new CombinedRangeCategoryPlotEx(rangeAxis); for (int p = 0; p < plotDef.getSubPlotCount(); p++) { ((CombinedRangeCategoryPlotEx) plot).add((CategoryPlot) this.configurePlot(componentRequest, id, plotDef.getSubPlot(p), params, true, plotType, plotDef)); } ((CombinedRangeCategoryPlotEx) plot).setOrientation(orientation); if (plotDef.getInsets() != null) { plot.setInsets(ChartUtil.getRectangle(componentRequest, plotDef.getInsets(), params)); } break; } } else { plot = this.configurePlot(componentRequest, id, plotDef, params, false, -1, null); } return plot; }