Example usage for javax.swing Box Box

List of usage examples for javax.swing Box Box

Introduction

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

Prototype

public Box(int axis) 

Source Link

Document

Creates a Box that displays its components along the specified axis.

Usage

From source file:psidev.psi.mi.filemakers.xmlMaker.gui.XsdTreePanelImpl.java

/**
 * create a button panel that includes buttons for loading the schema, to
 * associate a node to a flat file, a cell a default value or to specify
 * that a value should be automaticaly generated, to get informations about
 * the node, print the XML file or just have a preview of it.
 *//*from   w  w w.  ja v a  2  s .  c  o m*/
public Box getButtonPanel() {
    // associationLabel.setEditable(false);

    Box buttonsPanel = new Box(BoxLayout.Y_AXIS);

    JPanel treeBox = new JPanel();//
    treeBox.setLayout(new BoxLayout(treeBox, BoxLayout.Y_AXIS));// (BoxLayout.Y_AXIS);

    // Box mappingBox = new Box(BoxLayout.Y_AXIS);
    // mappingBox.setBorder(new TitledBorder("Mapping"));

    Box associationBox = new Box(BoxLayout.Y_AXIS);
    associationBox.setBorder(new TitledBorder("Associations"));

    Box nodeBox = new Box(BoxLayout.Y_AXIS);
    nodeBox.setBorder(new TitledBorder("Node"));

    Box outputBox = new Box(BoxLayout.Y_AXIS);
    outputBox.setBorder(new TitledBorder("Output"));

    /* add a button for loading a XML Schema */
    JButton loadFileb = new JButton("Open File");
    Utils.setDefaultSize(loadFileb);
    loadFileb.addActionListener(new LoadSchemaListener());

    JButton loadURLb = new JButton("Open URL");
    Utils.setDefaultSize(loadURLb);
    loadURLb.addActionListener(new LoadURLSchemaListener());

    JButton setIdb = new JButton("Prefix");
    Utils.setDefaultSize(setIdb);
    setIdb.addActionListener(new SetIdListener());

    /* add a button for duplicate a node (in case of lists) */
    JButton duplicateb = new JButton("Duplicate");
    Utils.setDefaultSize(duplicateb);
    duplicateb.addActionListener(new DuplicateListener());

    /* add a button for restauring original choice */
    JButton choiceb = new JButton("Restore");
    Utils.setDefaultSize(choiceb);
    choiceb.addActionListener(new OriginalNodeListener());

    JButton infosb = new JButton("About");
    Utils.setDefaultSize(infosb);
    infosb.addActionListener(new InfosListener());

    JButton checkb = new JButton("Check");
    Utils.setDefaultSize(checkb);
    checkb.addActionListener(new CheckListener());

    JButton previewb = new JButton("Preview");
    Utils.setDefaultSize(previewb);
    previewb.addActionListener(new PreviewListener());

    JButton printb = new JButton("Make XML");
    Utils.setDefaultSize(printb);
    printb.addActionListener(new PrintListener());

    treeBox.add(loadFileb);
    treeBox.add(loadURLb);
    treeBox.add(setIdb);
    treeBox.add(checkb);
    treeBox.setBorder(new TitledBorder("Schema"));

    nodeBox.add(duplicateb);
    nodeBox.add(choiceb);
    nodeBox.add(infosb);

    outputBox.add(previewb);
    outputBox.add(printb);

    associationButtons = new ButtonGroup();

    fieldAssociation = new JRadioButton("to field");
    duplicableFieldAssociation = new JRadioButton("to duplicable field");
    dictionnaryAssociation = new JRadioButton("to dictionnary");
    defaultAssociation = new JRadioButton("to default value");
    autoGenerationAssociationButton = new JRadioButton("to automatic value");
    flatFileAssociation = new JRadioButton("to flat file");

    associationButtons.add(flatFileAssociation);
    associationButtons.add(duplicableFieldAssociation);
    associationButtons.add(fieldAssociation);
    associationButtons.add(dictionnaryAssociation);
    associationButtons.add(defaultAssociation);
    associationButtons.add(autoGenerationAssociationButton);
    associationButtons.setSelected(flatFileAssociation.getModel(), true);

    JButton genericAssociationb = new JButton("Associate");
    Utils.setDefaultSize(genericAssociationb);
    genericAssociationb.addActionListener(new GenericAssociationListener());

    JButton genericCancelAssociationb = new JButton("Cancel");
    Utils.setDefaultSize(genericCancelAssociationb);
    genericCancelAssociationb.addActionListener(new GenericCancelAssociationListener());

    associationBox.add(flatFileAssociation);

    associationBox.add(duplicableFieldAssociation);

    associationBox.add(fieldAssociation);
    JButton editFieldb = new JButton("validation");
    Utils.setDefaultSize(editFieldb);
    editFieldb.addActionListener(new EditFieldAssociationListener());
    associationBox.add(editFieldb);
    associationBox.add(dictionnaryAssociation);
    associationBox.add(defaultAssociation);
    associationBox.add(defaultAssociation);
    associationBox.add(autoGenerationAssociationButton);

    associationBox.add(genericAssociationb);
    associationBox.add(genericCancelAssociationb);

    buttonsPanel.add(treeBox);
    buttonsPanel.add(associationBox);
    buttonsPanel.add(nodeBox);
    buttonsPanel.add(outputBox);
    // lineBox2.add(lineBox2);
    // buttonsPanel.add(lineBox3);
    return buttonsPanel;
}

From source file:greenfoot.gui.export.ExportPublishPane.java

/**
 * Build a help box with a link to appropriate help
 * @return help box//from w ww  .  jav a 2s  . com
 */
private static Box getHelpBox() {
    Box helpBox = new Box(BoxLayout.X_AXIS);
    helpBox.setAlignmentX(LEFT_ALIGNMENT);
    JLabel helpText1 = new JLabel(helpLine1 + " (");
    helpBox.add(helpText1);
    JLabel serverLink = new JLabel(serverURL);
    GreenfootUtil.makeLink(serverLink, serverURL);
    helpBox.add(serverLink);
    helpBox.add(new JLabel(")"));
    return helpBox;
}

From source file:psidev.psi.mi.filemakers.xmlMaker.XmlMakerGui.java

public XmlMakerGui() {
    super("XML Maker");

    /* look n'feel */
    try {//from w w w .  j a v  a  2 s .c  om
        //         UIManager.setLookAndFeel(new TonicLookAndFeel());
    } catch (Exception e) {
        System.out.println("Unable to load look'n feel");
    }

    getContentPane().setLayout(new BorderLayout());

    xsdTree = new XsdTreeStructImpl();
    JTextPaneMessageManager messageManager = new JTextPaneMessageManager();
    xsdTree.setMessageManager(messageManager);
    treePanel = new XsdTreePanelImpl(xsdTree, messageManager);

    flatFileTabbedPanel = new FlatFileTabbedPanel(xsdTree.flatFiles);
    flatFileTabbedPanel.setBorder(new TitledBorder("Flat files"));

    dictionnaryLists = new DictionaryPanel(xsdTree.dictionaries);
    dictionnaryLists.setBorder(new TitledBorder("Dictionnary"));

    Box associationsPanels = new Box(BoxLayout.Y_AXIS);

    associationsPanels.add(flatFileTabbedPanel);

    associationsPanels.add(dictionnaryLists);
    getContentPane().add(associationsPanels, BorderLayout.WEST);

    getContentPane().add(treePanel, BorderLayout.CENTER);

    treePanel.setTabFileTabbedPanel(flatFileTabbedPanel);
    treePanel.setDictionnaryPanel(dictionnaryLists);
    final CloseView fv = new CloseView();
    addWindowListener(fv);
    setJMenuBar(new XmlMakerMenu());
    //      setSize(800, 600);
    this.pack();
    setVisible(true);

    if (mappingFileName != null) {
        load(new File(mappingFileName));
    }

}

From source file:TransformExplorer.java

Box translationPanel() {
    Box panel = new Box(BoxLayout.Y_AXIS);

    panel.add(new LeftAlignComponent(new JLabel("Translation Offset")));

    // X translation label, slider, and value label
    FloatLabelJSlider coneTranslateXSlider = new FloatLabelJSlider("X", 0.1f, -2.0f, 2.0f, coneTranslation.x);
    coneTranslateXSlider.setMajorTickSpacing(1.0f);
    coneTranslateXSlider.setPaintTicks(true);
    coneTranslateXSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            coneTranslation.x = e.getValue();
            if (useCompoundTransform) {
                updateUsingCompoundTransform();
            } else {
                setConeTranslation();/*from w w  w  .j  a va  2s .co  m*/
            }
        }
    });
    panel.add(coneTranslateXSlider);

    // Y translation label, slider, and value label
    FloatLabelJSlider coneTranslateYSlider = new FloatLabelJSlider("Y", 0.1f, -2.0f, 2.0f, coneTranslation.y);
    coneTranslateYSlider.setMajorTickSpacing(1.0f);
    coneTranslateYSlider.setPaintTicks(true);
    coneTranslateYSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            coneTranslation.y = e.getValue();
            if (useCompoundTransform) {
                updateUsingCompoundTransform();
            } else {
                setConeTranslation();
            }
        }
    });
    panel.add(coneTranslateYSlider);

    // Z translation label, slider, and value label
    FloatLabelJSlider coneTranslateZSlider = new FloatLabelJSlider("Z", 0.1f, -2.0f, 2.0f, coneTranslation.z);
    coneTranslateZSlider.setMajorTickSpacing(1.0f);
    coneTranslateZSlider.setPaintTicks(true);
    coneTranslateZSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            coneTranslation.z = e.getValue();
            if (useCompoundTransform) {
                updateUsingCompoundTransform();
            } else {
                setConeTranslation();
            }
        }
    });
    panel.add(coneTranslateZSlider);

    return panel;
}

From source file:sim.util.media.chart.ChartGenerator.java

/** Generates a new ChartGenerator with a blank chart.  Before anything else, buildChart() is called.  */
public ChartGenerator() {
    // create the chart
    buildChart();/*from  ww w .j  av a 2s.c  o m*/
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.setAntiAlias(true);

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    split.setBorder(new EmptyBorder(0, 0, 0, 0));
    JScrollPane scroll = new JScrollPane();
    JPanel b = new JPanel();
    b.setLayout(new BorderLayout());
    b.add(seriesAttributes, BorderLayout.NORTH);
    b.add(new JPanel(), BorderLayout.CENTER);
    scroll.getViewport().setView(b);
    scroll.setBackground(getBackground());
    scroll.getViewport().setBackground(getBackground());
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());

    LabelledList list = new LabelledList("Chart Properties");
    DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list);
    globalAttributes.add(pan1);

    JLabel j = new JLabel("Right-Click or Control-Click");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);
    j = new JLabel("on Chart for More Options");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);

    titleField = new PropertyField() {
        public String newValue(String newValue) {
            setTitle(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    titleField.setValue(chart.getTitle().getText());

    list.add(new JLabel("Title"), titleField);

    buildGlobalAttributes(list);

    final JCheckBox legendCheck = new JCheckBox();
    ItemListener il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                LegendTitle title = new LegendTitle(chart.getPlot());
                title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4));
                chart.addLegend(title);
            } else {
                chart.removeLegend();
            }
        }
    };
    legendCheck.addItemListener(il);
    list.add(new JLabel("Legend"), legendCheck);
    legendCheck.setSelected(true);

    /*
      final JCheckBox aliasCheck = new JCheckBox();
      aliasCheck.setSelected(chart.getAntiAlias());
      il = new ItemListener()
      {
      public void itemStateChanged(ItemEvent e)
      {
      chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED );
      }
      };
      aliasCheck.addItemListener(il);
      list.add(new JLabel("Antialias"), aliasCheck);
    */

    JPanel pdfButtonPanel = new JPanel();
    pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output"));
    DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel);

    pdfButtonPanel.setLayout(new BorderLayout());
    Box pdfbox = new Box(BoxLayout.Y_AXIS);
    pdfButtonPanel.add(pdfbox, BorderLayout.WEST);

    JButton pdfButton = new JButton("Save as PDF");
    pdfbox.add(pdfButton);
    pdfButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE);
            fd.setFile(chart.getTitle().getText() + ".pdf");
            fd.setVisible(true);
            String fileName = fd.getFile();
            if (fileName != null) {
                Dimension dim = chartPanel.getPreferredSize();
                PDFEncoder.generatePDF(chart, dim.width, dim.height,
                        new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf")));
            }
        }
    });
    movieButton = new JButton("Create a Movie");
    pdfbox.add(movieButton);
    pdfbox.add(Box.createGlue());
    movieButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (movieMaker == null)
                startMovie();
            else
                stopMovie();
        }
    });

    globalAttributes.add(pan2);

    // we add into an outer box so we can later on add more global seriesAttributes
    // as the user instructs and still have glue be last
    Box outerAttributes = Box.createVerticalBox();
    outerAttributes.add(globalAttributes);
    outerAttributes.add(Box.createGlue());

    p.add(outerAttributes, BorderLayout.NORTH);
    p.add(scroll, BorderLayout.CENTER);
    p.setMinimumSize(new Dimension(0, 0));
    p.setPreferredSize(new Dimension(200, 0));
    split.setLeftComponent(p);

    // Add scale and proportion fields
    Box header = Box.createHorizontalBox();

    final double MAXIMUM_SCALE = 8;

    fixBox = new JCheckBox("Fill");
    fixBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setFixed(fixBox.isSelected());
        }
    });
    header.add(fixBox);
    fixBox.setSelected(true);

    // add the scale field
    scaleField = new NumberTextField("  Scale: ", 1.0, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0)
                newValue = currentValue;
            if (newValue > MAXIMUM_SCALE)
                newValue = currentValue;
            scale = newValue;
            resizeChart();
            return newValue;
        }
    };
    scaleField.setToolTipText("Zoom in and out");
    scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    scaleField.setEnabled(false);
    scaleField.setText("");
    header.add(scaleField);

    // add the proportion field
    proportionField = new NumberTextField("  Proportion: ", 1.5, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0)
                newValue = currentValue;
            proportion = newValue;
            resizeChart();
            return newValue;
        }
    };
    proportionField.setToolTipText("Change the chart proportions (ratio of width to height)");
    proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    header.add(proportionField);

    chartHolder.setMinimumSize(new Dimension(0, 0));
    chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    chartHolder.getViewport().setBackground(Color.gray);
    JPanel p2 = new JPanel();
    p2.setLayout(new BorderLayout());
    p2.add(chartHolder, BorderLayout.CENTER);
    p2.add(header, BorderLayout.NORTH);
    split.setRightComponent(p2);
    setLayout(new BorderLayout());
    add(split, BorderLayout.CENTER);

    // set the default to be white, which looks good when printed
    chart.setBackgroundPaint(Color.WHITE);

    // JFreeChart has a hillariously broken way of handling font scaling.
    // It allows fonts to scale independently in X and Y.  We hack a workaround here.
    chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION),
            (int) (DEFAULT_CHART_HEIGHT)));
}

From source file:edu.gmu.cs.sim.util.media.chart.ChartGenerator.java

/** Generates a new ChartGenerator with a blank chart.  Before anything else, buildChart() is called.  */
public ChartGenerator() {
    // create the chart
    buildChart();/*from www. ja  va 2s  .  c o m*/
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.setAntiAlias(true);

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    split.setBorder(new EmptyBorder(0, 0, 0, 0));
    JScrollPane scroll = new JScrollPane();
    JPanel b = new JPanel();
    b.setLayout(new BorderLayout());
    b.add(seriesAttributes, BorderLayout.NORTH);
    b.add(new JPanel(), BorderLayout.CENTER);
    scroll.getViewport().setView(b);
    scroll.setBackground(getBackground());
    scroll.getViewport().setBackground(getBackground());
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());

    LabelledList list = new LabelledList("Chart Properties");
    DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list);
    globalAttributes.add(pan1);

    JLabel j = new JLabel("Right-Click or Control-Click");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);
    j = new JLabel("on Chart for More Options");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);

    titleField = new PropertyField() {
        public String newValue(String newValue) {
            setTitle(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    titleField.setValue(chart.getTitle().getText());

    list.add(new JLabel("Title"), titleField);

    buildGlobalAttributes(list);

    final JCheckBox legendCheck = new JCheckBox();
    ItemListener il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                LegendTitle title = new LegendTitle(chart.getPlot());
                title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4));
                chart.addLegend(title);
            } else {
                chart.removeLegend();
            }
        }
    };
    legendCheck.addItemListener(il);
    list.add(new JLabel("Legend"), legendCheck);
    legendCheck.setSelected(true);

    /*
      final JCheckBox aliasCheck = new JCheckBox();
      aliasCheck.setSelected(chart.getAntiAlias());
      il = new ItemListener()
      {
      public void itemStateChanged(ItemEvent e)
      {
      chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED );
      }
      };
      aliasCheck.addItemListener(il);
      list.add(new JLabel("Antialias"), aliasCheck);
    */

    JPanel pdfButtonPanel = new JPanel();
    pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output"));
    DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel);

    pdfButtonPanel.setLayout(new BorderLayout());
    Box pdfbox = new Box(BoxLayout.Y_AXIS);
    pdfButtonPanel.add(pdfbox, BorderLayout.WEST);

    JButton pdfButton = new JButton("Save as PDF");
    pdfbox.add(pdfButton);
    pdfButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE);
            fd.setFile(chart.getTitle().getText() + ".pdf");
            fd.setVisible(true);
            String fileName = fd.getFile();
            if (fileName != null) {
                Dimension dim = chartPanel.getPreferredSize();
                PDFEncoder.generatePDF(chart, dim.width, dim.height,
                        new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf")));
            }
        }
    });
    movieButton = new JButton("Create a Movie");
    pdfbox.add(movieButton);
    pdfbox.add(Box.createGlue());
    movieButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (movieMaker == null) {
                startMovie();
            } else {
                stopMovie();
            }
        }
    });

    globalAttributes.add(pan2);

    // we add into an outer box so we can later on add more global seriesAttributes
    // as the user instructs and still have glue be last
    Box outerAttributes = Box.createVerticalBox();
    outerAttributes.add(globalAttributes);
    outerAttributes.add(Box.createGlue());

    p.add(outerAttributes, BorderLayout.NORTH);
    p.add(scroll, BorderLayout.CENTER);
    p.setMinimumSize(new Dimension(0, 0));
    p.setPreferredSize(new Dimension(200, 0));
    split.setLeftComponent(p);

    // Add scale and proportion fields
    Box header = Box.createHorizontalBox();

    final double MAXIMUM_SCALE = 8;

    fixBox = new JCheckBox("Fill");
    fixBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setFixed(fixBox.isSelected());
        }
    });
    header.add(fixBox);
    fixBox.setSelected(true);

    // add the scale field
    scaleField = new NumberTextField("  Scale: ", 1.0, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0) {
                newValue = currentValue;
            }
            if (newValue > MAXIMUM_SCALE) {
                newValue = currentValue;
            }
            scale = newValue;
            resizeChart();
            return newValue;
        }
    };
    scaleField.setToolTipText("Zoom in and out");
    scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    scaleField.setEnabled(false);
    scaleField.setText("");
    header.add(scaleField);

    // add the proportion field
    proportionField = new NumberTextField("  Proportion: ", 1.5, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0) {
                newValue = currentValue;
            }
            proportion = newValue;
            resizeChart();
            return newValue;
        }
    };
    proportionField.setToolTipText("Change the chart proportions (ratio of width to height)");
    proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    header.add(proportionField);

    chartHolder.setMinimumSize(new Dimension(0, 0));
    chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    chartHolder.getViewport().setBackground(Color.gray);
    JPanel p2 = new JPanel();
    p2.setLayout(new BorderLayout());
    p2.add(chartHolder, BorderLayout.CENTER);
    p2.add(header, BorderLayout.NORTH);
    split.setRightComponent(p2);
    setLayout(new BorderLayout());
    add(split, BorderLayout.CENTER);

    // set the default to be white, which looks good when printed
    chart.setBackgroundPaint(Color.WHITE);

    // JFreeChart has a hillariously broken way of handling font scaling.
    // It allows fonts to scale independently in X and Y.  We hack a workaround here.
    chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION),
            (int) (DEFAULT_CHART_HEIGHT)));
}

From source file:PolygonOffset.java

FloatLabelJSlider(String name, float resolution, float min, float max, float current) {

    this.resolution = resolution;
    this.min = min;
    this.max = max;
    this.current = current;

    if (resolution < minResolution) {
        resolution = minResolution;//w w  w .  j  a v a  2 s.c  o m
    }

    // round scale to nearest integer fraction. i.e. 0.3 => 1/3 = 0.33
    scale = (float) Math.round(1.0f / resolution);
    resolution = 1.0f / scale;

    // get the integer versions of max, min, current
    minInt = Math.round(min * scale);
    maxInt = Math.round(max * scale);
    curInt = Math.round(current * scale);

    // sliders use integers, so scale our floating point value by "scale"
    // to make each slider "notch" be "resolution". We will scale the
    // value down by "scale" when we get the event.
    slider = new JSlider(JSlider.HORIZONTAL, minInt, maxInt, curInt);
    slider.addChangeListener(this);

    valueLabel = new JLabel(" ");

    // set the initial value label
    setLabelString();

    // add min and max labels to the slider
    Hashtable labelTable = new Hashtable();
    labelTable.put(new Integer(minInt), new JLabel(nf.format(min)));
    labelTable.put(new Integer(maxInt), new JLabel(nf.format(max)));
    slider.setLabelTable(labelTable);
    slider.setPaintLabels(true);

    /* layout to align left */
    setLayout(new BorderLayout());
    Box box = new Box(BoxLayout.X_AXIS);
    add(box, BorderLayout.WEST);

    box.add(new JLabel(name));
    box.add(slider);
    box.add(valueLabel);
}

From source file:org.ayound.js.debug.ui.DebugMainFrame.java

private void initToolBar() {
    toolBar = new JToolBar();

    Container debugInfoContainer = new Box(BoxLayout.LINE_AXIS);
    toolBar.add(debugInfoContainer);/* ww w .ja v a 2  s  . c o m*/

    JLabel urlLabel = new JLabel(Messages.getString("DebugMainFrame.UrlLabel")); //$NON-NLS-1$
    debugInfoContainer.add(urlLabel);

    urlText = new JTextField(20);
    String historyUrl = ConfigUtil.getPropertie("url");
    if (historyUrl == null) {
        File testFile = new File(new File(getBaseDir()), "test/test.htm"); //$NON-NLS-1$
        urlText.setText(testFile.getAbsolutePath().replace('\\', '/'));
    } else {
        urlText.setText(historyUrl);
    }
    debugInfoContainer.add(urlText);

    urlButton = new JButton(Messages.getString("DebugMainFrame.Select")); //$NON-NLS-1$
    urlButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            JFileChooser fileDialog = new JFileChooser(); // 
            fileDialog.setFileFilter(new FileFilter() {

                @Override
                public boolean accept(File f) {
                    String fileName = f.getName().toLowerCase();
                    if (fileName.endsWith(".htm") //$NON-NLS-1$
                            || fileName.endsWith(".html") //$NON-NLS-1$
                            || f.isDirectory()) {
                        return true;
                    } else {
                        return false;
                    }

                }

                @Override
                public String getDescription() {
                    return ".htm,.html"; //$NON-NLS-1$
                }
            });
            int result = fileDialog.showOpenDialog(DebugMainFrame.this);
            if (result == JFileChooser.APPROVE_OPTION) {
                urlText.setText(fileDialog.getSelectedFile().getAbsolutePath());
            }
        }
    });
    debugInfoContainer.add(urlButton);

    JLabel portLabel = new JLabel(Messages.getString("DebugMainFrame.PortLabel")); //$NON-NLS-1$
    debugInfoContainer.add(portLabel);

    portText = new JTextField(2);
    portText.setText("8088"); //$NON-NLS-1$
    debugInfoContainer.add(portText);

    JLabel browserLabel = new JLabel(Messages.getString("DebugMainFrame.BrowserLabel")); //$NON-NLS-1$
    debugInfoContainer.add(browserLabel);

    browserText = new JTextField(20);
    debugInfoContainer.add(browserText);
    String historyBrowser = ConfigUtil.getPropertie("browser");
    if (historyBrowser != null) {
        browserText.setText(historyBrowser);
        // .setText("C:\\Program Files\\Internet Explorer\\iexplore.exe");
        // //$NON-NLS-1$
    }

    browserButton = new JButton(Messages.getString("DebugMainFrame.Select")); //$NON-NLS-1$
    browserButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            JFileChooser fileDialog = new JFileChooser(); // 
            fileDialog.setFileFilter(new FileFilter() {

                @Override
                public boolean accept(File f) {
                    String fileName = f.getName().toLowerCase();
                    if (fileName.endsWith(".exe") || f.isDirectory()) { //$NON-NLS-1$
                        return true;
                    } else {
                        return false;
                    }

                }

                @Override
                public String getDescription() {
                    return ".exe(windows)"; //$NON-NLS-1$
                }
            });
            int result = fileDialog.showOpenDialog(DebugMainFrame.this);
            if (result == JFileChooser.APPROVE_OPTION) {
                browserText.setText(fileDialog.getSelectedFile().getAbsolutePath());
            }
        }
    });
    debugInfoContainer.add(browserButton);

    toolBar.addSeparator();

    JButton startBtn = toolBar.add(actionDebugStart);
    startBtn.setToolTipText(Messages.getString("DebugMainFrame.StartDebug")); //$NON-NLS-1$

    JButton endBtn = toolBar.add(actionDebugEnd);
    endBtn.setToolTipText(Messages.getString("DebugMainFrame.EndDebug")); //$NON-NLS-1$

    getContentPane().add(toolBar, BorderLayout.BEFORE_FIRST_LINE);
}

From source file:TransformExplorer.java

Box scalePanel() {
    Box panel = new Box(BoxLayout.Y_AXIS);

    // Uniform Scale
    JLabel uniform = new JLabel("Uniform Scale");
    panel.add(new LeftAlignComponent(uniform));

    FloatLabelJSlider coneScaleSlider = new FloatLabelJSlider("S:", 0.1f, 0.0f, 3.0f, coneScale);
    coneScaleSlider.setMajorTickSpacing(1.0f);
    coneScaleSlider.setPaintTicks(true);
    coneScaleSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            coneScale = e.getValue();//  ww w. ja  v a  2 s . c  o  m
            useUniformScale = true;
            if (useCompoundTransform) {
                updateUsingCompoundTransform();
            } else {
                setConeUScale();
            }
        }
    });
    panel.add(coneScaleSlider);

    JLabel nonUniform = new JLabel("Non-Uniform Scale");
    panel.add(new LeftAlignComponent(nonUniform));

    // Non-Uniform Scale
    FloatLabelJSlider coneNUScaleXSlider = new FloatLabelJSlider("X: ", 0.1f, 0.0f, 3.0f,
            (float) coneNUScale.x);
    coneNUScaleXSlider.setMajorTickSpacing(1.0f);
    coneNUScaleXSlider.setPaintTicks(true);
    coneNUScaleXSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            coneNUScale.x = (double) e.getValue();
            useUniformScale = false;
            if (useCompoundTransform) {
                updateUsingCompoundTransform();
            } else {
                setConeNUScale();
            }
        }
    });
    panel.add(coneNUScaleXSlider);

    FloatLabelJSlider coneNUScaleYSlider = new FloatLabelJSlider("Y: ", 0.1f, 0.0f, 3.0f,
            (float) coneNUScale.y);
    coneNUScaleYSlider.setMajorTickSpacing(1.0f);
    coneNUScaleYSlider.setPaintTicks(true);
    coneNUScaleYSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            coneNUScale.y = (double) e.getValue();
            useUniformScale = false;
            if (useCompoundTransform) {
                updateUsingCompoundTransform();
            } else {
                setConeNUScale();
            }
        }
    });
    panel.add(coneNUScaleYSlider);

    FloatLabelJSlider coneNUScaleZSlider = new FloatLabelJSlider("Z: ", 0.1f, 0.0f, 3.0f,
            (float) coneNUScale.z);
    coneNUScaleZSlider.setMajorTickSpacing(1.0f);
    coneNUScaleZSlider.setPaintTicks(true);
    coneNUScaleZSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            coneNUScale.z = (double) e.getValue();
            useUniformScale = false;
            if (useCompoundTransform) {
                updateUsingCompoundTransform();
            } else {
                setConeNUScale();
            }
        }
    });
    panel.add(coneNUScaleZSlider);

    return panel;
}

From source file:org.apache.jmeter.gui.MainFrame.java

/**
 * Create the JMeter tool bar pane containing the running indicator.
 *
 * @return a panel containing the running indicator
 *///from  w w  w . ja  v  a2s  .  c  o m
private Component createToolBar() {
    Box toolPanel = new Box(BoxLayout.X_AXIS);
    // add the toolbar
    this.toolbar = JMeterToolBar.createToolbar(true);
    GuiPackage guiInstance = GuiPackage.getInstance();
    guiInstance.setMainToolbar(toolbar);
    toolPanel.add(toolbar);

    toolPanel.add(Box.createRigidArea(new Dimension(10, 15)));
    toolPanel.add(Box.createGlue());

    toolPanel.add(testTimeDuration);
    toolPanel.add(Box.createRigidArea(new Dimension(20, 15)));

    toolPanel.add(errorsOrFatalsLabel);
    toolPanel.add(warnIndicator);
    toolPanel.add(Box.createRigidArea(new Dimension(20, 15)));

    toolPanel.add(activeThreads);
    toolPanel.add(new JLabel(" / "));
    toolPanel.add(totalThreads);
    toolPanel.add(Box.createRigidArea(new Dimension(10, 15)));
    toolPanel.add(runningIndicator);
    return toolPanel;
}