List of usage examples for org.jfree.chart.plot XYPlot setBackgroundPaint
public void setBackgroundPaint(Paint paint)
From source file:charts.Chart.java
public static void MultipleLineChart(XYSeriesCollection datasets, String title, String x_axis_label, String y_axis_label) {/*from ww w . j av a 2s .co m*/ JFrame chartwindow = new JFrame(title); JFreeChart jfreechart = ChartFactory.createXYLineChart(title, x_axis_label, y_axis_label, datasets, PlotOrientation.VERTICAL, true, true, true); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.white); xyplot.setRangeGridlinePaint(Color.black); NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); XYLineAndShapeRenderer lineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); lineandshaperenderer.setShapesVisible(true); lineandshaperenderer.setDrawOutlines(true); lineandshaperenderer.setUseFillPaint(true); lineandshaperenderer.setFillPaint(Color.white); JPanel jpanel = new ChartPanel(jfreechart); jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight)); chartwindow.setContentPane(jpanel); chartwindow.pack(); RefineryUtilities.centerFrameOnScreen(chartwindow); chartwindow.setVisible(true); }
From source file:net.nosleep.superanalyzer.analysis.views.YearView.java
private void createChart() { NumberAxis xAxis = new NumberAxis(Misc.getString("RELEASE_YEAR")); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(Misc.getString("SONG_COUNT")); yAxis.setAutoRangeIncludesZero(true); xAxis.setNumberFormatOverride(new DecimalFormat("0")); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); XYPlot plot = new XYPlot(_dataset, xAxis, yAxis, renderer); // create and return the chart panel... _chart = new JFreeChart(Misc.getString("RELEASE_YEAR"), JFreeChart.DEFAULT_TITLE_FONT, plot, true); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4)); LegendTitle legend = _chart.getLegend(); legend.setFrame(BlockBorder.NONE);//from w w w . j a v a 2s .c om _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("RELEASE_YEAR_TOOLTIP"))); XYToolTipGenerator generator = new StandardXYToolTipGenerator("{2}", new DecimalFormat("0.00"), new DecimalFormat("0.00")); renderer.setToolTipGenerator(generator); ChartUtilities.applyCurrentTheme(_chart); // format the lines after applying the theme renderer.setBaseShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setBaseFillPaint(Color.white); renderer.setSeriesStroke(0, new BasicStroke(3.0f)); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0)); renderer.setSeriesStroke(1, new BasicStroke(3.0f)); renderer.setSeriesOutlineStroke(1, new BasicStroke(2.0f)); renderer.setSeriesShape(1, new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0)); _chart.setPadding(new RectangleInsets(10, 10, 10, 10)); Misc.formatChart(plot); }
From source file:edu.ucla.stat.SOCR.chart.demo.DotChart.java
/** * Creates a chart.//from w w w. j a v a2s . co m * * @param dataset the data for the chart. * * @return a chart. */ protected JFreeChart createChart1(XYDataset dataset) { //System.out.println("createChart1 called"); // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title "", // x axis label domain rangeLabel, // y axis label range dataset, // data PlotOrientation.HORIZONTAL, !legendPanelOn, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // renderer.setSeriesShape(0, java.awt.Shape.round); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setBaseLinesVisible(false); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); //change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); rangeAxis.setUpperMargin(0.01); rangeAxis.setLowerMargin(0.01); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); //domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setAutoRangeIncludesZero(true); domainAxis.setTickLabelsVisible(false); domainAxis.setTickMarksVisible(false); domainAxis.setUpperMargin(5); domainAxis.setLowerMargin(0.01); // OPTIONAL CUSTOMISATION COMPLETED. setYSummary(dataset); try { // System.out.println("setting the common RangeAxis to null"); common_rangeAxis = null; common_rangeAxis = (NumberAxis) rangeAxis.clone(); // System.out.println("creating the common RangeAxis"); } catch (CloneNotSupportedException e) { System.out.println("CloneNotSupportedException!, exception caught"); } return chart; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.XYCharts.SimpleBlockChart.java
/** * Creates a chart for the specified dataset. * //from w ww.j a v a2 s . c o m * @param dataset the dataset. * * @return A chart instance. */ public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); XYZDataset dataset = (XYZDataset) datasets.getDatasets().get("1"); JFreeChart chart = null; NumberAxis xAxis = new NumberAxis(xLabel); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (xLowerBound != null && xUpperBound != null) { xAxis.setLowerBound(xLowerBound); xAxis.setUpperBound(xUpperBound); } else { xAxis.setAutoRange(true); } xAxis.setAxisLinePaint(Color.white); xAxis.setTickMarkPaint(Color.white); if (addLabelsStyle != null && addLabelsStyle.getFont() != null) { xAxis.setLabelFont(addLabelsStyle.getFont()); xAxis.setLabelPaint(addLabelsStyle.getColor()); } NumberAxis yAxis = new NumberAxis(yLabel); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (yLowerBound != null && yUpperBound != null) { yAxis.setLowerBound(yLowerBound); yAxis.setUpperBound(yUpperBound); } else yAxis.setAutoRange(true); yAxis.setAxisLinePaint(Color.white); yAxis.setTickMarkPaint(Color.white); if (addLabelsStyle != null && addLabelsStyle.getFont() != null) { yAxis.setLabelFont(addLabelsStyle.getFont()); yAxis.setLabelPaint(addLabelsStyle.getColor()); } XYBlockRenderer renderer = new XYBlockRenderer(); PaintScale paintScale = null; if (grayPaintScale) { paintScale = new GrayPaintScale(minScaleValue, maxScaleValue); } else { if (scaleLowerBound != null && scaleUpperBound != null) { paintScale = new LookupPaintScale(scaleLowerBound, scaleUpperBound, Color.gray); } else { paintScale = new LookupPaintScale(minScaleValue, maxScaleValue, Color.gray); } for (int i = 0; i < zRangeArray.length; i++) { ZRange zRange = zRangeArray[i]; ((LookupPaintScale) paintScale).add(zRange.getValue().doubleValue(), zRange.getColor()); } } renderer.setPaintScale(paintScale); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); plot.setForegroundAlpha(0.66f); chart = new JFreeChart(plot); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } chart.removeLegend(); NumberAxis scaleAxis = new NumberAxis(zLabel); scaleAxis.setAxisLinePaint(Color.white); scaleAxis.setTickMarkPaint(Color.white); scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 7)); if (scaleLowerBound != null && scaleUpperBound != null) { scaleAxis.setLowerBound(scaleLowerBound); scaleAxis.setUpperBound(scaleUpperBound); } else scaleAxis.setAutoRange(true); if (addLabelsStyle != null && addLabelsStyle.getFont() != null) { scaleAxis.setLabelFont(addLabelsStyle.getFont()); scaleAxis.setLabelPaint(addLabelsStyle.getColor()); } if (blockHeight != null && blockWidth != null) { renderer.setBlockWidth(blockWidth.doubleValue()); renderer.setBlockHeight(blockHeight.doubleValue()); } PaintScaleLegend legend = new PaintScaleLegend(paintScale, scaleAxis); legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT); legend.setAxisOffset(5.0); legend.setMargin(new RectangleInsets(5, 5, 5, 5)); legend.setFrame(new BlockBorder(Color.black)); legend.setPadding(new RectangleInsets(10, 10, 10, 10)); legend.setStripWidth(10); legend.setPosition(RectangleEdge.RIGHT); legend.setBackgroundPaint(color); chart.addSubtitle(legend); // chart.setBackgroundPaint(new Color(180, 180, 250)); chart.setBackgroundPaint(color); logger.debug("OUT"); return chart; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.XYCharts.BlockChart.java
/** * Creates a chart for the specified dataset. * /*from w w w .j a va2 s . co m*/ * @param dataset the dataset. * * @return A chart instance. */ public JFreeChart createChart(DatasetMap datasets) { XYZDataset dataset = (XYZDataset) datasets.getDatasets().get("1"); //Creates the xAxis with its label and style NumberAxis xAxis = new NumberAxis(xLabel); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); xAxis.setLabel(xLabel); if (addLabelsStyle != null && addLabelsStyle.getFont() != null) { xAxis.setLabelFont(addLabelsStyle.getFont()); xAxis.setLabelPaint(addLabelsStyle.getColor()); } //Creates the yAxis with its label and style NumberAxis yAxis = new NumberAxis(yLabel); yAxis.setAutoRangeIncludesZero(false); yAxis.setInverted(false); yAxis.setLowerMargin(0.0); yAxis.setUpperMargin(0.0); yAxis.setTickLabelsVisible(true); yAxis.setLabel(yLabel); if (addLabelsStyle != null && addLabelsStyle.getFont() != null) { yAxis.setLabelFont(addLabelsStyle.getFont()); yAxis.setLabelPaint(addLabelsStyle.getColor()); } yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); Color outboundCol = new Color(Integer.decode(outboundColor).intValue()); //Sets the graph paint scale and the legend paintscale LookupPaintScale paintScale = new LookupPaintScale(zvalues[0], (new Double(zrangeMax)).doubleValue(), outboundCol); LookupPaintScale legendPaintScale = new LookupPaintScale(0.5, 0.5 + zvalues.length, outboundCol); for (int ke = 0; ke <= (zvalues.length - 1); ke++) { Double key = (new Double(zvalues[ke])); Color temp = (Color) colorRangeMap.get(key); paintScale.add(zvalues[ke], temp); legendPaintScale.add(0.5 + ke, temp); } //Configures the renderer XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setPaintScale(paintScale); double blockHeight = (new Double(blockH)).doubleValue(); double blockWidth = (new Double(blockW)).doubleValue(); renderer.setBlockWidth(blockWidth); renderer.setBlockHeight(blockHeight); //configures the plot with title, subtitle, axis ecc. XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); plot.setDomainCrosshairPaint(Color.black); plot.setForegroundAlpha(0.66f); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); JFreeChart chart = new JFreeChart(plot); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } chart.removeLegend(); chart.setBackgroundPaint(Color.white); //Sets legend labels SymbolAxis scaleAxis = new SymbolAxis(null, legendLabels); scaleAxis.setRange(0.5, 0.5 + zvalues.length); scaleAxis.setPlot(new PiePlot()); scaleAxis.setGridBandsVisible(false); scaleAxis.setLabel(zLabel); //scaleAxis.setLabelAngle(3.14/2); scaleAxis.setLabelFont(addLabelsStyle.getFont()); scaleAxis.setLabelPaint(addLabelsStyle.getColor()); //draws legend as chart subtitle PaintScaleLegend psl = new PaintScaleLegend(legendPaintScale, scaleAxis); psl.setAxisOffset(2.0); psl.setPosition(RectangleEdge.RIGHT); psl.setMargin(new RectangleInsets(5, 1, 5, 1)); chart.addSubtitle(psl); if (yLabels != null) { //Sets y legend labels LookupPaintScale legendPaintScale2 = new LookupPaintScale(0, (yLabels.length - 1), Color.white); for (int ke = 0; ke < yLabels.length; ke++) { Color temp = Color.white; legendPaintScale2.add(1 + ke, temp); } SymbolAxis scaleAxis2 = new SymbolAxis(null, yLabels); scaleAxis2.setRange(0, (yLabels.length - 1)); scaleAxis2.setPlot(new PiePlot()); scaleAxis2.setGridBandsVisible(false); //draws legend as chart subtitle PaintScaleLegend psl2 = new PaintScaleLegend(legendPaintScale2, scaleAxis2); psl2.setAxisOffset(5.0); psl2.setPosition(RectangleEdge.LEFT); psl2.setMargin(new RectangleInsets(8, 1, 40, 1)); psl2.setStripWidth(0); psl2.setStripOutlineVisible(false); chart.addSubtitle(psl2); } return chart; }
From source file:com.freedomotic.jfrontend.extras.GraphPanel.java
private void createChart(UsageDataFrame points, String title) { series = new TimeSeries(title); for (UsageData d : points.getData()) { Date resultdate = d.getDateTime(); Millisecond ms_read = new Millisecond(resultdate); int poweredValue = -1; if (d.getObjBehavior().equalsIgnoreCase("powered")) { poweredValue = d.getObjValue().equalsIgnoreCase("true") ? 1 : 0; } else if (d.getObjBehavior().equalsIgnoreCase("brigthness")) { try { poweredValue = Integer.parseInt(d.getObjValue()); } catch (NumberFormatException ex) { poweredValue = -1;//w ww .j a v a 2 s . c om } } series.addOrUpdate(ms_read, poweredValue); } XYDataset xyDataset = new TimeSeriesCollection(series); chart = ChartFactory.createTimeSeriesChart("Chart", "TIME", "VALUE", xyDataset, true, // legend true, // tooltips false // urls ); chart.setAntiAlias(true); // Set plot styles XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); // Set series line styles plot.setRenderer(new XYStepRenderer()); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setShapesVisible(true); renderer.setShapesFilled(true); } // Set date axis style DateAxis axis = (DateAxis) plot.getDomainAxis(); String formatString = "MM-dd HH"; DateTickUnitType dtut = DateTickUnitType.HOUR; if (jComboGranularity.getSelectedItem().equals("Year")) { formatString = "yyyy"; dtut = DateTickUnitType.YEAR; } else if (jComboGranularity.getSelectedItem().equals("Month")) { axis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM")); dtut = DateTickUnitType.MONTH; } else if (jComboGranularity.getSelectedItem().equals("Day")) { axis.setDateFormatOverride(new SimpleDateFormat("MM-dd")); dtut = DateTickUnitType.DAY; } else if (jComboGranularity.getSelectedItem().equals("Minute")) { formatString = "MM-dd HH:mm"; dtut = DateTickUnitType.MINUTE; } else if (jComboGranularity.getSelectedItem().equals("Second")) { formatString = "HH:mm:SS"; dtut = DateTickUnitType.SECOND; } DateFormat formatter = new SimpleDateFormat(formatString); DateTickUnit unit = new DateTickUnit(dtut, 1, formatter); axis.setTickUnit(unit); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(800, 500)); graphPanel.removeAll(); graphPanel.add(chartPanel); }
From source file:ec.ui.view.StabilityView.java
@Override protected void onColorSchemeChange() { pointsRenderer.setBasePaint(themeSupport.getLineColor(KnownColor.BLUE)); meanRenderer.setBasePaint(themeSupport.getLineColor(KnownColor.RED)); smoothRenderer.setBasePaint(themeSupport.getLineColor(KnownColor.GREEN)); XYPlot mainPlot = mainChart.getXYPlot(); mainPlot.setBackgroundPaint(themeSupport.getPlotColor()); mainPlot.setDomainGridlinePaint(themeSupport.getGridColor()); mainPlot.setRangeGridlinePaint(themeSupport.getGridColor()); mainChart.setBackgroundPaint(themeSupport.getBackColor()); XYPlot detailPlot = detailChart.getXYPlot(); detailPlot.setBackgroundPaint(themeSupport.getPlotColor()); detailPlot.setDomainGridlinePaint(themeSupport.getGridColor()); detailPlot.setRangeGridlinePaint(themeSupport.getGridColor()); detailChart.setBackgroundPaint(themeSupport.getBackColor()); }
From source file:nu.nethome.tools.protocol_analyzer.RawMessageDistributionWindow.java
private void configurePanelLooks(JFreeChart chart, int selectionSeries) { TextTitle title = chart.getTitle(); // fix title Font titleFont = title.getFont(); titleFont = titleFont.deriveFont(Font.PLAIN, (float) 14.0); title.setFont(titleFont);/*from w w w .j av a 2 s.c om*/ title.setPaint(Color.darkGray); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer signalRenderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer(); signalRenderer.setSeriesStroke(selectionSeries, new BasicStroke(5f)); }
From source file:Applet.EmbeddedChart.java
public synchronized void updateInfo(String[] legends, List<double[][]> yVals, boolean gofr) { removeAll();// w w w . j a v a 2s . c o m GridBagLayout gbl = new GridBagLayout(); gbl.columnWidths = new int[] { 10, 0, 0 }; gbl.rowHeights = new int[] { 0, 0, 0 }; gbl.columnWeights = new double[] { 0.0, 1.0, 1.0 }; gbl.rowWeights = new double[] { 1.0, 1.0, 0.0 }; setLayout(gbl); this.legends = legends; this.yvals = yVals; this.gofr = gofr; XYDataset dataset = createDataset(gofr, legends, yVals); JFreeChart chart = createChart(dataset, title, gofr); chartPanel = new ChartPanel(chart); chartPanel.setMinimumDrawWidth(0); chartPanel.setMinimumDrawHeight(0); chartPanel.setMaximumDrawWidth(2000); chartPanel.setMaximumDrawHeight(2000); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); chartPanel.getChart().setBackgroundPaint(null); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 2; gbc.gridheight = 2; gbc.fill = GridBagConstraints.BOTH; add(chartPanel, gbc); GridBagConstraints gbcX1 = new GridBagConstraints(); GridBagConstraints gbcX2 = new GridBagConstraints(); GridBagConstraints gbcY1 = new GridBagConstraints(); GridBagConstraints gbcY2 = new GridBagConstraints(); GridBagConstraints gbcButton = new GridBagConstraints(); final NumberAxis domain = (NumberAxis) ((XYPlot) chartPanel.getChart().getPlot()).getDomainAxis(); final NumberAxis range = (NumberAxis) ((XYPlot) chartPanel.getChart().getPlot()).getRangeAxis(); if (gofr) { domain.setLowerBound(over.gr_xMin); domain.setUpperBound(over.gr_xMax); range.setLowerBound(over.gr_yMin); range.setUpperBound(over.gr_yMax); } else { domain.setLowerBound(over.pot_xMin); domain.setUpperBound(over.pot_xMax); range.setLowerBound(over.pot_yMin); range.setUpperBound(over.pot_yMax); } gbcX2.gridx = 2; gbcX2.gridy = 2; gbcX2.anchor = GridBagConstraints.EAST; gbcX2.insets = new Insets(0, 0, 0, 12); final JTextField xMax = new JTextField(5); xMax.setMinimumSize(new Dimension(50, 20)); xMax.setText("" + domain.getUpperBound()); // gbcX2.fill = GridBagConstraints.VERTICAL; add(xMax, gbcX2); final boolean gr = gofr; xMax.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (gr) { over.gr_xMax = Double.parseDouble(xMax.getText()); domain.setRange(over.gr_xMin, over.gr_xMax); } else { over.pot_xMax = Double.parseDouble(xMax.getText()); domain.setRange(over.pot_xMin, over.pot_xMax); } } @Override public void focusGained(FocusEvent e) { } }); gbcX1.gridx = 1; gbcX1.gridy = 2; gbcX1.anchor = GridBagConstraints.WEST; gbcX1.insets = new Insets(0, 70, 0, 0); final JTextField xMin = new JTextField(5); xMin.setMinimumSize(new Dimension(50, 20)); xMin.setText("" + domain.getLowerBound()); // gbcX1.fill = GridBagConstraints.VERTICAL; add(xMin, gbcX1); xMin.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { x1 = Double.parseDouble(xMin.getText()); domain.setRange(x1, x2); if (gr) { over.gr_xMin = Double.parseDouble(xMin.getText()); domain.setRange(over.gr_xMin, over.gr_xMax); } else { over.pot_xMin = Double.parseDouble(xMin.getText()); domain.setRange(over.pot_xMin, over.pot_xMax); } } @Override public void focusGained(FocusEvent e) { } }); gbcY1.gridx = 0; gbcY1.gridy = 1; gbcY1.anchor = GridBagConstraints.SOUTH; gbcY1.insets = new Insets(0, 0, 45, 0); final JTextField yMin = new JTextField(5); yMin.setMinimumSize(new Dimension(50, 20)); yMin.setText("" + range.getLowerBound()); // gbcY1.fill = GridBagConstraints.BOTH; add(yMin, gbcY1); yMin.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (gr) { over.gr_yMin = Double.parseDouble(yMin.getText()); range.setRange(over.gr_yMin, over.gr_yMax); } else { over.pot_yMin = Double.parseDouble(yMin.getText()); range.setRange(over.pot_yMin, over.pot_yMax); } } @Override public void focusGained(FocusEvent e) { } }); gbcY2.gridx = 0; gbcY2.gridy = 0; gbcY2.anchor = GridBagConstraints.NORTH; gbcY2.insets = new Insets(10, 0, 0, 0); final JTextField yMax = new JTextField(5); yMax.setMinimumSize(new Dimension(50, 20)); yMax.setText("" + range.getUpperBound()); // gbcY2.fill = GridBagConstraints.BOTH; add(yMax, gbcY2); yMax.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (gr) { over.gr_yMax = Double.parseDouble(yMax.getText()); range.setRange(over.gr_yMin, over.gr_yMax); } else { over.pot_yMax = Double.parseDouble(yMax.getText()); range.setRange(over.pot_yMin, over.pot_yMax); } } @Override public void focusGained(FocusEvent e) { } }); }
From source file:clientv2.GUI.java
/** * Creates a chart//w ww . j a v a2 s .co m * * @param TS * @param GraphName * @return */ public JFreeChart createChart(TimeSeriesCollection TS, String GraphName, double minRange, double maxRange) { JFreeChart chart = ChartFactory.createTimeSeriesChart(GraphName, "Time", "Value", TS, true, true, false); final XYPlot plot = chart.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); plot.getRangeAxis().setRange(minRange, maxRange); plot.setBackgroundPaint(WHITE); plot.setDomainMinorGridlinePaint(BLACK); plot.setDomainGridlinePaint(BLACK); plot.setRangeMinorGridlinePaint(BLACK); plot.setRangeGridlinesVisible(true); axis.setFixedAutoRange(20000.0); return chart; }