Example usage for java.awt Font decode

List of usage examples for java.awt Font decode

Introduction

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

Prototype

public static Font decode(String str) 

Source Link

Document

Returns the Font that the str argument describes.

Usage

From source file:ca.phon.ipamap.IpaMap.java

/**
 * Get font pref
 */
private static Font getFontPref() {
    return PrefHelper.getFont(FONT_PROP, Font.decode(DEFAULT_FONT));
}

From source file:ffx.ui.ModelingPanel.java

private JPanel getAminoAcidPanel() {
    if (aminoPanel != null) {
        return aminoPanel;
    }//from w w w. j  a v  a  2 s .  co m
    JPanel buttonPanel = new JPanel(new GridLayout(4, 5, 2, 2));
    Residue.AA3 a[] = Residue.AA3.values();
    for (int i = 0; i < 20; i++) {
        JButton button = new JButton(a[i].name());
        button.setActionCommand("PROTEIN");
        button.addActionListener(this);
        buttonPanel.add(button);
    }
    buttonPanel.setMaximumSize(buttonPanel.getPreferredSize());
    aminoPanel = new JPanel();
    aminoPanel.setLayout(new BoxLayout(aminoPanel, BoxLayout.Y_AXIS));
    aminoPanel.add(buttonPanel);
    conformationComboBox = new JComboBox<>(Residue.Ramachandran);
    conformationComboBox.setFont(Font.decode("Monospaced"));
    conformationComboBox.setMaximumSize(buttonPanel.getPreferredSize());
    aminoPanel.add(conformationComboBox);
    return aminoPanel;
}

From source file:ffx.ui.ModelingPanel.java

private void initialize() {
    // Command Description
    descriptTextArea = new JTextArea();
    descriptTextArea.setEditable(false);
    descriptTextArea.setLineWrap(true);/*from  www  .j  a  v  a2 s  .co  m*/
    descriptTextArea.setWrapStyleWord(true);
    descriptTextArea.setDoubleBuffered(true);
    Insets insets = descriptTextArea.getInsets();
    insets.set(5, 5, 5, 5);
    descriptTextArea.setMargin(insets);
    descriptScrollPane = new JScrollPane(descriptTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    descriptScrollPane.setBorder(etchedBorder);
    // Command Input
    commandTextArea = new JTextArea();
    commandTextArea.setEditable(false);
    commandTextArea.setLineWrap(true);
    commandTextArea.setWrapStyleWord(true);
    commandTextArea.setDoubleBuffered(true);
    commandTextArea.setMargin(insets);
    // Command Options
    optionsTabbedPane = new JTabbedPane();
    statusLabel = new JLabel();
    statusLabel.setBorder(etchedBorder);
    statusLabel.setToolTipText("  Modeling command that will be executed");
    commandPanel = new JPanel(flowLayout);
    commandPanel.add(optionsTabbedPane);
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, commandPanel, descriptScrollPane);
    splitPane.setContinuousLayout(true);
    splitPane.setResizeWeight(1.0d);
    splitPane.setOneTouchExpandable(true);
    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);
    add(statusLabel, BorderLayout.SOUTH);
    // Initialize the Amino/Nucleic Acid ComboBox.
    acidComboBox.setEditable(false);
    acidComboBox.setMaximumSize(sizer.getPreferredSize());
    acidComboBox.setPreferredSize(sizer.getPreferredSize());
    acidComboBox.setMinimumSize(sizer.getPreferredSize());
    acidComboBox.setFont(Font.decode("Monospaced"));
    acidTextField.setMaximumSize(sizer.getPreferredSize());
    acidTextField.setMinimumSize(sizer.getPreferredSize());
    acidTextField.setPreferredSize(sizer.getPreferredSize());
    acidTextArea.setEditable(false);
    acidTextArea.setWrapStyleWord(true);
    acidTextArea.setLineWrap(true);
    acidTextArea.setFont(Font.decode("Monospaced"));
    acidScrollPane = new JScrollPane(acidTextArea);
    Dimension d = new Dimension(300, 400);
    acidScrollPane.setPreferredSize(d);
    acidScrollPane.setMaximumSize(d);
    acidScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    // Load the FFX commands.xml file that defines FFX commands.
    try {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        db.setEntityResolver(new DTDResolver());
        URL comURL = getClass().getClassLoader().getResource("ffx/ui/commands/commands.xml");
        Document doc = db.parse(comURL.openStream());
        NodeList nodelist = doc.getChildNodes();
        Node commandroot = null;
        for (int i = 0; i < nodelist.getLength(); i++) {
            commandroot = nodelist.item(i);
            if (commandroot.getNodeName().equals("FFXCommands") && commandroot instanceof Element) {
                break;
            }
        }
        if (commandroot == null || !(commandroot instanceof Element)) {
            commandList = null;
        }
        commandList = ((Element) commandroot).getElementsByTagName("Command");
    } catch (ParserConfigurationException | SAXException | IOException e) {
        System.err.println(e);
    } finally {
        if (commandList == null) {
            System.out.println("Force Field X commands.xml could not be parsed.");
            logger.severe("Force Field X will exit.");
            System.exit(-1);
        }
    }
    // Create a ComboBox with commands specific to each type of coordinate
    // file.
    xyzCommands = new JComboBox<>();
    intCommands = new JComboBox<>();
    arcCommands = new JComboBox<>();
    pdbCommands = new JComboBox<>();
    anyCommands = new JComboBox<>();
    Element command;
    String name;
    int numcommands = commandList.getLength();
    for (int i = 0; i < numcommands; i++) {
        command = (Element) commandList.item(i);
        name = command.getAttribute("name");
        String temp = command.getAttribute("fileType");
        if (temp.contains("ANY")) {
            temp = "XYZ INT ARC PDB";
            anyCommands.addItem(name);
        }
        String[] types = temp.split(" +");
        for (String type : types) {
            if (type.contains("XYZ")) {
                xyzCommands.addItem(name);
            }
            if (type.contains("INT")) {
                intCommands.addItem(name);
            }
            if (type.contains("ARC")) {
                arcCommands.addItem(name);
            }
            if (type.contains("PDB")) {
                pdbCommands.addItem(name);
            }
        }
    }
    initCommandComboBox(xyzCommands);
    initCommandComboBox(intCommands);
    initCommandComboBox(arcCommands);
    initCommandComboBox(pdbCommands);
    initCommandComboBox(anyCommands);
    currentCommandBox = anyCommands;
    activeCommand = (String) anyCommands.getSelectedItem();
    // Load the default Command.
    loadCommand();
    // Load the default Log File Settings.
    logSettings.setActionCommand("LogSettings");
    loadLogSettings();

    // Create the Toolbar.
    toolBar = new JToolBar("Modeling Commands", JToolBar.HORIZONTAL);
    toolBar.setLayout(new FlowLayout(FlowLayout.LEFT));
    jbLaunch = new JButton(new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/cog_go.png")));
    jbLaunch.setActionCommand("Launch");
    jbLaunch.setToolTipText("Launch the Force Field X Command");
    jbLaunch.addActionListener(this);
    insets.set(2, 2, 2, 2);
    jbLaunch.setMargin(insets);
    toolBar.add(jbLaunch);
    jbStop = new JButton(new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/stop.png")));
    jbStop.setActionCommand("End");
    jbStop.setToolTipText("Terminate the Current Force Field X Command");
    jbStop.addActionListener(this);
    jbStop.setMargin(insets);
    jbStop.setEnabled(false);
    toolBar.add(jbStop);
    toolBar.addSeparator();
    toolBar.add(anyCommands);
    currentCommandBox = anyCommands;
    toolBar.addSeparator();
    /*
     toolBar.add(logSettings);
     JButton jbdelete = new JButton(new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/page_delete.png")));
     jbdelete.setActionCommand("Delete");
     jbdelete.setToolTipText("Delete Log Files");
     jbdelete.addActionListener(this);
     jbdelete.setMargin(insets);
     toolBar.add(jbdelete);
     toolBar.addSeparator();
     */
    ImageIcon icinfo = new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/information.png"));
    descriptCheckBox = new JCheckBoxMenuItem(icinfo);
    descriptCheckBox.addActionListener(this);
    descriptCheckBox.setActionCommand("Description");
    descriptCheckBox.setToolTipText("Show/Hide Modeling Command Descriptions");
    descriptCheckBox.setMargin(insets);
    toolBar.add(descriptCheckBox);
    toolBar.add(new JLabel(""));
    toolBar.setBorderPainted(false);
    toolBar.setFloatable(false);
    toolBar.setRollover(true);
    add(toolBar, BorderLayout.NORTH);
    // Load ModelingPanel preferences.
    Preferences prefs = Preferences.userNodeForPackage(ffx.ui.ModelingPanel.class);
    descriptCheckBox.setSelected(!prefs.getBoolean("JobPanel_description", true));
    descriptCheckBox.doClick();
}

From source file:de._13ducks.cor.graphics.GraphicsComponent.java

public GraphicsComponent() {
    cgc = getGraphicsConfiguration();/* w  ww. j  a  va  2s. com*/
    interSelFields = new ArrayList<GameObject[]>();
    grayImgMap = new HashMap<String, CoRImage>();
    // Fonts initialisieren
    fonts = new Font[5];
    fonts[0] = Font.decode("Mono-10");
    fonts[1] = Font.decode("Mono-Bold-12");
    fonts[2] = Font.decode("Mono-Bold-10");
    fonts[3] = Font.decode("Mono-Italic-10");
    fonts[4] = Font.decode("Mono-8");

    optList = new ArrayList<Ability>();
}

From source file:ca.phon.ipamap.IpaMap.java

@Override
public Font getFont() {
    if (_cFont == null) {
        int fmin = 12;
        int fmax = 36;

        float fontSize = fmin + (scale) * (fmax - fmin);
        if (baseFont == null)
            baseFont = Font.decode(null);
        _cFont = baseFont.deriveFont(fontSize);
    }/*from   w w w  .  j a  v a2  s  .com*/
    return _cFont;
}

From source file:ffx.ui.MainPanel.java

private void initAbout() {
    aboutTextArea = new JTextArea();
    Font font = Font.decode(Font.MONOSPACED);
    aboutTextArea.setFont(font);//w  ww .j ava  2 s  .co  m
    aboutTextArea.setText(aboutString);
    aboutTextArea.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
    aboutTextArea.setEditable(false);
}

From source file:org.nuclos.client.ui.collect.Chart.java

private static Font fontFromString(String font) {
    return Font.decode(font);
}

From source file:nz.ac.waikato.cms.supernova.gui.Supernova.java

/**
 * Creates the panel for batch generation.
 *
 * @return      the panel/*from w ww  . j  av  a  2  s. com*/
 */
protected BasePanel createBatchPanel() {
    BasePanel result;
    JPanel params;
    JPanel left1;
    JPanel left2;
    JPanel panel;

    result = new BasePanel(new BorderLayout());
    m_BatchLog = new JTextArea(20, 40);
    m_BatchLog.setFont(Font.decode("Monospaced-PLAIN-12"));
    result.add(new BaseScrollPane(m_BatchLog), BorderLayout.CENTER);

    left1 = new JPanel(new BorderLayout());
    result.add(left1, BorderLayout.WEST);

    // params with height 2
    params = new JPanel(new GridLayout(0, 1));
    left1.add(params, BorderLayout.NORTH);

    m_BatchColors = new ColorTable();
    left1.add(new BaseScrollPane(m_BatchColors), BorderLayout.NORTH);

    // params with height 1
    panel = new JPanel(new BorderLayout());
    left1.add(panel, BorderLayout.CENTER);
    left2 = new JPanel(new BorderLayout());
    panel.add(left2, BorderLayout.NORTH);
    params = new JPanel(new GridLayout(0, 1));
    left2.add(params, BorderLayout.NORTH);

    // background
    m_BatchBackground = new ColorButton(Color.BLACK);
    params.add(createParameter("Background", m_BatchBackground));

    // opacity
    m_BatchOpacity = new JSpinner();
    m_BatchOpacity.setValue(10);
    ((SpinnerNumberModel) m_BatchOpacity.getModel()).setMinimum(0);
    ((SpinnerNumberModel) m_BatchOpacity.getModel()).setMaximum(100);
    ((SpinnerNumberModel) m_BatchOpacity.getModel()).setStepSize(10);
    ((JSpinner.DefaultEditor) m_BatchOpacity.getEditor()).getTextField().setColumns(5);
    params.add(createParameter("Opacity %", m_BatchOpacity));

    // margin
    m_BatchMargin = new JSpinner();
    m_BatchMargin.setValue(20);
    ((SpinnerNumberModel) m_BatchMargin.getModel()).setMinimum(0);
    ((SpinnerNumberModel) m_BatchMargin.getModel()).setMaximum(100);
    ((SpinnerNumberModel) m_BatchMargin.getModel()).setStepSize(10);
    ((JSpinner.DefaultEditor) m_BatchMargin.getEditor()).getTextField().setColumns(5);
    params.add(createParameter("Margin %", m_BatchMargin));

    // width
    m_BatchWidth = new JSpinner();
    m_BatchWidth.setValue(400);
    ((SpinnerNumberModel) m_BatchWidth.getModel()).setMinimum(1);
    ((SpinnerNumberModel) m_BatchWidth.getModel()).setStepSize(100);
    ((JSpinner.DefaultEditor) m_BatchWidth.getEditor()).getTextField().setColumns(5);
    params.add(createParameter("Width", m_BatchWidth));

    // height
    m_BatchHeight = new JSpinner();
    m_BatchHeight.setValue(400);
    ((SpinnerNumberModel) m_BatchHeight.getModel()).setMinimum(1);
    ((SpinnerNumberModel) m_BatchHeight.getModel()).setStepSize(100);
    ((JSpinner.DefaultEditor) m_BatchHeight.getEditor()).getTextField().setColumns(5);
    params.add(createParameter("Height", m_BatchHeight));

    // generator
    m_BatchGenerator = new JComboBox<>(Registry.toStringArray(Registry.getGenerators(), true));
    params.add(createParameter("Generator", m_BatchGenerator));

    // center
    m_BatchCenter = new JComboBox<>(Registry.toStringArray(Registry.getCenters(), true));
    params.add(createParameter("Center", m_BatchCenter));

    // csv
    m_BatchCSV = new FileChooserPanel();
    m_BatchCSV.addChoosableFileFilter(new ExtensionFileFilter("CSV files", "csv"));
    m_BatchCSV.setPreferredSize(new Dimension(170, (int) m_BatchCSV.getPreferredSize().getHeight()));
    params.add(createParameter("CSV", m_BatchCSV));

    // output
    m_BatchOutput = new DirectoryChooserPanel();
    m_BatchOutput.setPreferredSize(new Dimension(170, (int) m_BatchOutput.getPreferredSize().getHeight()));
    params.add(createParameter("Output", m_BatchOutput));

    // generate
    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    m_BatchGenerate = new JButton("Generate");
    m_BatchGenerate.addActionListener((ActionEvent e) -> {
        SwingWorker worker = new SwingWorker() {
            @Override
            protected Object doInBackground() throws Exception {
                generateBatchOutput();
                return null;
            }
        };
        worker.execute();
    });
    panel.add(m_BatchGenerate);
    params.add(panel);

    adjustLabels();

    return result;
}

From source file:org.apache.pdfbox.pdmodel.font.PDSimpleFont.java

/**
 * {@inheritDoc}/*from  ww w. ja  v  a2 s . c  o m*/
 */
public void drawString(String string, int[] codePoints, Graphics g, float fontSize, AffineTransform at, float x,
        float y) throws IOException {
    Font awtFont = getawtFont();
    FontRenderContext frc = new FontRenderContext(new AffineTransform(), true, true);
    GlyphVector glyphs = null;
    boolean useCodepoints = codePoints != null && isType0Font();
    PDFont descendantFont = useCodepoints ? ((PDType0Font) this).getDescendantFont() : null;
    // symbolic fonts may trigger the same fontmanager.so/dll error as described below
    if (useCodepoints && !descendantFont.getFontDescriptor().isSymbolic()) {
        PDCIDFontType2Font cid2Font = null;
        if (descendantFont instanceof PDCIDFontType2Font) {
            cid2Font = (PDCIDFontType2Font) descendantFont;
        }
        if ((cid2Font != null && cid2Font.hasCIDToGIDMap()) || isFontSubstituted) {
            // we still have to use the string if a CIDToGIDMap is used 
            glyphs = awtFont.createGlyphVector(frc, string);
        } else {
            glyphs = awtFont.createGlyphVector(frc, codePoints);
        }
    } else {
        // mdavis - fix fontmanager.so/dll on sun.font.FileFont.getGlyphImage
        // for font with bad cmaps?
        // Type1 fonts are not affected as they don't have cmaps
        if (!isType1Font() && awtFont.canDisplayUpTo(string) != -1) {
            LOG.warn("Changing font on <" + string + "> from <" + awtFont.getName() + "> to the default font");
            awtFont = Font.decode(null).deriveFont(1f);
        }
        glyphs = awtFont.createGlyphVector(frc, string);
    }
    Graphics2D g2d = (Graphics2D) g;
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    writeFont(g2d, at, x, y, glyphs);
}

From source file:org.colombbus.tangara.Configuration.java

/**
 * Get a font from the configuration/*  w w  w.j a v a 2 s .  c o  m*/
 *
 * @param prefix
 *            property prefix
 * @param defaultValue
 *            default font used if an error occurs
 * @return the font associated to the property <code>prefix</code>, or
 *         <code>defaultValue</code> if no font is found or if an error
 *         occurs.
 */
public Font getFont(String key, Font defaultValue) {
    String fontDesc = null;
    try {
        fontDesc = getProperty(key);
    } catch (MissingResourceException e) {
        LOG.warn("Could not find font resource " + key);//$NON-NLS-1$
    }
    if (fontDesc != null) {
        fontDesc = fontDesc.trim();
    }
    return Font.decode(fontDesc);
}