Example usage for java.awt GridBagConstraints PAGE_START

List of usage examples for java.awt GridBagConstraints PAGE_START

Introduction

In this page you can find the example usage for java.awt GridBagConstraints PAGE_START.

Prototype

int PAGE_START

To view the source code for java.awt GridBagConstraints PAGE_START.

Click Source Link

Document

Place the component centered along the edge of its display area associated with the start of a page for the current ComponentOrientation .

Usage

From source file:Main.java

public static void main(String[] args) {
    JFrame dialog = new JFrame();
    dialog.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    dialog.setResizable(true);//from   ww w  .j a v a 2s .c  o  m

    JPanel guiHolder = new JPanel();
    guiHolder.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    guiHolder.add(new JLabel("my test"), gbc);

    dialog.add(guiHolder);
    dialog.setSize(new Dimension(320, 240));
    dialog.setVisible(true);
}

From source file:tl.lib.dataCollection.gui.MultipleChartsPanel.java

public MultipleChartsPanel(_CollectionGUIScenario scenario, String label, String description) {
    super(new GridBagLayout());
    this.charts = new Hashtable<Integer, _ChartPanel>();
    this.scenario = scenario;
    this.description = description;
    this.label = label;
    grid = new GridBagConstraints();
    grid.weighty = 1;/*from w  w w .  j av  a  2 s .co m*/
    grid.weightx = 1;
    grid.anchor = GridBagConstraints.PAGE_START;
    grid.fill = GridBagConstraints.BOTH;
}

From source file:de.tor.tribes.ui.components.DatePicker.java

private void init() {
    //build Header
    for (int i = 0; i < 7; i++) {
        JLabel head = new JLabel(dayNames[i]);
        head.setBackground(GRAY);/*www.ja  va 2 s .co  m*/
        head.setOpaque(true);
        head.setPreferredSize(new Dimension(20, 20));
        head.setMinimumSize(new Dimension(20, 20));
        head.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        GridBagConstraints gbc = new GridBagConstraints();
        gbc.anchor = GridBagConstraints.PAGE_START;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridx = i;
        gbc.gridy = 0;
        gbc.insets = new Insets(2, 2, 6, 2);
        gbc.ipadx = 0;
        gbc.ipady = 0;
        gbc.weightx = 1.0;
        gbc.weighty = 0.0;
        jPanelDaySelection.add(head, gbc);
    }

    daysInMonth = new CrossedLabel[WEEKS_TO_SHOW][7];
    datesInMonth = new Date[WEEKS_TO_SHOW][7];
    for (int i = 0; i < WEEKS_TO_SHOW; i++) {
        for (int j = 0; j < 7; j++) {
            daysInMonth[i][j] = new CrossedLabel();
            daysInMonth[i][j].setPreferredSize(new Dimension(20, 20));
            daysInMonth[i][j].setMinimumSize(new Dimension(20, 20));
            daysInMonth[i][j].setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            daysInMonth[i][j].addMouseListener(new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent mouseevent) {
                    dayClicked(mouseevent);
                }
            });

            GridBagConstraints gbc = new GridBagConstraints();
            gbc.anchor = GridBagConstraints.PAGE_START;
            gbc.fill = GridBagConstraints.HORIZONTAL;
            gbc.gridx = j;
            gbc.gridy = i + 1;
            gbc.insets = new Insets(2, 2, 2, 2);
            gbc.ipadx = 0;
            gbc.ipady = 0;
            gbc.weightx = 1.0;
            gbc.weighty = 0.0;
            jPanelDaySelection.add(daysInMonth[i][j], gbc);
        }
    }

    buildCalendar();
}

From source file:org.fhcrc.cpl.viewer.quant.gui.PanelWithLogRatioHistAndFields.java

/**
 * Lay out GUI components, but NOT the histogram
 *//*  w w  w .  j  a va2 s  .c  o  m*/
protected void initGUI() {
    setLayout(new GridBagLayout());
    maxLowRatioLabel = new JLabel("Max Low Ratio: ");
    minHighRatioLabel = new JLabel("Min High Ratio: ");
    numPassingRatiosLabel = new JLabel("Retained: ");
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.weighty = 0;
    gbc.weightx = 1;
    gbc.gridwidth = 1;
    add(maxLowRatioLabel, gbc);
    gbc.gridwidth = GridBagConstraints.RELATIVE;
    add(minHighRatioLabel, gbc);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(numPassingRatiosLabel, gbc);
}

From source file:pl.otros.logview.gui.LogViewPanelWrapper.java

public LogViewPanelWrapper(String name, Stoppable stoppable, TableColumns[] visibleColumns,
        LogDataTableModel logDataTableModel, DataConfiguration configuration,
        OtrosApplication otrosApplication) {
    this.name = name;
    this.configuration = configuration;
    this.otrosApplication = otrosApplication;
    this.addHierarchyListener(new HierarchyListener() {

        @Override/*from  w  w  w . j  a v a  2  s .  c o m*/
        public void hierarchyChanged(HierarchyEvent e) {
            if (e.getChangeFlags() == 1 && e.getChanged().getParent() == null) {
                LOGGER.info("Log view panel is removed from view. Clearing data table for GC");
                dataTableModel.clear();
            }
        }
    });
    if (visibleColumns == null) {
        visibleColumns = TableColumns.ALL_WITHOUT_LOG_SOURCE;
    }

    fillDefaultConfiguration();

    stopableReference = new SoftReference<Stoppable>(stoppable);
    // this.statusObserver = statusObserver;
    dataTableModel = logDataTableModel == null ? new LogDataTableModel() : logDataTableModel;
    logViewPanel = new LogViewPanel(dataTableModel, visibleColumns, otrosApplication);

    cardLayout = new CardLayout();
    JPanel panelLoading = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(10, 10, 10, 10);
    c.anchor = GridBagConstraints.PAGE_START;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    c.ipadx = 1;
    c.ipady = 1;
    c.weightx = 10;
    c.weighty = 1;

    JLabel label = new JLabel("Loading file " + name);
    panelLoading.add(label, c);
    c.gridy++;
    c.weighty = 3;
    loadingProgressBar = new JProgressBar();
    loadingProgressBar.setIndeterminate(false);
    loadingProgressBar.setStringPainted(true);
    loadingProgressBar.setString("Connecting...");
    panelLoading.add(loadingProgressBar, c);
    statsTable = new JTable();

    c.gridy++;
    c.weighty = 1;
    c.weightx = 2;
    panelLoading.add(statsTable, c);
    c.gridy++;
    c.weightx = 1;
    stopButton = new JButton("Stop, you have imported already enough!");
    stopButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Stoppable stoppable = stopableReference.get();
            if (stoppable != null) {
                stoppable.stop();
            }
        }
    });
    panelLoading.add(stopButton, c);

    setLayout(cardLayout);
    add(panelLoading, CARD_LAYOUT_LOADING);
    add(logViewPanel, CARD_LAYOUT_CONTENT);
    cardLayout.show(this, CARD_LAYOUT_LOADING);

}

From source file:pl.otros.logview.api.gui.LogViewPanelWrapper.java

public LogViewPanelWrapper(final String name, final Stoppable stoppable, final TableColumns[] visibleColumns,
        final LogDataTableModel logDataTableModel, final DataConfiguration configuration,
        final OtrosApplication otrosApplication) {

    this.name = name;
    this.configuration = configuration;
    this.otrosApplication = otrosApplication;
    logLoader = otrosApplication.getLogLoader();
    this.addHierarchyListener(e -> {
        if (e.getChangeFlags() == 1 && e.getChanged().getParent() == null) {
            closing();/* w w w .j  a v  a2  s .  c  o m*/
        }
    });
    final TableColumns[] columns = (visibleColumns == null) ? TableColumns.ALL_WITHOUT_LOG_SOURCE
            : visibleColumns;

    fillDefaultConfiguration();

    SoftReference<Stoppable> stoppableReference = new SoftReference<>(stoppable);
    // this.statusObserver = statusObserver;
    dataTableModel = logDataTableModel == null ? new LogDataTableModel() : logDataTableModel;
    logViewPanel = new LogViewPanel(dataTableModel, columns, otrosApplication);

    cardLayout = new CardLayout();
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(10, 10, 10, 10);
    c.anchor = GridBagConstraints.PAGE_START;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    c.ipadx = 1;
    c.ipady = 1;
    c.weightx = 10;
    c.weighty = 1;

    c.gridy++;
    c.weighty = 3;
    loadingProgressBar = new JProgressBar();
    loadingProgressBar.setIndeterminate(false);
    loadingProgressBar.setStringPainted(true);
    loadingProgressBar.setString("Connecting...");

    c.gridy++;
    c.weighty = 1;
    c.weightx = 2;
    c.gridy++;
    c.weightx = 1;
    JButton stopButton = new JButton("Stop, you have imported already enough!");
    stopButton.addActionListener(e -> {
        Stoppable stoppable1 = stoppableReference.get();
        if (stoppable1 != null) {
            stoppable1.stop();
        }
    });

    setLayout(cardLayout);
    add(logViewPanel, CARD_LAYOUT_CONTENT);
    cardLayout.show(this, CARD_LAYOUT_LOADING);

}

From source file:com.vgi.mafscaling.OpenLoop.java

private void createRunTables(JPanel dataRunPanel) {
    GridBagConstraints gbc_run = new GridBagConstraints();
    gbc_run.anchor = GridBagConstraints.PAGE_START;
    gbc_run.insets = new Insets(0, 2, 0, 2);
    for (int i = 0; i < RunCount; ++i) {
        runTables[i] = new JTable();
        JTable table = runTables[i];
        table.getTableHeader().setReorderingAllowed(false);
        table.setModel(new DefaultTableModel(RunRowsCount, 3));
        table.setColumnSelectionAllowed(true);
        table.setCellSelectionEnabled(true);
        table.setBorder(new LineBorder(new Color(0, 0, 0)));
        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        table.getColumnModel().getColumn(0)
                .setHeaderValue("<html><center>Engine<br>Speed<br>(RPM)<br></center></html>");
        table.getColumnModel().getColumn(1)
                .setHeaderValue("<html><center>MAF<br>Sensor<br>Voltage<br></center></html>");
        table.getColumnModel().getColumn(2)
                .setHeaderValue("<html><center>AFR<br>Error<br>%<br></center></html>");
        Utils.initializeTable(table, ColumnWidth);
        excelAdapter.addTable(table, true, false);

        gbc_run.gridx = i;/*from  www  .ja  v  a2  s. c  o m*/
        gbc_run.gridy = 0;
        dataRunPanel.add(table.getTableHeader(), gbc_run);
        gbc_run.gridy = 1;
        dataRunPanel.add(table, gbc_run);
    }
}

From source file:com.vgi.mafscaling.MafCompare.java

/**
 * Initialize the contents of the frame.
 */// w  ww.  j av a  2  s. c  o m
private void initialize() {
    try {
        ImageIcon tableImage = new ImageIcon(getClass().getResource("/table.jpg"));
        setTitle(Title);
        setIconImage(tableImage.getImage());
        setBounds(100, 100, 621, 372);
        setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        setSize(Config.getCompWindowSize());
        setLocation(Config.getCompWindowLocation());
        setLocationRelativeTo(null);
        setVisible(false);
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                Utils.clearTable(origMafTable);
                Utils.clearTable(newMafTable);
                Utils.clearTable(compMafTable);
                Config.setCompWindowSize(getSize());
                Config.setCompWindowLocation(getLocation());
                origMafData.clear();
                newMafData.clear();
            }
        });

        JPanel dataPanel = new JPanel();
        GridBagLayout gbl_dataPanel = new GridBagLayout();
        gbl_dataPanel.columnWidths = new int[] { 0, 0, 0 };
        gbl_dataPanel.rowHeights = new int[] { RowHeight, RowHeight, RowHeight, RowHeight, RowHeight, 0 };
        gbl_dataPanel.columnWeights = new double[] { 0.0, 0.0, 0.0 };
        gbl_dataPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
        dataPanel.setLayout(gbl_dataPanel);
        getContentPane().add(dataPanel);

        JLabel origLabel = new JLabel(origMaf);
        GridBagConstraints gbc_origLabel = new GridBagConstraints();
        gbc_origLabel.anchor = GridBagConstraints.PAGE_START;
        gbc_origLabel.insets = new Insets(1, 1, 1, 5);
        gbc_origLabel.weightx = 0;
        gbc_origLabel.weighty = 0;
        gbc_origLabel.gridx = 0;
        gbc_origLabel.gridy = 0;
        gbc_origLabel.gridheight = 2;
        dataPanel.add(origLabel, gbc_origLabel);

        JLabel newLabel = new JLabel(newMaf);
        GridBagConstraints gbc_newLabel = new GridBagConstraints();
        gbc_newLabel.anchor = GridBagConstraints.PAGE_START;
        gbc_newLabel.insets = new Insets(1, 1, 1, 5);
        gbc_newLabel.weightx = 0;
        gbc_newLabel.weighty = 0;
        gbc_newLabel.gridx = 0;
        gbc_newLabel.gridy = 2;
        gbc_newLabel.gridheight = 2;
        dataPanel.add(newLabel, gbc_newLabel);

        JLabel compLabel = new JLabel("Change");
        GridBagConstraints gbc_compLabel = new GridBagConstraints();
        gbc_compLabel.anchor = GridBagConstraints.PAGE_START;
        gbc_compLabel.insets = new Insets(1, 1, 1, 5);
        gbc_compLabel.weightx = 0;
        gbc_compLabel.weighty = 0;
        gbc_compLabel.gridx = 0;
        gbc_compLabel.gridy = 4;
        dataPanel.add(compLabel, gbc_compLabel);

        JLabel origVoltLabel = new JLabel("volt");
        GridBagConstraints gbc_origVoltLabel = new GridBagConstraints();
        gbc_origVoltLabel.anchor = GridBagConstraints.PAGE_START;
        gbc_origVoltLabel.insets = new Insets(1, 1, 1, 5);
        gbc_origVoltLabel.weightx = 0;
        gbc_origVoltLabel.weighty = 0;
        gbc_origVoltLabel.gridx = 1;
        gbc_origVoltLabel.gridy = 0;
        dataPanel.add(origVoltLabel, gbc_origVoltLabel);

        JLabel origGsLabel = new JLabel(" g/s");
        GridBagConstraints gbc_origGsLabel = new GridBagConstraints();
        gbc_origGsLabel.anchor = GridBagConstraints.PAGE_START;
        gbc_origGsLabel.insets = new Insets(1, 1, 1, 5);
        gbc_origGsLabel.weightx = 0;
        gbc_origGsLabel.weighty = 0;
        gbc_origGsLabel.gridx = 1;
        gbc_origGsLabel.gridy = 1;
        dataPanel.add(origGsLabel, gbc_origGsLabel);

        JLabel newVoltLabel = new JLabel("volt");
        GridBagConstraints gbc_newVoltLabel = new GridBagConstraints();
        gbc_newVoltLabel.anchor = GridBagConstraints.PAGE_START;
        gbc_newVoltLabel.insets = new Insets(1, 1, 1, 5);
        gbc_newVoltLabel.weightx = 0;
        gbc_newVoltLabel.weighty = 0;
        gbc_newVoltLabel.gridx = 1;
        gbc_newVoltLabel.gridy = 2;
        dataPanel.add(newVoltLabel, gbc_newVoltLabel);

        JLabel newGsLabel = new JLabel(" g/s");
        GridBagConstraints gbc_newGsLabel = new GridBagConstraints();
        gbc_newGsLabel.anchor = GridBagConstraints.PAGE_START;
        gbc_newGsLabel.insets = new Insets(1, 1, 1, 5);
        gbc_newGsLabel.weightx = 0;
        gbc_newGsLabel.weighty = 0;
        gbc_newGsLabel.gridx = 1;
        gbc_newGsLabel.gridy = 3;
        dataPanel.add(newGsLabel, gbc_newGsLabel);

        JLabel compPctLabel = new JLabel(" %  ");
        GridBagConstraints gbc_compPctLabel = new GridBagConstraints();
        gbc_compPctLabel.anchor = GridBagConstraints.PAGE_START;
        gbc_compPctLabel.insets = new Insets(1, 1, 1, 5);
        gbc_compPctLabel.weightx = 0;
        gbc_compPctLabel.weighty = 0;
        gbc_compPctLabel.gridx = 1;
        gbc_compPctLabel.gridy = 4;
        dataPanel.add(compPctLabel, gbc_compPctLabel);

        JPanel tablesPanel = new JPanel();
        GridBagLayout gbl_tablesPanel = new GridBagLayout();
        gbl_tablesPanel.columnWidths = new int[] { 0 };
        gbl_tablesPanel.rowHeights = new int[] { 0, 0, 0 };
        gbl_tablesPanel.columnWeights = new double[] { 0.0 };
        gbl_tablesPanel.rowWeights = new double[] { 0.0, 0.0, 1.0 };
        tablesPanel.setLayout(gbl_tablesPanel);

        JScrollPane mafScrollPane = new JScrollPane(tablesPanel);
        mafScrollPane.setMinimumSize(new Dimension(1600, 107));
        mafScrollPane.getHorizontalScrollBar().setMaximumSize(new Dimension(20, 20));
        mafScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
        mafScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        GridBagConstraints gbc_mafScrollPane = new GridBagConstraints();
        gbc_mafScrollPane.weightx = 1.0;
        gbc_mafScrollPane.anchor = GridBagConstraints.PAGE_START;
        gbc_mafScrollPane.fill = GridBagConstraints.HORIZONTAL;
        gbc_mafScrollPane.gridx = 2;
        gbc_mafScrollPane.gridy = 0;
        gbc_mafScrollPane.gridheight = 5;
        dataPanel.add(mafScrollPane, gbc_mafScrollPane);

        origMafTable = new JTable();
        origMafTable.setColumnSelectionAllowed(true);
        origMafTable.setCellSelectionEnabled(true);
        origMafTable.setBorder(new LineBorder(new Color(0, 0, 0)));
        origMafTable.setRowHeight(RowHeight);
        origMafTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        origMafTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        origMafTable.setModel(new DefaultTableModel(2, MafTableColumnCount));
        origMafTable.setTableHeader(null);
        Utils.initializeTable(origMafTable, ColumnWidth);
        GridBagConstraints gbc_origMafTable = new GridBagConstraints();
        gbc_origMafTable.anchor = GridBagConstraints.PAGE_START;
        gbc_origMafTable.insets = new Insets(0, 0, 0, 0);
        gbc_origMafTable.fill = GridBagConstraints.HORIZONTAL;
        gbc_origMafTable.weightx = 1.0;
        gbc_origMafTable.weighty = 0;
        gbc_origMafTable.gridx = 0;
        gbc_origMafTable.gridy = 0;
        tablesPanel.add(origMafTable, gbc_origMafTable);
        excelAdapter.addTable(origMafTable, false, false, false, false, true, false, true, false, true);

        newMafTable = new JTable();
        newMafTable.setColumnSelectionAllowed(true);
        newMafTable.setCellSelectionEnabled(true);
        newMafTable.setBorder(new LineBorder(new Color(0, 0, 0)));
        newMafTable.setRowHeight(RowHeight);
        newMafTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        newMafTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        newMafTable.setModel(new DefaultTableModel(2, MafTableColumnCount));
        newMafTable.setTableHeader(null);
        Utils.initializeTable(newMafTable, ColumnWidth);
        GridBagConstraints gbc_newMafTable = new GridBagConstraints();
        gbc_newMafTable.anchor = GridBagConstraints.PAGE_START;
        gbc_newMafTable.insets = new Insets(0, 0, 0, 0);
        gbc_newMafTable.fill = GridBagConstraints.HORIZONTAL;
        gbc_newMafTable.weightx = 1.0;
        gbc_newMafTable.weighty = 0;
        gbc_newMafTable.gridx = 0;
        gbc_newMafTable.gridy = 1;
        tablesPanel.add(newMafTable, gbc_newMafTable);
        excelAdapter.addTable(newMafTable, false, false, false, false, false, false, false, false, true);

        compMafTable = new JTable();
        compMafTable.setColumnSelectionAllowed(true);
        compMafTable.setCellSelectionEnabled(true);
        compMafTable.setBorder(new LineBorder(new Color(0, 0, 0)));
        compMafTable.setRowHeight(RowHeight);
        compMafTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        compMafTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        compMafTable.setModel(new DefaultTableModel(1, MafTableColumnCount));
        compMafTable.setTableHeader(null);
        Utils.initializeTable(compMafTable, ColumnWidth);
        NumberFormatRenderer numericRenderer = new NumberFormatRenderer();
        numericRenderer.setFormatter(new DecimalFormat("0.000"));
        compMafTable.setDefaultRenderer(Object.class, numericRenderer);
        GridBagConstraints gbc_compMafTable = new GridBagConstraints();
        gbc_compMafTable.anchor = GridBagConstraints.PAGE_START;
        gbc_compMafTable.insets = new Insets(0, 0, 0, 0);
        gbc_compMafTable.fill = GridBagConstraints.HORIZONTAL;
        gbc_compMafTable.weightx = 1.0;
        gbc_compMafTable.weighty = 0;
        gbc_compMafTable.gridx = 0;
        gbc_compMafTable.gridy = 2;
        tablesPanel.add(compMafTable, gbc_compMafTable);
        compExcelAdapter.addTable(compMafTable, false, true, false, false, false, true, true, false, true);

        TableModelListener origTableListener = new TableModelListener() {
            public void tableChanged(TableModelEvent tme) {
                if (tme.getType() == TableModelEvent.UPDATE) {
                    int colCount = origMafTable.getColumnCount();
                    Utils.ensureColumnCount(colCount, newMafTable);
                    Utils.ensureColumnCount(colCount, compMafTable);
                    origMafData.clear();
                    String origY, origX, newY;
                    for (int i = 0; i < colCount; ++i) {
                        origY = origMafTable.getValueAt(1, i).toString();
                        if (Pattern.matches(Utils.fpRegex, origY)) {
                            origX = origMafTable.getValueAt(0, i).toString();
                            if (Pattern.matches(Utils.fpRegex, origX))
                                origMafData.add(Double.valueOf(origX), Double.valueOf(origY), false);
                            newY = newMafTable.getValueAt(1, i).toString();
                            if (Pattern.matches(Utils.fpRegex, newY))
                                compMafTable.setValueAt(
                                        ((Double.valueOf(newY) / Double.valueOf(origY)) - 1.0) * 100.0, 0, i);
                        } else
                            break;
                    }
                    origMafData.fireSeriesChanged();
                }
            }
        };

        TableModelListener newTableListener = new TableModelListener() {
            public void tableChanged(TableModelEvent tme) {
                if (tme.getType() == TableModelEvent.UPDATE) {
                    int colCount = newMafTable.getColumnCount();
                    Utils.ensureColumnCount(colCount, origMafTable);
                    Utils.ensureColumnCount(colCount, compMafTable);
                    newMafData.clear();
                    String newY, newX, origY;
                    for (int i = 0; i < colCount; ++i) {
                        newY = newMafTable.getValueAt(1, i).toString();
                        if (Pattern.matches(Utils.fpRegex, newY)) {
                            newX = newMafTable.getValueAt(0, i).toString();
                            if (Pattern.matches(Utils.fpRegex, newX))
                                newMafData.add(Double.valueOf(newX), Double.valueOf(newY), false);
                            origY = origMafTable.getValueAt(1, i).toString();
                            if (Pattern.matches(Utils.fpRegex, origY))
                                compMafTable.setValueAt(
                                        ((Double.valueOf(newY) / Double.valueOf(origY)) - 1.0) * 100.0, 0, i);
                        } else
                            break;
                    }
                    newMafData.fireSeriesChanged();
                }
            }
        };

        origMafTable.getModel().addTableModelListener(origTableListener);
        newMafTable.getModel().addTableModelListener(newTableListener);

        Action action = new AbstractAction() {
            private static final long serialVersionUID = 8148393537657380215L;

            public void actionPerformed(ActionEvent e) {
                TableCellListener tcl = (TableCellListener) e.getSource();
                if (Pattern.matches(Utils.fpRegex, compMafTable.getValueAt(0, tcl.getColumn()).toString())) {
                    if (Pattern.matches(Utils.fpRegex,
                            origMafTable.getValueAt(1, tcl.getColumn()).toString())) {
                        double corr = Double.valueOf(compMafTable.getValueAt(0, tcl.getColumn()).toString())
                                / 100.0 + 1.0;
                        newMafTable.setValueAt(
                                Double.valueOf(origMafTable.getValueAt(1, tcl.getColumn()).toString()) * corr,
                                1, tcl.getColumn());
                    }
                } else
                    compMafTable.setValueAt(tcl.getOldValue(), 0, tcl.getColumn());
            }
        };

        setCompMafCellListener(new TableCellListener(compMafTable, action));

        // CHART

        JFreeChart chart = ChartFactory.createXYLineChart(null, null, null, null, PlotOrientation.VERTICAL,
                false, true, false);
        chart.setBorderVisible(true);
        chartPanel = new ChartPanel(chart, true, true, true, true, true);
        chartPanel.setAutoscrolls(true);

        GridBagConstraints gbl_chartPanel = new GridBagConstraints();
        gbl_chartPanel.anchor = GridBagConstraints.PAGE_START;
        gbl_chartPanel.fill = GridBagConstraints.BOTH;
        gbl_chartPanel.insets = new Insets(1, 1, 1, 1);
        gbl_chartPanel.weightx = 1.0;
        gbl_chartPanel.weighty = 1.0;
        gbl_chartPanel.gridx = 0;
        gbl_chartPanel.gridy = 5;
        gbl_chartPanel.gridheight = 1;
        gbl_chartPanel.gridwidth = 3;
        dataPanel.add(chartPanel, gbl_chartPanel);

        XYSplineRenderer lineRenderer = new XYSplineRenderer(3);
        lineRenderer.setUseFillPaint(true);
        lineRenderer.setBaseToolTipGenerator(
                new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                        new DecimalFormat("0.00"), new DecimalFormat("0.00")));

        Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f);
        lineRenderer.setSeriesStroke(0, stroke);
        lineRenderer.setSeriesStroke(1, stroke);
        lineRenderer.setSeriesPaint(0, new Color(201, 0, 0));
        lineRenderer.setSeriesPaint(1, new Color(0, 0, 255));
        lineRenderer.setSeriesShape(0, ShapeUtilities.createDiamond((float) 2.5));
        lineRenderer.setSeriesShape(1, ShapeUtilities.createDownTriangle((float) 2.5));
        lineRenderer.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator() {
            private static final long serialVersionUID = -4045338273187150888L;

            public String generateLabel(XYDataset dataset, int series) {
                XYSeries xys = ((XYSeriesCollection) dataset).getSeries(series);
                return xys.getDescription();
            }
        });

        NumberAxis mafvDomain = new NumberAxis(XAxisName);
        mafvDomain.setAutoRangeIncludesZero(false);
        mafvDomain.setAutoRange(true);
        mafvDomain.setAutoRangeStickyZero(false);
        NumberAxis mafgsRange = new NumberAxis(YAxisName);
        mafgsRange.setAutoRangeIncludesZero(false);
        mafgsRange.setAutoRange(true);
        mafgsRange.setAutoRangeStickyZero(false);

        XYSeriesCollection lineDataset = new XYSeriesCollection();
        origMafData.setDescription(origMaf);
        newMafData.setDescription(newMaf);
        lineDataset.addSeries(origMafData);
        lineDataset.addSeries(newMafData);

        XYPlot plot = chart.getXYPlot();
        plot.setRangePannable(true);
        plot.setDomainPannable(true);
        plot.setDomainGridlinePaint(Color.DARK_GRAY);
        plot.setRangeGridlinePaint(Color.DARK_GRAY);
        plot.setBackgroundPaint(new Color(224, 224, 224));

        plot.setDataset(0, lineDataset);
        plot.setRenderer(0, lineRenderer);
        plot.setDomainAxis(0, mafvDomain);
        plot.setRangeAxis(0, mafgsRange);
        plot.mapDatasetToDomainAxis(0, 0);
        plot.mapDatasetToRangeAxis(0, 0);

        LegendTitle legend = new LegendTitle(plot.getRenderer());
        legend.setItemFont(new Font("Arial", 0, 10));
        legend.setPosition(RectangleEdge.TOP);
        chart.addLegend(legend);

    } catch (Exception e) {
        logger.error(e);
    }
}

From source file:com.vgi.mafscaling.Rescale.java

private void createControlPanel(JPanel dataPanel) {
    JPanel cntlPanel = new JPanel();
    GridBagConstraints gbl_ctrlPanel = new GridBagConstraints();
    gbl_ctrlPanel.insets = insets3;//from   w ww .  j ava 2  s.  c  o m
    gbl_ctrlPanel.anchor = GridBagConstraints.PAGE_START;
    gbl_ctrlPanel.fill = GridBagConstraints.HORIZONTAL;
    gbl_ctrlPanel.weightx = 1.0;
    gbl_ctrlPanel.gridx = 0;
    gbl_ctrlPanel.gridy = 0;
    dataPanel.add(cntlPanel, gbl_ctrlPanel);

    GridBagLayout gbl_cntlPanel = new GridBagLayout();
    gbl_cntlPanel.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
    gbl_cntlPanel.rowHeights = new int[] { 0, 0 };
    gbl_cntlPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
    gbl_cntlPanel.rowWeights = new double[] { 0 };
    cntlPanel.setLayout(gbl_cntlPanel);

    NumberFormat doubleFmt = NumberFormat.getNumberInstance();
    doubleFmt.setGroupingUsed(false);
    doubleFmt.setMaximumIntegerDigits(1);
    doubleFmt.setMinimumIntegerDigits(1);
    doubleFmt.setMaximumFractionDigits(3);
    doubleFmt.setMinimumFractionDigits(1);
    doubleFmt.setRoundingMode(RoundingMode.HALF_UP);

    NumberFormat scaleDoubleFmt = NumberFormat.getNumberInstance();
    scaleDoubleFmt.setGroupingUsed(false);
    scaleDoubleFmt.setMaximumIntegerDigits(1);
    scaleDoubleFmt.setMinimumIntegerDigits(1);
    scaleDoubleFmt.setMaximumFractionDigits(8);
    scaleDoubleFmt.setMinimumFractionDigits(1);
    scaleDoubleFmt.setRoundingMode(RoundingMode.HALF_UP);

    GridBagConstraints gbc_cntlPanelLabel = new GridBagConstraints();
    gbc_cntlPanelLabel.anchor = GridBagConstraints.EAST;
    gbc_cntlPanelLabel.insets = new Insets(2, 3, 2, 1);
    gbc_cntlPanelLabel.gridx = 0;
    gbc_cntlPanelLabel.gridy = 0;

    GridBagConstraints gbc_cntlPanelInput = new GridBagConstraints();
    gbc_cntlPanelInput.anchor = GridBagConstraints.WEST;
    gbc_cntlPanelInput.insets = new Insets(2, 1, 2, 3);
    gbc_cntlPanelInput.gridx = 1;
    gbc_cntlPanelInput.gridy = 0;

    cntlPanel.add(new JLabel("New Max V"), gbc_cntlPanelLabel);

    newMaxVFmtTextBox = new JFormattedTextField(doubleFmt);
    newMaxVFmtTextBox.setColumns(7);
    newMaxVFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            Object source = e.getSource();
            if (source == newMaxVFmtTextBox)
                updateNewMafScale();
        }
    });
    cntlPanel.add(newMaxVFmtTextBox, gbc_cntlPanelInput);

    gbc_cntlPanelLabel.gridx += 2;
    cntlPanel.add(new JLabel("Min V"), gbc_cntlPanelLabel);

    minVFmtTextBox = new JFormattedTextField(doubleFmt);
    minVFmtTextBox.setColumns(7);
    minVFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            Object source = e.getSource();
            if (source == minVFmtTextBox)
                updateNewMafScale();
        }
    });
    gbc_cntlPanelInput.gridx += 2;
    cntlPanel.add(minVFmtTextBox, gbc_cntlPanelInput);

    gbc_cntlPanelLabel.gridx += 2;
    cntlPanel.add(new JLabel("Max Unchanged"), gbc_cntlPanelLabel);

    maxVUnchangedFmtTextBox = new JFormattedTextField(doubleFmt);
    maxVUnchangedFmtTextBox.setColumns(7);
    maxVUnchangedFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            Object source = e.getSource();
            if (source == maxVUnchangedFmtTextBox)
                updateNewMafScale();
        }
    });
    gbc_cntlPanelInput.gridx += 2;
    cntlPanel.add(maxVUnchangedFmtTextBox, gbc_cntlPanelInput);

    gbc_cntlPanelLabel.gridx += 2;
    cntlPanel.add(new JLabel("Mode deltaV"), gbc_cntlPanelLabel);

    modeDeltaVFmtTextBox = new JFormattedTextField(scaleDoubleFmt);
    modeDeltaVFmtTextBox.setColumns(7);
    modeDeltaVFmtTextBox.setEditable(false);
    modeDeltaVFmtTextBox.setBackground(new Color(210, 210, 210));
    gbc_cntlPanelInput.gridx += 2;
    cntlPanel.add(modeDeltaVFmtTextBox, gbc_cntlPanelInput);
}

From source file:org.nuxeo.launcher.gui.NuxeoFrame.java

public NuxeoFrame(NuxeoLauncherGUI controller) throws HeadlessException {
    super("NuxeoCtl");
    setController(controller);//from  ww  w.  j  av a  2 s.c om

    // Main frame
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setIconImage(appIcon.getImage());
    getContentPane().setBackground(new Color(35, 37, 59));
    getContentPane().setLayout(new GridBagLayout());
    constraints = new GridBagConstraints();

    // Header (with main button inside)
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.anchor = GridBagConstraints.PAGE_START;
    JComponent header = buildHeader();
    header.setPreferredSize(new Dimension(480, 110));
    getContentPane().add(header, constraints);

    // Tabs
    constraints.fill = GridBagConstraints.BOTH;
    constraints.ipady = 100;
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    getContentPane().add(buildTabbedPanel(), constraints);

    // Footer
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.PAGE_END;
    constraints.ipady = 0;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.insets = new Insets(10, 0, 0, 0);
    getContentPane().add(buildFooter(), constraints);

    // debug((JComponent) this.getContentPane());
}