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:net.sf.housekeeper.swing.FoodEditorView.java
/** * Initializes the dialog's properties and builds its content pane and. The * dialog is then ready to be opened.//w w w. j a v a 2s . c om */ private void initDialog() { final JPanel panel = new JPanel(new BorderLayout()); panel.add(createEditorPanel(), BorderLayout.CENTER); panel.add(buildButtonBar(), BorderLayout.SOUTH); panel.setBorder(Borders.DIALOG_BORDER); dialog.setContentPane(panel); dialog.setResizable(false); }
From source file:edu.ku.brc.specify.config.AgentSearchDialogES.java
/** * Creates the Default UI for Lable task * *//*from w w w . j a v a 2 s . c o m*/ protected void createUI() { searchText = createTextField(30); searchBtn = createButton(getResourceString("SEARCH")); ActionListener doQuery = new ActionListener() { public void actionPerformed(ActionEvent e) { form.getDataFromUI(); StringBuilder strBuf = new StringBuilder(128); for (String key : formFieldToColumnMap.keySet()) { String value = dataMap.get(key); if (isNotEmpty(value)) { if (strBuf.length() > 0) { strBuf.append(" OR "); } strBuf.append(formFieldToColumnMap.get(key) + ":" + value); } } searchText.setText(strBuf.toString()); doQuery(); } }; searchBtn.addActionListener(doQuery); searchText.addActionListener(doQuery); searchText.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (searchText.getBackground() != textBGColor) { searchText.setBackground(textBGColor); } } }); String viewName = "test"; String name = null; // use the default formView = AppContextMgr.getInstance().getView(name, viewName); if (formView != null) { form = ViewFactory.createFormView(null, formView, null, dataMap, MultiView.NO_OPTIONS, null); if (form != null) { add(form.getUIComponent(), BorderLayout.CENTER); } else { return; } } else { log.info("Couldn't load form with name [" + name + "] Id [" + viewName + "]"); } //form.setDataObj(prefNode); //form.getValidator().validateForm(); JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 10)); PanelBuilder builder = new PanelBuilder(new FormLayout("p,1dlu,p", "p,2dlu,p,2dlu,p")); CellConstraints cc = new CellConstraints(); //builder.addSeparator(getResourceString("AgentSearchTitle"), cc.xywh(1,1,3,1)); builder.add(form.getUIComponent(), cc.xy(1, 1)); builder.add(searchBtn, cc.xy(3, 1)); panel.add(builder.getPanel(), BorderLayout.NORTH); contentPanel = new JPanel(new NavBoxLayoutManager(0, 2)); //contentPanel.setMaximumSize(new Dimension(300,300)); //contentPanel.setPreferredSize(new Dimension(300,300)); scrollPane = new JScrollPane(contentPanel); panel.add(scrollPane, BorderLayout.CENTER); //scrollPane.setMaximumSize(new Dimension(300,300)); scrollPane.setPreferredSize(new Dimension(300, 200)); // Bottom Button UI cancelBtn = createButton(getResourceString("CANCEL")); okBtn = createButton(getResourceString("OK")); okBtn.addActionListener(this); getRootPane().setDefaultButton(okBtn); ButtonBarBuilder btnBuilder = new ButtonBarBuilder(); btnBuilder.addGlue(); btnBuilder.addGriddedButtons(new JButton[] { cancelBtn, okBtn }); cancelBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setVisible(false); } }); panel.add(btnBuilder.getPanel(), BorderLayout.SOUTH); setContentPane(panel); pack(); updateUI(); }
From source file:ca.uhn.hl7v2.testpanel.ui.AddMessageDialog.java
/** * Create the dialog.//w w w . j a v a2 s. co m */ public AddMessageDialog(Controller theController) { myController = theController; setMinimumSize(new Dimension(450, 400)); setPreferredSize(new Dimension(450, 400)); setSize(new Dimension(450, 400)); setResizable(false); setMaximumSize(new Dimension(450, 400)); setTitle("Add Message"); setBounds(100, 100, 450, 401); getContentPane().setLayout(new BorderLayout()); mycontentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(mycontentPanel, BorderLayout.CENTER); GridBagLayout gbl_contentPanel = new GridBagLayout(); gbl_contentPanel.columnWidths = new int[] { 0, 0 }; gbl_contentPanel.rowHeights = new int[] { 0, 0, 0 }; gbl_contentPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_contentPanel.rowWeights = new double[] { 1.0, 0.0, Double.MIN_VALUE }; mycontentPanel.setLayout(gbl_contentPanel); { JPanel panel = new JPanel(); panel.setBorder( new TitledBorder(null, "Message Type", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_panel = new GridBagConstraints(); gbc_panel.weighty = 1.0; gbc_panel.insets = new Insets(0, 0, 5, 0); gbc_panel.fill = GridBagConstraints.BOTH; gbc_panel.gridx = 0; gbc_panel.gridy = 0; mycontentPanel.add(panel, gbc_panel); GridBagLayout gbl_panel = new GridBagLayout(); gbl_panel.columnWidths = new int[] { 0, 0, 0 }; gbl_panel.rowHeights = new int[] { 0, 0, 0 }; gbl_panel.columnWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE }; gbl_panel.rowWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; panel.setLayout(gbl_panel); { JLabel lblVersion = new JLabel("Version"); GridBagConstraints gbc_lblVersion = new GridBagConstraints(); gbc_lblVersion.insets = new Insets(0, 0, 5, 5); gbc_lblVersion.gridx = 0; gbc_lblVersion.gridy = 0; panel.add(lblVersion, gbc_lblVersion); } { JLabel lblType = new JLabel("Type"); GridBagConstraints gbc_lblType = new GridBagConstraints(); gbc_lblType.insets = new Insets(0, 0, 5, 0); gbc_lblType.gridx = 1; gbc_lblType.gridy = 0; panel.add(lblType, gbc_lblType); } { JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportBorder(null); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.weighty = 1.0; gbc_scrollPane.insets = new Insets(0, 0, 0, 5); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 0; gbc_scrollPane.gridy = 1; panel.add(scrollPane, gbc_scrollPane); { myVersionList = new JList(); myVersionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); scrollPane.setViewportView(myVersionList); } } { JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportBorder(null); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.weighty = 1.0; gbc_scrollPane.weightx = 1.0; gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 1; gbc_scrollPane.gridy = 1; panel.add(scrollPane, gbc_scrollPane); { myMessageTypeList = new JList(); myMessageTypeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); scrollPane.setViewportView(myMessageTypeList); } } } { JPanel panel = new JPanel(); panel.setBorder(new TitledBorder(null, "Options", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_panel = new GridBagConstraints(); gbc_panel.fill = GridBagConstraints.BOTH; gbc_panel.gridx = 0; gbc_panel.gridy = 1; mycontentPanel.add(panel, gbc_panel); GridBagLayout gbl_panel = new GridBagLayout(); gbl_panel.columnWidths = new int[] { 0, 0, 0 }; gbl_panel.rowHeights = new int[] { 0, 0 }; gbl_panel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gbl_panel.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; panel.setLayout(gbl_panel); { JLabel lblEncoding = new JLabel("Encoding"); GridBagConstraints gbc_lblEncoding = new GridBagConstraints(); gbc_lblEncoding.insets = new Insets(0, 0, 0, 5); gbc_lblEncoding.gridx = 0; gbc_lblEncoding.gridy = 0; panel.add(lblEncoding, gbc_lblEncoding); } { JPanel panel_1 = new JPanel(); panel_1.setBorder(null); GridBagConstraints gbc_panel_1 = new GridBagConstraints(); gbc_panel_1.anchor = GridBagConstraints.WEST; gbc_panel_1.fill = GridBagConstraints.VERTICAL; gbc_panel_1.gridx = 1; gbc_panel_1.gridy = 0; panel.add(panel_1, gbc_panel_1); { myEr7Radio = new JRadioButton("ER7"); myEr7Radio.setSelected(true); encodingButtonGroup.add(myEr7Radio); panel_1.add(myEr7Radio); } { JRadioButton myXmlRadio = new JRadioButton("XML"); encodingButtonGroup.add(myXmlRadio); panel_1.add(myXmlRadio); } } } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { String version = (String) myVersionList.getSelectedValue(); String fullType = (String) myMessageTypeList.getSelectedValue(); String structure = myTypesToStructures.get(fullType); String[] fullTypeBits = fullType.split("\\^"); String type = fullTypeBits[0]; String trigger = fullTypeBits[1]; Hl7V2EncodingTypeEnum encoding = myEr7Radio.isSelected() ? Hl7V2EncodingTypeEnum.ER_7 : Hl7V2EncodingTypeEnum.XML; myController.addMessage(version, type, trigger, structure, encoding); } finally { setVisible(false); } } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AddMessageDialog.this.setVisible(false); } }); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } initLocal(); }
From source file:se.six.jmeter.visualizer.statagg.StatAggVisualizer.java
/** * Main visualizer setup.//w ww . java 2s. co m */ private void init() { this.setLayout(new BorderLayout()); // MAIN PANEL JPanel mainPanel = new JPanel(); Border margin = new EmptyBorder(10, 10, 5, 10); mainPanel.setBorder(margin); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); //mainPanel.add(makeTitlePanel()); _chart = createChart(); _chartPanel = new ChartPanel(_chart); mainPanel.add(_chartPanel); _model = new StatAggTreeTableModel(); _table = new JXTreeTable(_model); _table.setRootVisible(false); //table.setShowHorizontalLines(true); //table.setShowVerticalLines(true); _table.setLeafIcon(new ImageIcon(getClass().getResource("task.png"))); _table.setRowSelectionAllowed(true); _table.setExpandsSelectedPaths(true); _table.setPreferredScrollableViewportSize(new Dimension(500, 70)); JScrollPane scrollPane = new JScrollPane(_table); this.add(mainPanel, BorderLayout.NORTH); this.add(scrollPane, BorderLayout.CENTER); }
From source file:gov.loc.repository.bagger.ui.NewBagInPlaceFrame.java
private JPanel createComponents() { TitlePane titlePane = new TitlePane(); initStandardCommands();//from w ww . ja va2s . c o m JPanel pageControl = new JPanel(new BorderLayout()); JPanel titlePaneContainer = new JPanel(new BorderLayout()); titlePane.setTitle(bagView.getPropertyMessage("NewBagInPlace.title")); titlePane.setMessage(new DefaultMessage(bagView.getPropertyMessage("NewBagInPlace.description"))); titlePaneContainer.add(titlePane.getControl()); titlePaneContainer.add(new JSeparator(), BorderLayout.SOUTH); pageControl.add(titlePaneContainer, BorderLayout.NORTH); JPanel contentPanel = new JPanel(new GridBagLayout()); contentPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); int row = 0; layoutSelectDataContent(contentPanel, row++); layoutBagVersionContent(contentPanel, row++); layoutProfileSelectionContent(contentPanel, row++); layoutAddKeepFilesToEmptyCheckBox(contentPanel, row++); layoutSpacer(contentPanel, row++); GuiStandardUtils.attachDialogBorder(contentPanel); pageControl.add(contentPanel); JComponent buttonBar = createButtonBar(); pageControl.add(buttonBar, BorderLayout.SOUTH); this.pack(); return pageControl; }
From source file:com.hp.alm.ali.idea.content.settings.SettingsPanel.java
public SettingsPanel(final Project prj, Color bgColor) { this.prj = prj; this.projectConf = prj.getComponent(AliProjectConfiguration.class); previewAndConnection = new JPanel(new GridBagLayout()); previewAndConnection.setOpaque(false); GridBagConstraints c2 = new GridBagConstraints(); c2.gridx = 0;/*ww w.j a v a 2 s. c om*/ c2.gridy = 1; c2.gridwidth = 2; c2.weighty = 1; c2.fill = GridBagConstraints.VERTICAL; JPanel filler = new JPanel(); filler.setOpaque(false); previewAndConnection.add(filler, c2); passwordPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); passwordPanel.setBackground(bgColor); JLabel label = new JLabel("Password"); label.setFont(label.getFont().deriveFont(Font.BOLD)); passwordPanel.add(label); final JPasswordField password = new JPasswordField(24); passwordPanel.add(password); JButton connect = new JButton("Login"); passwordPanel.add(connect); final JLabel message = new JLabel(); passwordPanel.add(message); ActionListener connectionAction = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { try { checkConnection(projectConf.getLocation(), projectConf.getDomain(), projectConf.getProject(), projectConf.getUsername(), password.getText()); } catch (AuthenticationFailed e) { message.setText(e.getMessage()); return; } projectConf.ALM_PASSWORD = password.getText(); projectConf.fireChanged(); } }; password.addActionListener(connectionAction); connect.addActionListener(connectionAction); restService = prj.getComponent(RestService.class); restService.addServerTypeListener(this); location = createTextPane(bgColor); domain = createTextPane(bgColor); project = createTextPane(bgColor); username = createTextPane(bgColor); final JPanel panel = new JPanel(new BorderLayout()); panel.setBackground(bgColor); panel.setBorder(new EmptyBorder(10, 10, 10, 10)); final JTextPane textPane = new JTextPane(); textPane.setEditorKit(new HTMLEditorKit()); textPane.setText( "<html><body>HP ALM integration can be configured on <a href=\"ide\">IDE</a> and overridden on <a href=\"project\">project</a> level.</body></html>"); textPane.setEditable(false); textPane.addHyperlinkListener(this); textPane.setBackground(bgColor); textPane.setCaret(new NonAdjustingCaret()); panel.add(textPane, BorderLayout.CENTER); JPanel content = new JPanel(new BorderLayout()); content.setBackground(bgColor); content.add(panel, BorderLayout.NORTH); content.add(previewAndConnection, BorderLayout.WEST); preview = new JPanel(new GridBagLayout()) { public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); // make enough room for the connection status message dim.width = Math.max(dim.width, 300); return dim; } public Dimension getMinimumSize() { return getPreferredSize(); } }; connectedTo(restService.getServerTypeIfAvailable()); preview.setBackground(bgColor); final GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.gridx = 0; c.gridy = 0; c.gridwidth = 2; c.anchor = GridBagConstraints.WEST; preview.add(location, c); c.gridwidth = 1; c.gridy++; preview.add(domain, c); c.gridy++; preview.add(project, c); c.gridy++; preview.add(username, c); c.gridx++; c.gridy--; c.gridheight = 2; c.weightx = 0; c.anchor = GridBagConstraints.SOUTHEAST; final LinkLabel reload = new LinkLabel("Reload", IconLoader.getIcon("/actions/sync.png")); reload.setListener(new LinkListener() { public void linkSelected(LinkLabel linkLabel, Object o) { projectConf.fireChanged(); } }, null); preview.add(reload, c); JPanel previewNorth = new JPanel(new BorderLayout()); previewNorth.setBackground(bgColor); previewNorth.add(preview, BorderLayout.NORTH); addToGridBagPanel(0, 0, previewAndConnection, previewNorth); setBackground(bgColor); setLayout(new BorderLayout()); add(content, BorderLayout.CENTER); onChanged(); ApplicationManager.getApplication().getComponent(AliConfiguration.class).addListener(this); projectConf.addListener(this); }
From source file:net.lldp.checksims.ui.results.ScrollViewer.java
/** * Create a scroll viewer from a sortable Matrix Viewer * @param results the sortableMatrix to view * @param toRevalidate frame to revalidate sometimes *///from w w w . j a v a2 s. co m public ScrollViewer(SimilarityMatrix exportMatrix, SortableMatrixViewer results, JFrame toRevalidate) { resultsView = new JScrollPane(results); setBackground(Color.black); resultsView.addComponentListener(new ComponentListener() { @Override public void componentHidden(ComponentEvent arg0) { } @Override public void componentMoved(ComponentEvent arg0) { } @Override public void componentResized(ComponentEvent ce) { Dimension size = ce.getComponent().getSize(); results.padToSize(size); } @Override public void componentShown(ComponentEvent arg0) { } }); resultsView.getViewport().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Rectangle r = resultsView.getViewport().getViewRect(); results.setViewAt(r); } }); resultsView.setBackground(Color.black); sidebar = new JPanel(); setPreferredSize(new Dimension(900, 631)); setMinimumSize(new Dimension(900, 631)); sidebar.setPreferredSize(new Dimension(200, 631)); sidebar.setMaximumSize(new Dimension(200, 3000)); resultsView.setMinimumSize(new Dimension(700, 631)); resultsView.setPreferredSize(new Dimension(700, 631)); sidebar.setBackground(Color.GRAY); setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); this.add(sidebar); this.add(resultsView); resultsView.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); resultsView.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); resultsView.getVerticalScrollBar().setUnitIncrement(16); resultsView.getHorizontalScrollBar().setUnitIncrement(16); Integer[] presetThresholds = { 80, 60, 40, 20, 0 }; JComboBox<Integer> threshHold = new JComboBox<Integer>(presetThresholds); threshHold.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { Integer item = (Integer) event.getItem(); results.updateThreshold(item / 100.0); toRevalidate.revalidate(); toRevalidate.repaint(); } } }); threshHold.setSelectedIndex(0); results.updateThreshold((Integer) threshHold.getSelectedItem() / 100.0); JTextField student1 = new JTextField(15); JTextField student2 = new JTextField(15); KeyListener search = new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { results.highlightMatching(student1.getText(), student2.getText()); toRevalidate.revalidate(); toRevalidate.repaint(); } @Override public void keyTyped(KeyEvent e) { } }; student1.addKeyListener(search); student2.addKeyListener(search); Collection<MatrixPrinter> printerNameSet = MatrixPrinterRegistry.getInstance() .getSupportedImplementations(); JComboBox<MatrixPrinter> exportAs = new JComboBox<>(new Vector<>(printerNameSet)); JButton exportAsSave = new JButton("Save"); JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setCurrentDirectory(new java.io.File(".")); fc.setDialogTitle("Save results"); exportAsSave.addActionListener(ae -> { MatrixPrinter method = (MatrixPrinter) exportAs.getSelectedItem(); int err = fc.showDialog(toRevalidate, "Save"); if (err == JFileChooser.APPROVE_OPTION) { try { FileUtils.writeStringToFile(fc.getSelectedFile(), method.printMatrix(exportMatrix)); } catch (InternalAlgorithmError | IOException e1) { // TODO log / show error } } }); JPanel thresholdLabel = new JPanel(); JPanel studentSearchLabel = new JPanel(); JPanel fileOutputLabel = new JPanel(); thresholdLabel.setBorder(BorderFactory.createTitledBorder("Matching Threshold")); studentSearchLabel.setBorder(BorderFactory.createTitledBorder("Student Search")); fileOutputLabel.setBorder(BorderFactory.createTitledBorder("Save Results")); thresholdLabel.add(threshHold); studentSearchLabel.add(student1); studentSearchLabel.add(student2); fileOutputLabel.add(exportAs); fileOutputLabel.add(exportAsSave); studentSearchLabel.setPreferredSize(new Dimension(200, 100)); studentSearchLabel.setMinimumSize(new Dimension(200, 100)); thresholdLabel.setPreferredSize(new Dimension(200, 100)); thresholdLabel.setMinimumSize(new Dimension(200, 100)); fileOutputLabel.setPreferredSize(new Dimension(200, 100)); fileOutputLabel.setMinimumSize(new Dimension(200, 100)); sidebar.setMaximumSize(new Dimension(200, 4000)); sidebar.add(thresholdLabel); sidebar.add(studentSearchLabel); sidebar.add(fileOutputLabel); }
From source file:com.robertolosanno.cdt_maven.Cdt.java
public Cdt() { //Ontologia// w w w .java 2 s .c o 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:GeometryByReferenceNIOBuffer.java
JPanel createGeometryByReferencePanel() { JPanel panel = new JPanel(); panel.setBorder(new TitledBorder("Geometry Type")); String values[] = { "Array", "Strip", "Indexed", "IndexedStrip" }; geomType = new JComboBox(values); geomType.setLightWeightPopupEnabled(false); geomType.addActionListener(this); geomType.setSelectedIndex(0);//from w w w. j a va 2s. c o m panel.add(new JLabel("Geometry Type")); panel.add(geomType); return panel; }
From source file:com.intel.stl.ui.main.view.StaDetailsPanel.java
/** * Description://from www. j ava 2 s. com * * @param sourceName */ protected void initComponent() { setLayout(new BorderLayout(0, 10)); setOpaque(false); setBorder(BorderFactory.createTitledBorder((Border) null)); JPanel titlePanel = new JPanel(new BorderLayout(5, 1)); titlePanel.setOpaque(false); numberLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN); numberLabel.setHorizontalAlignment(JLabel.RIGHT); titlePanel.add(numberLabel, BorderLayout.CENTER); nameLabel = ComponentFactory.getH3Label("", Font.PLAIN); nameLabel.setHorizontalAlignment(JLabel.LEFT); nameLabel.setVerticalAlignment(JLabel.BOTTOM); titlePanel.add(nameLabel, BorderLayout.EAST); add(titlePanel, BorderLayout.NORTH); JPanel mainPanel = new JPanel(); mainPanel.setOpaque(false); mainPanel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); GridBagLayout gridBag = new GridBagLayout(); mainPanel.setLayout(gridBag); GridBagConstraints gc = new GridBagConstraints(); gc.insets = new Insets(2, 2, 2, 2); gc.fill = GridBagConstraints.HORIZONTAL; gc.weightx = 1; gc.gridwidth = 1; gc.weighty = 0; failedChartPanel = new ChartPanel(null); failedChartPanel.setPreferredSize(new Dimension(60, 20)); mainPanel.add(failedChartPanel, gc); gc.fill = GridBagConstraints.BOTH; gc.weightx = 0; failedNumberLabel = ComponentFactory.getH2Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.BOLD); failedNumberLabel.setForeground(UIConstants.INTEL_DARK_RED); failedNumberLabel.setHorizontalAlignment(JLabel.CENTER); mainPanel.add(failedNumberLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; failedNameLabel = ComponentFactory.getH5Label(STLConstants.K0020_FAILED.getValue(), Font.PLAIN); failedNameLabel.setVerticalAlignment(JLabel.BOTTOM); mainPanel.add(failedNameLabel, gc); gc.fill = GridBagConstraints.HORIZONTAL; gc.weightx = 1; gc.gridwidth = 1; skippedChartPanel = new ChartPanel(null); skippedChartPanel.setPreferredSize(new Dimension(60, 20)); mainPanel.add(skippedChartPanel, gc); gc.fill = GridBagConstraints.BOTH; gc.weightx = 0; skippedNumberLabel = ComponentFactory.getH2Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.BOLD); skippedNumberLabel.setForeground(UIConstants.INTEL_DARK_ORANGE); skippedNumberLabel.setHorizontalAlignment(JLabel.CENTER); mainPanel.add(skippedNumberLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; skippedNameLabel = ComponentFactory.getH5Label(STLConstants.K0021_SKIPPED.getValue(), Font.PLAIN); skippedNameLabel.setVerticalAlignment(JLabel.BOTTOM); mainPanel.add(skippedNameLabel, gc); gc.weighty = 0; gc.fill = GridBagConstraints.NONE; gc.insets = new Insets(8, 2, 2, 2); gc.weightx = 1; gc.gridwidth = 1; gc.gridheight = types.length; typeChartPanel = new ChartPanel(null); typeChartPanel.setPreferredSize(new Dimension(80, 60)); mainPanel.add(typeChartPanel, gc); typeNumberLabels = new JLabel[types.length]; typeNameLabels = new JLabel[types.length]; gc.fill = GridBagConstraints.BOTH; gc.gridheight = 1; gc.insets = new Insets(12, 2, 2, 2); for (int i = 0; i < types.length; i++) { if (i == 1) { gc.insets = new Insets(2, 2, 2, 2); } gc.weightx = 0; gc.gridwidth = 1; typeNumberLabels[i] = createNumberLabel(); mainPanel.add(typeNumberLabels[i], gc); gc.gridwidth = GridBagConstraints.REMAINDER; typeNameLabels[i] = createNameLabel(types[i].getName()); mainPanel.add(typeNameLabels[i], gc); } gc.fill = GridBagConstraints.BOTH; mainPanel.add(Box.createGlue(), gc); add(mainPanel, BorderLayout.CENTER); }