List of usage examples for javax.swing JToggleButton JToggleButton
public JToggleButton(Action a)
From source file:edu.uci.ics.jung.samples.BalloonLayoutDemo.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public BalloonLayoutDemo() { // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree();/* w w w . j a v a 2 s . c o m*/ layout = new TreeLayout<String, Integer>(graph); radialLayout = new BalloonLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(900, 900)); vv = new VisualizationViewer<String, Integer>(layout, new Dimension(600, 600)); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); rings = new Rings(radialLayout); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); final ScalingControl scaler = new CrossoverScalingControl(); vv.scaleToLayout(scaler); 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()); } }); JToggleButton radial = new JToggleButton("Balloon"); radial.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, layout, radialLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity(); vv.addPreRenderPaintable(rings); } else { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout, layout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(radial); controls.add(scaleGrid); controls.add(modeBox); controls.add(hyperView); content.add(controls, BorderLayout.SOUTH); }
From source file:TreeColapse.java
@SuppressWarnings("unchecked") public TreeColapse() throws IOException { // create a simple graph for the demo graph = new DelegateForest<Node, Integer>(); createTree();/*from w w w.j a v a 2 s.c o m*/ layout = new TreeLayout<Node, Integer>(graph); collapser = new TreeCollapser(); radialLayout = new RadialTreeLayout<Node, Integer>(graph); radialLayout.setSize(new Dimension(600, 600)); vv = new VisualizationViewer<Node, Integer>(layout, new Dimension(600, 600)); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); //vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Node>()); vv.getRenderContext().setVertexLabelTransformer(new Transformer<Node, String>() { public String transform(Node e) { return (e.getName()); } }); vv.getRenderContext().setVertexShapeTransformer(new ClusterVertexShapeFunction()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); rings = new Rings(); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); 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()); } }); JToggleButton radial = new JToggleButton("Radial"); radial.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { // layout.setRadial(true); vv.setGraphLayout(radialLayout); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.addPreRenderPaintable(rings); } else { // layout.setRadial(false); vv.setGraphLayout(layout); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); JButton collapse = new JButton("Collapse"); collapse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Collection picked = new HashSet(vv.getPickedVertexState().getPicked()); if (picked.size() == 1) { Object root = picked.iterator().next(); Forest inGraph = (Forest) layout.getGraph(); try { collapser.collapse(vv.getGraphLayout(), inGraph, root); } catch (InstantiationException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IllegalAccessException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } vv.getPickedVertexState().clear(); vv.repaint(); } } }); JButton expand = new JButton("Expand"); expand.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Collection picked = vv.getPickedVertexState().getPicked(); for (Object v : picked) { if (v instanceof Forest) { Forest inGraph = (Forest) layout.getGraph(); collapser.expand(inGraph, (Forest) v); } vv.getPickedVertexState().clear(); vv.repaint(); } } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(radial); controls.add(scaleGrid); controls.add(modeBox); controls.add(collapse); controls.add(expand); content.add(controls, BorderLayout.SOUTH); }
From source file:gridvisual.GridVisualize.java
public GridVisualize() { // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree();//from www. j a v a2s .c o m layout = new TreeLayout<String, Integer>(graph); radialLayout = new BalloonLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(900, 900)); vv = new VisualizationViewer<String, Integer>(layout, new Dimension(600, 600)); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); rings = new Rings(radialLayout); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); final ScalingControl scaler = new CrossoverScalingControl(); vv.scaleToLayout(scaler); 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()); } }); JToggleButton radial = new JToggleButton("Balloon"); radial.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, layout, radialLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity(); vv.addPreRenderPaintable(rings); } else { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout, layout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(radial); controls.add(scaleGrid); controls.add(modeBox); controls.add(hyperView); content.add(controls, BorderLayout.SOUTH); for (String v : layout.getGraph().getVertices()) { java.awt.Point p = nodeTable.get(new Integer(Integer.parseInt(v))).coord; layout.setLocation(v, p); } /* Transformer<Integer,Paint> vertexPaint = new Transformer<Integer,Paint>() { public Paint transform(Integer i) { return Color.GREEN; } };*/ /* Transformer<Integer, Paint> vertexPaint = new Transformer<Integer, Paint>() { private final Color[] palette = {Color.GREEN, Color.BLUE, Color.RED}; public Paint transform(Integer i) { return palette[i.intValue() % palette.length]; } };*/ vv.getRenderContext().setVertexFillPaintTransformer(new MyTransformer(this.nodeTable)); }
From source file:graphView.JungTreeViewer.java
public JungTreeViewer(ArrayList<String> versions) { // Added by Minh Nguyen for CS550 Term Project, KAIST, 2014 Transformer<String, Shape> vertexSize = new Transformer<String, Shape>() { public Shape transform(String str) { Ellipse2D circle = new Ellipse2D.Double(-15, -15, 30, 30); // in this case, the vertex is twice as large return AffineTransform.getScaleInstance(1.5, 1.5).createTransformedShape(circle); }//from ww w . j a va2 s . c om }; Transformer<String, Paint> vertexPaint = new Transformer<String, Paint>() { @Override public Paint transform(String str) { Color green = new Color(0, 1, 0, 0.1f); String[] chars = str.split("\\."); if (chars.length == 1) { return Color.blue; } else { return green; } } }; // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree(versions); layout = new TreeLayout<String, Integer>(graph); radialLayout = new RadialTreeLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(700, 700)); vv = new VisualizationViewer<String, Integer>(layout, new Dimension(700, 700)); //jy: size vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); //vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.BLACK)); vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); //vv.getRenderContext().setVertexShapeTransformer(vertexSize); rings = new Rings(); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); JComboBox<String> modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); 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()); } }); JToggleButton radial = new JToggleButton("Radial"); radial.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, layout, radialLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.addPreRenderPaintable(rings); } else { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout, layout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(radial); controls.add(scaleGrid); controls.add(modeBox); content.add(controls, BorderLayout.SOUTH); }
From source file:com.declarativa.interprolog.gui.Testo1.java
private void updateGUI(Forest<String, Integer> grapho) { layout = new TreeLayout<String, Integer>(grapho); radialLayout = new BalloonLayout<String, Integer>(grapho); radialLayout.setSize(new Dimension(900, 900)); vv = new VisualizationViewer<String, Integer>(layout, new Dimension(600, 600)); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); rings = new Rings(radialLayout); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel);// ww w . j a v a 2 s .c o m final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); final ScalingControl scaler = new CrossoverScalingControl(); vv.scaleToLayout(scaler); 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()); } }); JToggleButton radial = new JToggleButton("Balloon"); radial.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, layout, radialLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity(); vv.addPreRenderPaintable(rings); } else { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout, layout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(radial); controls.add(scaleGrid); controls.add(modeBox); controls.add(jButton1); content.add(controls, BorderLayout.SOUTH); this.revalidate(); this.repaint(); }
From source file:geovista.network.gui.ClusteringDemo.java
private void setUpView() throws IOException { /*/* w w w . j a v a 2s. c o 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:cimat.tesis.sna.visualization.ClusteringDemo.java
private void setUpView(BufferedReader br) throws IOException { Factory<Number> vertexFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; }/*w ww . ja va 2 s .co m*/ }; 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); }
From source file:com.eviware.soapui.impl.wsdl.panels.request.AbstractWsdlRequestDesktopPanel.java
protected JComponent buildContent() { requestSplitPane = UISupport.createHorizontalSplit(); requestSplitPane.setResizeWeight(0.5); requestSplitPane.setBorder(null);/*from w w w. j a v a2 s . c o m*/ submitButton = createActionButton(new SubmitAction(), true); cancelButton = createActionButton(new CancelAction(), false); splitButton = createActionButton(new ChangeSplitPaneOrientationAction(requestSplitPane), true); tabsButton = new JToggleButton(new ChangeToTabsAction()); tabsButton.setPreferredSize(UISupport.TOOLBAR_BUTTON_DIMENSION); recreateButton = createActionButton(new RecreateRequestAction(request), true); cloneButton = createActionButton(new CloneRequestAction(request), true); createEmptyButton = createActionButton(new CreateEmptyRequestAction(request), true); submitButton.setEnabled(request.getEndpoint() != null && request.getEndpoint().trim().length() > 0); moveFocusAction = new MoveFocusAction(); wsiValidateAction = new WSIValidateAction(request); wsiValidateAction.setEnabled(request.getResponse() != null); requestEditor = buildRequestEditor(); responseEditor = buildResponseEditor(); requestEditorTabs = new JTabbedPane(JTabbedPane.BOTTOM); requestEditorTabs.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); requestEditorTabs.addTab("SOAP Request", requestEditor); requestEditorTabs.addTab("Request Attachments (" + request.getAttachmentCount() + ")", new AttachmentPanel(request, true)); responseEditorTabs = new JTabbedPane(JTabbedPane.BOTTOM); responseEditorTabs.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); responseEditorTabs.addTab("SOAP Response", responseEditor); responseEditorTabs.addTab( "Response Attachments (" + (request.getResponse() == null ? 0 : request.getResponse().getAttachments().length) + ")", new AttachmentPanel(request, false)); requestTabs = new JTabbedPane(); requestTabPanel = UISupport.createTabPanel(requestTabs, true); requestEditorTabPanel = UISupport.createTabPanel(requestEditorTabs, false); responseEditorTabPanel = UISupport.createTabPanel(responseEditorTabs, false); if (request.getSettings().getBoolean(UISettings.START_WITH_REQUEST_TABS)) { requestTabs.addTab("Request", requestEditorTabPanel); requestTabs.addTab("Response", responseEditorTabPanel); splitButton.setEnabled(false); tabsButton.setSelected(true); return requestTabPanel; } else { requestSplitPane.setTopComponent(requestEditorTabPanel); requestSplitPane.setBottomComponent(responseEditorTabPanel); requestSplitPane.setDividerLocation(0.5); return requestSplitPane; } }
From source file:au.org.ala.delta.editor.ui.ItemEditor.java
/** * Creates the user interface components of this dialog. *//*from www. j a v a 2 s. c om*/ private void createUI() { JPanel content = new JPanel(); JLabel lblTaxonNumber = new JLabel("Taxon Number:"); lblTaxonNumber.setName("taxonNumberLabel"); spinner = new JSpinner(); spinner.setModel(new SpinnerNumberModel(1, 1, 1, 1)); btnSelect = new JToggleButton("Select"); btnSelect.setName("selectTaxonNumberButton"); lblEditTaxonName = new JLabel(editTaxonLabelText); rtfEditor = new RtfEditor(); editorScroller = new JScrollPane(rtfEditor); chckbxTreatAsVariant = new JCheckBox("Treat as Variant"); chckbxTreatAsVariant.setName("treatAsVariantCheckbox"); JPanel panel = new JPanel(); btnDone = new JButton("Done"); btnDone.setName("doneEditingTaxonButton"); taxonSelectionList = new ItemList(); GroupLayout groupLayout = new GroupLayout(content); groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout .createSequentialGroup().addContainerGap() .addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout .createSequentialGroup() .addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup() .addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false) .addComponent(spinner).addComponent(lblTaxonNumber, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(18).addComponent(btnSelect)) .addComponent(chckbxTreatAsVariant)) .addGap(23) .addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addComponent(lblEditTaxonName) .addComponent(editorScroller, GroupLayout.DEFAULT_SIZE, 703, Short.MAX_VALUE))) .addGroup(groupLayout.createSequentialGroup() .addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup() .addGap(0, 759, Short.MAX_VALUE).addComponent(btnDone).addGap(5)) .addComponent(panel, GroupLayout.DEFAULT_SIZE, 850, Short.MAX_VALUE)) .addGap(1))) .addGap(19))); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout .createSequentialGroup().addContainerGap() .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(lblTaxonNumber) .addComponent(lblEditTaxonName)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup() .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) .addComponent(spinner, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(btnSelect)) .addPreferredGap(ComponentPlacement.RELATED, 90, Short.MAX_VALUE) .addComponent(chckbxTreatAsVariant)) .addComponent(editorScroller, GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)) .addGap(18).addComponent(panel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(btnDone)).addGap(17))); panel.setLayout(new BorderLayout(0, 0)); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); imageDetails = new ImageDetailsPanel(); imageDetails.setEnabled(false); tabbedPane.addTab("Images", imageDetails); panel.add(tabbedPane); content.setLayout(groupLayout); setPreferredSize(new Dimension(827, 500)); setMinimumSize(new Dimension(748, 444)); RtfToolBar toolbar = new RtfToolBar(this); toolbar.addEditor(rtfEditor); getContentPane().add(toolbar, BorderLayout.NORTH); getContentPane().add(content, BorderLayout.CENTER); }
From source file:de.tor.tribes.ui.views.DSWorkbenchStatsFrame.java
private void buildMenu() { JXTaskPane editPane = new JXTaskPane(); editPane.setTitle("Bearbeiten"); final JToggleButton createStats = new JToggleButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/medal.png"))); createStats.setToolTipText(//from www . j a v a2s. co m "Umschalten zwischen dem Erzeugen von Statistiken und der Anzeige von Verlaufsgrafiken"); createStats.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { boolean showChartView = !createStats.isSelected(); if (showChartView) { createStats .setIcon(new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/medal.png"))); } else { createStats .setIcon(new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/chart.png"))); } switchStatChartView(showChartView); } }); JXButton selectStart = new JXButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/beginning.png"))); selectStart.setToolTipText("Setzt eine Startmarkierung beim gewhlten Datenpunkt"); selectStart.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { setStartAnnotation(); } }); selectStart.setSize(createStats.getSize()); selectStart.setMinimumSize(createStats.getMinimumSize()); selectStart.setMaximumSize(createStats.getMaximumSize()); selectStart.setPreferredSize(createStats.getPreferredSize()); editPane.getContentPane().add(selectStart); JXButton selectEnd = new JXButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/end.png"))); selectEnd.setToolTipText("Setzt eine Endmarkierung beim gewhlten Datenpunkt"); selectEnd.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { setEndAnnotation(); } }); selectEnd.setSize(createStats.getSize()); selectEnd.setMinimumSize(createStats.getMinimumSize()); selectEnd.setMaximumSize(createStats.getMaximumSize()); selectEnd.setPreferredSize(createStats.getPreferredSize()); editPane.getContentPane().add(selectEnd); JXButton removeSelection = new JXButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/delete_region.png"))); removeSelection.setToolTipText("Lscht alle Datenpunkte zwischen der Start- und Endmarkierung"); removeSelection.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { removeSelection(); } }); removeSelection.setSize(createStats.getSize()); removeSelection.setMinimumSize(createStats.getMinimumSize()); removeSelection.setMaximumSize(createStats.getMaximumSize()); removeSelection.setPreferredSize(createStats.getPreferredSize()); editPane.getContentPane().add(removeSelection); createStats.setSize(removeSelection.getSize()); createStats.setMinimumSize(removeSelection.getMinimumSize()); createStats.setMaximumSize(removeSelection.getMaximumSize()); createStats.setPreferredSize(removeSelection.getPreferredSize()); editPane.getContentPane().add(createStats); JXTaskPane viewPane = new JXTaskPane(); viewPane.setTitle("Anzeige"); viewPane.getContentPane().add(jViewSelectionBox); JXTaskPane settingsPane = new JXTaskPane(); settingsPane.setTitle("Einstellungen"); settingsPane.getContentPane().add(jShowItemValues); settingsPane.getContentPane().add(jShowLegend); settingsPane.getContentPane().add(jShowLines); settingsPane.getContentPane().add(jShowDataPoints); centerPanel.setupTaskPane(editPane, viewPane, settingsPane); }