use of org.jfree.chart.api.RectangleInsets in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class ChartFactory method createPieChart.
/**
* Creates a pie chart with default settings.
* <P>
* The chart object returned by this method uses a {@link PiePlot} instance
* as the plot.
*
* @param title the chart title ({@code null} permitted).
* @param dataset the dataset for the chart ({@code null} permitted).
* @param legend a flag specifying whether or not a legend is required.
* @param tooltips configure chart to generate tool tips?
* @param locale the locale ({@code null} not permitted).
*
* @return A pie chart.
*/
public static JFreeChart createPieChart(String title, PieDataset dataset, boolean legend, boolean tooltips, Locale locale) {
PiePlot plot = new PiePlot(dataset);
plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
if (tooltips) {
plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
}
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
currentTheme.apply(chart);
return chart;
}
use of org.jfree.chart.api.RectangleInsets in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class ValueMarkerTest method testEquals.
/**
* Confirm that the equals method can distinguish all the required fields.
*/
@Test
public void testEquals() {
Marker m1 = new ValueMarker(45.0);
Marker m2 = new ValueMarker(45.0);
assertEquals(m1, m2);
assertEquals(m2, m1);
m1.setPaint(new GradientPaint(1.0f, 2.0f, Color.GREEN, 3.0f, 4.0f, Color.RED));
assertNotEquals(m1, m2);
m2.setPaint(new GradientPaint(1.0f, 2.0f, Color.GREEN, 3.0f, 4.0f, Color.RED));
assertEquals(m1, m2);
BasicStroke stroke = new BasicStroke(2.2f);
m1.setStroke(stroke);
assertNotEquals(m1, m2);
m2.setStroke(stroke);
assertEquals(m1, m2);
m1.setOutlinePaint(new GradientPaint(4.0f, 3.0f, Color.YELLOW, 2.0f, 1.0f, Color.WHITE));
assertNotEquals(m1, m2);
m2.setOutlinePaint(new GradientPaint(4.0f, 3.0f, Color.YELLOW, 2.0f, 1.0f, Color.WHITE));
assertEquals(m1, m2);
m1.setOutlineStroke(stroke);
assertNotEquals(m1, m2);
m2.setOutlineStroke(stroke);
assertEquals(m1, m2);
m1.setAlpha(0.1f);
assertNotEquals(m1, m2);
m2.setAlpha(0.1f);
assertEquals(m1, m2);
m1.setLabel("New Label");
assertNotEquals(m1, m2);
m2.setLabel("New Label");
assertEquals(m1, m2);
m1.setLabelFont(new Font("SansSerif", Font.PLAIN, 10));
assertNotEquals(m1, m2);
m2.setLabelFont(new Font("SansSerif", Font.PLAIN, 10));
assertEquals(m1, m2);
m1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.YELLOW));
assertNotEquals(m1, m2);
m2.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.YELLOW));
assertEquals(m1, m2);
m1.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
assertNotEquals(m1, m2);
m2.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
assertEquals(m1, m2);
m1.setLabelTextAnchor(TextAnchor.BASELINE_RIGHT);
assertNotEquals(m1, m2);
m2.setLabelTextAnchor(TextAnchor.BASELINE_RIGHT);
assertEquals(m1, m2);
m1.setLabelOffset(new RectangleInsets(10.0, 10.0, 10.0, 10.0));
assertNotEquals(m1, m2);
m2.setLabelOffset(new RectangleInsets(10.0, 10.0, 10.0, 10.0));
assertEquals(m1, m2);
m1.setLabelOffsetType(LengthAdjustmentType.EXPAND);
assertNotEquals(m1, m2);
m2.setLabelOffsetType(LengthAdjustmentType.EXPAND);
assertEquals(m1, m2);
m1 = new ValueMarker(12.3);
m2 = new ValueMarker(45.6);
assertNotEquals(m1, m2);
m2 = new ValueMarker(12.3);
assertEquals(m1, m2);
}
use of org.jfree.chart.api.RectangleInsets in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class XYPlotTest method testEquals.
/**
* Some checks for the equals() method.
*/
@Test
public void testEquals() {
XYPlot<String> plot1 = new XYPlot<>();
XYPlot<String> plot2 = new XYPlot<>();
assertEquals(plot1, plot2);
// orientation...
plot1.setOrientation(PlotOrientation.HORIZONTAL);
assertNotEquals(plot1, plot2);
plot2.setOrientation(PlotOrientation.HORIZONTAL);
assertEquals(plot1, plot2);
// axisOffset...
plot1.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05));
assertNotEquals(plot1, plot2);
plot2.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05));
assertEquals(plot1, plot2);
// domainAxis...
plot1.setDomainAxis(new NumberAxis("Domain Axis"));
assertNotEquals(plot1, plot2);
plot2.setDomainAxis(new NumberAxis("Domain Axis"));
assertEquals(plot1, plot2);
// domainAxisLocation...
plot1.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
assertNotEquals(plot1, plot2);
plot2.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
assertEquals(plot1, plot2);
// secondary DomainAxes...
plot1.setDomainAxis(11, new NumberAxis("Secondary Domain Axis"));
assertNotEquals(plot1, plot2);
plot2.setDomainAxis(11, new NumberAxis("Secondary Domain Axis"));
assertEquals(plot1, plot2);
// secondary DomainAxisLocations...
plot1.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
assertNotEquals(plot1, plot2);
plot2.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
assertEquals(plot1, plot2);
// rangeAxis...
plot1.setRangeAxis(new NumberAxis("Range Axis"));
assertNotEquals(plot1, plot2);
plot2.setRangeAxis(new NumberAxis("Range Axis"));
assertEquals(plot1, plot2);
// rangeAxisLocation...
plot1.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);
assertNotEquals(plot1, plot2);
plot2.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);
assertEquals(plot1, plot2);
// secondary RangeAxes...
plot1.setRangeAxis(11, new NumberAxis("Secondary Range Axis"));
assertNotEquals(plot1, plot2);
plot2.setRangeAxis(11, new NumberAxis("Secondary Range Axis"));
assertEquals(plot1, plot2);
// secondary RangeAxisLocations...
plot1.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
assertNotEquals(plot1, plot2);
plot2.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
assertEquals(plot1, plot2);
// secondary DatasetDomainAxisMap...
plot1.mapDatasetToDomainAxis(11, 11);
assertNotEquals(plot1, plot2);
plot2.mapDatasetToDomainAxis(11, 11);
assertEquals(plot1, plot2);
// secondaryDatasetRangeAxisMap...
plot1.mapDatasetToRangeAxis(11, 11);
assertNotEquals(plot1, plot2);
plot2.mapDatasetToRangeAxis(11, 11);
assertEquals(plot1, plot2);
// renderer
plot1.setRenderer(new DefaultXYItemRenderer());
assertNotEquals(plot1, plot2);
plot2.setRenderer(new DefaultXYItemRenderer());
assertEquals(plot1, plot2);
// secondary renderers
plot1.setRenderer(11, new DefaultXYItemRenderer());
assertNotEquals(plot1, plot2);
plot2.setRenderer(11, new DefaultXYItemRenderer());
assertEquals(plot1, plot2);
// domainGridlinesVisible
plot1.setDomainGridlinesVisible(false);
assertNotEquals(plot1, plot2);
plot2.setDomainGridlinesVisible(false);
assertEquals(plot1, plot2);
// domainGridlineStroke
Stroke stroke = new BasicStroke(2.0f);
plot1.setDomainGridlineStroke(stroke);
assertNotEquals(plot1, plot2);
plot2.setDomainGridlineStroke(stroke);
assertEquals(plot1, plot2);
// domainGridlinePaint
plot1.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.RED));
assertNotEquals(plot1, plot2);
plot2.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.RED));
assertEquals(plot1, plot2);
// rangeGridlinesVisible
plot1.setRangeGridlinesVisible(false);
assertNotEquals(plot1, plot2);
plot2.setRangeGridlinesVisible(false);
assertEquals(plot1, plot2);
// rangeGridlineStroke
plot1.setRangeGridlineStroke(stroke);
assertNotEquals(plot1, plot2);
plot2.setRangeGridlineStroke(stroke);
assertEquals(plot1, plot2);
// rangeGridlinePaint
plot1.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.GREEN, 3.0f, 4.0f, Color.RED));
assertNotEquals(plot1, plot2);
plot2.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.GREEN, 3.0f, 4.0f, Color.RED));
assertEquals(plot1, plot2);
// rangeZeroBaselineVisible
plot1.setRangeZeroBaselineVisible(true);
assertNotEquals(plot1, plot2);
plot2.setRangeZeroBaselineVisible(true);
assertEquals(plot1, plot2);
// rangeZeroBaselineStroke
plot1.setRangeZeroBaselineStroke(stroke);
assertNotEquals(plot1, plot2);
plot2.setRangeZeroBaselineStroke(stroke);
assertEquals(plot1, plot2);
// rangeZeroBaselinePaint
plot1.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.RED));
assertNotEquals(plot1, plot2);
plot2.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.RED));
assertEquals(plot1, plot2);
// rangeCrosshairVisible
plot1.setRangeCrosshairVisible(true);
assertNotEquals(plot1, plot2);
plot2.setRangeCrosshairVisible(true);
assertEquals(plot1, plot2);
// rangeCrosshairValue
plot1.setRangeCrosshairValue(100.0);
assertNotEquals(plot1, plot2);
plot2.setRangeCrosshairValue(100.0);
assertEquals(plot1, plot2);
// rangeCrosshairStroke
plot1.setRangeCrosshairStroke(stroke);
assertNotEquals(plot1, plot2);
plot2.setRangeCrosshairStroke(stroke);
assertEquals(plot1, plot2);
// rangeCrosshairPaint
plot1.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.PINK, 3.0f, 4.0f, Color.RED));
assertNotEquals(plot1, plot2);
plot2.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.PINK, 3.0f, 4.0f, Color.RED));
assertEquals(plot1, plot2);
// rangeCrosshairLockedOnData
plot1.setRangeCrosshairLockedOnData(false);
assertNotEquals(plot1, plot2);
plot2.setRangeCrosshairLockedOnData(false);
assertEquals(plot1, plot2);
// range markers
plot1.addRangeMarker(new ValueMarker(4.0));
assertNotEquals(plot1, plot2);
plot2.addRangeMarker(new ValueMarker(4.0));
assertEquals(plot1, plot2);
// secondary range markers
plot1.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND);
assertNotEquals(plot1, plot2);
plot2.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND);
assertEquals(plot1, plot2);
plot1.addRangeMarker(1, new ValueMarker(99.0), Layer.BACKGROUND);
assertNotEquals(plot1, plot2);
plot2.addRangeMarker(1, new ValueMarker(99.0), Layer.BACKGROUND);
assertEquals(plot1, plot2);
// fixed legend items
plot1.setFixedLegendItems(new LegendItemCollection());
assertNotEquals(plot1, plot2);
plot2.setFixedLegendItems(new LegendItemCollection());
assertEquals(plot1, plot2);
// weight
plot1.setWeight(3);
assertNotEquals(plot1, plot2);
plot2.setWeight(3);
assertEquals(plot1, plot2);
// quadrant origin
plot1.setQuadrantOrigin(new Point2D.Double(12.3, 45.6));
assertNotEquals(plot1, plot2);
plot2.setQuadrantOrigin(new Point2D.Double(12.3, 45.6));
assertEquals(plot1, plot2);
// quadrant paint
plot1.setQuadrantPaint(0, new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE));
assertNotEquals(plot1, plot2);
plot2.setQuadrantPaint(0, new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE));
assertEquals(plot1, plot2);
plot1.setQuadrantPaint(1, new GradientPaint(2.0f, 3.0f, Color.RED, 4.0f, 5.0f, Color.BLUE));
assertNotEquals(plot1, plot2);
plot2.setQuadrantPaint(1, new GradientPaint(2.0f, 3.0f, Color.RED, 4.0f, 5.0f, Color.BLUE));
assertEquals(plot1, plot2);
plot1.setQuadrantPaint(2, new GradientPaint(3.0f, 4.0f, Color.RED, 5.0f, 6.0f, Color.BLUE));
assertNotEquals(plot1, plot2);
plot2.setQuadrantPaint(2, new GradientPaint(3.0f, 4.0f, Color.RED, 5.0f, 6.0f, Color.BLUE));
assertEquals(plot1, plot2);
plot1.setQuadrantPaint(3, new GradientPaint(4.0f, 5.0f, Color.RED, 6.0f, 7.0f, Color.BLUE));
assertNotEquals(plot1, plot2);
plot2.setQuadrantPaint(3, new GradientPaint(4.0f, 5.0f, Color.RED, 6.0f, 7.0f, Color.BLUE));
assertEquals(plot1, plot2);
plot1.setDomainTickBandPaint(Color.RED);
assertNotEquals(plot1, plot2);
plot2.setDomainTickBandPaint(Color.RED);
assertEquals(plot1, plot2);
plot1.setRangeTickBandPaint(Color.BLUE);
assertNotEquals(plot1, plot2);
plot2.setRangeTickBandPaint(Color.BLUE);
assertEquals(plot1, plot2);
plot1.setDomainMinorGridlinesVisible(true);
assertNotEquals(plot1, plot2);
plot2.setDomainMinorGridlinesVisible(true);
assertEquals(plot1, plot2);
plot1.setDomainMinorGridlinePaint(Color.RED);
assertNotEquals(plot1, plot2);
plot2.setDomainMinorGridlinePaint(Color.RED);
assertEquals(plot1, plot2);
plot1.setDomainGridlineStroke(new BasicStroke(1.1f));
assertNotEquals(plot1, plot2);
plot2.setDomainGridlineStroke(new BasicStroke(1.1f));
assertEquals(plot1, plot2);
plot1.setRangeMinorGridlinesVisible(true);
assertNotEquals(plot1, plot2);
plot2.setRangeMinorGridlinesVisible(true);
assertEquals(plot1, plot2);
plot1.setRangeMinorGridlinePaint(Color.BLUE);
assertNotEquals(plot1, plot2);
plot2.setRangeMinorGridlinePaint(Color.BLUE);
assertEquals(plot1, plot2);
plot1.setRangeMinorGridlineStroke(new BasicStroke(1.23f));
assertNotEquals(plot1, plot2);
plot2.setRangeMinorGridlineStroke(new BasicStroke(1.23f));
assertEquals(plot1, plot2);
List<Integer> axisIndices = Arrays.asList(new Integer[] { 0, 1 });
plot1.mapDatasetToDomainAxes(0, axisIndices);
assertNotEquals(plot1, plot2);
plot2.mapDatasetToDomainAxes(0, axisIndices);
assertEquals(plot1, plot2);
plot1.mapDatasetToRangeAxes(0, axisIndices);
assertNotEquals(plot1, plot2);
plot2.mapDatasetToRangeAxes(0, axisIndices);
assertEquals(plot1, plot2);
// shadowGenerator
plot1.setShadowGenerator(new DefaultShadowGenerator(5, Color.GRAY, 0.6f, 4, -Math.PI / 4));
assertNotEquals(plot1, plot2);
plot2.setShadowGenerator(new DefaultShadowGenerator(5, Color.GRAY, 0.6f, 4, -Math.PI / 4));
assertEquals(plot1, plot2);
plot1.setShadowGenerator(null);
assertNotEquals(plot1, plot2);
plot2.setShadowGenerator(null);
assertEquals(plot1, plot2);
LegendItemCollection lic1 = new LegendItemCollection();
lic1.add(new LegendItem("XYZ", Color.RED));
plot1.setFixedLegendItems(lic1);
assertNotEquals(plot1, plot2);
LegendItemCollection lic2 = new LegendItemCollection();
lic2.add(new LegendItem("XYZ", Color.RED));
plot2.setFixedLegendItems(lic2);
assertEquals(plot1, plot2);
}
use of org.jfree.chart.api.RectangleInsets in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class DialValueIndicatorTest method testEquals.
/**
* Confirm that the equals method can distinguish all the required fields.
*/
@Test
public void testEquals() {
DialValueIndicator i1 = new DialValueIndicator(0);
DialValueIndicator i2 = new DialValueIndicator(0);
assertEquals(i1, i2);
// dataset index
i1.setDatasetIndex(99);
assertNotEquals(i1, i2);
i2.setDatasetIndex(99);
assertEquals(i1, i2);
// angle
i1.setAngle(43);
assertNotEquals(i1, i2);
i2.setAngle(43);
assertEquals(i1, i2);
// radius
i1.setRadius(0.77);
assertNotEquals(i1, i2);
i2.setRadius(0.77);
assertEquals(i1, i2);
// frameAnchor
i1.setFrameAnchor(RectangleAnchor.TOP_LEFT);
assertNotEquals(i1, i2);
i2.setFrameAnchor(RectangleAnchor.TOP_LEFT);
assertEquals(i1, i2);
// templateValue
i1.setTemplateValue(1.23);
assertNotEquals(i1, i2);
i2.setTemplateValue(1.23);
assertEquals(i1, i2);
// font
i1.setFont(new Font("Dialog", Font.PLAIN, 7));
assertNotEquals(i1, i2);
i2.setFont(new Font("Dialog", Font.PLAIN, 7));
assertEquals(i1, i2);
// paint
i1.setPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.GREEN));
assertNotEquals(i1, i2);
i2.setPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.GREEN));
assertEquals(i1, i2);
// backgroundPaint
i1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.GREEN));
assertNotEquals(i1, i2);
i2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.GREEN));
assertEquals(i1, i2);
// outlineStroke
i1.setOutlineStroke(new BasicStroke(1.1f));
assertNotEquals(i1, i2);
i2.setOutlineStroke(new BasicStroke(1.1f));
assertEquals(i1, i2);
// outlinePaint
i1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.GREEN));
assertNotEquals(i1, i2);
i2.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.GREEN));
assertEquals(i1, i2);
// insets
i1.setInsets(new RectangleInsets(1, 2, 3, 4));
assertNotEquals(i1, i2);
i2.setInsets(new RectangleInsets(1, 2, 3, 4));
assertEquals(i1, i2);
// valueAnchor
i1.setValueAnchor(RectangleAnchor.BOTTOM_LEFT);
assertNotEquals(i1, i2);
i2.setValueAnchor(RectangleAnchor.BOTTOM_LEFT);
assertEquals(i1, i2);
// textAnchor
i1.setTextAnchor(TextAnchor.TOP_LEFT);
assertNotEquals(i1, i2);
i2.setTextAnchor(TextAnchor.TOP_LEFT);
assertEquals(i1, i2);
// check an inherited attribute
i1.setVisible(false);
assertNotEquals(i1, i2);
i2.setVisible(false);
assertEquals(i1, i2);
}
use of org.jfree.chart.api.RectangleInsets in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class DateAxis method estimateMaximumTickLabelHeight.
/**
* Estimates the maximum width of the tick labels, assuming the specified
* tick unit is used.
* <P>
* Rather than computing the string bounds of every tick on the axis, we
* just look at two values: the lower bound and the upper bound for the
* axis. These two values will usually be representative.
*
* @param g2 the graphics device.
* @param unit the tick unit to use for calculation.
*
* @return The estimated maximum width of the tick labels.
*/
private double estimateMaximumTickLabelHeight(Graphics2D g2, DateTickUnit unit) {
RectangleInsets tickLabelInsets = getTickLabelInsets();
double result = tickLabelInsets.getTop() + tickLabelInsets.getBottom();
Font tickLabelFont = getTickLabelFont();
FontRenderContext frc = g2.getFontRenderContext();
LineMetrics lm = tickLabelFont.getLineMetrics("ABCxyz", frc);
if (!isVerticalTickLabels()) {
// all tick labels have the same width (equal to the height of
// the font)...
result += lm.getHeight();
} else {
// look at lower and upper bounds...
DateRange range = (DateRange) getRange();
Date lower = range.getLowerDate();
Date upper = range.getUpperDate();
String lowerStr, upperStr;
DateFormat formatter = getDateFormatOverride();
if (formatter != null) {
lowerStr = formatter.format(lower);
upperStr = formatter.format(upper);
} else {
lowerStr = unit.dateToString(lower);
upperStr = unit.dateToString(upper);
}
FontMetrics fm = g2.getFontMetrics(tickLabelFont);
double w1 = fm.stringWidth(lowerStr);
double w2 = fm.stringWidth(upperStr);
result += Math.max(w1, w2);
}
return result;
}
Aggregations