List of usage examples for javax.swing JSlider setPaintTicks
@BeanProperty(visualUpdate = true, description = "If true tick marks are painted on the slider.") public void setPaintTicks(boolean b)
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);//w ww.ja va 2 s . com 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.apereo.learninganalytics.snapp.ClusteringDemo.java
private void setUpView(Graph<Integer, Number> grp, Map<Integer, String> name) { /*/*w w w . j a va 2s . c o m*/ Factory<Number> vertexFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; } }; Factory<Number> edgeFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; } }; PajekNetReader<Graph<Number, Number>, Number,Number> pnr = new PajekNetReader<Graph<Number, Number>, Number,Number>(vertexFactory, edgeFactory); final Graph<Number,Number> graph = new SparseMultigraph<Number, Number>(); pnr.load(br, graph); */ //Create a simple layout frame //specify the Fruchterman-Rheingold layout algorithm this.usernames = name; final AggregateLayout<Integer, Number> layout = new AggregateLayout<Integer, Number>( new FRLayout<Integer, Number>(grp)); layout.setSize(new Dimension(500, 500)); 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.cyan; } 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; } }); vv.getRenderContext().setVertexLabelTransformer( // this chains together Transformers so that the html tags // are prepended to the toString method output new ChainedTransformer<Integer, String>( new Transformer[] { new ToStringLabeller<String>(), new Transformer<String, String>() { public String transform(String input) { return usernames.get(Integer.parseInt(input)); } } })); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.S); /* //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(grp.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 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(); } } }); // Add a restart button so the graph can be redrawn to fit the size of the frame JFrame jf = new JFrame("SNAPP: Find Clusters"); //jf.getContentPane().add(); //Container content = getContentPane(); //content.add(new GraphZoomScrollPane(vv)); jf.getContentPane().add(new GraphZoomScrollPane(vv)); JPanel south = new JPanel(); JPanel grid = new JPanel(new GridLayout(2, 1)); //grid.add(scramble); grid.add(groupVertices); 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); jf.getContentPane().add(south, BorderLayout.SOUTH); //jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.pack(); jf.setVisible(true); }
From source file:org.jcurl.demo.tactics.TacticsApp.java
public TacticsApp() { addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { TacticsApp.this.cmdExit(); }//from w w w .j a v a 2 s . c o 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(); { final JPanel p = new JPanel(new BorderLayout()); p.add(new SumWaitDisplay(mod_locations), "West"); p.add(master, "Center"); p.add(new SumShotDisplay(mod_locations), "East"); con.add(p, "Center"); } // con.add(new SumWaitDisplay(mod_locations), "West"); con.add(new SumOutDisplay(mod_locations), "West"); { final Box b1 = Box.createHorizontalBox(); b1.add(Box.createRigidArea(new Dimension(0, 75))); b1.add(pnl2); con.add(b1, "South"); } final JTabbedPane t = new JTabbedPane(); con.add(t, "East"); { final Box b0 = Box.createHorizontalBox(); t.add("Rock", b0); { final JPanel b1 = new JPanel(new BorderLayout()); final Box b2 = Box.createVerticalBox(); b2.add(new JComboBox(new String[] { "Dark", "Light" })); b2.add(new JLabel("Broom", SwingConstants.LEFT)); b1.add(b2, "North"); JSlider s = new JSlider(-2000, 2000, 0); s.setOrientation(SwingConstants.VERTICAL); s.setMajorTickSpacing(1000); s.setMinorTickSpacing(100); s.setPaintLabels(true); s.setPaintTicks(true); b1.add(s, "Center"); final Box b3 = Box.createHorizontalBox(); b3.add(new JFormattedTextField()); b3.add(new JLabel("mm", SwingConstants.LEFT)); b1.add(b3, "South"); b0.add(b1); } { final JPanel b1 = new JPanel(new BorderLayout()); final Box b2 = Box.createVerticalBox(); b2.add(new JComboBox(new String[] { "1", "2", "3", "4", "5", "6", "7", "8" })); b2.add(new JLabel("Splittime", SwingConstants.LEFT)); b1.add(b2, "North"); JSlider s = new JSlider(500, 2500, 1500); s.setOrientation(SwingConstants.VERTICAL); s.setMajorTickSpacing(1000); s.setMinorTickSpacing(100); s.setPaintLabels(true); s.setPaintTicks(true); b1.add(s, "Center"); final Box b3 = Box.createHorizontalBox(); b3.add(new JSpinner()); b3.add(new JLabel("ms", SwingConstants.LEFT)); b1.add(b3, "South"); b0.add(b1); } } { final Box b0 = Box.createHorizontalBox(); t.add("Ice", b0); { final JPanel b1 = new JPanel(new BorderLayout()); b1.add(new JLabel("Curl"), "North"); JSlider s = new JSlider(0, 5000, 0); s.setOrientation(SwingConstants.VERTICAL); s.setMajorTickSpacing(1000); s.setMinorTickSpacing(100); s.setPaintLabels(true); s.setPaintTicks(true); b1.add(s, "Center"); final JSpinner s1 = new JSpinner(); b1.add(s1, "South"); b0.add(b1); } { final JPanel b1 = new JPanel(new BorderLayout()); b1.add(new JLabel("DrawToTee"), "North"); JSlider s = new JSlider(15000, 30000, 25000); s.setOrientation(SwingConstants.VERTICAL); s.setMajorTickSpacing(5000); s.setMinorTickSpacing(1000); s.setPaintLabels(true); s.setPaintTicks(true); b1.add(s, "Center"); final JSpinner s1 = new JSpinner(); b1.add(s1, "South"); b0.add(b1); } } setJMenuBar(createMenu()); refreshTitle(); this.setSize(900, 400); new SpeedController(mod_locations, mod_speeds, master); new LocationController(mod_locations, pnl2); lastSaved = mod_locations.getLastChanged(); }
From source file:semgen.extraction.RadialGraph.Clusterer.java
public void setUpView() throws IOException { setTitle(SemGenTab.formatTabName(extractor.semsimmodel.getName())); layout = new AggregateLayout<String, Number>(new SemGenFRLayout<String, Number>(mygraph)); vv = new VisualizationViewer<String, Number>(layout); // this class will provide both label drawing and vertex shapes VertexLabelAsShapeRenderer<String, Number> vlasr = new VertexLabelAsShapeRenderer<String, Number>( vv.getRenderContext());/*from w w w .j a va2s.c om*/ // customize the render context vv.getRenderContext().setVertexLabelTransformer( // this chains together Transformers so that the html tags // are prepended to the toString method output new ChainedTransformer<String, String>( new Transformer[] { new ToStringLabeller<String>(), new Transformer<String, String>() { public String transform(String input) { return input; } } })); vv.getRenderContext().setVertexShapeTransformer(vlasr); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.red)); vv.getRenderContext().setEdgeDrawPaintTransformer(new ConstantTransformer(Color.yellow)); vv.getRenderContext().setEdgeStrokeTransformer(new ConstantTransformer(new BasicStroke(2.5f))); // customize the renderer vv.getRenderer().setVertexLabelRenderer(vlasr); vv.setBackground(Color.white); // Tell the renderer to use our own customized color rendering vv.getRenderContext() .setVertexFillPaintTransformer(MapTransformer.<String, Paint>getInstance(vertexPaints)); vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<String, Paint>() { public Paint transform(String v) { if (vv.getPickedVertexState().isPicked(v)) { if (selectioncheckbox != null) { extractor.clusterpanel.remove(selectioncheckbox); } Set<DataStructure> dsuris = new HashSet<DataStructure>(); for (String dsname : vv.getPickedVertexState().getPicked()) { dsuris.add(extractor.semsimmodel.getDataStructure(dsname)); } Component[] clusters = extractor.clusterpanel.checkboxpanel.getComponents(); extractor.clusterpanel.checkboxpanel.removeAll(); for (int x = -1; x < clusters.length; x++) { if (x == -1 && selectioncheckbox == null) { selectioncheckbox = new ExtractorJCheckBox("Selected node(s)", dsuris); selectioncheckbox.addItemListener(extractor); extractor.clusterpanel.checkboxpanel.add(selectioncheckbox); } else if (x > -1) { extractor.clusterpanel.checkboxpanel.add(clusters[x]); } } refreshModulePanel(); return Color.cyan; } else { if (vv.getPickedVertexState().getPicked().isEmpty()) { if (selectioncheckbox != null) { extractor.clusterpanel.checkboxpanel.remove(selectioncheckbox); selectioncheckbox = null; } } refreshModulePanel(); 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("Shake"); scramble.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Layout<String, Number> layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if (relaxer != null) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); DefaultModalGraphMouse<Object, Object> gm = new DefaultModalGraphMouse<Object, Object>(); vv.setGraphMouse(gm); 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(350, 50)); edgeBetweennessSlider.setPaintTicks(true); edgeBetweennessSlider.setMaximum(mygraph.getEdgeCount()); edgeBetweennessSlider.setMinimum(0); edgeBetweennessSlider.setValue(0); if (mygraph.getEdgeCount() > 10) { edgeBetweennessSlider.setMajorTickSpacing(mygraph.getEdgeCount() / 10); } else { edgeBetweennessSlider.setMajorTickSpacing(1); } edgeBetweennessSlider.setPaintLabels(true); edgeBetweennessSlider.setPaintTicks(true); // 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 String COMMANDSTRING = "Edges removed for clusters: "; final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue(); final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize); eastControls.setBorder(sliderBorder); eastControls.add(Box.createVerticalGlue()); groupVertices.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors, e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); 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(); } } }); clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected()); clusterpanel = new JPanel(); clusterpanel.setLayout(new BoxLayout(clusterpanel, BoxLayout.Y_AXIS)); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); clusterpanel.add(gzsp); JPanel south = new JPanel(); JPanel grid = new JPanel(new GridLayout(2, 1)); grid.add(scramble); grid.add(groupVertices); south.add(grid); south.add(eastControls); JPanel p = new JPanel(); p.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); p.add(gm.getModeComboBox()); south.add(p); clusterpanel.add(south); clusterpanel.add(Box.createGlue()); semscroller = new SemGenScrollPane(sempanel); splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, semscroller, clusterpanel); splitpane.setDividerLocation(initsempanelwidth); splitpane.setDividerLocation(initsempanelwidth + 10); this.add(splitpane); this.setPreferredSize(new Dimension(950, 800)); this.pack(); this.setLocationRelativeTo(null); this.setVisible(true); }
From source file:test.visualization.ClusteringDemo.java
private void setUpView(BufferedReader br) throws IOException { Factory<Number> vertexFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; }/*from w w w.ja v a 2 s .c om*/ }; Factory<Number> edgeFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; } }; PajekNetReader<Graph<Number, Number>, Number, Number> pnr = new PajekNetReader<Graph<Number, Number>, Number, Number>( vertexFactory, edgeFactory); final Graph<Number, Number> graph = new SparseMultigraph<Number, Number>(); pnr.load(br, graph); //Create a simple layout frame //specify the Fruchterman-Rheingold layout algorithm final AggregateLayout<Number, Number> layout = new AggregateLayout<Number, Number>( new FRLayout<Number, Number>(graph)); vv = new VisualizationViewer<Number, Number>(layout); vv.setBackground(Color.white); //Tell the renderer to use our own customized color rendering vv.getRenderContext() .setVertexFillPaintTransformer(MapTransformer.<Number, Paint>getInstance(vertexPaints)); vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Number, Paint>() { public Paint transform(Number v) { if (vv.getPickedVertexState().isPicked(v)) { return Color.cyan; } 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(graph.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 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(); } } }); 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(groupVertices); 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); }