List of usage examples for org.jfree.chart ChartFactory createXYAreaChart
public static JFreeChart createXYAreaChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
From source file:ispd.gui.auxiliar.Graficos.java
public void criarProcessamentoTempoMaquina(RedeDeFilas rdf) { XYSeriesCollection dadosGrafico = new XYSeriesCollection(); //Se tiver alguma mquina na lista. if (rdf.getMaquinas() != null) { //Lao foreach que percorre as mquinas. for (CS_Processamento maq : rdf.getMaquinas()) { //Lista que recebe os pares de intervalo de tempo em que a mquina executou. List<ParesOrdenadosUso> lista = maq.getListaProcessamento(); poderComputacionalTotal += (maq.getPoderComputacional() - (maq.getOcupacao() * maq.getPoderComputacional())); //Se a mquina tiver intervalos. if (!lista.isEmpty()) { //Cria o objeto do tipo XYSeries. XYSeries tmp_series;/*from w w w . j av a 2 s. co m*/ //Se o atributo numeroMaquina for 0, ou seja, no for um n de um cluster. if (maq.getnumeroMaquina() == 0) //Estancia com o nome puro. { tmp_series = new XYSeries(maq.getId()); } //Se for 1 ou mais, ou seja, um n de cluster. else //Estancia tmp_series com o nome concatenado com a palavra node e seu numero. { tmp_series = new XYSeries(maq.getId() + " node " + maq.getnumeroMaquina()); } int i; //Lao que vai adicionando os pontos para a criao do grfico. for (i = 0; i < lista.size(); i++) { //Calcula o uso, que 100% - taxa de ocupao inicial. Double uso = 100 - (maq.getOcupacao() * 100); //Adiciona ponto inicial. tmp_series.add(lista.get(i).getInicio(), uso); //Adiciona ponto final. tmp_series.add(lista.get(i).getFim(), uso); if (i + 1 != lista.size()) { uso = 0.0000; tmp_series.add(lista.get(i).getFim(), uso); tmp_series.add(lista.get(i + 1).getInicio(), uso); } } //Add no grfico. dadosGrafico.addSeries(tmp_series); } } } JFreeChart jfc = ChartFactory.createXYAreaChart("Use of computing power through time " + "\nMachines", //Titulo "Time (seconds)", // Eixo X "Rate of use of resources (%)", //Eixo Y dadosGrafico, // Dados para o grafico PlotOrientation.VERTICAL, //Orientacao do grafico true, true, false); // exibir: legendas, tooltips, url MachineThroughTimeChart = new ChartPanel(jfc); MachineThroughTimeChart.setPreferredSize(new Dimension(600, 300)); }
From source file:org.pentaho.reporting.engine.classic.extensions.legacy.charts.LegacyChartType.java
private JFreeChart createChart(final Expression aExpression) { if (aExpression instanceof BarLineChartExpression) { final CategoryAxis catAxis = new CategoryAxis("Category");// NON-NLS final NumberAxis barsAxis = new NumberAxis("Value");// NON-NLS final NumberAxis linesAxis = new NumberAxis("Value2");// NON-NLS final CategoryPlot plot = new CategoryPlot(createDataset(), catAxis, barsAxis, new BarRenderer()); plot.setRenderer(1, new LineAndShapeRenderer()); // add lines dataset and axis to plot plot.setDataset(1, createDataset()); plot.setRangeAxis(1, linesAxis); // map lines to second axis plot.mapDatasetToRangeAxis(1, 1); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // set location of second axis plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); return new JFreeChart("Bar Line Chart", plot); }/*w ww . j ava 2 s . c o m*/ if (aExpression instanceof RingChartExpression) { return ChartFactory.createRingChart("Ring Chart", createPieDataset(), true, false, false);// NON-NLS } if (aExpression instanceof AreaChartExpression) { return ChartFactory.createAreaChart("Area Chart", "Category", "Value", createDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof BarChartExpression) { return ChartFactory.createBarChart("Bar Chart", "Category", "Value", createDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof LineChartExpression) { return ChartFactory.createLineChart("Line Chart", "Category", "Value", createDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof MultiPieChartExpression) { return ChartFactory.createMultiplePieChart("Multi Pie Chart", createDataset(), TableOrder.BY_COLUMN, true, false, false);// NON-NLS } if (aExpression instanceof PieChartExpression) { return ChartFactory.createPieChart("Pie Chart", createPieDataset(), true, false, false);// NON-NLS } if (aExpression instanceof WaterfallChartExpressions) { return ChartFactory.createWaterfallChart("Bar Chart", "Category", "Value", createDataset(), PlotOrientation.HORIZONTAL, true, false, false);// NON-NLS } if (aExpression instanceof BubbleChartExpression) { return ChartFactory.createBubbleChart("Bubble Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof ExtendedXYLineChartExpression) { return ChartFactory.createXYLineChart("XY Line Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof ScatterPlotChartExpression) { return ChartFactory.createScatterPlot("Scatter Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof XYAreaLineChartExpression) { final NumberAxis catAxis = new NumberAxis("Range");// NON-NLS final NumberAxis barsAxis = new NumberAxis("Value");// NON-NLS final NumberAxis linesAxis = new NumberAxis("Value2");// NON-NLS final XYPlot plot = new XYPlot(createXYZDataset(), catAxis, barsAxis, new XYAreaRenderer()); plot.setRenderer(1, new XYLineAndShapeRenderer()); // add lines dataset and axis to plot plot.setDataset(1, createXYZDataset()); plot.setRangeAxis(1, linesAxis); // map lines to second axis plot.mapDatasetToRangeAxis(1, 1); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // set location of second axis plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); return new JFreeChart("XY Area Line Chart", plot);// NON-NLS } if (aExpression instanceof XYAreaChartExpression) { return ChartFactory.createXYAreaChart("XY Area Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof XYBarChartExpression) { return XYBarChartExpression.createXYBarChart("XY Bar Chart", "X", false, "Y", createIntervalXYDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof XYLineChartExpression) { return ChartFactory.createXYLineChart("XY Line Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof RadarChartExpression) { final SpiderWebPlot plot = new SpiderWebPlot(createDataset()); return new JFreeChart("Radar Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true); } if (aExpression instanceof ThermometerChartExpression) { final DefaultValueDataset dataset = new DefaultValueDataset(new Double(65.0)); final ThermometerPlot plot = new ThermometerPlot(dataset); return new JFreeChart("Thermometer Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true); } return null; }
From source file:be.vds.jtbdive.client.view.core.dive.profile.DiveProfileGraphicDetailPanel.java
private Component createGraphicPanel() { depthSerie = new XYSeries(DiveProfileChartFactory.SERIE_DEPTH); XYSeriesCollection depthCollection = new XYSeriesCollection(); depthCollection.addSeries(depthSerie); chart = ChartFactory.createXYAreaChart(null, getDomainLegend(), getRangeLegend(), depthCollection, PlotOrientation.VERTICAL, false, true, false); xyp = chart.getXYPlot();//from www. jav a2s . c o m Paint p = new GradientPaint(0f, 0f, UIAgent.getInstance().getColorWaterBottom(), 200f, 200f, UIAgent.getInstance().getColorWaterSurface(), false); xyp.setBackgroundPaint(p); xyp.setDomainGridlinePaint(UIAgent.getInstance().getColorWaterGrid()); xyp.setRangeGridlinePaint(UIAgent.getInstance().getColorWaterGrid()); xyp.setDomainCrosshairVisible(true); xyp.setRangeCrosshairVisible(true); xyp.setRangeCrosshairPaint(UIAgent.getInstance().getColorWaterCrossHair()); xyp.setDomainCrosshairPaint(UIAgent.getInstance().getColorWaterCrossHair()); xyp.setRangeCrosshairLockedOnData(true); xyp.setDomainCrosshairLockedOnData(true); ((NumberAxis) xyp.getDomainAxis()).setNumberFormatOverride(new MinutesNumberFormat()); XYAreaRenderer renderer0 = new XYAreaRenderer(); renderer0.setOutline(true); renderer0.setBaseOutlinePaint(UIAgent.getInstance().getColorWaterBottom()); Color baseColor = UIAgent.getInstance().getColorBaseBackground(); renderer0.setSeriesPaint(0, new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), 50)); xyp.setRenderer(0, renderer0); createDecoWarningCollection(); createAscentTooFastCollection(); createRemainBottomTimeCollection(); createDecoEntriesCollection(); createGazMixCollection(); chartPanel = new ChartPanel(chart); chart.setBackgroundPaint(null); chartPanel.setOpaque(false); chartPanel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseMoved(ChartMouseEvent arg0) { } @Override public void chartMouseClicked(ChartMouseEvent evt) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { double x = xyp.getDomainCrosshairValue(); double y = xyp.getRangeCrosshairValue(); Calendar cal = new GregorianCalendar(0, 0, 0, 0, 0, (int) x); instantTimeTf.setText(new SimpleDateFormat("HH:mm:ss").format(cal.getTime())); instantDepthTf.setText(StringManipulator.formatFixedDecimalNumber(y, UIAgent.PRECISION_DEPTH, UIAgent.NUMBER_DECIMAL_CHAR)); } }); } }); return chartPanel; }
From source file:ispd.gui.auxiliar.Graficos.java
public void criarProcessamentoTempoUser(List<Tarefa> tarefas, RedeDeFilas rdf) { ArrayList<tempo_uso_usuario> lista = new ArrayList<tempo_uso_usuario>(); int numberUsers = rdf.getUsuarios().size(); Map<String, Integer> users = new HashMap<String, Integer>(); XYSeries tmp_series[] = new XYSeries[numberUsers]; XYSeries tmp_series1[] = new XYSeries[numberUsers]; Double utilizacaoUser[] = new Double[numberUsers]; Double utilizacaoUser1[] = new Double[numberUsers]; XYSeriesCollection dadosGrafico = new XYSeriesCollection(); XYSeriesCollection dadosGrafico1 = new XYSeriesCollection(); for (int i = 0; i < numberUsers; i++) { users.put(rdf.getUsuarios().get(i), i); utilizacaoUser[i] = 0.0;/*from w ww .jav a 2 s. c o m*/ tmp_series[i] = new XYSeries(rdf.getUsuarios().get(i)); utilizacaoUser1[i] = 0.0; tmp_series1[i] = new XYSeries(rdf.getUsuarios().get(i)); } if (!tarefas.isEmpty()) { //Insere cada tarefa como dois pontos na lista for (Tarefa task : tarefas) { CS_Processamento local = (CS_Processamento) task.getLocalProcessamento(); if (local != null) { for (int i = 0; i < task.getTempoInicial().size(); i++) { Double uso = (task.getHistoricoProcessamento().get(i).getPoderComputacional() / poderComputacionalTotal) * 100; tempo_uso_usuario provisorio1 = new tempo_uso_usuario(task.getTempoInicial().get(i), true, uso, users.get(task.getProprietario())); lista.add(provisorio1); tempo_uso_usuario provisorio2 = new tempo_uso_usuario(task.getTempoFinal().get(i), false, uso, users.get(task.getProprietario())); lista.add(provisorio2); } } } //Ordena lista Collections.sort(lista); } for (int i = 0; i < lista.size(); i++) { tempo_uso_usuario temp = (tempo_uso_usuario) lista.get(i); int usuario = temp.get_user(); //Altera os valores do usuario atual e todos acima dele for (int j = usuario; j < numberUsers; j++) { //Salva valores anteriores tmp_series[j].add(temp.get_tempo(), utilizacaoUser[j]); if (temp.get_tipo()) { utilizacaoUser[j] += temp.get_uso_no(); } else { utilizacaoUser[j] -= temp.get_uso_no(); } //Novo valor tmp_series[j].add(temp.get_tempo(), utilizacaoUser[j]); } //Grafico1 tmp_series1[usuario].add(temp.get_tempo(), utilizacaoUser1[usuario]); if (temp.get_tipo()) { utilizacaoUser1[usuario] += temp.get_uso_no(); } else { utilizacaoUser1[usuario] -= temp.get_uso_no(); } tmp_series1[usuario].add(temp.get_tempo(), utilizacaoUser1[usuario]); } for (int i = 0; i < numberUsers; i++) { dadosGrafico.addSeries(tmp_series[i]); dadosGrafico1.addSeries(tmp_series1[i]); } JFreeChart user1 = ChartFactory.createXYAreaChart("Use of total computing power through time" + "\nUsers", //Titulo "Time (seconds)", // Eixo X "Rate of total use of resources (%)", //Eixo Y dadosGrafico1, // Dados para o grafico PlotOrientation.VERTICAL, //Orientacao do grafico true, true, false); // exibir: legendas, tooltips, url JFreeChart user2 = ChartFactory.createXYLineChart("Use of total resources through time" + "\nUsers", //Titulo "Time (seconds)", // Eixo X "Rate of total use of resources (%)", //Eixo Y dadosGrafico, // Dados para o grafico PlotOrientation.VERTICAL, //Orientacao do grafico true, true, false); // exibir: legendas, tooltips, url XYPlot xyplot = (XYPlot) user2.getPlot(); xyplot.setDomainPannable(true); XYStepAreaRenderer xysteparearenderer = new XYStepAreaRenderer(2); xysteparearenderer.setDataBoundsIncludesVisibleSeriesOnly(false); xysteparearenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); xysteparearenderer.setDefaultEntityRadius(6); xyplot.setRenderer(xysteparearenderer); UserThroughTimeChart1 = new ChartPanel(user1); UserThroughTimeChart1.setPreferredSize(new Dimension(600, 300)); UserThroughTimeChart2 = new ChartPanel(user2); UserThroughTimeChart2.setPreferredSize(new Dimension(600, 300)); }
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 ww w. j ava 2 s . c o m 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.jivesoftware.openfire.reporting.graph.GraphEngine.java
/** * Generates a SparkLine Time Area Chart. * @param key//w ww. j av a2s . c o m * @param stats * @param startTime * @param endTime * @return chart */ private JFreeChart generateSparklineAreaChart(String key, String color, Statistic[] stats, long startTime, long endTime, int dataPoints) { Color backgroundColor = getBackgroundColor(); XYDataset dataset = populateData(key, stats, startTime, endTime, dataPoints); JFreeChart chart = ChartFactory.createXYAreaChart(null, // chart title null, // xaxis label null, // yaxis label dataset, // data PlotOrientation.VERTICAL, false, // include legend false, // tooltips? false // URLs? ); chart.setBackgroundPaint(backgroundColor); chart.setBorderVisible(false); chart.setBorderPaint(null); XYPlot plot = (XYPlot) chart.getPlot(); plot.setForegroundAlpha(1.0f); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.setBackgroundPaint(backgroundColor); plot.setRangeGridlinesVisible(false); GraphDefinition graphDef = GraphDefinition.getDefinition(color); Color plotColor = graphDef.getInlineColor(0); plot.getRenderer().setSeriesPaint(0, plotColor); plot.getRenderer().setBaseItemLabelsVisible(false); plot.getRenderer().setBaseOutlinePaint(backgroundColor); plot.setOutlineStroke(null); plot.setDomainGridlinePaint(null); NumberAxis xAxis = (NumberAxis) chart.getXYPlot().getDomainAxis(); xAxis.setLabel(null); xAxis.setTickLabelsVisible(true); xAxis.setTickMarksVisible(true); xAxis.setAxisLineVisible(false); xAxis.setNegativeArrowVisible(false); xAxis.setPositiveArrowVisible(false); xAxis.setVisible(false); NumberAxis yAxis = (NumberAxis) chart.getXYPlot().getRangeAxis(); yAxis.setTickLabelsVisible(false); yAxis.setTickMarksVisible(false); yAxis.setAxisLineVisible(false); yAxis.setNegativeArrowVisible(false); yAxis.setPositiveArrowVisible(false); yAxis.setVisible(false); return chart; }
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static JFreeChart createXYAreaChart(String xAxisLabel, String yAxisLabel, XYDataset dataset, boolean includeLegend) { JFreeChart jfreechart = ChartFactory.createXYAreaChart(null, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, false, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainPannable(true);//w w w. j a va 2s . co m xyplot.setBackgroundPaint(null); xyplot.setOutlinePaint(null); xyplot.setForegroundAlpha(0.8F); xyplot.setRangeGridlinePaint(UIConstants.INTEL_DARK_GRAY); DateAxis dateaxis = new DateAxis(xAxisLabel); dateaxis.setLowerMargin(0.0D); dateaxis.setUpperMargin(0.0D); xyplot.setDomainAxis(dateaxis); NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); rangeAxis.setRangeType(RangeType.POSITIVE); rangeAxis.setLabelFont(UIConstants.H5_FONT); rangeAxis.setLabelInsets(new RectangleInsets(0, 0, 0, 0)); if (includeLegend) { LegendTitle legendtitle = new LegendTitle(xyplot); legendtitle.setItemFont(UIConstants.H5_FONT); legendtitle.setBackgroundPaint(UIConstants.INTEL_WHITE); legendtitle.setFrame(new BlockBorder(UIConstants.INTEL_BLUE)); legendtitle.setPosition(RectangleEdge.BOTTOM); XYTitleAnnotation xytitleannotation = new XYTitleAnnotation(0.97999999999999998D, 0.99999999999999998D, legendtitle, RectangleAnchor.TOP_RIGHT); // xytitleannotation.setMaxWidth(0.47999999999999998D); xyplot.addAnnotation(xytitleannotation); } XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setSeriesPaint(1, UIConstants.INTEL_DARK_GRAY); xyitemrenderer.setSeriesPaint(0, NodeTypeViz.SWITCH.getColor()); xyitemrenderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator("<html><b>{0}</b><br> Time: {1}<br> Data: {2}</html>", Util.getHHMMSS(), new DecimalFormat("#,##0.00"))); return jfreechart; }
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static JFreeChart createXYAreaSparkline(XYDataset dataset) { JFreeChart jfreechart = ChartFactory.createXYAreaChart(null, null, null, dataset, PlotOrientation.VERTICAL, false, false, false);/*from www . jav a 2 s .co m*/ XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainPannable(true); xyplot.setBackgroundPaint(null); xyplot.setOutlinePaint(null); xyplot.setForegroundAlpha(0.8F); xyplot.setDomainGridlinesVisible(false); xyplot.setDomainCrosshairVisible(false); xyplot.setRangeGridlinesVisible(false); xyplot.setRangeCrosshairVisible(false); DateAxis dateaxis = new DateAxis(""); dateaxis.setTickLabelsVisible(false); dateaxis.setTickMarksVisible(false); dateaxis.setAxisLineVisible(false); dateaxis.setNegativeArrowVisible(false); dateaxis.setPositiveArrowVisible(false); dateaxis.setVisible(false); xyplot.setDomainAxis(dateaxis); ValueAxis rangeAxis = xyplot.getRangeAxis(); rangeAxis.setTickLabelsVisible(false); rangeAxis.setTickMarksVisible(false); rangeAxis.setAxisLineVisible(false); rangeAxis.setNegativeArrowVisible(false); rangeAxis.setPositiveArrowVisible(false); rangeAxis.setVisible(false); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setSeriesPaint(1, UIConstants.INTEL_DARK_GRAY); xyitemrenderer.setSeriesPaint(0, NodeTypeViz.SWITCH.getColor()); return jfreechart; }
From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java
protected JFreeChart createXyAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createXYAreaChart( (String) evaluateExpression(getChart().getTitleExpression()), (String) evaluateExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()), (String) evaluateExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()), (XYDataset) getDataset(), getPlot().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot) getPlot(); // Handle the axis formating for the category axis configureAxis(jfreeChart.getXYPlot().getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), false, (Comparable) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(jfreeChart.getXYPlot().getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), true, (Comparable) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java
protected JFreeChart createXyAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createXYAreaChart( (String) evaluateExpression(getChart().getTitleExpression()), (String) evaluateExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()), (String) evaluateExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()), (XYDataset) getDataset(), getPlot().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot) getPlot(); // Handle the axis formating for the category axis configureAxis(jfreeChart.getXYPlot().getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(),//from w ww . jav a 2 s . co m (Comparable) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(jfreeChart.getXYPlot().getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }