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.zephyrsoft.sdb2.MainController.java

private void loadDefaultSettingsForUnsetSettings() {
    putDefaultIfKeyIsUnset(SettingKey.BACKGROUND_COLOR, Color.BLACK);
    putDefaultIfKeyIsUnset(SettingKey.TEXT_COLOR, Color.WHITE);

    putDefaultIfKeyIsUnset(SettingKey.TOP_MARGIN, Integer.valueOf(10));
    putDefaultIfKeyIsUnset(SettingKey.LEFT_MARGIN, Integer.valueOf(0));
    putDefaultIfKeyIsUnset(SettingKey.RIGHT_MARGIN, Integer.valueOf(0));
    putDefaultIfKeyIsUnset(SettingKey.BOTTOM_MARGIN, Integer.valueOf(20));
    putDefaultIfKeyIsUnset(SettingKey.DISTANCE_TITLE_TEXT, Integer.valueOf(20));
    putDefaultIfKeyIsUnset(SettingKey.DISTANCE_TEXT_COPYRIGHT, Integer.valueOf(20));

    putDefaultIfKeyIsUnset(SettingKey.SONG_LIST_FILTER, FilterTypeEnum.TITLE_AND_LYRICS);
    putDefaultIfKeyIsUnset(SettingKey.SCREEN_1_CONTENTS, ScreenContentsEnum.ONLY_LYRICS);
    putDefaultIfKeyIsUnset(SettingKey.SCREEN_1_DISPLAY, "");
    putDefaultIfKeyIsUnset(SettingKey.SCREEN_2_CONTENTS, ScreenContentsEnum.LYRICS_AND_CHORDS);
    putDefaultIfKeyIsUnset(SettingKey.SCREEN_2_DISPLAY, "");

    putDefaultIfKeyIsUnset(SettingKey.SHOW_TITLE, Boolean.TRUE);
    putDefaultIfKeyIsUnset(SettingKey.TITLE_FONT, new Font(Font.SERIF, Font.BOLD, 10));
    putDefaultIfKeyIsUnset(SettingKey.LYRICS_FONT, new Font(Font.SERIF, Font.PLAIN, 10));
    putDefaultIfKeyIsUnset(SettingKey.TRANSLATION_FONT, new Font(Font.SERIF, Font.PLAIN, 10));
    putDefaultIfKeyIsUnset(SettingKey.COPYRIGHT_FONT, new Font(Font.SERIF, Font.ITALIC, 10));
    putDefaultIfKeyIsUnset(SettingKey.LOGO_FILE, "");
    putDefaultIfKeyIsUnset(SettingKey.SECONDS_UNTIL_COUNTED, Integer.valueOf(60));

    // check that really all settings are set
    for (SettingKey key : SettingKey.values()) {
        if (!settings.isSet(key)) {
            throw new IllegalStateException("unset value for setting key: " + key);
        }//from   w  w  w.  j a va2  s  . c om
    }
}

From source file:org.pentaho.reporting.engine.classic.core.layout.output.RenderUtility.java

public static DefaultImageReference createImageFromDrawable(final DrawableWrapper drawable,
        final StrictBounds rect, final StyleSheet box, final OutputProcessorMetaData metaData) {
    final int imageWidth = (int) StrictGeomUtility.toExternalValue(rect.getWidth());
    final int imageHeight = (int) StrictGeomUtility.toExternalValue(rect.getHeight());

    if (imageWidth == 0 || imageHeight == 0) {
        return null;
    }//from ww w . ja v  a2s. co m

    final double scale = RenderUtility.getNormalizationScale(metaData);
    final Image image = ImageUtils.createTransparentImage((int) (imageWidth * scale),
            (int) (imageHeight * scale));
    final Graphics2D g2 = (Graphics2D) image.getGraphics();

    final Object attribute = box.getStyleProperty(ElementStyleKeys.ANTI_ALIASING);
    if (attribute != null) {
        if (Boolean.TRUE.equals(attribute)) {
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        } else if (Boolean.FALSE.equals(attribute)) {
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
        }

    }
    if (RenderUtility.isFontSmooth(box, metaData)) {
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    } else {
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
    }

    g2.scale(scale, scale);
    // the clipping bounds are a sub-area of the whole drawable
    // we only want to print a certain area ...

    final String fontName = (String) box.getStyleProperty(TextStyleKeys.FONT);
    final int fontSize = box.getIntStyleProperty(TextStyleKeys.FONTSIZE, 8);
    final boolean bold = box.getBooleanStyleProperty(TextStyleKeys.BOLD);
    final boolean italics = box.getBooleanStyleProperty(TextStyleKeys.ITALIC);
    if (bold && italics) {
        g2.setFont(new Font(fontName, Font.BOLD | Font.ITALIC, fontSize));
    } else if (bold) {
        g2.setFont(new Font(fontName, Font.BOLD, fontSize));
    } else if (italics) {
        g2.setFont(new Font(fontName, Font.ITALIC, fontSize));
    } else {
        g2.setFont(new Font(fontName, Font.PLAIN, fontSize));
    }

    g2.setStroke((Stroke) box.getStyleProperty(ElementStyleKeys.STROKE));
    g2.setPaint((Paint) box.getStyleProperty(ElementStyleKeys.PAINT));

    drawable.draw(g2, new Rectangle2D.Double(0, 0, imageWidth, imageHeight));
    g2.dispose();

    try {
        return new DefaultImageReference(image);
    } catch (final IOException e1) {
        logger.warn("Unable to fully load a given image. (It should not happen here.)", e1);
        return null;
    }
}

From source file:org.eclipse.wb.tests.designer.swing.model.property.FontPropertyEditorTest.java

/**
 * Test for {@link DerivedFontInfo}.//from   w ww .  j  a v a2s .c  o m
 */
public void test_FontInfo_Derived() throws Exception {
    Font baseFont = new Font("Arial", Font.BOLD, 12);
    String baseFontSource = "button.getFont()";
    String baseFontClipboardSource = "%this%.getFont()";
    // no changes
    {
        FontInfo fontInfo = new DerivedFontInfo(baseFont, baseFontSource, baseFontClipboardSource, null, null,
                null, null, null);
        {
            Font font = fontInfo.getFont();
            assertEquals("Arial", font.getFamily());
            assertEquals(Font.BOLD, font.getStyle());
            assertEquals(12, font.getSize());
        }
        assertEquals("<no changes>, Arial 12 Bold", fontInfo.getText());
        assertNull(fontInfo.getSource());
        assertNull(fontInfo.getClipboardSource());
    }
    // new family
    {
        FontInfo fontInfo = new DerivedFontInfo(baseFont, baseFontSource, baseFontClipboardSource, "Tahoma",
                null, null, null, null);
        {
            Font font = fontInfo.getFont();
            assertEquals("Tahoma", font.getFamily());
            assertEquals(Font.BOLD, font.getStyle());
            assertEquals(12, font.getSize());
        }
        assertEquals("*Tahoma, Tahoma 12 Bold", fontInfo.getText());
        assertEquals("new java.awt.Font(\"Tahoma\", button.getFont().getStyle(), button.getFont().getSize())",
                fontInfo.getSource());
        assertEquals("new java.awt.Font(\"Tahoma\", %this%.getFont().getStyle(), %this%.getFont().getSize())",
                fontInfo.getClipboardSource());
    }
    // new family +5
    {
        FontInfo fontInfo = new DerivedFontInfo(baseFont, baseFontSource, baseFontClipboardSource, "Tahoma",
                null, null, new Integer(5), null);
        {
            Font font = fontInfo.getFont();
            assertEquals("Tahoma", font.getFamily());
            assertEquals(Font.BOLD, font.getStyle());
            assertEquals(17, font.getSize());
        }
        assertEquals("*Tahoma +5, Tahoma 17 Bold", fontInfo.getText());
        assertEquals(
                "new java.awt.Font(\"Tahoma\", button.getFont().getStyle(), button.getFont().getSize() + 5)",
                fontInfo.getSource());
        assertEquals(
                "new java.awt.Font(\"Tahoma\", %this%.getFont().getStyle(), %this%.getFont().getSize() + 5)",
                fontInfo.getClipboardSource());
    }
    // new family =20
    {
        FontInfo fontInfo = new DerivedFontInfo(baseFont, baseFontSource, baseFontClipboardSource, "Tahoma",
                null, null, null, new Integer(20));
        {
            Font font = fontInfo.getFont();
            assertEquals("Tahoma", font.getFamily());
            assertEquals(Font.BOLD, font.getStyle());
            assertEquals(20, font.getSize());
        }
        assertEquals("*Tahoma 20, Tahoma 20 Bold", fontInfo.getText());
        assertEquals("new java.awt.Font(\"Tahoma\", button.getFont().getStyle(), 20)", fontInfo.getSource());
    }
    // +Bold
    {
        FontInfo fontInfo = new DerivedFontInfo(baseFont, baseFontSource, baseFontClipboardSource, null,
                Boolean.TRUE, null, null, null);
        {
            Font font = fontInfo.getFont();
            assertEquals("Arial", font.getFamily());
            assertEquals(Font.BOLD, font.getStyle());
            assertEquals(12, font.getSize());
        }
        assertEquals("+Bold, Arial 12 Bold", fontInfo.getText());
        assertEquals("button.getFont().deriveFont(button.getFont().getStyle() | java.awt.Font.BOLD)",
                fontInfo.getSource());
    }
    // -Bold
    {
        FontInfo fontInfo = new DerivedFontInfo(baseFont, baseFontSource, baseFontClipboardSource, null,
                Boolean.FALSE, null, null, null);
        {
            Font font = fontInfo.getFont();
            assertEquals("Arial", font.getFamily());
            assertEquals(Font.PLAIN, font.getStyle());
            assertEquals(12, font.getSize());
        }
        assertEquals("-Bold, Arial 12", fontInfo.getText());
        assertEquals("button.getFont().deriveFont(button.getFont().getStyle() & ~java.awt.Font.BOLD)",
                fontInfo.getSource());
    }
    // +Italic
    {
        FontInfo fontInfo = new DerivedFontInfo(baseFont, baseFontSource, baseFontClipboardSource, null, null,
                Boolean.TRUE, null, null);
        {
            Font font = fontInfo.getFont();
            assertEquals("Arial", font.getFamily());
            assertEquals(Font.BOLD | Font.ITALIC, font.getStyle());
            assertEquals(12, font.getSize());
        }
        assertEquals("+Italic, Arial 12 Bold Italic", fontInfo.getText());
        assertEquals("button.getFont().deriveFont(button.getFont().getStyle() | java.awt.Font.ITALIC)",
                fontInfo.getSource());
    }
    // -Italic
    {
        FontInfo fontInfo = new DerivedFontInfo(baseFont, baseFontSource, baseFontClipboardSource, null, null,
                Boolean.FALSE, null, null);
        {
            Font font = fontInfo.getFont();
            assertEquals("Arial", font.getFamily());
            assertEquals(Font.BOLD, font.getStyle());
            assertEquals(12, font.getSize());
        }
        assertEquals("-Italic, Arial 12 Bold", fontInfo.getText());
        assertEquals("button.getFont().deriveFont(button.getFont().getStyle() & ~java.awt.Font.ITALIC)",
                fontInfo.getSource());
    }
    // +Bold +Italic
    {
        FontInfo fontInfo = new DerivedFontInfo(baseFont, baseFontSource, baseFontClipboardSource, null,
                Boolean.TRUE, Boolean.TRUE, null, null);
        {
            Font font = fontInfo.getFont();
            assertEquals("Arial", font.getFamily());
            assertEquals(Font.BOLD | Font.ITALIC, font.getStyle());
            assertEquals(12, font.getSize());
        }
        assertEquals("+Bold +Italic, Arial 12 Bold Italic", fontInfo.getText());
        assertEquals(
                "button.getFont().deriveFont(button.getFont().getStyle() | java.awt.Font.BOLD | java.awt.Font.ITALIC)",
                fontInfo.getSource());
    }
    // -Bold +Italic
    {
        FontInfo fontInfo = new DerivedFontInfo(baseFont, baseFontSource, baseFontClipboardSource, null,
                Boolean.FALSE, Boolean.TRUE, null, null);
        {
            Font font = fontInfo.getFont();
            assertEquals("Arial", font.getFamily());
            assertEquals(Font.ITALIC, font.getStyle());
            assertEquals(12, font.getSize());
        }
        assertEquals("-Bold +Italic, Arial 12 Italic", fontInfo.getText());
        assertEquals(
                "button.getFont().deriveFont(button.getFont().getStyle() & ~java.awt.Font.BOLD | java.awt.Font.ITALIC)",
                fontInfo.getSource());
    }
    // +Bold -Italic
    {
        FontInfo fontInfo = new DerivedFontInfo(baseFont, baseFontSource, baseFontClipboardSource, null,
                Boolean.TRUE, Boolean.FALSE, null, null);
        {
            Font font = fontInfo.getFont();
            assertEquals("Arial", font.getFamily());
            assertEquals(Font.BOLD, font.getStyle());
            assertEquals(12, font.getSize());
        }
        assertEquals("+Bold -Italic, Arial 12 Bold", fontInfo.getText());
        assertEquals(
                "button.getFont().deriveFont(button.getFont().getStyle() & ~java.awt.Font.ITALIC | java.awt.Font.BOLD)",
                fontInfo.getSource());
    }
    // -Bold -Italic
    {
        FontInfo fontInfo = new DerivedFontInfo(baseFont, baseFontSource, baseFontClipboardSource, null,
                Boolean.FALSE, Boolean.FALSE, null, null);
        {
            Font font = fontInfo.getFont();
            assertEquals("Arial", font.getFamily());
            assertEquals(Font.PLAIN, font.getStyle());
            assertEquals(12, font.getSize());
        }
        assertEquals("-Bold -Italic, Arial 12", fontInfo.getText());
        assertEquals(
                "button.getFont().deriveFont(button.getFont().getStyle() & ~java.awt.Font.BOLD & ~java.awt.Font.ITALIC)",
                fontInfo.getSource());
    }
    // +5
    {
        FontInfo fontInfo = new DerivedFontInfo(baseFont, baseFontSource, baseFontClipboardSource, null, null,
                null, +5, null);
        {
            Font font = fontInfo.getFont();
            assertEquals("Arial", font.getFamily());
            assertEquals(Font.BOLD, font.getStyle());
            assertEquals(12 + 5, font.getSize());
        }
        assertEquals("+5, Arial 17 Bold", fontInfo.getText());
        assertEquals("button.getFont().deriveFont(button.getFont().getSize() + 5f)", fontInfo.getSource());
    }
    // -5
    {
        FontInfo fontInfo = new DerivedFontInfo(baseFont, baseFontSource, baseFontClipboardSource, null, null,
                null, -5, null);
        {
            Font font = fontInfo.getFont();
            assertEquals("Arial", font.getFamily());
            assertEquals(Font.BOLD, font.getStyle());
            assertEquals(12 - 5, font.getSize());
        }
        assertEquals("-5, Arial 7 Bold", fontInfo.getText());
        assertEquals("button.getFont().deriveFont(button.getFont().getSize() - 5f)", fontInfo.getSource());
    }
    // =20
    {
        FontInfo fontInfo = new DerivedFontInfo(baseFont, baseFontSource, baseFontClipboardSource, null, null,
                null, null, 20);
        {
            Font font = fontInfo.getFont();
            assertEquals("Arial", font.getFamily());
            assertEquals(Font.BOLD, font.getStyle());
            assertEquals(20, font.getSize());
        }
        assertEquals("20, Arial 20 Bold", fontInfo.getText());
        assertEquals("button.getFont().deriveFont(20f)", fontInfo.getSource());
    }
    // -Bold =20
    {
        FontInfo fontInfo = new DerivedFontInfo(baseFont, baseFontSource, baseFontClipboardSource, null,
                Boolean.FALSE, null, null, 20);
        {
            Font font = fontInfo.getFont();
            assertEquals("Arial", font.getFamily());
            assertEquals(Font.PLAIN, font.getStyle());
            assertEquals(20, font.getSize());
        }
        assertEquals("20 -Bold, Arial 20", fontInfo.getText());
        assertEquals("button.getFont().deriveFont(button.getFont().getStyle() & ~java.awt.Font.BOLD, 20f)",
                fontInfo.getSource());
    }
    // -Italic =20
    {
        FontInfo fontInfo = new DerivedFontInfo(baseFont, baseFontSource, baseFontClipboardSource, null, null,
                Boolean.FALSE, null, 20);
        {
            Font font = fontInfo.getFont();
            assertEquals("Arial", font.getFamily());
            assertEquals(Font.BOLD, font.getStyle());
            assertEquals(20, font.getSize());
        }
        assertEquals("20 -Italic, Arial 20 Bold", fontInfo.getText());
        assertEquals("button.getFont().deriveFont(button.getFont().getStyle() & ~java.awt.Font.ITALIC, 20f)",
                fontInfo.getSource());
    }
}

From source file:savant.ucscexplorer.UCSCExplorerPlugin.java

private void buildUI() {
    topLevelPanel.removeAll();/*  ww  w  .  j  ava2 s .  c  o m*/
    topLevelPanel.setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(5, 5, 5, 5);

    try {
        UCSCDataSourcePlugin ucsc = getUCSCPlugin();
        ucsc.getConnection();
        JLabel cladeLabel = new JLabel("Clade:");
        gbc.anchor = GridBagConstraints.EAST;
        topLevelPanel.add(cladeLabel, gbc);

        cladeCombo = new JComboBox();
        cladeCombo.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                UCSCDataSourcePlugin ucsc = getUCSCPlugin();
                String clade = (String) cladeCombo.getSelectedItem();
                genomeCombo.setModel(new DefaultComboBoxModel(ucsc.getCladeGenomes(clade)));
                genomeCombo.setSelectedItem(ucsc.getCurrentGenome(clade));
            }
        });

        gbc.anchor = GridBagConstraints.WEST;
        topLevelPanel.add(cladeCombo, gbc);

        JLabel genomeLabel = new JLabel("Genome:");
        gbc.anchor = GridBagConstraints.EAST;
        topLevelPanel.add(genomeLabel, gbc);

        genomeCombo = new JComboBox();
        genomeCombo.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                buildProgressUI();
                new GroupsFetcher(getUCSCPlugin(), (GenomeDef) genomeCombo.getSelectedItem()) {
                    @Override
                    public void done(List<GroupDef> groups) {
                        if (groups != null) {
                            GridBagConstraints gbc = new GridBagConstraints();
                            gbc.gridwidth = GridBagConstraints.REMAINDER;
                            gbc.fill = GridBagConstraints.BOTH;
                            gbc.weightx = 1.0;
                            for (GroupDef g : groups) {
                                groupsPanel.add(new GroupPanel(g), gbc);
                            }

                            // Add a filler panel to force everything to the top.
                            gbc.weighty = 1.0;
                            groupsPanel.add(new JPanel(), gbc);
                            loadButton.setEnabled(true);
                            topLevelPanel.validate();
                        }
                    }

                    @Override
                    public void showProgress(double value) {
                        updateProgress(progressMessage, value);
                    }
                }.execute();
            }
        });
        gbc.anchor = GridBagConstraints.WEST;
        topLevelPanel.add(genomeCombo, gbc);

        loadButton = new JButton("Load Selected Tracks");
        loadButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                try {
                    loadSelectedTracks();
                } catch (Throwable x) {
                    DialogUtils.displayException(getTitle(), "Unable to load selected tracks.", x);
                }
            }
        });
        gbc.anchor = GridBagConstraints.EAST;
        gbc.gridwidth = GridBagConstraints.REMAINDER;
        topLevelPanel.add(loadButton, gbc);

        groupsPanel = new GroupsPanel();
        groupsPanel.setLayout(new GridBagLayout());

        JScrollPane groupsScroller = new JScrollPane(groupsPanel,
                ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        topLevelPanel.add(groupsScroller, gbc);

        buildProgressUI();

        GenomeUtils.addGenomeChangedListener(new Listener<GenomeChangedEvent>() {
            @Override
            public void handleEvent(GenomeChangedEvent event) {
                UCSCDataSourcePlugin ucsc = getUCSCPlugin();
                ucsc.selectGenomeDB(null);
                GenomeAdapter newGenome = event.getNewGenome();
                GenomeDef g = new GenomeDef(newGenome.getName(), null);
                String newClade = ucsc.findCladeForGenome(g);

                // newClade could be null if the user has opened a genome which has no UCSC equivalent.
                if (newClade != null) {
                    cladeCombo.setSelectedItem(newClade);
                }
            }
        });

        ucsc.selectGenomeDB(null);
        new CladesFetcher(getUCSCPlugin()) {
            @Override
            public void done(String selectedClade) {
                cladeCombo.setModel(new DefaultComboBoxModel(UCSCDataSourcePlugin.STANDARD_CLADES));
                if (selectedClade != null) {
                    cladeCombo.setSelectedItem(selectedClade);
                } else {
                    cladeCombo.setSelectedIndex(0);
                }
            }

            @Override
            public void showProgress(double value) {
                updateProgress(progressMessage, value);
            }
        }.execute();
    } catch (Exception x) {
        LOG.error("Unable to connect to UCSC database.", x);
        topLevelPanel.removeAll();
        gbc.anchor = GridBagConstraints.CENTER;
        gbc.gridwidth = GridBagConstraints.REMAINDER;
        gbc.fill = GridBagConstraints.NONE;
        gbc.weightx = 0.0;
        gbc.weighty = 0.0;
        topLevelPanel.add(new JLabel("Unable to connect to UCSC database."), gbc);
        JLabel error = new JLabel(MiscUtils.getMessage(x));
        Font f = topLevelPanel.getFont();
        f = f.deriveFont(Font.ITALIC, f.getSize() - 2.0f);
        error.setFont(f);
        topLevelPanel.add(error, gbc);
    }
}

From source file:net.sf.jasperreports.engine.util.JRFontUtil.java

/**
 * Returns a java.awt.Font instance by converting a JRFont instance.
 * Mostly used in combination with third-party visualization packages such as JFreeChart (for chart themes).
 * Unless the font parameter is null, this method always returns a non-null AWT font, regardless whether it was
 * found in the font extensions or not. This is because we do need a font to draw with and there is no point
 * in raising a font missing exception here, as it is not JasperReports who does the drawing. 
 *///from ww w.  j  a  va2s .  c o m
public static Font getAwtFont(JRFont font, Locale locale) {
    if (font == null) {
        return null;
    }

    // ignoring missing font as explained in the Javadoc
    Font awtFont = getAwtFontFromBundles(font.getFontName(),
            ((font.isBold() ? Font.BOLD : Font.PLAIN) | (font.isItalic() ? Font.ITALIC : Font.PLAIN)),
            font.getFontSize(), locale, true);

    if (awtFont == null) {
        awtFont = new Font(getAttributesWithoutAwtFont(new HashMap<Attribute, Object>(), font));
    } else {
        // add underline and strikethrough attributes since these are set at
        // style/font level
        Map<Attribute, Object> attributes = new HashMap<Attribute, Object>();
        if (font.isUnderline()) {
            attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
        }
        if (font.isStrikeThrough()) {
            attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
        }

        if (!attributes.isEmpty()) {
            awtFont = awtFont.deriveFont(attributes);
        }
    }

    return awtFont;
}

From source file:skoa.helpers.ConfiguracionGraficas.java

private void inicializarPaneles() {
    espera = new JButton();
    inicializaDataSource(); //Inicializa el pool de conexiones.      
    nfich = new JTextField();
    nfich.setEditable(false);//ww w  . ja v a2  s . co m
    rfich = new JTextField();
    fichero = new JPanel(); //Volvemos a crear y a configurar "panel" para no tener problemas al cambiar de vista.
    fichero.setLayout(new GridLayout(1, 3));
    e = new ElectorFicheros();
    abrir = e.openButton;
    abrir.setEnabled(false); //Al principio, se desactiva, hasta que no se elija un tipo de consulta.
    boton3 = new JButton("Seleccionar"); //Boton3 de seleccion de un fichero escogido.
    boton3.setFont(new Font("Tahoma", Font.PLAIN, 12));
    boton3.setEnabled(false);
    fichero.add(abrir);
    fichero.add(nfich);
    fichero.add(boton3);
    //Paneles principales:
    principal.setLayout(new BorderLayout());
    principal.add(new JPanel(), "West"); //aadido para que se vea este panel centrado
    principal.add(new JPanel(), "East"); //y no pegado a los bordes de la ventana
    principal.add(new JPanel(), "North"); //...
    principal.add(new JPanel(), "South"); //...      
    centro.setLayout(new BorderLayout());
    oeste.setLayout(new BorderLayout());
    //Panel centro
    grafica.setBackground(Color.lightGray);
    JPanel p = new JPanel();
    p.setBorder(BorderFactory.createEtchedBorder());
    if (g == 1) {
        grafica.setLayout(new GridLayout(1, 1));//1 grafica
        grafica.add(p);
    } else {
        grafica.setLayout(new GridLayout(2, 2));//4 graficas
        grafica.add(p);
        for (int i = 0; i < 3; i++) {
            p = new JPanel();
            p.setBorder(BorderFactory.createEtchedBorder());
            grafica.add(p);
        }
    }
    centro.add(new JPanel(), "West"); //aadido para que se vea este panel centrado
    centro.add(new JPanel(), "East"); //y no pegado a los bordes de la ventana
    centro.add(new JPanel(), "North"); //...
    centro.add(new JPanel(), "South"); //...
    centro.add(grafica, "Center");
    //Panel de datos:
    datos = new JPanel();
    datos.setLayout(new GridLayout(2, 1));
    //Panel de obtencion de datos
    panel = new JPanel();
    panel.setLayout(new GridLayout(2, 1));
    panel.setBorder(BorderFactory.createEtchedBorder());
    //Panel obtenidos (datos obtenidos)
    obtenidos = new JPanel();
    //obtenidos.setLayout(new GridLayout(5,1));
    obtenidos.setLayout(new GridLayout(6, 1));
    obtenidos.setBorder(BorderFactory.createEtchedBorder());
    //Panel dirs: num de DGs y DGs
    dirs = new JPanel();
    l3 = new JLabel("  Nmero de DGs: ");
    l3.setFont(new Font("Tahoma", Font.PLAIN, 12));
    String n[] = { "0", "1", "2", "3", "4", "5" };
    ndirs = new JComboBox(n);
    ndirs.setEditable(false);
    ndirs.setSelectedIndex(0);
    boton2 = new JButton("Seleccionar");
    boton2.setFont(new Font("Tahoma", Font.PLAIN, 12));
    dirs.setLayout(new GridLayout(1, 3));
    dirs.add(l3);
    dirs.add(ndirs); //n direcciones de grupo
    dirs.add(boton2);
    l4 = new JLabel("  Dir. de grupo:");
    l4.setFont(new Font("Tahoma", Font.PLAIN, 12));
    boton1 = new JButton("Seleccionar");
    boton1.setFont(new Font("Tahoma", Font.PLAIN, 12));
    listarDGs();
    dirs2 = new JPanel();
    dirs2.setLayout(new GridLayout(1, 3));
    dirs2.add(l4);
    dirs2.add(listado); //lista de direcciones de grupo
    dirs2.add(boton1);
    //Panel2: DGs seleccionadas y tipos de consulta
    c1 = new JCheckBox("Evolucin temporal"); //Consulta A.
    c1.setFont(new Font("Tahoma", Font.PLAIN, 12));
    c1.setSelected(false);
    c2 = new JCheckBox("Acumulacin por intervalos temporales"); //Consulta B.
    c2.setFont(new Font("Tahoma", Font.PLAIN, 12));
    c2.setSelected(false);
    c3 = new JCheckBox("Mx-Mn-Med por intervalos temporales"); //Consulta C.
    c3.setFont(new Font("Tahoma", Font.PLAIN, 12));
    c3.setSelected(false);
    c4 = new JCheckBox("Evolucin de diferencias"); //Consulta D.
    c4.setFont(new Font("Tahoma", Font.PLAIN, 12));
    c4.setSelected(false);
    tipos2 = new JPanel();
    tipos2.setLayout(new GridLayout(1, 4));
    tipos2.add(new JPanel());
    c4a = new JCheckBox("%"); //Consulta D -> %.
    c4a.setSelected(false);
    c4b = new JCheckBox("Diferencia"); //Consulta D -> Diferencia.
    c4b.setFont(new Font("Dialog", Font.PLAIN, 12));
    c4b.setSelected(false);
    tipos2.add(c4a);
    tipos2.add(c4b);
    tipos2.add(new JPanel());
    //CheckBox para ver si se muestra la grfica con doble eje
    dual = new JCheckBox("Dual");
    dual.setSelected(false);
    dual.setFont(new Font("Dialog", Font.ITALIC, 12));
    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());
    //Panel opciones: tipos de consulta y seleccion de DGs.
    opciones = new JPanel();
    opciones.setLayout(new GridLayout(8, 1));
    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
    opciones.add(dirs);
    opciones.add(dirs2);
    //Panel opciones2: DGs seleccionadas, tipo de fecha, fechas, aadir datos.
    opciones2 = new JPanel();
    opciones2.setLayout(new GridLayout(7, 1));
    opciones2.add(fichero); //Lugar en que va la seleccion de los resultados de una consulta ya hecha.
    //Panel3: en principio solo elegir fechas. Se inicializa fecha inicial
    fechas = new JPanel(); //Fecha inicial y final o todo
    fechas.setLayout(new GridLayout(1, 3));
    JLabel l2 = new JLabel("  Fechas: ");
    l2.setFont(new Font("Tahoma", Font.BOLD, 12));
    f1 = new JCheckBox("Intervalo");
    f1.setFont(new Font("Tahoma", Font.PLAIN, 12));
    f1.setSelected(false);
    f2 = new JCheckBox("Completo");
    f2.setFont(new Font("Tahoma", Font.PLAIN, 12));
    f2.setSelected(false);
    fechas.add(l2);
    fechas.add(f1);
    fechas.add(f2);
    fechaI = new JPanel();
    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);
    //Panel4: fecha final y [rango | nada]
    fechaF = new JPanel();
    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);
    //Panel 5: boton de aadir
    pAdd = new JPanel();
    pAdd.setLayout(new GridLayout(1, 4));
    pAdd.add(new JPanel());
    pAdd.add(new JPanel());
    anadir = new JButton("AADIR DATOS");
    anadir.setFont(new Font("Tahoma", Font.BOLD, 12));
    pAdd.add(anadir);
    //Panel obtenidos (datos obtenidos)
    r = new JTextField(16);
    //Otras inicializaciones:
    generar = new JButton("GENERAR GR?FICAS");
    generar.setFont(new Font("Tahoma", Font.BOLD, 12));
}

From source file:nz.govt.natlib.ndha.manualdeposit.metadata.PersonalSettings.java

public Font getStandardFont() {
    int attribute = Font.PLAIN;
    if (fontBold) {
        attribute += Font.BOLD;/*from  w  w w . j  a v  a 2  s .co  m*/
    }
    if (fontItalic) {
        attribute += Font.ITALIC;
    }
    return new Font(fontName, attribute, fontSize);
}

From source file:skoa.helpers.Graficos.java

/****************************************************************************************
 * Funcion evolucion(): dados los ficheros a leer, obtiene la serie de cada uno de ellos*
 * y la aade a la grfica en cuestion.                                                 *
 ****************************************************************************************/
private void evolucion() {
    TimeSeries serie;//  w ww . j a v a  2  s .c  o  m
    TimeSeriesCollection dataset = null;
    for (int i = 0; i < nombresFicheros.size(); i++) {
        ui = 0;
        nombreFichero = nombresFicheros.elementAt(i);
        unidad = unidad + "," + buscarUnidad(nombreFichero);
        serie = obtenerSerieEvolucion();
        if (i == 0)
            dataset = new TimeSeriesCollection(serie);
        else
            dataset.addSeries(serie);
    }
    unidad = unidad.substring(1); //Para quitar la coma del principio, introducida por la primera unidad.
    //Para generar el grfico se usa createTimeSeriesChart para ver la evolucin de las fechas.
    JFreeChart grafica = ChartFactory.createTimeSeriesChart("Valores medidos de las direcciones de grupo", //titulo
            "Fechas", //titulo eje x
            "Mediciones (" + unidad + ")", //titulo eje y
            dataset, //dataset
            true, //leyenda
            true, //tooltips
            false); //configure chart to generate URLs?
    //Dar color a cada categoria
    grafica.setBackgroundPaint(Color.WHITE); //Color del fondo del grfico
    if (fechaInicial.equals("") & fechaFinal.equals("")) { //Si estn vacas es porque no hay resultados para ese intervalo.
        fechaInicial = " ? ";
        fechaFinal = " ? ";
    }
    TextTitle t = new TextTitle("desde " + fechaInicial + " hasta " + fechaFinal,
            new Font("SanSerif", Font.ITALIC, 12));
    grafica.addSubtitle(t);
    try {
        ChartUtilities.saveChartAsJPEG(new File(ruta + "EvolucionSmall.jpg"), grafica, 400, 300);
        ChartUtilities.saveChartAsJPEG(new File(ruta + "EvolucionBig.jpg"), grafica, 900, 600);
    } catch (IOException e1) {
        System.err.println("Problem occurred creating chart." + e1);
    }
}

From source file:FontChooser.java

public int generateStyle() {
    int style = 0;
    if (!_isBold && !_isItalic) {
        style = Font.PLAIN;/*from  ww w. j av  a 2 s.  c  o m*/
    } else {
        if (_isBold) {
            style |= Font.BOLD;
        }
        if (_isItalic) {
            style |= Font.ITALIC;
        }
    }
    return style;
}

From source file:org.spiderplan.tools.visulization.GraphFrame.java

/**
 * @param graph/*from ww  w .  j av  a  2  s.  co  m*/
 * @param history optional history of the graph
 * @param title 
 * @param lC the layout
 * @param edgeLabels map from edges to string labels
 * @param w width of the window
 * @param h height of the window
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public GraphFrame(AbstractTypedGraph<V, E> graph, Vector<AbstractTypedGraph<V, E>> history, String title,
        LayoutClass lC, Map<E, String> edgeLabels, int w, int h) {
    super(title);
    this.edgeLabels = edgeLabels;
    this.g = new ObservableGraph<V, E>(graph);
    this.g.addGraphEventListener(this);

    this.defaultEdgeType = this.g.getDefaultEdgeType();

    this.layoutClass = lC;

    this.history = history;

    this.setLayout(lC);

    layout.setSize(new Dimension(w, h));

    try {
        Relaxer relaxer = new VisRunner((IterativeContext) layout);
        relaxer.stop();
        relaxer.prerelax();
    } catch (java.lang.ClassCastException e) {
    }

    //      Layout<V,E> staticLayout = new StaticLayout<V,E>(g, layout);
    //      Layout<V,E> staticLayout = new SpringLayout<V, E>(g);

    vv = new VisualizationViewer<V, E>(layout, new Dimension(w, h));

    JRootPane rp = this.getRootPane();
    rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().setBackground(java.awt.Color.lightGray);
    getContentPane().setFont(new Font("Serif", Font.PLAIN, 10));

    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.S);
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<V>());
    vv.setForeground(Color.black);

    graphMouse = new EditingModalGraphMouse<V, E>(vv.getRenderContext(), null, null);
    graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());

    //        vv.getRenderContext().setEd
    vv.getRenderContext().setEdgeLabelTransformer(this);
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<E>(vv.getPickedEdgeState(), Color.black, Color.cyan));

    vv.addComponentListener(new ComponentAdapter() {

        /**
         * @see java.awt.event.ComponentAdapter#componentResized(java.awt.event.ComponentEvent)
         */
        @Override
        public void componentResized(ComponentEvent arg0) {
            super.componentResized(arg0);
            layout.setSize(arg0.getComponent().getSize());
        }
    });

    getContentPane().add(vv);

    /**
     * Create simple container for stuff on SOUTH border of this JFrame
     */
    Container c = new Container();
    c.setLayout(new FlowLayout());
    c.setBackground(java.awt.Color.lightGray);
    c.setFont(new Font("Serif", Font.PLAIN, 10));

    /**
     * Button to dump jpeg
     */
    dumpJPEG = new JButton("Dump");
    dumpJPEG.addActionListener(this);
    dumpJPEG.setName("Dump");
    c.add(dumpJPEG);

    /**
     * Button that creates offspring frame for selected vertices
     */
    subGraphButton = new JButton("Subgraph");
    subGraphButton.addActionListener(this);
    subGraphButton.setName("Subgraph");
    c.add(subGraphButton);

    subGraphDepthLabel = new JLabel("Depth");
    c.add(subGraphDepthLabel);
    subGraphDepth = new JTextField("0", 2);
    subGraphDepth.setHorizontalAlignment(SwingConstants.CENTER);
    subGraphDepth.setToolTipText("Depth of sub-graph created from selected nodes.");
    c.add(subGraphDepth);

    /**
     * Button that switches mouse mode
     */
    switchMode = new JButton("Transformation");
    switchMode.addActionListener(this);
    switchMode.setName("SwitchMode");
    c.add(switchMode);

    /**
     * ComboBox for Layout selection:
     */
    JComboBox layoutList;
    if (graph instanceof Forest) {
        String[] layoutStrings = { "Static", "Circle", "DAG", "Spring", "Spring2", "FR", "FR2", "Baloon",
                "ISOM", "KK", "PolarPoint", "RadialTree", "Tree" };
        layoutList = new JComboBox(layoutStrings);
    } else {
        String[] layoutStrings = { "Static", "Circle", "DAG", "Spring", "Spring2", "FR", "FR2", "ISOM", "KK",
                "PolarPoint" };
        layoutList = new JComboBox(layoutStrings);
    }

    layoutList.setSelectedIndex(5);
    layoutList.addActionListener(this);
    layoutList.setName("SelectLayout");
    c.add(layoutList);

    /**
     * Add container to layout
     */
    c.setVisible(true);
    getContentPane().add(c, BorderLayout.SOUTH);

    /**
     * Setup history scroll bar
     */
    if (history != null) {
        historySlider = new JSlider(0, history.size() - 1, history.size() - 1);
        historySlider.addChangeListener(this);
        historySlider.setMajorTickSpacing(10);
        historySlider.setMinorTickSpacing(1);
        historySlider.setPaintTicks(true);
        historySlider.setPaintLabels(true);

        historySlider.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
        Font font = new Font("Serif", Font.ITALIC, 15);
        historySlider.setFont(font);

        getContentPane().add(historySlider, BorderLayout.NORTH);

    }
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.pack();
    this.setVisible(true);
}