本文整理汇总了Java中org.jfree.chart.axis.NumberAxis.setRange方法的典型用法代码示例。如果您正苦于以下问题:Java NumberAxis.setRange方法的具体用法?Java NumberAxis.setRange怎么用?Java NumberAxis.setRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.axis.NumberAxis
的用法示例。
在下文中一共展示了NumberAxis.setRange方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTranslateJava2DToValue
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* Test the translation of Java2D values to data values.
*/
public void testTranslateJava2DToValue() {
NumberAxis axis = new NumberAxis();
axis.setRange(50.0, 100.0);
Rectangle2D dataArea = new Rectangle2D.Double(10.0, 50.0, 400.0, 300.0);
double y1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT);
assertTrue(same(y1, 95.8333333, 0.000001));
double y2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT);
assertTrue(same(y2, 95.8333333, 0.000001));
double x1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP);
assertTrue(same(x1, 58.125, 0.000001));
double x2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM);
assertTrue(same(x2, 58.125, 0.000001));
axis.setInverted(true);
double y3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT);
assertTrue(same(y3, 54.1666667, 0.000001));
double y4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT);
assertTrue(same(y4, 54.1666667, 0.000001));
double x3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP);
assertTrue(same(x3, 91.875, 0.000001));
double x4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM);
assertTrue(same(x4, 91.875, 0.000001));
}
示例2: testTranslateJava2DToValue
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* Test the translation of Java2D values to data values.
*/
public void testTranslateJava2DToValue() {
NumberAxis axis = new NumberAxis();
axis.setRange(50.0, 100.0);
Rectangle2D dataArea = new Rectangle2D.Double(10.0, 50.0, 400.0, 300.0);
double y1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT);
assertEquals(y1, 95.8333333, EPSILON);
double y2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT);
assertEquals(y2, 95.8333333, EPSILON);
double x1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP);
assertEquals(x1, 58.125, EPSILON);
double x2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM);
assertEquals(x2, 58.125, EPSILON);
axis.setInverted(true);
double y3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT);
assertEquals(y3, 54.1666667, EPSILON);
double y4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT);
assertEquals(y4, 54.1666667, EPSILON);
double x3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP);
assertEquals(x3, 91.875, EPSILON);
double x4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM);
assertEquals(x4, 91.875, EPSILON);
}
示例3: testSetLowerBound
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* Some checks for the setLowerBound() method.
*/
public void testSetLowerBound() {
NumberAxis axis = new NumberAxis("X");
axis.setRange(0.0, 10.0);
axis.setLowerBound(5.0);
assertEquals(5.0, axis.getLowerBound(), EPSILON);
axis.setLowerBound(10.0);
assertEquals(10.0, axis.getLowerBound(), EPSILON);
assertEquals(11.0, axis.getUpperBound(), EPSILON);
//axis.setRangeType(RangeType.POSITIVE);
//axis.setLowerBound(-5.0);
//assertEquals(0.0, axis.getLowerBound(), EPSILON);
}
示例4: setAxisProperties
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* Sets the properties of the specified axis to match the properties
* defined on this panel.
*
* @param axis the axis.
*/
public void setAxisProperties(Axis axis) {
super.setAxisProperties(axis);
NumberAxis numberAxis = (NumberAxis) axis;
numberAxis.setAutoRange(this.autoRange);
if (!this.autoRange) {
numberAxis.setRange(this.minimumValue, this.maximumValue);
}
// numberAxis.setGridLinesVisible(this.showGridLinesCheckBox.isSelected());
// numberAxis.setGridPaint(this.gridPaintSample.getPaint());
// numberAxis.setGridStroke(this.gridStrokeSample.getStroke());
}
示例5: setAxisProperties
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* Sets the properties of the specified axis to match
* the properties defined on this panel.
*
* @param axis the axis.
*/
public void setAxisProperties(Axis axis) {
super.setAxisProperties(axis);
NumberAxis numberAxis = (NumberAxis) axis;
numberAxis.setAutoRange(this.autoRange);
if (! this.autoRange)
numberAxis.setRange(this.minimumValue, this.maximumValue);
}
示例6: setAxisProperties
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* Sets the properties of the specified axis to match the properties
* defined on this panel.
*
* @param axis the axis.
*/
public void setAxisProperties(Axis axis) {
super.setAxisProperties(axis);
NumberAxis numberAxis = (NumberAxis) axis;
numberAxis.setAutoRange(this.autoRange);
if (!this.autoRange) {
numberAxis.setRange(this.minimumValue, this.maximumValue);
}
}
示例7: plot
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
public static void plot(double[] predicts, double[] actuals, String name) {
double[] index = new double[predicts.length];
for (int i = 0; i < predicts.length; i++)
index[i] = i;
int min = minValue(predicts, actuals);
int max = maxValue(predicts, actuals);
final XYSeriesCollection dataSet = new XYSeriesCollection();
addSeries(dataSet, index, predicts, "Predicts");
addSeries(dataSet, index, actuals, "Actuals");
final JFreeChart chart = ChartFactory.createXYLineChart(
"Prediction Result", // chart title
"Index", // x axis label
name, // y axis label
dataSet, // data
PlotOrientation.VERTICAL,
true, // include legend
true, // tooltips
false // urls
);
XYPlot xyPlot = chart.getXYPlot();
// X-axis
final NumberAxis domainAxis = (NumberAxis) xyPlot.getDomainAxis();
domainAxis.setRange((int) index[0], (int) (index[index.length - 1] + 2));
domainAxis.setTickUnit(new NumberTickUnit(20));
domainAxis.setVerticalTickLabels(true);
// Y-axis
final NumberAxis rangeAxis = (NumberAxis) xyPlot.getRangeAxis();
rangeAxis.setRange(min, max);
rangeAxis.setTickUnit(new NumberTickUnit(50));
final ChartPanel panel = new ChartPanel(chart);
final JFrame f = new JFrame();
f.add(panel);
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.pack();
f.setVisible(true);
}
示例8: GraphGenerator
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
public GraphGenerator(final String title, AthenaFeatures athenaFeatures, String feature) {
super(title);
this.feature = feature;
final XYDataset dataset = createDatasetFromFeatureData(athenaFeatures, feature);
final JFreeChart chart = createChart(dataset);
chart.setTitle("");
LegendTitle legend = (LegendTitle) chart.getLegend();
chart.removeLegend();
Font nwfont = new Font("Arial",1,12);
legend.setItemFont(nwfont);
legend.setPosition(RectangleEdge.TOP);
// legend.setWidth(200);
legend.setItemLabelPadding(new RectangleInsets(3, 3, 3, 3));
legend.setHeight(10);
// legend.setPadding(new RectangleInsets(10, 10, 10, 10));
XYTitleAnnotation ta = new XYTitleAnnotation(0.99, 0.98, legend, RectangleAnchor.TOP_RIGHT);
ta.setMaxWidth(0.95);
// chart.addLegend(legend);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.white);
plot.setDomainZeroBaselinePaint(Color.gray);
plot.setDomainGridlinePaint(Color.gray);
plot.setDomainGridlineStroke(new BasicStroke(0.7f));
plot.setRangeGridlinePaint(Color.gray);
plot.setRangeGridlineStroke(new BasicStroke(0.7f));
plot.setDomainMinorGridlinePaint(Color.black);
plot.addAnnotation(ta);
final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
renderer.setSeriesPaint(0, Color.black);
renderer.setSeriesShape(0, ShapeUtilities.createDiamond(5));
renderer.setSeriesPaint(1, Color.red);
renderer.setSeriesShape(1, ShapeUtilities.createUpTriangle(5));
renderer.setSeriesPaint(2, Color.blue);
Shape shape = new Ellipse2D.Double(-5.0,-5.0,10,10);
renderer.setSeriesShape(2, shape);
renderer.setShapesFilled(false);
// renderer.setSeriesShapesVisible(1, false);
//apply theme
// StandardChartTheme.createJFreeTheme().apply(chart);
plot.setRenderer(renderer);
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
yAxis.setLabel(feature + " (K)");
yAxis.setAxisLineVisible(false);
yAxis.setTickUnit(new NumberTickUnit(50000));
yAxis.setNumberFormatOverride(new ByteFormat());
yAxis.setRange(new Range(0, 160000));
plot.getRenderer().setBaseItemLabelsVisible(true);
DateAxis xAxis = (DateAxis) plot.getDomainAxis();
xAxis.setAxisLineVisible(false);
xAxis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss"));
xAxis.setTickUnit(new DateTickUnit(DateTickUnit.MINUTE, 3));
xAxis.setLabelFont(new Font("Arial",1,12));
final ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(631, 381));
chartPanel.setMouseZoomable(true, true);
setContentPane(chartPanel);
try {
ChartUtilities.saveChartAsPNG(new File("result.png"), chart, 631, 381);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例9: GeneratePlot
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
public void GeneratePlot(String pngfile) throws IOException {
String modelfile = FilenameUtils.getFullPath(pngfile) + "/" + FilenameUtils.getBaseName(pngfile) + "_ModelPoints.txt";
FileWriter writer = new FileWriter(modelfile);
double[] IDObs = new double[IDEmpiricalDist.getN()];
double[] DecoyObs = new double[DecoyEmpiricalDist.getN()];
for (int i = 0; i < IDEmpiricalDist.getN(); i++) {
IDObs[i] = IDEmpiricalDist.getObs(i);
}
for (int i = 0; i < DecoyEmpiricalDist.getN(); i++) {
DecoyObs[i] = DecoyEmpiricalDist.getObs(i);
}
XYSeries model1 = new XYSeries("Incorrect matches");
XYSeries model2 = new XYSeries("Correct matches");
XYSeries model3 = new XYSeries("All target hits");
writer.write("UScore\tModel\tCorrect\tDecoy\n");
for (int i = 0; i < NoBinPoints; i++) {
model1.add(model_kde_x[i], decoy_kde_y[i]);
model2.add(model_kde_x[i], correct_kde_y[i]);
model3.add(model_kde_x[i], model_kde_y[i]);
writer.write(model_kde_x[i] + "\t" + model_kde_y[i] + "\t" + correct_kde_y[i] + "\t" + decoy_kde_y[i] + "\n");
}
writer.close();
MixtureModelProb = new Float[NoBinPoints + 1][3];
float positiveaccu = 0f;
float negativeaccu = 0f;
MixtureModelProb[0][0] = (float) model2.getMaxX() + Float.MIN_VALUE;
MixtureModelProb[0][1] = 1f;
MixtureModelProb[0][2] = 1f;
for (int i = 1; i < NoBinPoints + 1; i++) {
double positiveNumber = correct_kde_y[NoBinPoints - i];
double negativeNumber = decoy_kde_y[NoBinPoints - i];
MixtureModelProb[i][0] = (float) model_kde_x[NoBinPoints - i];
positiveaccu += positiveNumber;
negativeaccu += negativeNumber;
MixtureModelProb[i][2] = 0.999999f * (float) (positiveNumber / (negativeNumber + positiveNumber));
MixtureModelProb[i][1] = 0.999999f * (float) (positiveaccu / (negativeaccu + positiveaccu));
}
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(model1);
dataset.addSeries(model2);
dataset.addSeries(model3);
HistogramDataset histogramDataset = new HistogramDataset();
histogramDataset.setType(HistogramType.SCALE_AREA_TO_1);
histogramDataset.addSeries("ID hits", IDObs, 100);
histogramDataset.addSeries("Decoy hits", DecoyObs, 100);
//histogramDataset.addSeries("Model hits", ModelObs, 100);
JFreeChart chart = ChartFactory.createHistogram(FilenameUtils.getBaseName(pngfile), "Score", "Hits", histogramDataset, PlotOrientation.VERTICAL, true, false, false);
XYPlot plot = chart.getXYPlot();
NumberAxis domain = (NumberAxis) plot.getDomainAxis();
domain.setRange(min, max);
plot.setBackgroundPaint(Color.white);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setForegroundAlpha(0.8f);
chart.setBackgroundPaint(Color.white);
XYLineAndShapeRenderer render = new XYLineAndShapeRenderer();
plot.setDataset(1, dataset);
plot.setRenderer(1, render);
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
try {
ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
} catch (IOException e) {
}
}