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:unalcol.termites.boxplots.ECALMessages.java

/**
 * Creates a new demo.//from w  ww  . j a  v  a 2  s  . c  om
 *
 * @param title the frame title.
 * @param pf
 */
public ECALMessages(final String title, ArrayList<Double> pf) {

    super(title);

    final CategoryAxis xAxis = new CategoryAxis("");
    //final NumberAxis yAxis = new NumberAxis("Messages Sent");
    final NumberAxis yAxis = new NumberAxis("");

    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf, renderer);
    renderer.setFillBox(false);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    Font font = new Font("Dialog", Font.PLAIN, 13);
    xAxis.setTickLabelFont(font);
    yAxis.setTickLabelFont(font);
    yAxis.setLabelFont(font);

    final JFreeChart chart = new JFreeChart("Messages Sent " + getTitle(pf),
            new Font("SansSerif", Font.BOLD, 18), plot, true);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 370));
    setContentPane(chartPanel);
    TextTitle legendText = null;
    if (pf.size() == 1) {
        legendText = new TextTitle("Population Size");
    } else {
        legendText = new TextTitle("Population Size - Probability of Failure");
    }
    legendText.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendText);

    LegendTitle legend = chart.getLegend();
    legend.setPadding(new RectangleInsets(UnitType.RELATIVE, 0, 0.1, 0, 0));

    FileOutputStream output;
    try {
        output = new FileOutputStream("messagesECAL" + pf + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 670, 250, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(ECALMessages.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(ECALMessages.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:unalcol.termites.boxplots.MessagesSent2.java

/**
 * Creates a new demo./*from   w  w  w  .  j  ava  2  s .  c om*/
 *
 * @param title the frame title.
 * @param pf
 */
public MessagesSent2(final String title, ArrayList<Double> pf) {

    super(title);

    final CategoryAxis xAxis = new CategoryAxis("");
    //final NumberAxis yAxis = new NumberAxis("Messages Sent");
    final NumberAxis yAxis = new NumberAxis("");

    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf, renderer);
    renderer.setFillBox(false);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    Font font = new Font("Dialog", Font.PLAIN, 13);
    xAxis.setTickLabelFont(font);
    yAxis.setTickLabelFont(font);
    yAxis.setLabelFont(font);

    final JFreeChart chart = new JFreeChart("Messages Sent " + getTitle(pf),
            new Font("SansSerif", Font.BOLD, 18), plot, true);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 370));
    setContentPane(chartPanel);
    TextTitle legendText = null;
    if (pf.size() == 1) {
        legendText = new TextTitle("Population Size");
    } else {
        legendText = new TextTitle("Population Size - Probability of Failure");
    }
    legendText.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendText);

    LegendTitle legend = chart.getLegend();
    legend.setPadding(new RectangleInsets(UnitType.RELATIVE, 0, 0.1, 0, 0));

    FileOutputStream output;
    try {
        output = new FileOutputStream("messagesnumber2" + pf + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 670, 250, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(MessagesSent2.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(MessagesSent2.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:net.sf.profiler4j.console.AllocDiffPanel.java

public AllocDiffPanel(int maxAgeMillis) {
    super(new BorderLayout());

    totalSeries = new TimeSeries("Allocs/Sec", Millisecond.class);
    totalSeries.setMaximumItemAge(maxAgeMillis);

    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    seriesCollection.addSeries(totalSeries);

    NumberAxis numberAxis = new NumberAxis("Allocs/Sec");
    numberAxis.setLabelFont(new Font("SansSerif", 0, 14));
    numberAxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    DateAxis dateAxis = new DateAxis("Time");
    dateAxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    dateAxis.setLabelFont(new Font("SansSerif", 0, 14));
    dateAxis.setAutoRange(true);//w  w w.j av  a 2s.  c  o m
    dateAxis.setLowerMargin(0);
    dateAxis.setUpperMargin(0);
    dateAxis.setTickLabelsVisible(true);
    dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));

    XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, false);
    lineRenderer.setSeriesPaint(0, Color.RED);
    lineRenderer.setSeriesPaint(1, Color.GREEN.darker());
    lineRenderer.setStroke(new BasicStroke(2F, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));

    XYPlot xyplot = new XYPlot(seriesCollection, dateAxis, numberAxis, lineRenderer);
    xyplot.setBackgroundPaint(Color.WHITE);
    xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));

    JFreeChart chart = new JFreeChart("Object Allocactions in Remote JVM",
            new Font("SansSerif", Font.PLAIN, 18), xyplot, true);
    chart.setBackgroundPaint(Color.white);

    ChartPanel panel = new ChartPanel(chart);
    panel.setBorder(createCompoundBorder(createEmptyBorder(8, 8, 8, 8), createLineBorder(Color.LIGHT_GRAY)));
    add(panel);
    setBorder(createEmptyBorder(8, 8, 8, 8));
}

From source file:WalkingText.java

/** Applet Initializer */
public void init() {
    xloc = 0;/*from  w ww . j av a 2 s.c  om*/
    width = getSize().width;
    height = getSize().height;

    if ((mesg = getParameter("text")) == null)
        mesg = "Hello World of Java";

    String pSize = getParameter("fontsize");
    if (pSize == null)
        pSize = "12";

    String fontName = getParameter("fontName");
    if (fontName == null)
        fontName = "Helvetica";

    // System.out.println("Font is " + pSize + " point " + fontName);
    Font f = new Font(fontName, Font.PLAIN, Integer.parseInt(pSize));
    setFont(f);

    FontMetrics fm = getToolkit().getFontMetrics(f);
    textWidth = fm.stringWidth(mesg);
    textHeight = fm.getHeight();
    // System.out.println("TextWidth " + textWidth + ", ht " + textHeight);

    // use textHeight in y coordinate calculation
    yloc = height - ((height - textHeight) / 2);
}

From source file:playground.artemc.socialCost.MeanTravelTimeWriter.java

/**
 * @return a graphic showing the number of agents in the evacuated area
 */// w ww.  j av a2 s.com
private JFreeChart getGraphic(String modeName, double data[]) {

    final XYSeriesCollection xyData = new XYSeriesCollection();
    final XYSeries dataSerie = new XYSeries("mean trip travel time", false, true);

    for (int i = 0; i < data.length; i++) {
        dataSerie.add(i, data[i]);
    }

    xyData.addSeries(dataSerie);

    //      final JFreeChart chart = ChartFactory.createXYStepChart(
    final JFreeChart chart = ChartFactory.createXYLineChart("mean travel time, " + modeName, "iteration",
            "travel time", xyData, PlotOrientation.VERTICAL, true, // legend
            false, // tooltips
            false // urls
    );

    XYPlot plot = chart.getXYPlot();

    final CategoryAxis axis1 = new CategoryAxis("hour");
    axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7));
    plot.setDomainAxis(new NumberAxis("time"));
    return chart;
}

From source file:it.marcoberri.mbmeteo.action.chart.GetLastRDial.java

/**
 * Processes requests for both HTTP//  ww  w.  j  a va2  s  . co m
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    log.debug("start : " + this.getClass().getName());

    final HashMap<String, String> params = getParams(request.getParameterMap());
    final Integer dimy = Default.toInteger(params.get("dimy"), 600);
    final Integer dimx = Default.toInteger(params.get("dimx"), 800);

    Meteolog meteolog = ds.find(Meteolog.class).order("-time").limit(1).get();

    DefaultValueDataset dataset = new DefaultValueDataset(meteolog.getDayRainfall());

    // get data for diagrams
    DialPlot plot = new DialPlot();
    plot.setView(0.0, 0.0, 1.0, 1.0);
    plot.setDataset(0, dataset);

    GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(),
            new Color(170, 170, 220));

    DialBackground db = new DialBackground(gp);

    db.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
    plot.setBackground(db);

    StandardDialScale scale = new StandardDialScale();
    scale.setLowerBound(0);
    scale.setUpperBound(50);
    scale.setTickLabelOffset(0.14);
    scale.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10));
    plot.addScale(0, scale);

    DialPointer needle = new DialPointer.Pointer(0);

    plot.addLayer(needle);

    JFreeChart chart1 = new JFreeChart(plot);
    chart1.setTitle("Daily Rain mm");

    final File f = File.createTempFile("mbmeteo", ".jpg");
    ChartUtilities.saveChartAsJPEG(f, chart1, dimx, dimy);

    response.setContentType("image/jpeg");
    response.setHeader("Content-Length", "" + f.length());
    response.setHeader("Content-Disposition", "inline; filename=\"" + f.getName() + "\"");
    final OutputStream out = response.getOutputStream();
    final FileInputStream in = new FileInputStream(f.toString());
    final int size = in.available();
    final byte[] content = new byte[size];
    in.read(content);
    out.write(content);
    in.close();
    out.close();
}

From source file:fr.ign.cogit.simplu3d.rjmcmc.generic.visitor.StatsVisitor.java

/**
 * Creates a sample chart./*from  w w  w  .  jav a2 s .c om*/
 * 
 * @param dataset
 *            the dataset.
 * @return A sample chart.
 */
private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createXYLineChart("volution de l'nergie", "Itration",
            "nergie", dataset, PlotOrientation.VERTICAL, true, true, true);

    result.setBorderPaint(Color.white);

    result.setBackgroundPaint(Color.white);

    final XYPlot plot = result.getXYPlot();

    Font font = new Font("Verdana", Font.PLAIN, 32);
    Font font2 = new Font("Verdana", Font.PLAIN, 28);

    // axe x
    ValueAxis axis = plot.getDomainAxis();

    axis.setLabelFont(font);
    axis.setTickLabelFont(font2);

    axis.setAutoRange(true);
    // axis.setFixedAutoRange(60000.0); // 60 seconds
    axis = plot.getRangeAxis();

    // axe y
    ValueAxis axis2 = plot.getRangeAxis();

    axis2.setLabelFont(font);
    axis2.setTickLabelFont(font2);

    axis2.setAutoRange(true);
    // axis.setFixedAutoRange(60000.0); // 60 seconds
    axis2 = plot.getRangeAxis();

    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setBackgroundPaint(Color.white);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();

    renderer.setSeriesPaint(0, new Color(255, 0, 0));
    renderer.setSeriesStroke(0, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f));

    renderer.setLegendTextFont(0, font2);

    renderer.setSeriesPaint(1, new Color(2, 157, 116));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f));

    renderer.setLegendTextFont(1, font2);

    renderer.setSeriesPaint(2, new Color(112, 147, 219));
    renderer.setSeriesStroke(2, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f));

    renderer.setLegendTextFont(2, font2);

    renderer.setSeriesPaint(3, new Color(140, 23, 23));
    renderer.setSeriesStroke(3, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 6.0f, 6.0f }, 0.0f));

    renderer.setLegendTextFont(3, font2);

    // axis.setRange(0.0, 200.0);
    return result;
}

From source file:edu.uci.ics.jung.samples.AddNodeDemo.java

@Override
public void init() {

    //create a graph
    Graph<Number, Number> ig = Graphs
            .<Number, Number>synchronizedDirectedGraph(new DirectedSparseMultigraph<Number, Number>());

    ObservableGraph<Number, Number> og = new ObservableGraph<Number, Number>(ig);
    og.addGraphEventListener(new GraphEventListener<Number, Number>() {

        public void handleGraphEvent(GraphEvent<Number, Number> evt) {
            System.err.println("got " + evt);

        }/*from   ww w  .  j  a  v  a  2s. c  o  m*/
    });
    this.g = og;
    //create a graphdraw
    layout = new FRLayout2<Number, Number>(g);
    //        ((FRLayout)layout).setMaxIterations(200);

    vv = new VisualizationViewer<Number, Number>(layout, new Dimension(600, 600));

    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, 12));

    vv.getModel().getRelaxer().setSleepTime(500);
    vv.setGraphMouse(new DefaultModalGraphMouse<Number, Number>());

    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Number>());
    vv.setForeground(Color.white);
    getContentPane().add(vv);
    switchLayout = new JButton("Switch to SpringLayout");
    switchLayout.addActionListener(new ActionListener() {

        @SuppressWarnings({ "unchecked", "rawtypes" })
        public void actionPerformed(ActionEvent ae) {
            Dimension d = new Dimension(600, 600);
            if (switchLayout.getText().indexOf("Spring") > 0) {
                switchLayout.setText("Switch to FRLayout");
                layout = new SpringLayout<Number, Number>(g, new ConstantTransformer(EDGE_LENGTH));
                layout.setSize(d);
                vv.getModel().setGraphLayout(layout, d);
            } else {
                switchLayout.setText("Switch to SpringLayout");
                layout = new FRLayout<Number, Number>(g, d);
                vv.getModel().setGraphLayout(layout, d);
            }
        }
    });

    getContentPane().add(switchLayout, BorderLayout.SOUTH);

    timer = new Timer();
}

From source file:org.jfree.eastwood.GValueAxis3D.java

/**
 * Creates a new axis.//from w w  w.java  2s .c  om
 */
public GValueAxis3D() {
    super();
    this.axisForAutoLabels = new NumberAxis3D(null);
    this.axisForAutoLabels.setRange(0.0, 100.0);
    this.axisForAutoLabels.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    this.labelAxisStart = 0.0;
    this.labelAxisEnd = 100.0;
    this.tickLabels = new java.util.ArrayList();
    this.tickLabelPositions = new java.util.ArrayList();
    setLowerMargin(0.0);
    setUpperMargin(0.0);
    // the data is normalised into the range 0.0 to 1.0, so the real axis
    // has the same range...
    setRange(0.0, 1.0);
    setTickLabelPaint(Color.darkGray);
    setTickLabelFont(new Font("Dialog", Font.PLAIN, 11));
}

From source file:it.marcoberri.mbmeteo.action.chart.GetLastTDial.java

/**
 * Processes requests for both HTTP//from www.  j  a  v  a  2  s.  c  om
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    log.debug("start : " + this.getClass().getName());

    final HashMap<String, String> params = getParams(request.getParameterMap());
    final Integer dimy = Default.toInteger(params.get("dimy"), 600);
    final Integer dimx = Default.toInteger(params.get("dimx"), 800);

    Meteolog meteolog = ds.find(Meteolog.class).order("-time").limit(1).get();

    DefaultValueDataset dataset = new DefaultValueDataset(meteolog.getOutdoorTemperature());

    // get data for diagrams
    DialPlot plot = new DialPlot();
    plot.setView(0.0, 0.0, 1.0, 1.0);
    plot.setDataset(0, dataset);

    GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(),
            new Color(170, 170, 220));

    DialBackground db = new DialBackground(gp);

    db.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
    plot.setBackground(db);

    StandardDialScale scale = new StandardDialScale();
    scale.setLowerBound(-20);
    scale.setUpperBound(40);
    scale.setTickLabelOffset(0.14);
    scale.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10));
    plot.addScale(0, scale);

    DialPointer needle = new DialPointer.Pointer(0);

    plot.addLayer(needle);

    JFreeChart chart1 = new JFreeChart(plot);
    chart1.setTitle("Temperature C");

    final File f = File.createTempFile("mbmeteo", ".jpg");
    ChartUtilities.saveChartAsJPEG(f, chart1, dimx, dimy);

    response.setContentType("image/jpeg");
    response.setHeader("Content-Length", "" + f.length());
    response.setHeader("Content-Disposition", "inline; filename=\"" + f.getName() + "\"");
    final OutputStream out = response.getOutputStream();
    final FileInputStream in = new FileInputStream(f.toString());
    final int size = in.available();
    final byte[] content = new byte[size];
    in.read(content);
    out.write(content);
    in.close();
    out.close();
}