本文整理汇总了Java中org.jfree.chart.annotations.XYLineAnnotation类的典型用法代码示例。如果您正苦于以下问题:Java XYLineAnnotation类的具体用法?Java XYLineAnnotation怎么用?Java XYLineAnnotation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XYLineAnnotation类属于org.jfree.chart.annotations包,在下文中一共展示了XYLineAnnotation类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeGuessingLine
import org.jfree.chart.annotations.XYLineAnnotation; //导入依赖的package包/类
public static void makeGuessingLine(XYPlot xyplot) {
// draw guessing line
XYLineAnnotation guessing = new XYLineAnnotation(-5, -5, 100, 100, dashed, Color.red);
xyplot.addAnnotation(guessing);
XYPointerAnnotation worse = makePointer(75, 0, "Worse than guessing", TextAnchor.TOP_CENTER, 90);
xyplot.addAnnotation(worse);
XYPointerAnnotation better = makePointer(25, 100, "Better than guessing", TextAnchor.BOTTOM_CENTER, 270);
xyplot.addAnnotation(better);
XYTextAnnotation stroketext = new XYTextAnnotation(" Random Guess", 88, 107);
stroketext.setTextAnchor(TextAnchor.CENTER_RIGHT);
stroketext.setBackgroundPaint(Color.white);
stroketext.setPaint(Color.red);
stroketext.setFont(theme.getRegularFont());
xyplot.addAnnotation(stroketext);
XYLineAnnotation strokekey = new XYLineAnnotation(58, 107, 68, 107, dashed, Color.red);
xyplot.setBackgroundPaint(Color.white);
xyplot.addAnnotation(strokekey);
}
示例2: updateAnnotation
import org.jfree.chart.annotations.XYLineAnnotation; //导入依赖的package包/类
void updateAnnotation(RasterDataNode raster) {
removeAnnotation();
final AbstractTimeSeries timeSeries = getTimeSeries();
TimeCoding timeCoding = timeSeries.getRasterTimeMap().get(raster);
if (timeCoding != null) {
final ProductData.UTC startTime = timeCoding.getStartTime();
final Millisecond timePeriod = new Millisecond(startTime.getAsDate(),
ProductData.UTC.UTC_TIME_ZONE,
Locale.getDefault());
double millisecond = timePeriod.getFirstMillisecond();
Range valueRange = null;
for (int i = 0; i < timeSeriesPlot.getRangeAxisCount(); i++) {
valueRange = Range.combine(valueRange, timeSeriesPlot.getRangeAxis(i).getRange());
}
if (valueRange != null) {
XYAnnotation annotation = new XYLineAnnotation(millisecond, valueRange.getLowerBound(), millisecond,
valueRange.getUpperBound());
timeSeriesPlot.addAnnotation(annotation, true);
}
}
}
示例3: testEquals
import org.jfree.chart.annotations.XYLineAnnotation; //导入依赖的package包/类
/**
* Confirm that the equals method can distinguish all the required fields.
*/
public void testEquals() {
Stroke stroke = new BasicStroke(2.0f);
XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.blue);
XYLineAnnotation a2 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.blue);
assertTrue(a1.equals(a2));
}
示例4: testHashCode
import org.jfree.chart.annotations.XYLineAnnotation; //导入依赖的package包/类
/**
* Two objects that are equal are required to return the same hashCode.
*/
public void testHashCode() {
Stroke stroke = new BasicStroke(2.0f);
XYLineAnnotation a1 = new XYLineAnnotation(
10.0, 20.0, 100.0, 200.0, stroke, Color.blue
);
XYLineAnnotation a2 = new XYLineAnnotation(
10.0, 20.0, 100.0, 200.0, stroke, Color.blue
);
assertTrue(a1.equals(a2));
int h1 = a1.hashCode();
int h2 = a2.hashCode();
assertEquals(h1, h2);
}
示例5: saveMAplot
import org.jfree.chart.annotations.XYLineAnnotation; //导入依赖的package包/类
/**
* Make an MA plot from one or two 2-D datasets (one will be highlighted in a different color) and save image.
* This configuration is used by deepseq.stats.Normalization classes
*
* @param datapoints - 2D dataset (colored grey)
* @param datapoints_highlight - 2D dataset (colored blue), can be null
* @param yLine Double - data coordinates of line to be drawn parallel to x axis (used to show scaling line)
* @param outFilename - String
* @param rasterImage - boolean
*/
public void saveMAplot(Matrix datapoints, Matrix datapoints_highlight, Double yLine, String outFilename, boolean rasterImage){
this.setWidth(800);
this.setHeight(800);
this.setXLogScale(false);
this.setYLogScale(false);
this.addDataset("other", datapoints, new Color(75,75,75,60), 3);
if(datapoints_highlight!=null)
this.addDataset("highlighted", datapoints_highlight, new Color(0,0,255,60), 3);
this.setXAxisLabel("A");
this.setYAxisLabel("M");
this.setXRange(-20,-5);
this.setYRange(-6,6);
//Set the tick units according to the range
double xUpper = daxis.getRange().getUpperBound();
double xLower = daxis.getRange().getLowerBound();
if(daxis instanceof org.jfree.chart.axis.NumberAxis)
((NumberAxis)daxis).setTickUnit(new NumberTickUnit(5));
double yUpper = raxis.getRange().getUpperBound();
double yLower = raxis.getRange().getLowerBound();
if(raxis instanceof org.jfree.chart.axis.NumberAxis)
((NumberAxis)raxis).setTickUnit(new NumberTickUnit(3));
//Draw a red line along y = yLine
if(yLine!=null){
XYLineAnnotation lineAnnot = new XYLineAnnotation(xLower, yLine, xUpper, yLine, new BasicStroke(1), new Color(255,0,0));
this.plot.addAnnotation(lineAnnot);
}
try {
this.saveImage(new File(outFilename), width, height, rasterImage);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例6: saveMeanVarPlot
import org.jfree.chart.annotations.XYLineAnnotation; //导入依赖的package包/类
/**
* A mean-variance plot is log-log scaled, and a line can be drawn along the lowess fit
* @param datapoints : mean vs variance
* @param fitLine : coordinates (dataspace) of line
* @param outFilename
* @param rasterImage
*/
public void saveMeanVarPlot(Matrix datapoints, Matrix fitLine, String outFilename, boolean rasterImage){
this.setWidth(800);
this.setHeight(800);
this.setXLogScale(true);
this.setYLogScale(true);
this.addDataset("MV", datapoints, new Color(75,75,75,60), 3);
this.setXAxisLabel("Mean");
this.setYAxisLabel("Var");
this.setXRange(1, 100000);
this.setYRange(0.1, 1000000);
//Set the tick units according to the range
double xUpper = daxis.getRange().getUpperBound();
double xLower = daxis.getRange().getLowerBound();
if(daxis instanceof org.jfree.chart.axis.LogAxis)
((LogAxis)daxis).setTickUnit(new NumberTickUnit(1.0));
double yUpper = raxis.getRange().getUpperBound();
double yLower = raxis.getRange().getLowerBound();
if(raxis instanceof org.jfree.chart.axis.LogAxis)
((LogAxis)raxis).setTickUnit(new NumberTickUnit(1.0));
if(fitLine!=null){
//Draw a blue line along mean=var (Poisson)
XYLineAnnotation lineAnnot = new XYLineAnnotation(xLower, xLower, xUpper, xUpper, new BasicStroke(2), Color.blue);
this.plot.addAnnotation(lineAnnot);
//Draw a red line along the fit line
this.addDataset("Fit", fitLine, Color.RED, 3, false, true, false);
}
try {
this.saveImage(new File(outFilename), width, height, rasterImage);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例7: saveMAplot
import org.jfree.chart.annotations.XYLineAnnotation; //导入依赖的package包/类
/**
* Make an MA plot from one or two 2-D datasets (one will be highlighted in a different color) and save image.
* This configuration is used by deepseq.stats.Normalization classes
*
* @param datapoints - 2D dataset (colored grey)
* @param datapoints_highlight - 2D dataset (colored blue), can be null
* @param yLine Double - data coordinates of line to be drawn parallel to x axis (used to show scaling line)
* @param outFilename - String
* @param rasterImage - boolean
*/
public void saveMAplot(Matrix datapoints, Matrix datapoints_highlight, Double yLine, String outFilename, boolean rasterImage){
this.setWidth(800);
this.setHeight(800);
this.setXLogScale(false);
this.setYLogScale(false);
this.addDataset("other", datapoints, new Color(75,75,75,80), 3);
if(datapoints_highlight!=null)
this.addDataset("highlighted", datapoints_highlight, new Color(0,0,255,80), 3);
this.setXAxisLabel("A");
this.setYAxisLabel("M");
this.setXRangeFromData();
this.setYRange(-10.5,10.5);
//Set the tick units according to the range
double xUpper = daxis.getRange().getUpperBound();
double xLower = daxis.getRange().getLowerBound();
//if(daxis instanceof org.jfree.chart.axis.NumberAxis)
// ((NumberAxis)daxis).setTickUnit(new NumberTickUnit(5));
double yUpper = raxis.getRange().getUpperBound();
double yLower = raxis.getRange().getLowerBound();
if(raxis instanceof org.jfree.chart.axis.NumberAxis)
((NumberAxis)raxis).setTickUnit(new NumberTickUnit(3));
//Draw a line along y = yLine
if(yLine!=null){
XYLineAnnotation lineAnnot = new XYLineAnnotation(xLower, yLine, xUpper, yLine, new BasicStroke(1), new Color(0,0,0));
this.plot.addAnnotation(lineAnnot);
}
try {
this.saveImage(new File(outFilename), width, height, rasterImage);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例8: testPublicCloneable
import org.jfree.chart.annotations.XYLineAnnotation; //导入依赖的package包/类
/**
* Checks that this class implements PublicCloneable.
*/
public void testPublicCloneable() {
Stroke stroke = new BasicStroke(2.0f);
XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0,
stroke, Color.blue);
assertTrue(a1 instanceof PublicCloneable);
}
示例9: ScatterPanel
import org.jfree.chart.annotations.XYLineAnnotation; //导入依赖的package包/类
public ScatterPanel (String plotTitle, Dataset2D data, double samplingFraction, Color c) {
color = c;
dataset = new DefaultXYDataset();
double[][] values = new double[2][(int)(data.getCount() * samplingFraction)];
int count = 0;
for (int i = 0; i < data.getCount(); i++) {
double one = data.getVal(0,i);
double two = data.getVal(1,i);
if (Double.isNaN(one) || Double.isNaN(two) || Double.isInfinite(one)|| Double.isInfinite(two)) {
continue;
}else{
if (count >= values[0].length) {
break;
}
values[0][count] = one;
values[1][count] = two;
count++;
}
}
if (count < values.length) {
while (count < values.length && count > 0) {
//values[0][count] = values[0][count-1];
//values[1][count] = values[1][count-1];
values[0][count] = 0;
values[1][count] = 0;
count++;
}
}
dataset.addSeries(plotTitle,values);
chart = ChartFactory.createScatterPlot(plotTitle,
data.getLabelOne(),
data.getLabelTwo(),
dataset,PlotOrientation.VERTICAL,
false,false,false);
chart.setAntiAlias(true);
ChartPanel panel = new ChartPanel(chart);
XYPlot plot= chart.getXYPlot();
ValueAxis dAxis = plot.getDomainAxis();
ValueAxis rAxis = plot.getRangeAxis();
double maxbound = Math.max(dAxis.getUpperBound(), rAxis.getUpperBound());
double minbound = Math.min(dAxis.getLowerBound(), rAxis.getLowerBound());
dAxis.setUpperBound(maxbound);
rAxis.setUpperBound(maxbound);
dAxis.setLowerBound(minbound);
rAxis.setLowerBound(minbound);
plot.addAnnotation(new XYLineAnnotation(minbound, minbound, maxbound, maxbound));
plot.addAnnotation(new XYLineAnnotation(0, minbound, 0, maxbound));
plot.addAnnotation(new XYLineAnnotation(minbound, 0, maxbound, 0));
XYItemRenderer renderer = ((XYPlot)plot).getRenderer();
renderer.setSeriesPaint(0, color);
renderer.setBaseStroke(new BasicStroke((float).5));
renderer.setSeriesStroke(0,new BasicStroke((float).5));
renderer.setSeriesShape(0,new Rectangle(1,1));
setPreferredSize(new Dimension(800,800));
setLayout(new BorderLayout());
add(panel,BorderLayout.CENTER);
}
示例10: testHashCode
import org.jfree.chart.annotations.XYLineAnnotation; //导入依赖的package包/类
/**
* Two objects that are equal are required to return the same hashCode.
*/
public void testHashCode() {
Stroke stroke = new BasicStroke(2.0f);
XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0,
stroke, Color.blue);
XYLineAnnotation a2 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0,
stroke, Color.blue);
assertTrue(a1.equals(a2));
int h1 = a1.hashCode();
int h2 = a2.hashCode();
assertEquals(h1, h2);
}
示例11: run
import org.jfree.chart.annotations.XYLineAnnotation; //导入依赖的package包/类
@Override
public void run(final String arg0) {
// http://www.tutorialspoint.com/jfreechart/index.htm
final ApplicationFrame chart = new ApplicationFrame("Angular aperture");
final JFreeChart xyChart = ChartFactory.createXYLineChart(
"Angular aperture", "aperture diameter in µm", "delta in nm",
createDataset(), PlotOrientation.VERTICAL, true, true, false);
final ChartPanel chartPanel = new ChartPanel(xyChart);
chartPanel.setPreferredSize(new java.awt.Dimension(800, 600));
final XYPlot plot = xyChart.getXYPlot();
final ValueAxis axis = plot.getRangeAxis();
axis.setAutoRange(false);
axis.setUpperBound(2.0);
final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesPaint(1, Color.GREEN);
renderer.setSeriesPaint(2, Color.BLUE);
renderer.setSeriesStroke(0, new BasicStroke(2f));
renderer.setSeriesShapesVisible(0, false);
renderer.setSeriesShapesVisible(1, false);
renderer.setSeriesShapesVisible(2, false);
plot.setRenderer(renderer);
final double x_opt = mrad2µm(alpha_opt);
final double y_opt = 0.9 * Math.pow(C_s * Math.pow(lambda, 3), 0.25) * 1e9;
final XYLineAnnotation line = new XYLineAnnotation(0, y_opt, mrad2µm(Math
.ceil(2 * alpha_opt)), y_opt);
plot.addAnnotation(line);
final XYPointerAnnotation pointer = new XYPointerAnnotation(String.format(
"Smallest error disc: %.2g nm @ %.1f µm", y_opt, x_opt), x_opt, y_opt,
5.0 * Math.PI / 4.0);
stylePointer(pointer);
plot.addAnnotation(pointer);
final double aperture_alpha = 0.5 * 20 * 1e-6 / fl;
final XYPointerAnnotation resolution = new XYPointerAnnotation(String
.format("Resolution with %.0f µm aperture: %.2f nm", mrad2µm(
aperture_alpha * 1e3), delta(aperture_alpha) * 1e9), mrad2µm(
aperture_alpha * 1e3), delta(aperture_alpha) * 1e9, 1.0 * Math.PI /
4.0);
stylePointer(resolution);
plot.addAnnotation(resolution);
chart.setContentPane(chartPanel);
chart.pack();
RefineryUtilities.centerFrameOnScreen(chart);
chart.setVisible(true);
}
示例12: line2Annotation
import org.jfree.chart.annotations.XYLineAnnotation; //导入依赖的package包/类
public static XYLineAnnotation line2Annotation(Line2D.Double l2dd, Stroke s, Paint p){
return new XYLineAnnotation(l2dd.getX1(), l2dd.getY1(), l2dd.getX2(), l2dd.getY2(),s,p);
}