List of usage examples for java.awt Color green
Color green
To view the source code for java.awt Color green.
Click Source Link
From source file:TextComponentDemo.java
protected JMenu createStyleMenu() { JMenu menu = new JMenu("Style"); Action action = new StyledEditorKit.BoldAction(); action.putValue(Action.NAME, "Bold"); menu.add(action);/*from w w w . ja v a 2 s .c o m*/ action = new StyledEditorKit.ItalicAction(); action.putValue(Action.NAME, "Italic"); menu.add(action); action = new StyledEditorKit.UnderlineAction(); action.putValue(Action.NAME, "Underline"); menu.add(action); menu.addSeparator(); menu.add(new StyledEditorKit.FontSizeAction("12", 12)); menu.add(new StyledEditorKit.FontSizeAction("14", 14)); menu.add(new StyledEditorKit.FontSizeAction("18", 18)); menu.addSeparator(); menu.add(new StyledEditorKit.FontFamilyAction("Serif", "Serif")); menu.add(new StyledEditorKit.FontFamilyAction("SansSerif", "SansSerif")); menu.addSeparator(); menu.add(new StyledEditorKit.ForegroundAction("Red", Color.red)); menu.add(new StyledEditorKit.ForegroundAction("Green", Color.green)); menu.add(new StyledEditorKit.ForegroundAction("Blue", Color.blue)); menu.add(new StyledEditorKit.ForegroundAction("Black", Color.black)); return menu; }
From source file:bicat.gui.GraphicPane.java
/** * Default constructor, initializes some values. *//*from w w w . j a va 2 s . c o m*/ public GraphicPane() { geneList = null; graphDataList = null; filledRect = new Rectangle(0, 0); xStep = 10; yStep = 160; // sta ovo tacno znaci??? (size of the cells of the // visualized matrix?) colorWheel = new Color[8]; // samo 8? colorWheel[0] = Color.BLUE; colorWheel[1] = Color.CYAN; colorWheel[2] = Color.GREEN; colorWheel[3] = Color.MAGENTA; colorWheel[4] = Color.ORANGE; colorWheel[5] = Color.PINK; colorWheel[6] = Color.RED; colorWheel[7] = Color.YELLOW; // /* * DefaultPieDataset dpd = new DefaultPieDataset(); * dpd.setValue("Category 1",50); dpd.setValue("Category 2",50); */ // create a dataset... /* * DefaultPieDataset data = new DefaultPieDataset(); * data.setValue("Java", new Double(43.2)); data.setValue("Visual * Basic", new Double(0.0)); data.setValue("C/C++", new Double(17.5)); * * JFreeChart chart = ChartFactory.createPieChart("Sample",data, * true,true,false); ChartFrame frame = new ChartFrame("See", chart); * frame.pack(); // this.add(frame); //frame.pack(); * frame.setVisible(true); */ /* * chart = ChartFactory.createXYLineChart("Expression Profiles of a * Bicluster","genes","conditions", new * org.jfree.data.xy.DefaultTableXYDataset(), * org.jfree.chart.plot.PlotOrientation.HORIZONTAL, false,false,false); * * //ChartPanel cp = new ChartPanel(chart_1); chartPanel = new * ChartPanel(chart); this.add(chartPanel); //cp); * //,BorderLayout.WEST); this.setVisible(true); * //this.add("Proba",chart_1); //ChartFrame frame_1 = new * ChartFrame("XY",chart_1); //frame_1.pack(); * //frame_1.setVisible(true); */ }
From source file:api.window.Histogram.java
private JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYAreaChart(null, null, null, xydataset, PlotOrientation.VERTICAL, false, true, false); jfreechart.setBackgroundPaint(Color.white); xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setForegroundAlpha(0.65F);//from w w w . ja v a 2s. co m xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); ValueAxis valueaxis = xyplot.getDomainAxis(); valueaxis.setTickMarkPaint(Color.black); valueaxis.setLowerMargin(0.0D); valueaxis.setUpperMargin(0.0D); renderer = xyplot.getRenderer(); if (xydataset.getSeriesCount() == 4) { renderer.setSeriesPaint(0, Color.red); renderer.setSeriesPaint(1, Color.green); renderer.setSeriesPaint(2, Color.blue); renderer.setSeriesVisible(0, true); renderer.setSeriesVisible(1, true); renderer.setSeriesVisible(2, true); renderer.setSeriesPaint(3, Color.BLACK); renderer.setSeriesVisible(3, true); } else { this.remove(this.jPanel1); renderer.setSeriesPaint(0, Color.BLACK); renderer.setSeriesVisible(0, true); } ValueAxis valueaxis1 = xyplot.getRangeAxis(); valueaxis1.setTickMarkPaint(Color.black); return jfreechart; }
From source file:edu.cmu.sv.modelinference.eventtool.EventVisualizer.java
private void setViolationMarkers(Collection<Range<Integer>> violations, XYPlot plot) { for (Range<Integer> violation : violations) { ValueMarker startViolationMarker = new ValueMarker(violation.lowerEndpoint()); // position is the value on the axis startViolationMarker.setPaint(Color.BLACK); startViolationMarker.setStroke(new BasicStroke(1.0f)); plot.addDomainMarker(startViolationMarker); ValueMarker endViolationMarker = new ValueMarker(violation.upperEndpoint()); // position is the value on the axis endViolationMarker.setPaint(Color.GREEN); endViolationMarker.setStroke(new BasicStroke(0.5f)); plot.addDomainMarker(endViolationMarker); }//from w w w. j a v a2 s . c o m }
From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo.java
private static JFreeChart createLineChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createLineChart("Line Chart Demo 1", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );/*from w ww . jav a 2 s . c o m*/ chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setUseOutlinePaint(true); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); return chart; }
From source file:com.uniteddev.Unity.Login.java
public static void networkStatus(String state) { class networkService implements Runnable { public void run() { while (true) { Socket s = null;//from ww w . ja v a2 s . co m boolean connected = false; try { s = new Socket(Unity.ip, Integer.parseInt(Unity.port)); connected = true; } catch (Exception e) { } finally { if (s != null) { try { s.close(); } catch (IOException e1) { } } } if (connected) { System.out.println("Connection to server established."); server_stat_lbl.setText("Online"); server_stat_lbl.setForeground(Color.GREEN); } else { System.out.println("Unable to establish connection."); server_stat_lbl.setText("Offline"); server_stat_lbl.setForeground(Color.RED); } try { Thread.sleep(5000); } catch (Exception e) { } ; } } } if (state == "start") { networkProbe = new Thread(new networkService()); networkProbe.start(); } else if (state == "stop") { // kill thread only if it is sleeping, otherwise // we may have open socket connections try { while (networkProbe.getState() != Thread.State.TIMED_WAITING) { networkProbe.join(1000); } networkProbe.interrupt(); } catch (InterruptedException e) { } } }
From source file:cs.gui.stats.PerformanceStats.java
private ChartPanel createChart(String axisLabel, int type) { int width = (screenSize.width - (screenSize.width / 35)); int height = (int) (screenSize.height - (screenSize.height / (double) 4)); //int width = (screenSize.width - (screenSize.width / 35)) / 2; //int height = (int) (screenSize.height - (screenSize.height / (double) 4)) / 2; lastValue = new double[SUBPLOT_COUNT]; //================= visualise standard chart ========================== CombinedDomainXYPlot combineddomainxyplot = new CombinedDomainXYPlot(new DateAxis("Time")); lastValue[0] = 100D;/*ww w .j av a 2 s .c o m*/ TimeSeries timeseries = null; XYPlot xyplot = null; //add new timeseries to modularity row datasets[type] = new TimeSeriesCollection(); NumberAxis numberaxis = new NumberAxis(axisLabel); numberaxis.setAutoRangeIncludesZero(true); //fast StandardXYItemRenderer xyItemRender = new StandardXYItemRenderer(); //original //xyItemRender = new StandardXYItemRenderer(); xyItemRender.setSeriesStroke(0, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); xyItemRender.setSeriesStroke(1, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); xyItemRender.setSeriesStroke(2, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); xyItemRender.setSeriesStroke(3, new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, null, 0)); //TODO colours need to be defined statically before the renderer is created! xyplot = new XYPlot(datasets[type], null, numberaxis, xyItemRender); switch (type) { case 0: { xyItemRender.setSeriesPaint(0, Color.BLACK); timeseries = new TimeSeries("Number of existing threads", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); timeseries = new TimeSeries("Number of answered threads", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); } break; case 1: { xyItemRender.setSeriesPaint(0, Color.YELLOW); timeseries = new TimeSeries("Mean thread answer time (per day)", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); } break; case 2: { xyItemRender.setSeriesPaint(0, Color.GRAY); timeseries = new TimeSeries("Number of thread replies", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); } break; case 3: { xyItemRender.setSeriesPaint(0, Color.GREEN); timeseries = new TimeSeries("New thread arrival activity change (%)", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); xyItemRender.setSeriesPaint(1, Color.BLUE); timeseries = new TimeSeries("Thread reply activity change (%)", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); } break; case 4: { xyItemRender.setSeriesPaint(0, Color.GREEN); timeseries = new TimeSeries("Mean thread aswer time (per month)", org.jfree.data.time.Hour.class); datasets[type].addSeries(timeseries); } break; } NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.add(xyplot); ChartPanel chart = null; switch (type) { case 0: { jfreechart1 = new JFreeChart("", combineddomainxyplot); LegendTitle legendtitle = (LegendTitle) jfreechart1.getSubtitle(0); //set legend fonts jfreechart1.getLegend(0).setItemFont(new Font("Italic", Font.PLAIN, 11)); legendtitle.setPosition(RectangleEdge.BOTTOM); legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D)); jfreechart1.setBorderPaint(Color.black); jfreechart1.setBorderVisible(true); jfreechart1.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); valueAxis1 = combineddomainxyplot.getDomainAxis(); dateAxis1 = (DateAxis) valueAxis1; if (scope1 == 0) { valueAxis1.setAutoRange(true); } else { valueAxis1.setFixedAutoRange(scope1); } chart = new ChartPanel(jfreechart1); chart.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chart.add(buildPlotDisplayManagementPanel(valueAxis1, dateAxis1, ddlScope1)); combineddomainxyplot.setInsets(new RectangleInsets(40, 25, 0, 10)); chart.setPreferredSize(new Dimension(width, height)); jfreechart1.setAntiAlias(false); } break; case 1: { jfreechart2 = new JFreeChart("", combineddomainxyplot); LegendTitle legendtitle = (LegendTitle) jfreechart2.getSubtitle(0); //set legend fonts jfreechart2.getLegend(0).setItemFont(new Font("Italic", Font.PLAIN, 11)); legendtitle.setPosition(RectangleEdge.BOTTOM); legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D)); jfreechart2.setBorderPaint(Color.black); jfreechart2.setBorderVisible(true); jfreechart2.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); valueAxis2 = combineddomainxyplot.getDomainAxis(); dateAxis2 = (DateAxis) valueAxis2; if (scope2 == 0) { valueAxis2.setAutoRange(true); } else { valueAxis2.setFixedAutoRange(scope2); } chart = new ChartPanel(jfreechart2); chart.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chart.add(buildPlotDisplayManagementPanel(valueAxis2, dateAxis2, ddlScope2)); combineddomainxyplot.setInsets(new RectangleInsets(40, 25, 0, 10)); chart.setPreferredSize(new Dimension(width, height)); jfreechart2.setAntiAlias(false); } break; case 2: { jfreechart3 = new JFreeChart("", combineddomainxyplot); LegendTitle legendtitle = (LegendTitle) jfreechart3.getSubtitle(0); //set legend fonts jfreechart3.getLegend(0).setItemFont(new Font("Italic", Font.PLAIN, 11)); legendtitle.setPosition(RectangleEdge.BOTTOM); legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D)); jfreechart3.setBorderPaint(Color.black); jfreechart3.setBorderVisible(true); jfreechart3.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); valueAxis3 = combineddomainxyplot.getDomainAxis(); dateAxis3 = (DateAxis) valueAxis3; if (scope3 == 0) { valueAxis3.setAutoRange(true); } else { valueAxis3.setFixedAutoRange(scope3); } chart = new ChartPanel(jfreechart3); chart.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chart.add(buildPlotDisplayManagementPanel(valueAxis3, dateAxis3, ddlScope3)); combineddomainxyplot.setInsets(new RectangleInsets(40, 25, 0, 10)); chart.setPreferredSize(new Dimension(width, height)); jfreechart3.setAntiAlias(false); } break; case 3: { jfreechart4 = new JFreeChart("", combineddomainxyplot); LegendTitle legendtitle = (LegendTitle) jfreechart4.getSubtitle(0); //set legend fonts jfreechart4.getLegend(0).setItemFont(new Font("Italic", Font.PLAIN, 11)); legendtitle.setPosition(RectangleEdge.BOTTOM); legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D)); jfreechart4.setBorderPaint(Color.black); jfreechart4.setBorderVisible(true); jfreechart4.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); valueAxis4 = combineddomainxyplot.getDomainAxis(); dateAxis4 = (DateAxis) valueAxis4; if (scope4 == 0) { valueAxis4.setAutoRange(true); } else { valueAxis4.setFixedAutoRange(scope4); } chart = new ChartPanel(jfreechart4); chart.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chart.add(buildPlotDisplayManagementPanel(valueAxis4, dateAxis4, ddlScope4)); combineddomainxyplot.setInsets(new RectangleInsets(40, 25, 0, 10)); chart.setPreferredSize(new Dimension(width, height)); jfreechart4.setAntiAlias(false); } break; case 4: { jfreechart5 = new JFreeChart("", combineddomainxyplot); LegendTitle legendtitle = (LegendTitle) jfreechart5.getSubtitle(0); //set legend fonts jfreechart5.getLegend(0).setItemFont(new Font("Italic", Font.PLAIN, 11)); legendtitle.setPosition(RectangleEdge.BOTTOM); legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D)); jfreechart5.setBorderPaint(Color.black); jfreechart5.setBorderVisible(true); jfreechart5.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); valueAxis5 = combineddomainxyplot.getDomainAxis(); dateAxis5 = (DateAxis) valueAxis5; if (scope5 == 0) { valueAxis5.setAutoRange(true); } else { valueAxis5.setFixedAutoRange(scope5); } chart = new ChartPanel(jfreechart5); chart.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chart.add(buildPlotDisplayManagementPanel(valueAxis5, dateAxis5, ddlScope5)); combineddomainxyplot.setInsets(new RectangleInsets(40, 25, 0, 10)); chart.setPreferredSize(new Dimension(width, height)); jfreechart5.setAntiAlias(false); } break; } return chart; }
From source file:analisis_proyecto1.Ventana_principal.java
private void jButton4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton4MouseClicked //Generando el arreglo visual de numeros this.HeapSort.setVisible(false); heap.setTitle("Laurenn Alecxandra Cruz| 11211190"); heap.setSize(900, 500);//from w ww . j a va2s. c om heap.setVisible(true); JLabel titulo = new JLabel("Arreglo Inicial: "); titulo.setFont(new Font("Consolas", Font.BOLD, 14)); Panelarreglo.add(titulo); this.panelgenera.setForeground(Color.cyan); JButton[] arreglo = new JButton[this.heap_sort_numbers.size()]; for (int i = 0; i < this.heap_sort_numbers.size(); i++) { arreglo[i] = new JButton(); arreglo[i].setText(Integer.toString(this.heap_sort_numbers.get(i))); arreglo[i].setBackground(Color.GREEN); Panelarreglo.add(arreglo[i]); } int[] array = new int[this.heap_sort_numbers.size()]; //convierte ArreyList a arreglo for (int i = 0; i < this.heap_sort_numbers.size(); i++) { array[i] = this.heap_sort_numbers.get(i); } //LLamado a la funcion Heapsort Heapsort ordenamiento = new Heapsort(array); ordenamiento.ordenar(); this.arboles = ordenamiento.getArbolesDelegate(); //Visualizacion del arbol //---------------------Antes---------------------- JButton preview = new JButton("Antes"); preview.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int x = IncrementarIndice(1); if (x >= 0) { if (vs != null) { PanelArbol.remove(vs); } //-----------Dibujar arbol--------- vs = new BasicVisualizationServer<String, String>( new TreeLayout<String, String>(arboles.get(x)), new Dimension(300, 300)); Transformer<String, Paint> vertexPaint = new Transformer<String, Paint>() { public Paint transform(String i) { return Color.GREEN; } }; RenderContext<String, String> renderContext = vs.getRenderContext(); renderContext.setVertexFillPaintTransformer(vertexPaint); Transformer<String, String> transformer = new ToStringLabeller<String>(); renderContext.setEdgeLabelTransformer(transformer); Transformer<String, String> vertexTransformer = new ToStringLabeller<String>(); renderContext.setVertexLabelTransformer(vertexTransformer); vs.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); PanelArbol.add(vs); PanelArbol.updateUI(); } else { indice = 0; } } }); //-------------------Despues------------------------ JButton next = new JButton("Siguiente"); next.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int x = IncrementarIndice(0); if (x < arboles.size()) { if (vs != null) { PanelArbol.remove(vs); } //-----------Dibujar arbol--------- vs = new BasicVisualizationServer<String, String>( new TreeLayout<String, String>(arboles.get(x)), new Dimension(250, 250)); Transformer<String, Paint> vertexPaint = new Transformer<String, Paint>() { public Paint transform(String i) { return Color.GREEN; } }; RenderContext<String, String> renderContext = vs.getRenderContext(); renderContext.setVertexFillPaintTransformer(vertexPaint); Transformer<String, String> transformer = new ToStringLabeller<String>(); renderContext.setEdgeLabelTransformer(transformer); Transformer<String, String> vertexTransformer = new ToStringLabeller<String>(); renderContext.setVertexLabelTransformer(vertexTransformer); vs.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); PanelArbol.add(vs); PanelArbol.updateUI(); heap.repaint(); } else { indice = arboles.size() - 1; } } }); //---------------Terminar accion-------------------------- JButton terminar = new JButton("Salir"); terminar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { heap_sort_numbers = new ArrayList(); arboles = new ArrayList(); indice = -1; PanelArbol = new JPanel(); grid = new GridLayout(2, 0); flow = new FlowLayout(); panelgenera = new JPanel(grid); Panelarreglo = new JPanel(flow); heap.dispose(); HeapSort.dispose(); heap = new JFrame(); heap.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); } }); next.setBackground(Color.BLUE); preview.setBackground(Color.BLUE); terminar.setBackground(Color.BLUE); Panelarreglo.add(preview); Panelarreglo.add(next); Panelarreglo.add(terminar); this.panelgenera.add(Panelarreglo); this.panelgenera.add(PanelArbol); this.heap.add(panelgenera); heap.repaint(); paintComponents(getGraphics()); this.heap.setVisible(true); }
From source file:eu.hydrologis.jgrass.charting.datamodels.MultiXYTimeChartCreator.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); NumericChartData numericChartData = new NumericChartData(2); /*/*w ww. j a v a2 s .c o m*/ * first tab */ NumericChartDataItem tab1 = numericChartData.getChartDataItem(0); /* * title to be taken in the case of composed charts. In that case it is ambiguos which title * of which chart should be taken */ tab1.bigTitle = "Title of tab 1"; /* * extra string that will be taken to give the tab a name, the title could be non suitable */ tab1.chartStringExtra = "Text of tab 1"; /* * in tab 1: first chart with 2 series */ // the title for this chart tab1.chartTitles.add("Chart title 1 in tab 1"); // x label tab1.chartXLabels.add("X data"); // y label tab1.chartYLabels.add("Y data"); // define some data double[][][] data11 = new double[][][] { { { -1, -2, -3 }, { 2, 4, 6 } }, { { 1, 2, 3 }, { 2, 4, 6 } } }; tab1.chartSeriesData.add(data11); // give the series for this chart a name tab1.seriesNames.add(new String[] { "series 1", "series 2" }); /* * in tab 1: second chart with 1 serie */ tab1.seriesNames.add(new String[] { "series 1" }); double[][][] data12 = new double[][][] { { { 1, 2, 3 }, { 2, 4, 6 } } }; tab1.chartTitles.add("Chart title 2 in tab 1"); tab1.chartXLabels.add("X data"); tab1.chartYLabels.add("Y data"); tab1.chartSeriesData.add(data12); /* * second tab */ NumericChartDataItem tab2 = numericChartData.getChartDataItem(1); tab2.bigTitle = "Title of tab 2"; tab2.chartStringExtra = "Text of tab 2"; /* * in tab 2: one single chart with 3 series */ tab2.chartTitles.add("Chart title 1 in tab 2"); tab2.chartXLabels.add("X data"); tab2.chartYLabels.add("Y data"); double[][][] data2 = new double[][][] { { { -1, -2, -3 }, { 2, 4, 6 } }, { { 1, 2, 3 }, { 2, 4, 6 } }, { { 1, 2, 3 }, { -2, -4, -6 } } }; tab2.chartSeriesData.add(data2); tab2.seriesNames.add(new String[] { "series 1", "series 2", "series 3" }); /* * create the chart using a */ ChartCreator creator = new MultiXYTimeChartCreator(); // tweak some stuff /* create all the charts in the list for every tab? Yes. */ creator.M_HINT_CREATE_CHART = new boolean[][] { { true, true }, { true, false } }; /* create the checkboxes to hide and unhide the series? First no, second yes */ creator.M_HINT_CREATE_TOGGLEHIDESERIES = new boolean[][] { { false, false }, { true, false } }; /* define the types of chart to create */ creator.M_HINT_CHART_TYPE = new int[][] { { ChartCreator.XYBARCHART, ChartCreator.XYLINECHART }, { ChartCreator.XYLINECHART, -1 } }; /* define the vertical orientation of the chart */ creator.M_HINT_CHARTORIENTATION_UP = new boolean[][] { { false, true }, { true, true } }; /* * define the colors of the series, if = null, colors are taken automatically */ creator.M_HINT_CHARTSERIESCOLOR = new Color[2][2][3]; // tab 1, chart 1, all series creator.M_HINT_CHARTSERIESCOLOR[0][0] = new Color[] { Color.blue, Color.red, null }; // tab 1, chart 2, all series creator.M_HINT_CHARTSERIESCOLOR[0][1] = new Color[] { Color.green, null, null }; // tab 2, chart 1, all series creator.M_HINT_CHARTSERIESCOLOR[1][0] = new Color[] { Color.blue, Color.red, Color.yellow }; /* * finally create that plot */ creator.makePlot(shell, numericChartData); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }