Example usage for java.awt Insets set

List of usage examples for java.awt Insets set

Introduction

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

Prototype

public void set(int top, int left, int bottom, int right) 

Source Link

Document

Set top, left, bottom, and right to the specified values

Usage

From source file:ffx.ui.KeywordPanel.java

private void initialize() {
    // Load the Keyword Definitions
    loadXML();//  w  w  w. java2s .c o m
    // TextAreas
    flatfileTextArea = new JTextArea();
    flatfileTextArea.setEditable(false);
    flatfileTextArea.setFont(Font.decode("monospaced plain 12"));
    Insets insets = flatfileTextArea.getInsets();
    insets.set(5, 5, 5, 5);
    flatfileTextArea.setMargin(insets);
    // Keyword Edit Panel
    editPanel = new JPanel(flowLayout);
    ClassLoader loader = getClass().getClassLoader();
    ImageIcon icKeyPanel = new ImageIcon(loader.getResource("ffx/ui/icons/page_key.png"));
    noSystemLabel.setIcon(icKeyPanel);
    ImageIcon icon = new ImageIcon(loader.getResource("ffx/ui/icons/information.png"));
    noKeywordLabel.setIcon(icon);
    noKeywordPanel.add(noKeywordLabel);
    editScrollPane = new JScrollPane(editPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    descriptScrollPane = new JScrollPane(descriptTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    Border eb = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    descriptScrollPane.setBorder(eb);
    // Add the Keyword Group Panel and Decription Panel to a JSplitPane
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editScrollPane, descriptScrollPane);
    splitPane.setResizeWeight(1.0);
    splitPane.setOneTouchExpandable(true);
    statusLabel.setBorder(eb);
    // Add the main pieces to the overall KeywordPanel (except the ToolBar)
    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);
    add(statusLabel, BorderLayout.SOUTH);
    // Init the GridBagContraints
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.gridheight = 1;
    gridBagConstraints.gridwidth = 1;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    initToolBar();
    add(toolBar, BorderLayout.NORTH);
    setParamPath();
    loadPrefs();
    loadKeywordGroup();
}

From source file:ffx.ui.KeywordPanel.java

/**
 * Load up the Force Field X Keyword Definitions
 *//*from www .java2  s .  c  om*/
private void loadXML() {
    NodeList groups, keywords, values;
    Element group, keyword, value;
    String groupName;
    String keywordName, keywordDescription, keywordGUI;
    groups = null;
    try {
        // Build the Document from the keywords.xml file
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        db.setEntityResolver(new DTDResolver());
        URL keyURL = getClass().getClassLoader().getResource("ffx/ui/commands/keywords.xml");
        Document doc = db.parse(keyURL.openStream());
        Element document = doc.getDocumentElement();
        Element body = (Element) document.getElementsByTagName("body").item(0);
        groups = body.getElementsByTagName("section");
    } catch (ParserConfigurationException | SAXException | IOException e) {
        logger.warning(e.toString());
    }
    keywordHashMap = new LinkedHashMap<>();
    groupHashMap = new LinkedHashMap<>();
    groupHashMap.put("ACTIVE KEYWORDS", "Active Keywords");
    groupHashMap.put("FLAT FILE VIEW", "Flat File View");
    groupComboBox = new JComboBox<>();
    groupComboBox.addItem("Active Keywords");
    groupComboBox.addItem("Flat File View");
    descriptTextArea = new JTextArea();
    descriptTextArea.setLineWrap(true);
    descriptTextArea.setWrapStyleWord(true);
    Insets insets = descriptTextArea.getInsets();
    insets.set(5, 5, 5, 5);
    descriptTextArea.setMargin(insets);
    int length = groups.getLength();
    // Iterate through the Keyword Groups
    for (int i = 0; i < length; i++) {
        group = (Element) groups.item(i);
        groupName = group.getAttribute("name");
        groupComboBox.addItem(groupName);
        keywords = group.getElementsByTagName("subsection");
        int klength = keywords.getLength();
        for (int j = 0; j < klength; j++) {
            keyword = (Element) keywords.item(j);
            keywordName = keyword.getAttribute("name");
            Node text = keyword.getFirstChild();
            keywordDescription = text.getNodeValue().replace('\n', ' ');
            keywordDescription = keywordDescription.replaceAll("  +", " ");
            keywordGUI = keyword.getAttribute("rep");
            KeywordComponent.SwingRepresentation type;
            try {
                type = KeywordComponent.SwingRepresentation.valueOf(keywordGUI.toUpperCase());
            } catch (Exception e) {
                type = null;
                logger.log(Level.WARNING, "{0}: Unknown GUI Component - {1}",
                        new Object[] { keywordName, type });
                System.exit(-1);
            }
            KeywordComponent key;
            if (type == KeywordComponent.SwingRepresentation.CHECKBOXES
                    || type == KeywordComponent.SwingRepresentation.COMBOBOX) {
                values = keyword.getElementsByTagName("Value");
                String labels[] = new String[values.getLength()];
                for (int k = 0; k < values.getLength(); k++) {
                    value = (Element) values.item(k);
                    labels[k] = value.getAttribute("name");
                }
                key = new KeywordComponent(keywordName, groupName, type, keywordDescription, descriptTextArea,
                        labels);
            } else {
                key = new KeywordComponent(keywordName, groupName, type, keywordDescription, descriptTextArea);
            }
            keywordHashMap.put(keywordName.toUpperCase(), key);
            groupHashMap.put(groupName.toUpperCase(), groupName);
        }
    }
    groupComboBox.setSelectedIndex(0);
}

From source file:ffx.ui.ModelingPanel.java

private void initialize() {
    // Command Description
    descriptTextArea = new JTextArea();
    descriptTextArea.setEditable(false);
    descriptTextArea.setLineWrap(true);/*from www  .ja v  a 2s .c  o  m*/
    descriptTextArea.setWrapStyleWord(true);
    descriptTextArea.setDoubleBuffered(true);
    Insets insets = descriptTextArea.getInsets();
    insets.set(5, 5, 5, 5);
    descriptTextArea.setMargin(insets);
    descriptScrollPane = new JScrollPane(descriptTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    descriptScrollPane.setBorder(etchedBorder);
    // Command Input
    commandTextArea = new JTextArea();
    commandTextArea.setEditable(false);
    commandTextArea.setLineWrap(true);
    commandTextArea.setWrapStyleWord(true);
    commandTextArea.setDoubleBuffered(true);
    commandTextArea.setMargin(insets);
    // Command Options
    optionsTabbedPane = new JTabbedPane();
    statusLabel = new JLabel();
    statusLabel.setBorder(etchedBorder);
    statusLabel.setToolTipText("  Modeling command that will be executed");
    commandPanel = new JPanel(flowLayout);
    commandPanel.add(optionsTabbedPane);
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, commandPanel, descriptScrollPane);
    splitPane.setContinuousLayout(true);
    splitPane.setResizeWeight(1.0d);
    splitPane.setOneTouchExpandable(true);
    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);
    add(statusLabel, BorderLayout.SOUTH);
    // Initialize the Amino/Nucleic Acid ComboBox.
    acidComboBox.setEditable(false);
    acidComboBox.setMaximumSize(sizer.getPreferredSize());
    acidComboBox.setPreferredSize(sizer.getPreferredSize());
    acidComboBox.setMinimumSize(sizer.getPreferredSize());
    acidComboBox.setFont(Font.decode("Monospaced"));
    acidTextField.setMaximumSize(sizer.getPreferredSize());
    acidTextField.setMinimumSize(sizer.getPreferredSize());
    acidTextField.setPreferredSize(sizer.getPreferredSize());
    acidTextArea.setEditable(false);
    acidTextArea.setWrapStyleWord(true);
    acidTextArea.setLineWrap(true);
    acidTextArea.setFont(Font.decode("Monospaced"));
    acidScrollPane = new JScrollPane(acidTextArea);
    Dimension d = new Dimension(300, 400);
    acidScrollPane.setPreferredSize(d);
    acidScrollPane.setMaximumSize(d);
    acidScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    // Load the FFX commands.xml file that defines FFX commands.
    try {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        db.setEntityResolver(new DTDResolver());
        URL comURL = getClass().getClassLoader().getResource("ffx/ui/commands/commands.xml");
        Document doc = db.parse(comURL.openStream());
        NodeList nodelist = doc.getChildNodes();
        Node commandroot = null;
        for (int i = 0; i < nodelist.getLength(); i++) {
            commandroot = nodelist.item(i);
            if (commandroot.getNodeName().equals("FFXCommands") && commandroot instanceof Element) {
                break;
            }
        }
        if (commandroot == null || !(commandroot instanceof Element)) {
            commandList = null;
        }
        commandList = ((Element) commandroot).getElementsByTagName("Command");
    } catch (ParserConfigurationException | SAXException | IOException e) {
        System.err.println(e);
    } finally {
        if (commandList == null) {
            System.out.println("Force Field X commands.xml could not be parsed.");
            logger.severe("Force Field X will exit.");
            System.exit(-1);
        }
    }
    // Create a ComboBox with commands specific to each type of coordinate
    // file.
    xyzCommands = new JComboBox<>();
    intCommands = new JComboBox<>();
    arcCommands = new JComboBox<>();
    pdbCommands = new JComboBox<>();
    anyCommands = new JComboBox<>();
    Element command;
    String name;
    int numcommands = commandList.getLength();
    for (int i = 0; i < numcommands; i++) {
        command = (Element) commandList.item(i);
        name = command.getAttribute("name");
        String temp = command.getAttribute("fileType");
        if (temp.contains("ANY")) {
            temp = "XYZ INT ARC PDB";
            anyCommands.addItem(name);
        }
        String[] types = temp.split(" +");
        for (String type : types) {
            if (type.contains("XYZ")) {
                xyzCommands.addItem(name);
            }
            if (type.contains("INT")) {
                intCommands.addItem(name);
            }
            if (type.contains("ARC")) {
                arcCommands.addItem(name);
            }
            if (type.contains("PDB")) {
                pdbCommands.addItem(name);
            }
        }
    }
    initCommandComboBox(xyzCommands);
    initCommandComboBox(intCommands);
    initCommandComboBox(arcCommands);
    initCommandComboBox(pdbCommands);
    initCommandComboBox(anyCommands);
    currentCommandBox = anyCommands;
    activeCommand = (String) anyCommands.getSelectedItem();
    // Load the default Command.
    loadCommand();
    // Load the default Log File Settings.
    logSettings.setActionCommand("LogSettings");
    loadLogSettings();

    // Create the Toolbar.
    toolBar = new JToolBar("Modeling Commands", JToolBar.HORIZONTAL);
    toolBar.setLayout(new FlowLayout(FlowLayout.LEFT));
    jbLaunch = new JButton(new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/cog_go.png")));
    jbLaunch.setActionCommand("Launch");
    jbLaunch.setToolTipText("Launch the Force Field X Command");
    jbLaunch.addActionListener(this);
    insets.set(2, 2, 2, 2);
    jbLaunch.setMargin(insets);
    toolBar.add(jbLaunch);
    jbStop = new JButton(new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/stop.png")));
    jbStop.setActionCommand("End");
    jbStop.setToolTipText("Terminate the Current Force Field X Command");
    jbStop.addActionListener(this);
    jbStop.setMargin(insets);
    jbStop.setEnabled(false);
    toolBar.add(jbStop);
    toolBar.addSeparator();
    toolBar.add(anyCommands);
    currentCommandBox = anyCommands;
    toolBar.addSeparator();
    /*
     toolBar.add(logSettings);
     JButton jbdelete = new JButton(new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/page_delete.png")));
     jbdelete.setActionCommand("Delete");
     jbdelete.setToolTipText("Delete Log Files");
     jbdelete.addActionListener(this);
     jbdelete.setMargin(insets);
     toolBar.add(jbdelete);
     toolBar.addSeparator();
     */
    ImageIcon icinfo = new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/information.png"));
    descriptCheckBox = new JCheckBoxMenuItem(icinfo);
    descriptCheckBox.addActionListener(this);
    descriptCheckBox.setActionCommand("Description");
    descriptCheckBox.setToolTipText("Show/Hide Modeling Command Descriptions");
    descriptCheckBox.setMargin(insets);
    toolBar.add(descriptCheckBox);
    toolBar.add(new JLabel(""));
    toolBar.setBorderPainted(false);
    toolBar.setFloatable(false);
    toolBar.setRollover(true);
    add(toolBar, BorderLayout.NORTH);
    // Load ModelingPanel preferences.
    Preferences prefs = Preferences.userNodeForPackage(ffx.ui.ModelingPanel.class);
    descriptCheckBox.setSelected(!prefs.getBoolean("JobPanel_description", true));
    descriptCheckBox.doClick();
}

From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryFieldPanel.java

@Override
public void paint(Graphics g) {
    // TODO Auto-generated method stub
    super.paint(g);

    if (selected) {
        //this block was copied from RolloverCommand.paintComp()

        g.setColor(RolloverCommand.getActiveColor());
        Insets insets = getInsets();
        insets.set(1, 1, 1, 1);
        Dimension size = getSize();
        Graphics2D g2d = (Graphics2D) g;
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        RoundRectangle2D.Double rr = new RoundRectangle2D.Double(insets.left, insets.top,
                size.width - insets.right - insets.left, size.height - insets.bottom - insets.top, 10, 10);
        g2d.draw(rr);/*from  www .j  a va  2s  .co  m*/
        rr = new RoundRectangle2D.Double(insets.left + 1, insets.top + 1,
                size.width - insets.right - insets.left - 2, size.height - insets.bottom - insets.top - 2, 10,
                10);
        g2d.draw(rr);
    }
}