List of usage examples for org.jfree.chart.plot XYPlot XYPlot
public XYPlot()
XYPlot
instance with no dataset, no axes and no renderer. From source file:no.met.jtimeseries.chart.ChartPlotter.java
/** * Adds the specified weather symbols to the chart. Symbols are excluded if * necessary to fit in the chart. Specify phenomenon to follow value curve. * Plot on top of chart if phenomenon is null. * //www .j av a 2 s .co m * @return */ public void addWeatherSymbol(SymbolPhenomenon symbols, NumberPhenomenon phenomenon) { boolean followPhenomenon = (phenomenon != null); NumberAxis na; if (!followPhenomenon) { na = new NumberAxis(""); na.setVisible(false); weatherSymbolPlot = new XYPlot(); weatherSymbolPlot.setDomainAxis(plot.getDomainAxis(0)); weatherSymbolPlot.setRangeAxis(na); weatherSymbolPlot.setRangeGridlinesVisible(false); weatherSymbolPlot.setOutlineVisible(false); weatherSymbolPlot.setDomainGridlinesVisible(false); } XYImageAnnotation imageannotation; int imageSize = getWeatherSymbolImageSize(); for (SymbolValueItem symbol : symbols) { Image image = Symbols.getSymbolImage(symbol.getValue()); image = image.getScaledInstance(imageSize, imageSize, Image.SCALE_SMOOTH); if (followPhenomenon) { // plot over the phenomenon curve Double val = phenomenon.getValueByTime(symbol.getTimeFrom()); if (val != null) { double padding = 0.08; // space between curve and symbol in // phenomenon units imageannotation = new XYImageAnnotation(symbol.getTimeFrom().getTime(), val.doubleValue() + padding * (plot.getRangeAxis().getUpperBound() - plot.getRangeAxis().getLowerBound()), image, RectangleAnchor.CENTER); plot.addAnnotation(imageannotation); } } else { // plot symbols on top in separate weatherSymbolPlot imageannotation = new XYImageAnnotation(symbol.getTimeFrom().getTime(), 0.5, image); weatherSymbolPlot.addAnnotation(imageannotation); } } }
From source file:de.dmarcini.submatix.pclogger.gui.spx42LogGraphPanel.java
/** * Zeichne die eigentliche Grafik Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui * /*from w ww . ja v a 2 s . c o m*/ * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 03.07.2012 * @param dbId * dbid in Tabelle D_TABLE_DIVEDETAIL * @param device */ private void makeGraphForLog(int dbId, String device) { Vector<Integer[]> diveList; Vector<String> diluents; int[] headData; XYPlot thePlot; JFreeChart logChart; int min, sec; // das alte Zeug entsorgen releaseGraph(); // // Daten eines TG lesen // lg.debug("read dive log from DB..."); diveList = databaseUtil.getDiveDataFromIdLog(dbId); if (diveList == null || diveList.isEmpty()) { return; } // // verwendete Diluents finden // diluents = getDiluentNamesFromDive(diveList); // Anzeigen String diluentString = StringUtils.join(diluents, ", "); diluentLabel.setText( String.format(LangStrings.getString("spx42LogGraphPanel.diluentLabel.text"), diluentString)); lg.debug(diluents); // // Labels fr Tachgangseckdaten fllen // headData = databaseUtil.getHeadDiveDataFromIdLog(dbId); notesLabel.setText(databaseUtil.getNotesForIdLog(dbId)); showingUnitSystem = SpxPcloggerProgramConfig.unitsProperty; savedUnitSystem = headData[6]; // jetzt die Strings fr Masseinheiten holen String[] labels = getUnitsLabel(showingUnitSystem, savedUnitSystem); depthUnitName = labels[0]; tempUnitName = labels[1]; pressureUnitName = labels[2]; // // entscheide ob etwas umgerechnet werden sollte // if (showingUnitSystem == savedUnitSystem || showingUnitSystem == ProjectConst.UNITS_DEFAULT) { // nein, alles schick maxDepthValueLabel.setText(String.format(maxDepthLabelString, (headData[3] / 10.0), depthUnitName)); coldestTempValueLabel.setText(String.format(coldestLabelString, (headData[2] / 10.0), tempUnitName)); } else { // umrechnen! if (showingUnitSystem == ProjectConst.UNITS_IMPERIAL) { // metrisch-> imperial konvertieren // 1 foot == 30,48 cm == 0.3048 Meter maxDepthValueLabel .setText(String.format(maxDepthLabelString, (headData[3] / 10.0) / 0.3048, depthUnitName)); // t F = 5?9 (t 32) C coldestTempValueLabel.setText( String.format(coldestLabelString, (5.0 / 9.0) * ((headData[2] / 10.0) - 32), tempUnitName)); } else { maxDepthValueLabel .setText(String.format(maxDepthLabelString, (headData[3] / 10.0) * 0.3048, depthUnitName)); // t C = (9?5 t + 32) F coldestTempValueLabel.setText( String.format(coldestLabelString, ((9.0 / 5.0) * (headData[2] / 10.0)) + 32, tempUnitName)); } } min = headData[5] / 60; sec = headData[5] % 60; diveLenValueLabel.setText(String.format(diveLenLabelString, min, sec, "min")); // // einen Plot machen (Grundlage des Diagramms) // lg.debug("create graph..."); thePlot = new XYPlot(); // // Eigenschaften definieren // thePlot.setBackgroundPaint(Color.lightGray); thePlot.setDomainGridlinesVisible(true); thePlot.setDomainGridlinePaint(Color.white); thePlot.setRangeGridlinesVisible(true); thePlot.setRangeGridlinePaint(Color.white); thePlot.setDomainPannable(true); thePlot.setRangePannable(false); // // ein Chart zur Anzeige in einem Panel erzeugen // logChart = new JFreeChart(LangStrings.getString("spx42LogGraphPanel.graph.chartTitle"), thePlot); logChart.setAntiAlias(true); logChart.addSubtitle(new TextTitle(LangStrings.getString("spx42LogGraphPanel.graph.chartSubTitle"))); // ein Thema zufgen, damit ich eigene Farben einbauen kann ChartUtilities.applyCurrentTheme(logChart); // // ein Diagramm-Panel erzeugen // chartPanel = new ChartPanel(logChart); chartPanel.setMouseZoomable(true); chartPanel.setAutoscrolls(true); chartPanel.setMouseWheelEnabled(true); chartPanel.setRangeZoomable(false); chartPanel.setDisplayToolTips(false); chartPanel.setZoomTriggerDistance(10); add(chartPanel, BorderLayout.CENTER); // // Datumsachse umformatieren // final NumberAxis axis = new NumberAxis(LangStrings.getString("spx42LogGraphPanel.graph.dateAxisTitle")); MinuteFormatter formatter = new MinuteFormatter( LangStrings.getString("spx42LogGraphPanel.graph.dateAxisUnit")); axis.setNumberFormatOverride(formatter); thePlot.setDomainAxis(axis); // // Temperatur einfgen // if (SpxPcloggerProgramConfig.showTemperature) { makeTemperatureGraph(diveList, thePlot, labels); } // // Partialdruck einfgen // die Achse erst mal machen final NumberAxis ppo2Axis = new NumberAxis( LangStrings.getString("spx42LogGraphPanel.graph.ppo2AxisTitle") + " " + pressureUnitName); final NumberAxis percentAxis = new NumberAxis(LangStrings.getString("spx42LogGraphPanel.graph.inertgas")); // // wenn eine der Achsen dargesstellt werden muss, dann sollte die Achse auch in der Grafil da sein // if (SpxPcloggerProgramConfig.showPpo01 || SpxPcloggerProgramConfig.showPpo02 || SpxPcloggerProgramConfig.showPpo03 || SpxPcloggerProgramConfig.showPpoResult || SpxPcloggerProgramConfig.showSetpoint) { ppo2Axis.setAutoRangeIncludesZero(false); ppo2Axis.setAutoRange(false); // // wie skaliere ich die Achse? // if (showingUnitSystem == ProjectConst.UNITS_DEFAULT) { // so wie gespeichert if (savedUnitSystem == ProjectConst.UNITS_METRIC) { ppo2Axis.setRange(0.0, 3.5); } else { ppo2Axis.setRange(0.0, (3.5 * 14.504)); } } else if (showingUnitSystem == ProjectConst.UNITS_METRIC) { ppo2Axis.setRange(0.0, 3.5); } else { ppo2Axis.setRange(0.0, (3.5 * 14.504)); } ppo2Axis.setLabelPaint(new Color(ProjectConst.GRAPH_PPO2ALL_ACOLOR)); ppo2Axis.setTickLabelPaint(new Color(ProjectConst.GRAPH_PPO2ALL_ACOLOR)); thePlot.setRangeAxis(GRAPH_PPO2ALL, ppo2Axis); } if (SpxPcloggerProgramConfig.showHe || SpxPcloggerProgramConfig.showN2) { percentAxis.setAutoRangeIncludesZero(false); percentAxis.setAutoRange(false); percentAxis.setRange(0.0, 100.0); percentAxis.setLabelPaint(new Color(ProjectConst.GRAPH_INNERTGAS_ACOLOR)); percentAxis.setTickLabelPaint(new Color(ProjectConst.GRAPH_INNERTGAS_ACOLOR)); thePlot.setRangeAxis(GRAPH_HE, percentAxis); } // // Partialdrcke der einzelnen Sensoren einfgen // // Sensor 01 anzeigen if (SpxPcloggerProgramConfig.showPpo01) { makePpoGraph(diveList, thePlot, 1); } // Sensor 02 anzeigen if (SpxPcloggerProgramConfig.showPpo02) { makePpoGraph(diveList, thePlot, 2); } // Sensor 03 anzeigen if (SpxPcloggerProgramConfig.showPpo03) { makePpoGraph(diveList, thePlot, 3); } // Resultierenden PPO anzeigen if (SpxPcloggerProgramConfig.showPpoResult) { makePpoGraph(diveList, thePlot, 0); // makePpoResultGraph( diveList, thePlot ); } if (SpxPcloggerProgramConfig.showSetpoint) { makeSetpointGraph(diveList, thePlot); } // // Helium und Stickstoffanteil im Gas? // if (SpxPcloggerProgramConfig.showHe) { makeInnertGasGraph(diveList, thePlot, "he"); } if (SpxPcloggerProgramConfig.showN2) { makeInnertGasGraph(diveList, thePlot, "n2"); } // // die Nullzeit auf Wunsch // if (SpxPcloggerProgramConfig.showNulltime) { makeNulltimeGraph(diveList, thePlot); } // // die Tiefe einfgen // makeDepthGraph(diveList, thePlot); // showingDbIdForDiveWasShowing = dbId; lg.debug("create graph...OK"); }