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:org.jfree.graphics2d.demo.SVGPieChartDemo1.java

/**
 * Creates a chart.//from  w ww . java  2  s . co  m
 *
 * @param dataset  the dataset.
 *
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createPieChart("Smart Phones Manufactured / Q3 2011", // chart title
            dataset);
    chart.removeLegend();

    // set a custom background for the chart
    chart.setBackgroundPainter(new GradientPainter(new Color(20, 20, 20), RectangleAnchor.TOP_LEFT,
            Color.DARK_GRAY, RectangleAnchor.BOTTOM_RIGHT));

    // customise the title position and font
    TextTitle t = chart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.LEFT);
    t.setPaint(new Color(240, 240, 240));
    t.setFont(new Font("Arial", Font.BOLD, 26));

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPainter(null);
    plot.setInteriorGap(0.04);
    plot.setBorderPainter(null);

    // use gradients and white borders for the section colours
    plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE));
    plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED));
    plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN));
    plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW));
    plot.setBaseSectionOutlinePaint(Color.WHITE);
    plot.setSectionOutlinesVisible(true);
    plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f));

    // customise the section label appearance
    plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
    plot.setLabelLinkPaint(Color.WHITE);
    plot.setLabelLinkStroke(new BasicStroke(2.0f));
    plot.setLabelOutlineStroke(null);
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelBackgroundPaint(null);
    // add a subtitle giving the data source
    TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523",
            new Font("Courier New", Font.PLAIN, 12));
    source.setPaint(Color.WHITE);
    source.setPosition(RectangleEdge.BOTTOM);
    source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(source);
    return chart;

}

From source file:ca.sqlpower.wabit.swingui.report.selectors.FancyDateSelectorField.java

public FancyDateSelectorField(final DateSelector selector, Runnable refreshRoutine) {

    this.selector = selector;
    this.refreshRoutine = refreshRoutine;
    //this.addPopupMenuListener(popupMenuListener);
    this.addActionListener(new ActionListener() {
        @Override/*from  w  w  w.  ja va 2  s. c  om*/
        public void actionPerformed(ActionEvent e) {
            refreshEverything();
        }
    });
    this.selector.addSPListener(spListener);

    Date currentValue = selector.getCurrentValue() == null ? null : (Date) selector.getCurrentValue();
    setDate(currentValue);

    if (ObjectUtils.equals(getDate(), selector.getDefaultValue())) {
        setForeground(Color.GRAY);
        setFont(getFont().deriveFont(Font.ITALIC));
    } else {
        setForeground(Color.BLACK);
        setFont(getFont().deriveFont(Font.PLAIN));
    }
}

From source file:org.owasp.benchmark.score.report.ScatterScores.java

private JFreeChart display(String title, int height, int width, List<Report> toolResults) {
    JFrame f = new JFrame(title);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries series = new XYSeries("Scores");
    for (int i = 0; i < toolResults.size(); i++) {
        Report toolReport = toolResults.get(i);
        OverallResults overallResults = toolReport.getOverallResults();
        series.add(overallResults.getFalsePositiveRate() * 100, overallResults.getTruePositiveRate() * 100);
    }//from   www  . j  a v  a2  s . co m
    dataset.addSeries(series);

    chart = ChartFactory.createScatterPlot(title, "False Positive Rate", "True Positive Rate", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    String fontName = "Arial";
    DecimalFormat pctFormat = new DecimalFormat("0'%'");

    theme = (StandardChartTheme) org.jfree.chart.StandardChartTheme.createJFreeTheme();
    theme.setExtraLargeFont(new Font(fontName, Font.PLAIN, 24)); // title
    theme.setLargeFont(new Font(fontName, Font.PLAIN, 20)); // axis-title
    theme.setRegularFont(new Font(fontName, Font.PLAIN, 16));
    theme.setSmallFont(new Font(fontName, Font.PLAIN, 12));
    theme.setRangeGridlinePaint(Color.decode("#C0C0C0"));
    theme.setPlotBackgroundPaint(Color.white);
    theme.setChartBackgroundPaint(Color.white);
    theme.setGridBandPaint(Color.red);
    theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0));
    theme.setBarPainter(new StandardBarPainter());
    theme.setAxisLabelPaint(Color.decode("#666666"));
    theme.apply(chart);

    XYPlot xyplot = chart.getXYPlot();
    NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis();
    NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis();

    xyplot.setOutlineVisible(true);

    rangeAxis.setRange(-5, 109.99);
    rangeAxis.setNumberFormatOverride(pctFormat);
    rangeAxis.setTickLabelPaint(Color.decode("#666666"));
    rangeAxis.setMinorTickCount(5);
    rangeAxis.setTickUnit(new NumberTickUnit(10));
    rangeAxis.setAxisLineVisible(true);
    rangeAxis.setMinorTickMarksVisible(true);
    rangeAxis.setTickMarksVisible(true);
    rangeAxis.setLowerMargin(10);
    rangeAxis.setUpperMargin(10);
    xyplot.setRangeGridlineStroke(new BasicStroke());
    xyplot.setRangeGridlinePaint(Color.lightGray);
    xyplot.setRangeMinorGridlinePaint(Color.decode("#DDDDDD"));
    xyplot.setRangeMinorGridlinesVisible(true);

    domainAxis.setRange(-5, 105);
    domainAxis.setNumberFormatOverride(pctFormat);
    domainAxis.setTickLabelPaint(Color.decode("#666666"));
    domainAxis.setMinorTickCount(5);
    domainAxis.setTickUnit(new NumberTickUnit(10));
    domainAxis.setAxisLineVisible(true);
    domainAxis.setTickMarksVisible(true);
    domainAxis.setMinorTickMarksVisible(true);
    domainAxis.setLowerMargin(10);
    domainAxis.setUpperMargin(10);
    xyplot.setDomainGridlineStroke(new BasicStroke());
    xyplot.setDomainGridlinePaint(Color.lightGray);
    xyplot.setDomainMinorGridlinePaint(Color.decode("#DDDDDD"));
    xyplot.setDomainMinorGridlinesVisible(true);

    chart.setTextAntiAlias(true);
    chart.setAntiAlias(true);
    chart.removeLegend();
    chart.setPadding(new RectangleInsets(20, 20, 20, 20));
    xyplot.getRenderer().setSeriesPaint(0, Color.decode("#4572a7"));

    //        // setup item labels
    //        XYItemRenderer renderer = xyplot.getRenderer();
    //        Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 7.0f, 7.0f);
    //        for ( int i = 0; i < dataset.getSeriesCount(); i++ ) {
    //            renderer.setSeriesShape(i, circle);
    //            renderer.setSeriesPaint(i, Color.blue);
    //            String label = ""+((String)dataset.getSeries(i).getKey());
    //            int idx = label.indexOf( ':');
    //            label = label.substring( 0, idx );
    //            StandardXYItemLabelGenerator generator = new StandardXYItemLabelGenerator(label); 
    //            renderer.setSeriesItemLabelGenerator(i, generator); 
    //            renderer.setSeriesItemLabelsVisible(i, true);
    //            ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER );
    //            renderer.setSeriesPositiveItemLabelPosition(i, position);
    //        }

    makeDataLabels(toolResults, xyplot);
    makeLegend(toolResults, 57, 48, dataset, xyplot);

    Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 6, 3 },
            0);
    for (XYDataItem item : (List<XYDataItem>) series.getItems()) {
        double x = item.getX().doubleValue();
        double y = item.getY().doubleValue();
        double z = (x + y) / 2;
        XYLineAnnotation score = new XYLineAnnotation(x, y, z, z, dashed, Color.blue);
        xyplot.addAnnotation(score);
    }

    //        // put legend inside plot
    //        LegendTitle lt = new LegendTitle(xyplot);
    //        lt.setItemFont(theme.getSmallFont());
    //        lt.setPosition(RectangleEdge.RIGHT);
    //        lt.setItemFont(theme.getSmallFont());
    //        XYTitleAnnotation ta = new XYTitleAnnotation(.7, .55, lt, RectangleAnchor.TOP_LEFT);
    //        ta.setMaxWidth(0.48);
    //        xyplot.addAnnotation(ta);

    // draw guessing line
    XYLineAnnotation guessing = new XYLineAnnotation(-5, -5, 105, 105, dashed, Color.red);
    xyplot.addAnnotation(guessing);

    XYPointerAnnotation worse = makePointer(75, 5, "Worse than guessing", TextAnchor.TOP_CENTER, 90);
    xyplot.addAnnotation(worse);

    XYPointerAnnotation better = makePointer(25, 100, "Better than guessing", TextAnchor.BOTTOM_CENTER, 270);
    xyplot.addAnnotation(better);

    XYTextAnnotation stroketext = new XYTextAnnotation("                     Random Guess", 88, 107);
    stroketext.setTextAnchor(TextAnchor.CENTER_RIGHT);
    stroketext.setBackgroundPaint(Color.white);
    stroketext.setPaint(Color.red);
    stroketext.setFont(theme.getRegularFont());
    xyplot.addAnnotation(stroketext);

    XYLineAnnotation strokekey = new XYLineAnnotation(58, 107, 68, 107, dashed, Color.red);
    xyplot.setBackgroundPaint(Color.white);
    xyplot.addAnnotation(strokekey);

    ChartPanel cp = new ChartPanel(chart, height, width, 400, 400, 1200, 1200, false, false, false, false,
            false, false);
    f.add(cp);
    f.pack();
    f.setLocationRelativeTo(null);
    //      f.setVisible(true);
    return chart;
}

From source file:utils.ChartUtils.java

/**
 * Update XY chart/*from w  w w  .  j  ava2  s  .c  om*/
 * 
 * @param plot ChartPanel Plot
 * @param sortedArray Sorted array of values
 */
public static void updateXYChart(ChartPanel plot, double[] sortedArray) {

    XYPlot xyplot = plot.getChart().getXYPlot();

    double min = sortedArray[0];
    double max = sortedArray[sortedArray.length - 1];

    double median = Utils.getMedian(sortedArray);

    double q1 = Utils.getQ1(sortedArray);
    double q3 = Utils.getQ3(sortedArray);

    XYTextAnnotation annotation;

    //min-lowlimit horizontal
    XYSeries serie15 = new XYSeries("15");
    serie15.add(min, 0.5);

    //max-toplimit horizontal
    XYSeries serie16 = new XYSeries("16");
    serie16.add(max, 0.5);

    //min vertical
    XYSeries serie1 = new XYSeries("0");
    serie1.add(min, 0.45);
    serie1.add(min, 0.55);

    annotation = new XYTextAnnotation("Min", min, 0.40);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    //min-q1 horizontal
    XYSeries serie2 = new XYSeries("1");
    serie2.add(min, 0.5);
    serie2.add(q1, 0.5);

    //q1 vertical  
    XYSeries serie3 = new XYSeries("2");
    serie3.add(q1, 0.1);
    serie3.add(q1, 0.9);

    annotation = new XYTextAnnotation("Q1", q1, 0.08);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    // median 
    XYSeries serie_mediana = new XYSeries("11");
    serie_mediana.add(median, 0.1);
    serie_mediana.add(median, 0.9);

    annotation = new XYTextAnnotation("Median", median, 0.04);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    //q1-q3 horizontal sup
    XYSeries serie4 = new XYSeries("3");
    serie4.add(q1, 0.9);
    serie4.add(q3, 0.9);

    //q1-q3 horizontal inf
    XYSeries serie5 = new XYSeries("4");
    serie5.add(q1, 0.1);
    serie5.add(q3, 0.1);

    //q3 vertical
    XYSeries serie6 = new XYSeries("5");
    serie6.add(q3, 0.1);
    serie6.add(q3, 0.9);

    annotation = new XYTextAnnotation("Q3", q3, 0.08);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    //q3-max horizontal
    XYSeries serie7 = new XYSeries("6");
    serie7.add(q3, 0.5);
    serie7.add(max, 0.5);

    //max vertical
    XYSeries serie8 = new XYSeries("7");
    serie8.add(max, 0.45);
    serie8.add(max, 0.55);

    annotation = new XYTextAnnotation("Max", max, 0.4);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    XYSeriesCollection xyseriescollection = new XYSeriesCollection();

    xyseriescollection.addSeries(serie1);
    xyseriescollection.addSeries(serie2);
    xyseriescollection.addSeries(serie3);
    xyseriescollection.addSeries(serie4);
    xyseriescollection.addSeries(serie5);
    xyseriescollection.addSeries(serie6);
    xyseriescollection.addSeries(serie7);
    xyseriescollection.addSeries(serie8);
    xyseriescollection.addSeries(serie15);
    xyseriescollection.addSeries(serie16);
    xyseriescollection.addSeries(serie_mediana);

    xyplot.getRenderer().setSeriesPaint(9, Color.black);
    xyplot.getRenderer().setSeriesPaint(10, Color.black);

    xyplot.getRenderer().setSeriesPaint(0, Color.black);
    xyplot.getRenderer().setSeriesPaint(1, Color.black);
    xyplot.getRenderer().setSeriesPaint(2, Color.black);
    xyplot.getRenderer().setSeriesPaint(3, Color.black);
    xyplot.getRenderer().setSeriesPaint(4, Color.black);
    xyplot.getRenderer().setSeriesPaint(5, Color.black);
    xyplot.getRenderer().setSeriesPaint(6, Color.black);
    xyplot.getRenderer().setSeriesPaint(7, Color.black);
    xyplot.getRenderer().setSeriesPaint(8, Color.black);
    xyplot.getRenderer().setSeriesPaint(9, Color.black);
    xyplot.getRenderer().setSeriesPaint(10, Color.black);
    xyplot.getRenderer().setSeriesPaint(11, Color.black);
    xyplot.getRenderer().setSeriesPaint(12, Color.black);
    xyplot.getRenderer().setSeriesPaint(13, Color.black);

    //add dataset
    xyplot.setDataset(xyseriescollection);

    // add a second dataset and renderer... 
    XYSeriesCollection anotherserie = new XYSeriesCollection();

    XYSeries serie_point = new XYSeries("21");

    double[] yValue = { 0.47, 0.49, 0.51, 0.53 };

    for (int i = 0, j = 0; i < sortedArray.length; i++, j++) {
        if (j % 4 == 0) {
            j = 0;
        }
        serie_point.add(sortedArray[i], yValue[j]);
    }

    anotherserie.addSeries(serie_point);

    XYLineAndShapeRenderer renderer1 = new XYLineAndShapeRenderer(false, true);
    renderer1.setSeriesPaint(0, Color.lightGray);

    xyplot.setDataset(1, anotherserie);
    xyplot.setRenderer(1, renderer1);
}

From source file:ancat.visualizers.UndirectedModelVisualizer.java

private void produce(String fileName) {
    _currentLayout.setSize(new Dimension(600, 600));

    VisualizationImageServer<V, E> vv = new VisualizationImageServer<V, E>(_currentLayout,
            new Dimension(600, 600));

    vv.setPreferredSize(new Dimension(600, 600));

    // Setup up a new vertex to paint transformer...
    Transformer<V, Paint> vertexPaint = new Transformer<V, Paint>() {
        public Paint transform(V v) {
            //return Color.GREEN;
            ancat.common.Vertex vertex = (Vertex) v;

            if (vertex instanceof ancat.common.ExecutableFile)
                return Color.BLUE;

            if (vertex instanceof ancat.common.DynamicLibrary)
                return Color.YELLOW;

            if (vertex instanceof ancat.common.ConfigurationFile)
                return Color.ORANGE;

            if (vertex instanceof ancat.common.Unspecified)
                return Color.RED;

            return Color.darkGray;
        }//from   w w  w.  ja va 2  s  .c o m
    };
    // Set up a new stroke Transformer for the edges
    float dash[] = { 10.0f };

    final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash,
            0.0f);

    Transformer<E, Stroke> edgeStrokeTransformer = new Transformer<E, Stroke>() {
        public Stroke transform(E s) {
            return edgeStroke;
        }
    };

    Transformer<E, Font> edgeFontTransformer = new Transformer<E, Font>() {
        public Font transform(E e) {
            return new Font("Dialog", Font.PLAIN, 10);
        }
    };

    Transformer<E, String> lblTransformer = new Transformer<E, String>() {
        public String transform(E e) {
            Edge edge = (Edge) e;
            //return edge.getXMLId();
            return edge.getXMLId() != null ? edge.getXMLId() : "";
        }
    };

    Transformer<V, Font> vertexFontTransformer = new Transformer<V, Font>() {
        public Font transform(V v) {
            return new Font("Dialog", Font.PLAIN, 10);
        }
    };

    Transformer<V, String> vLblTransformer = new Transformer<V, String>() {
        public String transform(V v) {
            Vertex vertex = (Vertex) v;
            return vertex.getElementID();
        }
    };

    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<V>());
    vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<E>());
    // ---->
    vv.getRenderContext().setEdgeFontTransformer(edgeFontTransformer);
    vv.getRenderContext().setLabelOffset(20);
    vv.getRenderContext().setEdgeLabelTransformer(lblTransformer);

    vv.getRenderContext().setVertexFontTransformer(vertexFontTransformer);
    vv.getRenderContext().setVertexLabelTransformer(vLblTransformer);

    vv.getRenderer().getVertexLabelRenderer().setPosition(Position.N);

    BufferedImage img = new BufferedImage((int) _currentLayout.getSize().getWidth(),
            (int) _currentLayout.getSize().getHeight(), BufferedImage.TYPE_INT_ARGB);

    vv.getImage(new Point(0, 0), new Dimension(700, 700));

    Graphics2D g2d = (Graphics2D) img.getGraphics();

    vv.paint(g2d);

    setDisclaimer(g2d);

    g2d.dispose();

    try {
        File file = new File(fileName);

        ImageIO.write(img, "png", file);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.leonarduk.finance.chart.PieChartFactory.java

public JFreeChart buildChart() {
    final JFreeChart chart = ChartFactory.createPieChart(this.title, this.dataset);

    final PiePlot p = (PiePlot) chart.getPlot();
    p.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
    p.setInteriorGap(0.01);//from w  w  w. j a  va 2  s  .  c  om

    return chart;
}

From source file:gui.QTLResultsPanel.java

/** QTLResultsPanel().
 * /*  ww  w.j  a v  a  2s  .co  m*/
 * @param qtlResult = the QTL results to show.
 * @param order = the ordered result data this QTL was created from. 
 */
public QTLResultsPanel(QTLResult qtlResult, OrderedResult order) {
    this.qtlResult = qtlResult;
    this.order = order;

    // Trait listbox
    traitModel = new DefaultListModel<Trait>();
    for (Trait trait : qtlResult.getTraits()) {
        traitModel.addElement(trait);
    }
    traitList = new JList<Trait>(traitModel);
    traitList.addListSelectionListener(this);
    traitList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane sp1 = new JScrollPane(traitList);
    sp1.setPreferredSize(new Dimension(125, 50));

    // Details text box
    details = new JTextArea();
    details.setFont(new Font("Monospaced", Font.PLAIN, 11));
    details.setMargin(new Insets(2, 5, 2, 5));
    details.setEditable(false);
    details.setTabSize(6);
    JScrollPane sp4;
    if (AppFrame.tpmmode == AppFrame.TPMMODE_QTL) {
        simpleDetails = new JScrollPane();
        simpleDetails.setFont(new Font("Monospaced", Font.PLAIN, 11));
        simplesplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
        simpleright = new JTextArea();
        simpleright.setFont(new Font("Monospaced", Font.PLAIN, 11));
        simpleright.setMargin(new Insets(2, 5, 2, 5));
        simpleright.setEditable(false);
        simpleright.setTabSize(6);
        simplesplit.setRightComponent(new JScrollPane(simpleright));

        simplesplit.setLeftComponent(simpleDetails);
        sp4 = new JScrollPane(simplesplit);
    } else {
        // TPM MODE NONSNP
        simpleright = new JTextArea();
        simpleright.setFont(new Font("Monospaced", Font.PLAIN, 11));
        simpleright.setMargin(new Insets(2, 5, 2, 5));
        simpleright.setEditable(false);
        sp4 = new JScrollPane(simpleright);
    }

    lodDetails = new JTextArea();
    lodDetails.setFont(new Font("Monospaced", Font.PLAIN, 11));
    lodDetails.setMargin(new Insets(2, 5, 2, 5));
    lodDetails.setEditable(false);
    lodDetails.setTabSize(6);
    JScrollPane sp3 = new JScrollPane(lodDetails);
    JTabbedPane tabs = new JTabbedPane();
    JScrollPane sp2 = new JScrollPane(details);
    tabs.add(sp2, "Full Model");
    tabs.add(sp4, "Simple Model");
    tabs.add(sp3, "LOD Details");

    // The splitpane
    splits = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splits.setTopComponent(new JPanel());
    splits.setBottomComponent(tabs);
    splits.setResizeWeight(0.5);

    // pane2
    JSplitPane splits2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splits2.setLeftComponent(sp1);
    splits2.setRightComponent(splits);

    setLayout(new BorderLayout());
    add(new GradientPanel("QTL Analysis Results"), BorderLayout.NORTH);
    // add(sp1, BorderLayout.WEST);
    // add(splits);
    add(splits2);
    add(toolbar = new QTLResultsToolBar(this), BorderLayout.EAST);
}

From source file:org.matsim.pt.counts.PtBiasErrorGraph.java

@Override
public JFreeChart createChart(final int nbr) {
    DefaultCategoryDataset dataset0 = new DefaultCategoryDataset();
    DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();

    this.errorStats = new ComparisonErrorStatsCalculator(this.ccl_);

    double[] meanRelError = errorStats.getMeanRelError();
    // double[] meanAbsError = errorStats.getMeanAbsError();
    double[] meanAbsBias = errorStats.getMeanAbsBias();

    for (int h = 0; h < 24; h++) {
        dataset0.addValue(meanRelError[h], "Mean rel error", Integer.toString(h + 1));
        // dataset1.addValue(meanAbsError[h], "Mean abs error",
        // Integer.toString(h + 1));
        dataset1.addValue(meanAbsBias[h], "Mean abs bias", Integer.toString(h + 1));
    }//from ww  w  . ja  v a2s.c o  m

    this.chart_ = ChartFactory.createLineChart(this.chartTitle, "Hour", "Mean rel error [%]", dataset0,
            PlotOrientation.VERTICAL, true, // legend?
            true, // tooltips?
            false // URLs?
    );
    CategoryPlot plot = this.chart_.getCategoryPlot();
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    plot.setDataset(1, dataset1);
    plot.mapDatasetToRangeAxis(1, 1);

    final LineAndShapeRenderer renderer = new LineAndShapeRenderer();
    renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator());
    plot.setRenderer(0, renderer);

    final CategoryAxis axis1 = new CategoryAxis("Hour");
    axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7));
    plot.setDomainAxis(axis1);

    // final ValueAxis axis2 = new
    // NumberAxis("Mean abs {bias, error} [veh/h]");
    final ValueAxis axis2 = new NumberAxis("Mean abs bias [veh/h]");
    plot.setRangeAxis(1, axis2);

    final ValueAxis axis3 = plot.getRangeAxis(0);
    axis3.setRange(0.0, 100.0);

    final LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
    renderer2.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator());
    renderer2.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator());
    // renderer2.setSeriesPaint(0, Color.black);
    plot.setRenderer(1, renderer2);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);

    return this.chart_;
}

From source file:AnimatedMetadataGraph.java

@Override
public void init() {

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

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

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

        }//  ww w . ja  v  a 2s  .com
    });
    this.g = og;
    //create a graphdraw
    layout = new FRLayout<String, String>(g);
    layout.setSize(new Dimension(600, 600));
    Relaxer relaxer = new VisRunner((IterativeContext) layout);
    relaxer.stop();
    relaxer.prerelax();

    Layout<String, String> staticLayout = new StaticLayout<String, String>(g, layout);

    vv = new VisualizationViewer<String, String>(staticLayout, 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.setGraphMouse(new DefaultModalGraphMouse<Number, Number>());

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

    vv.addComponentListener(new ComponentAdapter() {

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

    getContentPane().add(vv);
    switchLayout = new JButton("Switch to SpringLayout");
    switchLayout.addActionListener(new ActionListener() {

        @SuppressWarnings("unchecked")
        public void actionPerformed(ActionEvent ae) {
            Dimension d = vv.getSize();//new Dimension(600,600);
            if (switchLayout.getText().indexOf("Spring") > 0) {
                switchLayout.setText("Switch to FRLayout");
                layout = new SpringLayout<String, String>(g, new ConstantTransformer(EDGE_LENGTH));
                layout.setSize(d);
                Relaxer relaxer = new VisRunner((IterativeContext) layout);
                relaxer.stop();
                relaxer.prerelax();
                StaticLayout<String, String> staticLayout = new StaticLayout<String, String>(g, layout);
                LayoutTransition<String, String> lt = new LayoutTransition<String, String>(vv,
                        vv.getGraphLayout(), staticLayout);
                Animator animator = new Animator(lt);
                animator.start();
                //   vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.repaint();

            } else {
                switchLayout.setText("Switch to SpringLayout");
                layout = new FRLayout<String, String>(g, d);
                layout.setSize(d);
                Relaxer relaxer = new VisRunner((IterativeContext) layout);
                relaxer.stop();
                relaxer.prerelax();
                StaticLayout<String, String> staticLayout = new StaticLayout<String, String>(g, layout);
                LayoutTransition<String, String> lt = new LayoutTransition<String, String>(vv,
                        vv.getGraphLayout(), staticLayout);
                Animator animator = new Animator(lt);
                animator.start();
                //   vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.repaint();

            }
        }
    });

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

    timer = new Timer();
}

From source file:com.antelink.sourcesquare.gui.view.ExitSourceSquareView.java

/**
 * Create the frame.//from   www.  j  a v a  2 s  . c  om
 */
public ExitSourceSquareView() {
    setIconImage(Toolkit.getDefaultToolkit().getImage(SourceSquareView.class.getResource("/antelink.png")));
    setTitle("SourceSquare");
    setResizable(false);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 500, 170);
    this.contentPane = new JPanel();
    this.contentPane.setBackground(Color.WHITE);
    this.contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(this.contentPane);

    this.mainPanel = new JPanel();
    this.mainPanel.setBackground(Color.WHITE);
    GroupLayout gl_contentPane = new GroupLayout(this.contentPane);
    gl_contentPane.setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
            .addComponent(this.mainPanel, GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE));
    gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
            .addComponent(this.mainPanel, GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE));
    this.mainPanel.setLayout(new BoxLayout(this.mainPanel, BoxLayout.Y_AXIS));

    JPanel panel_1 = new JPanel();
    panel_1.setBackground(Color.WHITE);
    this.mainPanel.add(panel_1);
    panel_1.setLayout(new BorderLayout(0, 0));

    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout(FlowLayout.CENTER, 50, 20));
    panel.setBackground(Color.WHITE);
    panel_1.add(panel, BorderLayout.SOUTH);

    Image openButtonImage = Toolkit.getDefaultToolkit()
            .getImage(SourceSquareView.class.getResource("/OpenButton.png"));
    this.openButtonLabel = new JLabel(new ImageIcon(openButtonImage));
    this.openButtonLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    panel.add(this.openButtonLabel);

    JLabel exitLabel = new JLabel("<html><b>Closing this window will quit the application</b></html>");
    exitLabel.setFont(new Font("Helvetica", Font.PLAIN, 13));

    JLabel explainLabel = new JLabel("<html>(You won't be able to see or publish your results anymore)</html>");
    explainLabel.setFont(new Font("Helvetica", Font.PLAIN, 13));

    JPanel textPanel = new JPanel();
    textPanel.setBackground(Color.WHITE);
    textPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 0));

    textPanel.add(exitLabel, BorderLayout.CENTER);
    textPanel.add(explainLabel, BorderLayout.CENTER);

    panel_1.add(textPanel, BorderLayout.CENTER);

    CopyrightPanel copyrightPanel = new CopyrightPanel();
    copyrightPanel.setBackground(Color.WHITE);
    this.mainPanel.add(copyrightPanel);
    this.contentPane.setLayout(gl_contentPane);

    setLocationRelativeTo(null);
}