Example usage for javax.swing Box createHorizontalBox

List of usage examples for javax.swing Box createHorizontalBox

Introduction

In this page you can find the example usage for javax.swing Box createHorizontalBox.

Prototype

public static Box createHorizontalBox() 

Source Link

Document

Creates a Box that displays its components from left to right.

Usage

From source file:pcgen.gui2.tabs.bio.CampaignHistoryInfoPane.java

private void initComponents() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    addButton.setText("Add Next Chronicle");
    addButton.setActionCommand(ADD_COMMAND);
    allButton.setText("All");
    allButton.setActionCommand(ALL_COMMAND);
    noneButton.setText("None");
    noneButton.setActionCommand(NONE_COMMAND);

    Box hbox = Box.createHorizontalBox();
    hbox.add(Box.createRigidArea(new Dimension(5, 0)));
    hbox.add(new JLabel("Check an item to include on your Character Sheet"));
    hbox.add(Box.createRigidArea(new Dimension(5, 0)));
    hbox.add(allButton);/*from w w w.ja  v  a2  s  .  c om*/
    hbox.add(Box.createRigidArea(new Dimension(3, 0)));
    hbox.add(noneButton);
    hbox.add(Box.createHorizontalGlue());

    add(Box.createVerticalStrut(5));
    add(hbox);
    add(Box.createVerticalStrut(10));
    JScrollPane pane = new JScrollPane(chroniclesPane) {

        @Override
        public Dimension getMaximumSize() {
            Dimension size = getPreferredSize();
            size.width = Integer.MAX_VALUE;
            return size;
        }

        @Override
        public boolean isValidateRoot() {
            return false;
        }

    };
    pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    add(pane);
    add(Box.createVerticalStrut(10));
    addButton.setAlignmentX(0.5f);
    add(addButton);
    add(Box.createVerticalStrut(5));
    add(Box.createVerticalGlue());
}

From source file:pcgen.gui2.tabs.DomainInfoTab.java

private void initComponents() {
    setOrientation(VERTICAL_SPLIT);//from www  .  j a va2  s . co m

    JPanel panel = new JPanel(new BorderLayout());
    FilterBar bar = new FilterBar();
    bar.addDisplayableFilter(new SearchFilterPanel());
    deityTable.setDisplayableFilter(bar);
    panel.add(bar, BorderLayout.NORTH);

    deityTable.setSortingPriority(Collections.singletonList(new SortingPriority(0, SortMode.ASCENDING)));
    deityTable.sortModel();
    ListSelectionModel selectionModel = deityTable.getSelectionModel();
    selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    panel.add(new JScrollPane(deityTable), BorderLayout.CENTER);

    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    box.add(new JLabel("Deity:"));
    box.add(Box.createHorizontalStrut(5));
    box.add(selectedDeity);
    box.add(Box.createHorizontalStrut(5));
    box.add(selectDeity);
    box.add(Box.createHorizontalGlue());
    panel.add(box, BorderLayout.SOUTH);

    FlippingSplitPane splitPane = new FlippingSplitPane();
    splitPane.setLeftComponent(panel);

    panel = new JPanel(new BorderLayout());
    bar = new FilterBar();
    bar.addDisplayableFilter(new SearchFilterPanel());
    domainFilter = bar;
    panel.add(bar, BorderLayout.NORTH);
    selectionModel = domainTable.getSelectionModel();
    selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane scrollPane = TableUtils.createCheckBoxSelectionPane(domainTable, domainRowHeaderTable);
    panel.add(scrollPane, BorderLayout.CENTER);

    box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    box.add(new JLabel("Domains Remaining to be Selected:"));
    box.add(Box.createHorizontalStrut(5));
    box.add(selectedDomain);
    box.add(Box.createHorizontalGlue());

    panel.add(box, BorderLayout.SOUTH);

    splitPane.setRightComponent(panel);
    setTopComponent(splitPane);
    splitPane = new FlippingSplitPane();
    splitPane.setLeftComponent(deityInfo);
    splitPane.setRightComponent(domainInfo);
    setBottomComponent(splitPane);
    setResizeWeight(.65);
}

From source file:pcgen.gui2.tabs.EquipInfoTab.java

private void initComponents() {
    FontManipulation.small(newSetButton);
    newSetButton.setMargin(new Insets(0, 0, 0, 0));
    FontManipulation.small(removeSetButton);
    removeSetButton.setMargin(new Insets(0, 0, 0, 0));

    exportTemplateButton.setText(LanguageBundle.getString("in_equipExportTemplate")); //$NON-NLS-1$
    viewBrowserButton.setText(LanguageBundle.getString("in_equipViewBrowser")); //$NON-NLS-1$
    exportFileButton.setText(LanguageBundle.getString("in_equipExportFile")); //$NON-NLS-1$
    setNoteButton.setText(LanguageBundle.getString("in_equipSetNote")); //$NON-NLS-1$

    setOrientation(HORIZONTAL_SPLIT);//from ww w  .  ja  va2s  . co m
    FlippingSplitPane splitPane = new FlippingSplitPane(VERTICAL_SPLIT, "EquipMain");

    JPanel panel = new JPanel(new BorderLayout());

    Box bar = Box.createHorizontalBox();
    bar.add(Box.createHorizontalStrut(5));
    bar.add(new JLabel(LanguageBundle.getString("in_equipView"))); //$NON-NLS-1$
    bar.add(Box.createHorizontalStrut(5));
    bar.add(equipViewBox);
    bar.add(Box.createHorizontalStrut(5));
    tableFilter = new SearchFilterPanel();
    bar.add(tableFilter.getFilterComponent());
    bar.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
    panel.add(bar, BorderLayout.NORTH);

    equipmentTable.setAutoCreateColumnsFromModel(false);
    equipmentTable.setColumnModel(createEquipmentColumnModel());
    equipmentTable.setAutoCreateRowSorter(true);
    panel.add(new JScrollPane(equipmentTable), BorderLayout.CENTER);

    Box buttonsBox = Box.createHorizontalBox();
    buttonsBox.add(Box.createHorizontalGlue());
    equipButton.setHorizontalTextPosition(SwingConstants.LEADING);
    buttonsBox.add(equipButton);
    buttonsBox.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    panel.add(buttonsBox, BorderLayout.SOUTH);

    splitPane.setTopComponent(panel);
    splitPane.setBottomComponent(infoPane);

    setLeftComponent(splitPane);

    panel = new JPanel(new BorderLayout());

    Box equipPane = Box.createVerticalBox();
    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    box.add(new JLabel(LanguageBundle.getString("in_equipSetLabel"))); //$NON-NLS-1$
    box.add(Box.createHorizontalStrut(3));
    box.add(equipSetBox);
    box.add(Box.createHorizontalStrut(3));
    box.add(newSetButton);
    box.add(Box.createHorizontalStrut(3));
    box.add(removeSetButton);
    box.add(Box.createHorizontalGlue());
    box.add(new JLabel(LanguageBundle.getString("in_equipWeightLabel"))); //$NON-NLS-1$
    box.add(Box.createHorizontalStrut(5));
    box.add(weightLabel);
    box.add(Box.createHorizontalGlue());
    box.add(new JLabel(LanguageBundle.getString("in_equipLoadLabel"))); //$NON-NLS-1$
    box.add(Box.createHorizontalStrut(5));
    box.add(loadLabel);
    box.add(Box.createHorizontalStrut(5));
    box.add(limitLabel);
    box.add(Box.createHorizontalGlue());

    equipPane.add(Box.createVerticalStrut(3));
    equipPane.add(box);
    equipPane.add(Box.createVerticalStrut(3));

    box = Box.createHorizontalBox();
    box.add(exportTemplateButton);
    exportTemplateButton.setEnabled(false);
    box.add(Box.createHorizontalStrut(3));
    box.add(viewBrowserButton);
    viewBrowserButton.setEnabled(false);
    box.add(Box.createHorizontalStrut(3));
    box.add(exportFileButton);
    exportFileButton.setEnabled(false);
    box.add(Box.createHorizontalStrut(3));
    box.add(setNoteButton);
    setNoteButton.setEnabled(false);
    box.add(Box.createHorizontalStrut(3));
    box.add(expandAllButton);
    box.add(Box.createHorizontalStrut(3));
    box.add(collapseAllButton);
    equipPane.add(box);
    equipPane.add(Box.createVerticalStrut(3));

    panel.add(equipPane, BorderLayout.NORTH);

    EquipmentModel.initializeTreeTable(equipmentSetTable);
    panel.add(new JScrollPane(equipmentSetTable), BorderLayout.CENTER);

    Box selPanelbuttonsBox = Box.createHorizontalBox();
    selPanelbuttonsBox.add(Box.createHorizontalStrut(3));
    selPanelbuttonsBox.add(unequipButton);
    selPanelbuttonsBox.add(Box.createHorizontalStrut(3));
    selPanelbuttonsBox.add(unequipAllButton);
    selPanelbuttonsBox.add(Box.createHorizontalStrut(3));
    selPanelbuttonsBox.add(moveUpButton);
    selPanelbuttonsBox.add(Box.createHorizontalStrut(3));
    selPanelbuttonsBox.add(moveDownButton);
    selPanelbuttonsBox.add(Box.createHorizontalGlue());
    selPanelbuttonsBox.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    panel.add(selPanelbuttonsBox, BorderLayout.SOUTH);
    setRightComponent(panel);
}

From source file:pcgen.gui2.tabs.spells.SpellBooksTab.java

private void initComponents() {
    availableTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setRowSorter(new SortableTableRowSorter() {

        @Override/* w  w  w  .jav a  2s  . co m*/
        public SortableTableModel getModel() {
            return (SortableTableModel) selectedTable.getModel();
        }

    });
    selectedTable.getRowSorter().toggleSortOrder(0);
    FilterBar<CharacterFacade, SuperNode> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    qFilterButton.setText(LanguageBundle.getString("in_igQualFilter")); //$NON-NLS-1$
    filterBar.addDisplayableFilter(qFilterButton);

    FlippingSplitPane upperPane = new FlippingSplitPane("SpellBooksTop");
    JPanel availPanel = FilterUtilities.configureFilteredTreeViewPane(availableTable, filterBar);
    Box box = Box.createVerticalBox();
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(new JLabel(LanguageBundle.getString("InfoSpells.set.auto.book")));
        hbox.add(Box.createHorizontalGlue());
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(defaultBookCombo);
        hbox.add(Box.createHorizontalGlue());
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(addButton);
        hbox.add(Box.createHorizontalStrut(5));
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    availPanel.add(box, BorderLayout.SOUTH);
    upperPane.setLeftComponent(availPanel);

    box = Box.createVerticalBox();
    box.add(new JScrollPane(selectedTable));
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(removeButton);
        hbox.add(Box.createHorizontalGlue());
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    upperPane.setRightComponent(box);
    upperPane.setResizeWeight(0);
    setTopComponent(upperPane);

    FlippingSplitPane bottomPane = new FlippingSplitPane("SpellBooksBottom");
    bottomPane.setLeftComponent(spellsPane);
    bottomPane.setRightComponent(classPane);
    setBottomComponent(bottomPane);
    setOrientation(VERTICAL_SPLIT);
}

From source file:pcgen.gui2.tabs.spells.SpellsPreparedTab.java

private void initComponents() {
    availableTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setRowSorter(new SortableTableRowSorter() {

        @Override/*from   w ww.  j  ava2  s .c om*/
        public SortableTableModel getModel() {
            return (SortableTableModel) selectedTable.getModel();
        }

    });
    selectedTable.getRowSorter().toggleSortOrder(0);
    FilterBar<CharacterFacade, SuperNode> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    qFilterButton.setText(LanguageBundle.getString("in_igQualFilter")); //$NON-NLS-1$
    filterBar.addDisplayableFilter(qFilterButton);

    FlippingSplitPane upperPane = new FlippingSplitPane("SpellsPreparedTop");
    JPanel availPanel = FilterUtilities.configureFilteredTreeViewPane(availableTable, filterBar);
    Box box = Box.createVerticalBox();
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        addMMSpellButton.setHorizontalTextPosition(SwingConstants.LEADING);
        hbox.add(addMMSpellButton);
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(2));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(slotsBox);
        hbox.add(Box.createHorizontalGlue());
        hbox.add(Box.createHorizontalStrut(10));
        hbox.add(addSpellButton);
        hbox.add(Box.createHorizontalStrut(5));
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    availPanel.add(box, BorderLayout.SOUTH);
    upperPane.setLeftComponent(availPanel);

    box = Box.createVerticalBox();
    box.add(new JScrollPane(selectedTable));
    box.add(Box.createVerticalStrut(4));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(removeSpellButton);
        hbox.add(Box.createHorizontalStrut(10));
        hbox.add(new JLabel(LanguageBundle.getString("InfoPreparedSpells.preparedList")));
        hbox.add(Box.createHorizontalStrut(3));
        hbox.add(spellListField);
        hbox.add(Box.createHorizontalStrut(3));
        hbox.add(addSpellListButton);
        hbox.add(Box.createHorizontalStrut(3));
        hbox.add(removeSpellListButton);
        hbox.add(Box.createHorizontalStrut(5));
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    upperPane.setRightComponent(box);
    upperPane.setResizeWeight(0);
    setTopComponent(upperPane);

    FlippingSplitPane bottomPane = new FlippingSplitPane("SpellsPreparedBottom");
    bottomPane.setLeftComponent(spellsPane);
    bottomPane.setRightComponent(classPane);
    setBottomComponent(bottomPane);
    setOrientation(VERTICAL_SPLIT);
}

From source file:plugins.ImageRectificationPanel.java

public final void createGui() {
    this.removeAll();

    if (imageGCPsXCoords == null) {
        return;/*from w w w  .  j ava 2 s.  co m*/
    }
    int i;
    int newN = 0;
    for (i = 0; i < imageGCPsXCoords.length; i++) {
        if (useGCP[i]) {
            newN++;
        }
    }
    double[] X1 = new double[newN];
    double[] Y1 = new double[newN];
    double[] X2 = new double[newN];
    double[] Y2 = new double[newN];

    int j = 0;
    for (i = 0; i < imageGCPsXCoords.length; i++) {
        if (useGCP[i]) {
            X1[j] = imageGCPsXCoords[i];
            Y1[j] = imageGCPsYCoords[i];
            X2[j] = mapGCPsXCoords[i];
            Y2[j] = mapGCPsYCoords[i];
            j++;
        }
    }

    calculateEquations(X1, Y1, X2, Y2);

    // gui stuff
    this.setLayout(new BorderLayout());

    DecimalFormat df = new DecimalFormat("###,###,##0.000");

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));
    JButton btnOK = createButton(bundle.getString("OK"), bundle.getString("OK"), "ok");
    JButton btnExit = createButton(bundle.getString("Close"), bundle.getString("Close"), "close");
    //JButton btnRefresh = createButton("Cancel", "Cancel");

    buttonPane.add(Box.createHorizontalStrut(10));
    buttonPane.add(btnOK);
    buttonPane.add(Box.createHorizontalStrut(5));
    //buttonPane.add(btnRefresh);
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(btnExit);
    buttonPane.add(Box.createHorizontalGlue());

    progressBar = new JProgressBar(0, 100);
    buttonPane.add(progressBar);
    buttonPane.add(Box.createHorizontalStrut(5));
    cancel = new JLabel(bundle.getString("Cancel"));
    cancel.setForeground(Color.BLUE.darker());
    cancel.addMouseListener(this);
    buttonPane.add(cancel);
    buttonPane.add(Box.createHorizontalStrut(10));

    this.add(buttonPane, BorderLayout.SOUTH);

    Box mainBox = Box.createVerticalBox();
    mainBox.add(Box.createVerticalStrut(10));

    Box box1 = Box.createHorizontalBox();
    box1.add(Box.createHorizontalStrut(10));
    box1.add(new JLabel(bundle.getString("PolynomialOrder") + ": "));
    SpinnerModel model = new SpinnerNumberModel(polyOrder, //initial value
            1, //min
            5, //max
            1); //step

    polyOrderSpinner = new JSpinner(model);
    polyOrderSpinner.setPreferredSize(new Dimension(15, polyOrderSpinner.getPreferredSize().height));
    polyOrderSpinner.addChangeListener(this);

    JSpinner.DefaultEditor editor = (JSpinner.DefaultEditor) polyOrderSpinner.getEditor();
    editor.getTextField().setEnabled(true);
    editor.getTextField().setEditable(false);

    box1.add(polyOrderSpinner);
    box1.add(Box.createHorizontalGlue());
    JLabel label = new JLabel("RMSE: " + df.format(overallRMSE));
    box1.add(label);
    box1.add(Box.createHorizontalStrut(10));
    mainBox.add(box1);

    mainBox.add(Box.createVerticalStrut(10));

    // Create columns names
    int numPoints = imageGCPsXCoords.length;
    Object dataValues[][] = new Object[numPoints][7];
    j = 0;
    for (i = 0; i < numPoints; i++) {
        dataValues[i][0] = i + 1;
        dataValues[i][1] = df.format(imageGCPsXCoords[i]);
        dataValues[i][2] = df.format(imageGCPsYCoords[i]);
        dataValues[i][3] = df.format(mapGCPsXCoords[i]);
        dataValues[i][4] = df.format(mapGCPsYCoords[i]);
        if (useGCP[i]) {
            dataValues[i][5] = df.format(residualsXY[j]);
            j++;
        } else {
            dataValues[i][5] = null;
        }
        dataValues[i][6] = useGCP[i];
    }

    String columnNames[] = { "GCP", bundle.getString("Image") + " X", bundle.getString("Image") + " Y",
            bundle.getString("Map") + " X", bundle.getString("Map") + " Y", messages.getString("Error"),
            "Use" };

    DefaultTableModel tableModel = new DefaultTableModel(dataValues, columnNames);

    dataTable = new JTable(tableModel) {
        private static final long serialVersionUID = 1L;

        @Override
        public Class getColumnClass(int column) {
            switch (column) {
            case 0:
                return Integer.class;
            case 1:
                return String.class; //Double.class;
            case 2:
                return String.class; //Double.class;
            case 3:
                return String.class; //Double.class;
            case 4:
                return String.class; //Double.class;
            case 5:
                return String.class; //Double.class;
            case 6:
                return Boolean.class;
            default:
                return String.class; //Double.class;
            }
        }

        @Override
        public Component prepareRenderer(TableCellRenderer renderer, int index_row, int index_col) {
            Component comp = super.prepareRenderer(renderer, index_row, index_col);
            //even index, selected or not selected

            if (index_row % 2 == 0) {
                comp.setBackground(Color.WHITE);
                comp.setForeground(Color.BLACK);
            } else {
                comp.setBackground(new Color(225, 245, 255)); //new Color(210, 230, 255));
                comp.setForeground(Color.BLACK);
            }
            if (isCellSelected(index_row, index_col)) {
                comp.setForeground(Color.RED);
            }
            return comp;
        }
    };

    tableModel.addTableModelListener(this);

    TableCellRenderer rend = dataTable.getTableHeader().getDefaultRenderer();
    TableColumnModel tcm = dataTable.getColumnModel();
    //for (int j = 0; j < tcm.getColumnCount(); j += 1) {
    TableColumn tc = tcm.getColumn(0);
    TableCellRenderer rendCol = tc.getHeaderRenderer(); // likely null  
    if (rendCol == null) {
        rendCol = rend;
    }
    Component c = rendCol.getTableCellRendererComponent(dataTable, tc.getHeaderValue(), false, false, 0, 0);
    tc.setPreferredWidth(35);

    tc = tcm.getColumn(6);
    rendCol = tc.getHeaderRenderer(); // likely null  
    if (rendCol == null) {
        rendCol = rend;
    }
    c = rendCol.getTableCellRendererComponent(dataTable, tc.getHeaderValue(), false, false, 0, 6);
    tc.setPreferredWidth(35);

    JScrollPane scroll = new JScrollPane(dataTable);
    mainBox.add(scroll);

    this.add(mainBox, BorderLayout.CENTER);

    this.validate();
}

From source file:satalitelist.EdgeLabelDemo.java

/**
 * create an instance of a simple graph with controls to
 * demo the label positioning features/* w ww .j a v  a  2s.  com*/
 *
 */
@SuppressWarnings("serial")
public EdgeLabelDemo(StemAndCycleList al) {
    cities = (ArrayList<INode>) al.list;
    list = al;
    al.score = al.getCycleScore();
    // create a simple graph for the demo
    graph = new SparseMultigraph<Integer, MyEdge>();
    //Integer[] v = createVertices(7);
    fillSevenCitiesWithPrices();
    for (INode n : cities) {
        graph.addVertex(Integer.parseInt(n.toString()));
    }
    createVertices();
    //createEdges(v);

    Layout<Integer, MyEdge> layout = new FRLayout2<Integer, MyEdge>(graph);
    vv = new VisualizationViewer<Integer, MyEdge>(layout, new Dimension(1000, 800));
    vv.setBackground(Color.white);

    vertexLabelRenderer = vv.getRenderContext().getVertexLabelRenderer();
    edgeLabelRenderer = vv.getRenderContext().getEdgeLabelRenderer();

    vv.getRenderContext().setEdgeLabelTransformer(new Transformer<MyEdge, String>() {
        public String transform(MyEdge i) {
            return i.toString();
        }
    });
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<MyEdge>(vv.getPickedEdgeState(), Color.black, Color.cyan));
    vv.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.red, Color.yellow));
    // add my listener for ToolTips

    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Integer>());
    vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<MyEdge, Stroke>() {

        public Stroke transform(MyEdge i) {
            switch (i.kind) {
            case NORMAL:
                return new BasicStroke(2, 1, 1, 0, new float[] { 10, 0 }, 0);
            case VIRTUAL:
                return new BasicStroke(2, 1, 1, 0, new float[] { 5 }, 0);
            case INVISIBLE:
                return new BasicStroke(1, 1, 1, 0, new float[] { 1, 10 }, 0);
            }
            throw new RuntimeException("No such a type");
        }
    });

    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);

    // create a frome to hold the graph
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    Container content = getContentPane();
    content.add(panel);

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

    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 lineButton = new JRadioButton("Line");
    lineButton.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<Integer, MyEdge>());
                vv.repaint();
            }
        }
    });

    JRadioButton quadButton = new JRadioButton("QuadCurve");
    quadButton.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<Integer, MyEdge>());
                vv.repaint();
            }
        }
    });

    JRadioButton cubicButton = new JRadioButton("CubicCurve");
    cubicButton.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<Integer, MyEdge>());
                vv.repaint();
            }
        }
    });

    radio.add(quadButton);
    radio.add(cubicButton);
    radio.add(lineButton);

    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    Box controls = Box.createHorizontalBox();

    JPanel zoomPanel = new JPanel(new GridLayout(0, 1));
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Scale"));
    zoomPanel.add(plus);
    zoomPanel.add(minus);

    JPanel edgePanel = new JPanel(new GridLayout(0, 1));
    edgePanel.setBorder(BorderFactory.createTitledBorder("EdgeType Type"));
    edgePanel.add(lineButton);
    edgePanel.add(quadButton);
    edgePanel.add(cubicButton);

    JPanel rotatePanel = new JPanel();
    rotatePanel.setBorder(BorderFactory.createTitledBorder("Alignment"));
    rotatePanel.add(cycleLabel);
    rotatePanel.add(stemLabel);
    rotatePanel.add(otherEndLabel);

    JPanel labelPanel = new JPanel(new BorderLayout());

    labelPanel.add(rotatePanel, BorderLayout.WEST);

    JPanel modePanel = new JPanel(new GridLayout(2, 1));
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(graphMouse.getModeComboBox());

    JPanel movePanel = new JPanel(new GridLayout(2, 1));
    modePanel.setBorder(BorderFactory.createTitledBorder("Make move"));
    JButton button = new JButton("Make move");
    button.addActionListener(new StemAndCycleAl());
    modePanel.add(button);

    controls.add(zoomPanel);
    controls.add(edgePanel);
    controls.add(labelPanel);
    controls.add(modePanel);
    controls.add(movePanel);
    content.add(controls, BorderLayout.SOUTH);
    lineButton.setSelected(true);
}

From source file:visolate.Visolate.java

private Box getLoadFileBox() {
    if (myLoadFileBox == null) {
        myLoadFileBox = Box.createHorizontalBox();

        loadButton = new JButton("Load");
        loadButton.setEnabled(false);//from  www .j a v  a  2s . co m
        loadButton.setBackground(Color.WHITE);
        loadButton.setVerticalAlignment(AbstractButton.CENTER);
        loadButton.setHorizontalAlignment(AbstractButton.CENTER);
        Dimension d = loadButton.getPreferredSize();
        loadButton.setMaximumSize(new Dimension(d.width, d.height));
        loadButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                loadFile();
            }
        });
        myLoadFileBox.add(loadButton);

        loadField = new JTextField();
        d = loadField.getPreferredSize();
        loadField.setMaximumSize(new Dimension(Integer.MAX_VALUE, d.height));
        myLoadFileBox.add(loadField);

        browseButton = new JButton("Browse...");
        browseButton.setBackground(Color.WHITE);
        browseButton.setVerticalAlignment(AbstractButton.CENTER);
        browseButton.setHorizontalAlignment(AbstractButton.CENTER);
        d = browseButton.getPreferredSize();
        browseButton.setMaximumSize(new Dimension(d.width, d.height));
        browseButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                File file = browse();
                if (file != null)
                    loadFile(file);
                loadButton.setEnabled(true);
            }
        });
        myLoadFileBox.add(browseButton);

        myLoadFileBox.setBorder(BorderFactory.createTitledBorder("Input File"));
    }
    return myLoadFileBox;
}

From source file:visolate.Visolate.java

private Box getGcodeBox() {
    if (myGcodeBox == null) {
        Dimension d;/* w  w w . j a  va 2 s .c o m*/
        myGcodeBox = Box.createHorizontalBox();

        gcodeButton = new JButton("Save G-Code");
        gcodeButton.setEnabled(false);
        gcodeButton.setBackground(Color.WHITE);
        gcodeButton.setVerticalAlignment(AbstractButton.CENTER);
        gcodeButton.setHorizontalAlignment(AbstractButton.CENTER);
        d = gcodeButton.getPreferredSize();
        gcodeButton.setMaximumSize(new Dimension(d.width, d.height));
        gcodeButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                saveGCode();
            }
        });
        myGcodeBox.add(gcodeButton);

        gcodeField = new JTextField();
        gcodeField.setEnabled(false);
        d = gcodeField.getPreferredSize();
        gcodeField.setMaximumSize(new Dimension(Integer.MAX_VALUE, d.height));
        myGcodeBox.add(gcodeField);

        gcodeBrowseButton = new JButton("Browse...");
        gcodeBrowseButton.setEnabled(false);
        gcodeBrowseButton.setBackground(Color.WHITE);
        gcodeBrowseButton.setVerticalAlignment(AbstractButton.CENTER);
        gcodeBrowseButton.setHorizontalAlignment(AbstractButton.CENTER);
        d = gcodeBrowseButton.getPreferredSize();
        gcodeBrowseButton.setMaximumSize(new Dimension(d.width, d.height));
        gcodeBrowseButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                File file = browse();
                if (file != null)
                    saveGCode(file);
            }
        });
        myGcodeBox.add(gcodeBrowseButton);

        stopButton = new JButton("Stop");
        stopButton.setBackground(Color.WHITE);
        //    stopButton.setVerticalAlignment(AbstractButton.CENTER);
        //    stopButton.setHorizontalAlignment(AbstractButton.CENTER);
        stopButton.setAlignmentX(0.5f);
        d = stopButton.getPreferredSize();
        stopButton.setMaximumSize(new Dimension(Integer.MAX_VALUE, d.height));
        stopButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                stopProcess();
            }
        });
        stopButton.setEnabled(false);

        progressBar = new JProgressBar();
        progressBar.setBackground(Color.WHITE);
    }
    return myGcodeBox;
}

From source file:visolate.Visolate.java

private Box getTopologyAndToolpathsBox() {
    Box topologyAndToolpathsBox = Box.createHorizontalBox();
    topologyAndToolpathsBox.add(getTopologyBox());
    topologyAndToolpathsBox.add(Box.createHorizontalGlue());
    topologyAndToolpathsBox.add(getToolpathBox());
    return topologyAndToolpathsBox;
}