List of usage examples for javax.swing JPanel setBorder
@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.") public void setBorder(Border border)
From source file:WizardDialog.java
/** * Creates a panel containing the user interface for the dialog. * //www. ja v a 2 s. c o m * @return the panel. */ public JPanel createContent() { final JPanel content = new JPanel(new BorderLayout()); content.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); content.add((JPanel) this.panels.get(0)); final L1R3ButtonPanel buttons = new L1R3ButtonPanel("Help", "Previous", "Next", "Finish"); this.helpButton = buttons.getLeftButton(); this.helpButton.setEnabled(false); this.previousButton = buttons.getRightButton1(); this.previousButton.setActionCommand("previousButton"); this.previousButton.addActionListener(this); this.previousButton.setEnabled(false); this.nextButton = buttons.getRightButton2(); this.nextButton.setActionCommand("nextButton"); this.nextButton.addActionListener(this); this.nextButton.setEnabled(true); this.finishButton = buttons.getRightButton3(); this.finishButton.setActionCommand("finishButton"); this.finishButton.addActionListener(this); this.finishButton.setEnabled(false); buttons.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0)); content.add(buttons, BorderLayout.SOUTH); return content; }
From source file:br.edu.unifei.mestrado.view.GraphPartitioningVisualization.java
private void createView(final int partitions) { clusterer = new PartitionClusterer(partitions); final Graph<NodeWrapper, EdgeWrapper> graph = getGraph(); // Create a simple layout frame // specify the Fruchterman-Rheingold layout algorithm layout = new AggregateLayout<NodeWrapper, EdgeWrapper>(new FRLayout<NodeWrapper, EdgeWrapper>(graph)); vv = new VisualizationViewer<NodeWrapper, EdgeWrapper>(layout); vv.setBackground(Color.white); if (vertexLabelTransformer == null) { vertexLabelTransformer = new Transformer<NodeWrapper, String>() { @Override/* w w w .j a v a2 s . co m*/ public String transform(NodeWrapper v) { // TODO: voltar o D quando necessrio return "V" + v.getId() + ":" + v.getWeight();// + ":" + // v.getD(); } }; } vv.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer); // MapTransformer.<NodeWrapper, String> // getInstance(LazyMap.<NodeWrapper, String> decorate( // new HashMap<NodeWrapper, String>(), new // ToStringLabeller<NodeWrapper>()))); vv.getRenderContext().setEdgeLabelTransformer(edgeLabelTransformer); // UTIL: Alguma coisa, talvez o LazyMap no estava repintando a aresta // com o peso alterado // MapTransformer.<EdgeWrapper, String> // getInstance(LazyMap.<EdgeWrapper, String> decorate( // new HashMap<EdgeWrapper, String>(), new // ToStringLabeller<EdgeWrapper>() { // @Override // public String transform(EdgeWrapper v) { // logger.warn("A:" + v.getId() + ":" + v.getWeight()); // return "A:" + v.getId() + ":" + v.getWeight(); // } // }))); // Tell the renderer to use our own customized color rendering vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<NodeWrapper, EdgeWrapper>()); vv.getRenderContext().setVertexShapeTransformer(vertexShapeTransformer); vv.getRenderContext().setVertexFillPaintTransformer(vertexFillPaintTransformer); vv.getRenderContext().setVertexDrawPaintTransformer(vertexDrawPaintTransformer); vv.getRenderContext().setVertexStrokeTransformer(vertexStrokeTransformer); vv.getRenderContext().setEdgeDrawPaintTransformer(new Transformer<EdgeWrapper, Paint>() { // UTIL: Define as cores das arestas @Override public Paint transform(EdgeWrapper linkToProcess) { // if para mostrar arestas com as duas pontas no mesmo vertices if (linkToProcess.getStartNode().getId() == linkToProcess.getEndNode().getId()) { return Color.red; } Set<NodeWrapper> nodes = vv.getPickedVertexState().getPicked(); for (NodeWrapper node : nodes) { for (EdgeWrapper link : node.getEdges()) { if (link.getId() == linkToProcess.getId()) { return Color.orange; } } } if (linkToProcess.isEdgeOnCut()) { return Color.green; } return Color.blue; } }); // MapTransformer.<EdgeWrapper, Paint> getInstance(edgePaints)); vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<EdgeWrapper, Stroke>() { protected final Stroke THIN = new BasicStroke(1); // protected final Stroke THICK = new BasicStroke(2); protected final Stroke STRONG_THICK = new BasicStroke(3); public Stroke transform(EdgeWrapper e) { // if para mostrar arestas com as duas pontas no mesmo vertices if (e.getStartNode().getId() == e.getEndNode().getId()) { return STRONG_THICK; } // Paint c = edgePaints.get(e); // if (c == Color.red) return THIN; // else // return THIN; } }); DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); vv.setGraphMouse(gm); groupVertices = new JToggleButton("Group Clusters"); groupVertices.setSelected(true); groupVertices.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { clusterAndRecolor(layout, e.getStateChange() == ItemEvent.SELECTED, getGroupCircleVertices().isSelected()); vv.repaint(); } }); clusterAndRecolor(layout, groupVertices.isSelected(), getGroupCircleVertices().isSelected()); Container content = getContentPane(); content.add(new GraphZoomScrollPane(vv)); JPanel south = new JPanel(new GridLayout(1, 4)); JPanel grid1 = new JPanel(new GridLayout(2, 1)); grid1.add(groupVertices); grid1.add(getGroupCircleVertices()); south.add(grid1); 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 grid2 = new JPanel(new GridLayout(2, 1)); grid2.setBorder(BorderFactory.createTitledBorder("Scale")); south.add(grid2); grid2.add(plus); grid2.add(minus); JPanel grid3 = new JPanel(new GridLayout(1, 2)); south.add(grid3); grid3.add(getIterationLabel()); grid3.add(getCutLabel()); JPanel p = new JPanel(); p.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); p.add(gm.getModeComboBox()); south.add(p); content.add(south, BorderLayout.SOUTH); vv.repaint(); }
From source file:com.web.vehiclerouting.optaplanner.common.swingui.SolverAndPersistenceFrame.java
private JComponent createQuickOpenPanel(List<Action> quickOpenActionList, List<File> fileList, String title) { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); if (fileList.isEmpty()) { JLabel noneLabel = new JLabel("None"); noneLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); panel.add(noneLabel);//from ww w . j ava2 s. c o m } else { for (File file : fileList) { Action quickOpenAction = new QuickOpenAction(file); quickOpenActionList.add(quickOpenAction); JButton quickOpenButton = new JButton(quickOpenAction); quickOpenButton.setHorizontalAlignment(SwingConstants.LEFT); quickOpenButton.setMargin(new Insets(0, 0, 0, 0)); panel.add(quickOpenButton); } } JScrollPane scrollPane = new JScrollPane(panel); scrollPane.getVerticalScrollBar().setUnitIncrement(25); scrollPane.setMinimumSize(new Dimension(100, 80)); // Size fits into screen resolution 1024*768 scrollPane.setPreferredSize(new Dimension(180, 200)); JPanel titlePanel = new JPanel(new BorderLayout()); titlePanel.add(scrollPane, BorderLayout.CENTER); titlePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), BorderFactory.createTitledBorder(title))); return titlePanel; }
From source file:livecanvas.mesheditor.MeshEditor.java
public MeshEditor() { super("Mesh Editor", new ImageIcon(clazz.getResource("res/mesh_editor.png")), new BorderLayout()); setPreferredSize(new Dimension(1024, 600)); setBackground(Color.darkGray); tools = createTools();/*from w w w . ja v a 2 s . c o m*/ add(tools, BorderLayout.WEST); selectedColor = Color.black; JPanel east = new JPanel(new BorderLayout()); east.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); Layer rootLayer = new Layer("ROOT"); rootLayer.addSubLayer(new Layer("Layer1")); layersView = new LayersView(rootLayer); chain(layersView); layersView.addListener(this); east.add(layersView, BorderLayout.NORTH); propertiesPanel = new JPanel(new BorderLayout()); east.add(propertiesPanel); viewpointsView = new ViewpointsView(layersView.getSelectedLayer()); viewpointsView.addListener(this); east.add(viewpointsView, BorderLayout.SOUTH); add(east, BorderLayout.EAST); JPanel center = new JPanel(new BorderLayout()); center.setBackground(Color.lightGray); canvas = new CanvasMesh(800, 600); canvas.setCurrLayer(getRootLayer()); pointerHandler = new AffineTransformPointerHandler(canvas); canvas.setPointerHandler(pointerHandler); canvasContainer = new CanvasContainer(canvas); rootLayer.setCanvas(canvas); center.add(canvasContainer); renderImageSettings = new RenderImageSettings(); settings = new MeshEditorSettings(canvas.getSettings(), layersView.getSettings(), renderImageSettings); add(center); layersView.layersList.setSelectedIndex(1); setSelectedToolType(TOOLS_BRUSH); }
From source file:FontChooser.java
private void createUserInterface() { final JPanel content = new JPanel(new GridBagLayout()); final GridBagConstraints gbc = new GridBagConstraints(); setContentPane(content);// w w w. j a v a2 s . c o m content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(2, 2, 2, 2); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = gbc.gridy = 0; content.add(new JLabel("Font"), gbc); ++gbc.gridx; content.add(new JLabel("Size"), gbc); if (_selectStyles) { ++gbc.gridx; content.add(new JLabel("Style"), gbc); } ++gbc.gridy; gbc.gridx = 0; _fontNamesCmb = new JComboBox( GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()); content.add(_fontNamesCmb, gbc); ++gbc.gridx; _fontSizesCmb.setEditable(true); content.add(_fontSizesCmb, gbc); if (_selectStyles) { ++gbc.gridx; content.add(_boldChk, gbc); ++gbc.gridy; content.add(_italicChk, gbc); } gbc.gridx = 0; ++gbc.gridy; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.CENTER; content.add(createPreviewPanel(), gbc); ++gbc.gridy; gbc.fill = GridBagConstraints.HORIZONTAL; content.add(createButtonsPanel(), gbc); pack(); setResizable(true); }
From source file:io.github.jeremgamer.editor.panels.MusicFrame.java
public MusicFrame(JFrame frame, final GeneralSave gs) { ArrayList<BufferedImage> icons = new ArrayList<BufferedImage>(); try {/* w w w . j ava2 s . c o m*/ icons.add(ImageIO.read(ImageGetter.class.getResource("icon16.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon32.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon64.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon128.png"))); } catch (IOException e1) { e1.printStackTrace(); } this.setIconImages((List<? extends Image>) icons); this.setTitle("Musique"); this.setSize(new Dimension(300, 225)); this.addWindowListener(new WindowListener() { @Override public void windowActivated(WindowEvent event) { } @Override public void windowClosed(WindowEvent event) { } @Override public void windowClosing(WindowEvent event) { try { gs.save(new File("projects/" + Editor.getProjectName() + "/general.rbd")); } catch (IOException e) { e.printStackTrace(); } if (clip != null) { clip.stop(); clip.close(); try { audioStream.close(); } catch (IOException e) { e.printStackTrace(); } } } @Override public void windowDeactivated(WindowEvent event) { } @Override public void windowDeiconified(WindowEvent event) { } @Override public void windowIconified(WindowEvent event) { } @Override public void windowOpened(WindowEvent event) { } }); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS)); this.setModal(true); this.setLocationRelativeTo(frame); JPanel properties = new JPanel(); properties.setBorder(BorderFactory.createTitledBorder("Lecture")); ButtonGroup bg = new ButtonGroup(); bg.add(one); bg.add(loop); one.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { JRadioButton rb = (JRadioButton) event.getSource(); if (rb.isSelected()) { gs.set("music.reading", 0); try { gs.save(new File("projects/" + Editor.getProjectName() + "/general.rbd")); } catch (IOException e) { e.printStackTrace(); } if (clip != null) { if (clip.isRunning()) clip.loop(0); } } } }); loop.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { JRadioButton rb = (JRadioButton) event.getSource(); if (rb.isSelected()) { gs.set("music.reading", 1); try { gs.save(new File("projects/" + Editor.getProjectName() + "/general.rbd")); } catch (IOException e) { e.printStackTrace(); } if (clip != null) { if (clip.isRunning()) clip.loop(Clip.LOOP_CONTINUOUSLY); } } } }); properties.add(one); properties.add(loop); if (gs.getInt("music.reading") == 0) { one.setSelected(true); } else { loop.setSelected(true); } volume.setMaximum(100); volume.setMinimum(0); volume.setValue(30); volume.setPaintTicks(true); volume.setPaintLabels(true); volume.setMinorTickSpacing(10); volume.setMajorTickSpacing(20); volume.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { JSlider slider = (JSlider) event.getSource(); double value = slider.getValue(); gain = value / 100; dB = (float) (Math.log(gain) / Math.log(10.0) * 20.0); if (clip != null) gainControl.setValue(dB); gs.set("music.volume", (int) value); } }); volume.setValue(gs.getInt("music.volume")); properties.add(volume); properties.setPreferredSize(new Dimension(300, 125)); content.add(properties); JPanel browsePanel = new JPanel(); browsePanel.setBorder(BorderFactory.createTitledBorder("")); JButton browse = new JButton("Parcourir..."); if (new File("projects/" + Editor.getProjectName() + "/music.wav").exists()) { preview.setEnabled(false); browse.setText(""); try { browse.setIcon(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } } browse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { JButton button = (JButton) event.getSource(); if (new File("projects/" + Editor.getProjectName() + "/music.wav").exists()) { if (clip != null) { clip.stop(); clip.close(); try { audioStream.close(); } catch (IOException e) { e.printStackTrace(); } } name.setText(""); preview.setEnabled(false); button.setText("Parcourir..."); button.setIcon(null); new File("projects/" + Editor.getProjectName() + "/music.wav").delete(); gs.set("music.name", ""); } else { String path = null; JFileChooser chooser = new JFileChooser(Editor.lastPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("Audio (WAV)", "wav"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); Editor.lastPath = chooser.getSelectedFile().getParent(); copyMusic(new File(path)); button.setText(""); try { button.setIcon( new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } gs.set("music.name", new File(path).getName()); try { gs.save(new File("projects/" + Editor.getProjectName() + "/general.rbd")); } catch (IOException e) { e.printStackTrace(); } name.setText(new File(path).getName()); preview.setEnabled(true); } } } }); if (new File("projects/" + Editor.getProjectName() + "/music.wav").exists()) { preview.setEnabled(true); } else { preview.setEnabled(false); } preview.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { JToggleButton tb = (JToggleButton) event.getSource(); if (tb.isSelected()) { try { audioStream = AudioSystem.getAudioInputStream( new File("projects/" + Editor.getProjectName() + "/music.wav")); format = audioStream.getFormat(); info = new DataLine.Info(Clip.class, format); clip = (Clip) AudioSystem.getLine(info); clip.open(audioStream); clip.start(); gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN); gainControl.setValue(dB); if (loop.isSelected()) { clip.loop(Clip.LOOP_CONTINUOUSLY); } else { clip.loop(0); } clip.addLineListener(new LineListener() { @Override public void update(LineEvent event) { Clip clip = (Clip) event.getSource(); if (!clip.isRunning()) { preview.setSelected(false); clip.stop(); clip.close(); try { audioStream.close(); } catch (IOException e) { e.printStackTrace(); } } } }); } catch (Exception exc) { exc.printStackTrace(); } } else { clip.stop(); clip.close(); try { audioStream.close(); } catch (IOException e) { e.printStackTrace(); } } } }); JPanel buttons = new JPanel(); buttons.setLayout(new BorderLayout()); buttons.add(browse, BorderLayout.WEST); buttons.add(preview, BorderLayout.EAST); browsePanel.setLayout(new BorderLayout()); browsePanel.add(buttons, BorderLayout.NORTH); browsePanel.add(name, BorderLayout.SOUTH); name.setPreferredSize(new Dimension(280, 25)); name.setText(gs.getString("music.name")); content.add(browsePanel); this.setContentPane(content); this.setVisible(true); }
From source file:org.obiba.onyx.jade.instrument.ricelake.RiceLakeWeightInstrumentRunner.java
protected JPanel buildMeasureCountSubPanel() { JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); panel.add(measureCountLabel = new MeasureCountLabel()); panel.setAlignmentX(Component.LEFT_ALIGNMENT); return (panel); }
From source file:com.employee.scheduler.common.swingui.SolverAndPersistenceFrame.java
private JComponent createQuickOpenPanel(JPanel panel, String title, List<Action> quickOpenActionList, List<File> fileList) { panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); refreshQuickOpenPanel(panel, quickOpenActionList, fileList); JScrollPane scrollPane = new JScrollPane(panel); scrollPane.getVerticalScrollBar().setUnitIncrement(25); scrollPane.setMinimumSize(new Dimension(100, 80)); // Size fits into screen resolution 1024*768 scrollPane.setPreferredSize(new Dimension(180, 200)); JPanel titlePanel = new JPanel(new BorderLayout()); titlePanel.add(scrollPane, BorderLayout.CENTER); titlePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), BorderFactory.createTitledBorder(title))); return titlePanel; }
From source file:es.urjc.ia.fia.genericSearch.statistics.JUNGStatistics.java
@Override public void showStatistics() { // Layout: tree and radial treeLayout = new TreeLayout<AuxVertex, ACTION>(this.tree, 35, 100); radialLayout = new RadialTreeLayout<AuxVertex, ACTION>(this.tree, 35, 130); radialLayout.setSize(new Dimension(200 * (this.tree.getHeight() + 1), 200 * (this.tree.getHeight() + 1))); // The BasicVisualizationServer<V,E> is parameterized by the edge types vv = new VisualizationViewer<AuxVertex, ACTION>(treeLayout); vv.setPreferredSize(new Dimension(800, 600)); //Sets the viewing area size vv.setBackground(Color.white); // Background color vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<AuxVertex>()); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<AuxVertex, ACTION>()); // Setup up a new vertex to paint transformer Transformer<AuxVertex, Paint> vertexPaint = new Transformer<AuxVertex, Paint>() { @Override/*from w w w . j a v a2 s.c om*/ public Paint transform(AuxVertex arg0) { if (arg0.getState().isSolution() && arg0.isExplored()) { return Color.GREEN; } else if (arg0.isExplored()) { return Color.CYAN; } else if (arg0.isDuplicated()) { return Color.GRAY; } else { return Color.WHITE; } } }; // Tooltip for vertex Transformer<AuxVertex, String> toolTipsState = new Transformer<AuxVertex, String>() { @Override public String transform(AuxVertex arg0) { String sortInfo = ""; if (arg0.isExplored()) { if (arg0.getState().isSolution() && arg0.isExplored()) { sortInfo = "<u><i>Solution state " + arg0.getExplored() + "</i></u>"; } else { sortInfo = "<u><i>Explored state " + arg0.getExplored() + "</i></u>"; } } else if (arg0.isDuplicated()) { sortInfo = "<u><i>Duplicated state </i></u>"; } else { sortInfo = "<u><i>Unexplored state</i></u>"; } return "<html><p>" + sortInfo + "</p>" + "<p>State: " + arg0.getState().toString() + "</p>" + "<p>Cost: " + arg0.getState().getSolutionCost() + "</p></html>"; } }; vv.setVertexToolTipTransformer(toolTipsState); // Tooltip for edge Transformer<ACTION, String> toolTipsAction = new Transformer<ACTION, String>() { @Override public String transform(ACTION arg0) { return "Cost: " + arg0.cost(); } }; vv.setEdgeToolTipTransformer(toolTipsAction); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<AuxVertex, ACTION>()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<ACTION>()); vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); // Create a graph mouse and add it to the visualization component DefaultModalGraphMouse<State<ACTION>, ACTION> gm = new DefaultModalGraphMouse<State<ACTION>, ACTION>(); gm.setMode(ModalGraphMouse.Mode.TRANSFORMING); vv.setGraphMouse(gm); vv.addKeyListener(gm.getModeKeyListener()); JFrame vFrame = new JFrame("Statistics Tree View"); vFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); /* vFrame.getContentPane().add(vv); vFrame.pack(); vFrame.setVisible(true); */ rings = new Rings(); Container content = vFrame.getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); JComboBox modeBox = gm.getModeComboBox(); modeBox.addItemListener(gm.getModeListener()); gm.setMode(ModalGraphMouse.Mode.TRANSFORMING); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { @Override 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<AuxVertex, ACTION> lt = new LayoutTransition<AuxVertex, ACTION>(vv, treeLayout, radialLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.addPreRenderPaintable(rings); } else { LayoutTransition<AuxVertex, ACTION> lt = new LayoutTransition<AuxVertex, ACTION>(vv, radialLayout, treeLayout); 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")); /* * Statistics */ JLabel stats = new JLabel(); long totalTime = endTime.getTime() - initTime.getTime(); stats.setText("<html>" + "<b>Total States:</b> " + this.totalStates + "<br>" + "<b>Explored States:</b> " + this.explorerStates + "<br>" + "<b>Duplicated States (detected):</b> " + this.duplicatedStates + "<br>" + "<b>Solution States:</b> " + this.solutionStates + "<br>" + "<b>Total time: </b>" + totalTime + " milliseconds" + "</html>"); JPanel legend = new JPanel(); legend.setLayout(new BoxLayout(legend, BoxLayout.Y_AXIS)); JLabel len = new JLabel("<html><b>Lengend</b></html>"); JLabel lexpl = new JLabel("Explored state"); lexpl.setBackground(Color.CYAN); lexpl.setOpaque(true); JLabel lune = new JLabel("Unexplored state"); lune.setBackground(Color.WHITE); lune.setOpaque(true); JLabel ldupl = new JLabel("Duplicated state"); ldupl.setBackground(Color.GRAY); ldupl.setOpaque(true); JLabel lsol = new JLabel("Solution state"); lsol.setBackground(Color.GREEN); lsol.setOpaque(true); legend.add(len); legend.add(lexpl); legend.add(lune); legend.add(ldupl); legend.add(lsol); JPanel controls = new JPanel(); controls.add(stats); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(radial); controls.add(scaleGrid); //controls.add(modeBox); controls.add(legend); content.add(controls, BorderLayout.SOUTH); vFrame.pack(); vFrame.setVisible(true); }
From source file:edu.wpi.cs.wpisuitetng.modules.requirementsmanager.view.charts.StatView.java
/** * Builds the side panel with all the options for this StatViw * // w w w . ja v a2s .c o m * @return the formatted side panel */ public JPanel buildSidePanel() { final int VERTICAL_PADDING = 5; final int HORIZONTAL_PADDING = 5; final int FAR = 5; final SpringLayout sidePanelLayout = new SpringLayout(); final JPanel sidePanel = new JPanel(sidePanelLayout); final JLabel lblStatisticType = new JLabel("Statistic Type"); final String[] availableStatisticTypes = { "Status", "Assignees", "Iterations", "Velocity" }; // TODO: Add Estimates, Effort, Tasks charts for future use. comboBoxStatisticType = new JComboBox(availableStatisticTypes); comboBoxStatisticType.addActionListener(this); makePieRadio = new JRadioButton("Pie Chart"); makePieRadio.setMnemonic(KeyEvent.VK_P); makePieRadio.setActionCommand("Pie Chart"); makePieRadio.addActionListener(this); makeBarRadio = new JRadioButton("Bar Chart"); makeBarRadio.setMnemonic(KeyEvent.VK_B); makeBarRadio.setActionCommand("Bar Chart"); makeBarRadio.addActionListener(this); makeLineRadio = new JRadioButton("Line Chart"); makeLineRadio.setMnemonic(KeyEvent.VK_B); makeLineRadio.setActionCommand("Line Chart"); makeLineRadio.addActionListener(this); makeLineRadio.setEnabled(false); final ButtonGroup group = new ButtonGroup(); group.add(makePieRadio); group.add(makeBarRadio); group.add(makeLineRadio); updateSelectedItems(); final JPanel radioPanel = new JPanel(new GridLayout(3, 1)); radioPanel.add(makePieRadio); radioPanel.add(makeBarRadio); radioPanel.add(makeLineRadio); radioPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Chart Type")); sidePanel.add(lblStatisticType); sidePanel.add(comboBoxStatisticType); sidePanel.add(radioPanel); sidePanelLayout.putConstraint(SpringLayout.NORTH, lblStatisticType, VERTICAL_PADDING, SpringLayout.NORTH, sidePanel); sidePanelLayout.putConstraint(SpringLayout.WEST, lblStatisticType, HORIZONTAL_PADDING, SpringLayout.WEST, sidePanel); sidePanelLayout.putConstraint(SpringLayout.NORTH, comboBoxStatisticType, VERTICAL_PADDING, SpringLayout.SOUTH, lblStatisticType); sidePanelLayout.putConstraint(SpringLayout.WEST, comboBoxStatisticType, HORIZONTAL_PADDING, SpringLayout.WEST, sidePanel); sidePanelLayout.putConstraint(SpringLayout.NORTH, radioPanel, VERTICAL_PADDING + FAR, SpringLayout.SOUTH, comboBoxStatisticType); sidePanelLayout.putConstraint(SpringLayout.WEST, radioPanel, HORIZONTAL_PADDING, SpringLayout.WEST, sidePanel); return sidePanel; }