Java Code Examples for org.jfree.chart.ChartFrame#setVisible()
The following examples show how to use
org.jfree.chart.ChartFrame#setVisible() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HomeAdmin.java From StudentGradesManageSystem with Apache License 2.0 | 6 votes |
public void makeChartByMap(Map<String, Object> map,String title) { DefaultPieDataset dpd = new DefaultPieDataset(); //建立一个默认的饼图 System.out.println(map); dpd.setValue("优", Integer.parseInt(map.get("优").toString())); dpd.setValue("良", Integer.parseInt(map.get("良").toString())); dpd.setValue("中", Integer.parseInt(map.get("中").toString())); dpd.setValue("差", Integer.parseInt(map.get("差").toString())); dpd.setValue("不及格", Integer.parseInt(map.get("不及格").toString())); JFreeChart chart = ChartFactory.createPieChart(title, dpd, true, true, false); PiePlot piePlot = (PiePlot) chart.getPlot(); piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(("{0}:({2})"), NumberFormat.getNumberInstance(), new DecimalFormat("0.00%"))); //可以查具体的API文档,第一个参数是标题,第二个参数是一个数据集,第三个参数表示是否显示Legend,第四个参数表示是否显示提示,第五个参数表示图中是否存在URL ChartFrame chartFrame = new ChartFrame(title, chart); //chart要放在Java容器组件中,ChartFrame继承自java的Jframe类。该第一个参数的数据是放在窗口左上角的,不是正中间的标题。 chartFrame.pack(); //以合适的大小展现图形 chartFrame.setVisible(true);//图形是否可见 }
Example 2
Source File: Grafico.java From cst with GNU Lesser General Public License v3.0 | 6 votes |
public Grafico(String frametitle, String charttitle, String xlabel, String ylabel, XYSeriesCollection dataset){ JFreeChart chart = ChartFactory.createXYLineChart(charttitle, xlabel, ylabel, dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setShapesFilled(true); setXyplot(plot); setChart(chart); ChartFrame frame= new ChartFrame(frametitle,chart); frame.pack(); frame.setVisible(true); }
Example 3
Source File: VisualizePanelAttribute.java From KEEL with GNU General Public License v3.0 | 6 votes |
private void imagejLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_imagejLabelMouseClicked if (this.chart != null) { this.chart.setTitle(((VisualizePanel) this.getParent().getParent()).getData().getAttributeIndex( this.tableInfojTable.getSelectedRow())); ChartFrame frame = new ChartFrame("Attribute chart", chart, true); frame.pack(); frame.setBackground(new Color(225, 225, 225)); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = frame.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); frame.setIconImage(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/keel/GraphInterKeel/resources/ico/logo/logo.gif"))); frame.setVisible(true); } }
Example 4
Source File: VisualizePanelCharts2D.java From KEEL with GNU General Public License v3.0 | 6 votes |
private void imagejLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_imagejLabelMouseClicked if (this.chart2 != null) { ChartFrame frame = new ChartFrame("Attribute comparison", chart2, true); frame.pack(); frame.setBackground(new Color(225, 225, 225)); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = frame.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); frame.setIconImage(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/keel/GraphInterKeel/resources/ico/logo/logo.gif"))); frame.setVisible(true); } }
Example 5
Source File: ChartTest.java From Neural-Network-Programming-with-Java-SecondEdition with MIT License | 5 votes |
public static void main(String[] args) { ArrayList<Double> dados1 = new ArrayList<Double>(); dados1.add(1.0); dados1.add(2.0); dados1.add(4.0); dados1.add(8.0); dados1.add(16.0); dados1.add(32.0); dados1.add(64.0); dados1.add(128.0); Chart c = new Chart(); c.plot(dados1, "Line plot", "X axis", "Y axis"); int numberOfInputs=2; int numberOfNeurons=10; int numberOfPoints=100; double[][] rndDataSet = RandomNumberGenerator.GenerateMatrixBetween(numberOfPoints, numberOfInputs, -10.0, 10.0); String[] seriesNames = {"Scatter Plot"}; Paint[] seriesColor = {Color.WHITE}; Chart chart = new Chart("Scatter Plot",rndDataSet,seriesNames,0,seriesColor,Chart.SeriesType.DOTS); ChartFrame frame = new ChartFrame("Scatter Plot", chart.scatterPlot("X Axis", "Y Axis")); frame.pack(); frame.setVisible(true); }
Example 6
Source File: ChartPlotter.java From audiveris with GNU Affero General Public License v3.0 | 5 votes |
/** * Wrap chart into a frame with specific title and display the frame at provided * location. * * @param title frame title * @param location frame location */ public void display (String title, Point location) { ChartFrame frame = new ChartFrame(title, chart, true); frame.pack(); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.setLocation(location); frame.setVisible(true); }
Example 7
Source File: Kohonen0DTest.java From Neural-Network-Programming-with-Java-SecondEdition with MIT License | 5 votes |
public static void main(String[] args){ RandomNumberGenerator.seed=0; int numberOfInputs=2; int numberOfNeurons=10; int numberOfPoints=100; double[][] rndDataSet = RandomNumberGenerator.GenerateMatrixBetween(numberOfPoints, numberOfInputs, -10.0, 10.0); Kohonen kn0 = new Kohonen(numberOfInputs,numberOfNeurons,new UniformInitialization(-1.0,1.0),0); NeuralDataSet neuralDataSet = new NeuralDataSet(rndDataSet,2); CompetitiveLearning complrn=new CompetitiveLearning(kn0,neuralDataSet,LearningAlgorithm.LearningMode.ONLINE); complrn.show2DData=true; complrn.printTraining=true; complrn.setLearningRate(0.003); complrn.setMaxEpochs(10000); complrn.setReferenceEpoch(3000); try{ String[] seriesNames = {"Training Data"}; Paint[] seriesColor = {Color.WHITE}; Chart chart = new Chart("Training",rndDataSet,seriesNames,0,seriesColor); ChartFrame frame = new ChartFrame("Training", chart.scatterPlot("X", "Y")); frame.pack(); frame.setVisible(true); //System.in.read(); complrn.setPlot2DFrame(frame); complrn.showPlot2DData(); //System.in.read(); complrn.train(); } catch(Exception ne){ } }
Example 8
Source File: ChartTest.java From Neural-Network-Programming-with-Java-SecondEdition with MIT License | 5 votes |
public static void main(String[] args) { ArrayList<Double> dados1 = new ArrayList<Double>(); dados1.add(1.0); dados1.add(2.0); dados1.add(4.0); dados1.add(8.0); dados1.add(16.0); dados1.add(32.0); dados1.add(64.0); dados1.add(128.0); Chart c = new Chart(); c.plot(dados1, "Line plot", "X axis", "Y axis"); int numberOfInputs=2; int numberOfNeurons=10; int numberOfPoints=100; double[][] rndDataSet = RandomNumberGenerator.GenerateMatrixBetween(numberOfPoints, numberOfInputs, -10.0, 10.0); String[] seriesNames = {"Scatter Plot"}; Paint[] seriesColor = {Color.WHITE}; Chart chart = new Chart("Scatter Plot",rndDataSet,seriesNames,0,seriesColor,Chart.SeriesType.DOTS); ChartFrame frame = new ChartFrame("Scatter Plot", chart.scatterPlot("X Axis", "Y Axis")); frame.pack(); frame.setVisible(true); }
Example 9
Source File: Kohonen0DTest.java From Neural-Network-Programming-with-Java-SecondEdition with MIT License | 5 votes |
public static void main(String[] args){ RandomNumberGenerator.seed=0; int numberOfInputs=2; int numberOfNeurons=10; int numberOfPoints=100; double[][] rndDataSet = RandomNumberGenerator.GenerateMatrixBetween(numberOfPoints, numberOfInputs, -10.0, 10.0); Kohonen kn0 = new Kohonen(numberOfInputs,numberOfNeurons,new UniformInitialization(-1.0,1.0),0); NeuralDataSet neuralDataSet = new NeuralDataSet(rndDataSet,2); CompetitiveLearning complrn=new CompetitiveLearning(kn0,neuralDataSet,LearningAlgorithm.LearningMode.ONLINE); complrn.show2DData=true; complrn.printTraining=true; complrn.setLearningRate(0.003); complrn.setMaxEpochs(10000); complrn.setReferenceEpoch(3000); try{ String[] seriesNames = {"Training Data"}; Paint[] seriesColor = {Color.WHITE}; Chart chart = new Chart("Training",rndDataSet,seriesNames,0,seriesColor); ChartFrame frame = new ChartFrame("Training", chart.scatterPlot("X", "Y")); frame.pack(); frame.setVisible(true); //System.in.read(); complrn.setPlot2DFrame(frame); complrn.showPlot2DData(); //System.in.read(); complrn.train(); } catch(Exception ne){ } }
Example 10
Source File: ChartTest.java From Neural-Network-Programming-with-Java-SecondEdition with MIT License | 5 votes |
public static void main(String[] args) { ArrayList<Double> dados1 = new ArrayList<Double>(); dados1.add(1.0); dados1.add(2.0); dados1.add(4.0); dados1.add(8.0); dados1.add(16.0); dados1.add(32.0); dados1.add(64.0); dados1.add(128.0); Chart c = new Chart(); c.plot(dados1, "Line plot", "X axis", "Y axis"); int numberOfInputs=2; int numberOfNeurons=10; int numberOfPoints=100; double[][] rndDataSet = RandomNumberGenerator.GenerateMatrixBetween(numberOfPoints, numberOfInputs, -10.0, 10.0); String[] seriesNames = {"Scatter Plot"}; Paint[] seriesColor = {Color.WHITE}; Chart chart = new Chart("Scatter Plot",rndDataSet,seriesNames,0,seriesColor,Chart.SeriesType.DOTS); ChartFrame frame = new ChartFrame("Scatter Plot", chart.scatterPlot("X Axis", "Y Axis")); frame.pack(); frame.setVisible(true); }
Example 11
Source File: Kohonen0DTest.java From Neural-Network-Programming-with-Java-SecondEdition with MIT License | 5 votes |
public static void main(String[] args){ RandomNumberGenerator.seed=0; int numberOfInputs=2; int numberOfNeurons=10; int numberOfPoints=100; double[][] rndDataSet = RandomNumberGenerator.GenerateMatrixBetween(numberOfPoints, numberOfInputs, -10.0, 10.0); Kohonen kn0 = new Kohonen(numberOfInputs,numberOfNeurons,new UniformInitialization(-1.0,1.0),0); NeuralDataSet neuralDataSet = new NeuralDataSet(rndDataSet,2); CompetitiveLearning complrn=new CompetitiveLearning(kn0,neuralDataSet,LearningAlgorithm.LearningMode.ONLINE); complrn.show2DData=true; complrn.printTraining=true; complrn.setLearningRate(0.003); complrn.setMaxEpochs(10000); complrn.setReferenceEpoch(3000); try{ String[] seriesNames = {"Training Data"}; Paint[] seriesColor = {Color.WHITE}; Chart chart = new Chart("Training",rndDataSet,seriesNames,0,seriesColor); ChartFrame frame = new ChartFrame("Training", chart.scatterPlot("X", "Y")); frame.pack(); frame.setVisible(true); //System.in.read(); complrn.setPlot2DFrame(frame); complrn.showPlot2DData(); //System.in.read(); complrn.train(); } catch(Exception ne){ } }
Example 12
Source File: Kohonen2DTest.java From Neural-Network-Programming-with-Java-SecondEdition with MIT License | 4 votes |
public static void main(String[] args){ RandomNumberGenerator.seed=System.currentTimeMillis(); int numberOfInputs=2; int neuronsGridX=12; int neuronsGridY=12; int numberOfPoints=1000; double[][] rndDataSet; rndDataSet = RandomNumberGenerator.GenerateMatrixGaussian(numberOfPoints, numberOfInputs, 100.0, 1.0); //rndDataSet = RandomNumberGenerator.GenerateMatrixBetween(numberOfPoints, numberOfInputs, 100.0, 110.0); for (int i=0;i<numberOfPoints;i++){ rndDataSet[i][0]*=Math.sin(i); rndDataSet[i][0]+=RandomNumberGenerator.GenerateNext()*50; rndDataSet[i][1]*=Math.cos(i); rndDataSet[i][1]+=RandomNumberGenerator.GenerateNext()*50; } // for (int i=0;i<numberOfPoints;i++){ // rndDataSet[i][0]=i; // rndDataSet[i][0]+=RandomNumberGenerator.GenerateNext(); // rndDataSet[i][1]=Math.cos(i/100.0); // rndDataSet[i][1]+=RandomNumberGenerator.GenerateNext()*5; // } Kohonen kn2 = new Kohonen(numberOfInputs,neuronsGridX,neuronsGridY,new GaussianInitialization(500.0,20.0)); NeuralDataSet neuralDataSet = new NeuralDataSet(rndDataSet,2); CompetitiveLearning complrn=new CompetitiveLearning(kn2,neuralDataSet ,LearningAlgorithm.LearningMode.ONLINE); complrn.show2DData=true; complrn.printTraining=true; complrn.setLearningRate(0.5); complrn.setMaxEpochs(1000); complrn.setReferenceEpoch(300); complrn.sleep=-1; try{ String[] seriesNames = {"Training Data"}; Paint[] seriesColor = {Color.WHITE}; Chart chart = new Chart("Training",rndDataSet,seriesNames,0,seriesColor,Chart.SeriesType.DOTS); ChartFrame frame = new ChartFrame("Training", chart.scatterPlot("X", "Y")); frame.pack(); frame.setVisible(true); // //System.in.read(); complrn.setPlot2DFrame(frame); complrn.showPlot2DData(); //System.in.read(); complrn.train(); } catch(Exception ne){ } }
Example 13
Source File: Kohonen1DTest.java From Neural-Network-Programming-with-Java-SecondEdition with MIT License | 4 votes |
public static void main(String[] args){ RandomNumberGenerator.seed=0; int numberOfInputs=2; int numberOfNeurons=20; int numberOfPoints=1000; double[][] rndDataSet = RandomNumberGenerator.GenerateMatrixBetween(numberOfPoints, numberOfInputs, -100.0, 100.0); for (int i=0;i<numberOfPoints;i++){ rndDataSet[i][0]=i; rndDataSet[i][0]+=RandomNumberGenerator.GenerateNext(); rndDataSet[i][1]=Math.cos(i/100.0)*1000; rndDataSet[i][1]+=RandomNumberGenerator.GenerateNext()*400; } Kohonen kn1 = new Kohonen(numberOfInputs,numberOfNeurons,new UniformInitialization(0.0,1000.0),1); NeuralDataSet neuralDataSet = new NeuralDataSet(rndDataSet,2); CompetitiveLearning complrn=new CompetitiveLearning(kn1,neuralDataSet,LearningAlgorithm.LearningMode.ONLINE); complrn.show2DData=true; complrn.printTraining=true; complrn.setLearningRate(0.3); complrn.setMaxEpochs(10000); complrn.setReferenceEpoch(3000); try{ String[] seriesNames = {"Training Data"}; Paint[] seriesColor = {Color.WHITE}; Chart chart = new Chart("Training",rndDataSet,seriesNames,0,seriesColor,Chart.SeriesType.DOTS); ChartFrame frame = new ChartFrame("Training", chart.scatterPlot("X", "Y")); frame.pack(); frame.setVisible(true); complrn.setPlot2DFrame(frame); complrn.showPlot2DData(); System.in.read(); complrn.train(); } catch(Exception ne){ } }
Example 14
Source File: Kohonen1DTest.java From Neural-Network-Programming-with-Java-SecondEdition with MIT License | 4 votes |
public static void main(String[] args){ RandomNumberGenerator.seed=0; int numberOfInputs=2; int numberOfNeurons=20; int numberOfPoints=1000; double[][] rndDataSet = RandomNumberGenerator.GenerateMatrixBetween(numberOfPoints, numberOfInputs, -100.0, 100.0); for (int i=0;i<numberOfPoints;i++){ rndDataSet[i][0]=i; rndDataSet[i][0]+=RandomNumberGenerator.GenerateNext(); rndDataSet[i][1]=Math.cos(i/100.0)*1000; rndDataSet[i][1]+=RandomNumberGenerator.GenerateNext()*400; } Kohonen kn1 = new Kohonen(numberOfInputs,numberOfNeurons,new UniformInitialization(0.0,1000.0),1); NeuralDataSet neuralDataSet = new NeuralDataSet(rndDataSet,2); CompetitiveLearning complrn=new CompetitiveLearning(kn1,neuralDataSet,LearningAlgorithm.LearningMode.ONLINE); complrn.show2DData=true; complrn.printTraining=true; complrn.setLearningRate(0.3); complrn.setMaxEpochs(10000); complrn.setReferenceEpoch(3000); try{ String[] seriesNames = {"Training Data"}; Paint[] seriesColor = {Color.WHITE}; Chart chart = new Chart("Training",rndDataSet,seriesNames,0,seriesColor,Chart.SeriesType.DOTS); ChartFrame frame = new ChartFrame("Training", chart.scatterPlot("X", "Y")); frame.pack(); frame.setVisible(true); complrn.setPlot2DFrame(frame); complrn.showPlot2DData(); System.in.read(); complrn.train(); } catch(Exception ne){ } }
Example 15
Source File: Kohonen2DTest.java From Neural-Network-Programming-with-Java-SecondEdition with MIT License | 4 votes |
public static void main(String[] args){ RandomNumberGenerator.seed=System.currentTimeMillis(); int numberOfInputs=2; int neuronsGridX=12; int neuronsGridY=12; int numberOfPoints=1000; double[][] rndDataSet; rndDataSet = RandomNumberGenerator.GenerateMatrixGaussian(numberOfPoints, numberOfInputs, 100.0, 1.0); //rndDataSet = RandomNumberGenerator.GenerateMatrixBetween(numberOfPoints, numberOfInputs, 100.0, 110.0); for (int i=0;i<numberOfPoints;i++){ rndDataSet[i][0]*=Math.sin(i); rndDataSet[i][0]+=RandomNumberGenerator.GenerateNext()*50; rndDataSet[i][1]*=Math.cos(i); rndDataSet[i][1]+=RandomNumberGenerator.GenerateNext()*50; } // for (int i=0;i<numberOfPoints;i++){ // rndDataSet[i][0]=i; // rndDataSet[i][0]+=RandomNumberGenerator.GenerateNext(); // rndDataSet[i][1]=Math.cos(i/100.0); // rndDataSet[i][1]+=RandomNumberGenerator.GenerateNext()*5; // } Kohonen kn2 = new Kohonen(numberOfInputs,neuronsGridX,neuronsGridY,new GaussianInitialization(500.0,20.0)); NeuralDataSet neuralDataSet = new NeuralDataSet(rndDataSet,2); CompetitiveLearning complrn=new CompetitiveLearning(kn2,neuralDataSet ,LearningAlgorithm.LearningMode.ONLINE); complrn.show2DData=true; complrn.printTraining=true; complrn.setLearningRate(0.5); complrn.setMaxEpochs(1000); complrn.setReferenceEpoch(300); complrn.sleep=-1; try{ String[] seriesNames = {"Training Data"}; Paint[] seriesColor = {Color.WHITE}; Chart chart = new Chart("Training",rndDataSet,seriesNames,0,seriesColor,Chart.SeriesType.DOTS); ChartFrame frame = new ChartFrame("Training", chart.scatterPlot("X", "Y")); frame.pack(); frame.setVisible(true); // //System.in.read(); complrn.setPlot2DFrame(frame); complrn.showPlot2DData(); //System.in.read(); complrn.train(); } catch(Exception ne){ } }
Example 16
Source File: Kohonen2DTest.java From Neural-Network-Programming-with-Java-SecondEdition with MIT License | 4 votes |
public static void main(String[] args){ RandomNumberGenerator.seed=System.currentTimeMillis(); int numberOfInputs=2; int neuronsGridX=12; int neuronsGridY=12; int numberOfPoints=1000; double[][] rndDataSet; rndDataSet = RandomNumberGenerator.GenerateMatrixGaussian(numberOfPoints, numberOfInputs, 100.0, 1.0); //rndDataSet = RandomNumberGenerator.GenerateMatrixBetween(numberOfPoints, numberOfInputs, 100.0, 110.0); for (int i=0;i<numberOfPoints;i++){ rndDataSet[i][0]*=Math.sin(i); rndDataSet[i][0]+=RandomNumberGenerator.GenerateNext()*50; rndDataSet[i][1]*=Math.cos(i); rndDataSet[i][1]+=RandomNumberGenerator.GenerateNext()*50; } // for (int i=0;i<numberOfPoints;i++){ // rndDataSet[i][0]=i; // rndDataSet[i][0]+=RandomNumberGenerator.GenerateNext(); // rndDataSet[i][1]=Math.cos(i/100.0); // rndDataSet[i][1]+=RandomNumberGenerator.GenerateNext()*5; // } Kohonen kn2 = new Kohonen(numberOfInputs,neuronsGridX,neuronsGridY,new GaussianInitialization(500.0,20.0)); NeuralDataSet neuralDataSet = new NeuralDataSet(rndDataSet,2); CompetitiveLearning complrn=new CompetitiveLearning(kn2,neuralDataSet ,LearningAlgorithm.LearningMode.ONLINE); complrn.show2DData=true; complrn.printTraining=true; complrn.setLearningRate(0.5); complrn.setMaxEpochs(1000); complrn.setReferenceEpoch(300); complrn.sleep=-1; try{ String[] seriesNames = {"Training Data"}; Paint[] seriesColor = {Color.WHITE}; Chart chart = new Chart("Training",rndDataSet,seriesNames,0,seriesColor,Chart.SeriesType.DOTS); ChartFrame frame = new ChartFrame("Training", chart.scatterPlot("X", "Y")); frame.pack(); frame.setVisible(true); // //System.in.read(); complrn.setPlot2DFrame(frame); complrn.showPlot2DData(); //System.in.read(); complrn.train(); } catch(Exception ne){ } }
Example 17
Source File: Kohonen1DTest.java From Neural-Network-Programming-with-Java-SecondEdition with MIT License | 4 votes |
public static void main(String[] args){ RandomNumberGenerator.seed=0; int numberOfInputs=2; int numberOfNeurons=20; int numberOfPoints=1000; double[][] rndDataSet = RandomNumberGenerator.GenerateMatrixBetween(numberOfPoints, numberOfInputs, -100.0, 100.0); for (int i=0;i<numberOfPoints;i++){ rndDataSet[i][0]=i; rndDataSet[i][0]+=RandomNumberGenerator.GenerateNext(); rndDataSet[i][1]=Math.cos(i/100.0)*1000; rndDataSet[i][1]+=RandomNumberGenerator.GenerateNext()*400; } Kohonen kn1 = new Kohonen(numberOfInputs,numberOfNeurons,new UniformInitialization(0.0,1000.0),1); NeuralDataSet neuralDataSet = new NeuralDataSet(rndDataSet,2); CompetitiveLearning complrn=new CompetitiveLearning(kn1,neuralDataSet,LearningAlgorithm.LearningMode.ONLINE); complrn.show2DData=true; complrn.printTraining=true; complrn.setLearningRate(0.3); complrn.setMaxEpochs(10000); complrn.setReferenceEpoch(3000); try{ String[] seriesNames = {"Training Data"}; Paint[] seriesColor = {Color.WHITE}; Chart chart = new Chart("Training",rndDataSet,seriesNames,0,seriesColor,Chart.SeriesType.DOTS); ChartFrame frame = new ChartFrame("Training", chart.scatterPlot("X", "Y")); frame.pack(); frame.setVisible(true); complrn.setPlot2DFrame(frame); complrn.showPlot2DData(); System.in.read(); complrn.train(); } catch(Exception ne){ } }
Example 18
Source File: MotivationalViewer.java From cst with GNU Lesser General Public License v3.0 | 4 votes |
@Override public synchronized void run() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); final JFreeChart chart = ChartFactory.createBarChart( getTitle(), getEntity(), "Value", dataset, PlotOrientation.VERTICAL, true, true, false ); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); chart.setBackgroundPaint(Color.lightGray); ChartFrame frame= new ChartFrame(getTitle(), chart); frame.pack(); frame.setVisible(true); while (true) { ArrayList<Codelet> tempCodeletsList = new ArrayList<Codelet>(); tempCodeletsList.addAll(this.getListOfMotivationalEntities()); synchronized (tempCodeletsList) { for (Codelet co : tempCodeletsList) { dataset.addValue(co.getActivation(), co.getName(), "activation"); } try { Thread.currentThread().sleep(getRefreshPeriod()); } catch (InterruptedException e) { e.printStackTrace(); } } } }
Example 19
Source File: Chart.java From freeacs with MIT License | 4 votes |
/** * All params can be null. * * @param min - the minimum number on the left range axis (must be set if max is set) * @param max - the maximum number on the left range axis (must be set if min is set) * @param method2 - the method to run out of Record, and populates a bar series (right range axis) * @param highLightIndex - the index to highlight * @return * @throws Exception */ public JFreeChart makeTimeChart(Double min, Double max, String method2, Integer highLightIndex) throws Exception { startTms = System.currentTimeMillis(); endTms = 0; XYBarRenderer.setDefaultShadowsVisible(false); TimeSeriesCollection data = new TimeSeriesCollection(); Map<String, TimeSeries> timeSeriesMap = makeTimeSeriesMap(method, recordMap, keyNames); for (TimeSeries timeSeries : timeSeriesMap.values()) { data.addSeries(timeSeries); } String yAxisLabel = method; String denominator = Record.getDenominator(report.getRecordClass(), method.toLowerCase()); if (denominator != null) { yAxisLabel += " (" + denominator + ")"; } chart = ChartFactory.createTimeSeriesChart(title, "Time", yAxisLabel, data, true, true, true); XYPlot plot = (XYPlot) chart.getPlot(); if (method2 != null) { Map<Key, R> recordMap2 = recordMap; TimeSeriesCollection data2 = new TimeSeriesCollection(); if (keyNames.length > 0) { recordMap2 = report.getMapAggregatedOn(); } Map<String, TimeSeries> timeSeriesMap2 = makeTimeSeriesMap(method2, recordMap2); if (timeSeriesMap2.get("Total (" + method2 + ")") != null) { data2.addSeries(timeSeriesMap2.get("Total (" + method2 + ")")); } String y2AxisLabel = method2; String demoninator2 = Record.getDenominator(report.getRecordClass(), method2.toLowerCase()); if (demoninator2 != null) { y2AxisLabel += " (" + demoninator2 + ")"; } NumberAxis axis2 = new NumberAxis(y2AxisLabel); XYBarRenderer renderer2 = new XYBarRenderer(0.20); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(1, data2); plot.setRenderer(1, renderer2); plot.mapDatasetToRangeAxis(1, 1); renderer2.setBarPainter(new StandardXYBarPainter()); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); } if (min != null && max != null) { plot.getRangeAxis(0).setRange(min, max); } if (highLightIndex != null) { chart.getXYPlot().getRenderer().setSeriesStroke(highLightIndex, new BasicStroke(5f)); } XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setDefaultShapesVisible(true); renderer.setUseFillPaint(true); renderer.setDefaultFillPaint(Color.white); long diff = endTms - startTms; String format; if (diff > NINTY_DAYS) { format = "MMM-yyyy"; } else if (diff > TWO_DAYS) { format = "dd-MMM"; } else if (diff > TWO_MINUTES) { format = "HH:mm"; } else { format = "HH:mm:ss"; } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat(format)); LegendTitle lt = chart.getLegend(0); lt.setPosition(RectangleEdge.RIGHT); if (displayFrame) { ChartFrame frame = new ChartFrame(title, chart); frame.pack(); frame.setVisible(true); } return chart; }
Example 20
Source File: ScaleBuilder.java From libreveris with GNU Lesser General Public License v3.0 | 4 votes |
public void plot (Point upperLeft) { // All values, quorum line & spread line plotValues(); plotQuorumLine(); plotSpreadLine("", peak); // Second peak spread line? if (secondPeak != null) { plotSpreadLine("Second", secondPeak); } // Chart // JFreeChart chartLines = ChartFactory.createXYLineChart( // sheet.getId() + " (" + name + " runs)", // Title // "Lengths " + ((scale != null) ? scale : "*no scale*"), // X-Axis label // "Counts", // Y-Axis label // dataset, // Dataset // PlotOrientation.VERTICAL, // orientation, // true, // Show legend // false, // Show tool tips // false // urls // ); // use a histogram so we can see the actual buckets values // rather than being left to interpolate for any given length JFreeChart chart = ChartFactory.createHistogram( sheet.getId() + " (" + name + " runs)", // Title "", // X-Axis label - already labeled in chartLines "", // Y-Axis label - already labeled in chartLines dataset, // Dataset PlotOrientation.VERTICAL, // orientation, true, // Show legend false, // Show tool tips false // urls ); // have the quorum and spread be lines rather than bars XYPlot xyPlot = (XYPlot) chart.getPlot(); xyPlot.setDataset(1, datasetLines); XYLineAndShapeRenderer renderer1 = new XYLineAndShapeRenderer(); renderer1.setSeriesPaint(0, Color.GREEN); xyPlot.setRenderer(1, renderer1); // "FORWARD" causes the added dataset of // lines to be overlayed on histogram bars xyPlot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // Hosting frame ChartFrame frame = new ChartFrame( sheet.getId() + " - " + name + " runs", chart, true); frame.pack(); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.setLocation(upperLeft); frame.setVisible(true); }