当前位置: 首页>>代码示例>>Java>>正文


Java RectangleEdge类代码示例

本文整理汇总了Java中org.jfree.chart.ui.RectangleEdge的典型用法代码示例。如果您正苦于以下问题:Java RectangleEdge类的具体用法?Java RectangleEdge怎么用?Java RectangleEdge使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RectangleEdge类属于org.jfree.chart.ui包,在下文中一共展示了RectangleEdge类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: chartMouseMoved

import org.jfree.chart.ui.RectangleEdge; //导入依赖的package包/类
@Override
public void chartMouseMoved(ChartMouseEventFX event) {
    Rectangle2D dataArea = this.chartViewer.getCanvas().getRenderingInfo().getPlotInfo().getDataArea();
    JFreeChart chart = event.getChart();
    XYPlot plot = (XYPlot) chart.getPlot();
    ValueAxis xAxis = plot.getDomainAxis();
    double x = xAxis.java2DToValue(event.getTrigger().getX(), dataArea, 
            RectangleEdge.BOTTOM);
    // make the crosshairs disappear if the mouse is out of range
    if (!xAxis.getRange().contains(x)) { 
        x = Double.NaN;                  
    }
    double y = DatasetUtils.findYValue(plot.getDataset(), 0, x);
    this.xCrosshair.setValue(x);
    this.yCrosshair.setValue(y);
}
 
开发者ID:jfree,项目名称:jfree-fxdemos,代码行数:17,代码来源:CrosshairOverlayFXDemo1.java

示例2: testBugX

import org.jfree.chart.ui.RectangleEdge; //导入依赖的package包/类
/**
 * This test is for a particular bug that arose just prior to the release
 * of JFreeChart 1.0.10.  A BorderArrangement with LEFT, CENTRE and RIGHT
 * blocks that is too wide, by default, for the available space, wasn't
 * shrinking the centre block as expected.
 */
@Test  
public void testBugX() {
    RectangleConstraint constraint = new RectangleConstraint(
            new Range(0.0, 200.0), new Range(0.0, 100.0));
    BlockContainer container = new BlockContainer(new BorderArrangement());
    BufferedImage image = new BufferedImage(200, 100,
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();

    container.add(new EmptyBlock(10.0, 6.0), RectangleEdge.LEFT);
    container.add(new EmptyBlock(20.0, 6.0), RectangleEdge.RIGHT);
    container.add(new EmptyBlock(30.0, 6.0));
    Size2D size = container.arrange(g2, constraint);
    assertEquals(60.0, size.width, EPSILON);
    assertEquals(6.0, size.height, EPSILON);

    container.clear();
    container.add(new EmptyBlock(10.0, 6.0), RectangleEdge.LEFT);
    container.add(new EmptyBlock(20.0, 6.0), RectangleEdge.RIGHT);
    container.add(new EmptyBlock(300.0, 6.0));
    size = container.arrange(g2, constraint);
    assertEquals(200.0, size.width, EPSILON);
    assertEquals(6.0, size.height, EPSILON);
}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:31,代码来源:BorderArrangementTest.java

示例3: getCategorySeriesMiddle

import org.jfree.chart.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Returns the middle coordinate (in Java2D space) for a series within a
 * category.
 *
 * @param categoryIndex  the category index.
 * @param categoryCount  the category count.
 * @param seriesIndex the series index.
 * @param seriesCount the series count.
 * @param itemMargin  the item margin (0.0 <= itemMargin < 1.0);
 * @param area  the area ({@code null} not permitted).
 * @param edge  the edge ({@code null} not permitted).
 *
 * @return The coordinate in Java2D space.
 *
 * @since 1.0.13
 */
public double getCategorySeriesMiddle(int categoryIndex, int categoryCount,
        int seriesIndex, int seriesCount, double itemMargin,
        Rectangle2D area, RectangleEdge edge) {

    double start = getCategoryStart(categoryIndex, categoryCount, area,
            edge);
    double end = getCategoryEnd(categoryIndex, categoryCount, area, edge);
    double width = end - start;
    if (seriesCount == 1) {
        return start + width / 2.0;
    }
    else {
        double gap = (width * itemMargin) / (seriesCount - 1);
        double ww = (width * (1 - itemMargin)) / seriesCount;
        return start + (seriesIndex * (ww + gap)) + ww / 2.0;
    }
}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:34,代码来源:CategoryAxis.java

示例4: LegendTitle

import org.jfree.chart.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Creates a new legend title with the specified arrangement.
 *
 * @param source  the source.
 * @param hLayout  the horizontal item arrangement ({@code null} not
 *                 permitted).
 * @param vLayout  the vertical item arrangement ({@code null} not
 *                 permitted).
 */
public LegendTitle(LegendItemSource source,
                   Arrangement hLayout, Arrangement vLayout) {
    this.sources = new LegendItemSource[] {source};
    this.items = new BlockContainer(hLayout);
    this.hLayout = hLayout;
    this.vLayout = vLayout;
    this.backgroundPaint = null;
    this.legendItemGraphicEdge = RectangleEdge.LEFT;
    this.legendItemGraphicAnchor = RectangleAnchor.CENTER;
    this.legendItemGraphicLocation = RectangleAnchor.CENTER;
    this.legendItemGraphicPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.itemFont = DEFAULT_ITEM_FONT;
    this.itemPaint = DEFAULT_ITEM_PAINT;
    this.itemLabelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.sortOrder = SortOrder.ASCENDING;
}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:26,代码来源:LegendTitle.java

示例5: Title

import org.jfree.chart.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Creates a new title.
 *
 * @param position  the position of the title ({@code null} not
 *                  permitted).
 * @param horizontalAlignment  the horizontal alignment of the title (LEFT,
 *                             CENTER or RIGHT, {@code null} not
 *                             permitted).
 * @param verticalAlignment  the vertical alignment of the title (TOP,
 *                           MIDDLE or BOTTOM, {@code null} not
 *                           permitted).
 * @param padding  the amount of space to leave around the outside of the
 *                 title ({@code null} not permitted).
 */
protected Title(RectangleEdge position, 
        HorizontalAlignment horizontalAlignment, 
        VerticalAlignment verticalAlignment, RectangleInsets padding) {

    Args.nullNotPermitted(position, "position");
    Args.nullNotPermitted(horizontalAlignment, "horizontalAlignment");
    Args.nullNotPermitted(verticalAlignment, "verticalAlignment");
    Args.nullNotPermitted(padding, "padding");

    this.visible = true;
    this.position = position;
    this.horizontalAlignment = horizontalAlignment;
    this.verticalAlignment = verticalAlignment;
    setPadding(padding);
    this.listenerList = new EventListenerList();
    this.notify = true;
}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:32,代码来源:Title.java

示例6: lengthToJava2D

import org.jfree.chart.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Converts a length in data coordinates into the corresponding length in
 * Java2D coordinates.
 *
 * @param length  the length.
 * @param area  the plot area.
 * @param edge  the edge along which the axis lies.
 *
 * @return The length in Java2D coordinates.
 */
@Override
public double lengthToJava2D(double length, Rectangle2D area,
                             RectangleEdge edge) {
    double axisLength = 0.0;
    if (this.displayEnd > this.displayStart) {
        axisLength = this.displayEnd - this.displayStart;
    }
    else {
        axisLength = (this.fixedRange.getUpperBound() - this.displayStart)
            + (this.displayEnd - this.fixedRange.getLowerBound());
    }
    double areaLength;
    if (RectangleEdge.isLeftOrRight(edge)) {
        areaLength = area.getHeight();
    }
    else {
        areaLength = area.getWidth();
    }
    return (length / axisLength) * areaLength;
}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:31,代码来源:ModuloAxis.java

示例7: paintBar

import org.jfree.chart.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Paints a single bar instance.
 *
 * @param g2  the graphics target.
 * @param renderer  the renderer.
 * @param row  the row index.
 * @param column  the column index.
 * @param bar  the bar
 * @param base  indicates which side of the rectangle is the base of the
 *              bar.
 */
@Override
public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row,
        int column, RectangularShape bar, RectangleEdge base) {

    Paint itemPaint = renderer.getItemPaint(row, column);
    GradientPaintTransformer t = renderer.getGradientPaintTransformer();
    if (t != null && itemPaint instanceof GradientPaint) {
        itemPaint = t.transform((GradientPaint) itemPaint, bar);
    }
    g2.setPaint(itemPaint);
    g2.fill(bar);

    // draw the outline...
    if (renderer.isDrawBarOutline()) {
           // && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) {
        Stroke stroke = renderer.getItemOutlineStroke(row, column);
        Paint paint = renderer.getItemOutlinePaint(row, column);
        if (stroke != null && paint != null) {
            g2.setStroke(stroke);
            g2.setPaint(paint);
            g2.draw(bar);
        }
    }

}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:37,代码来源:StandardXYBarPainter.java

示例8: calculateCategorySize

import org.jfree.chart.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Calculates the size (width or height, depending on the location of the
 * axis) of a category.
 *
 * @param categoryCount  the number of categories.
 * @param area  the area within which the categories will be drawn.
 * @param edge  the axis location.
 *
 * @return The category size.
 */
protected double calculateCategorySize(int categoryCount, Rectangle2D area,
        RectangleEdge edge) {
    double result;
    double available = 0.0;

    if ((edge == RectangleEdge.TOP) || (edge == RectangleEdge.BOTTOM)) {
        available = area.getWidth();
    }
    else if ((edge == RectangleEdge.LEFT)
            || (edge == RectangleEdge.RIGHT)) {
        available = area.getHeight();
    }
    if (categoryCount > 1) {
        result = available * (1 - getLowerMargin() - getUpperMargin()
                 - getCategoryMargin());
        result = result / categoryCount;
    }
    else {
        result = available * (1 - getLowerMargin() - getUpperMargin());
    }
    return result;
}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:33,代码来源:CategoryAxis.java

示例9: valueToJava2D

import org.jfree.chart.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Translates a data value to a Java2D coordinate.
 *
 * @param value  the value.
 * @param area  the area.
 * @param edge  the edge.
 *
 * @return A Java2D coordinate.
 */
@Override
public double valueToJava2D(double value, Rectangle2D area,
                            RectangleEdge edge) {
    double result;
    double v = mapValueToFixedRange(value);
    if (this.displayStart < this.displayEnd) {  // regular number axis
        result = trans(v, area, edge);
    }
    else {  // displayStart > displayEnd, need to handle split
        double cutoff = (this.displayStart + this.displayEnd) / 2.0;
        double length1 = this.fixedRange.getUpperBound()
                         - this.displayStart;
        double length2 = this.displayEnd - this.fixedRange.getLowerBound();
        if (v > cutoff) {
            result = transStart(v, area, edge, length1, length2);
        }
        else {
            result = transEnd(v, area, edge, length1, length2);
        }
    }
    return result;
}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:32,代码来源:ModuloAxis.java

示例10: paintBar

import org.jfree.chart.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Paints a single bar instance.
 *
 * @param g2  the graphics target.
 * @param renderer  the renderer.
 * @param row  the row index.
 * @param column  the column index.
 * @param bar  the bar
 * @param base  indicates which side of the rectangle is the base of the
 *              bar.
 */
@Override
public void paintBar(Graphics2D g2, BarRenderer renderer, int row,
        int column, RectangularShape bar, RectangleEdge base) {

    Paint itemPaint = renderer.getItemPaint(row, column);
    GradientPaintTransformer t = renderer.getGradientPaintTransformer();
    if (t != null && itemPaint instanceof GradientPaint) {
        itemPaint = t.transform((GradientPaint) itemPaint, bar);
    }
    g2.setPaint(itemPaint);
    g2.fill(bar);

    // draw the outline...
    if (renderer.isDrawBarOutline()) {
           // && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) {
        Stroke stroke = renderer.getItemOutlineStroke(row, column);
        Paint paint = renderer.getItemOutlinePaint(row, column);
        if (stroke != null && paint != null) {
            g2.setStroke(stroke);
            g2.setPaint(paint);
            g2.draw(bar);
        }
    }

}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:37,代码来源:StandardBarPainter.java

示例11: paintBarShadow

import org.jfree.chart.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Paints a single bar instance.
 *
 * @param g2  the graphics target.
 * @param renderer  the renderer.
 * @param row  the row index.
 * @param column  the column index.
 * @param bar  the bar
 * @param base  indicates which side of the rectangle is the base of the
 *              bar.
 * @param pegShadow  peg the shadow to the base of the bar?
 */
@Override
public void paintBarShadow(Graphics2D g2, BarRenderer renderer, int row,
        int column, RectangularShape bar, RectangleEdge base,
        boolean pegShadow) {

    // handle a special case - if the bar colour has alpha == 0, it is
    // invisible so we shouldn't draw any shadow
    Paint itemPaint = renderer.getItemPaint(row, column);
    if (itemPaint instanceof Color) {
        Color c = (Color) itemPaint;
        if (c.getAlpha() == 0) {
            return;
        }
    }

    RectangularShape shadow = createShadow(bar, renderer.getShadowXOffset(),
            renderer.getShadowYOffset(), base, pegShadow);
    g2.setPaint(renderer.getShadowPaint());
    g2.fill(shadow);

}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:34,代码来源:StandardBarPainter.java

示例12: reserveSpace

import org.jfree.chart.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Estimates the space required for the axis, given a specific drawing area.
 *
 * @param g2  the graphics device (used to obtain font information).
 * @param plot  the plot that the axis belongs to.
 * @param plotArea  the area within which the axis should be drawn.
 * @param edge  the axis location (top or bottom).
 * @param space  the space already reserved.
 *
 * @return The space required to draw the axis.
 */
@Override
public AxisSpace reserveSpace(Graphics2D g2, Plot plot, 
        Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) {

    // create a new space object if one wasn't supplied...
    if (space == null) {
        space = new AxisSpace();
    }

    // if the axis is not visible, no additional space is required...
    if (!isVisible()) {
        return space;
    }

    space = super.reserveSpace(g2, plot, plotArea, edge, space);
    double maxdim = getMaxDim(g2, edge);
    if (RectangleEdge.isTopOrBottom(edge)) {
        space.add(maxdim, edge);
    }
    else if (RectangleEdge.isLeftOrRight(edge)) {
        space.add(maxdim, edge);
    }
    return space;
}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:36,代码来源:SubCategoryAxis.java

示例13: zoomRangeAxes

import org.jfree.chart.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Multiplies the range on the range axis by the specified factor.
 *
 * @param factor  the zoom factor.
 * @param info  the plot rendering info.
 * @param source  the source point (in Java2D space).
 * @param useAnchor  use source point as zoom anchor?
 *
 * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)
 *
 * @since 1.0.7
 */
@Override
public void zoomRangeAxes(double factor, PlotRenderingInfo info,
                          Point2D source, boolean useAnchor) {
    // get the source coordinate - this plot has always a VERTICAL
    // orientation
    final double sourceX = source.getX();

    for (int axisIdx = 0; axisIdx < getAxisCount(); axisIdx++) {
        final ValueAxis axis = getAxis(axisIdx);
        if (axis != null) {
            if (useAnchor) {
                double anchorX = axis.java2DToValue(sourceX,
                        info.getDataArea(), RectangleEdge.BOTTOM);
                axis.resizeRange(factor, anchorX);
            }
            else {
                axis.resizeRange(factor);
            }
        }
    }
}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:34,代码来源:PolarPlot.java

示例14: drawHorizontalLine

import org.jfree.chart.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Utility method for drawing a horizontal line across the data area of the
 * plot.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param value  the coordinate, where to draw the line.
 * @param stroke  the stroke to use.
 * @param paint  the paint to use.
 */
protected void drawHorizontalLine(Graphics2D g2, Rectangle2D dataArea,
                                  double value, Stroke stroke,
                                  Paint paint) {

    ValueAxis axis = getRangeAxis();
    if (getOrientation() == PlotOrientation.HORIZONTAL) {
        axis = getDomainAxis();
    }
    if (axis.getRange().contains(value)) {
        double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT);
        Line2D line = new Line2D.Double(dataArea.getMinX(), yy,
                dataArea.getMaxX(), yy);
        g2.setStroke(stroke);
        g2.setPaint(paint);
        g2.draw(line);
    }

}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:29,代码来源:XYPlot.java

示例15: drawDomainGridlines

import org.jfree.chart.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Draws the gridlines for the plot, if they are visible.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param ticks  the ticks.
 */
protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea,
        List ticks) {
    if (!isDomainGridlinesVisible()) {
        return;
    }
    Object saved = g2.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, 
            RenderingHints.VALUE_STROKE_NORMALIZE);
    Iterator iterator = ticks.iterator();
    while (iterator.hasNext()) {
        ValueTick tick = (ValueTick) iterator.next();
        double v = this.domainAxis.valueToJava2D(tick.getValue(),
                dataArea, RectangleEdge.BOTTOM);
        Line2D line = new Line2D.Double(v, dataArea.getMinY(), v,
                dataArea.getMaxY());
        g2.setPaint(getDomainGridlinePaint());
        g2.setStroke(getDomainGridlineStroke());
        g2.draw(line);
    }
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, saved);
}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:29,代码来源:FastScatterPlot.java


注:本文中的org.jfree.chart.ui.RectangleEdge类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。