Example usage for java.awt Font PLAIN

List of usage examples for java.awt Font PLAIN

Introduction

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

Prototype

int PLAIN

To view the source code for java.awt Font PLAIN.

Click Source Link

Document

The plain style constant.

Usage

From source file:daylightchart.sunchart.chart.SunChart.java

private void createAltitudeAxis(final XYPlot plot) {
    final NumberAxis axis = new NumberAxis();
    axis.setTickLabelFont(ChartConfiguration.chartFont.deriveFont(Font.PLAIN, 12));
    ///*from   w w w.j a  v a  2 s. c  om*/
    plot.setRangeAxis(axis);
}

From source file:de.berlios.statcvs.xml.chart.AbstractChart.java

/**
 * create chart with titles and credit information
 *///  www.j  a va 2 s.c o  m
protected void setup(boolean defaultShowLegend) {
    if (chart == null) {
        throw new NullPointerException("Chart is not initialized");
    }

    if (this.subtitle != null && settings.getBoolean("showSubtitle", true)) {
        Font font = new Font("SansSerif", Font.PLAIN, 12);
        TextTitle title = new TextTitle(this.subtitle, font);
        title.setSpacer(new Spacer(Spacer.RELATIVE, 0.05, 0.05, 0.05, 0.0));
        chart.addSubtitle(title);
    }

    if (settings.getBoolean("showCredit", true)) {
        Font font = new Font("SansSerif", Font.PLAIN, 9);
        TextTitle copyright = new TextTitle("generated by statcvs-xml\u00B2", font);
        copyright.setPosition(RectangleEdge.BOTTOM);
        copyright.setHorizontalAlignment(HorizontalAlignment.RIGHT);
        chart.addSubtitle(copyright);
    }

    if (!settings.getBoolean("showLegend", defaultShowLegend)) {
        chart.setLegend(null);
    }

    chart.setBackgroundPaint(Color.white);
}

From source file:playground.anhorni.counts.StdDevBoxPlot.java

public JFreeChart createChart() {
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

    ArrayList<Double>[] lists = this.createArrayLists();

    // add the collected values to the graph / dataset
    for (int i = 0; i < 24; i++) {
        dataset.add(lists[i], "hour", Integer.toString(i + 1));
    }/*from  w  ww  .j a  v a  2  s .co m*/
    final CategoryAxis xAxis = new CategoryAxis(xlabel);
    xAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 10));
    //xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    final NumberAxis yAxis = new NumberAxis(ylabel);
    yAxis.setAutoRangeIncludesZero(true);

    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setSeriesPaint(0, Color.blue);
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    this.chart_ = new JFreeChart(chartTitle, new Font("SansSerif", Font.BOLD, 14), plot, false);
    return this.chart_;
}

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

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

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

    JFreeChart chart = getChart("summary.chart1", 0);
    Plot plot = chart.getPlot();
    Assert.assertEquals("renderer", ThermometerPlot.class, plot.getClass());
    ThermometerPlot thermometerPlot = (ThermometerPlot) plot;
    Assert.assertEquals("value", 15, thermometerPlot.getDataset().getValue());
    Assert.assertEquals("data range low", 3d, thermometerPlot.getLowerBound());
    Assert.assertEquals("data range high", 30d, thermometerPlot.getUpperBound());
    Assert.assertEquals("value color", Color.BLUE, thermometerPlot.getValuePaint());
    try {
        Field field = thermometerPlot.getClass().getDeclaredField("valueFormat");
        field.setAccessible(true);
        Assert.assertEquals("value mask", "15.0", ((NumberFormat) field.get(thermometerPlot)).format(15));
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail(e.getMessage());
    }
    Assert.assertEquals("value font", new Font("Arial", Font.PLAIN, 10), thermometerPlot.getValueFont());
    Assert.assertEquals("value location", ThermometerPlot.BULB, thermometerPlot.getValueLocation());
    Assert.assertEquals("mercury color", Color.LIGHT_GRAY, thermometerPlot.getMercuryPaint());
    try {
        Field field = thermometerPlot.getClass().getDeclaredField("subrangeInfo");
        field.setAccessible(true);
        double[][] subrangeInfo = (double[][]) field.get(thermometerPlot);
        Assert.assertEquals("low data range low", 8d, subrangeInfo[2][0]);
        Assert.assertEquals("low data range high", 10d, subrangeInfo[2][1]);
        Assert.assertEquals("medium data range low", 18d, subrangeInfo[1][0]);
        Assert.assertEquals("medium data range high", 20d, subrangeInfo[1][1]);
        Assert.assertEquals("high data range low", 28d, subrangeInfo[0][0]);
        Assert.assertEquals("high data range high", 30d, subrangeInfo[0][1]);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail(e.getMessage());
    }
}

From source file:Text2DTest1.java

TransformGroup createText2D(String szText, Color3f color, int nSize, float scale, float trans) {
    TransformGroup tg = new TransformGroup();
    Transform3D t3d = new Transform3D();
    t3d.setScale(scale);//from  w  w  w . ja  v a  2  s.com
    t3d.setTranslation(new Vector3d(-8.0, trans, 0));

    tg.setTransform(t3d);

    Text2D text2D = new Text2D(szText, color, "SansSerif", nSize, Font.PLAIN);

    tg.addChild(text2D);
    return tg;
}

From source file:eu.irreality.age.SwingAetheriaGameLoaderInterface.java

public static void loadFont() {

    //cargar configuracin del ini

    String fontName = "Courier New";
    int fontSize = 12;
    try {//  w ww . j ava 2 s.  c o m
        BufferedReader iniReader = new BufferedReader(
                Utility.getBestInputStreamReader(new FileInputStream("age.cfg")));
        String linea;
        for (int line = 1; line < 100; line++) {
            linea = iniReader.readLine();
            if (linea != null) {
                //System.out.println("Linea " + linea );
                String codigo = StringMethods.getTok(linea, 1, '=').trim().toLowerCase();
                if (codigo.equals("font name")) {
                    //System.out.println("Nombre: " + StringMethods.getTok(linea,2,'=').trim() );
                    fontName = StringMethods.getTok(linea, 2, '=').trim();
                } else if (codigo.equals("font size")) {
                    fontSize = Integer.parseInt(StringMethods.getTok(linea, 2, '=').trim());
                }
            }
        }
    }
    //las excepciones nos la sudan porque hay valores por defecto
    catch (FileNotFoundException fnfe) {
        ;
    } catch (NumberFormatException nfe) {
        ;
    } catch (IOException ioe) {
        ;
    } catch (SecurityException se) //applet mode
    {
        ;
    }
    Font[] fuentes = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
    Font fuenteElegida;
    for (int f = 0; f < fuentes.length; f++) {
        if (fuentes[f].getFontName().equalsIgnoreCase(fontName)) {
            SwingAetheriaGameLoaderInterface.font = fuentes[f].deriveFont((float) fontSize);
            break;
        }
        //System.out.println("Fuente: " + fuentes[f]);
    }

    //System.err.println("He seleccionado mi fuente, y es: " + SwingAetheriaGameLoaderInterface.font  );

    //font not selected? be less picky
    if (SwingAetheriaGameLoaderInterface.font == null) {
        String[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
        Arrays.sort(fonts);
        if (Arrays.binarySearch(fonts, "Courier New") >= 0) {
            SwingAetheriaGameLoaderInterface.font = new Font("Courier New", Font.PLAIN, 12);
        } else if (Arrays.binarySearch(fonts, "Courier") >= 0) {
            SwingAetheriaGameLoaderInterface.font = new Font("Courier", Font.PLAIN, 12);
        } else if (Arrays.binarySearch(fonts, "Monospaced") >= 0) {
            SwingAetheriaGameLoaderInterface.font = new Font("Monospaced", Font.PLAIN, 13);
        }
    }

    //still not selected? well, in that case just default to font 0
    if (SwingAetheriaGameLoaderInterface.font == null)
        SwingAetheriaGameLoaderInterface.font = fuentes[0].deriveFont((float) fontSize);
}

From source file:y.graphs.ChartHelperELF.java

private static JFreeChart createChart(final TimeSeriesCollection dataset, Date from, Date to, Config config,
        ArrayList<ConfigSerie> series) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(Config.getResource("MsgTitleMagGraph"),
            Config.getResource("TitleDate"), Config.getResource("MsgTitleMagGraphYAxis"), dataset, true, // include legend
            true, // tooltips
            false // urls
    );/*from  ww w .  ja  v  a2  s. c  o  m*/

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    LegendTitle lt = new LegendTitle(plot);
    lt.setItemFont(new Font("Dialog", Font.PLAIN, 12));
    lt.setBackgroundPaint(Color.white);
    lt.setFrame(new BlockBorder(Color.white));
    lt.setVerticalAlignment(VerticalAlignment.CENTER);
    XYTitleAnnotation ta = new XYTitleAnnotation(config.getLegendX(), config.getLegendY(), lt,
            RectangleAnchor.TOP_RIGHT);
    ta.setMaxWidth(config.getLegendSize());
    plot.addAnnotation(ta);
    chart.removeLegend();

    plot.setBackgroundPaint(config.getColorBackgroundELF());
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    final Stroke lineStroke = new BasicStroke((float) config.getLineWidthELF());

    for (int si = 0; si < series.size(); si++) {
        final ConfigSerie cs = series.get(si);
        renderer.setSeriesLinesVisible(si, cs.isDrawLine());

        final float size = cs.getShapeSize();
        renderer.setSeriesShapesVisible(si, size > 0);
        if (size > 0)
            renderer.setSeriesShape(si, ShapeUtilities.createRegularCross(size, size));

        renderer.setSeriesStroke(si, lineStroke);
        //            renderer.setSeriesOutlineStroke(si, lineStroke);
        renderer.setSeriesPaint(si, cs.getColor());
    }
    plot.setRenderer(renderer);

    // x axis
    final DateAxis rangeAxis = (DateAxis) plot.getDomainAxis();
    //        rangeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits()); // Returns a collection of standard date tick units that uses the default time zone. This collection will be used by default, but you are free to create your own collection if you want to
    rangeAxis.setAutoRange(true);
    //        rangeAxis.setRange(from, to);
    rangeAxis.setLowerMargin(0.01);
    rangeAxis.setUpperMargin(0.01);

    {
        final Font axisFont = config.getAxisFont();
        if (axisFont != null) {
            rangeAxis.setLabelFont(axisFont);
            plot.getRangeAxis().setLabelFont(axisFont);
        }
    }

    final String xaxisFmt = config.getAxisFormat();

    if (xaxisFmt == null || xaxisFmt.isEmpty()) {
        double diffInDays = (to.getTime() - from.getTime()) / (1000.0 * 60.0 * 60.0 * 24.0);
        if (diffInDays < 2)
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_TIMEFMT, DateFormatSymbols.getInstance()));
        else
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_SHORTTIMEFMT, DateFormatSymbols.getInstance()));
    } else
        rangeAxis.setDateFormatOverride(new SimpleDateFormat(xaxisFmt, DateFormatSymbols.getInstance()));

    final ValueAxis domain = plot.getRangeAxis();
    if (config.getForceYmin() != 0 || config.getForceYmax() != 0)
        domain.setRange(ElfValue.valueIntToDouble(config.getForceYmin()),
                ElfValue.valueIntToDouble(config.getForceYmax()));

    // title
    final Font titleFont = config.getTitleFont();
    if (titleFont != null)
        chart.getTitle().setFont(titleFont);

    return chart;
}

From source file:y.graphs.ChartHelperSRB.java

private static JFreeChart createChart(final TimeSeriesCollection dataset, Date from, Date to, Config config,
        ArrayList<ConfigSerie> series) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(Config.getResource("MsgTitleSrbGraph"),
            Config.getResource("TitleDate"), Config.getResource("MsgTitleSrbGraphYAxis"), dataset, true, // include legend
            true, // tooltips
            false // urls
    );//from  www .  j a v a2 s  .  c  om

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    LegendTitle lt = new LegendTitle(plot);
    lt.setItemFont(new Font("Dialog", Font.PLAIN, 12));
    lt.setBackgroundPaint(Color.white);
    lt.setFrame(new BlockBorder(Color.white));
    lt.setVerticalAlignment(VerticalAlignment.CENTER);
    XYTitleAnnotation ta = new XYTitleAnnotation(config.getLegendX(), config.getLegendY(), lt,
            RectangleAnchor.TOP_RIGHT);
    ta.setMaxWidth(config.getLegendSize());
    plot.addAnnotation(ta);
    chart.removeLegend();

    plot.setBackgroundPaint(config.getColorBackgroundSRB());
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    final Stroke lineStroke = new BasicStroke((float) config.getLineWidthSRB());

    for (int si = 0; si < series.size(); si++) {
        final ConfigSerie cs = series.get(si);
        renderer.setSeriesLinesVisible(si, cs.isDrawLine());

        final float size = cs.getShapeSize();
        renderer.setSeriesShapesVisible(si, size > 0);
        if (size > 0)
            renderer.setSeriesShape(si, ShapeUtilities.createRegularCross(size, size));

        renderer.setSeriesStroke(si, lineStroke);
        //          renderer.setSeriesOutlineStroke(si, lineStroke);
        renderer.setSeriesPaint(si, cs.getColor());
    }
    plot.setRenderer(renderer);

    // x axis
    final DateAxis rangeAxis = (DateAxis) plot.getDomainAxis();
    //      rangeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits()); // Returns a collection of standard date tick units that uses the default time zone. This collection will be used by default, but you are free to create your own collection if you want to
    rangeAxis.setAutoRange(true);
    //        rangeAxis.setRange(from, to);
    rangeAxis.setLowerMargin(0.01);
    rangeAxis.setUpperMargin(0.01);

    {
        final Font axisFont = config.getAxisFont();
        if (axisFont != null) {
            rangeAxis.setLabelFont(axisFont);
            plot.getRangeAxis().setLabelFont(axisFont);
        }
    }

    final String xaxisFmt = config.getAxisFormat();

    if (xaxisFmt == null || xaxisFmt.isEmpty()) {
        double diffInDays = (to.getTime() - from.getTime()) / (1000.0 * 60.0 * 60.0 * 24.0);
        if (diffInDays < 2)
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_TIMEFMT, DateFormatSymbols.getInstance()));
        else
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_SHORTTIMEFMT, DateFormatSymbols.getInstance()));
    } else
        rangeAxis.setDateFormatOverride(new SimpleDateFormat(xaxisFmt, DateFormatSymbols.getInstance()));

    final ValueAxis domain = plot.getRangeAxis();
    if (config.getForceYmin() != 0 || config.getForceYmax() != 0)
        domain.setRange(ElfValue.valueIntToDouble(config.getForceYmin()),
                ElfValue.valueIntToDouble(config.getForceYmax()));

    // title
    final Font titleFont = config.getTitleFont();
    if (titleFont != null)
        chart.getTitle().setFont(titleFont);

    return chart;
}

From source file:Text3DApp.java

public BranchGroup createSceneGraph() {
    // Create the root of the branch graph
    BranchGroup objRoot = new BranchGroup();

    Transform3D t3D = new Transform3D();
    t3D.setTranslation(new Vector3f(0.0f, 0.0f, -3.0f));
    TransformGroup objMove = new TransformGroup(t3D);
    objRoot.addChild(objMove);/*w w  w. ja v a 2s . c o  m*/

    // Create the transform group node and initialize it to the
    // identity. Add it to the root of the subgraph.
    TransformGroup objSpin = new TransformGroup();
    objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objMove.addChild(objSpin);

    Appearance textAppear = new Appearance();
    ColoringAttributes textColor = new ColoringAttributes();
    textColor.setColor(1.0f, 0.0f, 0.0f);
    textAppear.setColoringAttributes(textColor);
    textAppear.setMaterial(new Material());

    // Create a simple shape leaf node, add it to the scene graph.
    Font3D font3D = new Font3D(new Font("Helvetica", Font.PLAIN, 1), new FontExtrusion());
    Text3D textGeom = new Text3D(font3D, new String("3DText"));
    textGeom.setAlignment(Text3D.ALIGN_CENTER);
    Shape3D textShape = new Shape3D();
    textShape.setGeometry(textGeom);
    textShape.setAppearance(textAppear);
    objSpin.addChild(textShape);

    // Create a new Behavior object that will perform the desired
    // operation on the specified transform object and add it into
    // the scene graph.
    Alpha rotationAlpha = new Alpha(-1, 10000);

    RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objSpin);

    // a bounding sphere specifies a region a behavior is active
    // create a sphere centered at the origin with radius of 100
    BoundingSphere bounds = new BoundingSphere();
    rotator.setSchedulingBounds(bounds);
    objSpin.addChild(rotator);

    DirectionalLight lightD = new DirectionalLight();
    lightD.setInfluencingBounds(bounds);
    lightD.setDirection(new Vector3f(0.0f, 0.0f, -1.0f));
    lightD.setColor(new Color3f(1.0f, 0.0f, 1.0f));
    objMove.addChild(lightD);

    AmbientLight lightA = new AmbientLight();
    lightA.setInfluencingBounds(bounds);
    objMove.addChild(lightA);

    return objRoot;
}

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

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

    numberOfPagesTest(1);//  ww  w  .j a va  2s  .c o  m

    JFreeChart chart = getChart("summary.chart1", 0);
    Plot plot = chart.getPlot();
    Assert.assertEquals("renderer", MeterPlot.class, plot.getClass());
    MeterPlot meterPlot = (MeterPlot) plot;
    Assert.assertEquals("value", 15, meterPlot.getDataset().getValue());
    Assert.assertEquals("data range low", 3d, meterPlot.getRange().getLowerBound());
    Assert.assertEquals("data range high", 30d, meterPlot.getRange().getUpperBound());
    Assert.assertEquals("value color", Color.BLUE, meterPlot.getValuePaint());
    Assert.assertEquals("value mask", "15.0", meterPlot.getTickLabelFormat().format(15));
    Assert.assertEquals("value font", new Font("Arial", Font.PLAIN, 10), meterPlot.getValueFont());
    Assert.assertEquals("shape", DialShape.CIRCLE, meterPlot.getDialShape());
    Assert.assertEquals("meter angle", 270, meterPlot.getMeterAngle());
    Assert.assertEquals("units", "units", meterPlot.getUnits());
    Assert.assertEquals("tick interval", 3d, meterPlot.getTickSize());
    Assert.assertEquals("background color", Color.LIGHT_GRAY, meterPlot.getDialBackgroundPaint());
    Assert.assertEquals("needle color", Color.CYAN, meterPlot.getNeedlePaint());
    Assert.assertEquals("tick color", Color.MAGENTA, meterPlot.getTickPaint());
    Assert.assertEquals("tick label font", new Font("Courier New", Font.PLAIN, 10),
            meterPlot.getTickLabelFont());
    Assert.assertEquals("intervals size", 2, meterPlot.getIntervals().size());
    intervalTest((MeterInterval) meterPlot.getIntervals().get(0), "red", new Color(1f, 0f, 0f, 0.8f), 25d, 30d);
    intervalTest((MeterInterval) meterPlot.getIntervals().get(1), "yellow", new Color(1f, 1f, 0f, 0.5f), 20d,
            25d);
}