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:net.sf.jasperreports.engine.util.JRFontUtil.java

/**
 * Fills the supplied Map parameter with attributes copied from the JRFont parameter.
 * The attributes include the TextAttribute.FONT, which has a java.awt.Font object as value.
 * @deprecated Replaced by {@link #getAttributesWithoutAwtFont(Map, JRFont)}.
 *///from w ww.j a  v a  2  s  .  c  om
public static Map<Attribute, Object> getAttributes(Map<Attribute, Object> attributes, JRFont font,
        Locale locale) {
    //Font awtFont = getAwtFont(font);//FIXMEFONT optimize so that we don't load the AWT font for all exporters.
    Font awtFont = getAwtFontFromBundles(font.getFontName(),
            ((font.isBold() ? Font.BOLD : Font.PLAIN) | (font.isItalic() ? Font.ITALIC : Font.PLAIN)),
            font.getFontSize(), locale, true);
    if (awtFont != null) {
        attributes.put(TextAttribute.FONT, awtFont);
    }

    getAttributesWithoutAwtFont(attributes, font);

    return attributes;
}

From source file:binky.reportrunner.ui.actions.admin.GetAuditChartAction.java

@Override
@PreAuthorize("hasRole('ROLE_ADMIN')")
public String execute() throws Exception {

    // do some stuff and get a chart going
    // DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
    TimeSeriesCollection dataSet = new TimeSeriesCollection();
    List<RunnerHistoryEvent> events = auditService.getSuccessEvents(module, new Date(fromDate),
            new Date(toDate));
    Map<String, TimeSeries> serieses = new HashMap<String, TimeSeries>();
    for (RunnerHistoryEvent e : events) {
        TimeSeries s = serieses.get(e.getMethod());
        if (s == null) {
            s = new TimeSeries(e.getMethod());
            serieses.put(e.getMethod(), s);
        }//from w  w w.  j  av a2s. c  o m
        s.addOrUpdate(new Millisecond(e.getTimeStamp()), e.getRunTime());
    }
    for (TimeSeries s : serieses.values()) {
        dataSet.addSeries(s);
    }
    chart = ChartFactory.createTimeSeriesChart(module, "", "run time (ms)", dataSet, true, false, false);

    // .createLineChart("","","Run Time (ms)",dataSet,PlotOrientation.VERTICAL,
    // true,false,false);
    XYPlot linePlot = (XYPlot) chart.getPlot();
    linePlot.setDomainGridlinesVisible(true);
    linePlot.setRangeGridlinesVisible(true);
    linePlot.setRangeGridlinePaint(Color.black);
    linePlot.setDomainGridlinePaint(Color.black);
    TextTitle subTitle = new TextTitle("Successful Executions");
    subTitle.setFont(new Font("Arial", Font.ITALIC, 10));
    chart.addSubtitle(subTitle);
    chart.getTitle().setFont(new Font("Arial", Font.BOLD, 12));

    DateAxis axis = (DateAxis) linePlot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("hh:mm:ss dd-MM-yyyy"));

    XYItemRenderer r = linePlot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
    }
    chart.setAntiAlias(true);
    chart.setTextAntiAlias(true);
    return SUCCESS;
}

From source file:CheckFonts.java

/**
 * ?  ??  dialog base unit'./*from www.  j av a 2  s .  c o  m*/
 * 
 * ? :   - ?  ????  ,   - ??  ????
 *  .
 */
protected static Dimension getDimension(ResourceDialog dialog, String text) throws Exception {
    int fontPixelsSize = (int) Math.round(dialog.pointsize * 96.0 / 72);

    Font f = getDialogFont(dialog).deriveFont(dialog.italic != 0 ? Font.ITALIC : 0, fontPixelsSize);

    // BufferedImage img = new BufferedImage(1024, 512, BufferedImage.TYPE_INT_RGB);
    // Graphics gr = img.getGraphics();
    // FontMetrics fm = gr.getFontMetrics(f);
    // r = fm.stringWidth(text);

    FontRenderContext frc = new FontRenderContext(null, false, false);
    Rectangle2D strDialogUnits = f.getStringBounds("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", frc);
    // ? ???   - http://support.microsoft.com/kb/125681
    double fullWidth = strDialogUnits.getWidth();
    double fullHeight = strDialogUnits.getHeight();
    long avgWidth = Math.round(Math.ceil(fullWidth) / 26 + 1) / 2;
    long avgHeight = Math.round(Math.ceil(fullHeight));
    double dbuX = avgWidth / 4.0;
    double dbuY = avgHeight / 8.0;

    Rectangle2D strRect = f.getStringBounds(text.replace("&", ""), frc);
    int w = (int) Math.ceil(strRect.getWidth() / dbuX);

    int h = (int) Math.ceil(strRect.getHeight() / dbuY);

    return new Dimension(w, h);
}

From source file:org.jfree.chart.demo.XYSeriesDemo3.java

/**
 * Creates a sample chart./*from  w ww .  ja  va  2s. c om*/
 * 
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(IntervalXYDataset dataset) {
    final JFreeChart chart = ChartFactory.createXYBarChart("XY Series Demo", "X", false, "Y", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    final IntervalMarker target = new IntervalMarker(400.0, 700.0);
    target.setLabel("Target Range");
    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);
    return chart;
}

From source file:FontChooser.java

private String styleToString(int style) {
    String str = "";
    if ((style & Font.BOLD) == Font.BOLD) {
        if (str.length() > 0) {
            str += ",";
        }/*from www.j a  v  a 2s. c  o  m*/
        str += "Bold";
    }
    if ((style & Font.ITALIC) == Font.ITALIC) {
        if (str.length() > 0) {
            str += ",";
        }
        str += "Italic";
    }
    if (str.length() <= 0) {
        str = "Plain";
    }
    return str;
}

From source file:sernet.gs.ui.rcp.main.bsi.views.chart.RealisierungLineChart.java

private JFreeChart createProgressChart(Object dataset) {
    final double plotGap = 10.0;
    final int axisUpperBoundPadding = 50;
    final int labelFontSize = 10;
    XYDataset data1 = (XYDataset) dataset;
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis(Messages.RealisierungLineChart_1);
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis(Messages.RealisierungLineChart_2));
    plot.setGap(plotGap);/* w  w w  . j  av a2s .com*/

    plot.add(subplot1, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);

    CountMassnahmen command = new CountMassnahmen();
    try {
        command = ServiceFactory.lookupCommandService().executeCommand(command);
    } catch (CommandException e) {
        ExceptionUtil.log(e, Messages.RealisierungLineChart_3);
    }
    int totalNum = command.getTotalCount();

    NumberAxis axis = (NumberAxis) subplot1.getRangeAxis();
    axis.setUpperBound(totalNum + axisUpperBoundPadding);

    ValueMarker bst = new ValueMarker(totalNum);
    bst.setPaint(Color.GREEN);
    bst.setLabel(Messages.RealisierungLineChart_4);
    bst.setLabelAnchor(RectangleAnchor.LEFT);
    bst.setLabelFont(new Font("SansSerif", Font.ITALIC + Font.BOLD, labelFontSize)); //$NON-NLS-1$
    bst.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    subplot1.addRangeMarker(bst, Layer.BACKGROUND);

    // return a new chart containing the overlaid plot...
    JFreeChart chart = new JFreeChart(Messages.RealisierungLineChart_6, JFreeChart.DEFAULT_TITLE_FONT, plot,
            true);
    chart.setBackgroundPaint(Color.white);
    return chart;
}

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

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

    numberOfPagesTest(1);/* ww  w.  jav a  2s.c  o m*/

    JFreeChart chart = getChart("summary.chart1", 0);
    Axis axis = chart.getXYPlot().getDomainAxis();
    XYPlot plot = chart.getXYPlot();
    Assert.assertEquals("renderer", XYAreaRenderer.class, plot.getRenderer().getClass());
    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());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart2", 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());
}

From source file:ca.sqlpower.wabit.swingui.report.selectors.FancyDateSelectorField.java

public FancyDateSelectorField(final DateSelector selector, Runnable refreshRoutine) {

    this.selector = selector;
    this.refreshRoutine = refreshRoutine;
    //this.addPopupMenuListener(popupMenuListener);
    this.addActionListener(new ActionListener() {
        @Override/*from   w ww  . ja  v a 2 s .c om*/
        public void actionPerformed(ActionEvent e) {
            refreshEverything();
        }
    });
    this.selector.addSPListener(spListener);

    Date currentValue = selector.getCurrentValue() == null ? null : (Date) selector.getCurrentValue();
    setDate(currentValue);

    if (ObjectUtils.equals(getDate(), selector.getDefaultValue())) {
        setForeground(Color.GRAY);
        setFont(getFont().deriveFont(Font.ITALIC));
    } else {
        setForeground(Color.BLACK);
        setFont(getFont().deriveFont(Font.PLAIN));
    }
}

From source file:components.CheckBoxDemo.java

public CheckBoxDemo() {
    super(new BorderLayout());

    //Create the check boxes.
    chinButton = new JCheckBox("Chin");
    chinButton.setMnemonic(KeyEvent.VK_C);
    chinButton.setSelected(true);/*  w  w w.  j a  v  a2 s.c  o  m*/

    glassesButton = new JCheckBox("Glasses");
    glassesButton.setMnemonic(KeyEvent.VK_G);
    glassesButton.setSelected(true);

    hairButton = new JCheckBox("Hair");
    hairButton.setMnemonic(KeyEvent.VK_H);
    hairButton.setSelected(true);

    teethButton = new JCheckBox("Teeth");
    teethButton.setMnemonic(KeyEvent.VK_T);
    teethButton.setSelected(true);

    //Register a listener for the check boxes.
    chinButton.addItemListener(this);
    glassesButton.addItemListener(this);
    hairButton.addItemListener(this);
    teethButton.addItemListener(this);

    //Indicates what's on the geek.
    choices = new StringBuffer("cght");

    //Set up the picture label
    pictureLabel = new JLabel();
    pictureLabel.setFont(pictureLabel.getFont().deriveFont(Font.ITALIC));
    updatePicture();

    //Put the check boxes in a column in a panel
    JPanel checkPanel = new JPanel(new GridLayout(0, 1));
    checkPanel.add(chinButton);
    checkPanel.add(glassesButton);
    checkPanel.add(hairButton);
    checkPanel.add(teethButton);

    add(checkPanel, BorderLayout.LINE_START);
    add(pictureLabel, BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:com.pronoiahealth.olhie.server.services.BookCoverImageService.java

/**
 * Initialize the various maps, fonts, etc..
 *//*from w  ww .jav  a 2s  . c o  m*/
@PostConstruct
protected void postActivate() {
    try {
        // Init the coverMap and load the images
        coverMap = new HashMap<String, byte[]>();
        List<BookCover> covers = coverDisplayData.getCovers();
        for (BookCover cover : covers) {
            coverMap.put(cover.getCoverName(),
                    readResourceToByteArray("/" + cover.getImgUrl(), servletContext));
        }

        // Load needed fonts
        medulaOneRegularFont = Font.createFont(Font.TRUETYPE_FONT,
                servletContext.getResourceAsStream("/Olhie/font/MedulaOne-Regular.ttf"));
        medulaOneRegularFont48 = medulaOneRegularFont.deriveFont(new Float(48.0));
        arialBoldFont13 = new Font("Arial Bold", Font.BOLD, 13);
        arialBoldFont16 = new Font("Arial Bold", Font.ITALIC, 16);

        // Init font maps
        // author
        authorFontMap = new Hashtable<TextAttribute, Object>();
        authorFontMap.put(TextAttribute.FONT, arialBoldFont16);
        authorFontMap.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);

        // Title
        titleFontMap = new Hashtable<TextAttribute, Object>();
        titleFontMap.put(TextAttribute.FONT, medulaOneRegularFont48);
        titleFontMap.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);

        // Back cover title
        backTitleFontMap = new Hashtable<TextAttribute, Object>();
        backTitleFontMap.put(TextAttribute.FONT, arialBoldFont13);
        backTitleFontMap.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
        backTitleFontMap.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_ONE_PIXEL);

        // Build palette factory
        palFac = new PaletteFactory();

    } catch (Exception e) {
        log.log(Level.SEVERE, "Error occured during BookCoverImageService initialization.", e);
    }
}