Example usage for javax.swing JToolBar setMaximumSize

List of usage examples for javax.swing JToolBar setMaximumSize

Introduction

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

Prototype

@BeanProperty(description = "The maximum size of the component.")
public void setMaximumSize(Dimension maximumSize) 

Source Link

Document

Sets the maximum size of this component to a constant value.

Usage

From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.sda.DatasetViewerUIComponent.java

/***********************************************************************************************
 * Initialise this UIComponent.//from   ww w  .  j  a v a2s.c  o m
 */

public void initialiseUI() {
    final List<Component> listComponents;
    final JToolBar toolbarViewer;
    final MetadataExplorerUIComponentInterface uiMetadata;

    super.initialiseUI();

    getDatasetSemaphore().setState(SuperposedDataAnalyserHelper.BLOCK_EVENTS);

    // Create the Viewer JToolBar
    listComponents = SuperposedDataAnalyserHelper.createDatasetToolbarComponents(getObservatoryInstrument(),
            getSdaUI(), this, getFontData(), getColourData());
    toolbarViewer = UIComponentHelper.buildToolbar(listComponents);
    toolbarViewer.setFloatable(false);
    toolbarViewer.setMinimumSize(DIM_TOOLBAR_SIZE);
    toolbarViewer.setPreferredSize(DIM_TOOLBAR_SIZE);
    toolbarViewer.setMaximumSize(DIM_TOOLBAR_SIZE);
    toolbarViewer.setBackground(UIComponentPlugin.DEFAULT_COLOUR_TAB_BACKGROUND.getColor());

    // There is only ever one Chart for the DatasetViewer
    // A special version for use in e.g. the Superposed Data Analyser, with no Toolbar
    setChartViewer(new LogLinChartUIComponent(getSdaUI().getHostTask(), getObservatoryInstrument(),
            SuperposedDataAnalyserUIComponentInterface.TITLE_DATASET, null, REGISTRY.getFrameworkResourceKey(),
            DataUpdateType.DECIMATE,
            REGISTRY.getIntegerProperty(
                    getObservatoryInstrument().getHostAtom().getResourceKey() + KEY_DISPLAY_DATA_MAX),
            -SuperposedDataAnalyserUIComponentInterface.DEFAULT_COMPOSITE_RANGE,
            SuperposedDataAnalyserUIComponentInterface.DEFAULT_COMPOSITE_RANGE,
            -SuperposedDataAnalyserUIComponentInterface.DEFAULT_COMPOSITE_RANGE,
            SuperposedDataAnalyserUIComponentInterface.DEFAULT_COMPOSITE_RANGE) {
        final static long serialVersionUID = -2433194350569140263L;

        /**********************************************************************************
         * Customise the XYPlot of a new chart, e.g. for fixed range axes.
         *
         * @param datasettype
         * @param primarydataset
         * @param secondarydatasets
         * @param updatetype
         * @param displaylimit
         * @param channelselector
         * @param debug
         *
         * @return JFreeChart
         */

        public JFreeChart createCustomisedChart(final DatasetType datasettype, final XYDataset primarydataset,
                final List<XYDataset> secondarydatasets, final DataUpdateType updatetype,
                final int displaylimit, final ChannelSelectorUIComponentInterface channelselector,
                final boolean debug) {
            final JFreeChart jFreeChart;

            jFreeChart = super.createCustomisedChart(datasettype, primarydataset, secondarydatasets, updatetype,
                    displaylimit, channelselector, debug);
            // Remove all labels
            jFreeChart.setTitle(EMPTY_STRING);

            if ((jFreeChart.getXYPlot() != null) && (jFreeChart.getXYPlot().getDomainAxis() != null)) {
                jFreeChart.getXYPlot().getDomainAxis().setLabel(EMPTY_STRING);
            }

            if ((jFreeChart.getXYPlot() != null) && (jFreeChart.getXYPlot().getRangeAxis() != null)) {
                jFreeChart.getXYPlot().getRangeAxis().setLabel(EMPTY_STRING);
            }

            return (jFreeChart);
        }

        /**********************************************************************************
         * Initialise the Chart.
         */

        public synchronized void initialiseUI() {
            final String SOURCE = "ChartUIComponent.initialiseUI() ";

            setChannelSelector(false);
            setDatasetDomainControl(false);

            super.initialiseUI();

            // Indicate if the Chart can Autorange, and is currently Autoranging
            setCanAutorange(true);
            setLinearMode(true);

            // Configure the Chart for this specific use
            if (getChannelSelectorOccupant() != null) {
                getChannelSelectorOccupant().setAutoranging(true);
                getChannelSelectorOccupant().setLinearMode(true);
                getChannelSelectorOccupant().setDecimating(true);
                getChannelSelectorOccupant().setLegend(false);
                getChannelSelectorOccupant().setShowChannels(false);
                getChannelSelectorOccupant().debugSelector(LOADER_PROPERTIES.isChartDebug(), SOURCE);
            }
        }
    });

    getChartViewer().initialiseUI();

    // Now add the Viewer Chart as a ChangeListener
    getOffsetControl().addChangeListener(getSdaUI().getDatasetViewer().getChartViewer());

    // Prepare and initialise a Metadata viewer, with no Toolbar
    uiMetadata = new MetadataExplorerUIComponent(getSdaUI().getHostTask(), getObservatoryInstrument(), null,
            REGISTRY.getFrameworkResourceKey(), false);
    setMetadataViewer(uiMetadata);
    getMetadataViewer().initialiseUI();

    // Make sure we are notified if the Composite Metadata changes in any way
    if (uiMetadata.getTheLeafUI() != null) {
        uiMetadata.getTheLeafUI().addMetadataChangedListener(this);
    }

    // The ViewerContainer contains either the Chart viewer or the Metadata viewer
    // Start with the Chart visible
    getViewerContainer().removeAll();
    getViewerContainer().add((Component) getChartViewer(), BorderLayout.CENTER);

    // Assemble the whole Viewer
    removeAll();
    add(toolbarViewer, BorderLayout.NORTH);
    add((Component) getViewerContainer(), BorderLayout.CENTER);
}

From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartUIHelper.java

/***********************************************************************************************
 * Create the default Toolbar for a Chart.
 *
 * @param obsinstrument/*from   w w  w . j ava 2s. com*/
 * @param chart
 * @param title
 * @param fontdata
 * @param colourforeground
 * @param colourbackground
 * @param debug
 *
 * @return JToolBar
 */

public static JToolBar createDefaultToolbar(final ObservatoryInstrumentInterface obsinstrument,
        final ChartUIComponentPlugin chart, final String title, final FontInterface fontdata,
        final ColourInterface colourforeground, final ColourInterface colourbackground, final boolean debug) {
    final JToolBar toolbar;

    if ((obsinstrument != null) && (chart != null)) {
        final List<Component> listComponentsToAdd;
        final JLabel labelName;

        listComponentsToAdd = new ArrayList<Component>(10);

        //-------------------------------------------------------------------------------------
        // Initialise the Label

        labelName = new JLabel(title, RegistryModelUtilities.getAtomIcon(obsinstrument.getHostAtom(),
                ObservatoryInterface.FILENAME_ICON_CHART_VIEWER), SwingConstants.LEFT) {
            static final long serialVersionUID = 7580736117336162922L;

            // Enable Antialiasing in Java 1.5
            protected void paintComponent(final Graphics graphics) {
                final Graphics2D graphics2D = (Graphics2D) graphics;

                // For antialiasing text
                graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                        RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
                super.paintComponent(graphics2D);
            }
        };

        labelName.setFont(
                fontdata.getFont().deriveFont(ReportTableHelper.SIZE_HEADER_FONT).deriveFont(Font.BOLD));
        labelName.setForeground(colourforeground.getColor());
        labelName.setIconTextGap(UIComponentPlugin.TOOLBAR_ICON_TEXT_GAP);

        listComponentsToAdd.add(new JToolBar.Separator(UIComponentPlugin.DIM_TOOLBAR_SEPARATOR_BUTTON));
        listComponentsToAdd.add(labelName);
        listComponentsToAdd.add(new JToolBar.Separator(UIComponentPlugin.DIM_TOOLBAR_SEPARATOR));

        listComponentsToAdd.add(Box.createHorizontalGlue());

        UIComponentHelper.addToolbarPrintButtons(listComponentsToAdd, chart, chart.getChartPanel(), title,
                fontdata, colourforeground, colourbackground, debug);

        // Build the Toolbar using the Components, if any
        toolbar = UIComponentHelper.buildToolbar(listComponentsToAdd);
    } else {
        toolbar = new JToolBar();
    }

    toolbar.setFloatable(false);
    toolbar.setMinimumSize(UIComponentPlugin.DIM_TOOLBAR_SIZE);
    toolbar.setPreferredSize(UIComponentPlugin.DIM_TOOLBAR_SIZE);
    toolbar.setMaximumSize(UIComponentPlugin.DIM_TOOLBAR_SIZE);
    toolbar.setBackground(colourbackground.getColor());
    NavigationUtilities.updateComponentTreeUI(toolbar);

    return (toolbar);
}

From source file:org.zaproxy.zap.view.MainToolbarPanel.java

public void initialise() {
    setLayout(new java.awt.GridBagLayout());
    setPreferredSize(DisplayUtils.getScaledDimension(getMaximumSize().width, 25));
    setMaximumSize(DisplayUtils.getScaledDimension(getMaximumSize().width, 25));
    this.setBorder(BorderFactory.createEtchedBorder());

    expandButtons = new ButtonGroup();

    GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
    GridBagConstraints gridBagConstraints2 = new GridBagConstraints();

    gridBagConstraints1.gridx = 0;//from w ww .  ja va  2s. c  o  m
    gridBagConstraints1.gridy = 0;
    gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;

    gridBagConstraints2.gridx = 1;
    gridBagConstraints2.gridy = 0;
    gridBagConstraints2.weightx = 1.0;
    gridBagConstraints2.weighty = 1.0;
    gridBagConstraints2.anchor = java.awt.GridBagConstraints.EAST;
    gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;

    JToolBar t1 = new JToolBar();
    t1.setEnabled(true);
    t1.setPreferredSize(new java.awt.Dimension(80000, 25));
    t1.setMaximumSize(new java.awt.Dimension(80000, 25));

    add(getToolbar(), gridBagConstraints1);
    add(t1, gridBagConstraints2);

    toolbar.add(getModeSelect());
    toolbar.add(getBtnNew());
    toolbar.add(getBtnOpen());
    toolbar.add(getBtnSave());
    toolbar.add(getBtnSnapshot());
    toolbar.add(getBtnSession());
    toolbar.add(getBtnOptions());

    toolbar.addSeparator();
    toolbar.add(getShowAllTabs());
    toolbar.add(getHideAllTabs());
    toolbar.add(getShowTabIconNames());
    toolbar.addSeparator();

    toolbar.add(getBtnExpandSites());
    toolbar.add(getBtnExpandReports());
    toolbar.add(getBtnExpandFull());

    toolbar.addSeparator();
}