Search in sources :

Example 46 with RectangleInsets

use of org.jfree.chart.api.RectangleInsets in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.

the class AxisTest method testEquals.

/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    Axis a1 = new CategoryAxis("Test");
    Axis a2 = new CategoryAxis("Test");
    assertEquals(a1, a2);
    // visible flag...
    a1.setVisible(false);
    assertNotEquals(a1, a2);
    a2.setVisible(false);
    assertEquals(a1, a2);
    // label...
    a1.setLabel("New Label");
    assertNotEquals(a1, a2);
    a2.setLabel("New Label");
    assertEquals(a1, a2);
    // label font...
    a1.setLabelFont(new Font("Dialog", Font.PLAIN, 8));
    assertNotEquals(a1, a2);
    a2.setLabelFont(new Font("Dialog", Font.PLAIN, 8));
    assertEquals(a1, a2);
    // label paint...
    a1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.BLACK));
    assertNotEquals(a1, a2);
    a2.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.BLACK));
    assertEquals(a1, a2);
    // attributed label...
    a1.setAttributedLabel(new AttributedString("Hello World!"));
    assertNotEquals(a1, a2);
    a2.setAttributedLabel(new AttributedString("Hello World!"));
    assertEquals(a1, a2);
    AttributedString l1 = a1.getAttributedLabel();
    l1.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUB, 1, 2);
    a1.setAttributedLabel(l1);
    assertNotEquals(a1, a2);
    AttributedString l2 = a2.getAttributedLabel();
    l2.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUB, 1, 2);
    a2.setAttributedLabel(l2);
    assertEquals(a1, a2);
    // label insets...
    a1.setLabelInsets(new RectangleInsets(10.0, 10.0, 10.0, 10.0));
    assertNotEquals(a1, a2);
    a2.setLabelInsets(new RectangleInsets(10.0, 10.0, 10.0, 10.0));
    assertEquals(a1, a2);
    // label angle...
    a1.setLabelAngle(1.23);
    assertNotEquals(a1, a2);
    a2.setLabelAngle(1.23);
    assertEquals(a1, a2);
    // label location...
    a1.setLabelLocation(AxisLabelLocation.HIGH_END);
    assertNotEquals(a1, a2);
    a2.setLabelLocation(AxisLabelLocation.HIGH_END);
    assertEquals(a1, a2);
    // axis line visible...
    a1.setAxisLineVisible(false);
    assertNotEquals(a1, a2);
    a2.setAxisLineVisible(false);
    assertEquals(a1, a2);
    // axis line stroke...
    BasicStroke s = new BasicStroke(1.1f);
    a1.setAxisLineStroke(s);
    assertNotEquals(a1, a2);
    a2.setAxisLineStroke(s);
    assertEquals(a1, a2);
    // axis line paint...
    a1.setAxisLinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLACK));
    assertNotEquals(a1, a2);
    a2.setAxisLinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLACK));
    assertEquals(a1, a2);
    // tick labels visible flag...
    a1.setTickLabelsVisible(false);
    assertNotEquals(a1, a2);
    a2.setTickLabelsVisible(false);
    assertEquals(a1, a2);
    // tick label font...
    a1.setTickLabelFont(new Font("Dialog", Font.PLAIN, 12));
    assertNotEquals(a1, a2);
    a2.setTickLabelFont(new Font("Dialog", Font.PLAIN, 12));
    assertEquals(a1, a2);
    // tick label paint...
    a1.setTickLabelPaint(new GradientPaint(1.0f, 2.0f, Color.YELLOW, 3.0f, 4.0f, Color.BLACK));
    assertNotEquals(a1, a2);
    a2.setTickLabelPaint(new GradientPaint(1.0f, 2.0f, Color.YELLOW, 3.0f, 4.0f, Color.BLACK));
    assertEquals(a1, a2);
    // tick label insets...
    a1.setTickLabelInsets(new RectangleInsets(10.0, 10.0, 10.0, 10.0));
    assertNotEquals(a1, a2);
    a2.setTickLabelInsets(new RectangleInsets(10.0, 10.0, 10.0, 10.0));
    assertEquals(a1, a2);
    // tick marks visible flag...
    a1.setTickMarksVisible(false);
    assertNotEquals(a1, a2);
    a2.setTickMarksVisible(false);
    assertEquals(a1, a2);
    // tick mark inside length...
    a1.setTickMarkInsideLength(1.23f);
    assertNotEquals(a1, a2);
    a2.setTickMarkInsideLength(1.23f);
    assertEquals(a1, a2);
    // tick mark outside length...
    a1.setTickMarkOutsideLength(1.23f);
    assertNotEquals(a1, a2);
    a2.setTickMarkOutsideLength(1.23f);
    assertEquals(a1, a2);
    // tick mark stroke...
    a1.setTickMarkStroke(new BasicStroke(2.0f));
    assertNotEquals(a1, a2);
    a2.setTickMarkStroke(new BasicStroke(2.0f));
    assertEquals(a1, a2);
    // tick mark paint...
    a1.setTickMarkPaint(new GradientPaint(1.0f, 2.0f, Color.CYAN, 3.0f, 4.0f, Color.BLACK));
    assertNotEquals(a1, a2);
    a2.setTickMarkPaint(new GradientPaint(1.0f, 2.0f, Color.CYAN, 3.0f, 4.0f, Color.BLACK));
    assertEquals(a1, a2);
    // fixed dimension...
    a1.setFixedDimension(3.21f);
    assertNotEquals(a1, a2);
    a2.setFixedDimension(3.21f);
    assertEquals(a1, a2);
    a1.setMinorTickMarksVisible(true);
    assertNotEquals(a1, a2);
    a2.setMinorTickMarksVisible(true);
    assertEquals(a1, a2);
    a1.setMinorTickMarkInsideLength(1.23f);
    assertNotEquals(a1, a2);
    a2.setMinorTickMarkInsideLength(1.23f);
    assertEquals(a1, a2);
    a1.setMinorTickMarkOutsideLength(3.21f);
    assertNotEquals(a1, a2);
    a2.setMinorTickMarkOutsideLength(3.21f);
    assertEquals(a1, a2);
}
Also used : BasicStroke(java.awt.BasicStroke) AttributedString(java.text.AttributedString) GradientPaint(java.awt.GradientPaint) RectangleInsets(org.jfree.chart.api.RectangleInsets) Font(java.awt.Font) Test(org.junit.jupiter.api.Test)

Example 47 with RectangleInsets

use of org.jfree.chart.api.RectangleInsets in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.

the class WaferMapPlot method draw.

/**
 * Draws the wafermap view.
 *
 * @param g2  the graphics device.
 * @param area  the plot area.
 * @param anchor  the anchor point ({@code null} permitted).
 * @param state  the plot state.
 * @param info  the plot rendering info.
 */
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState state, PlotRenderingInfo info) {
    // if the plot area is too small, just return...
    boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW);
    boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW);
    if (b1 || b2) {
        return;
    }
    // record the plot area...
    if (info != null) {
        info.setPlotArea(area);
    }
    // adjust the drawing area for the plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);
    drawChipGrid(g2, area);
    drawWaferEdge(g2, area);
}
Also used : RectangleInsets(org.jfree.chart.api.RectangleInsets)

Example 48 with RectangleInsets

use of org.jfree.chart.api.RectangleInsets in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.

the class CombinedRangeXYPlot method add.

/**
 * Adds a subplot with a particular weight (greater than or equal to one).
 * The weight determines how much space is allocated to the subplot
 * relative to all the other subplots.
 * <br><br>
 * You must ensure that the subplot has a non-null domain axis.  The range
 * axis for the subplot will be set to {@code null}.
 *
 * @param subplot  the subplot ({@code null} not permitted).
 * @param weight  the weight (must be 1 or greater).
 */
public void add(XYPlot subplot, int weight) {
    Args.nullNotPermitted(subplot, "subplot");
    if (weight <= 0) {
        String msg = "The 'weight' must be positive.";
        throw new IllegalArgumentException(msg);
    }
    // store the plot and its weight
    subplot.setParent(this);
    subplot.setWeight(weight);
    subplot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
    subplot.setRangeAxis(null);
    subplot.addChangeListener(this);
    this.subplots.add(subplot);
    configureRangeAxes();
    fireChangeEvent();
}
Also used : RectangleInsets(org.jfree.chart.api.RectangleInsets)

Example 49 with RectangleInsets

use of org.jfree.chart.api.RectangleInsets in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.

the class PolarPlot method draw.

/**
 * Draws the plot on a Java 2D graphics device (such as the screen or a
 * printer).
 * <P>
 * This plot relies on a {@link PolarItemRenderer} to draw each
 * item in the plot.  This allows the visual representation of the data to
 * be changed easily.
 * <P>
 * The optional info argument collects information about the rendering of
 * the plot (dimensions, tooltip information etc).  Just pass in
 * {@code null} if you do not need this information.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot (including axes and
 *              labels) should be drawn.
 * @param anchor  the anchor point ({@code null} permitted).
 * @param parentState  ignored.
 * @param info  collects chart drawing information ({@code null}
 *              permitted).
 */
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) {
    // if the plot area is too small, just return...
    boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW);
    boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW);
    if (b1 || b2) {
        return;
    }
    // record the plot area...
    if (info != null) {
        info.setPlotArea(area);
    }
    // adjust the drawing area for the plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);
    Rectangle2D dataArea = area;
    if (info != null) {
        info.setDataArea(dataArea);
    }
    // draw the plot background and axes...
    drawBackground(g2, dataArea);
    int axisCount = this.axes.size();
    AxisState state = null;
    for (int i = 0; i < axisCount; i++) {
        ValueAxis axis = getAxis(i);
        if (axis != null) {
            PolarAxisLocation location = this.axisLocations.get(i);
            AxisState s = drawAxis(axis, location, g2, dataArea);
            if (i == 0) {
                state = s;
            }
        }
    }
    // now for each dataset, get the renderer and the appropriate axis
    // and render the dataset...
    Shape originalClip = g2.getClip();
    Composite originalComposite = g2.getComposite();
    g2.clip(dataArea);
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha()));
    this.angleTicks = refreshAngleTicks();
    drawGridlines(g2, dataArea, this.angleTicks, state.getTicks());
    render(g2, dataArea, info);
    g2.setClip(originalClip);
    g2.setComposite(originalComposite);
    drawOutline(g2, dataArea);
    drawCornerTextItems(g2, dataArea);
}
Also used : AxisState(org.jfree.chart.axis.AxisState) Shape(java.awt.Shape) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) ValueAxis(org.jfree.chart.axis.ValueAxis) Rectangle2D(java.awt.geom.Rectangle2D) RectangleInsets(org.jfree.chart.api.RectangleInsets) Point(java.awt.Point) Paint(java.awt.Paint)

Example 50 with RectangleInsets

use of org.jfree.chart.api.RectangleInsets in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.

the class ThermometerPlot method draw.

/**
 * Draws the plot on a Java 2D graphics device (such as the screen or a
 * printer).
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 * @param anchor  the anchor point ({@code null} permitted).
 * @param parentState  the state from the parent plot, if there is one.
 * @param info  collects info about the drawing.
 */
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) {
    RoundRectangle2D outerStem = new RoundRectangle2D.Double();
    RoundRectangle2D innerStem = new RoundRectangle2D.Double();
    RoundRectangle2D mercuryStem = new RoundRectangle2D.Double();
    Ellipse2D outerBulb = new Ellipse2D.Double();
    Ellipse2D innerBulb = new Ellipse2D.Double();
    String temp;
    FontMetrics metrics;
    if (info != null) {
        info.setPlotArea(area);
    }
    // adjust for insets...
    RectangleInsets insets = getInsets();
    insets.trim(area);
    drawBackground(g2, area);
    // adjust for padding...
    Rectangle2D interior = (Rectangle2D) area.clone();
    this.padding.trim(interior);
    int midX = (int) (interior.getX() + (interior.getWidth() / 2));
    int midY = (int) (interior.getY() + (interior.getHeight() / 2));
    int stemTop = (int) (interior.getMinY() + getBulbRadius());
    int stemBottom = (int) (interior.getMaxY() - getBulbDiameter());
    Rectangle2D dataArea = new Rectangle2D.Double(midX - getColumnRadius(), stemTop, getColumnRadius(), stemBottom - stemTop);
    outerBulb.setFrame(midX - getBulbRadius(), stemBottom, getBulbDiameter(), getBulbDiameter());
    outerStem.setRoundRect(midX - getColumnRadius(), interior.getMinY(), getColumnDiameter(), stemBottom + getBulbDiameter() - stemTop, getColumnDiameter(), getColumnDiameter());
    Area outerThermometer = new Area(outerBulb);
    Area tempArea = new Area(outerStem);
    outerThermometer.add(tempArea);
    innerBulb.setFrame(midX - getBulbRadius() + getGap(), stemBottom + getGap(), getBulbDiameter() - getGap() * 2, getBulbDiameter() - getGap() * 2);
    innerStem.setRoundRect(midX - getColumnRadius() + getGap(), interior.getMinY() + getGap(), getColumnDiameter() - getGap() * 2, stemBottom + getBulbDiameter() - getGap() * 2 - stemTop, getColumnDiameter() - getGap() * 2, getColumnDiameter() - getGap() * 2);
    Area innerThermometer = new Area(innerBulb);
    tempArea = new Area(innerStem);
    innerThermometer.add(tempArea);
    if ((this.dataset != null) && (this.dataset.getValue() != null)) {
        double current = this.dataset.getValue().doubleValue();
        double ds = this.rangeAxis.valueToJava2D(current, dataArea, RectangleEdge.LEFT);
        // already calculated
        int i = getColumnDiameter() - getGap() * 2;
        // already calculated
        int j = getColumnRadius() - getGap();
        int l = (i / 2);
        int k = (int) Math.round(ds);
        if (k < (getGap() + interior.getMinY())) {
            k = (int) (getGap() + interior.getMinY());
            l = getBulbRadius();
        }
        Area mercury = new Area(innerBulb);
        if (k < (stemBottom + getBulbRadius())) {
            mercuryStem.setRoundRect(midX - j, k, i, (stemBottom + getBulbRadius()) - k, l, l);
            tempArea = new Area(mercuryStem);
            mercury.add(tempArea);
        }
        g2.setPaint(getCurrentPaint());
        g2.fill(mercury);
        // draw range indicators...
        if (this.subrangeIndicatorsVisible) {
            g2.setStroke(this.subrangeIndicatorStroke);
            Range range = this.rangeAxis.getRange();
            // draw start of normal range
            double value = this.subrangeInfo[NORMAL][RANGE_LOW];
            if (range.contains(value)) {
                double x = midX + getColumnRadius() + 2;
                double y = this.rangeAxis.valueToJava2D(value, dataArea, RectangleEdge.LEFT);
                Line2D line = new Line2D.Double(x, y, x + 10, y);
                g2.setPaint(this.subrangePaint[NORMAL]);
                g2.draw(line);
            }
            // draw start of warning range
            value = this.subrangeInfo[WARNING][RANGE_LOW];
            if (range.contains(value)) {
                double x = midX + getColumnRadius() + 2;
                double y = this.rangeAxis.valueToJava2D(value, dataArea, RectangleEdge.LEFT);
                Line2D line = new Line2D.Double(x, y, x + 10, y);
                g2.setPaint(this.subrangePaint[WARNING]);
                g2.draw(line);
            }
            // draw start of critical range
            value = this.subrangeInfo[CRITICAL][RANGE_LOW];
            if (range.contains(value)) {
                double x = midX + getColumnRadius() + 2;
                double y = this.rangeAxis.valueToJava2D(value, dataArea, RectangleEdge.LEFT);
                Line2D line = new Line2D.Double(x, y, x + 10, y);
                g2.setPaint(this.subrangePaint[CRITICAL]);
                g2.draw(line);
            }
        }
        // draw the axis...
        if ((this.rangeAxis != null) && (this.axisLocation != NONE)) {
            int drawWidth = AXIS_GAP;
            if (this.showValueLines) {
                drawWidth += getColumnDiameter();
            }
            Rectangle2D drawArea;
            double cursor;
            switch(this.axisLocation) {
                case RIGHT:
                    cursor = midX + getColumnRadius();
                    drawArea = new Rectangle2D.Double(cursor, stemTop, drawWidth, (stemBottom - stemTop + 1));
                    this.rangeAxis.draw(g2, cursor, area, drawArea, RectangleEdge.RIGHT, null);
                    break;
                case LEFT:
                default:
                    // cursor = midX - COLUMN_RADIUS - AXIS_GAP;
                    cursor = midX - getColumnRadius();
                    drawArea = new Rectangle2D.Double(cursor, stemTop, drawWidth, (stemBottom - stemTop + 1));
                    this.rangeAxis.draw(g2, cursor, area, drawArea, RectangleEdge.LEFT, null);
                    break;
            }
        }
        // draw text value on screen
        g2.setFont(this.valueFont);
        g2.setPaint(this.valuePaint);
        metrics = g2.getFontMetrics();
        switch(this.valueLocation) {
            case RIGHT:
                g2.drawString(this.valueFormat.format(current), midX + getColumnRadius() + getGap(), midY);
                break;
            case LEFT:
                String valueString = this.valueFormat.format(current);
                int stringWidth = metrics.stringWidth(valueString);
                g2.drawString(valueString, midX - getColumnRadius() - getGap() - stringWidth, midY);
                break;
            case BULB:
                temp = this.valueFormat.format(current);
                i = metrics.stringWidth(temp) / 2;
                g2.drawString(temp, midX - i, stemBottom + getBulbRadius() + getGap());
                break;
            default:
        }
    /**
     */
    }
    g2.setPaint(this.thermometerPaint);
    g2.setFont(this.valueFont);
    // draw units indicator
    metrics = g2.getFontMetrics();
    int tickX1 = midX - getColumnRadius() - getGap() * 2 - metrics.stringWidth(UNITS[this.units]);
    if (tickX1 > area.getMinX()) {
        g2.drawString(UNITS[this.units], tickX1, (int) (area.getMinY() + 20));
    }
    // draw thermometer outline
    g2.setStroke(this.thermometerStroke);
    g2.draw(outerThermometer);
    g2.draw(innerThermometer);
    drawOutline(g2, area);
}
Also used : RoundRectangle2D(java.awt.geom.RoundRectangle2D) Rectangle2D(java.awt.geom.Rectangle2D) RoundRectangle2D(java.awt.geom.RoundRectangle2D) Range(org.jfree.data.Range) Line2D(java.awt.geom.Line2D) Ellipse2D(java.awt.geom.Ellipse2D) Paint(java.awt.Paint) Area(java.awt.geom.Area) FontMetrics(java.awt.FontMetrics) RectangleInsets(org.jfree.chart.api.RectangleInsets)

Aggregations

RectangleInsets (org.jfree.chart.api.RectangleInsets)58 Rectangle2D (java.awt.geom.Rectangle2D)19 Test (org.junit.jupiter.api.Test)17 Font (java.awt.Font)16 BasicStroke (java.awt.BasicStroke)14 GradientPaint (java.awt.GradientPaint)13 Paint (java.awt.Paint)9 Shape (java.awt.Shape)9 AxisState (org.jfree.chart.axis.AxisState)7 FontMetrics (java.awt.FontMetrics)6 Stroke (java.awt.Stroke)6 FontRenderContext (java.awt.font.FontRenderContext)6 LineMetrics (java.awt.font.LineMetrics)6 RectangleEdge (org.jfree.chart.api.RectangleEdge)6 AxisSpace (org.jfree.chart.axis.AxisSpace)6 ValueAxis (org.jfree.chart.axis.ValueAxis)6 StandardPieSectionLabelGenerator (org.jfree.chart.labels.StandardPieSectionLabelGenerator)6 StandardPieToolTipGenerator (org.jfree.chart.labels.StandardPieToolTipGenerator)6 AlphaComposite (java.awt.AlphaComposite)5 Composite (java.awt.Composite)5