Example usage for java.awt Color YELLOW

List of usage examples for java.awt Color YELLOW

Introduction

In this page you can find the example usage for java.awt Color YELLOW.

Prototype

Color YELLOW

To view the source code for java.awt Color YELLOW.

Click Source Link

Document

The color yellow.

Usage

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

/**
 * create an instance of a simple graph with controls to
 * demo the zoom features.//from w w  w  .j a  va2 s .c  om
 * 
 */
public HyperbolicVertexImageShaperDemo() {

    // create a simple graph for the demo
    graph = new DirectedSparseMultigraph<Number, Number>();
    Number[] vertices = createVertices(11);

    // a Map for the labels
    Map<Number, String> map = new HashMap<Number, String>();
    for (int i = 0; i < vertices.length; i++) {
        map.put(vertices[i], iconNames[i % iconNames.length]);
    }

    // a Map for the Icons
    Map<Number, Icon> iconMap = new HashMap<Number, Icon>();
    for (int i = 0; i < vertices.length; i++) {
        String name = "/images/topic" + iconNames[i] + ".gif";
        try {
            Icon icon = new LayeredIcon(
                    new ImageIcon(HyperbolicVertexImageShaperDemo.class.getResource(name)).getImage());
            iconMap.put(vertices[i], icon);
        } catch (Exception ex) {
            System.err.println("You need slashdoticons.jar in your classpath to see the image " + name);
        }
    }

    createEdges(vertices);

    FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph);
    layout.setMaxIterations(100);
    vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400, 400));

    Transformer<Number, Paint> vpf = new PickableVertexPaintTransformer<Number>(vv.getPickedVertexState(),
            Color.white, Color.yellow);
    vv.getRenderContext().setVertexFillPaintTransformer(vpf);
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan));

    vv.setBackground(Color.white);

    final Transformer<Number, String> vertexStringerImpl = new VertexStringerImpl<Number>(map);
    vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl);
    vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan));
    vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan));

    // features on and off. For a real application, use VertexIconAndShapeFunction instead.
    final VertexIconShapeTransformer<Number> vertexImageShapeFunction = new VertexIconShapeTransformer<Number>(
            new EllipseVertexShapeTransformer<Number>());

    final DefaultVertexIconTransformer<Number> vertexIconFunction = new DefaultVertexIconTransformer<Number>();

    vertexImageShapeFunction.setIconMap(iconMap);
    vertexIconFunction.setIconMap(iconMap);

    vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction);
    vv.getRenderContext().setVertexIconTransformer(vertexIconFunction);

    // Get the pickedState and add a listener that will decorate the
    // Vertex images with a checkmark icon when they are picked
    PickedState<Number> ps = vv.getPickedVertexState();
    ps.addItemListener(new PickWithIconListener(vertexIconFunction));

    vv.addPostRenderPaintable(new VisualizationServer.Paintable() {
        int x;
        int y;
        Font font;
        FontMetrics metrics;
        int swidth;
        int sheight;
        String str = "Thank You, slashdot.org, for the images!";

        public void paint(Graphics g) {
            Dimension d = vv.getSize();
            if (font == null) {
                font = new Font(g.getFont().getName(), Font.BOLD, 20);
                metrics = g.getFontMetrics(font);
                swidth = metrics.stringWidth(str);
                sheight = metrics.getMaxAscent() + metrics.getMaxDescent();
                x = (d.width - swidth) / 2;
                y = (int) (d.height - sheight * 1.5);
            }
            g.setFont(font);
            Color oldColor = g.getColor();
            g.setColor(Color.lightGray);
            g.drawString(str, x, y);
            g.setColor(oldColor);
        }

        public boolean useTransform() {
            return false;
        }
    });

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<Number>());

    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>();
    vv.setGraphMouse(graphMouse);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JComboBox modeBox = graphMouse.getModeComboBox();
    JPanel modePanel = new JPanel();
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));
    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(scaleGrid);

    controls.add(modePanel);
    content.add(controls, BorderLayout.SOUTH);

    this.viewSupport = new HyperbolicImageLensSupport<Number, Number>(vv);
    this.modelSupport = new LayoutLensSupport<Number, Number>(vv);

    graphMouse.addItemListener(modelSupport.getGraphMouse().getModeListener());
    graphMouse.addItemListener(viewSupport.getGraphMouse().getModeListener());

    ButtonGroup radio = new ButtonGroup();
    JRadioButton none = new JRadioButton("None");
    none.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (viewSupport != null) {
                viewSupport.deactivate();
            }
            if (modelSupport != null) {
                modelSupport.deactivate();
            }
        }
    });
    none.setSelected(true);

    JRadioButton hyperView = new JRadioButton("View");
    hyperView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    JRadioButton hyperModel = new JRadioButton("Layout");
    hyperModel.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            modelSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    radio.add(none);
    radio.add(hyperView);
    radio.add(hyperModel);

    JMenuBar menubar = new JMenuBar();
    JMenu modeMenu = graphMouse.getModeMenu();
    menubar.add(modeMenu);

    JPanel lensPanel = new JPanel(new GridLayout(2, 0));
    lensPanel.setBorder(BorderFactory.createTitledBorder("Lens"));
    lensPanel.add(none);
    lensPanel.add(hyperView);
    lensPanel.add(hyperModel);
    controls.add(lensPanel);
}

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

/**
 * create an instance of a simple graph with controls to
 * demo the zoom features.//from  w w  w .j a v  a  2  s . c o  m
 * 
 */
@SuppressWarnings("rawtypes")
public LensVertexImageShaperDemo() {

    // create a simple graph for the demo
    graph = new DirectedSparseGraph<Number, Number>();
    Number[] vertices = createVertices(11);

    // a Map for the labels
    Map<Number, String> map = new HashMap<Number, String>();
    for (int i = 0; i < vertices.length; i++) {
        map.put(vertices[i], iconNames[i % iconNames.length]);
    }

    // a Map for the Icons
    Map<Number, Icon> iconMap = new HashMap<Number, Icon>();
    for (int i = 0; i < vertices.length; i++) {
        String name = "/images/topic" + iconNames[i] + ".gif";
        try {
            Icon icon = new LayeredIcon(
                    new ImageIcon(LensVertexImageShaperDemo.class.getResource(name)).getImage());
            iconMap.put(vertices[i], icon);
        } catch (Exception ex) {
            System.err.println("You need slashdoticons.jar in your classpath to see the image " + name);
        }
    }

    createEdges(vertices);

    FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph);
    layout.setMaxIterations(100);
    vv = new VisualizationViewer<Number, Number>(layout, new Dimension(600, 600));

    Transformer<Number, Paint> vpf = new PickableVertexPaintTransformer<Number>(vv.getPickedVertexState(),
            Color.white, Color.yellow);
    vv.getRenderContext().setVertexFillPaintTransformer(vpf);
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan));

    vv.setBackground(Color.white);

    final Transformer<Number, String> vertexStringerImpl = new VertexStringerImpl<Number>(map);
    vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl);
    vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan));
    vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan));

    // features on and off. For a real application, use VertexIconAndShapeFunction instead.
    final VertexIconShapeTransformer<Number> vertexImageShapeFunction = new VertexIconShapeTransformer<Number>(
            new EllipseVertexShapeTransformer<Number>());

    final DefaultVertexIconTransformer<Number> vertexIconFunction = new DefaultVertexIconTransformer<Number>();

    vertexImageShapeFunction.setIconMap(iconMap);
    vertexIconFunction.setIconMap(iconMap);

    vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction);
    vv.getRenderContext().setVertexIconTransformer(vertexIconFunction);

    // Get the pickedState and add a listener that will decorate the
    // Vertex images with a checkmark icon when they are picked
    PickedState<Number> ps = vv.getPickedVertexState();
    ps.addItemListener(new PickWithIconListener(vertexIconFunction));

    vv.addPostRenderPaintable(new VisualizationViewer.Paintable() {
        int x;
        int y;
        Font font;
        FontMetrics metrics;
        int swidth;
        int sheight;
        String str = "Thank You, slashdot.org, for the images!";

        public void paint(Graphics g) {
            Dimension d = vv.getSize();
            if (font == null) {
                font = new Font(g.getFont().getName(), Font.BOLD, 20);
                metrics = g.getFontMetrics(font);
                swidth = metrics.stringWidth(str);
                sheight = metrics.getMaxAscent() + metrics.getMaxDescent();
                x = (d.width - swidth) / 2;
                y = (int) (d.height - sheight * 1.5);
            }
            g.setFont(font);
            Color oldColor = g.getColor();
            g.setColor(Color.lightGray);
            g.drawString(str, x, y);
            g.setColor(oldColor);
        }

        public boolean useTransform() {
            return false;
        }
    });

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<Number>());

    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();
    vv.setGraphMouse(graphMouse);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JComboBox modeBox = graphMouse.getModeComboBox();
    JPanel modePanel = new JPanel();
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));
    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(scaleGrid);

    controls.add(modePanel);
    content.add(controls, BorderLayout.SOUTH);

    this.viewSupport = new MagnifyImageLensSupport<Number, Number>(vv);
    //           new ViewLensSupport<Number,Number>(vv, new HyperbolicShapeTransformer(vv, 
    //              vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), 
    //                new ModalLensGraphMouse());

    this.modelSupport = new LayoutLensSupport<Number, Number>(vv);

    graphMouse.addItemListener(modelSupport.getGraphMouse().getModeListener());
    graphMouse.addItemListener(viewSupport.getGraphMouse().getModeListener());

    ButtonGroup radio = new ButtonGroup();
    JRadioButton none = new JRadioButton("None");
    none.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (viewSupport != null) {
                viewSupport.deactivate();
            }
            if (modelSupport != null) {
                modelSupport.deactivate();
            }
        }
    });
    none.setSelected(true);

    JRadioButton hyperView = new JRadioButton("View");
    hyperView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    JRadioButton hyperModel = new JRadioButton("Layout");
    hyperModel.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            modelSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    radio.add(none);
    radio.add(hyperView);
    radio.add(hyperModel);

    JMenuBar menubar = new JMenuBar();
    JMenu modeMenu = graphMouse.getModeMenu();
    menubar.add(modeMenu);

    JPanel lensPanel = new JPanel(new GridLayout(2, 0));
    lensPanel.setBorder(BorderFactory.createTitledBorder("Lens"));
    lensPanel.add(none);
    lensPanel.add(hyperView);
    lensPanel.add(hyperModel);
    controls.add(lensPanel);
}

From source file:barChart1.BarChartDemo.java

/**
 * Creates a sample chart./*from   w ww .j a  va2 s  . c  o  m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private static JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart("Belgium vs Italy vs Ireland ", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(64, 0, 0));

    GradientPaint gp3 = new GradientPaint(0.0f, 0.0f, Color.yellow, 0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);
    renderer.setSeriesPaint(3, gp2);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:financepro.XYLineChartExample.java

License:asdf

private JPanel createChartPanel() {
    // creates a line chart object
    // returns the chart panel
    String chartTitle = "Various Financial Ratios";
    String xAxisLabel = "Years";
    String yAxisLabel = "Ratio Values";

    XYDataset dataset = createDataset();

    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, xAxisLabel, yAxisLabel, dataset);

    XYPlot plot = chart.getXYPlot();// ww  w . j  a v a 2s .c  om
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(renderer);

    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesPaint(3, Color.CYAN);
    renderer.setSeriesPaint(4, Color.BLACK);

    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    renderer.setSeriesStroke(1, new BasicStroke(4.0f));
    renderer.setSeriesStroke(2, new BasicStroke(4.0f));
    renderer.setSeriesStroke(3, new BasicStroke(4.0f));
    renderer.setSeriesStroke(4, new BasicStroke(4.0f));

    plot.setRenderer(renderer);
    plot.setOutlinePaint(Color.BLUE);
    plot.setOutlineStroke(new BasicStroke(4.0f));
    plot.setBackgroundPaint(Color.DARK_GRAY);

    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.BLACK);

    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.BLACK);

    return new ChartPanel(chart);
}

From source file:com.google.code.facebook.graph.sna.applet.VertexImageShaperDemo.java

public VertexImageShaperDemo() {

    // create a simple graph for the demo
    graph = new DirectedSparseGraph<Number, Number>();
    createGraph(VERTEX_COUNT);/*w ww  .  j a va 2s . c  om*/

    // a Map for the labels
    Map<Number, String> map = new HashMap<Number, String>();
    for (int i = 0; i < VERTEX_COUNT; i++) {
        map.put(i, iconNames[i % iconNames.length]);
    }

    // a Map for the Icons
    Map<Number, Icon> iconMap = new HashMap<Number, Icon>();
    for (int i = 0; i < VERTEX_COUNT; i++) {
        String name = "/images/topic" + iconNames[i] + ".gif";
        try {
            Icon icon = new LayeredIcon(
                    new ImageIcon(VertexImageShaperDemo.class.getResource(name)).getImage());
            iconMap.put(i, icon);
        } catch (Exception ex) {
            System.err.println("You need slashdoticons.jar in your classpath to see the image " + name);
        }
    }

    FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph);
    layout.setMaxIterations(100);
    layout.setInitializer(new RandomLocationTransformer<Number>(new Dimension(400, 400), 0));
    vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400, 400));

    // This demo uses a special renderer to turn outlines on and off.
    // you do not need to do this in a real application.
    // Instead, just let vv use the Renderer it already has
    vv.getRenderer().setVertexRenderer(new DemoRenderer<Number, Number>());

    Transformer<Number, Paint> vpf = new PickableVertexPaintTransformer<Number>(vv.getPickedVertexState(),
            Color.white, Color.yellow);
    vv.getRenderContext().setVertexFillPaintTransformer(vpf);
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan));

    vv.setBackground(Color.white);

    final Transformer<Number, String> vertexStringerImpl = new VertexStringerImpl<Number, String>(map);
    vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl);
    vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan));
    vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan));
    //        vv.getRenderContext().setEdgeLabelTransformer(new Transformer<Number,String>() {
    //           URL url = getClass().getResource("/images/lightning-s.gif");
    //         public String transform(Number input) {
    //            
    //            return "<html><img src="+url+" height=10 width=21>"+input.toString();
    //         }});

    // For this demo only, I use a special class that lets me turn various
    // features on and off. For a real application, use VertexIconShapeTransformer instead.
    final DemoVertexIconShapeTransformer<Number> vertexIconShapeTransformer = new DemoVertexIconShapeTransformer<Number>(
            new EllipseVertexShapeTransformer<Number>());

    final DemoVertexIconTransformer<Number> vertexIconTransformer = new DemoVertexIconTransformer<Number>();

    vertexIconShapeTransformer.setIconMap(iconMap);
    vertexIconTransformer.setIconMap(iconMap);

    vv.getRenderContext().setVertexShapeTransformer(vertexIconShapeTransformer);
    vv.getRenderContext().setVertexIconTransformer(vertexIconTransformer);

    // un-comment for RStar Tree visual testing
    //vv.addPostRenderPaintable(new BoundingRectanglePaintable(vv.getRenderContext(), vv.getGraphLayout()));

    // Get the pickedState and add a listener that will decorate the
    // Vertex images with a checkmark icon when they are picked
    PickedState<Number> ps = vv.getPickedVertexState();
    ps.addItemListener(new PickWithIconListener<Number>(vertexIconTransformer));

    vv.addPostRenderPaintable(new VisualizationViewer.Paintable() {
        int x;
        int y;
        Font font;
        FontMetrics metrics;
        int swidth;
        int sheight;
        String str = "Thank You, slashdot.org, for the images!";

        public void paint(Graphics g) {
            Dimension d = vv.getSize();
            if (font == null) {
                font = new Font(g.getFont().getName(), Font.BOLD, 20);
                metrics = g.getFontMetrics(font);
                swidth = metrics.stringWidth(str);
                sheight = metrics.getMaxAscent() + metrics.getMaxDescent();
                x = (d.width - swidth) / 2;
                y = (int) (d.height - sheight * 1.5);
            }
            g.setFont(font);
            Color oldColor = g.getColor();
            g.setColor(Color.lightGray);
            g.drawString(str, x, y);
            g.setColor(oldColor);
        }

        public boolean useTransform() {
            return false;
        }
    });

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<Number>());

    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>();
    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());
    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JCheckBox shape = new JCheckBox("Shape");
    shape.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            vertexIconShapeTransformer.setShapeImages(e.getStateChange() == ItemEvent.SELECTED);
            vv.repaint();
        }
    });
    shape.setSelected(true);

    JCheckBox fill = new JCheckBox("Fill");
    fill.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            vertexIconTransformer.setFillImages(e.getStateChange() == ItemEvent.SELECTED);
            vv.repaint();
        }
    });
    fill.setSelected(true);

    JCheckBox drawOutlines = new JCheckBox("Outline");
    drawOutlines.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            vertexIconTransformer.setOutlineImages(e.getStateChange() == ItemEvent.SELECTED);
            vv.repaint();
        }
    });

    JComboBox modeBox = graphMouse.getModeComboBox();
    JPanel modePanel = new JPanel();
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));
    JPanel labelFeatures = new JPanel(new GridLayout(1, 0));
    labelFeatures.setBorder(BorderFactory.createTitledBorder("Image Effects"));
    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(scaleGrid);
    labelFeatures.add(shape);
    labelFeatures.add(fill);
    labelFeatures.add(drawOutlines);

    controls.add(labelFeatures);
    controls.add(modePanel);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:nl.phanos.liteliveresultsclient.gui.ResultsWindows.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*w w  w.  j  a v  a2  s  .  com*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    LayerdPane = new javax.swing.JLayeredPane();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTable1 = new javax.swing.JTable();
    jPanel1 = new javax.swing.JPanel();
    SerieLabel = new java.awt.Label();
    photopanel = new javax.swing.JPanel();
    photolabel = new javax.swing.JLabel();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
    jMenuItem1 = new javax.swing.JMenuItem();
    jMenuItem2 = new javax.swing.JMenuItem();
    jCheckBoxMenuItem2 = new javax.swing.JCheckBoxMenuItem();
    jMenu2 = new javax.swing.JMenu();
    SeparateClock = new javax.swing.JCheckBoxMenuItem();
    ChangeIp = new javax.swing.JMenuItem();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setPreferredSize(new java.awt.Dimension(1280, 720));
    addComponentListener(new java.awt.event.ComponentAdapter() {
        public void componentResized(java.awt.event.ComponentEvent evt) {
            formComponentResized(evt);
        }
    });

    jTable1.setBackground(new java.awt.Color(0, 0, 0));
    jTable1.setFont(new java.awt.Font("Lucida Grande", 0, 48)); // NOI18N
    jTable1.setForeground(java.awt.Color.yellow);
    jTable1.setModel(
            new javax.swing.table.DefaultTableModel(
                    new Object[][] { { null, null, null, null }, { null, null, null, null },
                            { null, null, null, null }, { null, null, null, null } },
                    new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
    jTable1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
        public void mouseMoved(java.awt.event.MouseEvent evt) {
            jTable1MouseMoved(evt);
        }
    });
    jTable1.addComponentListener(new java.awt.event.ComponentAdapter() {
        public void componentResized(java.awt.event.ComponentEvent evt) {
            jTable1ComponentResized(evt);
        }
    });
    jScrollPane1.setViewportView(jTable1);

    SerieLabel.setBackground(new java.awt.Color(0, 0, 0));
    SerieLabel.setFont(new java.awt.Font("Lucida Grande", 0, 48)); // NOI18N
    SerieLabel.setForeground(java.awt.Color.yellow);
    SerieLabel.setText("200m T64 Finale");

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout
            .setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(SerieLabel, javax.swing.GroupLayout.Alignment.TRAILING,
                            javax.swing.GroupLayout.DEFAULT_SIZE, 724, Short.MAX_VALUE));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(SerieLabel, javax.swing.GroupLayout.DEFAULT_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));

    SerieLabel.getAccessibleContext().setAccessibleName("SerieLabel");

    photopanel.setBackground(new java.awt.Color(0, 0, 0));
    photopanel.setPreferredSize(new java.awt.Dimension(0, 100));
    photopanel.setRequestFocusEnabled(false);

    javax.swing.GroupLayout photopanelLayout = new javax.swing.GroupLayout(photopanel);
    photopanel.setLayout(photopanelLayout);
    photopanelLayout.setHorizontalGroup(photopanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(photopanelLayout.createSequentialGroup().addContainerGap().addComponent(photolabel,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()));
    photopanelLayout.setVerticalGroup(photopanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(photopanelLayout.createSequentialGroup().addContainerGap().addComponent(photolabel,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()));

    LayerdPane.setLayer(jScrollPane1, javax.swing.JLayeredPane.DEFAULT_LAYER);
    LayerdPane.setLayer(jPanel1, javax.swing.JLayeredPane.DEFAULT_LAYER);
    LayerdPane.setLayer(photopanel, javax.swing.JLayeredPane.DEFAULT_LAYER);

    javax.swing.GroupLayout LayerdPaneLayout = new javax.swing.GroupLayout(LayerdPane);
    LayerdPane.setLayout(LayerdPaneLayout);
    LayerdPaneLayout
            .setHorizontalGroup(LayerdPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(LayerdPaneLayout.createSequentialGroup().addContainerGap().addComponent(
                            jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                            Short.MAX_VALUE))
                    .addGroup(LayerdPaneLayout.createSequentialGroup()
                            .addComponent(photopanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jScrollPane1)));
    LayerdPaneLayout.setVerticalGroup(LayerdPaneLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(LayerdPaneLayout.createSequentialGroup()
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(LayerdPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(photopanel, javax.swing.GroupLayout.DEFAULT_SIZE, 544,
                                    Short.MAX_VALUE)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 544,
                                    Short.MAX_VALUE))));

    jMenu1.setText("Options");

    jCheckBoxMenuItem1.setText("Fullscreen");
    jCheckBoxMenuItem1.setEnabled(false);
    jCheckBoxMenuItem1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jCheckBoxMenuItem1ActionPerformed(evt);
        }
    });
    jMenu1.add(jCheckBoxMenuItem1);

    jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_EQUALS,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.META_MASK));
    jMenuItem1.setText("Larger Text");
    jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem1ActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItem1);

    jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_MINUS,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.META_MASK));
    jMenuItem2.setText("Smaler Text");
    jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem2ActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItem2);

    jCheckBoxMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.META_MASK));
    jCheckBoxMenuItem2.setSelected(true);
    jCheckBoxMenuItem2.setText("ShowPhoto");
    jCheckBoxMenuItem2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jCheckBoxMenuItem2ActionPerformed(evt);
        }
    });
    jMenu1.add(jCheckBoxMenuItem2);

    jMenuBar1.add(jMenu1);

    jMenu2.setText("Clock");

    SeparateClock.setSelected(true);
    SeparateClock.setText("Separate clock");
    SeparateClock.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            SeparateClockActionPerformed(evt);
        }
    });
    jMenu2.add(SeparateClock);

    ChangeIp.setText("Change Ip");
    ChangeIp.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ChangeIpActionPerformed(evt);
        }
    });
    jMenu2.add(ChangeIp);

    jMenuBar1.add(jMenu2);

    setJMenuBar(jMenuBar1);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(LayerdPane));
    layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(LayerdPane));

    LayerdPane.getAccessibleContext().setAccessibleName("");

    pack();
}

From source file:joshua.ui.hypergraph_visualizer.HyperGraphViewer.java

private Transformer<Vertex, Paint> vertexPainter() {
    return new Transformer<Vertex, Paint>() {
        private Color[] colors = { Color.blue, Color.red, Color.yellow, Color.green, Color.cyan };

        public Paint transform(Vertex v) {
            return colors[v.getColor() % colors.length];
        }//from w  w w . j a va 2s .c  om
    };
}

From source file:demo.VertexImageShaperDemo.java

public VertexImageShaperDemo() {

    // create a simple graph for the demo
    graph = new DirectedSparseGraph<Number, Number>();
    createGraph(VERTEX_COUNT);/*from  w w  w.  ja  v a  2 s  .c o m*/

    // a Map for the labels
    Map<Number, String> map = new HashMap<Number, String>();
    for (int i = 0; i < VERTEX_COUNT; i++) {
        map.put(i, iconNames[i % iconNames.length]);
    }

    // a Map for the Icons
    Map<Number, Icon> iconMap = new HashMap<Number, Icon>();
    for (int i = 0; i < VERTEX_COUNT; i++) {
        String name = "/images/topic" + iconNames[i] + ".gif";
        try {
            Icon icon = new LayeredIcon(
                    new ImageIcon(VertexImageShaperDemo.class.getResource(name)).getImage());
            //iconMap.put(i, icon);
            iconMap.put(i, new ImageIcon("transferir.png"));
        } catch (Exception ex) {
            System.err.println("You need slashdoticons.jar in your classpath to see the image " + name);
        }
    }

    FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph);
    layout.setMaxIterations(100);
    layout.setInitializer(new RandomLocationTransformer<Number>(new Dimension(400, 400), 0));
    vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400, 400));

    // This demo uses a special renderer to turn outlines on and off.
    // you do not need to do this in a real application.
    // Instead, just let vv use the Renderer it already has
    vv.getRenderer().setVertexRenderer(new DemoRenderer<Number, Number>());

    Transformer<Number, Paint> vpf = new PickableVertexPaintTransformer<Number>(vv.getPickedVertexState(),
            Color.white, Color.yellow);
    vv.getRenderContext().setVertexFillPaintTransformer(vpf);
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan));

    vv.setBackground(Color.white);

    final Transformer<Number, String> vertexStringerImpl = new VertexStringerImpl<Number, String>(map);
    vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl);
    vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan));
    vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan));
    //        vv.getRenderContext().setEdgeLabelTransformer(new Transformer<Number,String>() {
    //           URL url = getClass().getResource("/images/lightning-s.gif");
    //         public String transform(Number input) {
    //            
    //            return "<html><img src="+url+" height=10 width=21>"+input.toString();
    //         }});

    // For this demo only, I use a special class that lets me turn various
    // features on and off. For a real application, use VertexIconShapeTransformer instead.
    final DemoVertexIconShapeTransformer<Number> vertexIconShapeTransformer = new DemoVertexIconShapeTransformer<Number>(
            new EllipseVertexShapeTransformer<Number>());

    final DemoVertexIconTransformer<Number> vertexIconTransformer = new DemoVertexIconTransformer<Number>();

    vertexIconShapeTransformer.setIconMap(iconMap);
    vertexIconTransformer.setIconMap(iconMap);

    vv.getRenderContext().setVertexShapeTransformer(vertexIconShapeTransformer);
    vv.getRenderContext().setVertexIconTransformer(vertexIconTransformer);

    // un-comment for RStar Tree visual testing
    //vv.addPostRenderPaintable(new BoundingRectanglePaintable(vv.getRenderContext(), vv.getGraphLayout()));

    // Get the pickedState and add a listener that will decorate the
    // Vertex images with a checkmark icon when they are picked
    PickedState<Number> ps = vv.getPickedVertexState();
    ps.addItemListener(new PickWithIconListener<Number>(vertexIconTransformer));

    vv.addPostRenderPaintable(new VisualizationViewer.Paintable() {
        int x;
        int y;
        Font font;
        FontMetrics metrics;
        int swidth;
        int sheight;
        String str = "Thank You, slashdot.org, for the images!";

        public void paint(Graphics g) {
            Dimension d = vv.getSize();
            if (font == null) {
                font = new Font(g.getFont().getName(), Font.BOLD, 20);
                metrics = g.getFontMetrics(font);
                swidth = metrics.stringWidth(str);
                sheight = metrics.getMaxAscent() + metrics.getMaxDescent();
                x = (d.width - swidth) / 2;
                y = (int) (d.height - sheight * 1.5);
            }
            g.setFont(font);
            Color oldColor = g.getColor();
            g.setColor(Color.lightGray);
            g.drawString(str, x, y);
            g.setColor(oldColor);
        }

        public boolean useTransform() {
            return false;
        }
    });

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<Number>());

    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>();
    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());
    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JCheckBox shape = new JCheckBox("Shape");
    shape.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            vertexIconShapeTransformer.setShapeImages(e.getStateChange() == ItemEvent.SELECTED);
            vv.repaint();
        }
    });
    shape.setSelected(true);

    JCheckBox fill = new JCheckBox("Fill");
    fill.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            vertexIconTransformer.setFillImages(e.getStateChange() == ItemEvent.SELECTED);
            vv.repaint();
        }
    });
    fill.setSelected(true);

    JCheckBox drawOutlines = new JCheckBox("Outline");
    drawOutlines.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            vertexIconTransformer.setOutlineImages(e.getStateChange() == ItemEvent.SELECTED);
            vv.repaint();
        }
    });

    JComboBox modeBox = graphMouse.getModeComboBox();
    JPanel modePanel = new JPanel();
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));
    JPanel labelFeatures = new JPanel(new GridLayout(1, 0));
    labelFeatures.setBorder(BorderFactory.createTitledBorder("Image Effects"));
    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(scaleGrid);
    labelFeatures.add(shape);
    labelFeatures.add(fill);
    labelFeatures.add(drawOutlines);

    controls.add(labelFeatures);
    controls.add(modePanel);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:org.deeplearning4j.ui.TestRendering.java

@Ignore
@Test//from w  ww  .  ja  v  a  2s. co  m
public void test() throws Exception {

    List<Component> list = new ArrayList<>();

    //Common style for all of the charts
    StyleChart s = new StyleChart.Builder().width(640, LengthUnit.Px).height(480, LengthUnit.Px)
            .margin(LengthUnit.Px, 100, 40, 40, 20).strokeWidth(2).pointSize(4)
            .seriesColors(Color.GREEN, Color.MAGENTA).titleStyle(new StyleText.Builder().font("courier")
                    .fontSize(16).underline(true).color(Color.GRAY).build())
            .build();

    //Line chart with vertical grid
    Component c1 = new ChartLine.Builder("Line Chart!", s)
            .addSeries("series0", new double[] { 0, 1, 2, 3 }, new double[] { 0, 2, 1, 4 })
            .addSeries("series1", new double[] { 0, 1, 2, 3 }, new double[] { 0, 1, 0.5, 2.5 })
            .setGridWidth(1.0, null) //Vertical grid lines, no horizontal grid
            .build();
    list.add(c1);

    //Scatter chart
    Component c2 = new ChartScatter.Builder("Scatter!", s)
            .addSeries("series0", new double[] { 0, 1, 2, 3 }, new double[] { 0, 2, 1, 4 }).showLegend(true)
            .setGridWidth(0, 0).build();
    list.add(c2);

    //Histogram with variable sized bins
    Component c3 = new ChartHistogram.Builder("Histogram!", s).addBin(-1, -0.5, 0.2).addBin(-0.5, 0, 0.5)
            .addBin(0, 1, 2.5).addBin(1, 2, 0.5).build();
    list.add(c3);

    //Stacked area chart
    Component c4 = new ChartStackedArea.Builder("Area Chart!", s).setXValues(new double[] { 0, 1, 2, 3, 4, 5 })
            .addSeries("series0", new double[] { 0, 1, 0, 2, 0, 1 })
            .addSeries("series1", new double[] { 2, 1, 2, 0.5, 2, 1 }).build();
    list.add(c4);

    //Table
    StyleTable ts = new StyleTable.Builder().backgroundColor(Color.LIGHT_GRAY).headerColor(Color.ORANGE)
            .borderWidth(1).columnWidths(LengthUnit.Percent, 20, 40, 40).width(500, LengthUnit.Px)
            .height(200, LengthUnit.Px).build();

    Component c5 = new ComponentTable.Builder(ts).header("H1", "H2", "H3").content(
            new String[][] { { "row0col0", "row0col1", "row0col2" }, { "row1col0", "row1col1", "row1col2" } })
            .build();
    list.add(c5);

    //Accordion decorator, with the same chart
    StyleAccordion ac = new StyleAccordion.Builder().height(480, LengthUnit.Px).width(640, LengthUnit.Px)
            .build();

    Component c6 = new DecoratorAccordion.Builder(ac).title("Accordion - Collapsed By Default!")
            .setDefaultCollapsed(true).addComponents(c5).build();
    list.add(c6);

    //Text with styling
    Component c7 = new ComponentText.Builder("Here's some blue text in a green div!",
            new StyleText.Builder().font("courier").fontSize(30).underline(true).color(Color.BLUE).build())
                    .build();

    //Div, with a chart inside
    Style divStyle = new StyleDiv.Builder().width(30, LengthUnit.Percent).height(200, LengthUnit.Px)
            .backgroundColor(Color.GREEN).floatValue(StyleDiv.FloatValue.right).build();
    Component c8 = new ComponentDiv(divStyle, c7,
            new ComponentText("(Also: it's float right, 30% width, 200 px high )", null));
    list.add(c8);

    //Timeline chart:
    List<ChartTimeline.TimelineEntry> entries = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        entries.add(new ChartTimeline.TimelineEntry("e0-" + i, 10 * i, 10 * i + 5, Color.BLUE));
    }
    List<ChartTimeline.TimelineEntry> entries2 = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        entries2.add(new ChartTimeline.TimelineEntry("e1-" + i, (int) (5 * i + 0.2 * i * i),
                (int) (5 * i + 0.2 * i * i) + 3, Color.ORANGE));
    }
    List<ChartTimeline.TimelineEntry> entries3 = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        entries3.add(new ChartTimeline.TimelineEntry("e2-" + i, (int) (2 * i + 0.6 * i * i + 3),
                (int) (2 * i + 0.6 * i * i + 3) + 2 * i + 1));
    }
    Color[] c = new Color[] { Color.CYAN, Color.YELLOW, Color.GREEN, Color.PINK };
    List<ChartTimeline.TimelineEntry> entries4 = new ArrayList<>();
    Random r = new Random(12345);
    for (int i = 0; i < 10; i++) {
        entries4.add(new ChartTimeline.TimelineEntry("e3-" + i, (int) (2 * i + 0.6 * i * i + 3),
                (int) (2 * i + 0.6 * i * i + 3) + i + 1, c[r.nextInt(c.length)]));
    }
    Component c9 = new ChartTimeline.Builder("Title", s).addLane("Lane 0", entries).addLane("Lane 1", entries2)
            .addLane("Lane 2", entries3).addLane("Lane 3", entries4).build();
    list.add(c9);

    //Generate HTML
    StringBuilder sb = new StringBuilder();
    sb.append("<!DOCTYPE html>\n" + "<html lang=\"en\">\n" + "<head>\n" + "    <meta charset=\"UTF-8\">\n"
            + "    <title>Title</title>\n" + "</head>\n" + "<body>\n" + "\n" + "    <div id=\"maindiv\">\n"
            + "\n" + "    </div>\n" + "\n" + "\n"
            + "    <script src=\"//code.jquery.com/jquery-1.10.2.js\"></script>\n"
            + "    <script src=\"https://code.jquery.com/ui/1.11.4/jquery-ui.min.js\"></script>\n"
            + "    <link rel=\"stylesheet\" href=\"//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css\">\n"
            + "    <script src=\"https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js\"></script>\n"
            + "    <script src=\"src/main/resources/assets/dl4j-ui.js\"></script>\n" + "\n" + "    <script>\n");

    ObjectMapper om = new ObjectMapper();
    for (int i = 0; i < list.size(); i++) {
        Component component = list.get(i);
        sb.append("        ").append("var str").append(i).append(" = '")
                .append(om.writeValueAsString(component).replaceAll("'", "\\\\'")).append("';\n");

        sb.append("        ").append("var obj").append(i).append(" = Component.getComponent(str").append(i)
                .append(");\n");
        sb.append("        ").append("obj").append(i).append(".render($('#maindiv'));\n");
        sb.append("\n\n");
    }

    sb.append("    </script>\n" + "\n" + "</body>\n" + "</html>");

    FileUtils.writeStringToFile(new File("TestRendering.html"), sb.toString());
}

From source file:net.sf.mzmine.chartbasics.chartthemes.ChartThemeFactory.java

/**
 * Creates and returns a theme called "Darkness". In this theme, the charts have a black
 * background and white lines and labels
 *
 * @return The "Darkness" theme.//from   w w w .  j a  va 2s  . c om
 */
public static EStandardChartTheme createDarknessTheme() {
    EStandardChartTheme theme = new EStandardChartTheme(THEME.DARKNESS, "Darkness");
    // Fonts
    theme.setExtraLargeFont(new Font("Arial", Font.BOLD, 20));
    theme.setLargeFont(new Font("Arial", Font.BOLD, 11));
    theme.setRegularFont(new Font("Arial", Font.PLAIN, 11));
    theme.setSmallFont(new Font("Arial", Font.PLAIN, 11));
    //
    theme.setTitlePaint(Color.white);
    theme.setSubtitlePaint(Color.white);
    theme.setLegendBackgroundPaint(Color.black);
    theme.setLegendItemPaint(Color.white);
    theme.setChartBackgroundPaint(Color.black);
    theme.setPlotBackgroundPaint(Color.black);
    theme.setPlotOutlinePaint(Color.yellow);
    theme.setBaselinePaint(Color.white);
    theme.setCrosshairPaint(Color.red);
    theme.setLabelLinkPaint(Color.lightGray);
    theme.setTickLabelPaint(Color.white);
    theme.setAxisLabelPaint(Color.white);
    theme.setShadowPaint(Color.darkGray);
    theme.setItemLabelPaint(Color.white);
    theme.setDrawingSupplier(new DefaultDrawingSupplier(
            new Paint[] { Color.WHITE, Color.decode("0xFFFF00"), Color.decode("0x0036CC"),
                    Color.decode("0xFF0000"), Color.decode("0xFFFF7F"), Color.decode("0x6681CC"),
                    Color.decode("0xFF7F7F"), Color.decode("0xFFFFBF"), Color.decode("0x99A6CC"),
                    Color.decode("0xFFBFBF"), Color.decode("0xA9A938"), Color.decode("0x2D4587") },
            new Paint[] { Color.decode("0xFFFF00"), Color.decode("0x0036CC") },
            new Stroke[] { new BasicStroke(2.0f) }, new Stroke[] { new BasicStroke(0.5f) },
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));
    theme.setErrorIndicatorPaint(Color.lightGray);
    theme.setGridBandPaint(new Color(255, 255, 255, 20));
    theme.setGridBandAlternatePaint(new Color(255, 255, 255, 40));

    // axis
    Color transp = new Color(255, 255, 255, 200);
    theme.setRangeGridlinePaint(transp);
    theme.setDomainGridlinePaint(transp);

    theme.setAxisLinePaint(Color.white);

    theme.setMasterFontColor(Color.WHITE);
    // axis offset
    theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0));
    return theme;
}