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:org.pentaho.reporting.engine.classic.extensions.modules.sbarcodes.BarcodeWrapper.java

/**
 * Provides the computed stylesheet of the report element that contained this drawable. The stylesheet is immutable.
 *
 * @param style//from  ww  w.  j a v a  2s  .  c o m
 *          the stylesheet.
 */
public void setStyleSheet(final StyleSheet style) {
    if (style != null) {
        final String fontName = (String) style.getStyleProperty(TextStyleKeys.FONT);
        final int fontSize = style.getIntStyleProperty(TextStyleKeys.FONTSIZE, 0);
        final boolean bold = style.getBooleanStyleProperty(TextStyleKeys.BOLD);
        final boolean italics = style.getBooleanStyleProperty(TextStyleKeys.ITALIC);
        final Color foregroundColor = (Color) style.getStyleProperty(ElementStyleKeys.PAINT);
        final Color backgroundColor = (Color) style.getStyleProperty(ElementStyleKeys.BACKGROUND_COLOR);
        if (fontName != null && fontSize > 0) {
            int fontstyle = Font.PLAIN;
            if (bold) {
                fontstyle |= Font.BOLD;
            }
            if (italics) {
                fontstyle |= Font.ITALIC;
            }

            barcode.setFont(new Font(fontName, fontstyle, fontSize));
        }
        if (foregroundColor != null) {
            barcode.setForeground(foregroundColor);
        }
        if (backgroundColor != null) {
            barcode.setBackground(backgroundColor);
            barcode.setOpaque(backgroundColor.getAlpha() == 255);
        } else {
            barcode.setBackground(ALPHA);
            barcode.setOpaque(false);
        }

        scale = style.getBooleanStyleProperty(ElementStyleKeys.SCALE);
        keepAspectRatio = style.getBooleanStyleProperty(ElementStyleKeys.KEEP_ASPECT_RATIO);
    }
}

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

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

    numberOfPagesTest(1);/*from  w  w w .ja  v  a2 s. com*/

    JFreeChart chart = getChart("summary.chart1", 0);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    Assert.assertEquals("renderer", GanttRenderer.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());
    ganttChartDataTest(chart, "label", new String[] { "task1", "task2", "task3" },
            new Object[][] { { toDate(2011, 1, 1), toDate(2011, 1, 8), 1d },
                    { toDate(2011, 1, 10), toDate(2011, 1, 15), 0.5d },
                    { toDate(2011, 1, 15), toDate(2011, 1, 25), 0.8d } });
    ganttChartDataTest(chart, "serie1", new String[] { "task1", "task2", "task3" },
            new Object[][] { { toDate(2011, 1, 2), toDate(2011, 1, 9), null },
                    { toDate(2011, 1, 8), toDate(2011, 1, 14), null },
                    { toDate(2011, 1, 16), toDate(2011, 1, 20), null } });

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getCategoryPlot().getDomainAxis();
    Assert.assertEquals("task label", "task", axis.getLabel());
    Assert.assertEquals("task label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("task 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("time label", "time", axis.getLabel());
    Assert.assertEquals("time label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("time 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("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
}

From source file:Text2DTest.java

public BranchGroup createSceneGraph() {
    // Create the root of the branch graph
    BranchGroup objRoot = new BranchGroup();

    // Create a Transformgroup to scale all objects so they
    // appear in the scene.
    TransformGroup objScale = new TransformGroup();
    Transform3D t3d = new Transform3D();
    t3d.setScale(0.4);//from w ww .j ava  2 s . c  o  m
    objScale.setTransform(t3d);
    objRoot.addChild(objScale);

    // Create the transform group node and initialize it to the
    // identity. Enable the TRANSFORM_WRITE capability so that
    // our behavior code can modify it at runtime. Add it to the
    // root of the subgraph.
    TransformGroup objTrans = new TransformGroup();
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

    TransformGroup textTranslationGroup;
    Transform3D textTranslation;
    float yPos = -.5f;
    Shape3D textObject = new Text2D("Rotating Yellow Text", new Color3f(1f, 1f, 0f), "Serif", 60, Font.BOLD);
    Appearance app = textObject.getAppearance();

    PolygonAttributes pa = app.getPolygonAttributes();
    if (pa == null)
        pa = new PolygonAttributes();
    pa.setCullFace(PolygonAttributes.CULL_NONE);
    if (app.getPolygonAttributes() == null)
        app.setPolygonAttributes(pa);
    objTrans.addChild(textObject);

    textTranslation = new Transform3D();
    textTranslation.setTranslation(new Vector3f(0f, yPos, 0f));
    textTranslationGroup = new TransformGroup(textTranslation);
    textTranslationGroup.addChild(objTrans);
    objScale.addChild(textTranslationGroup);
    yPos += .5f;

    /* Blue 40point text */
    textObject = new Text2D("Blue 40point Text", new Color3f(0f, 0f, 1f), "Serif", 40, Font.BOLD);
    textTranslation = new Transform3D();
    textTranslation.setTranslation(new Vector3f(0f, yPos, 0f));
    textTranslationGroup = new TransformGroup(textTranslation);
    textTranslationGroup.addChild(textObject);
    objScale.addChild(textTranslationGroup);
    yPos += .5f;

    /* Green italic text */
    textObject = new Text2D("Green Italic Text", new Color3f(0f, 1f, 0f), "Serif", 70, Font.ITALIC);
    textTranslation = new Transform3D();
    textTranslation.setTranslation(new Vector3f(0f, yPos, 0f));
    textTranslationGroup = new TransformGroup(textTranslation);
    textTranslationGroup.addChild(textObject);
    objScale.addChild(textTranslationGroup);
    yPos += .5f;

    // Create a new Behavior object that will perform the desired
    // operation on the specified transform object and add it into
    // the scene graph.
    Transform3D yAxis = new Transform3D();
    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0);

    RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f,
            (float) Math.PI * 2.0f);
    rotator.setSchedulingBounds(bounds);
    objTrans.addChild(rotator);

    return objRoot;
}

From source file:org.eclipse.om2m.ipe.sample.gui.GUI.java

/**
 * Creates the frame./*from  ww w.  ja v  a2 s. c  o  m*/
 */
public GUI() {
    setLocationByPlatform(true);
    setVisible(false);
    setResizable(false);
    setTitle("Sample Simulated IPE");
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 500) / 2, (screenSize.height - 570) / 2, 497, 570);

    contentPanel = new JPanel();
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPanel);
    contentPanel.setLayout(null);

    // Lamp0 Switcher0
    JPanel panel_Lamp0 = new JPanel();
    panel_Lamp0.setBounds(10, 5, 319, 260);
    contentPanel.add(panel_Lamp0);
    panel_Lamp0.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
    panel_Lamp0.setLayout(null);
    LABEL_LAMP_0.setIcon(iconLampOFF);
    LABEL_LAMP_0.setHorizontalTextPosition(SwingConstants.CENTER);
    LABEL_LAMP_0.setHorizontalAlignment(SwingConstants.CENTER);
    LABEL_LAMP_0.setBounds(10, 9, 149, 240);
    panel_Lamp0.add(LABEL_LAMP_0);

    // Lamp0 Switch Button
    JButton button_Lamp0 = new JButton();
    button_Lamp0.setOpaque(false);
    button_Lamp0.setPressedIcon(iconButtonON);
    button_Lamp0.setIcon(iconButtonOFF);
    button_Lamp0.setBounds(187, 44, 122, 155);
    panel_Lamp0.add(button_Lamp0);
    button_Lamp0.setMinimumSize(new Dimension(30, 23));
    button_Lamp0.setMaximumSize(new Dimension(30, 23));
    button_Lamp0.setPreferredSize(new Dimension(30, 23));

    JLabel labelSwitcher0 = new JLabel("Switch LAMP_0");
    labelSwitcher0.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14));
    labelSwitcher0.setFocusCycleRoot(true);
    labelSwitcher0.setBorder(null);
    labelSwitcher0.setAutoscrolls(true);
    labelSwitcher0.setBounds(187, 199, 118, 29);
    panel_Lamp0.add(labelSwitcher0);
    // Listener for Lamp0 Switch Button
    button_Lamp0.addActionListener(new java.awt.event.ActionListener() {
        // Button Clicked
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            // Change Lamp0 State
            new Thread() {
                public void run() {
                    // Send switch request to switch lamp0 state
                    SampleMonitor.switchLamp(LAMP_0);
                }
            }.start();
        }
    });

    // Lamp1 Switcher 1
    JPanel panel_Lamp1 = new JPanel();
    panel_Lamp1.setBounds(10, 271, 319, 260);
    contentPanel.add(panel_Lamp1);
    panel_Lamp1.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
    panel_Lamp1.setLayout(null);

    LABEL_LAMP_1.setIcon(iconLampOFF);
    LABEL_LAMP_1.setHorizontalTextPosition(SwingConstants.CENTER);
    LABEL_LAMP_1.setHorizontalAlignment(SwingConstants.CENTER);
    LABEL_LAMP_1.setBounds(10, 9, 154, 240);
    panel_Lamp1.add(LABEL_LAMP_1);

    // Lamp1 Switch Button
    JButton button_Lamp1 = new JButton();
    button_Lamp1.setOpaque(false);
    button_Lamp1.setPressedIcon(iconButtonON);
    button_Lamp1.setIcon(iconButtonOFF);
    button_Lamp1.setBounds(187, 44, 122, 156);
    panel_Lamp1.add(button_Lamp1);
    button_Lamp1.setMinimumSize(new Dimension(30, 23));
    button_Lamp1.setMaximumSize(new Dimension(30, 23));
    button_Lamp1.setPreferredSize(new Dimension(30, 23));

    JLabel labelSwitcher1 = new JLabel("Switch LAMP_1");
    labelSwitcher1.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14));
    labelSwitcher1.setFocusCycleRoot(true);
    labelSwitcher1.setBorder(null);
    labelSwitcher1.setAutoscrolls(true);
    labelSwitcher1.setBounds(187, 199, 118, 29);
    panel_Lamp1.add(labelSwitcher1);
    // Listener for Lamp1 Switch Button
    button_Lamp1.addActionListener(new java.awt.event.ActionListener() {
        //Switch Button clicked
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            // Change Lamp1 State
            new Thread() {
                public void run() {
                    // Send switch request to switch lamp1 state
                    SampleMonitor.switchLamp(LAMP_1);
                }
            }.start();
        }
    });

    // Switcher All lamps
    JButton buttonAllLamp = new JButton();
    buttonAllLamp.setOpaque(false);
    buttonAllLamp.setPressedIcon(iconButtonON);
    buttonAllLamp.setIcon(iconButtonOFF);
    buttonAllLamp.setBounds(339, 190, 145, 168);
    contentPanel.add(buttonAllLamp);
    buttonAllLamp.setMinimumSize(new Dimension(30, 23));
    buttonAllLamp.setMaximumSize(new Dimension(30, 23));
    buttonAllLamp.setPreferredSize(new Dimension(30, 23));

    JLabel labelSwitchAll = new JLabel("Switch All");
    labelSwitchAll.setAutoscrolls(true);
    labelSwitchAll.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14));
    labelSwitchAll.setFocusCycleRoot(true);
    labelSwitchAll.setBorder(null);
    labelSwitchAll.setBounds(371, 369, 85, 29);
    contentPanel.add(labelSwitchAll);
    // Listener of Switch all Button
    buttonAllLamp.addActionListener(new java.awt.event.ActionListener() {
        // Switch Button Clicked
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            // Change all lamps states
            new Thread() {
                public void run() {
                    // Send switch all request to create a content with the current State
                    SampleMonitor.switchAll();
                }
            }.start();
        }
    });

    lampObserver = new SampleModel.LampObserver() {

        @Override
        public void onLampStateChange(String lampId, boolean state) {
            setLabel(lampId, state);
        }
    };
    SampleModel.addObserver(lampObserver);
}

From source file:MultiLineLabel.java

public void setItalic(boolean italic) {
    if (italic)//w  w  w.j ava 2 s.c  om
        fontAttributes |= Font.ITALIC;
    else
        fontAttributes &= ~Font.ITALIC;
}

From source file:ToolbarDemo.java

protected void updateMonitor() {
    int index = -1;
    for (int k = 0; k < fontMenus.length; k++) {
        if (fontMenus[k].isSelected()) {
            index = k;//from   www .  j av a  2 s.co m
            break;
        }
    }
    if (index == -1)
        return;

    if (index == 2) // Courier
    {
        boldMenu.setSelected(false);
        boldMenu.setEnabled(false);
        italicMenu.setSelected(false);
        italicMenu.setEnabled(false);
    } else {
        boldMenu.setEnabled(true);
        italicMenu.setEnabled(true);
    }

    int style = Font.PLAIN;
    if (boldMenu.isSelected())
        style |= Font.BOLD;
    if (italicMenu.isSelected())
        style |= Font.ITALIC;
    Font fn = fonts[index].deriveFont(style);
}

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

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

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

    JFreeChart chart = getChart("summary.chart1", 0);
    XYItemRenderer renderer = chart.getXYPlot().getRenderer();
    Assert.assertEquals("renderer", XYDifferenceRenderer.class, renderer.getClass());
    Assert.assertFalse("show shapes", ((XYDifferenceRenderer) renderer).getShapesVisible());
    Assert.assertEquals("positive paint", Color.BLUE, ((XYDifferenceRenderer) renderer).getPositivePaint());
    Assert.assertEquals("negative paint", Color.MAGENTA, ((XYDifferenceRenderer) renderer).getNegativePaint());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getXYPlot().getDomainAxis();
    Assert.assertEquals("category label", "time", 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());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertTrue("vertical tick labels", ((ValueAxis) axis).isVerticalTickLabels());

    chart = getChart("summary.chart3", 0);
    axis = chart.getXYPlot().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());
    Assert.assertTrue("vertical tick labels", ((ValueAxis) axis).isVerticalTickLabels());
}

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

/**
 * Creates an overlaid chart./* w w  w .java 2  s . com*/
 *
 * @return The chart.
 */
private JFreeChart createChart() {
    createDataset();
    final JFreeChart chart = ChartFactory.createXYLineChart("Real Time Network Dynamics", "Time", "Activation",
            dataset, PlotOrientation.VERTICAL, true, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    target = new IntervalMarker(14, 16);
    target.setLabel("Activation Threshold");
    target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11));
    target.setLabelAnchor(RectangleAnchor.LEFT);
    target.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    target.setPaint(new Color(222, 222, 255, 128));
    plot.addRangeMarker(target, Layer.BACKGROUND);
    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
    BasicStroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
    for (int i = 0; i < series.length - 1; i++) {
        renderer.setSeriesStroke(i, stroke);
    }
    renderer.setSeriesStroke(series.length - 1, new BasicStroke(2.0f, BasicStroke.CAP_BUTT,
            BasicStroke.JOIN_MITER, 10.0f, new float[] { 10.0f }, 0.0f));
    plot.setRenderer(renderer);
    return chart;
}

From source file:RenderQualityTest.java

public void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHints(hints);/*w  w w.j  ava  2 s. c om*/

    g2.draw(new Ellipse2D.Double(10, 10, 60, 50));
    g2.setFont(new Font("Serif", Font.ITALIC, 40));
    g2.drawString("Hello", 75, 50);

    g2.draw(new Rectangle2D.Double(200, 10, 40, 40));
    g2.draw(new Line2D.Double(201, 11, 239, 49));

    g2.drawImage(image, 250, 10, 100, 100, null);
}

From source file:MenuDemo.java

protected void updateMonitor() {
    int index = -1;
    for (int k = 0; k < menus.length; k++) {
        if (menus[k].isSelected()) {
            index = k;/*w  w w . ja v a 2s.  c o m*/
            break;
        }
    }
    if (index == -1)
        return;

    if (index == 2) // Courier
    {
        boldMenuItem.setSelected(false);
        boldMenuItem.setEnabled(false);
        italicMenuItem.setSelected(false);
        italicMenuItem.setEnabled(false);
    } else {
        boldMenuItem.setEnabled(true);
        italicMenuItem.setEnabled(true);
    }

    int style = Font.PLAIN;
    if (boldMenuItem.isSelected())
        style |= Font.BOLD;
    if (italicMenuItem.isSelected())
        style |= Font.ITALIC;
}