Example usage for java.awt Font ITALIC

List of usage examples for java.awt Font ITALIC

Introduction

In this page you can find the example usage for java.awt Font ITALIC.

Prototype

int ITALIC

To view the source code for java.awt Font ITALIC.

Click Source Link

Document

The italicized style constant.

Usage

From source file:com.mxgraph.examples.swing.chart.TimeSeriesChartDemo1.java

/**
 * Creates a chart./*from   ww w  .j a  v a2 s  .c o m*/
 *
 * @param dataset  a dataset.
 *
 * @return A chart.
 */
public static JFreeChart createChart(XYDataset dataset, String name) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart(name, // title
            "Date", // x-axis label
            "Value", // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
        renderer.setItemLabelGenerator(new StandardXYItemLabelGenerator());
        renderer.setBaseItemLabelsVisible(true);
        // 
        renderer.setItemLabelsVisible(true);
        // 
        renderer.setBaseShapesVisible(true);
        // 
        renderer.setBaseShapesFilled(true);

        //  renderer.setLegendItemLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})"));

    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"/*"yyyy-MM-dd HH:mm:ss"*/));

    chart.getTitle().setFont(new Font("", Font.BOLD, 15));
    chart.getLegend().setItemFont(new Font("", Font.BOLD, 15));
    //
    plot.getRangeAxis().setLabelFont(new Font("", Font.BOLD, 15));
    //
    chart.getLegend().setItemFont(new Font("", Font.ITALIC, 15));
    //
    plot.getDomainAxis().setTickLabelFont(new Font("", 1, 15));
    //
    plot.getDomainAxis().setLabelFont(new Font("", 1, 12));

    return chart;

}

From source file:net.sf.dynamicreports.test.jasper.chart.Bar3DChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);// w  w w .  j  a v  a 2 s. c om

    JFreeChart chart = getChart("summary.chart1", 0);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    Assert.assertEquals("renderer", BarRenderer3D.class, categoryPlot.getRenderer().getClass());
    BarRenderer3D renderer = (BarRenderer3D) categoryPlot.getRenderer();
    Assert.assertTrue("show labels", renderer.getBaseItemLabelsVisible());
    Assert.assertEquals("x offset", 2d, renderer.getXOffset());
    Assert.assertEquals("y offset", 3d, renderer.getYOffset());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getCategoryPlot().getDomainAxis();
    Assert.assertEquals("category label", "category", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions()
            .getLabelPosition(RectangleEdge.LEFT);
    Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getCategoryPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}

From source file:net.sf.dynamicreports.test.jasper.chart.BarChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);//w w  w  . j  a v a2s .  c om

    JFreeChart chart = getChart("summary.chart1", 0);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    Assert.assertEquals("renderer", BarRenderer.class, categoryPlot.getRenderer().getClass());
    Assert.assertTrue("show labels", categoryPlot.getRenderer().getBaseItemLabelsVisible());
    Assert.assertFalse("show tick labels", categoryPlot.getDomainAxis().isTickMarksVisible());
    Assert.assertFalse("show tick marks", categoryPlot.getDomainAxis().isTickLabelsVisible());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getCategoryPlot().getDomainAxis();
    Assert.assertEquals("category label", "category", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions()
            .getLabelPosition(RectangleEdge.LEFT);
    Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getCategoryPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}

From source file:net.sf.dynamicreports.test.jasper.chart.StackedBarChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);/* w ww. ja  va 2s.  c  om*/

    JFreeChart chart = getChart("summary.chart1", 0);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    Assert.assertEquals("renderer", StackedBarRenderer.class, categoryPlot.getRenderer().getClass());
    Assert.assertTrue("show labels", categoryPlot.getRenderer().getBaseItemLabelsVisible());
    Assert.assertFalse("show tick labels", categoryPlot.getDomainAxis().isTickMarksVisible());
    Assert.assertFalse("show tick marks", categoryPlot.getDomainAxis().isTickLabelsVisible());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getCategoryPlot().getDomainAxis();
    Assert.assertEquals("category label", "category", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions()
            .getLabelPosition(RectangleEdge.LEFT);
    Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getCategoryPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}

From source file:org.pentaho.chart.plugin.jfreechart.dial.JFreeDialChartGeneratorIT.java

public void testScale() throws Exception {
    JFreeChart chart = getJFreeChart("testchart.xml", new Object[][] { { 8D } }); //$NON-NLS-1$
    DialPlot plot = (DialPlot) chart.getPlot();
    StandardDialScale scale = (StandardDialScale) plot.getScale(0);
    assertEquals(-20D, scale.getLowerBound());
    assertEquals(20D, scale.getUpperBound());
    assertEquals(-135D, scale.getStartAngle());
    assertEquals(-180D, scale.getExtent());

    assertEquals(5D, scale.getMajorTickIncrement());
    assertEquals(2, scale.getMinorTickCount());

    assertEquals(new Color(255, 105, 180) /*hotpink*/, scale.getTickLabelPaint());
    assertEquals(12, scale.getTickLabelFont().getSize());
    assertEquals(Font.ITALIC | Font.BOLD, scale.getTickLabelFont().getStyle());
    // had trouble getting a font comparison to work without breaking it down into size, style, and name
    assertEquals("Monospaced", scale.getTickLabelFont().getName()); //$NON-NLS-1$

    assertEquals(5F, ((BasicStroke) scale.getMajorTickStroke()).getLineWidth());
    assertEquals(3F, ((BasicStroke) scale.getMinorTickStroke()).getLineWidth());

    assertEquals(0.10D, scale.getMajorTickLength());
    assertEquals(0.05D, scale.getMinorTickLength());

}

From source file:net.sf.dynamicreports.test.jasper.chart.WaterfallBarChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);//from   w  w  w . j a  va2s. c  o  m

    JFreeChart chart = getChart("summary.chart1", 0);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    Assert.assertEquals("renderer", WaterfallBarRenderer.class, categoryPlot.getRenderer().getClass());
    Assert.assertTrue("show labels", categoryPlot.getRenderer().getBaseItemLabelsVisible());
    Assert.assertFalse("show tick labels", categoryPlot.getDomainAxis().isTickMarksVisible());
    Assert.assertFalse("show tick marks", categoryPlot.getDomainAxis().isTickLabelsVisible());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getCategoryPlot().getDomainAxis();
    Assert.assertEquals("category label", "category", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions()
            .getLabelPosition(RectangleEdge.LEFT);
    Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getCategoryPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}

From source file:net.sf.dynamicreports.test.jasper.chart.StackedBar3DChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);/* w  w w  .j  av  a2 s.  c om*/

    JFreeChart chart = getChart("summary.chart1", 0);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    Assert.assertEquals("renderer", StackedBarRenderer3D.class, categoryPlot.getRenderer().getClass());
    BarRenderer3D renderer = (BarRenderer3D) categoryPlot.getRenderer();
    Assert.assertTrue("show labels", renderer.getBaseItemLabelsVisible());
    Assert.assertEquals("x offset", 2d, renderer.getXOffset());
    Assert.assertEquals("y offset", 3d, renderer.getYOffset());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getCategoryPlot().getDomainAxis();
    Assert.assertEquals("category label", "category", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions()
            .getLabelPosition(RectangleEdge.LEFT);
    Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getCategoryPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}

From source file:wef.articulab.view.ui.BNXYPlot.java

public IntervalXYDataset refreshDataset() {
    if (behaviors != null) {
        int sizeSeries = series.length - 1;

        //keep number of samples no bigger than maxNumSamples
        if (behaviors[0].size() > maxNumSamples) {
            for (int i = 0; i < behaviors.length; i++) {
                behaviors[i].remove(0);/*from  ww  w .j ava 2 s  . co  m*/
            }
            thresholds.remove(0);
            activations.remove(0);
            offset++;
        }

        //Activation thresholds
        XYSeries ts = dataset.getSeries(series[sizeSeries]);
        ts.clear();
        for (int j = 0; j < thresholds.size(); j++) {
            ts.addOrUpdate(j + offset, thresholds.get(j).doubleValue());
        }
        target.setStartValue(minThreshold);
        target.setEndValue(maxThreshold);

        //behaviors
        for (int i = 0; i < sizeSeries; i++) {
            int size = behaviors[i].size();
            ts = dataset.getSeries(series[i]);
            ts.clear();
            for (int j = 0; j < size; j++) {
                ts.add(j + offset, behaviors[i].get(j).doubleValue());
            }
        }

        //who is activated?
        for (int x = 0; x < activations.size(); x++) {
            String name = (String) activations.get(x)[0];
            double y = (Double) activations.get(x)[1];
            if (name != null && !name.isEmpty()) {
                XYTextAnnotation annotation = new XYTextAnnotation(name, (x + offset), y);
                annotation.setFont(new Font("SansSerif", Font.ITALIC, 11));
                chart.getXYPlot().addAnnotation(annotation);
            }
        }
    }
    return dataset;
}

From source file:TextInputDemo.java

protected JComponent createAddressDisplay() {
    JPanel panel = new JPanel(new BorderLayout());
    addressDisplay = new JLabel();
    addressDisplay.setHorizontalAlignment(JLabel.CENTER);
    regularFont = addressDisplay.getFont().deriveFont(Font.PLAIN, 16.0f);
    italicFont = regularFont.deriveFont(Font.ITALIC);
    updateDisplays();/*from ww  w.jav  a2 s .  co m*/

    //Lay out the panel.
    panel.setBorder(BorderFactory.createEmptyBorder(GAP / 2, //top
            0, //left
            GAP / 2, //bottom
            0)); //right
    panel.add(new JSeparator(JSeparator.VERTICAL), BorderLayout.LINE_START);
    panel.add(addressDisplay, BorderLayout.CENTER);
    panel.setPreferredSize(new Dimension(200, 150));

    return panel;
}

From source file:org.reactome.server.tools.diagram.exporter.raster.itext.awt.DefaultFontMapper.java

private int extractAwtStyle(PdfFont font) {
    final FontNames fontNames = font.getFontProgram().getFontNames();
    int style = Font.PLAIN;
    if (fontNames.isBold())
        style |= Font.BOLD;/*w w  w  . ja v a2s.com*/
    if (fontNames.isItalic())
        style |= Font.ITALIC;
    return style;
}