本文整理匯總了Java中org.jfree.chart.axis.AxisLocation類的典型用法代碼示例。如果您正苦於以下問題:Java AxisLocation類的具體用法?Java AxisLocation怎麽用?Java AxisLocation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AxisLocation類屬於org.jfree.chart.axis包,在下文中一共展示了AxisLocation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: draw
import org.jfree.chart.axis.AxisLocation; //導入依賴的package包/類
/**
* Draws the annotation. This method is called by the drawing code in the {@link XYPlot} class,
* you don't normally need to call this method directly.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param dataArea the data area.
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
*/
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
ValueAxis domainAxis, ValueAxis rangeAxis) {
PlotOrientation orientation = plot.getOrientation();
AxisLocation domainAxisLocation = plot.getDomainAxisLocation();
AxisLocation rangeAxisLocation = plot.getRangeAxisLocation();
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(domainAxisLocation, orientation);
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(rangeAxisLocation, orientation);
float j2DX = (float) domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
float j2DY = (float) rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
float xx = 0.0f;
float yy = 0.0f;
if (orientation == PlotOrientation.HORIZONTAL) {
xx = j2DY;
yy = j2DX;
}
else if (orientation == PlotOrientation.VERTICAL) {
xx = j2DX;
yy = j2DY;
}
xx = xx - this.image.getWidth(null) / 2.0f;
yy = yy - this.image.getHeight(null) / 2.0f;
g2.drawImage(this.image, (int) xx, (int) yy, null);
}
示例2: testAxisLocationIndices
import org.jfree.chart.axis.AxisLocation; //導入依賴的package包/類
@Test
public void testAxisLocationIndices() {
CategoryDataset dataset = new DefaultCategoryDataset();
CategoryAxis xAxis = new CategoryAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
CategoryItemRenderer renderer = new BarRenderer();
CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
CategoryAxis xAxis2 = new CategoryAxis("X2");
NumberAxis yAxis2 = new NumberAxis("Y2");
plot.setDomainAxis(99, xAxis2);
plot.setRangeAxis(99, yAxis2);
plot.setDomainAxisLocation(99, AxisLocation.BOTTOM_OR_RIGHT);
assertEquals(AxisLocation.BOTTOM_OR_RIGHT,
plot.getDomainAxisLocation(99));
plot.setRangeAxisLocation(99, AxisLocation.BOTTOM_OR_LEFT);
assertEquals(AxisLocation.BOTTOM_OR_LEFT,
plot.getRangeAxisLocation(99));
}
示例3: PaintScaleLegend
import org.jfree.chart.axis.AxisLocation; //導入依賴的package包/類
/**
* Creates a new instance.
*
* @param scale the scale (<code>null</code> not permitted).
* @param axis the axis (<code>null</code> not permitted).
*/
public PaintScaleLegend(PaintScale scale, ValueAxis axis) {
ParamChecks.nullNotPermitted(axis, "axis");
this.scale = scale;
this.axis = axis;
this.axis.addChangeListener(this);
this.axisLocation = AxisLocation.BOTTOM_OR_LEFT;
this.axisOffset = 0.0;
this.axis.setRange(scale.getLowerBound(), scale.getUpperBound());
this.stripWidth = 15.0;
this.stripOutlineVisible = true;
this.stripOutlinePaint = Color.gray;
this.stripOutlineStroke = new BasicStroke(0.5f);
this.backgroundPaint = Color.white;
this.subdivisions = 100;
}
示例4: PaintScaleLegend
import org.jfree.chart.axis.AxisLocation; //導入依賴的package包/類
/**
* Creates a new instance.
*
* @param scale the scale ({@code null} not permitted).
* @param axis the axis ({@code null} not permitted).
*/
public PaintScaleLegend(PaintScale scale, ValueAxis axis) {
Args.nullNotPermitted(axis, "axis");
this.scale = scale;
this.axis = axis;
this.axis.addChangeListener(this);
this.axisLocation = AxisLocation.BOTTOM_OR_LEFT;
this.axisOffset = 0.0;
this.axis.setRange(scale.getLowerBound(), scale.getUpperBound());
this.stripWidth = 15.0;
this.stripOutlineVisible = true;
this.stripOutlinePaint = Color.GRAY;
this.stripOutlineStroke = new BasicStroke(0.5f);
this.backgroundPaint = Color.WHITE;
this.subdivisions = 100;
}
示例5: testAxisLocationIndices
import org.jfree.chart.axis.AxisLocation; //導入依賴的package包/類
@Test
public void testAxisLocationIndices() {
XYDataset dataset = new XYSeriesCollection();
NumberAxis xAxis = new NumberAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
XYItemRenderer renderer = new DefaultXYItemRenderer();
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
NumberAxis xAxis2 = new NumberAxis("X2");
NumberAxis yAxis2 = new NumberAxis("Y2");
plot.setDomainAxis(99, xAxis2);
plot.setRangeAxis(99, yAxis2);
plot.setDomainAxisLocation(99, AxisLocation.BOTTOM_OR_RIGHT);
assertEquals(AxisLocation.BOTTOM_OR_RIGHT,
plot.getDomainAxisLocation(99));
plot.setRangeAxisLocation(99, AxisLocation.BOTTOM_OR_LEFT);
assertEquals(AxisLocation.BOTTOM_OR_LEFT,
plot.getRangeAxisLocation(99));
}
示例6: getChartAxisLocation
import org.jfree.chart.axis.AxisLocation; //導入依賴的package包/類
/**
* Specifies the axis location.
* It has to be overridden for child themes with another default axis location
*/
protected AxisLocation getChartAxisLocation(JRChartAxis chartAxis)
{
if (chartAxis.getPositionValue() != null)
{
switch (chartAxis.getPositionValue())
{
case RIGHT_OR_BOTTOM :
return AxisLocation.BOTTOM_OR_RIGHT;
default:
return AxisLocation.TOP_OR_LEFT;
}
}
else
{
return (AxisLocation)getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_LOCATION);
}
}
示例7: convertUponSet
import org.jfree.chart.axis.AxisLocation; //導入依賴的package包/類
@Override
public Object convertUponSet(Object value)
{
if (value == null)
{
return null;
}
return
AxisLocation.BOTTOM_OR_LEFT.toString().equals(value)
? AxisLocation.BOTTOM_OR_LEFT
: AxisLocation.BOTTOM_OR_RIGHT.toString().equals(value)
? AxisLocation.BOTTOM_OR_RIGHT
: AxisLocation.TOP_OR_LEFT.toString().equals(value)
? AxisLocation.TOP_OR_LEFT
: AxisLocation.TOP_OR_RIGHT.toString().equals(value)
? AxisLocation.TOP_OR_RIGHT : null;
}
示例8: createChart
import org.jfree.chart.axis.AxisLocation; //導入依賴的package包/類
private JFreeChart createChart(CategoryDataset dataset, HttpServletRequest request) {
JFreeChart chart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false);
CategoryPlot plot = chart.getCategoryPlot();
Paint background = new GradientPaint(0, 0, Color.lightGray, 0, IMAGE_MIN_HEIGHT, Color.white);
plot.setBackgroundPaint(background);
plot.setDomainGridlinePaint(Color.white);
plot.setDomainGridlinesVisible(true);
plot.setRangeGridlinePaint(Color.white);
plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
LogarithmicAxis rangeAxis = new LogarithmicAxis(null);
rangeAxis.setStrictValuesFlag(false);
rangeAxis.setAllowNegativesFlag(true);
plot.setRangeAxis(rangeAxis);
// Disable bar outlines.
BarRenderer renderer = (BarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
// Set up gradient paint for series.
GradientPaint gp0 = new GradientPaint(
0.0f, 0.0f, Color.blue,
0.0f, 0.0f, new Color(0, 0, 64)
);
renderer.setSeriesPaint(0, gp0);
// Rotate labels.
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
// Set theme-specific colors.
Color bgColor = getBackground(request);
Color fgColor = getForeground(request);
chart.setBackgroundPaint(bgColor);
domainAxis.setTickLabelPaint(fgColor);
domainAxis.setTickMarkPaint(fgColor);
domainAxis.setAxisLinePaint(fgColor);
rangeAxis.setTickLabelPaint(fgColor);
rangeAxis.setTickMarkPaint(fgColor);
rangeAxis.setAxisLinePaint(fgColor);
return chart;
}
示例9: createPlot
import org.jfree.chart.axis.AxisLocation; //導入依賴的package包/類
/**
* Creates a sample plot.
*
* @return A sample plot.
*/
private CombinedDomainXYPlot createPlot() {
// create subplot 1...
XYDataset data1 = createDataset1();
XYItemRenderer renderer1 = new StandardXYItemRenderer();
NumberAxis rangeAxis1 = new NumberAxis("Range 1");
XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0);
annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
annotation.setRotationAngle(Math.PI / 4.0);
subplot1.addAnnotation(annotation);
// create subplot 2...
XYDataset data2 = createDataset2();
XYItemRenderer renderer2 = new StandardXYItemRenderer();
NumberAxis rangeAxis2 = new NumberAxis("Range 2");
rangeAxis2.setAutoRangeIncludesZero(false);
XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
// parent plot...
CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain"));
plot.setGap(10.0);
// add the subplots...
plot.add(subplot1, 1);
plot.add(subplot2, 1);
plot.setOrientation(PlotOrientation.VERTICAL);
return plot;
}
示例10: createPlot
import org.jfree.chart.axis.AxisLocation; //導入依賴的package包/類
/**
* Creates a sample plot.
*
* @return A sample plot.
*/
private CombinedRangeXYPlot createPlot() {
// create subplot 1...
XYDataset data1 = createDataset1();
XYItemRenderer renderer1 = new StandardXYItemRenderer();
NumberAxis rangeAxis1 = new NumberAxis("Range 1");
XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0);
annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
annotation.setRotationAngle(Math.PI / 4.0);
subplot1.addAnnotation(annotation);
// create subplot 2...
XYDataset data2 = createDataset2();
XYItemRenderer renderer2 = new StandardXYItemRenderer();
NumberAxis rangeAxis2 = new NumberAxis("Range 2");
rangeAxis2.setAutoRangeIncludesZero(false);
XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
// parent plot...
CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis("Range"));
plot.setGap(10.0);
// add the subplots...
plot.add(subplot1, 1);
plot.add(subplot2, 1);
plot.setOrientation(PlotOrientation.VERTICAL);
return plot;
}
示例11: setDomainAxisLocation
import org.jfree.chart.axis.AxisLocation; //導入依賴的package包/類
/**
* Sets the location of the domain axis and, if requested, sends a {@link PlotChangeEvent} to
* all registered listeners.
*
* @param location the location (<code>null</code> not permitted).
* @param notify notify listeners?
*/
public void setDomainAxisLocation(AxisLocation location, boolean notify) {
if (location == null) {
throw new IllegalArgumentException("Null 'location' argument.");
}
this.domainAxisLocations.set(0, location);
if (notify) {
notifyListeners(new PlotChangeEvent(this));
}
}
示例12: getDomainAxisEdge
import org.jfree.chart.axis.AxisLocation; //導入依賴的package包/類
/**
* Returns the edge for a domain axis.
*
* @param index the axis index.
*
* @return The edge.
*/
public RectangleEdge getDomainAxisEdge(int index) {
AxisLocation location = getDomainAxisLocation(index);
RectangleEdge result = Plot.resolveDomainAxisLocation(location, this.orientation);
if (result == null) {
result = RectangleEdge.opposite(getDomainAxisEdge());
}
return result;
}
示例13: setRangeAxisLocation
import org.jfree.chart.axis.AxisLocation; //導入依賴的package包/類
/**
* Sets the location of the primary range axis and, if requested, sends a
* {@link PlotChangeEvent} to all registered listeners.
*
* @param location the location (<code>null</code> not permitted).
* @param notify notify listeners?
*/
public void setRangeAxisLocation(AxisLocation location, boolean notify) {
if (location == null) {
throw new IllegalArgumentException("Null 'location' argument.");
}
this.rangeAxisLocations.set(0, location);
if (notify) {
notifyListeners(new PlotChangeEvent(this));
}
}
示例14: getRangeAxisEdge
import org.jfree.chart.axis.AxisLocation; //導入依賴的package包/類
/**
* Returns the edge for a range axis.
*
* @param index the axis index.
*
* @return The edge.
*/
public RectangleEdge getRangeAxisEdge(int index) {
AxisLocation location = getRangeAxisLocation(index);
RectangleEdge result = Plot.resolveRangeAxisLocation(location, this.orientation);
if (result == null) {
result = RectangleEdge.opposite(getRangeAxisEdge());
}
return result;
}
示例15: setDomainAxisLocation
import org.jfree.chart.axis.AxisLocation; //導入依賴的package包/類
/**
* Sets the location of the domain axis.
*
* @param location the axis location (<code>null</code> not permitted).
* @param notify a flag that controls whether listeners are notified.
*/
public void setDomainAxisLocation(AxisLocation location, boolean notify) {
if (location == null) {
throw new IllegalArgumentException("Null 'location' argument.");
}
setDomainAxisLocation(0, location);
}