List of usage examples for javax.swing BorderFactory createTitledBorder
public static TitledBorder createTitledBorder(Border border)
From source file:ca.phon.plugins.praat.export.TextGridExportWizard.java
private WizardStep setupExportOptionsStep() { final WizardStep retVal = new WizardStep(); final DialogHeader header = new DialogHeader("Generate TextGrids", "Setup export options."); overwriteBox = new JCheckBox(); overwriteBox.setText(OVERWRITE_MESSAGE); nameField = new JTextField(); nameField.setEnabled(false);//from w w w . j a va 2 s. c om defaultNameButton = new JRadioButton( "Save as default TextGrid for session (__res/textgrids/.../default.TextGrid)"); customNameButton = new JRadioButton("Save TextGrid with custom name"); defaultNameButton.setSelected(true); defaultNameButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { boolean state = defaultNameButton.isSelected(); if (state) { nameField.setEnabled(false); } } }); customNameButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean state = customNameButton.isSelected(); if (state) { nameField.setEnabled(true); } } }); nameGroup = new ButtonGroup(); nameGroup.add(defaultNameButton); nameGroup.add(customNameButton); final TextGridExporter exporter = new TextGridExporter(); exportsTree = new ExportEntryCheckboxTree(session); exportsTree.setBorder(BorderFactory.createTitledBorder("Select tiers")); exportsTree.setChecked(exporter.getExports(getProject())); final JScrollPane exportsScroller = new JScrollPane(exportsTree); final JPanel topPanel = new JPanel(); topPanel.setLayout(new VerticalLayout()); topPanel.setBorder(BorderFactory.createTitledBorder("Options")); topPanel.add(defaultNameButton); topPanel.add(customNameButton); topPanel.add(nameField); topPanel.add(overwriteBox); final JPanel centerPanel = new JPanel(); centerPanel.setLayout(new BorderLayout()); centerPanel.add(topPanel, BorderLayout.NORTH); centerPanel.add(exportsScroller, BorderLayout.CENTER); retVal.setLayout(new BorderLayout()); retVal.add(header, BorderLayout.NORTH); retVal.add(centerPanel, BorderLayout.CENTER); return retVal; }
From source file:econtroller.gui.ControllerGUI.java
private void createModelerControlPanel() { modelerControlPanelSection = new JPanel(); GroupLayout group = new GroupLayout(modelerControlPanelSection); modelerControlPanelSection.setLayout(group); group.setAutoCreateGaps(true);/* ww w . j a va 2s .c o m*/ group.setAutoCreateContainerGaps(true); modelerControlPanelSection.setBorder(BorderFactory.createTitledBorder("Black Box System Identification")); createSamplingAndNodeOrderingSection(); createNrInstanceSection(); createControlPanelButtons(); createChartPanels(); group.setHorizontalGroup(group.createSequentialGroup() .addGroup(group.createParallelGroup().addComponent(orderedEnabled).addComponent(samplingOrderLbl) .addComponent(maxNrInstancesLbl).addComponent(startModelerButton) .addComponent(dumpDataIntoFilesBtn).addComponent(cpuLoadPanel) .addComponent(responseTimePanel).addComponent(nrInstancePanel)) .addGroup(group.createParallelGroup().addComponent(sampleOrderLayout).addComponent(instanceLayout) .addComponent(stopModelerButton).addComponent(resetModelerButton) .addComponent(bandwidthPanel).addComponent(costPanel).addComponent(throughputPanel))); group.setVerticalGroup(group.createSequentialGroup() .addGroup(group.createParallelGroup().addComponent(orderedEnabled)) .addGroup( group.createParallelGroup().addComponent(samplingOrderLbl).addComponent(sampleOrderLayout)) .addGroup(group.createParallelGroup().addComponent(maxNrInstancesLbl).addComponent(instanceLayout)) .addGroup(group.createParallelGroup().addComponent(startModelerButton) .addComponent(stopModelerButton)) .addGroup(group.createParallelGroup().addComponent(dumpDataIntoFilesBtn) .addComponent(resetModelerButton)) .addGroup(group.createParallelGroup().addComponent(cpuLoadPanel).addComponent(bandwidthPanel)) .addGroup(group.createParallelGroup().addComponent(responseTimePanel).addComponent(costPanel)) .addGroup(group.createParallelGroup().addComponent(nrInstancePanel).addComponent(throughputPanel))); modelerPanel.add(modelerControlPanelSection); }
From source file:com.google.code.facebook.graph.sna.applet.BalloonLayoutDemo.java
public BalloonLayoutDemo() { // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree();/*from w w w . j a va 2 s . co 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: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();//from w ww.java2 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:com.robertolosanno.cdt_maven.Cdt.java
public Cdt() { //Ontologia// w ww . j a v a 2s . co m OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); loadModel(m); ExtendedIterator<OntClass> iter = m.listHierarchyRootClasses(); // create a simple graph graph = new DelegateTree<String, String>(); createTree(iter); //Vincoli System.out.println("--- CONSTRAINTS ---"); ExtendedIterator<ObjectProperty> iterProp = m.listObjectProperties(); while (iterProp.hasNext()) { ObjectProperty objProp = iterProp.next(); plotConstraint(objProp); } treeLayout = new TreeLayout<String, String>(graph); vv = new VisualizationViewer<String, String>(treeLayout, new Dimension(1200, 600)); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); //***************** MODIFICA COLORE VERTICE ************************ Transformer<String, Paint> vertexColor = new Transformer<String, Paint>() { public Paint transform(String s) { String[] ss = s.split("#"); String type = ss[1]; if (type.equals("root")) return Color.lightGray; if (type.equals("dim")) return Color.BLACK; if (type.equals("val")) return Color.WHITE; if (type.equals("par_val")) return Color.WHITE; if (type.equals("par_dim")) return Color.WHITE; return Color.GREEN; } }; vv.getRenderContext().setVertexFillPaintTransformer(vertexColor); //**************** MODIFICA FORMA VERTICE *************************** //Dati per creare un triangolo (lo creaiamo attraverso la classe Polygon) final int[] xShape = new int[4]; final int[] yShape = new int[4]; final int nShape; // count of points // Make a shape xShape[0] = -10; xShape[1] = 0; xShape[2] = 10; yShape[0] = 0; yShape[1] = 20; yShape[2] = 0; nShape = 3; Transformer<String, Shape> vertexShape = new Transformer<String, Shape>() { private final Shape[] styles = { new Rectangle(-10, -10, 20, 20), new Ellipse2D.Double(-10, -10, 20, 20), new Polygon(xShape, yShape, nShape) //Triangolo }; @Override public Shape transform(String i) { String[] type = i.split("#"); if (type[1].equals("par_val")) { return styles[0]; } else if (type[1].equals("par_dim")) { return styles[2]; } else { return styles[1]; } } }; vv.getRenderContext().setVertexShapeTransformer(vertexShape); // vv.getRenderer().setVertexRenderer(new MyRenderer()); //**************** MODIFICA FONT LABEL *************************** vv.getRenderContext().setVertexFontTransformer(new Transformer<String, Font>() { @Override public Font transform(String arg0) { Font font = new Font("Arial Unicode MS", Font.PLAIN, 11); return font; } }); // ********************** POSIZIONA LA LABEL SOTTO IL VERTICE **************************** vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.S); //******************** RIMUOVE DAL TESTO DELLA LABEL DEL VERTICE IL TIPO DI VERTICE ************************ Transformer<String, String> transformer = new Transformer<String, String>() { @Override public String transform(String arg0) { String[] node = arg0.split("#"); return node[0]; } }; vv.getRenderContext().setVertexLabelTransformer(transformer); 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()); } }); 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(scaleGrid); controls.add(modeBox); content.add(controls, BorderLayout.SOUTH); }
From source file:cloud.gui.CloudGUI.java
private void createResponseTimePanel(JFreeChart chart) { if (null != chart) { if (responseTimeDiagramPanel != null) statisticsPanel.remove(responseTimeDiagramPanel); responseTimeDiagramPanel = new ChartPanel(chart); responseTimeDiagramPanel.setBorder(BorderFactory.createTitledBorder("Response Time")); statisticsPanel.add(responseTimeDiagramPanel); statisticsPanel.revalidate();// www . j a v a 2s. co m } else { logger.error("chart for responseTime can not be null"); } }
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 w ww . j ava2s. 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:gridvisual.GridVisualize.java
public GridVisualize() { // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree();/*from w ww .j a v a2s.co 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:demos.TreeCollapse.java
@SuppressWarnings("unchecked") public TreeCollapse() { // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree();//from w ww.ja v a2s. c o m layout = new TreeLayout<String, Integer>(graph); collapser = new TreeCollapser(); radialLayout = new RadialTreeLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(600, 600)); 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()); 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<Object>(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:com.floreantpos.config.ui.TerminalConfigurationView.java
private void initComponents() { setLayout(new BorderLayout()); JPanel contentPanel = new JPanel(new MigLayout("gap 5px 10px", "[][][grow]", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ JLabel lblTerminalNumber = new JLabel(Messages.getString("TerminalConfigurationView.TERMINAL_NUMBER")); //$NON-NLS-1$ contentPanel.add(lblTerminalNumber, "alignx left,aligny center"); //$NON-NLS-1$ tfTerminalNumber = new IntegerTextField(); tfTerminalNumber.setColumns(10);/*from w ww .j a va 2s .c om*/ contentPanel.add(tfTerminalNumber, "aligny top,wrap"); //$NON-NLS-1$ JLabel lblTerminalLocation = new JLabel(Messages.getString("TerminalConfigurationView.24")); //$NON-NLS-1$ taTerminalLocation = new JTextArea(); taTerminalLocation.setLineWrap(true); taTerminalLocation.setPreferredSize(PosUIManager.getSize(350, 40)); JScrollPane taScrollPane = new JScrollPane(taTerminalLocation); contentPanel.add(new JLabel(Messages.getString("TerminalConfigurationView.9"))); //$NON-NLS-1$ tfSecretKeyLength = new IntegerTextField(3); contentPanel.add(tfSecretKeyLength, "wrap"); //$NON-NLS-1$ contentPanel.add(cbShowDbConfiguration, "spanx 3"); //$NON-NLS-1$ cbAutoLogoff.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (cbAutoLogoff.isSelected()) { tfLogoffTime.setEnabled(true); } else { tfLogoffTime.setEnabled(false); } } }); contentPanel.add(cbAutoLogoff, "newline"); //$NON-NLS-1$ contentPanel.add(tfLogoffTime, "wrap"); //$NON-NLS-1$ contentPanel.add(cbTranslatedName, "span 2"); //$NON-NLS-1$ contentPanel.add(cbFullscreenMode, "newline, span"); //$NON-NLS-1$ contentPanel.add(cbUseSettlementPrompt, "newline, span"); //$NON-NLS-1$ contentPanel.add(cbShowBarCodeOnReceipt, "newline,span"); //$NON-NLS-1$ contentPanel.add(cbGroupKitchenReceiptItems, "newline,span"); //$NON-NLS-1$ contentPanel.add(chkEnabledMultiCurrency, "newline,span"); //$NON-NLS-1$ contentPanel.add(chkAllowToDelPrintedItem, "newline,span"); //$NON-NLS-1$ contentPanel.add(chkAllowQuickMaintenance, "newline,span"); //$NON-NLS-1$ contentPanel.add(chkModifierCannotExceedMaxLimit, "newline,span"); //$NON-NLS-1$ contentPanel.add(new JLabel(Messages.getString("TerminalConfigurationView.17")), "newline"); //$NON-NLS-1$//$NON-NLS-2$ contentPanel.add(cbFonts, "span 2, wrap"); //$NON-NLS-1$ Vector<String> defaultViewList = new Vector<String>(); List<OrderType> orderTypes = Application.getInstance().getOrderTypes(); if (orderTypes != null) { for (OrderType orderType : orderTypes) { defaultViewList.add(orderType.getName()); } } defaultViewList.add(SwitchboardOtherFunctionsView.VIEW_NAME); defaultViewList.add(KitchenDisplayView.VIEW_NAME); defaultViewList.add(SwitchboardView.VIEW_NAME); cbDefaultView = new JComboBox<String>(defaultViewList); contentPanel.add(new JLabel("Default View"), "newline"); //$NON-NLS-1$//$NON-NLS-2$ contentPanel.add(cbDefaultView, "span 2, wrap"); //$NON-NLS-1$ contentPanel.add(lblTerminalLocation, "alignx left,aligny top"); //$NON-NLS-1$ contentPanel.add(taScrollPane, "aligny top, spanx 2,wrap"); //$NON-NLS-1$ JPanel touchConfigurationPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 20, 10)); touchConfigurationPanel.setBorder(BorderFactory.createTitledBorder("-")); //$NON-NLS-1$ touchConfigurationPanel.add(new JLabel(Messages.getString("TerminalConfigurationView.18"))); //$NON-NLS-1$ tfButtonHeight = new IntegerTextField(5); //touchConfigPanel.add(tfButtonHeight); int FPS_MIN = 10; int FPS_MAX = 50; int FPS_INIT = 10; jsResize = new JSlider(JSlider.HORIZONTAL, FPS_MIN, FPS_MAX, FPS_INIT); jsResize.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { double fps = (int) source.getValue(); fps = fps / 10; tfScaleFactor.setText(String.valueOf(fps)); } } }); touchConfigurationPanel.add(jsResize); //touchConfigPanel.add(new JLabel("Menu item button height")); tfScaleFactor = new DoubleTextField(5); touchConfigurationPanel.add(tfScaleFactor); //touchConfigPanel.add(new JLabel(Messages.getString("TerminalConfigurationView.20"))); //$NON-NLS-1$ tfFontSize = new IntegerTextField(5); //touchConfigPanel.add(tfFontSize); contentPanel.add(touchConfigurationPanel, "span 3, wrap"); //$NON-NLS-1$ addCashDrawerConfig(); JScrollPane scrollPane = new JScrollPane(contentPanel); scrollPane.setBorder(null); add(scrollPane); }