Example usage for java.awt Color decode

List of usage examples for java.awt Color decode

Introduction

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

Prototype

public static Color decode(String nm) throws NumberFormatException 

Source Link

Document

Converts a String to an integer and returns the specified opaque Color .

Usage

From source file:demos.MinimumSpanningTreeDemo.java

/**
 * create an instance of a simple graph in two views with controls to demo
 * the zoom features.//www . ja va 2  s  .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:io.github.tavernaextras.biocatalogue.ui.search_results.ServiceListCellRenderer.java

/**
 * //  w  w w  .j av  a2s  . c  o m
 * @param itemToRender
 * @param expandedView <code>true</code> to indicate that this method generates the top
 *                     fragment of the expanded list entry for this SOAP operation / REST method.
 * @return
 */
protected GridBagConstraints prepareLoadedEntry(Object itemToRender, boolean selected) {
    TYPE resourceType = determineResourceType(itemToRender);
    Service service = (Service) itemToRender;
    ;

    // service type
    if (service.getServiceTechnologyTypes() != null
            && service.getServiceTechnologyTypes().getTypeList().size() > 0) {
        if (service.getServiceTechnologyTypes().getTypeList().size() > 1
                && !(service.getServiceTechnologyTypes().getTypeList().get(0).toString()
                        .equalsIgnoreCase("SOAP"))
                && service.getServiceTechnologyTypes().getTypeList().get(1).toString()
                        .equalsIgnoreCase("SOAPLAB")) {
            jlTypeIcon = new JLabel(ResourceManager.getImageIcon(ResourceManager.SERVICE_TYPE_MULTITYPE_ICON));
        } else if (service.getServiceTechnologyTypes().getTypeArray(0).toString().equalsIgnoreCase("SOAP")) {
            jlTypeIcon = new JLabel(ResourceManager.getImageIcon(ResourceManager.SERVICE_TYPE_SOAP_ICON));
        } else if (service.getServiceTechnologyTypes().getTypeArray(0).toString().equalsIgnoreCase("REST")) {
            jlTypeIcon = new JLabel(ResourceManager.getImageIcon(ResourceManager.SERVICE_TYPE_REST_ICON));
        }
    } else {
        // can't tell the type - just show as a service of no particular type
        jlTypeIcon = new JLabel(resourceType.getIcon());
    }

    // service status
    jlItemStatus = new JLabel(ServiceMonitoringStatusInterpreter.getStatusIcon(service, true));

    jlItemTitle = new JLabel(Resource.getDisplayNameForResource(service), JLabel.LEFT);
    jlItemTitle.setForeground(Color.decode("#AD0000")); // very dark red
    jlItemTitle.setFont(jlItemTitle.getFont().deriveFont(Font.PLAIN, jlItemTitle.getFont().getSize() + 2));

    int descriptionMaxLength = DESCRIPTION_MAX_LENGTH_EXPANDED;
    String strDescription = Util.stripAllHTML(service.getDescription());
    strDescription = (strDescription == null || strDescription.length() == 0
            ? "<font color=\"gray\">no description</font>"
            : StringEscapeUtils
                    .escapeHtml(Util.ensureLineLengthWithinString(strDescription, LINE_LENGTH, false)));

    if (strDescription.length() > descriptionMaxLength) {
        strDescription = strDescription.substring(0, descriptionMaxLength)
                + "<font color=\"gray\">(...)</font>";
    }
    strDescription = "<html><b>Description: </b>" + strDescription + "</html>";
    jlDescription = new JLabel(strDescription);

    return (arrangeLayout(true));
}

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  www.j  a va  2 s  . c  o 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  2s  .c o  m*/
 * 
 */
@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:gda.gui.beans.SimpleBinaryBean.java

@Override
public void run() {
    synchronized (this) {
        try {/*from  w  ww .j  av a2 s .c o m*/
            String currentPosition = (String) simpleBinary.getPosition();
            String[] positions = simpleBinary.getPositions();
            if (positions.length > 0 && currentPosition.equals(positions[0])) {
                this.lblState.setForeground(Color.RED);
            } else {
                this.lblState.setForeground(Color.decode("#228B22")); // nicegreen
            }
            this.lblState.setText(currentPosition);
        } catch (DeviceException e) {
            logger.error("Exception while trying to observe " + simpleBinaryName + ": " + e.getMessage());
        } finally {
            updateLock = false;
        }
    }
}

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

/**
 * create an instance of a simple graph with controls to
 * demo the zoom features./*from   w  ww.ja v a  2 s .co m*/
 * 
 */
@SuppressWarnings("serial")
public PerspectiveVertexImageShaperDemo() {

    // 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(PerspectiveVertexImageShaperDemo.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);

    final VertexStringerImpl<Number> vertexStringerImpl = new VertexStringerImpl<Number>(map);

    final VertexIconShapeTransformer<Number> vertexImageShapeFunction = new VertexIconShapeTransformer<Number>(
            new EllipseVertexShapeTransformer<Number>());

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

    vv.setBackground(Color.decode("0xffffdd"));
    final DefaultVertexIconTransformer<Number> vertexIconFunction = new DefaultVertexIconTransformer<Number>();
    vertexImageShapeFunction.setIconMap(iconMap);
    vertexIconFunction.setIconMap(iconMap);
    vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction);
    vv.getRenderContext().setVertexIconTransformer(vertexIconFunction);
    vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl);
    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);

    this.viewSupport = new PerspectiveImageLensSupport<Number, Number>(vv);
    this.layoutSupport = new PerspectiveLayoutTransformSupport<Number, Number>(vv);

    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, 0.9f, vv.getCenter());
        }
    });
    final JSlider horizontalSlider = new JSlider(-120, 120, 0) {

        /* (non-Javadoc)
         * @see javax.swing.JComponent#getPreferredSize()
         */
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(80, super.getPreferredSize().height);
        }
    };

    final JSlider verticalSlider = new JSlider(-120, 120, 0) {

        /* (non-Javadoc)
         * @see javax.swing.JComponent#getPreferredSize()
         */
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(super.getPreferredSize().width, 80);
        }
    };
    verticalSlider.setOrientation(JSlider.VERTICAL);
    final ChangeListener changeListener = new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            int vval = -verticalSlider.getValue();
            int hval = horizontalSlider.getValue();

            Dimension d = vv.getSize();
            PerspectiveTransform pt = null;
            pt = PerspectiveTransform.getQuadToQuad(vval, hval, d.width - vval, -hval, d.width + vval,
                    d.height + hval, -vval, d.height - hval,

                    0, 0, d.width, 0, d.width, d.height, 0, d.height);

            viewSupport.getPerspectiveTransformer().setPerspectiveTransform(pt);
            layoutSupport.getPerspectiveTransformer().setPerspectiveTransform(pt);
            vv.repaint();
        }
    };
    horizontalSlider.addChangeListener(changeListener);
    verticalSlider.addChangeListener(changeListener);

    JPanel perspectivePanel = new JPanel(new BorderLayout());
    JPanel perspectiveCenterPanel = new JPanel(new BorderLayout());
    perspectivePanel.setBorder(BorderFactory.createTitledBorder("Perspective Controls"));
    final JButton center = new JButton("Center");
    center.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            horizontalSlider.setValue(0);
            verticalSlider.setValue(0);
        }
    });

    final JCheckBox noText = new JCheckBox("No Text");
    noText.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            JCheckBox cb = (JCheckBox) e.getSource();
            vertexStringerImpl.setEnabled(!cb.isSelected());
            vv.repaint();
        }
    });
    JPanel centerPanel = new JPanel();
    centerPanel.add(noText);

    ButtonGroup radio = new ButtonGroup();
    JRadioButton none = new JRadioButton("None");
    none.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            boolean selected = e.getStateChange() == ItemEvent.SELECTED;
            if (selected) {
                if (viewSupport != null) {
                    viewSupport.deactivate();
                }
                if (layoutSupport != null) {
                    layoutSupport.deactivate();
                }
            }
            center.setEnabled(!selected);
            horizontalSlider.setEnabled(!selected);
            verticalSlider.setEnabled(!selected);
        }
    });
    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) {
            layoutSupport.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);

    panel.setCorner(menubar);

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

    JPanel lensPanel = new JPanel(new GridLayout(2, 0));
    lensPanel.add(none);
    lensPanel.add(hyperView);
    lensPanel.add(hyperModel);

    perspectivePanel.add(lensPanel, BorderLayout.WEST);
    perspectiveCenterPanel.add(horizontalSlider, BorderLayout.SOUTH);
    perspectivePanel.add(verticalSlider, BorderLayout.EAST);
    perspectiveCenterPanel.add(center);
    perspectivePanel.add(perspectiveCenterPanel);
    controls.add(perspectivePanel, BorderLayout.EAST);

    controls.add(centerPanel);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:org.apache.myfaces.custom.roundeddiv.HtmlRoundedDivRenderer.java

protected RoundedBorderGenerator buildGenerator(HttpServletRequest request) {
    RoundedBorderGenerator borderGen;/*from  www .  j a v a  2 s  .  com*/
    String param;
    Color foregroundColor = Color.decode("#" + request.getParameter("c"));

    Dimension size = null;
    if ((param = request.getParameter("s")) != null) {
        int i = param.indexOf('x');
        size = new Dimension(Integer.parseInt(param.substring(0, i)), Integer.parseInt(param.substring(i + 1)));
    }

    Color backgroundColor = null, borderColor = null;
    if ((param = request.getParameter("bgc")) != null) {
        backgroundColor = Color.decode("#" + param);
    }
    if ((param = request.getParameter("bc")) != null) {
        borderColor = Color.decode("#" + param);
    }

    int borderWidth = Integer.parseInt(request.getParameter("bw"));
    int radius = Integer.parseInt(request.getParameter("r"));

    boolean inverse = "t".equals(request.getParameter("i"));

    borderGen = new RoundedBorderGenerator(borderColor, borderWidth, radius, foregroundColor, backgroundColor,
            size, inverse);
    return borderGen;
}

From source file:es.emergya.ui.gis.MapViewer.java

/**
 * Preferred constructor./* www .  j  a  v  a 2  s  . c o  m*/
 * 
 * @param title
 *            of the tab
 * @param type
 *            of plugin
 * @param order
 *            of tab
 * @param icon
 *            of tab
 * @param layers
 *            to be included on the mapView
 */
public MapViewer(String title, PluginType type, int order, String icon, List<MarkerLayer> layers) {
    setTitle(title);
    this.type = type;
    this.order = order;
    this.tip = title;

    if (icon != null)
        this.icon = LogicConstants.getIcon(icon);

    BorderLayout b = new BorderLayout();
    b.setVgap(10);
    b.setHgap(10);

    this.setLayout(b);

    // super.tab = content;
    // if (content != null)
    // this.add(content, BorderLayout.CENTER);
    ((BorderLayout) getLayout()).setHgap(0);
    ((BorderLayout) getLayout()).setVgap(0);
    Main.platform = Main.getPlatformHook();
    Main.platform.preStartupHook();
    Main.pref.init(true);
    Main.pref.putColor(marktr("scale"), Color.decode("#007f7f"));
    Main.pref.put("wmsplugin.alpha_channel", true);
    Main.preConstructorInit(new HashMap<String, Collection<String>>());
    new Main() {
    };

    for (MarkerLayer layer : layers) {
        this.mapView.addLayer(layer);
        layer.setMapView((MapView) this.mapView);
    }
}

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  ww  w.  j a  v a  2 s  .  co m
 */
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;
}

From source file:org.bitstrings.maven.plugins.splasher.DrawingUtil.java

public static Color decodeColor(String colorStr) throws IllegalArgumentException {
    Color color = COLOR_MAP.get(colorStr);

    if (color == null) {
        try {/*  w w  w .j  a v  a  2  s  . c o  m*/
            color = Color.decode(colorStr);
        } catch (NumberFormatException e) {
            try {
                int[] rgb = decodeExpressions(colorStr, 3);

                color = new Color(rgb[0], rgb[1], rgb[2]);
            } catch (IllegalArgumentException e2) {
                throw new IllegalArgumentException("Unable to decode color " + colorStr, e);
            }
        }
    }

    return color;
}