Example usage for javax.swing JSlider getValue

List of usage examples for javax.swing JSlider getValue

Introduction

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

Prototype

public int getValue() 

Source Link

Document

Returns the slider's current value from the BoundedRangeModel .

Usage

From source file:fr.free.hd.servers.gui.FaceView.java

private JPanel createKind() {
    JPanel panel = new JPanel(new GridLayout(3, 0));
    final JSlider sliderX = new JSlider();
    final JSlider sliderY = new JSlider();
    final JComboBox box = new JComboBox(HandKeyEnum.values());
    sliderX.setMinimum(-1000);/*from   w  w w  .j  ava  2s. c  o  m*/
    sliderX.setMaximum(1000);
    sliderX.setMajorTickSpacing(100);
    sliderX.setPaintLabels(true);
    sliderX.setPaintTicks(true);
    sliderX.setPaintTrack(true);
    sliderY.setMinimum(-1000);
    sliderY.setMaximum(1000);
    sliderY.setMajorTickSpacing(100);
    sliderY.setPaintLabels(true);
    sliderY.setPaintTicks(true);
    sliderY.setPaintTrack(true);

    box.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            kind = (HandKeyEnum) e.getItem();
            updateLabel();
        }
    });
    panel.add(box);

    sliderX.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            switch (kind) {
            case HAND_KEY_2D:
                face.setAnchorX_2D(sliderX.getValue());
                break;
            case HAND_KEY_2M:
                face.setAnchorX_2M(sliderX.getValue());
                break;
            case HAND_KEY_1M:
                face.setAnchorX_1M(sliderX.getValue());
                break;
            case HAND_KEY_2V:
                face.setAnchorX_2V(sliderX.getValue());
                break;
            case HAND_KEY_3D:
                face.setAnchorX_3D(sliderX.getValue());
                break;
            case HAND_KEY_3G:
                face.setAnchorX_3G(sliderX.getValue());
                break;
            case HAND_KEY_4G:
                face.setAnchorX_4G(sliderX.getValue());
                break;
            case HAND_KEY_5M:
                face.setAnchorX_5M(sliderX.getValue());
                break;
            }
            updateLabel();
        }
    });
    sliderY.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            switch (kind) {
            case HAND_KEY_2D:
                face.setAnchorY_2D(sliderY.getValue());
                break;
            case HAND_KEY_2M:
                face.setAnchorY_2M(sliderY.getValue());
                break;
            case HAND_KEY_1M:
                face.setAnchorY_1M(sliderY.getValue());
                break;
            case HAND_KEY_2V:
                face.setAnchorY_2V(sliderY.getValue());
                break;
            case HAND_KEY_3D:
                face.setAnchorY_3D(sliderY.getValue());
                break;
            case HAND_KEY_3G:
                face.setAnchorY_3G(sliderY.getValue());
                break;
            case HAND_KEY_4G:
                face.setAnchorY_4G(sliderY.getValue());
                break;
            case HAND_KEY_5M:
                face.setAnchorY_5M(sliderY.getValue());
                break;
            }
            updateLabel();
        }
    });
    panel.add(sliderX);
    panel.add(sliderY);
    return panel;
}

From source file:musite.ui.MusiteResultPanel.java

private void specificitySliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_specificitySliderStateChanged
    if (ignoreSlideChangeEvent)
        return;//from  ww w . j a v  a2  s  .  c o  m

    javax.swing.JSlider source = (javax.swing.JSlider) evt.getSource();

    if (!lockScore) {
        int value = (int) source.getValue();
        threshold = (maxScore - minScore) * value / maxTick + minScore;
        scoreCutoffTextField.setText(String.format("%.2f", threshold));
    }

    if (!lockSpec) {
        if (selectedModel().getSpecEstimator() != null) {
            setSpecificity(threshold);
            specificityTextField.setText(String.format("%.2f", specificity * 100));
        }
    }

    if (!source.getValueIsAdjusting()) { // does not work
        result.setThreshold(selectedModel(), threshold);
        if (phosphoCheckBox.isSelected()) {
            runResetProteinList();
        } else {
            resetDisplay();
        }
    }
}

From source file:geovista.network.gui.ClusteringDemo.java

private void setUpView() throws IOException {

    /*/*from   w ww .  j  a v a2 s . co m*/
     * Factory<Integer> vertexFactory = new Factory<Integer>() { int n = 0;
     * public Integer create() { return n++; } }; Factory<Number>
     * edgeFactory = new Factory<Number>() { int n = 0; public Number
     * create() { return n++; } };
     */

    /*
     * PajekNetReader<Graph<Integer, Number>, Integer,Number> pnr = new
     * PajekNetReader<Graph<Integer, Number>, Integer,Number>(vertexFactory,
     * edgeFactory);
     * 
     * final Graph<Integer,Number> graph = new SparseMultigraph<Integer,
     * Number>();
     * 
     * pnr.load(br, graph);
     */

    // Create a simple layout frame
    // specify the Fruchterman-Rheingold layout algorithm
    layout = new AggregateLayout<Integer, Number>(new FRLayout<Integer, Number>(g));

    vv = new VisualizationViewer<Integer, Number>(layout);
    vv.setBackground(Color.white);
    // Tell the renderer to use our own customized color rendering
    vv.getRenderContext()
            .setVertexFillPaintTransformer(MapTransformer.<Integer, Paint>getInstance(vertexPaints));
    vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Integer, Paint>() {
        public Paint transform(Integer v) {
            if (vv.getPickedVertexState().isPicked(v)) {
                return Color.blue;
            } else {
                return Color.BLACK;
            }
        }
    });

    vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints));

    vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() {
        protected final Stroke THIN = new BasicStroke(1);
        protected final Stroke THICK = new BasicStroke(2);

        public Stroke transform(Number e) {
            Paint c = edgePaints.get(e);
            if (c == Color.LIGHT_GRAY) {
                return THIN;
            } else {
                return THICK;
            }
        }
    });

    /*
     * //add restart button JButton scramble = new JButton("Restart");
     * scramble.addActionListener(new ActionListener() { public void
     * actionPerformed(ActionEvent arg0) { Layout layout =
     * vv.getGraphLayout(); layout.initialize(); Relaxer relaxer =
     * vv.getModel().getRelaxer(); if(relaxer != null) { relaxer.stop();
     * relaxer.prerelax(); relaxer.relax(); } }
     * 
     * });
     * 
     * DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
     * vv.setGraphMouse(gm);
     */

    final JToggleButton groupVertices = new JToggleButton("Group Clusters");

    // Create slider to adjust the number of edges to remove when clustering
    final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL);
    edgeBetweennessSlider.setBackground(Color.WHITE);
    edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50));
    edgeBetweennessSlider.setPaintTicks(true);
    edgeBetweennessSlider.setMaximum(g.getEdgeCount());
    edgeBetweennessSlider.setMinimum(0);
    edgeBetweennessSlider.setValue(0);
    edgeBetweennessSlider.setMajorTickSpacing(10);
    edgeBetweennessSlider.setPaintLabels(true);
    edgeBetweennessSlider.setPaintTicks(true);

    // edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black));
    // TO DO: edgeBetweennessSlider.add(new
    // JLabel("Node Size (PageRank With Priors):"));
    // I also want the slider value to appear
    final JPanel eastControls = new JPanel();
    /*
     * eastControls.setOpaque(true); eastControls.setLayout(new
     * BoxLayout(eastControls, BoxLayout.Y_AXIS));
     * eastControls.add(Box.createVerticalGlue());
     */
    // eastControls.add(edgeBetweennessSlider);

    final Box cluster_panel = Box.createVerticalBox();
    cluster_panel.setBorder(BorderFactory.createTitledBorder("Cluster"));
    cluster_panel.add(edgeBetweennessSlider);

    final String COMMANDSTRING = "Edges removed for clusters: ";
    final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue();

    final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize);
    /*
     * eastControls.setBorder(sliderBorder); //eastControls.add(eastSize);
     * eastControls.add(Box.createVerticalGlue());
     */

    groupVertices.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors,
                    e.getStateChange() == ItemEvent.SELECTED);
            vv.repaint();
        }
    });

    clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected());

    edgeBetweennessSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();
            if (!source.getValueIsAdjusting()) {
                int numEdgesToRemove = source.getValue();
                clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected());
                sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue());
                eastControls.repaint();
                vv.validate();
                vv.repaint();
            }
        }
    });

    cluster_panel.add(groupVertices);
    Container content = getContentPane();
    content.add(new GraphZoomScrollPane(vv));
    JPanel south = new JPanel();
    JPanel grid = new JPanel(new GridLayout(2, 1));
    // grid.add(scramble);
    grid.add(cluster_panel);
    // south.add
    south.add(grid);
    south.add(eastControls);
    JPanel p = new JPanel();
    // p.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    // p.add(gm.getModeComboBox());
    south.add(p);

    content.add(south, BorderLayout.SOUTH);
}

From source file:forms.frDados.java

/**
 * Atualiza o raio no controlador do mapa OSM
 * @param evt // w  ww.  j  a v a  2s .  c  o  m
 */
private void sldRaioMarcStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sldRaioMarcStateChanged
    if (mapOsm == null)
        return;

    JSlider source = (JSlider) evt.getSource();
    mapOsm.getMapController().setRaio((float) source.getValue());
    mapOsm.getMapController().refreshCandidato();
    lblRaio.setText(new Integer(sldRaioMarc.getValue()).toString());
}

From source file:fr.free.hd.servers.gui.FaceView.java

private JPanel createPosition() {
    JPanel panel = new JPanel(new GridLayout(5, 0));
    final JSlider slider = new JSlider();
    final JSlider sliderDegree = new JSlider();
    final JSlider sliderX = new JSlider();
    final JSlider sliderY = new JSlider();
    slider.setMinimum(0);/*from   w w w  .  ja va2s .co m*/
    slider.setMaximum(1000);
    sliderX.setMinimum(-1000);
    sliderX.setMaximum(1000);
    sliderX.setMajorTickSpacing(100);
    sliderX.setPaintLabels(true);
    sliderX.setPaintTicks(true);
    sliderX.setPaintTrack(true);
    sliderY.setMinimum(-1000);
    sliderY.setMaximum(1000);
    sliderY.setMajorTickSpacing(100);
    sliderY.setPaintLabels(true);
    sliderY.setPaintTicks(true);
    sliderY.setPaintTrack(true);
    sliderDegree.setMinimum(0);
    sliderDegree.setMaximum(360);
    sliderDegree.setMajorTickSpacing(20);
    sliderDegree.setPaintLabels(true);
    sliderDegree.setPaintTicks(true);
    sliderDegree.setPaintTrack(true);

    final JComboBox box = new JComboBox(HandPositionEnum.values());
    box.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            position = (HandPositionEnum) e.getItem();
            updateLabel();
        }
    });
    panel.add(box);

    slider.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            switch (position) {
            case HAND_POSITION_BOUCHE:
                face.setBoucheRatio(slider.getValue());
                break;
            case HAND_POSITION_COTE:
                face.setCoteRatio(slider.getValue());
                break;
            case HAND_POSITION_COU:
                face.setCouRatio(slider.getValue());
                break;
            case HAND_POSITION_MENTON:
                face.setMentonRatio(slider.getValue());
                break;
            case HAND_POSITION_PAUMETTE:
                face.setPaumetteRatio(slider.getValue());
                break;
            }
            updateLabel();
        }
    });
    sliderDegree.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            switch (position) {
            case HAND_POSITION_BOUCHE:
                face.setBoucheDegree(sliderDegree.getValue());
                break;
            case HAND_POSITION_COTE:
                face.setCoteDegree(sliderDegree.getValue());
                break;
            case HAND_POSITION_COU:
                face.setCouDegree(sliderDegree.getValue());
                break;
            case HAND_POSITION_MENTON:
                face.setMentonDegree(sliderDegree.getValue());
                break;
            case HAND_POSITION_PAUMETTE:
                face.setPaumetteDegree(sliderDegree.getValue());
                break;
            }
            updateLabel();
        }
    });
    sliderX.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            switch (position) {
            case HAND_POSITION_BOUCHE:
                face.setBoucheX(sliderX.getValue());
                break;
            case HAND_POSITION_COTE:
                face.setCoteX(sliderX.getValue());
                break;
            case HAND_POSITION_COU:
                face.setCouX(sliderX.getValue());
                break;
            case HAND_POSITION_MENTON:
                face.setMentonX(sliderX.getValue());
                break;
            case HAND_POSITION_PAUMETTE:
                face.setPaumetteX(sliderX.getValue());
                break;
            }
            updateLabel();
        }
    });
    sliderY.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            switch (position) {
            case HAND_POSITION_BOUCHE:
                face.setBoucheY(sliderY.getValue());
                break;
            case HAND_POSITION_COTE:
                face.setCoteY(sliderY.getValue());
                break;
            case HAND_POSITION_COU:
                face.setCouY(sliderY.getValue());
                break;
            case HAND_POSITION_MENTON:
                face.setMentonY(sliderY.getValue());
                break;
            case HAND_POSITION_PAUMETTE:
                face.setPaumetteY(sliderY.getValue());
                break;
            }
            updateLabel();
        }
    });
    panel.add(slider);
    panel.add(sliderX);
    panel.add(sliderY);
    panel.add(sliderDegree);
    return panel;
}

From source file:geovista.network.gui.NodeLinkView.java

protected void addControls(final JPanel jp) {

    // Satellite/*from w  w  w .j  a  va  2s .co  m*/
    // JComboBox modeBox = graphMouse.getModeComboBox();
    // modeBox.addItemListener(((DefaultModalGraphMouse)satellite.getGraphMouse()).getModeListener());

    // Control Panel
    jp.setBackground(Color.WHITE);
    jp.setLayout(new BorderLayout());
    jp.add(vv, BorderLayout.CENTER);
    JPanel control_panel = new JPanel(new GridLayout(5, 1));
    jp.add(control_panel, BorderLayout.EAST);

    // File_Layout Panel
    Class[] combos = getCombos();
    final JComboBox jcb = new JComboBox(combos);
    jcb.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            String valueString = value.toString();
            valueString = valueString.substring(valueString.lastIndexOf('.') + 1);
            return super.getListCellRendererComponent(list, valueString, index, isSelected, cellHasFocus);
        }
    });

    jcb.addActionListener(new LayoutChooser(jcb, vv));
    jcb.setSelectedItem(FRLayout.class);
    final Box file_layout_panel = Box.createVerticalBox();
    file_layout_panel.setBorder(BorderFactory.createTitledBorder("File_Layout"));
    final JComboBox graph_chooser = new JComboBox(g_names);
    graph_chooser.addActionListener(new GraphChooser(jcb));
    JPanel layoutPanel = new JPanel();
    jcb.setAlignmentX(Component.CENTER_ALIGNMENT);
    layoutPanel.add(jcb);
    graph_chooser.setAlignmentX(Component.CENTER_ALIGNMENT);
    layoutPanel.add(graph_chooser);
    file_layout_panel.add(layoutPanel);

    // Basic Operation Panel

    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, 1 / 1.1f, vv.getCenter());
        }
    });
    JButton reset = new JButton("reset");
    reset.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Layout<Integer, Number> layout = vv.getGraphLayout();
            layout.initialize();
            Relaxer relaxer = vv.getModel().getRelaxer();
            if (relaxer != null) {
                relaxer.stop();
                relaxer.prerelax();
                relaxer.relax();
            }
        }
    });

    // Tranform and picking part
    final DefaultModalGraphMouse<Integer, Number> graphMouse = new DefaultModalGraphMouse<Integer, Number>();
    vv.setGraphMouse(graphMouse);
    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(((DefaultModalGraphMouse<Integer, Number>) vv.getGraphMouse()).getModeListener());

    JButton collapse = new JButton("Collapse");
    JButton expand = new JButton("Expand");

    final Box basic_panel = Box.createVerticalBox();
    basic_panel.setBorder(BorderFactory.createTitledBorder("Basic_Operation"));
    JPanel zoomPanel = new JPanel();
    // plus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(plus);
    // minus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(minus);
    // modeBox.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(modeBox);
    // reset.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(reset);
    // collapse.setAlignmentY(Component.CENTER_ALIGNMENT);
    zoomPanel.add(collapse);
    // expand.setAlignmentY(Component.CENTER_ALIGNMENT);
    zoomPanel.add(expand);

    basic_panel.add(zoomPanel);

    // Vertex Part
    String[] vertexScoreType = { "VertexScore", "Degree", "BarycenterScorer", "BetweennessCentrality",
            "ClosenessCentrality", "DistanceCentralityScorer", "EigenvectorCentrality" };
    final JComboBox vertexScoreList = new JComboBox(vertexScoreType);
    vertexScoreList.setSelectedIndex(0);

    vertexScoreList.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            // Renderer.VertexLabel.Position position =
            // (Renderer.VertexLabel.Position)e.getItem();
            // vv.getRenderer().getVertexLabelRenderer().setPosition(position);
            if (vertexScoreList.getSelectedIndex() == 0) {

                // vertexScores = new VertexScoreTransformer<Integer,
                // Double>(voltage_scores);
                // vv.getRenderContext().setVertexShapeTransformer(new
                // ConstantTransformer(null));
                // vssa.setScaling(false);
                vv.getRenderContext().setVertexLabelTransformer(nonvertexLabel);
                vv.repaint();
            }

            if (vertexScoreList.getSelectedIndex() == 1) {
                // vertexScores = new VertexScoreTransformer<Integer,
                // Double>(degreeScorer);
                /*
                 * vssa = new
                 * VertexShapeSizeAspect<Integer,Number>((Graph<Integer
                 * ,Number>)g, transformerDegree);
                 * vv.getRenderContext().setVertexShapeTransformer(vssa);
                 * vssa.setScaling(true);
                 */

                vv.getRenderContext().setVertexLabelTransformer(vertexLabelDegree);
                vv.repaint();
            }
            if (vertexScoreList.getSelectedIndex() == 2) {
                vssa = new VertexShapeSizeAspect<Integer, Number>((Graph<Integer, Number>) g,
                        transformerBarycenter);
                vv.getRenderContext().setVertexShapeTransformer(vssa);
                vssa.setScaling(true);
                vv.getRenderContext().setVertexLabelTransformer(vertexLabelBarycenter);
                vv.repaint();
            }

            if (vertexScoreList.getSelectedIndex() == 3) {

                // betweennessCentrality= new BetweennessCentrality(g);
                // voltages = new VertexScoreTransformer<Integer,
                // Double>(betweennessCentrality);
                vssa = new VertexShapeSizeAspect<Integer, Number>((Graph<Integer, Number>) g,
                        transformerBetweenness);
                vv.getRenderContext().setVertexShapeTransformer(vssa);
                vssa.setScaling(true);
                vv.getRenderContext().setVertexLabelTransformer(vertexLabelBetweenness);
                vv.repaint();
            }
            if (vertexScoreList.getSelectedIndex() == 4) {
                vssa = new VertexShapeSizeAspect<Integer, Number>((Graph<Integer, Number>) g,
                        transformerCloseness);
                vv.getRenderContext().setVertexShapeTransformer(vssa);
                vssa.setScaling(true);
                vv.getRenderContext().setVertexLabelTransformer(vertexLabelCloseness);
                vv.repaint();
            }
            if (vertexScoreList.getSelectedIndex() == 5) {
                vssa = new VertexShapeSizeAspect<Integer, Number>((Graph<Integer, Number>) g,
                        transformerDistanceCentrality);
                vv.getRenderContext().setVertexShapeTransformer(vssa);
                vssa.setScaling(true);
                vv.getRenderContext().setVertexLabelTransformer(vertexLabelDistanceCentrality);
                vv.repaint();
            }
            if (vertexScoreList.getSelectedIndex() == 6) {
                vssa = new VertexShapeSizeAspect<Integer, Number>((Graph<Integer, Number>) g,
                        transformerEigenvector);
                vv.getRenderContext().setVertexShapeTransformer(vssa);
                vssa.setScaling(true);
                vv.getRenderContext().setVertexLabelTransformer(vertexLabelEigenvector);
                vv.repaint();
            }

        }
    });
    // cb.setSelectedItem(Renderer.VertexLabel.Position.SE);

    /*
     * v_shape = new JCheckBox("shape by degree");
     * v_shape.addActionListener(this); v_size = new
     * JCheckBox("size by vertexScores"); v_size.addActionListener(this);
     * v_size.setSelected(true); v_aspect = new
     * JCheckBox("stretch by degree ratio");
     * v_aspect.addActionListener(this);
     */
    v_small = new JCheckBox("filter when degree < " + VertexDisplayPredicate.MIN_DEGREE);
    v_small.addActionListener(this);
    e_labels = new JCheckBox("show edge labels");
    e_labels.addActionListener(this);

    // Vertex Panel
    final Box vertex_panel = Box.createVerticalBox();
    vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices"));
    // vertex_panel.add(v_stroke);
    vertex_panel.add(vertexScoreList);
    // vertex_panel.add(v_degree_labels);
    /*
     * vertex_panel.add(v_shape); vertex_panel.add(v_size);
     * vertex_panel.add(v_aspect);
     */
    vertex_panel.add(v_small);

    // Edge Part
    final Box edge_panel = Box.createVerticalBox();
    edge_panel.setBorder(BorderFactory.createTitledBorder("Edges"));
    edge_panel.add(e_labels);

    final JToggleButton groupVertices = new JToggleButton("Group Clusters");
    // Create slider to adjust the number of edges to remove when clustering
    final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL);
    edgeBetweennessSlider.setBackground(Color.WHITE);
    edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50));
    edgeBetweennessSlider.setPaintTicks(true);
    edgeBetweennessSlider.setMaximum(g.getEdgeCount());
    edgeBetweennessSlider.setMinimum(0);
    edgeBetweennessSlider.setValue(0);
    edgeBetweennessSlider.setMajorTickSpacing(10);
    edgeBetweennessSlider.setPaintLabels(true);
    edgeBetweennessSlider.setPaintTicks(true);

    // Cluster Part
    final Box cluster_panel = Box.createVerticalBox();
    cluster_panel.setBorder(BorderFactory.createTitledBorder("Cluster"));
    cluster_panel.add(edgeBetweennessSlider);

    final String COMMANDSTRING = "Edges removed for clusters: ";
    final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue();

    final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize);
    cluster_panel.setBorder(sliderBorder);
    cluster_panel.add(Box.createVerticalGlue());
    groupVertices.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors,
                    e.getStateChange() == ItemEvent.SELECTED);
            vv.repaint();
        }
    });

    clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected());

    edgeBetweennessSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();
            if (!source.getValueIsAdjusting()) {
                int numEdgesToRemove = source.getValue();
                clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected());
                sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue());
                cluster_panel.repaint();
                vv.validate();
                vv.repaint();
            }
        }
    });
    cluster_panel.add(groupVertices);

    control_panel.add(file_layout_panel);
    control_panel.add(vertex_panel);
    control_panel.add(edge_panel);
    control_panel.add(cluster_panel);
    control_panel.add(basic_panel);
}

From source file:CSSDFarm.UserInterface.java

private void sliderServerOnOffMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderServerOnOffMouseReleased
    JSlider source = (JSlider) evt.getSource();
    server.togglePower(source.getValue());

}

From source file:CSSDFarm.UserInterface.java

private void sliderServerOnOffKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_sliderServerOnOffKeyReleased
    // TODO add your handling code here:
    JSlider source = (JSlider) evt.getSource();
    server.togglePower(source.getValue());
}

From source file:CSSDFarm.UserInterface.java

private void sliderViewStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderViewStateChanged
    // TODO add your handling code here:
    JSlider source = (JSlider) evt.getSource();
    if (!source.getValueIsAdjusting()) {
        if (source.getValue() == 0) {
            panelReportTable.setVisible(false);
            panelHeatmap.setVisible(true);
            displayHeatmap();//  w ww. j  ava2s . c  o m
        } else {
            panelReportTable.setVisible(true);
            panelHeatmap.setVisible(false);
        }

    }
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void sunZSliderStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_sunZSliderStateChanged
{//GEN-HEADEREND:event_sunZSliderStateChanged

    final JSlider source = (JSlider) evt.getSource();

    if (!source.getValueIsAdjusting()) {
        int value = (int) source.getValue();

        this.parent.getParameters().getRenderParameters().getSunPosition().setZ(value);
    }//from w  ww .j  a  v  a 2 s.com
}