I was wondering if you can use Jcckit to developp elaborate charts for a stand alone application. Because, as I don't need to developp a web application I don't have SVG installed.
If it's not possible to do that with Jcckit, do you know an other way?
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you want to store a chart as an image there are two ways:
1. Make a screen shot and use some photo software
2. Use the class sun.awt.image.codec.JPEGImageEncoderImpl which is a part of JDK since 1.2 to store an Image as a JPEG file. For more details see e.g. http://www.jguru.com/faq/view.jsp?EID=703938
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
actually i am currently using JCCKit for animated graphics for my stand alone application
here is the basic method:
(1) define a class which extends GraphicsPlotCanvas.
public MyPlot extends GraphicsPlotCanvas{
.....
}
(2) add it to a JPanel
javax.swing.Jpanel myPanel = new Jpanel();
// define your plot as of the plot you defined above
MyPlot thisPlot = new MyPlot;
myPanel.add(thisPlot.getGraphicsCanvas());
// add controls if you have them
// see Brusselator example
myPanel.add(new MyController().getControlPanel);
(3) you can then add this Jpanel to a JFrame or JDialog box.
JFrame mainFrame = new JFrame("Main");
mainFrame.add(myPanel)
///////////////////////////////
here is some code, it need to provide the plot classes and stuff, see brusselator it almost the same.
///////////////////////////////
/*
* BrownianChart.java
*
* Created on March 23, 2004, 10:37 AM
*/
public class BrownianChart extends javax.swing.JFrame{
private Properties _configData = new Properties();
private ConfigParameters _config
= new ConfigParameters( new PropertiesBasedConfigData(_configData) );
WeinerProcess1D _W = new WeinerProcess1D(dt, totalTime);
int len = _W.getNumberOfPoints() + 1;
double[] indices = _config.getDoubleArray("indices", new double[len]);
double[] t = _config.getDoubleArray("t" , new double[len]);
double[] x = _config.getDoubleArray("x" , new double[len]);
double[] dx = _config.getDoubleArray("dx" , new double[len]);
for (int i = 0; i < len; i++) {
int index = (int) (indices[i] + 0.5);
}
return _W;
}
public class JccKitTestBrusselator extends javax.swing.JFrame{
private Properties _configData = new Properties();
private ConfigParameters _config
= new ConfigParameters( new PropertiesBasedConfigData(_configData));
I was wondering if you can use Jcckit to developp elaborate charts for a stand alone application. Because, as I don't need to developp a web application I don't have SVG installed.
If it's not possible to do that with Jcckit, do you know an other way?
Thanks
If you want to store a chart as an image there are two ways:
1. Make a screen shot and use some photo software
2. Use the class sun.awt.image.codec.JPEGImageEncoderImpl which is a part of JDK since 1.2 to store an Image as a JPEG file. For more details see e.g. http://www.jguru.com/faq/view.jsp?EID=703938
actually i am currently using JCCKit for animated graphics for my stand alone application
here is the basic method:
(1) define a class which extends GraphicsPlotCanvas.
public MyPlot extends GraphicsPlotCanvas{
.....
}
(2) add it to a JPanel
javax.swing.Jpanel myPanel = new Jpanel();
// define your plot as of the plot you defined above
MyPlot thisPlot = new MyPlot;
myPanel.add(thisPlot.getGraphicsCanvas());
// add controls if you have them
// see Brusselator example
myPanel.add(new MyController().getControlPanel);
(3) you can then add this Jpanel to a JFrame or JDialog box.
JFrame mainFrame = new JFrame("Main");
mainFrame.add(myPanel)
///////////////////////////////
here is some code, it need to provide the plot classes and stuff, see brusselator it almost the same.
///////////////////////////////
/*
* BrownianChart.java
*
* Created on March 23, 2004, 10:37 AM
*/
package com.sourceforge.midas.charts;
import java.util.*;
import java.util.Properties;
import java.awt.*;
import javax.swing.*;
import jcckit.util.ConfigData;
import jcckit.util.ConfigParameters;
import jcckit.util.PropertiesBasedConfigData;
import com.sourceforge.midas.charts.*;
import com.sourceforge.midas.maths.simulations.*;
import com.sourceforge.midas.charts.BrownianPlot;
public class BrownianChart extends javax.swing.JFrame{
private Properties _configData = new Properties();
private ConfigParameters _config
= new ConfigParameters( new PropertiesBasedConfigData(_configData) );
private WeinerProcess1D createWeinerProcess() {
double totalTime = _config.getDouble("totalTime", 200 );
double dt = _config.getDouble("dt" , 1);
WeinerProcess1D _W = new WeinerProcess1D(dt, totalTime);
int len = _W.getNumberOfPoints() + 1;
double[] indices = _config.getDoubleArray("indices", new double[len]);
double[] t = _config.getDoubleArray("t" , new double[len]);
double[] x = _config.getDoubleArray("x" , new double[len]);
double[] dx = _config.getDoubleArray("dx" , new double[len]);
for (int i = 0; i < len; i++) {
int index = (int) (indices[i] + 0.5);
}
return _W;
}
private void initChartProperties(){
_configData.put( "background", "0xffffff");
_configData.put( "paper", "0 0 1 0.35");
_configData.put( "dt", "0.01");
_configData.put( "dx", "200");
_configData.put( "defaultAxisLabelAttributes/className", "jcckit.graphic.BasicGraphicAttributes");
_configData.put( "defaultAxisLabelAttributes/fontType", "bold");
_configData.put( "defaultAxisLabelAttributes/fontSize", "0.035");
_configData.put( "defaultTicLabelAttributes/className", "jcckit.graphic.BasicGraphicAttributes");
_configData.put( "defaultTicLabelAttributes/fontType", "bold");
_configData.put( "defaultTicLabelAttributes/fontSize", "0.015");
_configData.put( "plot/coordinateSystem/origin", "0.075 0.02");
_configData.put( "plot/coordinateSystem/xAxis/axisLength", "0.9");
_configData.put( "plot/coordinateSystem/xAxis/maximum", "200");
_configData.put( "plot/coordinateSystem/xAxis/axisLabelAttributes/", "defaultAxisLabelAttributes/");
_configData.put( "plot/coordinateSystem/xAxis/ticLabelFormat", "%0f");
_configData.put( "plot/coordinateSystem/xAxis/ticLabelAttributes/", "defaultTicLabelAttributes/");
_configData.put( "plot/coordinateSystem/xAxis/axisLabelPosition", "0 -0.02");
_configData.put( "plot/coordinateSystem/yAxis/axisLength", "0.37");
_configData.put( "plot/coordinateSystem/yAxis/axisLabel", "x, dx");
_configData.put( "plot/coordinateSystem/yAxis/axisLabelAttributes/", "defaultAxisLabelAttributes/");
_configData.put( "plot/coordinateSystem/yAxis/automaticTicCalculation", "false");
_configData.put( "plot/coordinateSystem/yAxis/numberOfTics", "7");
_configData.put( "plot/coordinateSystem/yAxis/ticLabelAttributes/", "defaultTicLabelAttributes/");
_configData.put( "plot/coordinateSysstn/yAxis/minimum", "-30");
_configData.put( "plot/coordinateSystem/yAxis/maximum", "30");
_configData.put( "plot/coordinateSystem/yAxis/axisLabelPosition", "-0.035 0");
_configData.put( "plot/curveFactory/definitions", "def null");
_configData.put( "plot/curveFactory/def/symbolFactory/className", "jcckit.plot.SquareSymbolFactory");
_configData.put( "plot/curveFactory/def/symbolFactory/size", "0.004");
_configData.put( "plot/curveFactory/def/symbolFactory/attributes/className"
, "jcckit.graphic.ShapeAttributes");
_configData.put( "plot/legend/boxHeight", "0.08");
_configData.put( "plot/legend/boxWidth", "0.09");
_configData.put( "plot/legend/upperRightCorner", "0.97 0.385");
_configData.put( "plot/legend/", "");
_configData.put( "plot/legend/", "");
}
public Container createContentPane() {
JPanel contentPane = new JPanel(new BorderLayout());
contentPane.setBackground(_config.getColor("background", getBackground()));
contentPane.setOpaque(true);
// creating the weiner process
WeinerProcess1D _W = createWeinerProcess();
// creating the Brownian Chart
initChartProperties();
BrownianPlot plot = new BrownianPlot(_config, _W);
// javax.swing.JPanel panel = new JPanel();
contentPane.add(plot.getGraphicsCanvas(), BorderLayout.CENTER);
contentPane.add(new BrownianController(_W).getControlPanel(),
BorderLayout.SOUTH);
return contentPane;
}
public static void createAndShow() {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Midas");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
BrownianChart client = new BrownianChart();
frame.setContentPane(client.createContentPane());
frame.setSize(450, 260);
frame.setVisible(true);
}
public static void main(String[] argv){
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShow();
}
} );
}
}
Modified code from eragasa to Busselator. So now you can just compile and test as Java astandalone application.
/*
*/
package JccKitTest;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Properties;
import java.awt.;
import javax.swing.;
import jcckit.GraphicsPlotCanvas;
import jcckit.data.DataCurve;
import jcckit.data.DataPlot;
import jcckit.data.DataPoint;
import jcckit.util.ConfigParameters;
import jcckit.util.PropertiesBasedConfigData;
public class JccKitTestBrusselator extends javax.swing.JFrame{
private Properties _configData = new Properties();
private ConfigParameters _config
= new ConfigParameters( new PropertiesBasedConfigData(_configData));
}