Java 类org.jfree.chart.util.ShapeUtils 实例源码

项目:jfreechart    文件:SamplingXYLineRenderer.java   
/**
 * Tests this renderer for equality with an arbitrary object.
 *
 * @param obj  the object ({@code null} permitted).
 *
 * @return {@code true} or {@code false}.
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof SamplingXYLineRenderer)) {
        return false;
    }
    if (!super.equals(obj)) {
        return false;
    }
    SamplingXYLineRenderer that = (SamplingXYLineRenderer) obj;
    if (!ShapeUtils.equal(this.legendLine, that.legendLine)) {
        return false;
    }
    return true;
}
项目:jfreechart    文件:XYDotRenderer.java   
/**
 * Tests this renderer for equality with an arbitrary object.  This method
 * returns {@code true} if and only if:
 *
 * <ul>
 * <li>{@code obj} is not {@code null};</li>
 * <li>{@code obj} is an instance of {@code XYDotRenderer};</li>
 * <li>both renderers have the same attribute values.
 * </ul>
 *
 * @param obj  the object ({@code null} permitted).
 *
 * @return A boolean.
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof XYDotRenderer)) {
        return false;
    }
    XYDotRenderer that = (XYDotRenderer) obj;
    if (this.dotWidth != that.dotWidth) {
        return false;
    }
    if (this.dotHeight != that.dotHeight) {
        return false;
    }
    if (!ShapeUtils.equal(this.legendShape, that.legendShape)) {
        return false;
    }
    return super.equals(obj);
}
项目:jfreechart    文件:XYAreaRenderer2.java   
/**
 * Tests this renderer for equality with an arbitrary object.
 *
 * @param obj  the object ({@code null} not permitted).
 *
 * @return A boolean.
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof XYAreaRenderer2)) {
        return false;
    }
    XYAreaRenderer2 that = (XYAreaRenderer2) obj;
    if (this.showOutline != that.showOutline) {
        return false;
    }
    if (!ShapeUtils.equal(this.legendArea, that.legendArea)) {
        return false;
    }
    return super.equals(obj);
}
项目:jfreechart    文件:DefaultDrawingSupplier.java   
/**
 * A utility method for testing the equality of two arrays of shapes.
 *
 * @param s1  the first array ({@code null} permitted).
 * @param s2  the second array ({@code null} permitted).
 *
 * @return A boolean.
 */
private boolean equalShapes(Shape[] s1, Shape[] s2) {
    if (s1 == null) {
        return s2 == null;
    }
    if (s2 == null) {
        return false;
    }
    if (s1.length != s2.length) {
        return false;
    }
    for (int i = 0; i < s1.length; i++) {
        if (!ShapeUtils.equal(s1[i], s2[i])) {
            return false;
        }
    }
    return true;
}
项目:jfreechart-fx    文件:ZoomHandlerFX.java   
/**
 * Handles a mouse pressed event by recording the initial mouse pointer
 * location.
 * 
 * @param canvas  the JavaFX canvas ({@code null} not permitted).
 * @param e  the mouse event ({@code null} not permitted).
 */
@Override
public void handleMousePressed(ChartCanvas canvas, MouseEvent e) {
    Point2D pt = new Point2D.Double(e.getX(), e.getY());
    Rectangle2D dataArea = canvas.findDataArea(pt);
    if (dataArea != null) {
        this.startPoint = ShapeUtils.getPointInRectangle(e.getX(),
                e.getY(), dataArea);
    } else {
        this.startPoint = null;
        canvas.clearLiveHandler();
    }
}
项目:jfreechart    文件:XYDifferenceRenderer.java   
/**
 * Tests this renderer for equality with an arbitrary object.
 *
 * @param obj  the object ({@code null} permitted).
 *
 * @return A boolean.
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof XYDifferenceRenderer)) {
        return false;
    }
    if (!super.equals(obj)) {
        return false;
    }
    XYDifferenceRenderer that = (XYDifferenceRenderer) obj;
    if (!PaintUtils.equal(this.positivePaint, that.positivePaint)) {
        return false;
    }
    if (!PaintUtils.equal(this.negativePaint, that.negativePaint)) {
        return false;
    }
    if (this.shapesVisible != that.shapesVisible) {
        return false;
    }
    if (!ShapeUtils.equal(this.legendLine, that.legendLine)) {
        return false;
    }
    if (this.roundXCoordinates != that.roundXCoordinates) {
        return false;
    }
    return true;
}
项目:jfreechart    文件:XYBarRenderer.java   
/**
 * Returns a clone of the renderer.
 *
 * @return A clone.
 *
 * @throws CloneNotSupportedException  if the renderer cannot be cloned.
 */
@Override
public Object clone() throws CloneNotSupportedException {
    XYBarRenderer result = (XYBarRenderer) super.clone();
    if (this.gradientPaintTransformer != null) {
        result.gradientPaintTransformer = (GradientPaintTransformer)
            ObjectUtils.clone(this.gradientPaintTransformer);
    }
    result.legendBar = ShapeUtils.clone(this.legendBar);
    return result;
}
项目:jfreechart    文件:XYAreaRenderer.java   
/**
 * Tests this renderer for equality with an arbitrary object.
 *
 * @param obj  the object ({@code null} permitted).
 *
 * @return A boolean.
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof XYAreaRenderer)) {
        return false;
    }
    XYAreaRenderer that = (XYAreaRenderer) obj;
    if (this.plotArea != that.plotArea) {
        return false;
    }
    if (this.plotLines != that.plotLines) {
        return false;
    }
    if (this.plotShapes != that.plotShapes) {
        return false;
    }
    if (this.showOutline != that.showOutline) {
        return false;
    }
    if (this.useFillPaint != that.useFillPaint) {
        return false;
    }
    if (!this.gradientTransformer.equals(that.gradientTransformer)) {
        return false;
    }
    if (!ShapeUtils.equal(this.legendArea, that.legendArea)) {
        return false;
    }
    return true;
}
项目:jfreechart    文件:MultiplePiePlot.java   
/**
 * Tests this plot for equality with an arbitrary object.  Note that the
 * plot's dataset is not considered in the equality test.
 *
 * @param obj  the object ({@code null} permitted).
 *
 * @return {@code true} if this plot is equal to {@code obj}, and
 *     {@code false} otherwise.
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof MultiplePiePlot)) {
        return false;
    }
    MultiplePiePlot that = (MultiplePiePlot) obj;
    if (this.dataExtractOrder != that.dataExtractOrder) {
        return false;
    }
    if (this.limit != that.limit) {
        return false;
    }
    if (!this.aggregatedItemsKey.equals(that.aggregatedItemsKey)) {
        return false;
    }
    if (!PaintUtils.equal(this.aggregatedItemsPaint,
            that.aggregatedItemsPaint)) {
        return false;
    }
    if (!ObjectUtils.equal(this.pieChart, that.pieChart)) {
        return false;
    }
    if (!ShapeUtils.equal(this.legendItemShape, that.legendItemShape)) {
        return false;
    }
    if (!super.equals(obj)) {
        return false;
    }
    return true;
}
项目:jfreechart    文件:CategoryAxis.java   
/**
 * A utility method for determining the width of a text block.
 *
 * @param block  the text block.
 * @param position  the position.
 * @param g2  the graphics device.
 *
 * @return The width.
 */
protected double calculateTextBlockWidth(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtils.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double w = rotatedBox.getBounds2D().getWidth() + insets.getLeft()
            + insets.getRight();
    return w;
}
项目:jfreechart    文件:CategoryAxis.java   
/**
 * A utility method for determining the height of a text block.
 *
 * @param block  the text block.
 * @param position  the label position.
 * @param g2  the graphics device.
 *
 * @return The height.
 */
protected double calculateTextBlockHeight(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtils.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double h = rotatedBox.getBounds2D().getHeight()
               + insets.getTop() + insets.getBottom();
    return h;
}
项目:jfreechart    文件:LegendGraphic.java   
/**
 * Tests this {@code LegendGraphic} instance for equality with an
 * arbitrary object.
 *
 * @param obj  the object ({@code null} permitted).
 *
 * @return A boolean.
 */
@Override
public boolean equals(Object obj) {
    if (!(obj instanceof LegendGraphic)) {
        return false;
    }
    LegendGraphic that = (LegendGraphic) obj;
    if (this.shapeVisible != that.shapeVisible) {
        return false;
    }
    if (!ShapeUtils.equal(this.shape, that.shape)) {
        return false;
    }
    if (this.shapeFilled != that.shapeFilled) {
        return false;
    }
    if (!PaintUtils.equal(this.fillPaint, that.fillPaint)) {
        return false;
    }
    if (!ObjectUtils.equal(this.fillPaintTransformer,
            that.fillPaintTransformer)) {
        return false;
    }
    if (this.shapeOutlineVisible != that.shapeOutlineVisible) {
        return false;
    }
    if (!PaintUtils.equal(this.outlinePaint, that.outlinePaint)) {
        return false;
    }
    if (!ObjectUtils.equal(this.outlineStroke, that.outlineStroke)) {
        return false;
    }
    if (this.shapeAnchor != that.shapeAnchor) {
        return false;
    }
    if (this.shapeLocation != that.shapeLocation) {
        return false;
    }
    if (this.lineVisible != that.lineVisible) {
        return false;
    }
    if (!ShapeUtils.equal(this.line, that.line)) {
        return false;
    }
    if (!PaintUtils.equal(this.linePaint, that.linePaint)) {
        return false;
    }
    if (!ObjectUtils.equal(this.lineStroke, that.lineStroke)) {
        return false;
    }
    return super.equals(obj);
}
项目:jfreechart    文件:XYLineAndShapeRenderer.java   
/**
 * Tests this renderer for equality with an arbitrary object.
 *
 * @param obj  the object ({@code null} permitted).
 *
 * @return {@code true} or {@code false}.
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof XYLineAndShapeRenderer)) {
        return false;
    }
    if (!super.equals(obj)) {
        return false;
    }
    XYLineAndShapeRenderer that = (XYLineAndShapeRenderer) obj;
    if (!ObjectUtils.equal(
        this.seriesLinesVisible, that.seriesLinesVisible)
    ) {
        return false;
    }
    if (this.defaultLinesVisible != that.defaultLinesVisible) {
        return false;
    }
    if (!ShapeUtils.equal(this.legendLine, that.legendLine)) {
        return false;
    }
    if (!ObjectUtils.equal(
        this.seriesShapesVisible, that.seriesShapesVisible)
    ) {
        return false;
    }
    if (this.defaultShapesVisible != that.defaultShapesVisible) {
        return false;
    }
    if (!ObjectUtils.equal(
        this.seriesShapesFilled, that.seriesShapesFilled)
    ) {
        return false;
    }
    if (this.defaultShapesFilled != that.defaultShapesFilled) {
        return false;
    }
    if (this.drawOutlines != that.drawOutlines) {
        return false;
    }
    if (this.useOutlinePaint != that.useOutlinePaint) {
        return false;
    }
    if (this.useFillPaint != that.useFillPaint) {
        return false;
    }
    if (this.drawSeriesLineAsPath != that.drawSeriesLineAsPath) {
        return false;
    }
    return true;
}
项目:jfreechart    文件:StandardXYItemRenderer.java   
/**
 * Tests this renderer for equality with another object.
 *
 * @param obj  the object ({@code null} permitted).
 *
 * @return A boolean.
 */
@Override
public boolean equals(Object obj) {

    if (obj == this) {
        return true;
    }
    if (!(obj instanceof StandardXYItemRenderer)) {
        return false;
    }
    StandardXYItemRenderer that = (StandardXYItemRenderer) obj;
    if (this.baseShapesVisible != that.baseShapesVisible) {
        return false;
    }
    if (this.plotLines != that.plotLines) {
        return false;
    }
    if (this.plotImages != that.plotImages) {
        return false;
    }
    if (this.plotDiscontinuous != that.plotDiscontinuous) {
        return false;
    }
    if (this.gapThresholdType != that.gapThresholdType) {
        return false;
    }
    if (this.gapThreshold != that.gapThreshold) {
        return false;
    }
    if (!this.seriesShapesFilled.equals(that.seriesShapesFilled)) {
        return false;
    }
    if (this.baseShapesFilled != that.baseShapesFilled) {
        return false;
    }
    if (this.drawSeriesLineAsPath != that.drawSeriesLineAsPath) {
        return false;
    }
    if (!ShapeUtils.equal(this.legendLine, that.legendLine)) {
        return false;
    }
    return super.equals(obj);

}
项目:jfreechart    文件:XYBarRenderer.java   
/**
 * Tests this renderer for equality with an arbitrary object.
 *
 * @param obj  the object to test against ({@code null} permitted).
 *
 * @return A boolean.
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof XYBarRenderer)) {
        return false;
    }
    XYBarRenderer that = (XYBarRenderer) obj;
    if (this.base != that.base) {
        return false;
    }
    if (this.drawBarOutline != that.drawBarOutline) {
        return false;
    }
    if (this.margin != that.margin) {
        return false;
    }
    if (this.useYInterval != that.useYInterval) {
        return false;
    }
    if (!ObjectUtils.equal(this.gradientPaintTransformer,
            that.gradientPaintTransformer)) {
        return false;
    }
    if (!ShapeUtils.equal(this.legendBar, that.legendBar)) {
        return false;
    }
    if (!ObjectUtils.equal(this.positiveItemLabelPositionFallback,
            that.positiveItemLabelPositionFallback)) {
        return false;
    }
    if (!ObjectUtils.equal(this.negativeItemLabelPositionFallback,
            that.negativeItemLabelPositionFallback)) {
        return false;
    }
    if (!this.barPainter.equals(that.barPainter)) {
        return false;
    }
    if (this.shadowsVisible != that.shadowsVisible) {
        return false;
    }
    if (this.shadowXOffset != that.shadowXOffset) {
        return false;
    }
    if (this.shadowYOffset != that.shadowYOffset) {
        return false;
    }
    if (this.barAlignmentFactor != that.barAlignmentFactor) {
        return false;
    }
    return super.equals(obj);
}
项目:jfreechart    文件:DefaultPolarItemRenderer.java   
/**
 * Tests this renderer for equality with an arbitrary object.
 *
 * @param obj  the object ({@code null} not permitted).
 *
 * @return {@code true} if this renderer is equal to {@code obj},
 *     and {@code false} otherwise.
 */
@Override
public boolean equals(Object obj) {
    if (obj == null) {
        return false;
    }
    if (!(obj instanceof DefaultPolarItemRenderer)) {
        return false;
    }
    DefaultPolarItemRenderer that = (DefaultPolarItemRenderer) obj;
    if (!this.seriesFilled.equals(that.seriesFilled)) {
        return false;
    }
    if (this.drawOutlineWhenFilled != that.drawOutlineWhenFilled) {
        return false;
    }
    if (!ObjectUtils.equal(this.fillComposite, that.fillComposite)) {
        return false;
    }
    if (this.useFillPaint != that.useFillPaint) {
        return false;
    }
    if (!ShapeUtils.equal(this.legendLine, that.legendLine)) {
        return false;
    }
    if (this.shapesVisible != that.shapesVisible) {
        return false;
    }
    if (this.connectFirstAndLastPoint != that.connectFirstAndLastPoint) {
        return false;
    }
    if (!this.toolTipGeneratorList.equals(that.toolTipGeneratorList)) {
        return false;
    }
    if (!ObjectUtils.equal(this.baseToolTipGenerator,
            that.baseToolTipGenerator)) {
        return false;
    }
    if (!ObjectUtils.equal(this.urlGenerator, that.urlGenerator)) {
        return false;
    }
    if (!ObjectUtils.equal(this.legendItemToolTipGenerator,
            that.legendItemToolTipGenerator)) {
        return false;
    }
    if (!ObjectUtils.equal(this.legendItemURLGenerator,
            that.legendItemURLGenerator)) {
        return false;
    }
    return super.equals(obj);
}
项目:jfreechart    文件:LegendItem.java   
/**
 * Tests this item for equality with an arbitrary object.
 *
 * @param obj  the object ({@code null} permitted).
 *
 * @return A boolean.
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof LegendItem)) {
        return false;
    }
    LegendItem that = (LegendItem) obj;
    if (this.datasetIndex != that.datasetIndex) {
        return false;
    }
    if (this.series != that.series) {
        return false;
    }
    if (!this.label.equals(that.label)) {
        return false;
    }
    if (!AttributedStringUtils.equal(this.attributedLabel,
            that.attributedLabel)) {
        return false;
    }
    if (!ObjectUtils.equal(this.description, that.description)) {
        return false;
    }
    if (this.shapeVisible != that.shapeVisible) {
        return false;
    }
    if (!ShapeUtils.equal(this.shape, that.shape)) {
        return false;
    }
    if (this.shapeFilled != that.shapeFilled) {
        return false;
    }
    if (!PaintUtils.equal(this.fillPaint, that.fillPaint)) {
        return false;
    }
    if (!ObjectUtils.equal(this.fillPaintTransformer,
            that.fillPaintTransformer)) {
        return false;
    }
    if (this.shapeOutlineVisible != that.shapeOutlineVisible) {
        return false;
    }
    if (!this.outlineStroke.equals(that.outlineStroke)) {
        return false;
    }
    if (!PaintUtils.equal(this.outlinePaint, that.outlinePaint)) {
        return false;
    }
    if (!this.lineVisible == that.lineVisible) {
        return false;
    }
    if (!ShapeUtils.equal(this.line, that.line)) {
        return false;
    }
    if (!this.lineStroke.equals(that.lineStroke)) {
        return false;
    }
    if (!PaintUtils.equal(this.linePaint, that.linePaint)) {
        return false;
    }
    if (!ObjectUtils.equal(this.labelFont, that.labelFont)) {
        return false;
    }
    if (!PaintUtils.equal(this.labelPaint, that.labelPaint)) {
        return false;
    }
    return true;
}
项目:jfreechart    文件:XYLineAnnotation.java   
/**
 * Draws the annotation.  This method is called by the {@link XYPlot}
 * class, you won't normally need to call it yourself.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param rendererIndex  the renderer index.
 * @param info  if supplied, this info object will be populated with
 *              entity information.
 */
@Override
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
                 ValueAxis domainAxis, ValueAxis rangeAxis,
                 int rendererIndex,
                 PlotRenderingInfo info) {

    PlotOrientation orientation = plot.getOrientation();
    RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
            plot.getDomainAxisLocation(), orientation);
    RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
            plot.getRangeAxisLocation(), orientation);
    float j2DX1 = 0.0f;
    float j2DX2 = 0.0f;
    float j2DY1 = 0.0f;
    float j2DY2 = 0.0f;
    if (orientation == PlotOrientation.VERTICAL) {
        j2DX1 = (float) domainAxis.valueToJava2D(this.x1, dataArea,
                domainEdge);
        j2DY1 = (float) rangeAxis.valueToJava2D(this.y1, dataArea,
                rangeEdge);
        j2DX2 = (float) domainAxis.valueToJava2D(this.x2, dataArea,
                domainEdge);
        j2DY2 = (float) rangeAxis.valueToJava2D(this.y2, dataArea,
                rangeEdge);
    }
    else if (orientation == PlotOrientation.HORIZONTAL) {
        j2DY1 = (float) domainAxis.valueToJava2D(this.x1, dataArea,
                domainEdge);
        j2DX1 = (float) rangeAxis.valueToJava2D(this.y1, dataArea,
                rangeEdge);
        j2DY2 = (float) domainAxis.valueToJava2D(this.x2, dataArea,
                domainEdge);
        j2DX2 = (float) rangeAxis.valueToJava2D(this.y2, dataArea,
                rangeEdge);
    }
    g2.setPaint(this.paint);
    g2.setStroke(this.stroke);
    Line2D line = new Line2D.Float(j2DX1, j2DY1, j2DX2, j2DY2);
    // line is clipped to avoid JRE bug 6574155, for more info
    // see JFreeChart bug 2221495
    boolean visible = LineUtils.clipLine(line, dataArea);
    if (visible) {
        g2.draw(line);
    }

    String toolTip = getToolTipText();
    String url = getURL();
    if (toolTip != null || url != null) {
        addEntity(info, ShapeUtils.createLineRegion(line, 1.0f),
                rendererIndex, toolTip, url);
    }
}
项目:jfreechart    文件:TextBlock.java   
/**
 * Returns the bounds of the text block.
 * 
 * @param g2  the graphics device ({@code null} not permitted).
 * @param anchorX  the x-coordinate for the anchor point.
 * @param anchorY  the y-coordinate for the anchor point.
 * @param anchor  the text block anchor ({@code null} not permitted).
 * @param rotateX  the x-coordinate for the rotation point.
 * @param rotateY  the y-coordinate for the rotation point.
 * @param angle  the rotation angle.
 * 
 * @return The bounds.
 */
public Shape calculateBounds(Graphics2D g2, float anchorX, float anchorY, 
        TextBlockAnchor anchor, float rotateX, float rotateY, double angle) {

    Size2D d = calculateDimensions(g2);
    float[] offsets = calculateOffsets(anchor, d.getWidth(), d.getHeight());
    Rectangle2D bounds = new Rectangle2D.Double(anchorX + offsets[0], 
            anchorY + offsets[1], d.getWidth(), d.getHeight());
    Shape rotatedBounds = ShapeUtils.rotateShape(bounds, angle, rotateX, 
            rotateY);
    return rotatedBounds;   

}