List of usage examples for org.jfree.chart.plot XYPlot setDomainCrosshairVisible
public void setDomainCrosshairVisible(boolean flag)
From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.GpsScatterPlotUIComponent.java
/*********************************************************************************************** * Customise the XYPlot of a new chart, e.g. for fixed range axes. * Remember that a GPS Scatter Plot has no ChannelSelector. * * @param datasettype//from w ww . ja va 2 s . c o m * @param primarydataset * @param secondarydatasets * @param updatetype * @param displaylimit * @param channelselector * @param debug * * @return JFreeChart */ public JFreeChart createCustomisedChart(final DatasetType datasettype, final XYDataset primarydataset, final List<XYDataset> secondarydatasets, final DataUpdateType updatetype, final int displaylimit, final ChannelSelectorUIComponentInterface channelselector, final boolean debug) { final String SOURCE = "GpsScatterPlotUIComponent.createCustomisedChart() "; final JFreeChart jFreeChart; final XYPlot plot; final Stroke strokeCrosshair; final XYDotRenderer renderer; final ValueAxis axisRange; final NumberAxis axisDomain; // See ChartHelper for other calls to ChartFactory // Note that no ChannelSector means no way to control the legend, so turn it off jFreeChart = ChartFactory.createScatterPlot(MSG_WAITING_FOR_DATA, MSG_WAITING_FOR_DATA, MSG_WAITING_FOR_DATA, primarydataset, PlotOrientation.VERTICAL, false, //channelselector.hasLegend(), true, false); jFreeChart.setBackgroundPaint(UIComponentPlugin.DEFAULT_COLOUR_CANVAS.getColor()); // Experimental chart configuration jFreeChart.getTitle().setFont(UIComponentPlugin.DEFAULT_FONT.getFont().deriveFont(20.0f)); plot = (XYPlot) jFreeChart.getPlot(); plot.setBackgroundPaint(ChartHelper.COLOR_PLOT); plot.setDomainGridlinePaint(ChartHelper.COLOR_GRIDLINES); plot.setRangeGridlinePaint(ChartHelper.COLOR_GRIDLINES); plot.setAxisOffset(ChartHelper.PLOT_RECTANGLE_INSETS); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); plot.setDomainCrosshairVisible(true); plot.setDomainCrosshairLockedOnData(false); plot.setRangeCrosshairVisible(true); plot.setRangeCrosshairLockedOnData(true); // Make the Crosshair more visible by changing the width from the default strokeCrosshair = new BasicStroke(2.0f, // The width of this BasicStroke BasicStroke.CAP_BUTT, // The decoration of the ends of a BasicStroke BasicStroke.JOIN_BEVEL, // The decoration applied where path segments meet 0.0f, // The limit to trim the miter join new float[] { 2.0f, 2.0f }, // The array representing the dashing pattern 0.0f); // The offset to start the dashing pattern plot.setDomainCrosshairStroke(strokeCrosshair); plot.setRangeCrosshairStroke(strokeCrosshair); renderer = new XYDotRenderer(); renderer.setDotWidth(2); renderer.setDotHeight(2); plot.setRenderer(renderer); axisDomain = (NumberAxis) plot.getDomainAxis(); axisRange = plot.getRangeAxis(); // Remember that a GPS Scatter Plot has no ChannelSelector if (canAutorange()) { // The fix could be anywhere... axisDomain.setAutoRangeIncludesZero(false); axisDomain.setAutoRange(true); axisRange.setAutoRange(true); } else { // Allow range to full global extents! axisDomain.setRange(getLinearFixedMinY(), getLinearFixedMaxY()); axisRange.setRange(-90.0, 90.0); } return (jFreeChart); }
From source file:org.jrecruiter.web.actions.admin.ShowStatisticsAction.java
public final String chartJobCount() throws Exception { final Calendar calendarToday = CalendarUtils.getCalendarWithoutTime(); final Calendar calendar30 = CalendarUtils.getCalendarWithoutTime(); calendar30.add(Calendar.MONTH, -36); final List<JobCountPerDay> jobCountPerDayList = jobService.getJobCountPerDayAndPeriod(calendar30.getTime(), calendarToday.getTime());/*from ww w . j av a 2 s .c o m*/ final TimeSeries hitsPerDayData = new TimeSeries("Hits", Day.class); final XYDataset hitsPerDayDataset = new TimeSeriesCollection(hitsPerDayData); this.chart = ChartFactory.createTimeSeriesChart("", super.getText("class.ShowStatisticsAcion.chart.job.count.caption"), "", hitsPerDayDataset, false, true, false); final XYPlot xyplot = (XYPlot) this.chart.getPlot(); for (JobCountPerDay jobCountPerDay : jobCountPerDayList) { final Day day = new Day(jobCountPerDay.getJobDate()); if (jobCountPerDay.getAutomaticallyCleaned()) { final Marker originalEnd = new ValueMarker(day.getFirstMillisecond()); originalEnd.setPaint(new Color(0, 80, 138, 150)); float[] dashPattern = { 6, 2 }; originalEnd.setStroke( new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10, dashPattern, 0)); originalEnd.setLabelAnchor(RectangleAnchor.TOP_LEFT); originalEnd.setLabelTextAnchor(TextAnchor.TOP_RIGHT); originalEnd.setLabel("C"); originalEnd.setAlpha(0.1F); xyplot.addDomainMarker(originalEnd); } hitsPerDayData.add(day, jobCountPerDay.getTotalNumberOfJobs()); } chart.setBackgroundPaint(new Color(255, 255, 255, 0)); xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY); xyplot.setBackgroundPaint(new Color(255, 255, 255, 0)); xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(false); xyitemrenderer.setSeriesPaint(0, new Color(244, 66, 0)); } DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setAutoRange(true); dateaxis.setAutoTickUnitSelection(true); NumberAxis valueAxis = (NumberAxis) xyplot.getRangeAxis(); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return SUCCESS; }
From source file:mil.tatrc.physiology.utilities.csv.plots.CSVPlotTool.java
public void formatXYPlot(JFreeChart chart, Paint bgColor) { XYPlot plot = (XYPlot) chart.getPlot(); //For Scientific notation NumberFormat formatter = new DecimalFormat("0.######E0"); for (int i = 0; i < plot.getDomainAxisCount(); i++) { plot.getDomainAxis(i).setLabelFont(largeFont); plot.getDomainAxis(i).setTickLabelFont(smallFont); plot.getDomainAxis(i).setLabelPaint(bgColor == Color.red ? Color.white : Color.black); plot.getDomainAxis(i).setTickLabelPaint(bgColor == Color.red ? Color.white : Color.black); }//from w w w.ja va2s . c o m for (int i = 0; i < plot.getRangeAxisCount(); i++) { plot.getRangeAxis(i).setLabelFont(largeFont); plot.getRangeAxis(i).setTickLabelFont(smallFont); plot.getRangeAxis(i).setLabelPaint(bgColor == Color.red ? Color.white : Color.black); plot.getRangeAxis(i).setTickLabelPaint(bgColor == Color.red ? Color.white : Color.black); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(i); rangeAxis.setNumberFormatOverride(formatter); } //White background outside of plottable area chart.setBackgroundPaint(bgColor); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); chart.getLegend().setItemFont(smallFont); chart.getTitle().setFont(largeFont); chart.getTitle().setPaint(bgColor == Color.red ? Color.white : Color.black); }
From source file:logdruid.ui.chart.GraphPanel.java
public void load(JPanel panel_2) { startDateJSpinner = (JSpinner) panel_2.getComponent(2); endDateJSPinner = (JSpinner) panel_2.getComponent(3); // scrollPane.setV panel.removeAll();/*from w w w .j ava 2 s.com*/ Dimension panelSize = this.getSize(); add(scrollPane, BorderLayout.CENTER); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); // scrollPane.set trying to replace scroll where it was JCheckBox relativeCheckBox = (JCheckBox) panel_2.getComponent(5); estimatedTime = System.currentTimeMillis() - startTime; logger.info("gathering time: " + estimatedTime); startTime = System.currentTimeMillis(); // Map<Source, Map<String, MineResult>> Map<Source, Map<String, MineResult>> treeMap = new TreeMap<Source, Map<String, MineResult>>( mineResultSet.mineResults); Iterator mineResultSetIterator = treeMap.entrySet().iterator(); int ite = 0; logger.debug("mineResultSet size: " + mineResultSet.mineResults.size()); while (mineResultSetIterator.hasNext()) { final Map.Entry pairs = (Map.Entry) mineResultSetIterator.next(); logger.debug("mineResultSet key/source: " + ((Source) pairs.getKey()).getSourceName()); JCheckBox checkBox = (JCheckBox) panel_1.getComponent(ite++); logger.debug("checkbox: " + checkBox.getText() + ", " + checkBox.isSelected()); if (checkBox.isSelected()) { Map mrArrayList = (Map<String, MineResult>) pairs.getValue(); ArrayList<String> mineResultGroup = new ArrayList<String>(); Set<String> mrss = mrArrayList.keySet(); mineResultGroup.addAll(mrss); Collections.sort(mineResultGroup, new AlphanumComparator()); Iterator mrArrayListIterator = mineResultGroup.iterator(); while (mrArrayListIterator.hasNext()) { String key = (String) mrArrayListIterator.next(); logger.debug(key); final MineResult mr = (MineResult) mrArrayList.get(key); Map<String, ExtendedTimeSeries> statMap = mr.getStatTimeseriesMap(); Map<String, ExtendedTimeSeries> eventMap = mr.getEventTimeseriesMap(); // logger.info("mineResultSet hash size: " // +mr.getTimeseriesMap().size()); // logger.info("mineResultSet hash content: " + // mr.getStatTimeseriesMap()); logger.debug("mineResultSet mr.getStartDate(): " + mr.getStartDate() + " mineResultSet mr.getEndDate(): " + mr.getEndDate()); logger.debug("mineResultSet (Date)jsp.getValue(): " + (Date) startDateJSpinner.getValue()); logger.debug("mineResultSet (Date)jsp2.getValue(): " + (Date) endDateJSPinner.getValue()); if (mr.getStartDate() != null && mr.getEndDate() != null) { if ((mr.getStartDate().before((Date) endDateJSPinner.getValue())) && (mr.getEndDate().after((Date) startDateJSpinner.getValue()))) { ArrayList<String> mineResultGroup2 = new ArrayList<String>(); Set<String> mrss2 = statMap.keySet(); mineResultGroup2.addAll(mrss2); Collections.sort(mineResultGroup2, new AlphanumComparator()); Iterator statMapIterator = mineResultGroup2.iterator(); // Iterator statMapIterator = statMap.entrySet().iterator(); if (!statMap.entrySet().isEmpty() || !eventMap.entrySet().isEmpty()) { JPanel checkboxPanel = new JPanel(new WrapLayout()); checkboxPanel.setBackground(Color.white); int count = 1; chart = ChartFactory.createXYAreaChart(// Title mr.getSourceID() + " " + mr.getGroup(), // + null, // X-Axis // label null, // Y-Axis label null, // Dataset PlotOrientation.VERTICAL, false, // Show // legend true, // tooltips false // url ); TextTitle my_Chart_title = new TextTitle(mr.getSourceID() + " " + mr.getGroup(), new Font("Verdana", Font.BOLD, 17)); chart.setTitle(my_Chart_title); XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis range = plot.getRangeAxis(); range.setVisible(false); final DateAxis domainAxis1 = new DateAxis(); domainAxis1.setTickLabelsVisible(true); // domainAxis1.setTickMarksVisible(true); logger.debug("getRange: " + domainAxis1.getRange()); if (relativeCheckBox.isSelected()) { domainAxis1.setRange((Date) startDateJSpinner.getValue(), (Date) endDateJSPinner.getValue()); } else { Date startDate = mr.getStartDate(); Date endDate = mr.getEndDate(); if (mr.getStartDate().before((Date) startDateJSpinner.getValue())) { startDate = (Date) startDateJSpinner.getValue(); logger.debug("setMinimumDate: " + (Date) startDateJSpinner.getValue()); } if (mr.getEndDate().after((Date) endDateJSPinner.getValue())) { endDate = (Date) endDateJSPinner.getValue(); logger.debug("setMaximumDate: " + (Date) endDateJSPinner.getValue()); } if (startDate.before(endDate)) { domainAxis1.setRange(startDate, endDate); } } XYToolTipGenerator tt1 = new XYToolTipGenerator() { public String generateToolTip(XYDataset dataset, int series, int item) { StringBuffer sb = new StringBuffer(); String htmlStr = "<html>"; Number x; FastDateFormat sdf = FastDateFormat.getInstance("dd-MMM-yyyy HH:mm:ss"); x = dataset.getX(series, item); sb.append(htmlStr); if (x != null) { sb.append("<p style='color:#000000;'>" + (sdf.format(x)) + "</p>"); sb.append("<p style='color:#000000;'>" + dataset.getSeriesKey(series).toString() + ": " + form.format(dataset.getYValue(0, item)) + "</p>"); if (mr.getFileLineForDate(new Date(x.longValue()), dataset.getSeriesKey(series).toString()) != null) { sb.append( "<p style='color:#0000FF;'>" + cd.sourceFileArrayListMap .get(pairs.getKey()).get(mr .getFileLineForDate( new Date(x.longValue()), dataset.getSeriesKey(series) .toString()) .getFileId()) .getFile().getName() + ":" + mr.getFileLineForDate(new Date(x.longValue()), dataset.getSeriesKey(series).toString()) .getLineNumber() + "</p>"); } } return sb.toString(); } }; while (statMapIterator.hasNext()) { TimeSeriesCollection dataset = new TimeSeriesCollection(); String me = (String) statMapIterator.next(); ExtendedTimeSeries ts = (ExtendedTimeSeries) statMap.get(me); // logger.info(((TimeSeries) // me.getValue()).getMaxY()); if (((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY() > 0) dataset.addSeries(ts.getTimeSeries()); logger.debug("mineResultSet group: " + mr.getGroup() + ", key: " + me + " nb records: " + ((ExtendedTimeSeries) statMap.get(me)) .getTimeSeries().getItemCount()); logger.debug("(((TimeSeries) me.getValue()).getMaxY(): " + (((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY())); logger.debug("(((TimeSeries) me.getValue()).getMinY(): " + (((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMinY())); XYPlot plot1 = chart.getXYPlot(); // LogarithmicAxis axis4 = new LogarithmicAxis(me.toString()); NumberAxis axis4 = new NumberAxis(me.toString()); axis4.setAutoRange(true); axis4.setAxisLineVisible(true); axis4.setAutoRangeIncludesZero(false); plot1.setDomainCrosshairVisible(true); plot1.setRangeCrosshairVisible(true); axis4.setRange(new Range( ((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMinY(), ((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY())); axis4.setLabelPaint(colors[count]); axis4.setTickLabelPaint(colors[count]); plot1.setRangeAxis(count, axis4); final ValueAxis domainAxis = domainAxis1; domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); plot1.setDomainAxis(domainAxis); plot1.setForegroundAlpha(0.5f); plot1.setDataset(count, dataset); plot1.mapDatasetToRangeAxis(count, count); final XYAreaRenderer renderer = new XYAreaRenderer(); // XYAreaRenderer2 // also // nice if ((((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY() - ((ExtendedTimeSeries) statMap.get(me)).getTimeSeries() .getMinY()) > 0) { // renderer.setToolTipGenerator(new // StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,new // FastDateFormat("d-MMM-yyyy HH:mm:ss"), // new DecimalFormat("#,##0.00"))); } renderer.setSeriesPaint(0, colors[count]); renderer.setSeriesVisible(0, true); renderer.setSeriesToolTipGenerator(0, tt1); plot1.setRenderer(count, renderer); int hits = 0; // ts.getStat()[1] int matchs = 0; if (((ExtendedTimeSeries) statMap.get(me)).getStat() != null) { hits = ((ExtendedTimeSeries) statMap.get(me)).getStat()[1]; // matchs= ((ExtendedTimeSeries) statMap.get(me)).getStat()[0]; } JCheckBox jcb = new JCheckBox(new VisibleAction(panel, checkboxPanel, axis4, me.toString() + "(" + hits + ")", 0)); Boolean selected = true; jcb.setSelected(true); jcb.setBackground(Color.white); jcb.setBorderPainted(true); jcb.setBorder(BorderFactory.createLineBorder(colors[count], 1, true)); jcb.setFont(new Font("Sans-serif", oldSmallFont.getStyle(), oldSmallFont.getSize())); checkboxPanel.add(jcb); count++; } Iterator eventMapIterator = eventMap.entrySet().iterator(); while (eventMapIterator.hasNext()) { // HistogramDataset histoDataSet=new HistogramDataset(); TimeSeriesCollection dataset = new TimeSeriesCollection(); Map.Entry me = (Map.Entry) eventMapIterator.next(); // if (dataset.getEndXValue(series, item)) if (((ExtendedTimeSeries) me.getValue()).getTimeSeries().getMaxY() > 0) dataset.addSeries(((ExtendedTimeSeries) me.getValue()).getTimeSeries()); logger.debug("mineResultSet group: " + mr.getGroup() + ", key: " + me.getKey() + " nb records: " + ((ExtendedTimeSeries) me.getValue()).getTimeSeries().getItemCount()); logger.debug("mineResultSet hash content: " + mr.getEventTimeseriesMap()); logger.debug("(((TimeSeries) me.getValue()).getMaxY(): " + (((ExtendedTimeSeries) me.getValue()).getTimeSeries().getMaxY())); logger.debug("(((TimeSeries) me.getValue()).getMinY(): " + (((ExtendedTimeSeries) me.getValue()).getTimeSeries().getMinY())); XYPlot plot2 = chart.getXYPlot(); // LogarithmicAxis axis4 = new LogarithmicAxis(me.toString()); NumberAxis axis4 = new NumberAxis(me.getKey().toString()); axis4.setAutoRange(true); // axis4.setInverted(true); axis4.setAxisLineVisible(true); axis4.setAutoRangeIncludesZero(true); // axis4.setRange(new Range(((TimeSeries) // axis4.setRange(new Range(((TimeSeries) // me.getValue()).getMinY(), ((TimeSeries) // me.getValue()).getMaxY())); axis4.setLabelPaint(colors[count]); axis4.setTickLabelPaint(colors[count]); plot2.setRangeAxis(count, axis4); final ValueAxis domainAxis = domainAxis1; // domainAxis.setLowerMargin(0.001); // domainAxis.setUpperMargin(0.0); plot2.setDomainCrosshairVisible(true); plot2.setRangeCrosshairVisible(true); //plot2.setRangeCrosshairLockedOnData(true); plot2.setDomainAxis(domainAxis); plot2.setForegroundAlpha(0.5f); plot2.setDataset(count, dataset); plot2.mapDatasetToRangeAxis(count, count); XYBarRenderer rend = new XYBarRenderer(); // XYErrorRenderer rend.setShadowVisible(false); rend.setDrawBarOutline(true); Stroke stroke = new BasicStroke(5); rend.setBaseStroke(stroke); final XYItemRenderer renderer = rend; renderer.setSeriesToolTipGenerator(0, tt1); // renderer.setItemLabelsVisible(true); renderer.setSeriesPaint(0, colors[count]); renderer.setSeriesVisible(0, true); plot2.setRenderer(count, renderer); int hits = 0; int matchs = 0; if (((ExtendedTimeSeries) me.getValue()).getStat() != null) { hits = ((ExtendedTimeSeries) me.getValue()).getStat()[1]; // matchs= ((ExtendedTimeSeries) me.getValue()).getStat()[0]; } JCheckBox jcb = new JCheckBox(new VisibleAction(panel, checkboxPanel, axis4, me.getKey().toString() + "(" + hits + ")", 0)); jcb.setSelected(true); jcb.setBackground(Color.white); jcb.setBorderPainted(true); jcb.setBorder(BorderFactory.createLineBorder(colors[count], 1, true)); jcb.setFont(new Font("Sans-serif", oldSmallFont.getStyle(), oldSmallFont.getSize())); checkboxPanel.add(jcb); count++; } JPanel pan = new JPanel(); pan.setLayout(new BorderLayout()); pan.setPreferredSize(new Dimension(600, Integer.parseInt((String) Preferences.getPreference("chartSize")))); // pan.setPreferredSize(panelSize); panel.add(pan); final ChartPanel cpanel = new ChartPanel(chart); cpanel.setMinimumDrawWidth(0); cpanel.setMinimumDrawHeight(0); cpanel.setMaximumDrawWidth(1920); cpanel.setMaximumDrawHeight(1200); // cpanel.setInitialDelay(0); cpanel.setDismissDelay(9999999); cpanel.setInitialDelay(50); cpanel.setReshowDelay(200); cpanel.setPreferredSize(new Dimension(600, 350)); // cpanel.restoreAutoBounds(); fix the tooltip // missing problem but then relative display is // broken panel.add(new JSeparator(SwingConstants.HORIZONTAL)); pan.add(cpanel, BorderLayout.CENTER); // checkboxPanel.setPreferredSize(new Dimension(600, // 0)); cpanel.addChartMouseListener(new ChartMouseListener() { public void chartMouseClicked(ChartMouseEvent chartmouseevent) { // chartmouseevent.getEntity(). ChartEntity entity = chartmouseevent.getEntity(); if (entity instanceof XYItemEntity) { XYItemEntity item = ((XYItemEntity) entity); if (item.getDataset() instanceof TimeSeriesCollection) { TimeSeriesCollection data = (TimeSeriesCollection) item .getDataset(); TimeSeries series = data.getSeries(item.getSeriesIndex()); TimeSeriesDataItem dataitem = series.getDataItem(item.getItem()); // logger.info(" Serie: "+series.getKey().toString() // + // " Period : "+dataitem.getPeriod().toString()); // mr.getFileForDate(new Date // (x.longValue()) ; int x = chartmouseevent.getTrigger().getX(); // logger.info(mr.getFileForDate(dataitem.getPeriod().getEnd())); int y = chartmouseevent.getTrigger().getY(); String myString = ""; if (dataitem.getPeriod() != null) { logger.info(dataitem.getPeriod().getEnd()); // myString = mr.getFileForDate(dataitem.getPeriod().getEnd()).toString(); String lineString = "" + mr.getFileLineForDate(dataitem.getPeriod().getEnd(), item.getDataset() .getSeriesKey(item.getSeriesIndex()) .toString()) .getLineNumber(); String fileString = cd.sourceFileArrayListMap .get(pairs.getKey()) .get(mr.getFileLineForDate( dataitem.getPeriod().getEnd(), item.getDataset() .getSeriesKey(item.getSeriesIndex()) .toString()) .getFileId()) .getFile().getAbsolutePath(); String command = Preferences.getPreference("editorCommand"); command = command.replace("$line", lineString); command = command.replace("$file", fileString); logger.info(command); Runtime rt = Runtime.getRuntime(); try { rt.exec(command); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } StringSelection stringSelection = new StringSelection( fileString); Clipboard clpbrd = Toolkit.getDefaultToolkit() .getSystemClipboard(); clpbrd.setContents(stringSelection, null); // cpanel.getGraphics().drawString("file name copied", x - 5, y - 5); try { Thread.sleep(500); } catch (InterruptedException e) { // TODO Auto-generated catch // block e.printStackTrace(); } } // logger.info(mr.getFileForDate(dataitem.getPeriod().getStart())); } } } public void chartMouseMoved(ChartMouseEvent e) { } }); pan.add(checkboxPanel, BorderLayout.SOUTH); } } } else { logger.debug("mr dates null: " + mr.getGroup() + mr.getSourceID() + mr.getLogFiles()); } } } } // Map=miner.mine(sourceFiles,repo); estimatedTime = System.currentTimeMillis() - startTime; revalidate(); logger.info("display time: " + estimatedTime); }
From source file:org.tolven.web.MenuAction.java
/** * Creates a chart based on MenuData/*w ww .j a v a 2 s.c o m*/ * @param dataset a dataset * @return A chart suitable for rendering */ public JFreeChart createChart(String title, XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title "Date", // x-axis label "Value", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
From source file:com.att.aro.ui.view.diagnostictab.GraphPanel.java
private void setCrossHair(double crossHairValue) { // set the cross hair values of plot and sub-plots Plot mainplot = getAdvancedGraph().getPlot(); if (mainplot instanceof CombinedDomainXYPlot) { combinedPlot = (CombinedDomainXYPlot) mainplot; List<?> plots = combinedPlot.getSubplots(); for (Object p : plots) { if (p instanceof XYPlot) { XYPlot subPlot = (XYPlot) p; subPlot.setDomainCrosshairLockedOnData(false); subPlot.setDomainCrosshairValue(crossHairValue); subPlot.setDomainCrosshairVisible(true); }//from w w w . j a va2 s . c o m } combinedPlot.setDomainCrosshairLockedOnData(false); combinedPlot.setDomainCrosshairValue(crossHairValue, true); combinedPlot.setDomainCrosshairVisible(true); } getHandlePanel().setHandlePosition(getHandleCoordinate()); }
From source file:org.ujmp.jfreechart.MatrixChartPanel.java
public synchronized void redraw() { Dataset dataset = null;/*from ww w . jav a 2 s .c o m*/ dataset = new XYSeriesCollectionWrapper(getMatrix()); // dataset = new CategoryDatasetWrapper(getMatrix()); String title = getMatrix().getLabel(); String xLabel = StringUtil.format(getMatrix().getMatrix().getDimensionLabel(Matrix.ROW)); String yLabel = null; // setChart(ChartFactory.createLineChart(title, xLabel, yLabel, // (CategoryDataset) dataset, PlotOrientation.VERTICAL, true, // true, false)); setChart(ChartFactory.createXYLineChart(title, xLabel, yLabel, (XYDataset) dataset, PlotOrientation.VERTICAL, true, true, false)); XYPlot plot = getChart().getXYPlot(); if (getConfig().isLogScaleDomain()) { try { NumberAxis axis = new LogarithmicAxis(null); plot.setDomainAxis(axis); } catch (Exception e) { NumberAxis axis = new NumberAxis(); plot.setDomainAxis(axis); } } else { NumberAxis axis = new NumberAxis(); plot.setDomainAxis(axis); } if (getConfig().isLogScaleRange()) { try { NumberAxis axis = new LogarithmicAxis(null); plot.setRangeAxis(axis); } catch (Exception e) { NumberAxis axis = new NumberAxis(); plot.setRangeAxis(axis); } } else { NumberAxis axis = new NumberAxis(); plot.setRangeAxis(axis); } getChart().setTitle((String) null); getChart().setBackgroundPaint(Color.WHITE); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); for (int i = 0; i < getMatrix().getColumnCount(); i++) { renderer.setSeriesStroke(i, new BasicStroke(3)); plot.setRenderer(i, renderer); } plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.getRangeAxis().setAutoRange(true); plot.getDomainAxis().setAutoRange(true); plot.getDomainAxis().setUpperMargin(0); setMouseZoomable(false); }
From source file:org.ramadda.geodata.cdmdata.CdmDataOutputHandler.java
/** * Create the chart//from w ww. j a v a2s .c o m * * * @param request the request * @param entry the entry * @param dataset the dataset * * @return the chart */ private static JFreeChart createChart(Request request, Entry entry, XYDataset dataset) { LatLonPointImpl llp = new LatLonPointImpl(request.getLatOrLonValue(ARG_LOCATION + ".latitude", 0), request.getLatOrLonValue(ARG_LOCATION + ".longitude", 0)); String title = entry.getName() + " at " + llp.toString(); JFreeChart chart = ChartFactory.createTimeSeriesChart( //entry.getName(), // title title, // title "Date", // x-axis label "", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); ValueAxis rangeAxis = new NumberAxis(""); rangeAxis.setVisible(false); XYPlot plot = (XYPlot) chart.getPlot(); if (request.get("gray", false)) { plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); } else { plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); } plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setRangeAxis(0, rangeAxis, false); XYItemRenderer r = plot.getRenderer(); DateAxis axis = (DateAxis) plot.getDomainAxis(); //axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
From source file:v800_trainer.XYGraphik.java
public JPanel StartGraphik(JCicloTronic JTronicHandle) { int num = 0;/* www . j a v a2 s.c o m*/ int num2 = 0, num0, num02; //fr Streckendifferenz int selected; int single; int i; int j; int Stunden; int Minuten; int Sekunden; int Tagadder = 0; int Linecount = 0; Second xTime[]; double xWerte[]; double xWerte2[];//fr Streckendifferenz double y1Werte[]; double y2Werte[]; double y3Werte[]; double y4Werte[]; double y5Werte[]; double y6Werte[]; double y7Werte[]; double y8Werte[]; double y8bWerte[]; double y9Werte[]; double y10Werte[]; JFreeChart chart; Rectangle2D.Double Legendenpunkt = new Rectangle2D.Double(); selected = JTronicHandle.Auswahl_Graphik.getSelectedIndex(); if (selected == 0) { single = 1; } else { single = 0; } //Defaultchart erstellen if (JTronicHandle.Graphik_Radio_Strecke.isSelected()) { XYSeries dataset = new XYSeries(""); dataset.add(1, 1); XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); chart = ChartFactory.createXYLineChart("Multiple Axis Demo 1", "Strecke", "", dataset1, PlotOrientation.HORIZONTAL, true, true, false); } else { TimeSeries dataset = new TimeSeries(""); dataset.add(new Second(1, 1, 1, 1, 1, 1900), 1); TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 1", "Zeit", "", dataset1, true, true, false); } ; //Tooltips fr Zeitachse einstellen // XYToolTipGenerator ToolTip = new StandardXYToolTipGenerator("{0}: ({1}, {2})", // (DateFormat) new SimpleDateFormat("kk:mm.ss"), // NumberFormat.getInstance()); // chart.setAntiAlias(true); chart.setNotify(false); if (single == 0) { chart.setTitle(JTronicHandle.Statistikhandle.TourData[JTronicHandle.Auswahl_Graphik .getSelectedIndex()].DataProperty.getProperty("Titel", "")); chart.addSubtitle(new TextTitle(JTronicHandle.Auswahl_Graphik.getItemAt(selected).toString())); } else { chart.setTitle("Mehrfache Daten"); } chart.setBackgroundPaint(Color.white); JTronicHandle.applyChartTheme(chart); XYPlot plot = chart.getXYPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setRangeCrosshairLockedOnData(false); plot.setDomainCrosshairLockedOnData(false); int Anzahl_Kurven = Integer.parseInt(JTronicHandle.Properties.getProperty("AnzahlKurven", "5")) + 1; if (Anzahl_Kurven > JTronicHandle.Auswahl_Graphik.getItemCount()) { Anzahl_Kurven = JTronicHandle.Auswahl_Graphik.getItemCount(); } try { for (j = 0; j < (Anzahl_Kurven - 2) * single + 1; j++) { if (single == 1) { selected = j + 1; } num = JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte; num2 = JTronicHandle.Statistikhandle.TourData[selected].ZahlStreckenPunkte; num0 = JTronicHandle.Statistikhandle.TourData[1].ZahlStreckenPunkte; num02 = JTronicHandle.Statistikhandle.TourData[1].Datenpunkte; xTime = new Second[num]; xWerte = new double[num]; y1Werte = new double[num]; y2Werte = new double[num]; y3Werte = new double[num]; y4Werte = new double[num]; y5Werte = new double[num]; y6Werte = new double[num]; y7Werte = new double[num]; y8Werte = new double[num]; y8bWerte = new double[num]; xWerte2 = new double[num2]; y9Werte = new double[num2]; y10Werte = new double[num]; for (i = 0; i < num; i++) { xWerte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Strecke_gesZeit[i]; y1Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Geschw_gesZeit[i]; y2Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Hoehe_gesZeit[i]; y3Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Hf_gesZeit[i]; y4Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Temperatur_gesZeit[i]; y5Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Steigp_gesZeit[i]; y6Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Steigm_gesZeit[i]; y7Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].av_Geschw_gesZeit[i]; y8Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Cadence_gesZeit[i]; y8bWerte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Schritt_lnge[i]; } if (JTronicHandle.Graphik_check_Abstand.isSelected() && single == 1 && j != 0) { int p = 0; if (JTronicHandle.Graphik_Radio_Strecke.isSelected()) { for (i = 0; i < num2; i++) { xWerte2[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Streckenskala[i]; if (i < num0) { y9Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].ZeitberStrecke[i] - JTronicHandle.Statistikhandle.TourData[1].ZeitberStrecke[i]; } else { y9Werte[i] = y9Werte[i - 1]; } } } else { for (i = 0; i < num; i++) { p = 0; while (p < num02 - 1 && (JTronicHandle.Statistikhandle.TourData[selected].gesZeit[i] >= JTronicHandle.Statistikhandle.TourData[1].gesZeit[p])) { p++; } ; if (i < num02) { y10Werte[i] = (double) (JTronicHandle.Statistikhandle.TourData[selected].Strecke_gesZeit[i] - JTronicHandle.Statistikhandle.TourData[1].Strecke_gesZeit[p]) * 100.0; } else { y10Werte[i] = y10Werte[i - 1]; } } } } //Zeitbasis laden for (i = 0; i < num; i++) { Tagadder = 0; Stunden = (int) (JTronicHandle.Statistikhandle.TourData[selected].gesZeit[i] / 3600); Minuten = (int) ((JTronicHandle.Statistikhandle.TourData[selected].gesZeit[i] - Stunden * 3600) / 60); Sekunden = (int) (JTronicHandle.Statistikhandle.TourData[selected].gesZeit[i] - Stunden * 3600 - Minuten * 60); if (single == 0) { Minuten = Minuten + JTronicHandle.Statistikhandle.TourData[selected].StartMinuten; if (Minuten >= 60) { Minuten -= 60; Stunden++; } ; Stunden = Stunden + JTronicHandle.Statistikhandle.TourData[selected].StartStunden; } ; while (Stunden >= 24) { Stunden -= 24; Tagadder += 1; } ; try { if (single == 0) { xTime[i] = new Second(Sekunden, Minuten, Stunden, JTronicHandle.Statistikhandle.TourData[selected].Tag + Tagadder, JTronicHandle.Statistikhandle.TourData[selected].Monat, JTronicHandle.Statistikhandle.TourData[selected].Jahr); } else { xTime[i] = new Second(Sekunden, Minuten, Stunden, 1 + Tagadder, 1, 1900); } } catch (Exception e) { JOptionPane.showMessageDialog(null, "StartGraphik\n" + e + "Zeile " + i + " Zeitfehler " + Stunden + " " + Minuten + " " + Sekunden, "Achtung!", JOptionPane.ERROR_MESSAGE); } } if (JTronicHandle.Graphik_Radio_Strecke.isSelected()) { //Streckenachse if (JTronicHandle.Graphik_check_Geschwindigkeit.isSelected()) { XYSeries dataset = new XYSeries( "Geschwindigkeit [km/h] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y1Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Hhe.isSelected()) { XYSeries dataset = new XYSeries( "Hhe [m] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y2Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); NumberAxis axis2 = new NumberAxis("Hhe [m]"); axis2.setLabelFont(plot.getRangeAxis().getLabelFont()); axis2.setTickLabelFont(plot.getRangeAxis().getTickLabelFont()); axis2.setAutoRangeIncludesZero(true); axis2.setLabelPaint(Color.BLACK); axis2.setTickLabelPaint(Color.BLACK); axis2.setAxisLinePaint(Color.BLACK); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 1); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } ; if (JTronicHandle.Graphik_check_HF.isSelected()) { XYSeries dataset = new XYSeries( "Herzfrequenz [b/min] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y3Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Temp.isSelected()) { XYSeries dataset = new XYSeries( "Temperatur [C] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y4Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Steigung_p.isSelected()) { XYSeries dataset = new XYSeries( "Steigung [%] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y5Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Steigung_m.isSelected()) { XYSeries dataset = new XYSeries( "Steigung [m/min] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y6Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_av_Geschw.isSelected()) { XYSeries dataset = new XYSeries( "av Geschw. [km/h] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y7Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Cadence.isSelected()) { XYSeries dataset = new XYSeries( "Cadence [n/min] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y8Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Schrittlnge.isSelected()) { XYSeries dataset = new XYSeries( "Schrittlnge [cm] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y8bWerte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Abstand.isSelected() && single == 1 && j != 0) { XYSeries dataset = new XYSeries( "Zeitabstand [s] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr + " - " + JTronicHandle.Statistikhandle.TourData[1].Tag + "." + JTronicHandle.Statistikhandle.TourData[1].Monat + "." + JTronicHandle.Statistikhandle.TourData[1].Jahr); for (i = 0; i < num2; i++) { dataset.add(xWerte2[i], y9Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); NumberAxis axis3 = new NumberAxis("Abstand"); axis3.setLabelFont(plot.getRangeAxis().getLabelFont()); axis3.setTickLabelFont(plot.getRangeAxis().getTickLabelFont()); axis3.setAutoRangeIncludesZero(true); axis3.setLabelPaint(Color.BLACK); axis3.setTickLabelPaint(Color.BLACK); plot.setRangeAxis(2, axis3); plot.setRangeAxisLocation(2, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 2); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } } else { //Zeitachse if (JTronicHandle.Graphik_check_Geschwindigkeit.isSelected()) { TimeSeries dataset = new TimeSeries( "Geschwindigkeit [km/h] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y1Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); ValueAxis axis = plot.getRangeAxis(); axis.setLabelPaint(Color.BLACK); axis.setTickLabelPaint(Color.BLACK); plot.setRangeAxis(0, axis); plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Hhe.isSelected()) { TimeSeries dataset = new TimeSeries( "Hoehe [m] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y2Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); NumberAxis axis2 = (NumberAxis) plot.getRangeAxis().clone(); axis2.setLabel("Hhe [m]"); axis2.setAutoRangeIncludesZero(true); axis2.setLabelPaint(Color.BLACK); axis2.setTickLabelPaint(Color.BLACK); axis2.setAxisLinePaint(Color.BLACK); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 1); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_HF.isSelected()) { TimeSeries dataset = new TimeSeries( "Herzfrequenz [b/min] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y3Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Temp.isSelected()) { TimeSeries dataset = new TimeSeries( "Temperatur [C] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y4Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Steigung_p.isSelected()) { TimeSeries dataset = new TimeSeries("Steigung [%] "); for (i = 0; i < num; i++) { dataset.add(xTime[i], y5Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Steigung_m.isSelected()) { TimeSeries dataset = new TimeSeries( "Steigung [m/min] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y6Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_av_Geschw.isSelected()) { TimeSeries dataset = new TimeSeries( "av Geschw. [km/h] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y7Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Cadence.isSelected()) { TimeSeries dataset = new TimeSeries( "Cadence [n/min] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y8Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Schrittlnge.isSelected()) { TimeSeries dataset = new TimeSeries( "Schrittlnge [cm] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y8bWerte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Abstand.isSelected() && single == 1 && j != 0) { TimeSeries dataset = new TimeSeries( "Streckenabstand [m] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr + " - " + JTronicHandle.Statistikhandle.TourData[1].Tag + "." + JTronicHandle.Statistikhandle.TourData[1].Monat + "." + JTronicHandle.Statistikhandle.TourData[1].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y10Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); ValueAxis axis3 = (ValueAxis) plot.getRangeAxis().clone(); axis3.setLabel("Abstand"); axis3.setLabelPaint(Color.BLACK); axis3.setTickLabelPaint(Color.BLACK); plot.setRangeAxis(2, axis3); plot.setRangeAxisLocation(2, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 2); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } } } chart.setNotify(true); ChartPanel Panel = new ChartPanel(chart); return Panel; } catch (Exception e) { JOptionPane.showMessageDialog(null, "StartGraphik\nSchluss_Fehler: " + e, "Achtung!", JOptionPane.ERROR_MESSAGE); } return new ChartPanel(chart); }
From source file:CGgui.java
private void SaveChrt() { try {//www. j a v a 2 s . c om //remove crosshairs XYPlot xyplot = (XYPlot) chart.getPlot(); xyplot.setDomainCrosshairVisible(false); //remove marker if (intervalmarker != null) { xyplot.removeDomainMarker(intervalmarker, Layer.BACKGROUND); intervalmarker = null; } //save chartpanel.doSaveAs(); } catch (IOException err) { if (DEBUG) PrintText("Error: " + err); } //garbage collect //System.gc(); }