Example usage for javax.swing BorderFactory createEtchedBorder

List of usage examples for javax.swing BorderFactory createEtchedBorder

Introduction

In this page you can find the example usage for javax.swing BorderFactory createEtchedBorder.

Prototype

public static Border createEtchedBorder() 

Source Link

Document

Creates a border with an "etched" look using the component's current background color for highlighting and shading.

Usage

From source file:org.apache.jmeter.visualizers.StatGraphVisualizer.java

private JPanel createGraphDimensionPane() {
    JPanel dimensionPane = new JPanel();
    dimensionPane.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    dimensionPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            JMeterUtils.getResString("aggregate_graph_dimension"))); // $NON-NLS-1$

    dimensionPane.add(dynamicGraphSize);
    dynamicGraphSize.setSelected(true); // default option
    graphWidth.setEnabled(false);//from  ww  w .  j  a va  2 s .c  o  m
    graphHeight.setEnabled(false);
    dynamicGraphSize.addActionListener(this);
    dimensionPane.add(Box.createRigidArea(new Dimension(10, 0)));
    dimensionPane.add(graphWidth);
    dimensionPane.add(Box.createRigidArea(new Dimension(5, 0)));
    dimensionPane.add(graphHeight);
    return dimensionPane;
}

From source file:org.apache.jmeter.visualizers.StatGraphVisualizer.java

/**
 * Create pane for X Axis options//  w  ww  .  ja v  a 2s .c o  m
 * @return X Axis pane
 */
private JPanel createGraphXAxisPane() {
    JPanel xAxisPane = new JPanel();
    xAxisPane.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    xAxisPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            JMeterUtils.getResString("aggregate_graph_xaxis_group"))); // $NON-NLS-1$
    xAxisPane.add(maxLengthXAxisLabel);
    return xAxisPane;
}

From source file:org.apache.jmeter.visualizers.StatGraphVisualizer.java

/**
 * Create pane for Y Axis options/*w  w w.  ja v a  2s  . co  m*/
 * @return Y Axis pane
 */
private JPanel createGraphYAxisPane() {
    JPanel yAxisPane = new JPanel();
    yAxisPane.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    yAxisPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            JMeterUtils.getResString("aggregate_graph_yaxis_group"))); // $NON-NLS-1$
    yAxisPane.add(maxValueYAxisLabel);
    return yAxisPane;
}

From source file:org.apache.jmeter.visualizers.StatGraphVisualizer.java

/**
 * Create pane for legend settings/*from   w  w w. ja  v  a 2 s  . c o  m*/
 * @return Legend pane
 */
private JPanel createLegendPane() {
    JPanel legendPanel = new JPanel();
    legendPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    legendPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            JMeterUtils.getResString("aggregate_graph_legend"))); // $NON-NLS-1$

    legendPanel.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_legend_placement"), //$NON-NLS-1$
            legendPlacementList));
    legendPlacementList.setSelectedItem(JMeterUtils.getResString("aggregate_graph_legend.placement.bottom")); // $NON-NLS-1$ // default: bottom
    legendPanel.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_font"), //$NON-NLS-1$
            fontNameList));
    fontNameList.setSelectedIndex(0); // default: sans serif
    legendPanel.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_size"), //$NON-NLS-1$
            fontSizeList));
    fontSizeList.setSelectedItem(StatGraphProperties.fontSize[2]); // default: 10
    legendPanel.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_style"), //$NON-NLS-1$
            fontStyleList));
    fontStyleList.setSelectedItem(JMeterUtils.getResString("fontstyle.normal")); // $NON-NLS-1$ // default: normal

    return legendPanel;
}

From source file:org.datanucleus.ide.idea.ui.v10x.DNEConfigFormV10x.java

/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL/*from   w w  w  .ja  v  a 2  s.  c  om*/
 */
private void $$$setupUI$$$() {
    createUIComponents();
    configPanel = new JPanel();
    configPanel.setLayout(new GridLayoutManager(5, 3, new Insets(0, 0, 0, 0), -1, -1));
    enableEnhancerCheckBox = new JCheckBox();
    enableEnhancerCheckBox.setText("Enable Enhancer");
    configPanel.add(enableEnhancerCheckBox,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final JPanel panel1 = new JPanel();
    panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
    configPanel.add(panel1,
            new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null,
                    null, 0, false));
    jDORadioButton = new JRadioButton();
    jDORadioButton.setText("JDO");
    panel1.add(jDORadioButton,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    jPARadioButton = new JRadioButton();
    jPARadioButton.setText("JPA");
    panel1.add(jPARadioButton,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final Spacer spacer1 = new Spacer();
    panel1.add(spacer1,
            new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    configPanel.add(persistenceImplComboBox,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    final JLabel label1 = new JLabel();
    label1.setText(" Metadata file extensions (use ';' to separate)");
    configPanel.add(label1,
            new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    includeTestClassesCheckBox = new JCheckBox();
    includeTestClassesCheckBox.setText("Include Test classes");
    configPanel.add(includeTestClassesCheckBox,
            new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    metadataExtensionTextField.setAlignmentX(0.5f);
    metadataExtensionTextField.setAutoscrolls(true);
    metadataExtensionTextField.setMargin(new Insets(1, 1, 1, 1));
    configPanel.add(metadataExtensionTextField,
            new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 0, false));
    addToCompilerResourceCheckBox = new JCheckBox();
    addToCompilerResourceCheckBox.setText("Add to compiler resource patterns");
    configPanel.add(addToCompilerResourceCheckBox,
            new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    indexNotReadyPanel = new JPanel();
    indexNotReadyPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    configPanel.add(indexNotReadyPanel,
            new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    final JLabel label2 = new JLabel();
    label2.setText("Please wait until indexing is finished");
    indexNotReadyPanel.add(label2,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    contentPanel = new JPanel();
    contentPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
    configPanel.add(contentPanel,
            new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    final JPanel panel2 = new JPanel();
    panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    contentPanel.add(panel2,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    panel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Affected Modules"));
    final JScrollPane scrollPane1 = new JScrollPane();
    panel2.add(scrollPane1,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    affectedModulesTable = new JTable();
    affectedModulesTable.setEnabled(true);
    affectedModulesTable.setFillsViewportHeight(false);
    affectedModulesTable.setPreferredScrollableViewportSize(new Dimension(450, 30));
    scrollPane1.setViewportView(affectedModulesTable);
    final JPanel panel3 = new JPanel();
    panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    contentPanel.add(panel3,
            new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    panel3.setBorder(BorderFactory.createTitledBorder("Metadata and annotated classes for enhancement"));
    infoPanel = new JPanel();
    infoPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    panel3.add(infoPanel,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    final JLabel label3 = new JLabel();
    label3.setText("Please click 'Make Project' to see affected files");
    infoPanel.add(label3,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    metaDataAndClassesScrollPane = new JScrollPane();
    panel3.add(metaDataAndClassesScrollPane,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    metadataAndClassesTable = new JTable();
    metadataAndClassesTable.setFillsViewportHeight(false);
    metadataAndClassesTable.setFont(new Font(metadataAndClassesTable.getFont().getName(),
            metadataAndClassesTable.getFont().getStyle(), metadataAndClassesTable.getFont().getSize()));
    metadataAndClassesTable.setPreferredScrollableViewportSize(new Dimension(450, 100));
    metaDataAndClassesScrollPane.setViewportView(metadataAndClassesTable);
    ButtonGroup buttonGroup;
    buttonGroup = new ButtonGroup();
    buttonGroup.add(jDORadioButton);
    buttonGroup.add(jPARadioButton);
}

From source file:org.docx4all.swing.ExternalHyperlinkDialog.java

private void fillRow5(JPanel host, GridBagConstraints c) {
    c.gridx = 0;/*from w w w .  j  a va  2  s . c  o  m*/
    c.gridy = 4;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.insets = gridCellInsets;
    c.ipadx = 0;
    c.ipady = 0;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.fill = GridBagConstraints.NONE;

    JPanel directoryPathPanel = new JPanel();
    directoryPathPanel.setBorder(BorderFactory.createEtchedBorder());

    this.directoryPathField = new JTextArea();
    this.directoryPathField.setEditable(false);
    this.directoryPathField.setEnabled(false);
    this.directoryPathField.setLineWrap(true);

    JScrollPane sp = new JScrollPane(this.directoryPathField);
    sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    sp.setMinimumSize(new Dimension(350, 100));
    sp.setPreferredSize(new Dimension(350, 100));
    directoryPathPanel.add(sp);
    host.add(directoryPathPanel, c);

    c.gridx = 2;
    c.gridy = 4;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.insets = gridCellInsets;
    c.ipadx = 0;
    c.ipady = 0;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.fill = GridBagConstraints.NONE;

    this.selectButton = new JButton("Select...");
    this.selectButton.addActionListener(new SelectButtonActionListener());
    this.selectButton.setSize(100, 50);
    host.add(this.selectButton, c);
}

From source file:org.encog.workbench.tabs.visualize.bayesian.BayesianStructureTab.java

public BayesianStructureTab(BayesianNetwork method) {
    super(null);//from   www. ja  v a  2  s. co m

    // Graph<V, E> where V is the type of the vertices
    // and E is the type of the edges
    this.graph = buildGraph(method);

    Layout<DrawnEvent, DrawnEventConnection> layout = new KKLayout(graph);

    vv = new VisualizationViewer<DrawnEvent, DrawnEventConnection>(layout);

    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<DrawnEvent>());
    vv.getRenderer().getVertexLabelRenderer().setPositioner(new InsidePositioner());
    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.N);

    vv.setVertexToolTipTransformer(new Transformer<DrawnEvent, String>() {
        public String transform(DrawnEvent edge) {
            return edge.getToolTip();
        }
    });

    Transformer<DrawnEvent, Paint> vertexPaint = new Transformer<DrawnEvent, Paint>() {
        public Paint transform(DrawnEvent neuron) {
            return Color.white;
        }
    };

    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    this.setLayout(new BorderLayout());
    add(panel, BorderLayout.CENTER);
    final AbstractModalGraphMouse graphMouse = new DefaultModalGraphMouse();
    vv.setGraphMouse(graphMouse);

    vv.addKeyListener(graphMouse.getModeKeyListener());
    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);

    final ScalingControl scaler = new CrossoverScalingControl();

    Class[] combos = getCombos();
    final JComboBox jcb = new JComboBox(combos);
    // use a renderer to shorten the layout name presentation
    jcb.setRenderer(new DefaultListCellRenderer() {
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            String valueString = value.toString();
            valueString = valueString.substring(valueString.lastIndexOf('.') + 1);
            return super.getListCellRendererComponent(list, valueString, index, isSelected, cellHasFocus);
        }
    });
    jcb.addActionListener(new LayoutChooser(jcb, vv));
    jcb.setSelectedItem(FRLayout.class);

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

    JButton reset = new JButton("reset");
    reset.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity();
            vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW).setToIdentity();
        }
    });

    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(((DefaultModalGraphMouse<Integer, Number>) vv.getGraphMouse()).getModeListener());

    JPanel controls = new JPanel();
    controls.setLayout(new FlowLayout(FlowLayout.LEFT));
    controls.add(plus);
    controls.add(minus);
    controls.add(reset);
    controls.add(modeBox);
    controls.add(jcb);
    Border border = BorderFactory.createEtchedBorder();
    controls.setBorder(border);
    add(controls, BorderLayout.NORTH);

}

From source file:org.encog.workbench.tabs.visualize.epl.EPLTreeTab.java

public EPLTreeTab(final EncogProgram prg) {
    super(null);//from  w w  w  .ja  va  2  s  .c om

    // Graph<V, E> where V is the type of the vertices
    // and E is the type of the edges
    // Graph<V, E> where V is the type of the vertices 
    // and E is the type of the edges
    this.graph = new DelegateForest<ProgramNode, Integer>(
            new DirectedOrderedSparseMultigraph<ProgramNode, Integer>());

    buildGraph(prg);
    // Add some vertices. From above we defined these to be type Integer.
    // The Layout<V, E> is parameterized by the vertex and edge types
    TreeLayout<ProgramNode, Integer> treeLayout = new TreeLayout<ProgramNode, Integer>(graph);

    Transformer<ProgramNode, Paint> vertexPaint = new Transformer<ProgramNode, Paint>() {
        public Paint transform(ProgramNode v) {
            return Color.white;
        }
    };

    //layout.setSize(new Dimension(5000,5000)); // sets the initial size of the space
    // The BasicVisualizationServer<V,E> is parameterized by the edge types
    //BasicVisualizationServer<DrawnNeuron, DrawnConnection> vv = new BasicVisualizationServer<DrawnNeuron, DrawnConnection>(
    //      layout);

    //Dimension d = new Dimension(600,600);

    vv = new VisualizationViewer<ProgramNode, Integer>(treeLayout, new Dimension(600, 600));

    //vv.setPreferredSize(d); //Sets the viewing area size

    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv.getRenderContext().setVertexLabelTransformer(new Transformer<ProgramNode, String>() {

        @Override
        public String transform(ProgramNode node) {
            ProgramExtensionTemplate temp = node.getTemplate();
            if (temp == StandardExtensions.EXTENSION_VAR_SUPPORT) {
                int varIndex = (int) node.getData()[0].toIntValue();
                return prg.getVariables().getVariableName(varIndex);
            } else if (temp == StandardExtensions.EXTENSION_CONST_SUPPORT) {
                ExpressionValue expr = node.getData()[0];
                if (expr.isFloat()) {
                    return Format.formatDouble(expr.toFloatValue(), 2);
                } else {
                    return node.getData()[0].toStringValue();
                }
            } else if (node.getTemplate().getNodeType().isOperator()) {
                return node.getTemplate().getName();
            } else {
                return node.getTemplate().getName() + "()";
            }

        }
    });

    vv.setVertexToolTipTransformer(new ToStringLabeller<ProgramNode>());

    vv.setVertexToolTipTransformer(new Transformer<ProgramNode, String>() {
        public String transform(ProgramNode node) {
            ProgramExtensionTemplate temp = node.getTemplate();
            if (temp == StandardExtensions.EXTENSION_CONST_SUPPORT) {
                return node.getData()[0].toStringValue();
            } else {
                return null;
            }
        }
    });

    /*vv.setEdgeToolTipTransformer(new Transformer<DrawnConnection,String>() {
       public String transform(DrawnConnection edge) {
    return edge.getToolTip();
       }});*/

    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    this.setLayout(new BorderLayout());
    add(panel, BorderLayout.CENTER);
    final AbstractModalGraphMouse graphMouse = new DefaultModalGraphMouse<ProgramNode, Integer>();
    vv.setGraphMouse(graphMouse);
    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
    vv.getRenderContext().setEdgeArrowPredicate(new Predicate() {
        @Override
        public boolean evaluate(Object arg0) {
            // TODO Auto-generated method stub
            return false;
        }
    });
    Predicate d;

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

    JButton reset = new JButton("reset");
    reset.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity();
            vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW).setToIdentity();
        }
    });

    JPanel controls = new JPanel();
    controls.setLayout(new FlowLayout(FlowLayout.LEFT));
    controls.add(plus);
    controls.add(minus);
    controls.add(reset);
    Border border = BorderFactory.createEtchedBorder();
    controls.setBorder(border);
    add(controls, BorderLayout.NORTH);

}

From source file:org.encog.workbench.tabs.visualize.structure.GenomeStructureTab.java

public GenomeStructureTab(NEATGenome genome) {
    super(null);/*w  ww  .  j a  v a 2  s.c  o m*/
    this.genome = genome;

    // Graph<V, E> where V is the type of the vertices
    // and E is the type of the edges
    Graph<DrawnNeuron, DrawnConnection> g = null;
    g = buildGraph(genome);

    if (g == null) {
        throw new WorkBenchError("Can't visualize genome");
    }

    Transformer<DrawnNeuron, Point2D> staticTranformer = new Transformer<DrawnNeuron, Point2D>() {

        public Point2D transform(DrawnNeuron n) {
            int x = (int) (n.getX() * 600);
            int y = (int) (n.getY() * 300);

            Point2D result = new Point(x + 32, y);
            return result;
        }
    };

    Transformer<DrawnNeuron, Paint> vertexPaint = new Transformer<DrawnNeuron, Paint>() {
        public Paint transform(DrawnNeuron neuron) {
            switch (neuron.getType()) {
            case Bias:
                return Color.yellow;
            case Input:
                return Color.white;
            case Output:
                return Color.green;
            case Context:
                return Color.cyan;
            case Linear:
                return Color.blue;
            case Sigmoid:
                return Color.magenta;
            case Gaussian:
                return Color.cyan;
            case SIN:
                return Color.gray;
            default:
                return Color.red;
            }
        }

    };

    Transformer<DrawnConnection, Paint> edgePaint = new Transformer<DrawnConnection, Paint>() {
        public Paint transform(DrawnConnection connection) {
            if (connection.isContext()) {
                return Color.lightGray;
            } else {
                return Color.black;
            }
        }
    };

    // The Layout<V, E> is parameterized by the vertex and edge types
    StaticLayout<DrawnNeuron, DrawnConnection> layout = new StaticLayout<DrawnNeuron, DrawnConnection>(g,
            staticTranformer);

    layout.setSize(new Dimension(5000, 5000)); // sets the initial size of
    // the space
    // The BasicVisualizationServer<V,E> is parameterized by the edge types
    // BasicVisualizationServer<DrawnNeuron, DrawnConnection> vv = new
    // BasicVisualizationServer<DrawnNeuron, DrawnConnection>(
    // layout);

    // Dimension d = new Dimension(600,600);

    vv = new VisualizationViewer<DrawnNeuron, DrawnConnection>(layout);

    // vv.setPreferredSize(d); //Sets the viewing area size

    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    vv.getRenderContext().setEdgeDrawPaintTransformer(edgePaint);
    vv.getRenderContext().setArrowDrawPaintTransformer(edgePaint);
    vv.getRenderContext().setArrowFillPaintTransformer(edgePaint);

    vv.setVertexToolTipTransformer(new ToStringLabeller());

    vv.setVertexToolTipTransformer(new Transformer<DrawnNeuron, String>() {
        public String transform(DrawnNeuron edge) {
            return edge.getToolTip();
        }
    });

    vv.setEdgeToolTipTransformer(new Transformer<DrawnConnection, String>() {
        public String transform(DrawnConnection edge) {
            return edge.getToolTip();
        }
    });

    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    this.setLayout(new BorderLayout());
    add(panel, BorderLayout.CENTER);
    final AbstractModalGraphMouse graphMouse = new DefaultModalGraphMouse();
    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());
        }
    });

    JButton reset = new JButton("reset");
    reset.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity();
            vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW).setToIdentity();
        }
    });

    JPanel controls = new JPanel();
    controls.setLayout(new FlowLayout(FlowLayout.LEFT));
    controls.add(plus);
    controls.add(minus);
    controls.add(reset);
    Border border = BorderFactory.createEtchedBorder();
    controls.setBorder(border);
    add(controls, BorderLayout.NORTH);
    add(new LegendPanel(true), BorderLayout.SOUTH);

}

From source file:org.encog.workbench.tabs.visualize.structure.StructureTab.java

public StructureTab(MLMethod method) {
    super(null);//from w  w w  .  jav a 2 s  .c o m

    // Graph<V, E> where V is the type of the vertices
    // and E is the type of the edges
    Graph<DrawnNeuron, DrawnConnection> g = null;

    if (method instanceof BasicNetwork) {
        BasicNetwork network = (BasicNetwork) method;
        g = buildGraph(network.getStructure().getFlat());
    } else if (method instanceof NEATNetwork) {
        NEATNetwork neat = (NEATNetwork) method;
        g = buildGraph(neat);
    }

    if (g == null) {
        throw new WorkBenchError("Can't visualize network: " + method.getClass().getSimpleName());
    }

    Transformer<DrawnNeuron, Point2D> staticTranformer = new Transformer<DrawnNeuron, Point2D>() {

        public Point2D transform(DrawnNeuron n) {
            int x = (int) (n.getX() * 600);
            int y = (int) (n.getY() * 300);

            Point2D result = new Point(x + 32, y);
            return result;
        }
    };

    Transformer<DrawnNeuron, Paint> vertexPaint = new Transformer<DrawnNeuron, Paint>() {
        public Paint transform(DrawnNeuron neuron) {
            switch (neuron.getType()) {
            case Bias:
                return Color.yellow;
            case Input:
                return Color.white;
            case Output:
                return Color.green;
            case Context:
                return Color.cyan;
            default:
                return Color.red;
            }
        }

    };

    Transformer<DrawnConnection, Paint> edgePaint = new Transformer<DrawnConnection, Paint>() {
        public Paint transform(DrawnConnection connection) {
            if (connection.isContext()) {
                return Color.lightGray;
            } else {
                return Color.black;
            }
        }
    };

    // The Layout<V, E> is parameterized by the vertex and edge types
    StaticLayout<DrawnNeuron, DrawnConnection> layout = new StaticLayout<DrawnNeuron, DrawnConnection>(g,
            staticTranformer);

    layout.setSize(new Dimension(5000, 5000)); // sets the initial size of the space
    // The BasicVisualizationServer<V,E> is parameterized by the edge types
    //BasicVisualizationServer<DrawnNeuron, DrawnConnection> vv = new BasicVisualizationServer<DrawnNeuron, DrawnConnection>(
    //      layout);

    //Dimension d = new Dimension(600,600);

    vv = new VisualizationViewer<DrawnNeuron, DrawnConnection>(layout);

    //vv.setPreferredSize(d); //Sets the viewing area size

    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    vv.getRenderContext().setEdgeDrawPaintTransformer(edgePaint);
    vv.getRenderContext().setArrowDrawPaintTransformer(edgePaint);
    vv.getRenderContext().setArrowFillPaintTransformer(edgePaint);

    vv.setVertexToolTipTransformer(new ToStringLabeller());

    vv.setVertexToolTipTransformer(new Transformer<DrawnNeuron, String>() {
        public String transform(DrawnNeuron edge) {
            return edge.getToolTip();
        }
    });

    vv.setEdgeToolTipTransformer(new Transformer<DrawnConnection, String>() {
        public String transform(DrawnConnection edge) {
            return edge.getToolTip();
        }
    });

    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    this.setLayout(new BorderLayout());
    add(panel, BorderLayout.CENTER);
    final AbstractModalGraphMouse graphMouse = new DefaultModalGraphMouse();
    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());
        }
    });

    JButton reset = new JButton("reset");
    reset.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity();
            vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW).setToIdentity();
        }
    });

    JPanel controls = new JPanel();
    controls.setLayout(new FlowLayout(FlowLayout.LEFT));
    controls.add(plus);
    controls.add(minus);
    controls.add(reset);
    Border border = BorderFactory.createEtchedBorder();
    controls.setBorder(border);
    add(controls, BorderLayout.NORTH);

}