Example usage for java.awt Insets Insets

List of usage examples for java.awt Insets Insets

Introduction

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

Prototype

public Insets(int top, int left, int bottom, int right) 

Source Link

Document

Creates and initializes a new Insets object with the specified top, left, bottom, and right insets.

Usage

From source file:com.intel.stl.ui.monitor.view.PSNodesDetailsPanel.java

/**
 * Description:/*from   w w w.  jav  a 2s.c o m*/
 * 
 * @param name
 */
protected void initComponent() {
    setLayout(new BorderLayout(0, 0));
    setOpaque(false);
    setBorder(BorderFactory.createTitledBorder((Border) null));

    JPanel titlePanel = new JPanel(new BorderLayout(5, 1));
    titlePanel.setOpaque(false);
    numberLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN);
    numberLabel.setHorizontalAlignment(JLabel.RIGHT);
    titlePanel.add(numberLabel, BorderLayout.CENTER);
    nameLabel = ComponentFactory.getH3Label("", Font.PLAIN);
    nameLabel.setHorizontalAlignment(JLabel.LEFT);
    nameLabel.setVerticalAlignment(JLabel.BOTTOM);
    titlePanel.add(nameLabel, BorderLayout.EAST);
    add(titlePanel, BorderLayout.NORTH);

    JPanel mainPanel = new JPanel();
    mainPanel.setOpaque(false);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
    GridBagLayout gridBag = new GridBagLayout();
    mainPanel.setLayout(gridBag);
    GridBagConstraints gc = new GridBagConstraints();

    gc.weighty = 0;
    gc.insets = new Insets(8, 2, 2, 2);
    gc.weightx = 1;
    gc.gridwidth = 1;
    gc.gridheight = 2;
    // gc.gridheight = 3; // Should change to 3 if we add Route
    typeChartPanel = new ChartPanel(null);
    typeChartPanel.setPreferredSize(new Dimension(80, 60));
    mainPanel.add(typeChartPanel, gc);

    gc.fill = GridBagConstraints.BOTH;
    gc.insets = new Insets(12, 2, 2, 2);
    gc.weightx = 0;
    gc.gridheight = 1;
    swNumberLabel = createNumberLabel();
    mainPanel.add(swNumberLabel, gc);

    gc.gridwidth = GridBagConstraints.REMAINDER;
    swNameLabel = createNameLabel(STLConstants.K0048_SWITCHES.getValue());
    mainPanel.add(swNameLabel, gc);

    gc.insets = new Insets(2, 2, 6, 2);
    gc.gridwidth = 1;
    fiNumberLabel = createNumberLabel();
    mainPanel.add(fiNumberLabel, gc);

    gc.gridwidth = GridBagConstraints.REMAINDER;
    fiNameLabel = createNameLabel(STLConstants.K0052_HOSTS.getValue());
    mainPanel.add(fiNameLabel, gc);

    // gc.gridwidth = 1;
    // rtNumberLabel = ComponentFactory.getH4Label(
    // STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN);
    // rtNumberLabel.setHorizontalAlignment(JLabel.CENTER);
    // mainPanel.add(rtNumberLabel, gc);
    //
    // gc.gridwidth = GridBagConstraints.REMAINDER;
    // rtNameLabel = ComponentFactory.getH5Label(
    // STLConstants.K0050_ROUTERS.getValue(), Font.PLAIN);
    // rtNameLabel.setVerticalAlignment(JLabel.BOTTOM);
    // mainPanel.add(rtNameLabel, gc);

    add(mainPanel, BorderLayout.CENTER);

    JPanel bottomPanel = new JPanel(new GridBagLayout());
    bottomPanel.setOpaque(false);
    bottomPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, UIConstants.INTEL_BORDER_GRAY));
    gc = new GridBagConstraints();
    gc.insets = new Insets(0, 5, 1, 5);
    gc.fill = GridBagConstraints.BOTH;
    gc.weightx = 1;
    gc.gridheight = 2;
    otherPortsLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN);
    otherPortsLabel.setForeground(UIConstants.INTEL_GRAY);
    otherPortsLabel.setHorizontalAlignment(JLabel.RIGHT);
    bottomPanel.add(otherPortsLabel, gc);

    gc.gridwidth = GridBagConstraints.REMAINDER;
    gc.gridheight = 1;
    gc.weightx = 0;
    gc.weighty = 1;
    JLabel label = ComponentFactory.getH4Label(STLConstants.K1026_PORT_RESOURCE.getValue(), Font.PLAIN);
    label.setHorizontalAlignment(JLabel.LEFT);
    label.setVerticalAlignment(JLabel.BOTTOM);
    bottomPanel.add(label, gc);

    gc.weighty = 0;
    label = ComponentFactory.getH4Label(STLConstants.K2077_NOT_IN_FABRIC.getValue(), Font.PLAIN);
    label.setHorizontalAlignment(JLabel.LEFT);
    label.setVerticalAlignment(JLabel.BOTTOM);
    bottomPanel.add(label, gc);
    add(bottomPanel, BorderLayout.SOUTH);
}

From source file:dk.dma.epd.common.prototype.notification.StrategicRouteNotificationDetailPanelCommon.java

/**
 * Installs the given replyPanel at the top of the list of route messages
 * @param replyPanel the reply panel to install
 *//*www .  j  a va  2s  .  c o  m*/
public void addReplyPanelInMessagesPanel(JPanel replyPanel) {
    Insets insets = new Insets(5, 5, 0, 5);
    messagesPanel.add(replyPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets, 0, 0));
}

From source file:net.sourceforge.atunes.kernel.modules.state.RepositoryPanel.java

/**
 * Add components to panel//from   w  ww.j  a v a2s . co m
 */
private void setupPanel() {
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 10, 0, 0);
    add(new JLabel(I18nUtils.getString("REPOSITORY_REFRESH_TIME")), c);
    c.gridx = 1;
    c.weightx = 1;
    c.insets = new Insets(0, 10, 0, 0);
    add(this.refreshTime, c);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.insets = new Insets(10, 10, 0, 0);
    add(new JLabel(I18nUtils.getString("COMMAND_BEFORE_REPOSITORY_ACCESS")), c);
    c.gridx = 1;
    c.weightx = 1;
    add(this.commandBeforeAccessRepository, c);
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 0;
    add(new JLabel(I18nUtils.getString("COMMAND_AFTER_REPOSITORY_ACCESS")), c);
    c.gridx = 1;
    c.weightx = 1;
    add(this.commandAfterAccessRepository, c);
    c.gridx = 0;
    c.gridy = 3;
    c.insets = new Insets(20, 10, 0, 0);
    JScrollPane scrollPane = this.controlsBuilder.createScrollPane(this.repositoryFoldersList);
    scrollPane.setMinimumSize(new Dimension(400, 300));
    scrollPane.setPreferredSize(new Dimension(400, 300));
    add(scrollPane, c);
    JPanel addRemovePanel = new JPanel(new GridLayout(1, 2, 5, 0));
    addRemovePanel.add(this.addFolderButton);
    addRemovePanel.add(this.removeFolderButton);
    c.gridy = 4;
    c.insets = new Insets(10, 10, 0, 0);
    add(addRemovePanel, c);
    c.gridx = 0;
    c.gridy = 5;
    c.weighty = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    add(this.useRatingsStoredInTag, c);
}

From source file:com.web.vehiclerouting.optaplanner.common.swingui.SolverAndPersistenceFrame.java

private JComponent createQuickOpenPanel(List<Action> quickOpenActionList, List<File> fileList, String title) {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    if (fileList.isEmpty()) {
        JLabel noneLabel = new JLabel("None");
        noneLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
        panel.add(noneLabel);//  www.ja va2 s.  c  o m
    } else {
        for (File file : fileList) {
            Action quickOpenAction = new QuickOpenAction(file);
            quickOpenActionList.add(quickOpenAction);
            JButton quickOpenButton = new JButton(quickOpenAction);
            quickOpenButton.setHorizontalAlignment(SwingConstants.LEFT);
            quickOpenButton.setMargin(new Insets(0, 0, 0, 0));
            panel.add(quickOpenButton);
        }
    }
    JScrollPane scrollPane = new JScrollPane(panel);
    scrollPane.getVerticalScrollBar().setUnitIncrement(25);
    scrollPane.setMinimumSize(new Dimension(100, 80));
    // Size fits into screen resolution 1024*768
    scrollPane.setPreferredSize(new Dimension(180, 200));
    JPanel titlePanel = new JPanel(new BorderLayout());
    titlePanel.add(scrollPane, BorderLayout.CENTER);
    titlePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2),
            BorderFactory.createTitledBorder(title)));
    return titlePanel;
}

From source file:com.openbravo.pos.sales.restaurant.JRetailTicketsBagRestaurantMap.java

/**
 * Creates new form JTicketsBagRestaurant
 *//*  www  .jav  a  2 s .  co  m*/
public JRetailTicketsBagRestaurantMap(AppView app, RetailTicketsEditor panelticket, String businessType) {

    super(app, panelticket);
    this.m_App = app;
    dlReceipts = (DataLogicReceipts) app.getBean("com.openbravo.pos.sales.DataLogicReceipts");
    dlSales = (DataLogicSales) m_App.getBean("com.openbravo.pos.forms.DataLogicSales");
    dlSystem = (DataLogicSystem) m_App.getBean("com.openbravo.pos.forms.DataLogicSystem");

    m_restaurantmap = new JRetailTicketsBagRestaurant(app, this);
    m_PlaceCurrent = null;
    m_PlaceClipboard = null;
    customer = null;
    //Select all the floor details from db for showing the floor name in screen
    try {
        SentenceList sent = new StaticSentence(app.getSession(),
                "SELECT ID, NAME, IMAGE FROM FLOORS ORDER BY NAME", null, new SerializerReadClass(Floor.class));
        m_afloors = sent.list();

    } catch (BasicException eD) {
        m_afloors = new ArrayList<Floor>();
    }
    //Select all the tables details from db for showing the table names in screen
    try {
        SentenceList sent = new StaticSentence(app.getSession(),
                "SELECT ID, NAME, X, Y, FLOOR FROM PLACES WHERE NAME NOT LIKE 'takeaway' ORDER BY FLOOR", null,
                new SerializerReadClass(Place.class));
        m_aplaces = sent.list();
    } catch (BasicException eD) {
        m_aplaces = new ArrayList<Place>();
    }
    //Initialise the components
    initComponents();

    // add the Floors containers
    if (m_afloors.size() > 1) {
        // A tab container for 2 or more floors
        JTabbedPane jTabFloors = new JTabbedPane();
        jTabFloors.applyComponentOrientation(getComponentOrientation());
        jTabFloors.setBorder(new javax.swing.border.EmptyBorder(new Insets(5, 5, 5, 5)));
        jTabFloors.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
        jTabFloors.setFocusable(false);
        jTabFloors.setRequestFocusEnabled(false);
        m_jPanelMap.add(jTabFloors, BorderLayout.CENTER);

        for (Floor f : m_afloors) {
            f.getContainer().applyComponentOrientation(getComponentOrientation());

            JScrollPane jScrCont = new JScrollPane();
            jScrCont.applyComponentOrientation(getComponentOrientation());
            JPanel jPanCont = new JPanel();
            jPanCont.applyComponentOrientation(getComponentOrientation());

            jTabFloors.addTab(f.getName(), f.getIcon(), jScrCont);
            jScrCont.setViewportView(jPanCont);
            jPanCont.add(f.getContainer());
        }
    } else if (m_afloors.size() == 1) {
        // Just a frame for 1 floor
        Floor f = m_afloors.get(0);
        f.getContainer().applyComponentOrientation(getComponentOrientation());

        JPanel jPlaces = new JPanel();
        jPlaces.applyComponentOrientation(getComponentOrientation());
        jPlaces.setLayout(new BorderLayout());

        jPlaces.setBorder(new javax.swing.border.CompoundBorder(
                new javax.swing.border.EmptyBorder(new Insets(5, 5, 5, 5)),
                new javax.swing.border.TitledBorder(f.getName())));
        JScrollPane jScrCont = new JScrollPane();
        jScrCont.applyComponentOrientation(getComponentOrientation());
        JPanel jPanCont = new JPanel();
        jPanCont.applyComponentOrientation(getComponentOrientation());
        m_jPanelMap.add(jPlaces, BorderLayout.CENTER);
        jPlaces.add(jScrCont, BorderLayout.CENTER);
        jScrCont.setViewportView(jPanCont);
        jPanCont.add(f.getContainer());
    }

    // Add all the Table buttons.
    Floor currfloor = null;

    for (Place pl : m_aplaces) {
        int iFloor = 0;

        if (currfloor == null || !currfloor.getID().equals(pl.getFloor())) {
            // Look for a new floor
            do {
                currfloor = m_afloors.get(iFloor++);
            } while (!currfloor.getID().equals(pl.getFloor()));
        }

        currfloor.getContainer().add(pl.getButton());
        pl.setButtonBounds();
        pl.getButton().addActionListener(new MyActionListener(pl));
    }

    // Add the reservations panel
    m_jreservations = new JRetailTicketsBagRestaurantRes(app, this);
    add(m_jreservations, "res");
}

From source file:de.codesourcery.jasm16.ide.ui.utils.UIUtils.java

public static JFrame createMessageFrame(String title, String msg) {

    final JFrame frame = new JFrame(title);

    final JTextArea message = createMultiLineLabel(msg);

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout());

    final JPanel messagePanel = new JPanel();
    messagePanel.setLayout(new GridBagLayout());

    GridBagConstraints cnstrs = constraints(0, 0, true, false, GridBagConstraints.NONE);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;//from   w  w  w .j  a va2  s.  c o  m
    cnstrs.gridheight = 1;
    messagePanel.add(message, cnstrs);

    final JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());

    cnstrs = constraints(0, 0, true, false, GridBagConstraints.NONE);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = 1;
    cnstrs.weighty = 0;
    cnstrs.insets = new Insets(5, 2, 5, 2); // top,left,bottom,right           
    panel.add(messagePanel, cnstrs);

    cnstrs = constraints(0, 1, true, true, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = 1;
    cnstrs.weighty = 0;
    cnstrs.insets = new Insets(0, 2, 10, 2); // top,left,bottom,right      
    panel.add(buttonPanel, cnstrs);

    frame.getContentPane().add(panel);
    frame.pack();
    return frame;
}

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

/**
 * Initialize the contents of the frame.
 *///from  w w  w. j  av  a2 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.att.aro.ui.view.menu.tools.RegexWizard.java

public void init() {
    GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendViews("VideoParserWizard");
    setDefaultCloseOperation(RegexWizard.DISPOSE_ON_CLOSE);
    enableCheckBoxes(true);//  ww  w.  j  a va 2 s .c o m
    this.setSize(815, 800);
    this.setMaximumSize(new Dimension(815, 800));
    this.setMinimumSize(new Dimension(815, 700));
    this.setModal(false);
    this.setTitle(resourceBundle.getString("videoParser.wizard.title"));
    this.setLocationRelativeTo(getOwner());
    this.setAlwaysOnTop(true);
    this.setResizable(false);

    setLayout(new GridBagLayout());
    GridBagConstraints constraint = new GridBagConstraints();

    constraint.fill = GridBagConstraints.BOTH;
    constraint.gridx = 0;
    constraint.gridy = 0;
    constraint.weightx = 1;
    constraint.weighty = 0.6;
    constraint.gridwidth = 2;
    add(getFieldPanel(), constraint);

    constraint.gridy = 1;
    constraint.gridwidth = 1;
    constraint.weighty = 0.38;
    constraint.weightx = 0.4;
    constraint.insets = new Insets(0, 2, 0, 5);
    add(getMatcherPanel(), constraint);

    constraint.weightx = 0.5;
    constraint.gridx = 1;
    constraint.insets = new Insets(0, 1, 0, 2);
    add(getResultPanel(), constraint);

    constraint.weightx = 1;
    constraint.gridy = 2;
    constraint.gridx = 0;
    constraint.weighty = 0.02;
    constraint.gridwidth = 2;
    add(getBottomPanel(), constraint);

    this.addWindowListener(new WindowAdapter() {
        public void windowClosed(WindowEvent e) {
            clear();
        }
    });
    pack();
}

From source file:com.intel.stl.ui.main.view.StaDetailsPanel.java

/**
 * Description://from  www .  ja v a 2 s  .c  o m
 * 
 * @param sourceName
 */
protected void initComponent() {
    setLayout(new BorderLayout(0, 10));
    setOpaque(false);
    setBorder(BorderFactory.createTitledBorder((Border) null));

    JPanel titlePanel = new JPanel(new BorderLayout(5, 1));
    titlePanel.setOpaque(false);
    numberLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN);
    numberLabel.setHorizontalAlignment(JLabel.RIGHT);
    titlePanel.add(numberLabel, BorderLayout.CENTER);
    nameLabel = ComponentFactory.getH3Label("", Font.PLAIN);
    nameLabel.setHorizontalAlignment(JLabel.LEFT);
    nameLabel.setVerticalAlignment(JLabel.BOTTOM);
    titlePanel.add(nameLabel, BorderLayout.EAST);
    add(titlePanel, BorderLayout.NORTH);

    JPanel mainPanel = new JPanel();
    mainPanel.setOpaque(false);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
    GridBagLayout gridBag = new GridBagLayout();
    mainPanel.setLayout(gridBag);
    GridBagConstraints gc = new GridBagConstraints();

    gc.insets = new Insets(2, 2, 2, 2);
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.weightx = 1;
    gc.gridwidth = 1;
    gc.weighty = 0;
    failedChartPanel = new ChartPanel(null);
    failedChartPanel.setPreferredSize(new Dimension(60, 20));
    mainPanel.add(failedChartPanel, gc);

    gc.fill = GridBagConstraints.BOTH;
    gc.weightx = 0;
    failedNumberLabel = ComponentFactory.getH2Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.BOLD);
    failedNumberLabel.setForeground(UIConstants.INTEL_DARK_RED);
    failedNumberLabel.setHorizontalAlignment(JLabel.CENTER);
    mainPanel.add(failedNumberLabel, gc);

    gc.gridwidth = GridBagConstraints.REMAINDER;
    failedNameLabel = ComponentFactory.getH5Label(STLConstants.K0020_FAILED.getValue(), Font.PLAIN);
    failedNameLabel.setVerticalAlignment(JLabel.BOTTOM);
    mainPanel.add(failedNameLabel, gc);

    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.weightx = 1;
    gc.gridwidth = 1;
    skippedChartPanel = new ChartPanel(null);
    skippedChartPanel.setPreferredSize(new Dimension(60, 20));
    mainPanel.add(skippedChartPanel, gc);

    gc.fill = GridBagConstraints.BOTH;
    gc.weightx = 0;
    skippedNumberLabel = ComponentFactory.getH2Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.BOLD);
    skippedNumberLabel.setForeground(UIConstants.INTEL_DARK_ORANGE);
    skippedNumberLabel.setHorizontalAlignment(JLabel.CENTER);
    mainPanel.add(skippedNumberLabel, gc);

    gc.gridwidth = GridBagConstraints.REMAINDER;
    skippedNameLabel = ComponentFactory.getH5Label(STLConstants.K0021_SKIPPED.getValue(), Font.PLAIN);
    skippedNameLabel.setVerticalAlignment(JLabel.BOTTOM);
    mainPanel.add(skippedNameLabel, gc);

    gc.weighty = 0;
    gc.fill = GridBagConstraints.NONE;
    gc.insets = new Insets(8, 2, 2, 2);
    gc.weightx = 1;
    gc.gridwidth = 1;
    gc.gridheight = types.length;
    typeChartPanel = new ChartPanel(null);
    typeChartPanel.setPreferredSize(new Dimension(80, 60));
    mainPanel.add(typeChartPanel, gc);

    typeNumberLabels = new JLabel[types.length];
    typeNameLabels = new JLabel[types.length];
    gc.fill = GridBagConstraints.BOTH;
    gc.gridheight = 1;
    gc.insets = new Insets(12, 2, 2, 2);
    for (int i = 0; i < types.length; i++) {
        if (i == 1) {
            gc.insets = new Insets(2, 2, 2, 2);
        }

        gc.weightx = 0;
        gc.gridwidth = 1;
        typeNumberLabels[i] = createNumberLabel();
        mainPanel.add(typeNumberLabels[i], gc);

        gc.gridwidth = GridBagConstraints.REMAINDER;
        typeNameLabels[i] = createNameLabel(types[i].getName());
        mainPanel.add(typeNameLabels[i], gc);
    }

    gc.fill = GridBagConstraints.BOTH;
    mainPanel.add(Box.createGlue(), gc);

    add(mainPanel, BorderLayout.CENTER);
}

From source file:org.esa.beam.visat.toolviews.stat.ChartPagePanel.java

private JPanel createChartBottomPanel(final ChartPanel chartPanel) {

    final AbstractButton zoomAllButton = ToolButtonFactory.createButton(
            UIUtils.loadImageIcon("/com/bc/ceres/swing/actions/icons_22x22/view-fullscreen.png"), false);
    zoomAllButton.setToolTipText("Zoom all.");
    zoomAllButton.setName("zoomAllButton.");
    zoomAllButton.addActionListener(new ActionListener() {
        @Override/*from  w  ww  .j ava2 s . c o  m*/
        public void actionPerformed(ActionEvent e) {
            chartPanel.restoreAutoBounds();
            chartPanel.repaint();
        }
    });

    final AbstractButton propertiesButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/Edit24.gif"), false);
    propertiesButton.setToolTipText("Edit properties.");
    propertiesButton.setName("propertiesButton.");
    propertiesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            chartPanel.doEditChartProperties();
        }
    });

    final AbstractButton saveButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/Export24.gif"), false);
    saveButton.setToolTipText("Save chart as image.");
    saveButton.setName("saveButton.");
    saveButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                chartPanel.doSaveAs();
            } catch (IOException e1) {
                JOptionPane.showMessageDialog(chartPanel, "Could not save chart:\n" + e1.getMessage(), "Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    final AbstractButton printButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/Print24.gif"), false);
    printButton.setToolTipText("Print chart.");
    printButton.setName("printButton.");
    printButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            chartPanel.createChartPrintJob();
        }
    });

    final TableLayout tableLayout = new TableLayout(6);
    tableLayout.setColumnFill(4, TableLayout.Fill.HORIZONTAL);
    tableLayout.setColumnWeightX(4, 1.0);
    JPanel buttonPanel = new JPanel(tableLayout);
    tableLayout.setRowPadding(0, new Insets(0, 4, 0, 0));
    buttonPanel.add(zoomAllButton);
    tableLayout.setRowPadding(0, new Insets(0, 0, 0, 0));
    buttonPanel.add(propertiesButton);
    buttonPanel.add(saveButton);
    buttonPanel.add(printButton);
    buttonPanel.add(new JPanel());
    buttonPanel.add(getHelpButton());

    return buttonPanel;
}