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:com.jolbox.benchmark.BenchmarkLaunch.java

/**
 * @param results//from  w  w w  .ja v a2s.co  m
 * @param delay 
 * @param statementBenchmark 
 * @param noC3P0 
 * @throws IOException 
 */
private static void doPlotLineGraph(long[][] results, int delay, boolean statementBenchmark, boolean noC3P0)
        throws IOException {
    String title = "Multi-Thread test (" + delay + "ms delay)";
    if (statementBenchmark) {
        title += "\n(with PreparedStatements tests)";
    }
    String fname = System.getProperty("java.io.tmpdir") + File.separator + "bonecp-multithread-" + delay
            + "ms-delay";
    if (statementBenchmark) {
        fname += "-with-preparedstatements";
    }
    fname += "-poolsize-" + BenchmarkTests.pool_size + "-threads-" + BenchmarkTests.threads;
    if (noC3P0) {
        fname += "-noC3P0";
    }
    PrintWriter out = new PrintWriter(new FileWriter(fname + ".txt"));
    fname += ".png";

    XYSeriesCollection dataset = new XYSeriesCollection();
    for (int i = 0; i < ConnectionPoolType.values().length; i++) { //
        if (!ConnectionPoolType.values()[i].isEnabled()
                || (noC3P0 && ConnectionPoolType.values()[i].equals(ConnectionPoolType.C3P0))) {
            continue;
        }
        XYSeries series = new XYSeries(ConnectionPoolType.values()[i].toString());
        out.println(ConnectionPoolType.values()[i].toString());
        for (int j = 1 + BenchmarkTests.stepping; j < results[i].length; j += BenchmarkTests.stepping) {
            series.add(j, results[i][j]);
            out.println(j + "," + results[i][j]);
        }
        dataset.addSeries(series);
    }
    out.close();

    //         Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart(title, // Title
            "threads", // x-axis Label
            "time (ns)", // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            true, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );

    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    plot.setRenderer(renderer);
    renderer.setSeriesPaint(0, Color.BLUE);
    renderer.setSeriesPaint(1, Color.YELLOW);
    renderer.setSeriesPaint(2, Color.BLACK);
    renderer.setSeriesPaint(3, Color.DARK_GRAY);
    renderer.setSeriesPaint(4, Color.MAGENTA);
    renderer.setSeriesPaint(5, Color.RED);
    renderer.setSeriesPaint(6, Color.LIGHT_GRAY);
    //          renderer.setSeriesShapesVisible(1, true);   
    //          renderer.setSeriesShapesVisible(2, true);   

    try {
        ChartUtilities.saveChartAsPNG(new File(fname), chart, 1024, 768);
        System.out.println("******* Saved chart to: " + fname);
    } catch (IOException e) {
        System.err.println("Problem occurred creating chart.");
    }

}

From source file:Bouncer.java

protected void setPaint(Graphics2D g2) {
    if (mGradient) {
        GradientPaint gp = new GradientPaint(0, 0, Color.yellow, 50, 25, Color.red, true);
        g2.setPaint(gp);//from  ww  w .  ja v a  2s  . c o  m
    } else
        g2.setPaint(Color.orange);
}

From source file:umontreal.ssj.charts.SSJCategorySeriesCollection.java

/**
 * Gives the default color associated with a series
 *
 * @param   index Index of the series in the CategoryDataset object.
 * @return        default color object./*from  w ww. j  ava  2s . co  m*/
 */
protected static Color getDefaultColor(int index) {
    if (index % 6 == 0)
        return Color.RED;
    else if (index % 6 == 1)
        return Color.BLUE;
    else if (index % 6 == 2)
        return Color.GREEN;
    else if (index % 6 == 3)
        return Color.YELLOW;
    else if (index % 6 == 4)
        return Color.MAGENTA;
    else
        return Color.CYAN;
}

From source file:graph.jung2.MyLensDemo.java

public void init() {

    // create a simple graph for the demo
    TemporalNetworkOfWikipediaNodes net = null;
    try {/*w ww.j  a  v a 2  s .c o m*/

        // net = new TemporalNetworkOfWikipediaNodes(null, null);
        net = new TemporalNetworkOfWikipediaNodes(r, level);
        graph = net.createSampleNetwork(); //getCC_EDIT_Graph();

    } catch (Exception ex) {
        Logger.getLogger(MyLensDemo.class.getName()).log(Level.SEVERE, null, ex);
    }

    //        if ( net == null ) {
    //            graph = TemporalNetworkOfWikipediaNodes.createSampleNetwork();
    //        }
    //        else {
    //            graph = net.getGraph();
    //        }

    graphLayout = new FRLayout<String, Number>(graph);
    ((FRLayout) graphLayout).setMaxIterations(1000);

    Dimension preferredSize = new Dimension(600, 600);
    Map<String, Point2D> map = new HashMap<String, Point2D>();
    Transformer<String, Point2D> vlf = TransformerUtils.mapTransformer(map);
    grid = this.generateVertexGrid(map, preferredSize, 25);
    gridLayout = new StaticLayout<String, Number>(grid, vlf, preferredSize);

    final VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>(
            graphLayout, preferredSize);
    vv = new VisualizationViewer<String, Number>(visualizationModel, preferredSize);

    PickedState<String> ps = vv.getPickedVertexState();
    PickedState<Number> pes = vv.getPickedEdgeState();
    vv.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow));
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.cyan));
    vv.setBackground(Color.white);

    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());

    final Transformer<String, Shape> ovals = vv.getRenderContext().getVertexShapeTransformer();
    final Transformer<String, Shape> squares = new ConstantTransformer(new Rectangle2D.Float(-10, -10, 20, 20));

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

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

    /**
     * the regular graph mouse for the normal view
     */
    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());

    hyperbolicViewSupport = new ViewLensSupport<String, Number>(vv,
            new HyperbolicShapeTransformer(vv,
                    vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)),
            new ModalLensGraphMouse());
    hyperbolicLayoutSupport = new LayoutLensSupport<String, Number>(vv,
            new HyperbolicTransformer(vv,
                    vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)),
            new ModalLensGraphMouse());
    magnifyViewSupport = new ViewLensSupport<String, Number>(vv,
            new MagnifyShapeTransformer(vv,
                    vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)),
            new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f)));
    magnifyLayoutSupport = new LayoutLensSupport<String, Number>(vv,
            new MagnifyTransformer(vv,
                    vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)),
            new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f)));
    hyperbolicLayoutSupport.getLensTransformer()
            .setLensShape(hyperbolicViewSupport.getLensTransformer().getLensShape());
    magnifyViewSupport.getLensTransformer()
            .setLensShape(hyperbolicLayoutSupport.getLensTransformer().getLensShape());
    magnifyLayoutSupport.getLensTransformer()
            .setLensShape(magnifyViewSupport.getLensTransformer().getLensShape());

    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());
        }
    });

    ButtonGroup radio = new ButtonGroup();
    JRadioButton normal = new JRadioButton("None");
    normal.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                if (hyperbolicViewSupport != null) {
                    hyperbolicViewSupport.deactivate();
                }
                if (hyperbolicLayoutSupport != null) {
                    hyperbolicLayoutSupport.deactivate();
                }
                if (magnifyViewSupport != null) {
                    magnifyViewSupport.deactivate();
                }
                if (magnifyLayoutSupport != null) {
                    magnifyLayoutSupport.deactivate();
                }
            }
        }
    });

    final JRadioButton hyperView = new JRadioButton("Hyperbolic View");
    hyperView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    final JRadioButton hyperModel = new JRadioButton("Hyperbolic Layout");
    hyperModel.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            hyperbolicLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    final JRadioButton magnifyView = new JRadioButton("Magnified View");
    magnifyView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            magnifyViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    final JRadioButton magnifyModel = new JRadioButton("Magnified Layout");
    magnifyModel.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            magnifyLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    JLabel modeLabel = new JLabel("     Mode Menu >>");
    modeLabel.setUI(new VerticalLabelUI(false));
    radio.add(normal);
    radio.add(hyperModel);
    radio.add(hyperView);
    radio.add(magnifyModel);
    radio.add(magnifyView);
    normal.setSelected(true);

    graphMouse.addItemListener(hyperbolicLayoutSupport.getGraphMouse().getModeListener());
    graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener());
    graphMouse.addItemListener(magnifyLayoutSupport.getGraphMouse().getModeListener());
    graphMouse.addItemListener(magnifyViewSupport.getGraphMouse().getModeListener());

    ButtonGroup graphRadio = new ButtonGroup();
    JRadioButton graphButton = new JRadioButton("Graph");
    graphButton.setSelected(true);
    graphButton.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                visualizationModel.setGraphLayout(graphLayout);
                vv.getRenderContext().setVertexShapeTransformer(ovals);
                vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
                vv.repaint();
            }
        }
    });
    JRadioButton gridButton = new JRadioButton("Grid");
    gridButton.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                visualizationModel.setGraphLayout(gridLayout);
                vv.getRenderContext().setVertexShapeTransformer(squares);
                vv.getRenderContext().setVertexLabelTransformer(new ConstantTransformer(null));
                vv.repaint();
            }
        }
    });
    graphRadio.add(graphButton);
    graphRadio.add(gridButton);

    JPanel modePanel = new JPanel(new GridLayout(3, 1));
    modePanel.setBorder(BorderFactory.createTitledBorder("Display"));
    modePanel.add(graphButton);
    modePanel.add(gridButton);

    JMenuBar menubar = new JMenuBar();
    menubar.add(graphMouse.getModeMenu());
    gzsp.setCorner(menubar);

    Box controls = Box.createHorizontalBox();
    JPanel zoomControls = new JPanel(new GridLayout(2, 1));
    zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom"));
    JPanel hyperControls = new JPanel(new GridLayout(3, 2));
    hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens"));
    zoomControls.add(plus);
    zoomControls.add(minus);

    hyperControls.add(normal);
    hyperControls.add(new JLabel());

    hyperControls.add(hyperModel);
    hyperControls.add(magnifyModel);

    hyperControls.add(hyperView);
    hyperControls.add(magnifyView);

    controls.add(zoomControls);
    controls.add(hyperControls);
    controls.add(modePanel);
    controls.add(modeLabel);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:net.sf.jclal.gui.view.components.chart.ExternalBasicChart.java

private JFreeChart createChart(XYDataset dataset, String title, String xTitle, String yTitle) {

    colors.add(Color.BLACK);//from w ww .j a v  a 2 s  .c  om
    colors.add(1, Color.BLUE);
    colors.add(1, Color.RED);
    colors.add(1, Color.GREEN);
    colors.add(1, Color.YELLOW);
    colors.add(1, Color.CYAN);
    colors.add(1, Color.MAGENTA);
    colors.add(1, new Color(111, 83, 64));
    colors.add(1, new Color(153, 51, 255));
    colors.add(1, new Color(102, 204, 255));
    colors.add(1, new Color(85, 80, 126));
    colors.add(1, new Color(168, 80, 126));

    chart = ChartFactory.createXYLineChart(title, xTitle, yTitle, dataset, PlotOrientation.VERTICAL, true, true,
            false);

    chart.setBackgroundPaint(Color.white);

    chart.getXYPlot().setBackgroundPaint(Color.white);
    chart.getXYPlot().setDomainGridlinePaint(Color.white);
    chart.getXYPlot().setRangeGridlinePaint(Color.white);

    int numSeries = series.getSeriesCount();

    XYLineAndShapeRenderer renderer = ((XYLineAndShapeRenderer) chart.getXYPlot().getRenderer());

    renderer.setDrawSeriesLineAsPath(true);

    renderer.setSeriesStroke(0, new BasicStroke(2.0F));

    renderer.setSeriesStroke(1,
            new BasicStroke(2.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f, new float[] { 2 }, 0));

    renderer.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f,
            new float[] { 6.0f, 2.0f, 6.0f, 2.0f }, 0.0f));

    renderer.setSeriesStroke(3, new BasicStroke(2.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f,
            new float[] { 12.0f, 2.0f, 2.0f, 2.0f }, 0.0f));

    renderer.setSeriesStroke(4, new BasicStroke(2.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f,
            new float[] { 12.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f }, 0.0f));

    renderer.setSeriesStroke(5, new BasicStroke(2.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f,
            new float[] { 12, 2, 12, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, 0));

    renderer.setSeriesStroke(6, new BasicStroke(2.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f,
            new float[] { 6.0f, 2.0f, 6.0f, 2.0f, 2.0f, 2.0f }, 0.0f));

    renderer.setSeriesStroke(7, new BasicStroke(2.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f,
            new float[] { 6.0f, 2.0f, 6.0f, 2.0f, 6.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f }, 0.0f));

    for (int i = 0; i < numSeries; i++) {

        if (i == colors.size()) {

            colors = addColors(colors, numSeries);

        }

        if (viewWithOutColor) {
            renderer.setSeriesPaint(i, Color.BLACK);
        } else {
            String name = series.getSeries(i).getKey().toString();

            if (!controlCurveColor.containsKey(name)) {
                renderer.setSeriesPaint(i, colors.get(i));
                controlCurveColor.put(name, colors.get(i));

            } else {

                renderer.setSeriesPaint(i, controlCurveColor.get(name));

            }

            renderer.setSeriesShapesVisible(i, viewPointsForm);

            if (viewWhiteBackground) {
                chart.getXYPlot().setBackgroundPaint(Color.WHITE);
            }
        }
    }
    chart.getXYPlot().setRenderer(renderer);

    return chart;
}

From source file:demos.MinimumSpanningTreeDemo.java

/**
 * create an instance of a simple graph in two views with controls to demo
 * the zoom features./*from ww w  . ja  va  2s  .com*/
 * 
 */
public MinimumSpanningTreeDemo() {

    // create a simple graph for the demo
    // both models will share one graph
    graph = TestGraphs.getDemoGraph();

    MinimumSpanningForest2<String, Number> prim = new MinimumSpanningForest2<String, Number>(graph,
            new DelegateForest<String, Number>(), DelegateTree.<String, Number>getFactory(),
            new ConstantTransformer(1.0));

    tree = prim.getForest();

    // create two layouts for the one graph, one layout for each model
    Layout<String, Number> layout0 = new KKLayout<String, Number>(graph);
    layout0.setSize(preferredLayoutSize);
    Layout<String, Number> layout1 = new TreeLayout<String, Number>(tree);
    Layout<String, Number> layout2 = new StaticLayout<String, Number>(graph, layout1);

    // create the two models, each with a different layout
    VisualizationModel<String, Number> vm0 = new DefaultVisualizationModel<String, Number>(layout0,
            preferredSize);
    VisualizationModel<String, Number> vm1 = new DefaultVisualizationModel<String, Number>(layout1,
            preferredSizeRect);
    VisualizationModel<String, Number> vm2 = new DefaultVisualizationModel<String, Number>(layout2,
            preferredSizeRect);

    // create the two views, one for each model
    // they share the same renderer
    vv0 = new VisualizationViewer<String, Number>(vm0, preferredSize);
    vv1 = new VisualizationViewer<String, Number>(vm1, preferredSizeRect);
    vv2 = new VisualizationViewer<String, Number>(vm2, preferredSizeRect);

    // vv1.setRenderContext(vv2.getRenderContext());

    vv1.getRenderContext().setMultiLayerTransformer(vv0.getRenderContext().getMultiLayerTransformer());
    vv2.getRenderContext().setMultiLayerTransformer(vv0.getRenderContext().getMultiLayerTransformer());

    vv1.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());

    vv0.addChangeListener(vv1);
    vv1.addChangeListener(vv2);

    vv0.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    vv2.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());

    Color back = Color.decode("0xffffbb");
    vv0.setBackground(back);
    vv1.setBackground(back);
    vv2.setBackground(back);

    vv0.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv0.setForeground(Color.darkGray);
    vv1.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv1.setForeground(Color.darkGray);
    vv2.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv2.setForeground(Color.darkGray);

    // share one PickedState between the two views
    PickedState<String> ps = new MultiPickedState<String>();
    vv0.setPickedVertexState(ps);
    vv1.setPickedVertexState(ps);
    vv2.setPickedVertexState(ps);

    PickedState<Number> pes = new MultiPickedState<Number>();
    vv0.setPickedEdgeState(pes);
    vv1.setPickedEdgeState(pes);
    vv2.setPickedEdgeState(pes);

    // set an edge paint function that will show picking for edges
    vv0.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv0.getPickedEdgeState(), Color.black, Color.red));
    vv0.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(vv0.getPickedVertexState(), Color.red, Color.yellow));
    vv1.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv1.getPickedEdgeState(), Color.black, Color.red));
    vv1.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(vv1.getPickedVertexState(), Color.red, Color.yellow));

    // add default listeners for ToolTips
    vv0.setVertexToolTipTransformer(new ToStringLabeller());
    vv1.setVertexToolTipTransformer(new ToStringLabeller());
    vv2.setVertexToolTipTransformer(new ToStringLabeller());

    vv0.setLayout(new BorderLayout());
    vv1.setLayout(new BorderLayout());
    vv2.setLayout(new BorderLayout());

    Font font = vv0.getFont().deriveFont(Font.BOLD, 16);
    JLabel vv0Label = new JLabel("<html>Original Graph<p>using KKLayout");
    vv0Label.setFont(font);
    JLabel vv1Label = new JLabel("Minimum Spanning Trees");
    vv1Label.setFont(font);
    JLabel vv2Label = new JLabel("Original Graph using TreeLayout");
    vv2Label.setFont(font);
    JPanel flow0 = new JPanel();
    flow0.setOpaque(false);
    JPanel flow1 = new JPanel();
    flow1.setOpaque(false);
    JPanel flow2 = new JPanel();
    flow2.setOpaque(false);
    flow0.add(vv0Label);
    flow1.add(vv1Label);
    flow2.add(vv2Label);
    vv0.add(flow0, BorderLayout.NORTH);
    vv1.add(flow1, BorderLayout.NORTH);
    vv2.add(flow2, BorderLayout.NORTH);

    // vv2.getRenderContext().setEdgeDrawPaintTransformer(new
    // Transformer<Number,Paint>() {
    //
    // public Paint transform(Number e) {
    // if(tree.getEdges().contains(e) == false) return Color.lightGray;
    // return Color.black;
    // }});

    Container content = getContentPane();
    JPanel grid = new JPanel(new GridLayout(0, 1));
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(new GraphZoomScrollPane(vv0), BorderLayout.WEST);
    grid.add(new GraphZoomScrollPane(vv1));
    grid.add(new GraphZoomScrollPane(vv2));
    // panel.add(new GraphZoomScrollPane(vv3), BorderLayout.EAST);
    panel.add(grid);

    content.add(panel);

    // create a GraphMouse for each view
    DefaultModalGraphMouse gm0 = new DefaultModalGraphMouse();
    DefaultModalGraphMouse gm1 = new DefaultModalGraphMouse();
    DefaultModalGraphMouse gm2 = new DefaultModalGraphMouse();
    DefaultModalGraphMouse gm3 = new DefaultModalGraphMouse();

    vv0.setGraphMouse(gm0);
    vv1.setGraphMouse(gm1);
    vv2.setGraphMouse(gm2);
    // vv3.setGraphMouse(gm3);

    // create zoom buttons for scaling the transformer that is
    // shared between the two models.
    final ScalingControl scaler = new CrossoverScalingControl();

    vv0.scaleToLayout(scaler);
    vv1.scaleToLayout(scaler);
    vv2.scaleToLayout(scaler);
    // vv3.scaleToLayout(scaler);

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

    JPanel zoomPanel = new JPanel(new GridLayout(1, 2));
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom"));

    JPanel modePanel = new JPanel();
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    gm1.getModeComboBox().addItemListener(gm2.getModeListener());
    gm1.getModeComboBox().addItemListener(gm0.getModeListener());
    gm1.getModeComboBox().addItemListener(gm3.getModeListener());
    modePanel.add(gm1.getModeComboBox());

    JPanel controls = new JPanel();
    zoomPanel.add(plus);
    zoomPanel.add(minus);
    controls.add(zoomPanel);
    controls.add(modePanel);
    content.add(controls, BorderLayout.SOUTH);
}

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

/**
 * create an instance of a simple graph in two views with controls to
 * demo the zoom features.//from  w  w  w .j  a v a  2  s.  co m
 * 
 */
public MinimumSpanningTreeDemo() {

    // create a simple graph for the demo
    // both models will share one graph
    graph = TestGraphs.getDemoGraph();

    MinimumSpanningForest2<String, Number> prim = new MinimumSpanningForest2<String, Number>(graph,
            new DelegateForest<String, Number>(), DelegateTree.<String, Number>getFactory(),
            new ConstantTransformer(1.0));

    tree = prim.getForest();

    // create two layouts for the one graph, one layout for each model
    Layout<String, Number> layout0 = new KKLayout<String, Number>(graph);
    layout0.setSize(preferredLayoutSize);
    Layout<String, Number> layout1 = new TreeLayout<String, Number>(tree);
    Layout<String, Number> layout2 = new StaticLayout<String, Number>(graph, layout1);

    // create the two models, each with a different layout
    VisualizationModel<String, Number> vm0 = new DefaultVisualizationModel<String, Number>(layout0,
            preferredSize);
    VisualizationModel<String, Number> vm1 = new DefaultVisualizationModel<String, Number>(layout1,
            preferredSizeRect);
    VisualizationModel<String, Number> vm2 = new DefaultVisualizationModel<String, Number>(layout2,
            preferredSizeRect);

    // create the two views, one for each model
    // they share the same renderer
    vv0 = new VisualizationViewer<String, Number>(vm0, preferredSize);
    vv1 = new VisualizationViewer<String, Number>(vm1, preferredSizeRect);
    vv2 = new VisualizationViewer<String, Number>(vm2, preferredSizeRect);

    //        vv1.setRenderContext(vv2.getRenderContext());

    vv1.getRenderContext().setMultiLayerTransformer(vv0.getRenderContext().getMultiLayerTransformer());
    vv2.getRenderContext().setMultiLayerTransformer(vv0.getRenderContext().getMultiLayerTransformer());

    vv1.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());

    vv0.addChangeListener(vv1);
    vv1.addChangeListener(vv2);

    vv0.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    vv2.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());

    Color back = Color.decode("0xffffbb");
    vv0.setBackground(back);
    vv1.setBackground(back);
    vv2.setBackground(back);

    vv0.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv0.setForeground(Color.darkGray);
    vv1.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv1.setForeground(Color.darkGray);
    vv2.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv2.setForeground(Color.darkGray);

    // share one PickedState between the two views
    PickedState<String> ps = new MultiPickedState<String>();
    vv0.setPickedVertexState(ps);
    vv1.setPickedVertexState(ps);
    vv2.setPickedVertexState(ps);

    PickedState<Number> pes = new MultiPickedState<Number>();
    vv0.setPickedEdgeState(pes);
    vv1.setPickedEdgeState(pes);
    vv2.setPickedEdgeState(pes);

    // set an edge paint function that will show picking for edges
    vv0.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv0.getPickedEdgeState(), Color.black, Color.red));
    vv0.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(vv0.getPickedVertexState(), Color.red, Color.yellow));
    vv1.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv1.getPickedEdgeState(), Color.black, Color.red));
    vv1.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(vv1.getPickedVertexState(), Color.red, Color.yellow));

    // add default listeners for ToolTips
    vv0.setVertexToolTipTransformer(new ToStringLabeller());
    vv1.setVertexToolTipTransformer(new ToStringLabeller());
    vv2.setVertexToolTipTransformer(new ToStringLabeller());

    vv0.setLayout(new BorderLayout());
    vv1.setLayout(new BorderLayout());
    vv2.setLayout(new BorderLayout());

    Font font = vv0.getFont().deriveFont(Font.BOLD, 16);
    JLabel vv0Label = new JLabel("<html>Original Graph<p>using KKLayout");
    vv0Label.setFont(font);
    JLabel vv1Label = new JLabel("Minimum Spanning Trees");
    vv1Label.setFont(font);
    JLabel vv2Label = new JLabel("Original Graph using TreeLayout");
    vv2Label.setFont(font);
    JPanel flow0 = new JPanel();
    flow0.setOpaque(false);
    JPanel flow1 = new JPanel();
    flow1.setOpaque(false);
    JPanel flow2 = new JPanel();
    flow2.setOpaque(false);
    flow0.add(vv0Label);
    flow1.add(vv1Label);
    flow2.add(vv2Label);
    vv0.add(flow0, BorderLayout.NORTH);
    vv1.add(flow1, BorderLayout.NORTH);
    vv2.add(flow2, BorderLayout.NORTH);

    //        vv2.getRenderContext().setEdgeDrawPaintTransformer(new Transformer<Number,Paint>() {
    //
    //         public Paint transform(Number e) {
    //            if(tree.getEdges().contains(e) == false) return Color.lightGray;
    //            return Color.black;
    //         }});

    Container content = getContentPane();
    JPanel grid = new JPanel(new GridLayout(0, 1));
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(new GraphZoomScrollPane(vv0), BorderLayout.WEST);
    grid.add(new GraphZoomScrollPane(vv1));
    grid.add(new GraphZoomScrollPane(vv2));
    //        panel.add(new GraphZoomScrollPane(vv3), BorderLayout.EAST);
    panel.add(grid);

    content.add(panel);

    // create a GraphMouse for each view
    DefaultModalGraphMouse gm0 = new DefaultModalGraphMouse();
    DefaultModalGraphMouse gm1 = new DefaultModalGraphMouse();
    DefaultModalGraphMouse gm2 = new DefaultModalGraphMouse();
    DefaultModalGraphMouse gm3 = new DefaultModalGraphMouse();

    vv0.setGraphMouse(gm0);
    vv1.setGraphMouse(gm1);
    vv2.setGraphMouse(gm2);
    //        vv3.setGraphMouse(gm3);

    // create zoom buttons for scaling the transformer that is
    // shared between the two models.
    final ScalingControl scaler = new CrossoverScalingControl();

    vv0.scaleToLayout(scaler);
    vv1.scaleToLayout(scaler);
    vv2.scaleToLayout(scaler);
    //        vv3.scaleToLayout(scaler);

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

    JPanel zoomPanel = new JPanel(new GridLayout(1, 2));
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom"));

    JPanel modePanel = new JPanel();
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    gm1.getModeComboBox().addItemListener(gm2.getModeListener());
    gm1.getModeComboBox().addItemListener(gm0.getModeListener());
    gm1.getModeComboBox().addItemListener(gm3.getModeListener());
    modePanel.add(gm1.getModeComboBox());

    JPanel controls = new JPanel();
    zoomPanel.add(plus);
    zoomPanel.add(minus);
    controls.add(zoomPanel);
    controls.add(modePanel);
    content.add(controls, BorderLayout.SOUTH);
}

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

/**
 * create an instance of a simple graph in two views with controls to
 * demo the zoom features.//from w  ww . j  a v  a  2  s  .  c  om
 * 
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public MinimumSpanningTreeDemo() {

    // create a simple graph for the demo
    // both models will share one graph
    graph = TestGraphs.getDemoGraph();

    MinimumSpanningForest2<String, Number> prim = new MinimumSpanningForest2<String, Number>(graph,
            new DelegateForest<String, Number>(), DelegateTree.<String, Number>getFactory(),
            new ConstantTransformer(1.0));

    tree = prim.getForest();

    // create two layouts for the one graph, one layout for each model
    Layout<String, Number> layout0 = new KKLayout<String, Number>(graph);
    layout0.setSize(preferredLayoutSize);
    Layout<String, Number> layout1 = new TreeLayout<String, Number>(tree);
    Layout<String, Number> layout2 = new StaticLayout<String, Number>(graph, layout1);

    // create the two models, each with a different layout
    VisualizationModel<String, Number> vm0 = new DefaultVisualizationModel<String, Number>(layout0,
            preferredSize);
    VisualizationModel<String, Number> vm1 = new DefaultVisualizationModel<String, Number>(layout1,
            preferredSizeRect);
    VisualizationModel<String, Number> vm2 = new DefaultVisualizationModel<String, Number>(layout2,
            preferredSizeRect);

    // create the two views, one for each model
    // they share the same renderer
    vv0 = new VisualizationViewer<String, Number>(vm0, preferredSize);
    vv1 = new VisualizationViewer<String, Number>(vm1, preferredSizeRect);
    vv2 = new VisualizationViewer<String, Number>(vm2, preferredSizeRect);

    //        vv1.setRenderContext(vv2.getRenderContext());

    vv1.getRenderContext().setMultiLayerTransformer(vv0.getRenderContext().getMultiLayerTransformer());
    vv2.getRenderContext().setMultiLayerTransformer(vv0.getRenderContext().getMultiLayerTransformer());

    vv1.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());

    vv0.addChangeListener(vv1);
    vv1.addChangeListener(vv2);

    vv0.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    vv2.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());

    Color back = Color.decode("0xffffbb");
    vv0.setBackground(back);
    vv1.setBackground(back);
    vv2.setBackground(back);

    vv0.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv0.setForeground(Color.darkGray);
    vv1.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv1.setForeground(Color.darkGray);
    vv2.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv2.setForeground(Color.darkGray);

    // share one PickedState between the two views
    PickedState<String> ps = new MultiPickedState<String>();
    vv0.setPickedVertexState(ps);
    vv1.setPickedVertexState(ps);
    vv2.setPickedVertexState(ps);

    PickedState<Number> pes = new MultiPickedState<Number>();
    vv0.setPickedEdgeState(pes);
    vv1.setPickedEdgeState(pes);
    vv2.setPickedEdgeState(pes);

    // set an edge paint function that will show picking for edges
    vv0.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv0.getPickedEdgeState(), Color.black, Color.red));
    vv0.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(vv0.getPickedVertexState(), Color.red, Color.yellow));
    vv1.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv1.getPickedEdgeState(), Color.black, Color.red));
    vv1.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(vv1.getPickedVertexState(), Color.red, Color.yellow));

    // add default listeners for ToolTips
    vv0.setVertexToolTipTransformer(new ToStringLabeller());
    vv1.setVertexToolTipTransformer(new ToStringLabeller());
    vv2.setVertexToolTipTransformer(new ToStringLabeller());

    vv0.setLayout(new BorderLayout());
    vv1.setLayout(new BorderLayout());
    vv2.setLayout(new BorderLayout());

    Font font = vv0.getFont().deriveFont(Font.BOLD, 16);
    JLabel vv0Label = new JLabel("<html>Original Graph<p>using KKLayout");
    vv0Label.setFont(font);
    JLabel vv1Label = new JLabel("Minimum Spanning Trees");
    vv1Label.setFont(font);
    JLabel vv2Label = new JLabel("Original Graph using TreeLayout");
    vv2Label.setFont(font);
    JPanel flow0 = new JPanel();
    flow0.setOpaque(false);
    JPanel flow1 = new JPanel();
    flow1.setOpaque(false);
    JPanel flow2 = new JPanel();
    flow2.setOpaque(false);
    flow0.add(vv0Label);
    flow1.add(vv1Label);
    flow2.add(vv2Label);
    vv0.add(flow0, BorderLayout.NORTH);
    vv1.add(flow1, BorderLayout.NORTH);
    vv2.add(flow2, BorderLayout.NORTH);

    //        vv2.getRenderContext().setEdgeDrawPaintTransformer(new Transformer<Number,Paint>() {
    //
    //         public Paint transform(Number e) {
    //            if(tree.getEdges().contains(e) == false) return Color.lightGray;
    //            return Color.black;
    //         }});

    Container content = getContentPane();
    JPanel grid = new JPanel(new GridLayout(0, 1));
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(new GraphZoomScrollPane(vv0), BorderLayout.WEST);
    grid.add(new GraphZoomScrollPane(vv1));
    grid.add(new GraphZoomScrollPane(vv2));
    //        panel.add(new GraphZoomScrollPane(vv3), BorderLayout.EAST);
    panel.add(grid);

    content.add(panel);

    // create a GraphMouse for each view
    DefaultModalGraphMouse gm0 = new DefaultModalGraphMouse();
    DefaultModalGraphMouse gm1 = new DefaultModalGraphMouse();
    DefaultModalGraphMouse gm2 = new DefaultModalGraphMouse();
    DefaultModalGraphMouse gm3 = new DefaultModalGraphMouse();

    vv0.setGraphMouse(gm0);
    vv1.setGraphMouse(gm1);
    vv2.setGraphMouse(gm2);
    //        vv3.setGraphMouse(gm3);

    // create zoom buttons for scaling the transformer that is
    // shared between the two models.
    final ScalingControl scaler = new CrossoverScalingControl();

    vv0.scaleToLayout(scaler);
    vv1.scaleToLayout(scaler);
    vv2.scaleToLayout(scaler);
    //        vv3.scaleToLayout(scaler);

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

    JPanel zoomPanel = new JPanel(new GridLayout(1, 2));
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom"));

    JPanel modePanel = new JPanel();
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    gm1.getModeComboBox().addItemListener(gm2.getModeListener());
    gm1.getModeComboBox().addItemListener(gm0.getModeListener());
    gm1.getModeComboBox().addItemListener(gm3.getModeListener());
    modePanel.add(gm1.getModeComboBox());

    JPanel controls = new JPanel();
    zoomPanel.add(plus);
    zoomPanel.add(minus);
    controls.add(zoomPanel);
    controls.add(modePanel);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:org.zaproxy.zap.extension.customFire.ScanProgressDialog.java

/**
 * //from w  w w.j a va2s.c  om
 */
private void initialize() {
    this.setSize(new Dimension(580, 504));

    if (site != null) {

        this.setTitle("Scann Progress");

    }

    JTabbedPane tabbedPane = new JTabbedPane();
    JPanel tab1 = new JPanel();
    tab1.setLayout(new GridBagLayout());

    JPanel hostPanel = new JPanel();

    hostPanel.setLayout(new GridBagLayout());

    hostPanel.add(new JLabel("Host:"), LayoutHelper.getGBC(0, 0, 1, 0.4D));

    hostPanel.add(getHostSelect(), LayoutHelper.getGBC(1, 0, 1, 0.6D));

    tab1.add(hostPanel, LayoutHelper.getGBC(0, 0, 3, 1.0D, 0.0D));

    tab1.add(getJScrollPane(), LayoutHelper.getGBC(0, 1, 3, 1.0D, 1.0D));//*

    tab1.add(new JLabel(), LayoutHelper.getGBC(0, 1, 1, 1.0D, 0.0D)); // spacer
    tab1.add(getCloseButton(), LayoutHelper.getGBC(1, 2, 1, 0.0D, 0.0D));

    tab1.add(new JLabel(), LayoutHelper.getGBC(2, 1, 1, 1.0D, 0.0D)); // spacer

    tabbedPane.insertTab("Progress", null, tab1, null, 0);
    this.add(tabbedPane);

    int mins = extension.getScannerParam().getMaxChartTimeInMins();
    if (mins > 0) {
        // Treat zero mins as disabled

        JPanel tab2 = new JPanel();

        tab2.setLayout(new GridBagLayout());

        this.seriesTotal = new TimeSeries("TotalResponses"); // Name not shown, so no need to i18n
        final TimeSeriesCollection dataset = new TimeSeriesCollection(this.seriesTotal);

        this.series100 = new TimeSeries("1xx");
        this.series200 = new TimeSeries("2xx");
        this.series300 = new TimeSeries("3xx");
        this.series400 = new TimeSeries("4xx");
        this.series500 = new TimeSeries("5xx");

        this.seriesTotal.setMaximumItemAge(mins * 60);
        this.series100.setMaximumItemAge(mins * 60);
        this.series200.setMaximumItemAge(mins * 60);
        this.series300.setMaximumItemAge(mins * 60);
        this.series400.setMaximumItemAge(mins * 60);
        this.series500.setMaximumItemAge(mins * 60);

        dataset.addSeries(series100);
        dataset.addSeries(series200);
        dataset.addSeries(series300);
        dataset.addSeries(series400);
        dataset.addSeries(series500);

        chart = createChart(dataset);//*

        // Set up some vaguesly sensible colours
        chart.getXYPlot().getRenderer(0).setSeriesPaint(0, Color.BLACK); // Totals
        chart.getXYPlot().getRenderer(0).setSeriesPaint(1, Color.ORANGE); // 100: Info
        chart.getXYPlot().getRenderer(0).setSeriesPaint(2, Color.GREEN); // 200: OK
        chart.getXYPlot().getRenderer(0).setSeriesPaint(3, Color.BLUE); // 300: Info
        chart.getXYPlot().getRenderer(0).setSeriesPaint(4, Color.YELLOW); // 400: Bad req
        chart.getXYPlot().getRenderer(0).setSeriesPaint(5, Color.RED); // 500: Internal error

        chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(5.0f)); // Totals
        chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(3.0f)); // 100: Info
        chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(3.0f)); // 200: OK
        chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(3.0f)); // 300: Info
        chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(3.0f)); // 400: Bad req
        chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(3.0f)); // 500: Internal error

        final ChartPanel chartPanel = new ChartPanel(chart);

        tab2.add(chartPanel, LayoutHelper.getGBC(0, 0, 1, 1.0D, 1.0D));

        tabbedPane.insertTab("ResponseCharts", null, tab2, null, 1);

    }

    // Stop the updating thread when the window is closed
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {
            stopThread = true;
        }
    });

}

From source file:no.uio.medicine.virsurveillance.charts.StackedChart_AWT.java

private Color getColor(int index) {
    int index2 = index + this.colorOffset;
    switch (index2) {
    case 0://from   www. j  ava 2  s .  c om
        return Color.RED;
    case 1:
        return Color.BLUE;
    case 2:
        return Color.GREEN;
    case 3:
        return Color.YELLOW;
    case 4:
        return Color.DARK_GRAY;
    case 5:
        return Color.ORANGE;
    case 6:
        return Color.BLACK;
    case 7:
        return Color.CYAN;
    case 8:
        return Color.GRAY;
    case 9:
        return Color.LIGHT_GRAY;
    case 10:
        return Color.MAGENTA;
    case 11:
        return Color.PINK;
    case 12:
        return Color.WHITE;
    default:
        return getColor((int) Math.floor(Math.random() * 14));
    }

}