Example usage for java.awt Font getStyle

List of usage examples for java.awt Font getStyle

Introduction

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

Prototype

public int getStyle() 

Source Link

Document

Returns the style of this Font .

Usage

From source file:ca.sqlpower.wabit.dao.session.FontConverter.java

public String convertToSimpleType(Font convertFrom, Object... additionalInfo) {
    StringBuffer buffer = new StringBuffer();
    buffer.append(convertToStandardFontName(convertFrom.getFontName()));
    buffer.append("-");
    buffer.append(FontStyle.getStyleByValue(convertFrom.getStyle()).getEncodedName());
    buffer.append("-");
    buffer.append(convertFrom.getSize());
    return buffer.toString();
}

From source file:de.codesourcery.eve.skills.ui.components.impl.ItemBrowserComponent.java

public ItemBrowserComponent() {
    super();// ww  w  .  j a  va 2s  . c  om
    itemTree.setRootVisible(false);

    final Font currFont = itemDetails.getFont();
    itemDetails.setFont(new Font("monospaced", currFont.getStyle(), currFont.getSize()));
}

From source file:NwFontChooserS.java

private NwFontChooserS(Frame parent, boolean modal, Font font) {
    super(parent, modal);
    initAll();//from   w  ww.j  ava 2  s  .  co  m
    setTitle("Font Choosr");
    if (font == null)
        font = Sample.getFont();
    FontList.setSelectedItem(font.getName());
    SizeList.setSelectedItem(font.getSize() + "");
    StyleList.setSelectedItem(styleList[font.getStyle()]);

}

From source file:com.petersoft.advancedswing.enhancedtextarea.EnhancedTextArea.java

private void jFontSmallerButtonActionPerformed(ActionEvent evt) {
    Font f = jTextArea.getFont();
    Font newFont = new Font(f.getFontName(), f.getStyle(), f.getSize() - 1);
    jTextArea.setFont(newFont);/*from w  w w .  j ava 2  s .  co m*/
    lines.setFont(newFont);
}

From source file:com.petersoft.advancedswing.enhancedtextarea.EnhancedTextArea.java

private void jFontBiggerButtonActionPerformed(ActionEvent evt) {
    Font f = jTextArea.getFont();
    Font newFont = new Font(f.getFontName(), f.getStyle(), f.getSize() + 1);
    jTextArea.setFont(newFont);/* w w  w. j  a va 2 s.com*/
    lines.setFont(newFont);
}

From source file:org.yardstickframework.report.jfreechart.JFreeChartGraphPlotter.java

/**
 * @param folderToWrite Folder to write the resulted charts.
 * @param plots Collections of plots./*from w  ww  . j  av  a 2s  . co m*/
 * @param infoMap Map with additional plot info.
 * @param mode Generation mode.
 * @throws Exception If failed.
 */
private static void processPlots(File folderToWrite, Collection<List<PlotData>> plots,
        Map<String, List<JFreeChartPlotInfo>> infoMap, JFreeChartGenerationMode mode) throws Exception {
    ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);

    int idx = -1;

    while (true) {
        idx++;

        DefaultXYDataset dataSet = new DefaultXYDataset();

        List<JFreeChartPlotInfo> infoList = new ArrayList<>();

        String xAxisLabel = "";
        String yAxisLabel = "";
        String plotName = "";

        int cnt = 0;

        for (List<PlotData> plotData0 : plots) {
            if (plotData0.size() <= idx)
                continue;

            PlotData plotData = plotData0.get(idx);

            dataSet.addSeries(plotData.plotName() + "_" + cnt++, plotData.series().data);

            xAxisLabel = plotData.xAxisLabel;
            yAxisLabel = plotData.yAxisLabel;
            plotName = plotData.plotName();

            infoList.add(info(plotData.series(), mode));
        }

        if (infoList.isEmpty())
            break;

        JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, dataSet,
                PlotOrientation.VERTICAL, false, false, false);

        AxisSpace as = new AxisSpace();

        as.add(150, RectangleEdge.LEFT);

        XYPlot plot = (XYPlot) chart.getPlot();

        BasicStroke stroke = new BasicStroke(1);

        plot.setRenderer(renderer);
        plot.setBackgroundPaint(WHITE);
        plot.setRangeGridlinePaint(GRAY);
        plot.setDomainGridlinePaint(GRAY);
        plot.setFixedRangeAxisSpace(as);
        plot.setOutlineStroke(stroke);

        for (int i = 0; i < infoList.size(); i++) {
            Color color = PLOT_COLORS[i % PLOT_COLORS.length];

            renderer.setSeriesPaint(i, color);
            renderer.setSeriesStroke(i, new BasicStroke(3)); // Line thickness.

            infoList.get(i).color(Integer.toHexString(color.getRGB()).substring(2));
        }

        ValueAxis axis = plot.getRangeAxis();

        Font font = new Font("Helvetica,Arial,sans-serif", Font.BOLD, axis.getTickLabelFont().getSize() + 5);

        axis.setTickLabelFont(font);
        axis.setLabelFont(font);
        plot.getDomainAxis().setTickLabelFont(font);
        plot.getDomainAxis().setLabelFont(font);

        chart.setTitle(new TextTitle(yAxisLabel, new Font(font.getName(), font.getStyle(), 30)));

        File res = new File(folderToWrite, plotName + ".png");

        ChartUtilities.saveChartAsPNG(res, chart, 1000, 500, info);

        infoMap.put(res.getAbsolutePath(), infoList);

        println("Chart is saved to file: ", res);
    }
}

From source file:net.sf.jabref.gui.mergeentries.MergeEntries.java

private JLabel boldFontLabel(String text) {
    JLabel label = new JLabel(text);
    Font font = label.getFont();
    label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
    return label;
}

From source file:ca.sqlpower.architect.swingui.TestPlayPenComponent.java

/**
 * Returns a new value that is not equal to oldVal. The
 * returned object will be a new instance compatible with oldVal.  
 * // w w w.j  a  v a  2s. c om
 * @param property The property that should be modified.
 * @param oldVal The existing value of the property to modify.  The returned value
 * will not equal this one at the time this method was first called.
 */
private Object getNewDifferentValue(PropertyDescriptor property, Object oldVal) throws SQLObjectException {
    Object newVal; // don't init here so compiler can warn if the
    // following code doesn't always give it a value
    if (property.getPropertyType() == String.class) {
        newVal = "new " + oldVal;
    } else if (property.getPropertyType() == Boolean.class || property.getPropertyType() == Boolean.TYPE) {
        if (oldVal == null) {
            newVal = new Boolean(false);
        } else {
            newVal = new Boolean(!((Boolean) oldVal).booleanValue());
        }
    } else if (property.getPropertyType() == Integer.class || property.getPropertyType() == Integer.TYPE) {
        if (oldVal == null) {
            newVal = new Integer(0);
        } else {
            newVal = new Integer(((Integer) oldVal).intValue() + 1);
        }
    } else if (property.getPropertyType() == Double.class || property.getPropertyType() == Double.TYPE) {
        if (oldVal == null) {
            newVal = new Double(0);
        } else {
            newVal = new Double(((Double) oldVal).doubleValue() + 1);
        }
    } else if (property.getPropertyType() == Color.class) {
        if (oldVal == null) {
            newVal = new Color(0xFAC157);
        } else {
            Color oldColor = (Color) oldVal;
            newVal = new Color((oldColor.getRGB() + 0xF00) % 0x1000000);
        }
    } else if (property.getPropertyType() == Font.class) {
        if (oldVal == null) {
            newVal = FontManager.getDefaultPhysicalFont();
        } else {
            Font oldFont = (Font) oldVal;
            newVal = new Font(oldFont.getFontName(), oldFont.getSize() + 2, oldFont.getStyle());
        }
    } else if (property.getPropertyType() == Point.class) {
        if (oldVal == null) {
            newVal = new Point();
        } else {
            Point oldPoint = (Point) oldVal;
            newVal = new Point(oldPoint.x + 10, oldPoint.y + 10);
        }
    } else if (property.getPropertyType() == Insets.class) {
        if (oldVal == null) {
            newVal = new Insets(0, 0, 0, 0);
        } else {
            Insets oldInsets = (Insets) oldVal;
            newVal = new Insets(oldInsets.top + 10, oldInsets.left + 10, oldInsets.bottom + 10,
                    oldInsets.right + 10);
        }
    } else if (property.getPropertyType() == Set.class) {
        newVal = new HashSet();
        if (property.getName().equals("hiddenColumns")) {
            ((Set) newVal).add(new SQLColumn());
        } else {
            ((Set) newVal).add("Test");
        }
    } else if (property.getPropertyType() == List.class) {
        newVal = new ArrayList();
        if (property.getName().equals("selectedColumns")) {
            ((List) newVal).add(new SQLColumn());
        } else {
            ((List) newVal).add("Test");
        }
    } else if (property.getPropertyType() == TablePane.class) {
        SQLTable t = new SQLTable();
        t.initFolders(true);
        newVal = new TablePane(t, pp.getContentPane());
    } else if (property.getPropertyType() == SQLTable.class) {
        newVal = new SQLTable();
        ((SQLTable) newVal).initFolders(true);
    } else if (property.getPropertyType() == Dimension.class) {
        newVal = new Dimension();
        if (oldVal != null) {
            ((Dimension) newVal).width = ((Dimension) oldVal).width + 1;
        }
    } else {
        throw new RuntimeException("This test case lacks a value for " + property.getName() + " (type "
                + property.getPropertyType().getName() + ") in getNewDifferentValue()");
    }

    return newVal;
}

From source file:com.tulskiy.musique.system.configuration.Configuration.java

public void setFont(String key, Font value) {
    if (value == null)
        remove(key);// w ww .j a  v a  2 s .c  o  m
    else {
        String s = new Formatter().format("%s, %d, %d", value.getName(), value.getStyle(), value.getSize())
                .toString();
        put(key, s);
    }
}

From source file:com.haulmont.cuba.desktop.gui.components.SwingXTableSettings.java

protected void saveFontPreferences(Element element) {
    if (table.getFont() != null) {
        Font font = table.getFont();
        Map<TextAttribute, ?> attributes = font.getAttributes();
        // save content font
        element.addAttribute("fontFamily", font.getFamily());
        element.addAttribute("fontSize", Integer.toString(font.getSize()));
        element.addAttribute("fontStyle", Integer.toString(font.getStyle()));
        element.addAttribute("fontUnderline",
                Boolean.toString(attributes.get(TextAttribute.UNDERLINE) == TextAttribute.UNDERLINE_ON));
    }/*from  w  ww . j  a  v a2s.  c  o m*/
}