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.gumtree.vis.mask.ChartMaskingUtilities.java

private static void drawMaskName(Graphics2D g2, AbstractMask mask, Rectangle2D imageArea, double fontSizeRate) {
    if (mask.getName() == null) {
        return;/*from   w  ww .  j  a  v a 2  s .  c om*/
    }
    Point2D fontLocation = mask.getTitleLocation(imageArea);
    g2.setPaint(Color.black);
    Font currentFont = g2.getFont();
    g2.setFont(currentFont.deriveFont((float) (maskNameFont.getSize() * fontSizeRate)).deriveFont(Font.ITALIC));
    g2.drawString(mask.getName(), (int) fontLocation.getX(), (int) fontLocation.getY());
    g2.setFont(currentFont);
}

From source file:skoa.helpers.ConfiguracionGraficas.java

private void reestablecerPaneles() {
    datos.removeAll();/*from   www  .  j  a v a  2 s . c  om*/
    panel.removeAll(); //Borra todo lo del panel para inicializarlo de nuevo
    panel = new JPanel(); //NECESARIO CREARLO DE NUEVO.SINO, LA VISTA SE VE MAL Y NO CAMBIA HASTA CAMBIAR EL TAMAO DE LA VENTANA 
    panel.setLayout(new GridLayout(2, 1));
    panel.setBorder(BorderFactory.createEtchedBorder());
    //Seleccion de ficheros
    nfich = new JTextField();
    nfich.setEditable(false);
    rfich = new JTextField();
    fichero.removeAll();
    e = new ElectorFicheros();
    abrir = e.openButton;
    abrir.setEnabled(false); //Al principio, se desactiva, hasta que no se elija un tipo de consulta.
    boton3.setEnabled(false);
    fichero.add(abrir);
    fichero.add(nfich);
    fichero.add(boton3);
    //Panel opciones: tipos de consulta y seleccion de DGs.
    dual.setSelected(false);//CheckBox para ver si se muestra la grafica con doble eje
    JPanel dualA = new JPanel();
    dualA.setLayout(new GridLayout(1, 3));
    JLabel aux = new JLabel("Opcin de visualizacin: ");
    aux.setFont(new Font("Dialog", Font.ITALIC, 12));
    dualA.add(aux);
    dualA.add(dual);
    dualA.add(new JPanel());
    opciones.removeAll();
    opciones2.removeAll();
    c1.setSelected(false);
    c2.setSelected(false);
    c3.setSelected(false);
    c4.setSelected(false);
    opciones.add(dualA);
    opciones.add(c1);
    opciones.add(c2);
    opciones.add(c3);
    opciones.add(c4);
    opciones.add(new JPanel()); //Lugar en que van las subopciones de la consulta D
    ndirs.setEditable(false);
    ndirs.setSelectedIndex(0);
    dirs.removeAll();
    dirs.add(l3);
    dirs.add(ndirs); //n direcciones de grupo
    dirs.add(boton2);
    opciones.add(dirs);
    listado.setEditable(true);
    listado.setSelectedIndex(0);
    dirs2.removeAll();
    dirs2.add(l4);
    dirs2.add(listado);
    dirs2.add(boton1);
    opciones.add(dirs2);
    opciones2.add(fichero); //Lugar en que va la seleccion de los resultados de una consulta ya hecha.
    tipos2.removeAll();
    c4a.setSelected(false);
    c4b.setSelected(false);
    tipos2.add(c4a);
    tipos2.add(c4b);
    tipos2.add(new JPanel());
    //Inicializaciones de los paneles de fechas.
    fechas.removeAll();
    JLabel l2 = new JLabel("  Fechas: ");
    l2.setFont(new Font("Tahoma", Font.BOLD, 12));
    f1.setSelected(false);
    f2.setSelected(false);
    fechas.add(l2);
    fechas.add(f1);
    fechas.add(f2);
    fechaI.removeAll();
    JLabel l5 = new JLabel("Fecha inicial:");
    l5.setFont(new Font("Tahoma", Font.PLAIN, 12));
    fi = new JTextField(16);
    JLabel laux = new JLabel("<aaaa-mm-dd>         ");
    laux.setFont(new Font("Tahoma", Font.ITALIC, 10));
    fechaI.add(l5);
    fechaI.add(fi);
    fechaI.add(laux);
    //fecha final y [rango | nada]
    fechaF.removeAll();
    JLabel l6 = new JLabel("Fecha final:  ");
    l6.setFont(new Font("Tahoma", Font.PLAIN, 12));
    ff = new JTextField(16);
    laux = new JLabel("<aaaa-mm-dd hh:mm>");
    laux.setFont(new Font("Tahoma", Font.ITALIC, 10));
    fechaF.add(l6);
    fechaF.add(ff);
    fechaF.add(laux);
    //Otras inicializaciones:
    r = new JTextField(16);
    c = cd = nd = nd1 = f = 0;
    direcciones.removeAllElements();
    direcciones = new Vector<String>();
    boton3.setEnabled(false);
    //CARGA LA VISTA REESTABLECIDA
    panel.add(opciones);
    panel.add(opciones2);
}

From source file:edu.gmu.cs.sim.util.media.chart.ChartGenerator.java

/** Generates a new ChartGenerator with a blank chart.  Before anything else, buildChart() is called.  */
public ChartGenerator() {
    // create the chart
    buildChart();//from   w w w.  j  a  v  a  2  s  .  co  m
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.setAntiAlias(true);

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    split.setBorder(new EmptyBorder(0, 0, 0, 0));
    JScrollPane scroll = new JScrollPane();
    JPanel b = new JPanel();
    b.setLayout(new BorderLayout());
    b.add(seriesAttributes, BorderLayout.NORTH);
    b.add(new JPanel(), BorderLayout.CENTER);
    scroll.getViewport().setView(b);
    scroll.setBackground(getBackground());
    scroll.getViewport().setBackground(getBackground());
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());

    LabelledList list = new LabelledList("Chart Properties");
    DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list);
    globalAttributes.add(pan1);

    JLabel j = new JLabel("Right-Click or Control-Click");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);
    j = new JLabel("on Chart for More Options");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);

    titleField = new PropertyField() {
        public String newValue(String newValue) {
            setTitle(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    titleField.setValue(chart.getTitle().getText());

    list.add(new JLabel("Title"), titleField);

    buildGlobalAttributes(list);

    final JCheckBox legendCheck = new JCheckBox();
    ItemListener il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                LegendTitle title = new LegendTitle(chart.getPlot());
                title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4));
                chart.addLegend(title);
            } else {
                chart.removeLegend();
            }
        }
    };
    legendCheck.addItemListener(il);
    list.add(new JLabel("Legend"), legendCheck);
    legendCheck.setSelected(true);

    /*
      final JCheckBox aliasCheck = new JCheckBox();
      aliasCheck.setSelected(chart.getAntiAlias());
      il = new ItemListener()
      {
      public void itemStateChanged(ItemEvent e)
      {
      chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED );
      }
      };
      aliasCheck.addItemListener(il);
      list.add(new JLabel("Antialias"), aliasCheck);
    */

    JPanel pdfButtonPanel = new JPanel();
    pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output"));
    DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel);

    pdfButtonPanel.setLayout(new BorderLayout());
    Box pdfbox = new Box(BoxLayout.Y_AXIS);
    pdfButtonPanel.add(pdfbox, BorderLayout.WEST);

    JButton pdfButton = new JButton("Save as PDF");
    pdfbox.add(pdfButton);
    pdfButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE);
            fd.setFile(chart.getTitle().getText() + ".pdf");
            fd.setVisible(true);
            String fileName = fd.getFile();
            if (fileName != null) {
                Dimension dim = chartPanel.getPreferredSize();
                PDFEncoder.generatePDF(chart, dim.width, dim.height,
                        new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf")));
            }
        }
    });
    movieButton = new JButton("Create a Movie");
    pdfbox.add(movieButton);
    pdfbox.add(Box.createGlue());
    movieButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (movieMaker == null) {
                startMovie();
            } else {
                stopMovie();
            }
        }
    });

    globalAttributes.add(pan2);

    // we add into an outer box so we can later on add more global seriesAttributes
    // as the user instructs and still have glue be last
    Box outerAttributes = Box.createVerticalBox();
    outerAttributes.add(globalAttributes);
    outerAttributes.add(Box.createGlue());

    p.add(outerAttributes, BorderLayout.NORTH);
    p.add(scroll, BorderLayout.CENTER);
    p.setMinimumSize(new Dimension(0, 0));
    p.setPreferredSize(new Dimension(200, 0));
    split.setLeftComponent(p);

    // Add scale and proportion fields
    Box header = Box.createHorizontalBox();

    final double MAXIMUM_SCALE = 8;

    fixBox = new JCheckBox("Fill");
    fixBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setFixed(fixBox.isSelected());
        }
    });
    header.add(fixBox);
    fixBox.setSelected(true);

    // add the scale field
    scaleField = new NumberTextField("  Scale: ", 1.0, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0) {
                newValue = currentValue;
            }
            if (newValue > MAXIMUM_SCALE) {
                newValue = currentValue;
            }
            scale = newValue;
            resizeChart();
            return newValue;
        }
    };
    scaleField.setToolTipText("Zoom in and out");
    scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    scaleField.setEnabled(false);
    scaleField.setText("");
    header.add(scaleField);

    // add the proportion field
    proportionField = new NumberTextField("  Proportion: ", 1.5, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0) {
                newValue = currentValue;
            }
            proportion = newValue;
            resizeChart();
            return newValue;
        }
    };
    proportionField.setToolTipText("Change the chart proportions (ratio of width to height)");
    proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    header.add(proportionField);

    chartHolder.setMinimumSize(new Dimension(0, 0));
    chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    chartHolder.getViewport().setBackground(Color.gray);
    JPanel p2 = new JPanel();
    p2.setLayout(new BorderLayout());
    p2.add(chartHolder, BorderLayout.CENTER);
    p2.add(header, BorderLayout.NORTH);
    split.setRightComponent(p2);
    setLayout(new BorderLayout());
    add(split, BorderLayout.CENTER);

    // set the default to be white, which looks good when printed
    chart.setBackgroundPaint(Color.WHITE);

    // JFreeChart has a hillariously broken way of handling font scaling.
    // It allows fonts to scale independently in X and Y.  We hack a workaround here.
    chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION),
            (int) (DEFAULT_CHART_HEIGHT)));
}

From source file:net.sf.jasperreports.engine.fonts.FontUtil.java

protected Font getAwtFont(FontInfo fontInfo, int style, float size, boolean ignoreMissingFont) {
    @SuppressWarnings("unused")
    int faceStyle = Font.PLAIN;
    FontFamily family = fontInfo.getFontFamily();
    FontFace face = fontInfo.getFontFace();
    if (face == null) {
        if (((style & Font.BOLD) > 0) && ((style & Font.ITALIC) > 0)) {
            face = family.getBoldItalicFace();
            faceStyle = Font.BOLD | Font.ITALIC;
        }//from   ww  w  .ja v  a2s  .co  m

        if ((face == null || face.getFont() == null) && ((style & Font.BOLD) > 0)) {
            face = family.getBoldFace();
            faceStyle = Font.BOLD;
        }

        if ((face == null || face.getFont() == null) && ((style & Font.ITALIC) > 0)) {
            face = family.getItalicFace();
            faceStyle = Font.ITALIC;
        }

        if (face == null || face.getFont() == null) {
            face = family.getNormalFace();
            faceStyle = Font.PLAIN;
        }

        //         if (face == null)
        //         {
        //            throw new JRRuntimeException("Font family '" + family.getName() + "' does not have the normal font face.");
        //         }
    } else {
        faceStyle = fontInfo.getStyle();
    }

    Font awtFont;
    if (face == null || face.getFont() == null) {
        // None of the family's font faces was found to match, neither by name, nor by style and the font family does not even specify a normal face font.
        // In such case, we take the family name and consider it as JVM available font name.
        checkAwtFont(family.getName(), ignoreMissingFont);

        awtFont = new Font(family.getName(), style, (int) size);
        awtFont = awtFont.deriveFont(size);
    } else {
        awtFont = face.getFont();
        if (awtFont == null) {
            throw new JRRuntimeException(EXCEPTION_MESSAGE_KEY_NULL_FONT,
                    new Object[] { face.getName(), family.getName() });
        }

        //deriving with style and size in one call, because deriving with size and then style loses the float size
        awtFont = awtFont.deriveFont(style, size);// & ~faceStyle);
    }
    return awtFont;
}

From source file:processing.app.Theme.java

public static Map<String, Object> getStyledFont(String what, Font font) {
    String split[] = get("editor." + what + ".style").split(",");

    Color color = PreferencesHelper.parseColor(split[0]);

    String style = split[1];/*  ww  w  .  j  a va2  s .c om*/
    boolean bold = style.contains("bold");
    boolean italic = style.contains("italic");
    boolean underlined = style.contains("underlined");

    Font styledFont = new Font(font.getFamily(), (bold ? Font.BOLD : 0) | (italic ? Font.ITALIC : 0),
            font.getSize());
    if (underlined) {
        Map<TextAttribute, Object> attr = new Hashtable<>();
        attr.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
        styledFont = styledFont.deriveFont(attr);
    }

    Map<String, Object> result = new HashMap<>();
    result.put("color", color);
    result.put("font", styledFont);

    return result;
}

From source file:FontChooser.java

private void jStyleActionPerformed(java.awt.event.ActionEvent evt) {
    // Add your handling code here:
    StringTokenizer st = new StringTokenizer(jStyle.getText(), ",");
    int style = 0;
    while (st.hasMoreTokens()) {
        String str = st.nextToken().trim();
        if (str.equalsIgnoreCase("Plain")) {
            style |= Font.PLAIN;/*from   w  w  w . ja  va  2  s . c o m*/
        } else if (str.equalsIgnoreCase("Bold")) {
            style |= Font.BOLD;
        } else if (str.equalsIgnoreCase("Italic")) {
            style |= Font.ITALIC;
        }
    }
    if (style >= 0) {
        currentStyle = style;
        setSampleFont();
    }
}

From source file:lcmc.common.ui.EditableInfo.java

/** Returns a more panel with "more options are available" message. */
public final JPanel getMoreOptionsPanel(final int width) {
    final JLabel l = new JLabel(Tools.getString("EditableInfo.MoreOptions"));
    final Font font = l.getFont();
    final String name = font.getFontName();
    final int style = Font.ITALIC;
    final int size = font.getSize();
    l.setFont(new Font(name, style, size - 3));

    moreOptionsPanel.setBackground(Browser.PANEL_BACKGROUND);
    moreOptionsPanel.add(l);/*from ww  w.jav a2s .c o m*/
    final Dimension d = moreOptionsPanel.getPreferredSize();
    d.width = width;
    moreOptionsPanel.setMaximumSize(d);
    return moreOptionsPanel;
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.BarLineChartExpression.java

private String convertFontToString(final Font font) {
    if (font == null) {
        return null;
    }//ww  w.  j a va2  s  . co m

    final String fontName = font.getFamily();
    final int fontSize = font.getSize();
    final int fontStyle = font.getStyle();
    final String fontStyleText;
    if ((fontStyle & (Font.BOLD | Font.ITALIC)) == (Font.BOLD | Font.ITALIC)) {
        fontStyleText = "BOLDITALIC";
    } else if ((fontStyle & Font.BOLD) == Font.BOLD) {
        fontStyleText = "BOLD";
    } else if ((fontStyle & Font.ITALIC) == Font.ITALIC) {
        fontStyleText = "ITALIC";
    } else {
        fontStyleText = "PLAIN";
    }
    return (fontName + "-" + fontStyleText + "-" + fontSize);
}

From source file:edworld.pdfreader4humans.PDFReader.java

private Font font(TextComponent component, Map<String, Font> fonts) {
    String key = component.getFontName() + ":" + component.getFontSize();
    Font font = fonts.get(key);/*from   w w  w.  j a  va 2  s.  c o m*/
    if (font == null) {
        String name = component.getFontName().contains("Times") ? "TimesRoman" : "Dialog";
        int style = component.getFontName().contains("Bold") ? Font.BOLD
                : (component.getFontName().contains("Italic") ? Font.ITALIC : Font.PLAIN);
        font = new Font(name, style, (int) component.getFontSize());
        fonts.put(key, font);
    }
    return font;
}

From source file:org.pentaho.reporting.libraries.fonts.itext.BaseFontSupport.java

/**
 * Returns an AWT Font which can be used to represent the given BaseFont
 *
 * @param font the font to be converted/* w  w w. ja v  a2s  . com*/
 * @param size the desired point size of the resulting font
 * @return a Font which has similar properties to the provided BaseFont
 */

public Font pdfToAwt(final BaseFont font, final int size) {
    final String logicalName = getFontName(font);
    boolean bold = false;
    boolean italic = false;

    if (StringUtils.endsWithIgnoreCase(logicalName, "bolditalic")) {
        bold = true;
        italic = true;
    } else if (StringUtils.endsWithIgnoreCase(logicalName, "bold")) {
        bold = true;
    } else if (StringUtils.endsWithIgnoreCase(logicalName, "italic")) {
        italic = true;
    }

    int style = Font.PLAIN;
    if (bold) {
        style |= Font.BOLD;
    }
    if (italic) {
        style |= Font.ITALIC;
    }

    return new Font(logicalName, style, size);
}