Example usage for javax.swing JSlider JSlider

List of usage examples for javax.swing JSlider JSlider

Introduction

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

Prototype

public JSlider(int min, int max, int value) 

Source Link

Document

Creates a horizontal slider using the specified min, max and value.

Usage

From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PortHeatMapPlotPanel.java

private PortHeatMapPlotPanel(OMS_Collection history, ArrayList<IB_Vertex> includedNodes,
        EnumSet<IB_Depth> includedDepths) {
    super(new BorderLayout());

    // creates the main chart panel, which creates the PortHeatMapDataSet
    // (so all the data has been initialized here, available for all subsequent actions)
    overallDimension = new java.awt.Dimension(900, 500);
    heatPanel = (ChartPanel) createHeatPanel(history, includedNodes, includedDepths);
    heatPanel.setPreferredSize(overallDimension);

    // add the vertical and horizontal crosshairs
    CrosshairOverlay overlay = new CrosshairOverlay();
    TimeXhair = new Crosshair(0);
    TimeXhair.setPaint(TimeSliceColor); // vertical slice (single timestamp) for dataset1, SingleTimeChart plot 1, slider 2, etc
    PortXhair = new Crosshair(0);
    PortXhair.setPaint(PortSliceColor); // horizontal slice (single port) for dataset2, SinglePortChart, slider 1
    overlay.addDomainCrosshair(TimeXhair);
    overlay.addRangeCrosshair(PortXhair);
    heatPanel.addOverlay(overlay);//  w w w  .j  a  v  a  2  s  . c  om
    TimeXhair.setLabelVisible(true);
    TimeXhair.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
    TimeXhair.setLabelBackgroundPaint(new Color(255, 255, 0, 100));
    PortXhair.setLabelVisible(true);
    PortXhair.setLabelBackgroundPaint(new Color(255, 255, 0, 100));

    add(heatPanel);

    JPanel PortSliderPanel = new JPanel(new BorderLayout());

    // all ports, single timestamp (right vertical plot) - uses TimeXhair and slider 2 from the horizontal panel (TimeSliderPanel)
    XYSeriesCollection dataset1 = new XYSeriesCollection();
    SingleTimeChart = ChartFactory.createXYLineChart("Vertical Cross-section (all ports single timestamp)",
            PortAxisLabel, UtilizationAxisLabel, dataset1, PlotOrientation.HORIZONTAL, false, false, false);
    XYPlot plot1 = (XYPlot) SingleTimeChart.getPlot();
    plot1.getDomainAxis().setLowerMargin(0.0);
    plot1.getDomainAxis().setUpperMargin(0.0);
    plot1.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    plot1.getRenderer().setSeriesPaint(0, TimeSliceColor);

    // this is the right
    ChartPanel SingleTimeChartPanel = new ChartPanel(SingleTimeChart);
    SingleTimeChartPanel.setMinimumDrawWidth(0);
    SingleTimeChartPanel.setMinimumDrawHeight(0);

    SingleTimeChartPanel.setPreferredSize(new Dimension(200, (int) (overallDimension.getWidth() / 3)));
    ((XYPlot) SingleTimeChart.getPlot()).getRangeAxis().setRange(new Range(0, 1));
    ((XYPlot) SingleTimeChart.getPlot()).getDomainAxis().setRange(new Range(0, 1));

    // this slider panel holds the slider and the Single Time Snapshot of all ports, on the right or EAST (for use with plot2)
    PortSlider = new JSlider(0, 1, 0);
    PortSlider.addChangeListener(this);
    PortSlider.setOrientation(JSlider.VERTICAL);

    PortSliderPanel.add(SingleTimeChartPanel);
    PortSliderPanel.add(PortSlider, BorderLayout.WEST);

    TimeSliderPanel = new JPanel(new BorderLayout());

    // single port, all timestamps (lower horizontal plot) - uses PortXhair and slider 1 from the vertical panel (PortSliderPanel)
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    SinglePortChart = ChartFactory.createXYLineChart("Horizontal Cross-section (single port over time)",
            TimeAxisLabel, UtilizationAxisLabel, dataset2, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot2 = (XYPlot) SinglePortChart.getPlot();
    plot2.getDomainAxis().setLowerMargin(0.0);
    plot2.getDomainAxis().setUpperMargin(0.0);
    plot2.getRenderer().setSeriesPaint(0, PortSliceColor);

    ChartPanel SinglePortChartPanel = new ChartPanel(SinglePortChart);
    SinglePortChartPanel.setMinimumDrawWidth(0);
    SinglePortChartPanel.setMinimumDrawHeight(0);

    SinglePortChartPanel.setPreferredSize(new Dimension(200, (int) (overallDimension.getHeight() / 3)));
    ((XYPlot) SinglePortChart.getPlot()).getRangeAxis().setRange(new Range(0, 1));
    ((XYPlot) SinglePortChart.getPlot()).getDomainAxis().setRange(new Range(0, 1));

    DepthPanel = new HeatMapDepthPanel(null);
    DepthPanel.setPreferredSize(
            new Dimension((int) (overallDimension.getWidth() / 4), (int) (overallDimension.getHeight() / 3)));
    TimeSliderPanel.add(DepthPanel, BorderLayout.EAST);

    // this slider panel holds the slider and the Single Port for all times, in the BOTTOM (for use with plot1)
    TimeSlider = new JSlider(0, 1, 0);
    TimeSlider.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 200));
    TimeSlider.addChangeListener(this);

    TimeSliderPanel.add(SinglePortChartPanel);
    TimeSliderPanel.add(TimeSlider, BorderLayout.NORTH);
    add(PortSliderPanel, BorderLayout.EAST);
    add(TimeSliderPanel, BorderLayout.SOUTH);
    heatChart.setNotify(true);
}

From source file:edu.uci.ics.jung.samples.PerspectiveVertexImageShaperDemo.java

/**
 * create an instance of a simple graph with controls to
 * demo the zoom features.//from   w  w w  . j  av a  2 s. c om
 * 
 */
@SuppressWarnings("serial")
public PerspectiveVertexImageShaperDemo() {

    // create a simple graph for the demo
    graph = new DirectedSparseMultigraph<Number, Number>();
    Number[] vertices = createVertices(11);

    // a Map for the labels
    Map<Number, String> map = new HashMap<Number, String>();
    for (int i = 0; i < vertices.length; i++) {
        map.put(vertices[i], iconNames[i % iconNames.length]);
    }

    // a Map for the Icons
    Map<Number, Icon> iconMap = new HashMap<Number, Icon>();
    for (int i = 0; i < vertices.length; i++) {
        String name = "/images/topic" + iconNames[i] + ".gif";
        try {
            Icon icon = new LayeredIcon(
                    new ImageIcon(PerspectiveVertexImageShaperDemo.class.getResource(name)).getImage());
            iconMap.put(vertices[i], icon);
        } catch (Exception ex) {
            System.err.println("You need slashdoticons.jar in your classpath to see the image " + name);
        }
    }

    createEdges(vertices);

    final VertexStringerImpl<Number> vertexStringerImpl = new VertexStringerImpl<Number>(map);

    final VertexIconShapeTransformer<Number> vertexImageShapeFunction = new VertexIconShapeTransformer<Number>(
            new EllipseVertexShapeTransformer<Number>());

    FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph);
    layout.setMaxIterations(100);
    vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400, 400));

    vv.setBackground(Color.decode("0xffffdd"));
    final DefaultVertexIconTransformer<Number> vertexIconFunction = new DefaultVertexIconTransformer<Number>();
    vertexImageShapeFunction.setIconMap(iconMap);
    vertexIconFunction.setIconMap(iconMap);
    vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction);
    vv.getRenderContext().setVertexIconTransformer(vertexIconFunction);
    vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl);
    PickedState<Number> ps = vv.getPickedVertexState();
    ps.addItemListener(new PickWithIconListener(vertexIconFunction));

    vv.addPostRenderPaintable(new VisualizationServer.Paintable() {
        int x;
        int y;
        Font font;
        FontMetrics metrics;
        int swidth;
        int sheight;
        String str = "Thank You, slashdot.org, for the images!";

        public void paint(Graphics g) {
            Dimension d = vv.getSize();
            if (font == null) {
                font = new Font(g.getFont().getName(), Font.BOLD, 20);
                metrics = g.getFontMetrics(font);
                swidth = metrics.stringWidth(str);
                sheight = metrics.getMaxAscent() + metrics.getMaxDescent();
                x = (d.width - swidth) / 2;
                y = (int) (d.height - sheight * 1.5);
            }
            g.setFont(font);
            Color oldColor = g.getColor();
            g.setColor(Color.lightGray);
            g.drawString(str, x, y);
            g.setColor(oldColor);
        }

        public boolean useTransform() {
            return false;
        }
    });

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<Number>());

    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>();

    vv.setGraphMouse(graphMouse);

    this.viewSupport = new PerspectiveImageLensSupport<Number, Number>(vv);
    this.layoutSupport = new PerspectiveLayoutTransformSupport<Number, Number>(vv);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 0.9f, vv.getCenter());
        }
    });
    final JSlider horizontalSlider = new JSlider(-120, 120, 0) {

        /* (non-Javadoc)
         * @see javax.swing.JComponent#getPreferredSize()
         */
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(80, super.getPreferredSize().height);
        }
    };

    final JSlider verticalSlider = new JSlider(-120, 120, 0) {

        /* (non-Javadoc)
         * @see javax.swing.JComponent#getPreferredSize()
         */
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(super.getPreferredSize().width, 80);
        }
    };
    verticalSlider.setOrientation(JSlider.VERTICAL);
    final ChangeListener changeListener = new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            int vval = -verticalSlider.getValue();
            int hval = horizontalSlider.getValue();

            Dimension d = vv.getSize();
            PerspectiveTransform pt = null;
            pt = PerspectiveTransform.getQuadToQuad(vval, hval, d.width - vval, -hval, d.width + vval,
                    d.height + hval, -vval, d.height - hval,

                    0, 0, d.width, 0, d.width, d.height, 0, d.height);

            viewSupport.getPerspectiveTransformer().setPerspectiveTransform(pt);
            layoutSupport.getPerspectiveTransformer().setPerspectiveTransform(pt);
            vv.repaint();
        }
    };
    horizontalSlider.addChangeListener(changeListener);
    verticalSlider.addChangeListener(changeListener);

    JPanel perspectivePanel = new JPanel(new BorderLayout());
    JPanel perspectiveCenterPanel = new JPanel(new BorderLayout());
    perspectivePanel.setBorder(BorderFactory.createTitledBorder("Perspective Controls"));
    final JButton center = new JButton("Center");
    center.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            horizontalSlider.setValue(0);
            verticalSlider.setValue(0);
        }
    });

    final JCheckBox noText = new JCheckBox("No Text");
    noText.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            JCheckBox cb = (JCheckBox) e.getSource();
            vertexStringerImpl.setEnabled(!cb.isSelected());
            vv.repaint();
        }
    });
    JPanel centerPanel = new JPanel();
    centerPanel.add(noText);

    ButtonGroup radio = new ButtonGroup();
    JRadioButton none = new JRadioButton("None");
    none.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            boolean selected = e.getStateChange() == ItemEvent.SELECTED;
            if (selected) {
                if (viewSupport != null) {
                    viewSupport.deactivate();
                }
                if (layoutSupport != null) {
                    layoutSupport.deactivate();
                }
            }
            center.setEnabled(!selected);
            horizontalSlider.setEnabled(!selected);
            verticalSlider.setEnabled(!selected);
        }
    });
    none.setSelected(true);

    JRadioButton hyperView = new JRadioButton("View");
    hyperView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    JRadioButton hyperModel = new JRadioButton("Layout");
    hyperModel.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            layoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    radio.add(none);
    radio.add(hyperView);
    radio.add(hyperModel);

    JMenuBar menubar = new JMenuBar();
    JMenu modeMenu = graphMouse.getModeMenu();
    menubar.add(modeMenu);

    panel.setCorner(menubar);

    JPanel scaleGrid = new JPanel(new GridLayout(2, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));
    JPanel controls = new JPanel(new BorderLayout());
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(scaleGrid, BorderLayout.WEST);

    JPanel lensPanel = new JPanel(new GridLayout(2, 0));
    lensPanel.add(none);
    lensPanel.add(hyperView);
    lensPanel.add(hyperModel);

    perspectivePanel.add(lensPanel, BorderLayout.WEST);
    perspectiveCenterPanel.add(horizontalSlider, BorderLayout.SOUTH);
    perspectivePanel.add(verticalSlider, BorderLayout.EAST);
    perspectiveCenterPanel.add(center);
    perspectivePanel.add(perspectiveCenterPanel);
    controls.add(perspectivePanel, BorderLayout.EAST);

    controls.add(centerPanel);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.AdvancedXY_PlotPanel.java

private void initChart(XY_PlotPanel pPanel) {
    this.plotPanel = pPanel;
    this.chartPanel = pPanel.getChartPanel();
    if (pPanel instanceof SimpleXY_PlotPanel) {
        this.setTitle(((SimpleXY_PlotPanel) pPanel).getTitle());
    }/*from  w  w  w.  java 2s  .  com*/

    JFreeChart chart = chartPanel.getChart();
    XYPlot plot = (XYPlot) chart.getPlot();

    // how many data sets will there be (may not exist yet, cause swing worker may still be constructing them)
    int numRows = 2; // enough for counts, and delta counts
    if ((XY_PlotType.ADV_PORT_UTIL_PLUS.equals(getType())))
        numRows = 4;
    boolean includeExtra = numRows > MAX_DATASETS / 2 ? true : false;

    int rowSize = includeExtra ? MAX_DS_SIZE : MAX_DS_SIZE / 2 + 19; // extra for padding
    NumDataSets = numRows;

    // build the table model from the data sets, then build the table and slider

    // see "chartProgress()" method
    chart.addProgressListener(this);

    this.chartPanel.setPreferredSize(new java.awt.Dimension(750, 300));
    this.chartPanel.setDomainZoomable(true);
    this.chartPanel.setRangeZoomable(true);
    Border border = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createEtchedBorder());
    this.chartPanel.setBorder(border);
    add(this.chartPanel);

    JPanel dashboard = new JPanel(new BorderLayout());
    dashboard.setPreferredSize(new Dimension(400, rowSize));
    dashboard.setBorder(BorderFactory.createEmptyBorder(0, 4, 4, 4));

    this.model = new XY_PlotTableModel(numRows);

    // initialize the model, and table, here
    //    this.model.setValueAt("name", 0, 1);
    this.model.setValueAt(new Double("0.00"), 0, 1);
    this.model.setValueAt(new Double("0.00"), 0, 2);
    //    this.model.setValueAt("units", 0, 3);
    JTable table = new JTable(this.model);

    // the columns are name, time, value, units.  both name and units are strings
    // so need special renderers for time and value

    TableCellRenderer renderer1 = new DateCellRenderer(new SimpleDateFormat("HH:mm:ss"));
    TableCellRenderer renderer2 = new NumberCellRenderer();
    table.getColumnModel().getColumn(1).setCellRenderer(renderer1);
    table.getColumnModel().getColumn(2).setCellRenderer(renderer2);
    JScrollPane scroller = new JScrollPane(table);
    dashboard.add(scroller);

    this.slider = new JSlider(0, 100, 10);
    this.slider.addChangeListener(this);
    dashboard.add(this.slider, BorderLayout.SOUTH);
    add(dashboard, BorderLayout.SOUTH);

    //     XYPlot plot = (XYPlot) chart.getPlot();

    plot.setDomainCrosshairLockedOnData(true);
    plot.setRangeCrosshairVisible(false);
    plot.setDomainCrosshairVisible(true);
}

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

private void createPlayer(JPanel panel) {
    playerPanel = new JPanel();
    GridBagLayout gbl_playerPanel = new GridBagLayout();
    gbl_playerPanel.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
    gbl_playerPanel.rowHeights = new int[] { 0, 0, 0, 0 };
    gbl_playerPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
    gbl_playerPanel.rowWeights = new double[] { 0.0, 0.0 };
    playerPanel.setLayout(gbl_playerPanel);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = insets0;/*from   www  .  j a v a  2s  . c om*/
    gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridx = 0;
    gbc.gridy = 0;

    progressBar = new JSlider(0, 0, 0);
    progressBar.setMinimum(0);
    progressBar.setMaximum(lastRow);
    setProgressBar(logDataTable.getSelectedRow());
    progressBar.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            int row = progressBar.getValue();
            if (playing) {
                if (row == lastRow || (endPlay >= 0 && endPlay < row)) {
                    stop();
                    return;
                }
                if (showMarker) {
                    Rectangle2D dataArea = logView.getChartPanel().getChartRenderingInfo().getPlotInfo()
                            .getDataArea();
                    XYPlot plot = (XYPlot) logView.getChartPanel().getChart().getPlot();
                    double x = plot.getDomainAxis().valueToJava2D(row, dataArea, plot.getDomainAxisEdge());
                    boolean isLeft = (x < (dataArea.getMaxX() - dataArea.getMinX()) / 2) ? true : false;
                    logView.setMarkers(row, isLeft);
                }
            }
            logDataTable.getTable().setRowSelectionInterval(row, row);
            logDataTable.getTable().changeSelection(row, logDataTable.getSelectedColumn(), false, false);
            double x, y, z;
            int origXCol, origYCol, origZCol;
            synchronized (lock) {
                for (TableHolder tableHolder : tables) {
                    try {
                        origXCol = logDataTable.getCurrentIndexForOriginalColumn(tableHolder.xColIdx);
                        origYCol = logDataTable.getCurrentIndexForOriginalColumn(tableHolder.yColIdx);
                        origZCol = logDataTable.getCurrentIndexForOriginalColumn(tableHolder.zColIdx);
                        x = Double.valueOf(logDataTable.getValueAt(row, origXCol).toString());
                        y = Double.valueOf(logDataTable.getValueAt(row, origYCol).toString());
                        if (origZCol > 0)
                            z = Double.valueOf(logDataTable.getValueAt(row, origZCol).toString());
                        else
                            z = Double.NaN;
                        tableHolder.table.setCurrentPoint(x, y, z);
                    } catch (Exception ex) {
                        JOptionPane
                                .showMessageDialog(null,
                                        "Invalid numeric value in column " + (tableHolder.xColIdx + 1)
                                                + ", row " + (row + 1),
                                        "Invalid value", JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                }
            }
        }
    });
    gbc.weightx = 1.0;
    gbc.gridwidth = gbl_playerPanel.columnWidths.length;
    playerPanel.add(progressBar, gbc);

    stopButton = addPlayerButton(0, new ImageIcon(getClass().getResource("/stop.png")));
    rewButton = addPlayerButton(1, new ImageIcon(getClass().getResource("/rew.png")));
    playButton = addPlayerButton(2, playIcon);
    ffwButton = addPlayerButton(3, new ImageIcon(getClass().getResource("/ffw.png")));
    showIntepCells = addCheckBox(4, "Show interpolation cells");
    showSignifCells = addCheckBox(5, "Show significant cell");
    showTraceLine = addCheckBox(6, "Show trace line");
    showTraceMarker = addCheckBox(7, "Show plot trace marker");

    gbc.weightx = 0.0;
    gbc.gridwidth = 0;
    gbc.gridy = 1;
    panel.add(playerPanel, gbc);
}

From source file:TextureByReference.java

public JPanel buildGui() {
    flipB = new JCheckBox("flip image", true);
    flipB.addItemListener(this);
    javax.swing.Box flipBox = new javax.swing.Box(BoxLayout.Y_AXIS);
    flipBox.add(flipB);//w w w  . ja va 2 s . com
    Component strut1 = flipBox.createVerticalStrut(flipB.getPreferredSize().height);
    Component strut2 = flipBox.createVerticalStrut(flipB.getPreferredSize().height);
    Component strut3 = flipBox.createVerticalStrut(flipB.getPreferredSize().height);
    Component strut4 = flipBox.createVerticalStrut(flipB.getPreferredSize().height);
    Component strut5 = flipBox.createVerticalStrut(flipB.getPreferredSize().height);
    flipBox.add(strut1);
    flipBox.add(strut2);
    flipBox.add(strut3);
    flipBox.add(strut4);
    flipBox.add(strut5);

    yUp = new JRadioButton("y up");
    yUp.addActionListener(this);
    yUp.setSelected(true);
    yDown = new JRadioButton("y down");
    yDown.addActionListener(this);
    ButtonGroup yGroup = new ButtonGroup();
    yGroup.add(yUp);
    yGroup.add(yDown);
    JLabel yLabel = new JLabel("Image Orientation:");
    javax.swing.Box yBox = new javax.swing.Box(BoxLayout.Y_AXIS);
    yBox.add(yLabel);
    yBox.add(yUp);
    yBox.add(yDown);
    strut1 = yBox.createVerticalStrut(yUp.getPreferredSize().height);
    strut2 = yBox.createVerticalStrut(yUp.getPreferredSize().height);
    strut3 = yBox.createVerticalStrut(yUp.getPreferredSize().height);
    yBox.add(strut1);
    yBox.add(strut2);
    yBox.add(strut3);

    texByRef = new JRadioButton("by reference");
    texByRef.addActionListener(this);
    texByRef.setSelected(true);
    texByCopy = new JRadioButton("by copy");
    texByCopy.addActionListener(this);
    ButtonGroup texGroup = new ButtonGroup();
    texGroup.add(texByRef);
    texGroup.add(texByCopy);
    JLabel texLabel = new JLabel("Texture:*");
    javax.swing.Box texBox = new javax.swing.Box(BoxLayout.Y_AXIS);
    texBox.add(texLabel);
    texBox.add(texByRef);
    texBox.add(texByCopy);
    strut1 = texBox.createVerticalStrut(texByRef.getPreferredSize().height);
    strut2 = texBox.createVerticalStrut(texByRef.getPreferredSize().height);
    strut3 = texBox.createVerticalStrut(texByRef.getPreferredSize().height);
    texBox.add(strut1);
    texBox.add(strut2);
    texBox.add(strut3);

    geomByRef = new JRadioButton("by reference");
    geomByRef.addActionListener(this);
    geomByRef.setSelected(true);
    geomByCopy = new JRadioButton("by copy");
    geomByCopy.addActionListener(this);
    ButtonGroup geomGroup = new ButtonGroup();
    geomGroup.add(geomByRef);
    geomGroup.add(geomByCopy);
    JLabel geomLabel = new JLabel("Geometry:");
    javax.swing.Box geomBox = new javax.swing.Box(BoxLayout.Y_AXIS);
    geomBox.add(geomLabel);
    geomBox.add(geomByRef);
    geomBox.add(geomByCopy);
    strut1 = geomBox.createVerticalStrut(geomByRef.getPreferredSize().height);
    strut2 = geomBox.createVerticalStrut(geomByRef.getPreferredSize().height);
    strut3 = geomBox.createVerticalStrut(geomByRef.getPreferredSize().height);
    geomBox.add(strut1);
    geomBox.add(strut2);
    geomBox.add(strut3);

    img4ByteABGR = new JRadioButton("TYPE_4BYTE_ABGR");
    img4ByteABGR.addActionListener(this);
    img4ByteABGR.setSelected(true);
    img3ByteBGR = new JRadioButton("TYPE_3BYTE_BGR");
    img3ByteBGR.addActionListener(this);
    imgIntARGB = new JRadioButton("TYPE_INT_ARGB");
    imgIntARGB.addActionListener(this);
    imgCustomRGBA = new JRadioButton("TYPE_CUSTOM RGBA");
    imgCustomRGBA.addActionListener(this);
    imgCustomRGB = new JRadioButton("TYPE_CUSTOM RGB");
    imgCustomRGB.addActionListener(this);
    ButtonGroup imgGroup = new ButtonGroup();
    imgGroup.add(img4ByteABGR);
    imgGroup.add(img3ByteBGR);
    imgGroup.add(imgIntARGB);
    imgGroup.add(imgCustomRGBA);
    imgGroup.add(imgCustomRGB);
    JLabel imgLabel = new JLabel("Image Type:*");
    javax.swing.Box imgBox = new javax.swing.Box(BoxLayout.Y_AXIS);
    imgBox.add(imgLabel);
    imgBox.add(img4ByteABGR);
    imgBox.add(img3ByteBGR);
    imgBox.add(imgIntARGB);
    imgBox.add(imgCustomRGBA);
    imgBox.add(imgCustomRGB);

    javax.swing.Box topBox = new javax.swing.Box(BoxLayout.X_AXIS);
    topBox.add(flipBox);
    topBox.add(texBox);
    topBox.add(geomBox);
    topBox.add(yBox);
    Component strut = topBox.createRigidArea(new Dimension(10, 10));
    topBox.add(strut);
    topBox.add(imgBox);

    frameDelay = new JSlider(0, 50, 0);
    frameDelay.addChangeListener(this);
    frameDelay.setSnapToTicks(true);
    frameDelay.setPaintTicks(true);
    frameDelay.setPaintLabels(true);
    frameDelay.setMajorTickSpacing(10);
    frameDelay.setMinorTickSpacing(1);
    frameDelay.setValue(20);
    JLabel delayL = new JLabel("frame delay");
    javax.swing.Box delayBox = new javax.swing.Box(BoxLayout.X_AXIS);
    delayBox.add(delayL);
    delayBox.add(frameDelay);

    animationB = new JButton(" stop animation ");
    animationB.addActionListener(this);

    JLabel texInfo1 = new JLabel("*To use ImageComponent by reference feature, use TYPE_4BYTE_ABGR on Solaris");
    JLabel texInfo2 = new JLabel("and TYPE_3BYTE_BGR on Windows");

    JPanel buttonP = new JPanel();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    buttonP.setLayout(gridbag);
    c.anchor = GridBagConstraints.CENTER;
    c.gridwidth = GridBagConstraints.REMAINDER;
    gridbag.setConstraints(topBox, c);
    buttonP.add(topBox);
    gridbag.setConstraints(delayBox, c);
    buttonP.add(delayBox);
    gridbag.setConstraints(animationB, c);
    buttonP.add(animationB);
    gridbag.setConstraints(texInfo1, c);
    buttonP.add(texInfo1);
    gridbag.setConstraints(texInfo2, c);
    buttonP.add(texInfo2);

    return buttonP;

}

From source file:ucar.unidata.idv.control.chart.ChartWrapper.java

/**
 * Create the properties contents//from   w w w  .  j  av  a  2  s.com
 *
 * @param comps  List of components
 * @param tabIdx Which tab
 */
protected void getPropertiesComponents(List comps, int tabIdx) {
    super.getPropertiesComponents(comps, tabIdx);
    if (tabIdx != 0) {
        return;
    }

    if (canDoResolution()) {
        comps.add(GuiUtils.rLabel("Resolution: "));
        resolutionSlider = new JSlider(0, 100, (int) (100 * resolution));
        comps.add(GuiUtils.vbox(resolutionSlider,
                GuiUtils.leftRight(GuiUtils.lLabel("Low"), GuiUtils.rLabel("High"))));
    }

    /*
    if(canDoMinMaxDate() && minOk(dataMinDate) && maxOk(dataMaxDate)) {
    LocaleSpecificResources.setHourFormat(LocaleSpecificResources.HOUR_FORMAT_24);
            
    GregorianCalendar minCal = getMinCalendar();
    GregorianCalendar maxCal = getMaxCalendar();
    ActionListener listener = new ActionListener(){
            public void actionPerformed(ActionEvent e) {
                dateTimeChanged();
            }
        };
            
    minPicker = new DateTimePicker(minCal, "dd-MMM-yyyy HH:mm:ss z");
    minPicker.setDisplayTodayButton(false);
    minPicker.addActionListener(listener);
    minPicker.setMaxSelectableTime(maxCal);
    minPicker.setMinSelectableTime(getCalendar(new Date((long)dataMinDate)));
            
            
    maxPicker = new DateTimePicker(maxCal, "dd-MMM-yyyy HH:mm:ss z");
    maxPicker.setDisplayTodayButton(false);
    maxPicker.addActionListener(listener);
    maxPicker.setMinSelectableTime(minCal);
    maxPicker.setMaxSelectableTime(getCalendar(new Date((long)dataMaxDate)));
            
            
    JPanel datePanel = GuiUtils.hbox(minPicker, new JLabel(" to "), maxPicker);
    comps.add(GuiUtils.rLabel("Date Range: "));
    comps.add(GuiUtils.left(datePanel));
    }*/

    if (canDoJython()) {
        comps.add(GuiUtils.rLabel("Jython: "));
        jythonFld = new JTextField(jython, 40);
        comps.add(GuiUtils.centerRight(jythonFld, GuiUtils.makeButton("Apply", this, "applyJython")));
    }

    if (canDoDataChoiceList()) {
        chartOrderChanged = false;

        fieldProperties = new ArrayList();
        for (int paramIdx = 0; paramIdx < dataChoiceWrappers.size(); paramIdx++) {
            DataChoiceWrapper wrapper = (DataChoiceWrapper) dataChoiceWrappers.get(paramIdx);
            XmlObjectStore store;
            if (getDisplayControl() != null) {
                store = getDisplayControl().getControlContext().getIdv().getStore();
            } else {
                store = McIDASV.getStaticMcv().getStore();
            }
            fieldProperties.add(new FieldProperties(store, wrapper));
        }
        wrapperPanel = new JPanel();

        updateWrapperPanel();

        JScrollPane sp = new JScrollPane(GuiUtils.left(wrapperPanel),
                ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

        sp.getVerticalScrollBar().setUnitIncrement(10);

        JViewport vp = sp.getViewport();
        sp.setPreferredSize(new Dimension(600, 200));

        comps.add(GuiUtils.top(GuiUtils.rLabel("Fields:")));
        comps.add(sp);
    }

}

From source file:ucar.unidata.idv.flythrough.Flythrough.java

/**
 * _more_/*from w w  w.ja va  2  s. com*/
 *
 * @return _more_
 *
 * @throws RemoteException _more_
 * @throws VisADException _more_
 */
public JComponent doMakeViewpointPanel() throws VisADException, RemoteException {

    JSlider speedSlider = new JSlider(1, 200, 200 - animationSpeed);
    speedSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            JSlider slider = (JSlider) e.getSource();
            if (!slider.getValueIsAdjusting()) {
                animationSpeed = 200 - slider.getValue() + 1;
            }
        }
    });

    showTimesCbx = new JCheckBox("Set Animation Time", showTimes);
    showTimesCbx.setEnabled(hasTimes);
    animateCbx = new JCheckBox("Animated", animate);
    changeViewpointCbx = new JCheckBox("Change Viewpoint", changeViewpoint);

    orients = new Vector<TwoFacedObject>();
    orients.add(new TwoFacedObject("Towards Next Point", ORIENT_POINT));
    orients.add(new TwoFacedObject("Forward", ORIENT_FORWARD));
    orients.add(new TwoFacedObject("Up", ORIENT_UP));
    orients.add(new TwoFacedObject("Down", ORIENT_DOWN));
    orients.add(new TwoFacedObject("Left", ORIENT_LEFT));
    orients.add(new TwoFacedObject("Right", ORIENT_RIGHT));
    orientBox = new JComboBox(orients);
    orientBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            orientation = TwoFacedObject.getIdString(orientBox.getSelectedItem());
            goToCurrent();
        }
    });

    if (animationInfo == null) {
        animationInfo = new AnimationInfo();
        animationInfo.setShareIndex(true);
    }

    ActionListener listener = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            Misc.run(Flythrough.this, "goToCurrent");
        }
    };

    //xxxxx

    animationWidget = new AnimationWidget(null, null, animationInfo);

    if ((getShareGroup() == null) || getShareGroup().equals(SharableManager.GROUP_ALL)) {
        setShareGroup("flythrough");
    }
    animationWidget.setShareGroup(getShareGroup());
    animationWidget.setSharing(getSharing());

    animation = new Animation();
    animation.setAnimationInfo(animationInfo);
    animation.addPropertyChangeListener(this);
    animationWidget.setAnimation(animation);

    locationMarker = new SelectorPoint("flythrough.point",
            ShapeUtility.setSize(ShapeUtility.createShape(ShapeUtility.AIRPLANE3D)[0], .1f),
            new RealTuple(RealTupleType.SpatialCartesian3DTuple, new double[] { 0, 0, 0 }));

    locationMarker.setAutoSize(true);
    locationMarker.setManipulable(false);
    locationMarker.setColor(Color.green);
    locationMarker.setVisible(false);

    locationLine = new LineDrawing("flythroughpoint.line");
    locationLine.setVisible(false);
    locationLine.setLineWidth(2);
    locationLine.setColor(Color.green);

    //        locationLine2 = new LineDrawing("flythroughpoint.line2");
    //        locationLine2.setVisible(false);
    //        locationLine2.setLineWidth(2);
    //        locationLine2.setColor(Color.red);
    //        viewManager.getMaster().addDisplayable(locationLine2);

    Misc.runInABit(2000, this, "setScaleOnMarkers", null);

    viewManager.getMaster().addDisplayable(locationMarker);
    viewManager.getMaster().addDisplayable(locationLine);

    readout = new CursorReadoutWindow(viewManager, false);

    //zoomFld = new JTextField(zoom + "", 5);
    zoomFld = new JTextField(Misc.format(zoom), 5);

    for (int i = 0; i < tilt.length; i++) {
        final int theIndex = i;
        tiltSliders[i] = new JSlider(-90, 90, (int) tilt[i]);
        tiltSliders[i].setToolTipText("Control-R: reset");
        tiltSliders[i].addKeyListener(new KeyAdapter() {
            public void keyPressed(KeyEvent e) {
                if ((e.getKeyCode() == KeyEvent.VK_R) && e.isControlDown()) {
                    tilt[theIndex] = 0;
                    tiltLabels[theIndex].setText("" + (int) tilt[theIndex]);
                    tiltSliders[theIndex].setValue(0);
                    goToCurrent();
                }
            }
        });

        tiltLabels[i] = new JLabel("" + (int) tilt[i]);
        tiltSliders[i].addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                JSlider slider = (JSlider) e.getSource();
                tiltLabels[theIndex].setText("" + slider.getValue());
                if (!slider.getValueIsAdjusting()) {
                    tilt[theIndex] = slider.getValue();
                    goToCurrent();
                }
            }
        });
    }

    zoomFld.addActionListener(listener);

    fixedZCbx = GuiUtils.makeCheckbox("Use fixed Z", this, "useFixedZ");
    GuiUtils.tmpInsets = GuiUtils.INSETS_5;
    JComponent orientationComp = GuiUtils.formLayout(new Component[] { GuiUtils.filler(),
            GuiUtils.left(changeViewpointCbx), GuiUtils.rLabel("Tilt Down/Up:"),
            GuiUtils.centerRight(tiltSliders[0], tiltLabels[0]), GuiUtils.rLabel("Tilt Left/Right:"),
            GuiUtils.centerRight(tiltSliders[1], tiltLabels[1]), GuiUtils.rLabel("Zoom:"),
            GuiUtils.left(zoomFld), GuiUtils.rLabel("Orientation:"),
            GuiUtils.left(GuiUtils.hbox(orientBox, (doGlobe() ? GuiUtils.filler() : (JComponent) fixedZCbx))),
            //            GuiUtils.rLabel("Tilt Down/Up:"), GuiUtils.centerRight(tiltSliders[2],tiltLabels[2]),

            GuiUtils.rLabel("Transitions:"),
            GuiUtils.vbox(GuiUtils.left(animateCbx), GuiUtils.leftCenter(new JLabel("Speed"), speedSlider)),
            GuiUtils.filler(), GuiUtils.left(showTimesCbx), });

    return GuiUtils.top(orientationComp);

}

From source file:JXTransformer.java

private JPanel createToolPanel() {
        JPanel panel = new JPanel(new GridLayout(1, 0));
        rotationSlider = new JSlider(-180, 180, 0);
        rotationSlider.setLabelTable(rotationSlider.createStandardLabels(90, -180));
        rotationSlider.setPaintLabels(true);
        rotationSlider.setPaintTicks(true);
        rotationSlider.setMajorTickSpacing(45);
        rotationSlider.addChangeListener(this);
        rotationSlider.setBorder(BorderFactory.createTitledBorder("Rotate"));
        panel.add(rotationSlider);//from  w ww . j a  v  a 2  s  . co  m

        shearingSlider = new JSlider(-10, 10, 0);
        shearingSlider.setLabelTable(shearingSlider.createStandardLabels(5, -10));
        shearingSlider.setPaintLabels(true);
        shearingSlider.setPaintTicks(true);
        shearingSlider.setMajorTickSpacing(2);
        shearingSlider.addChangeListener(this);
        shearingSlider.setBorder(BorderFactory.createTitledBorder("Shear"));
        panel.add(shearingSlider);

        scalingSlider = new JSlider(50, 150, 100);
        scalingSlider.setLabelTable(scalingSlider.createStandardLabels(25, 50));
        scalingSlider.setPaintLabels(true);
        scalingSlider.setPaintTicks(true);
        scalingSlider.setMajorTickSpacing(10);
        scalingSlider.addChangeListener(this);
        scalingSlider.setBorder(BorderFactory.createTitledBorder("Scale"));
        panel.add(scalingSlider);
        return panel;
    }

From source file:org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultPropView.java

private JPanel getPriorityPanel(final ViewState state) {
    JPanel panel = new JPanel();
    panel.setBorder(new EtchedBorder());
    panel.setLayout(new BorderLayout());
    panel.add(new JLabel("Priority:  "), BorderLayout.WEST);
    final JLabel priorityLabel = new JLabel(String.valueOf(DEFAULT_PRIORITY));
    panel.add(priorityLabel, BorderLayout.CENTER);
    JSlider slider = new JSlider(0, 100, (int) 5 * 10);
    slider.setMajorTickSpacing(10);//from ww  w.ja va 2  s. c  om
    slider.setMinorTickSpacing(1);
    slider.setPaintLabels(true);
    slider.setPaintTicks(true);
    slider.setSnapToTicks(false);
    Format f = new DecimalFormat("0.0");
    Hashtable<Integer, JComponent> labels = new Hashtable<Integer, JComponent>();
    for (int i = 0; i <= 10; i += 2) {
        JLabel label = new JLabel(f.format(i));
        label.setFont(label.getFont().deriveFont(Font.PLAIN));
        labels.put(i * 10, label);
    }
    slider.setLabelTable(labels);
    slider.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            double value = ((JSlider) e.getSource()).getValue() / 10.0;
            priorityLabel.setText(value + "");
            priorityLabel.revalidate();
            if (!((JSlider) e.getSource()).getValueIsAdjusting()) {
                // FIXME: deal with priorities
                DefaultPropView.this.notifyListeners();
            }
        }

    });

    panel.add(slider, BorderLayout.SOUTH);
    return panel;
}

From source file:org.jcurl.demo.editor.EditorApp.java

public EditorApp() {
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            EditorApp.this.cmdExit();
        }/*  w w w  .j  a va 2s.co  m*/
    });
    master = new RockEditDisplay();
    master.setPos(mod_locations);
    master.setSpeed(mod_speeds);
    final PositionDisplay pnl2 = new PositionDisplay();
    pnl2.setPos(mod_locations);
    pnl2.setZoom(Zoomer.HOG2HACK);

    final Container con = getContentPane();

    con.add(master, "Center");
    con.add(new SumWaitDisplay(mod_locations), "West");
    con.add(new SumShotDisplay(mod_locations), "East");
    {
        final Box b0 = Box.createVerticalBox();
        final Box b1 = Box.createHorizontalBox();
        b1.add(Box.createRigidArea(new Dimension(0, 75)));
        b1.add(pnl2);
        b0.add(b1);
        b0.add(new JSlider(0, 100, 0));
        final Box b2 = Box.createHorizontalBox();
        b2.add(Box.createHorizontalGlue());
        b2.add(bStart = this.newButton("Start", this, "cmdRunStart"));
        b2.add(bPause = this.newButton("Pause", this, "cmdRunPause"));
        b2.add(bStop = this.newButton("Stop", this, "cmdRunStop"));
        b2.add(Box.createHorizontalGlue());
        b0.add(b2);
        con.add(b0, "South");
    }
    bStop.getAction().actionPerformed(null);

    setJMenuBar(createMenu());
    refreshTitle();
    this.setSize(900, 400);

    new SpeedController(mod_locations, mod_speeds, master);
    new LocationController(mod_locations, pnl2);
    lastSaved = mod_locations.getLastChanged();
}