Ver5からのフォントサイズ【Javaチャート・グラフ作成ツールEspressChart】


Ver5からデフォルトのフォントサイズが変更になっています。

それ以前のフォントサイズに戻すには下記のパッチを当てる必要があります。
———————————————————–

// The following lines are used for EC3.8 upgrade test 12/4/2007
chart.setAdjustFont(false);
chart.gethXAxis().gethLabel().setFont(new Font(“Arial”, Font.PLAIN, 9));
chart.gethYAxis().gethLabel().setFont(new Font(“Arial”, Font.PLAIN, 9));
chart.gethLegend().gethText().setFont(new Font(“Arial”, Font.PLAIN, 9));
// End of test

——————————————-
[下記にサンブルテストコードを記述します。]

——————————————–

// Import all necessary classes
import quadbase.ChartAPI.*;
import quadbase.util.*;
import java.awt.*;
import java.util.*;
import java.sql.*;
import java.applet.Applet;
import java.io.*;

// Set up Frame
public class Scatter10 extends Frame {
public QbChart chart;

// Start Frame
public Scatter10() {
start();
}

// Create Empty Chart and set up initial data and wipe out empty chart data
public void start() {

QbChart.setChartServerUsed(false);
setLayout(new BorderLayout());

Timestamp time[] = {new Timestamp(100, 9, 7, 0, 0, 0, 0),
new Timestamp(100, 9, 8, 0, 0, 0, 0), new Timestamp(100, 9, 9, 0, 0, 0, 0), new Timestamp(100, 9, 10, 0, 0, 0, 0),new Timestamp(100, 9, 7, 0, 0, 0, 0), new Timestamp(100, 9, 8, 0, 0, 0, 0), new Timestamp(100, 9, 9, 0, 0, 0, 0), new Timestamp(100, 9, 10, 0, 0, 0, 0)};

Integer ctime[]=new Integer[8];

for (int i = 0; i <8; i++) {
ctime[i] = new Integer( (int) ((time[i].getTime() – time[0].getTime())/1000) );
System.out.println(ctime[i]);

}
// use the first field is series

String dataType[] = {“String”, “int”, “double”};
String fieldName[] = {“Periods”, “ctime”, “Demand”};

String records[][] = {

{“Cisco”, ctime[0].toString(), “6”},

{“Cisco” , ctime[1].toString(), “5”},

{“Cisco” , ctime[2].toString(), “2”},
{“Cisco” , ctime[3].toString(), “1”},

{“Lucent”, ctime[4].toString(), “1.5”},

{“Lucent” , ctime[5].toString(), “2.5”},
{“Lucent” , ctime[6].toString(), “3.5”},

{“Lucent” , ctime[7].toString(), “5.5”}

};
DbData data = new DbData(dataType, fieldName, records);

int map[] = {1, 2};
int thickness[] = {2, 5};

try {
chart = new QbChart(this, QbChart.VIEW2D,
QbChart.SCATTER,
data,
new ColInfo(0, map), null);
} catch (Exception ex) {
System.out.println(“Cannot create the chart”);
ex.printStackTrace();
return;
}

// Set data points
Color color[] = {Color.green, Color.red};
IDataPointSet hDataPoints = chart.gethDataPoints();
hDataPoints.setColors(color);
hDataPoints.setConnectLinesVisible(true);
hDataPoints.setDataLineThickness(thickness);

// The following lines are used for EC3.8 upgrade test 12/4/2007
chart.setAdjustFont(false);
chart.gethXAxis().gethLabel().setFont(new Font(“Arial”, Font.PLAIN, 9));
chart.gethYAxis().gethLabel().setFont(new Font(“Arial”, Font.PLAIN, 9));
chart.gethLegend().gethText().setFont(new Font(“Arial”, Font.PLAIN, 9));
// End of test

// Set background color
ICanvas hCanvas = chart.gethCanvas();
hCanvas.setBackgroundColor(Color.white);

//Move legend
ILegend legend = chart.gethLegend();

IAxis hXAxis = chart.gethXAxis();
hXAxis.setScaleAutomatic(false); // low manual scale
hXAxis.setMinScale(new Integer(0));
hXAxis.setMaxScale(new Integer(258200));
hXAxis.setScaleStep(new Integer(86400));

// Set label

chart.gethXAxis().gethLabel().setAngle(90);

// for label replacement purpose replace 0 with 0.0
NumericFormat xLabel = new NumericFormat();
xLabel.decimal = 1;
chart.gethDataPoints().setLabelFormat(1, xLabel);

chart.gethDataPoints().replace(“0.0”, “2000/9/7”);
chart.gethDataPoints().replace(“86,400.0”, “2000/9/8”);
chart.gethDataPoints().replace(“172,800.0”, “2000/9/9”);
chart.gethDataPoints().replace(“259,200.0”, “2000/9/10”);

// Set YAxis
IAxis hYAxis = chart.gethYAxis();

this.add (“Center”, chart);

try {
chart.export(QbChart.GIF, “test”, 600, 400);

} catch (Exception e1) {
e1.printStackTrace();
}
}

public class FunctionLine1 implements IFunction{
public double getY(double x){
return (0.001*x + 2);
}
}

//Start
public static void main(String[] args) {
System.out.println(“Starting Export now …”);
Scatter10 t = new Scatter10();
t.resize(600,400);
t.setVisible(true);
System.out.println(“Done Exporting.”);
}
}

関連するトピックス: