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:com.mirth.connect.client.ui.SettingsPanelDatabaseTasks.java
private void initComponents() { JPanel containerPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3, fill")); containerPanel.setBackground(getBackground()); containerPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Database Tasks", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11))); containerPanel.add(new JLabel( "Cleanup or optimization tasks for the internal database. If no tasks are present, no action is necessary."), "top, wrap"); taskTable = new MirthTable(); taskTable//from ww w . j a v a2 s. c om .setModel(new RefreshTableModel(new Object[] { "Status", "Name", "Description", "Start Time" }, 0)); taskTable.setDragEnabled(false); taskTable.setRowSelectionAllowed(true); taskTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); taskTable.setRowHeight(UIConstants.ROW_HEIGHT); taskTable.setFocusable(false); taskTable.setOpaque(true); taskTable.getTableHeader().setReorderingAllowed(false); taskTable.setEditable(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { taskTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } taskTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { checkSelection(evt); } @Override public void mouseReleased(MouseEvent evt) { checkSelection(evt); } private void checkSelection(MouseEvent evt) { if (taskTable.rowAtPoint(new Point(evt.getX(), evt.getY())) < 0) { taskTable.clearSelection(); setVisibleTasks(2, 3, false); } } }); taskTable.getColumnModel().getColumn(0).setMinWidth(75); taskTable.getColumnModel().getColumn(0).setMaxWidth(75); taskTable.getColumnModel().getColumn(0).setCellRenderer(new ImageCellRenderer()); taskTable.getColumnModel().getColumn(1).setMinWidth(45); taskTable.getColumnModel().getColumn(1).setPreferredWidth(250); taskTable.getColumnModel().getColumn(2).setMinWidth(75); taskTable.getColumnModel().getColumn(2).setPreferredWidth(475); taskTable.getColumnModel().getColumn(3).setMinWidth(95); taskTable.getColumnModel().getColumn(3).setMaxWidth(95); taskTable.getColumnModel().getColumn(3).setCellRenderer(new DateCellRenderer()); taskTable.getSelectionModel().addListSelectionListener(this); JScrollPane taskTableScrollPane = new JScrollPane(taskTable); containerPanel.add(taskTableScrollPane, "grow, push"); add(containerPanel, "grow, h 60%"); JPanel channelsPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3, fill")); channelsPanel.setBackground(getBackground()); channelsPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Affected Channels", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11))); channelsTable = new MirthTable(); channelsTable.setModel(new RefreshTableModel(new Object[] { "Name", "Id" }, 0)); channelsTable.setDragEnabled(false); channelsTable.setRowSelectionAllowed(false); channelsTable.setRowHeight(UIConstants.ROW_HEIGHT); channelsTable.setFocusable(false); channelsTable.setOpaque(true); channelsTable.getTableHeader().setReorderingAllowed(false); channelsTable.setEditable(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { channelsTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } channelsPanel.add(new JScrollPane(channelsTable), "grow"); add(channelsPanel, "newline, grow, h 40%"); }
From source file:edu.clemson.cs.nestbed.client.gui.MoteDetailFrame.java
private JPanel buildMotePanel() { JPanel panel = new JPanel(); panel.setBorder(new TitledBorder("Mote Information")); panel.setLayout(new BorderLayout()); panel.add(buildMoteLabelPanel(), BorderLayout.WEST); panel.add(buildMoteFieldPanel(), BorderLayout.CENTER); return panel; }
From source file:components.ListDialog.java
private ListDialog(Frame frame, Component locationComp, String labelText, String title, Object[] data, String initialValue, String longValue) { super(frame, title, true); //Create and initialize the buttons. JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); ///*from w w w .ja v a 2s.c o m*/ final JButton setButton = new JButton("Set"); setButton.setActionCommand("Set"); setButton.addActionListener(this); getRootPane().setDefaultButton(setButton); //main part of the dialog list = new JList(data) { //Subclass JList to workaround bug 4832765, which can cause the //scroll pane to not let the user easily scroll up to the beginning //of the list. An alternative would be to set the unitIncrement //of the JScrollBar to a fixed value. You wouldn't get the nice //aligned scrolling, but it should work. public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { int row; if (orientation == SwingConstants.VERTICAL && direction < 0 && (row = getFirstVisibleIndex()) != -1) { Rectangle r = getCellBounds(row, row); if ((r.y == visibleRect.y) && (row != 0)) { Point loc = r.getLocation(); loc.y--; int prevIndex = locationToIndex(loc); Rectangle prevR = getCellBounds(prevIndex, prevIndex); if (prevR == null || prevR.y >= r.y) { return 0; } return prevR.height; } } return super.getScrollableUnitIncrement(visibleRect, orientation, direction); } }; list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); if (longValue != null) { list.setPrototypeCellValue(longValue); //get extra space } list.setLayoutOrientation(JList.HORIZONTAL_WRAP); list.setVisibleRowCount(-1); list.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { setButton.doClick(); //emulate button click } } }); JScrollPane listScroller = new JScrollPane(list); listScroller.setPreferredSize(new Dimension(250, 80)); listScroller.setAlignmentX(LEFT_ALIGNMENT); //Create a container so that we can add a title around //the scroll pane. Can't add a title directly to the //scroll pane because its background would be white. //Lay out the label and scroll pane from top to bottom. JPanel listPane = new JPanel(); listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS)); JLabel label = new JLabel(labelText); label.setLabelFor(list); listPane.add(label); listPane.add(Box.createRigidArea(new Dimension(0, 5))); listPane.add(listScroller); listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); //Lay out the buttons from left to right. JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(cancelButton); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(setButton); //Put everything together, using the content pane's BorderLayout. Container contentPane = getContentPane(); contentPane.add(listPane, BorderLayout.CENTER); contentPane.add(buttonPane, BorderLayout.PAGE_END); //Initialize values. setValue(initialValue); pack(); setLocationRelativeTo(locationComp); }
From source file:org.nuclos.client.layout.wysiwyg.component.properties.PropertyChartPropertyDomainStep.java
private PanelComponent getPanelComponent(ChartFunction chartFunction, String prefix) { JPanel editor = new JPanel(); editor.setLayout(new BorderLayout()); JPanel valueEditor = new JPanel(new GridBagLayout()); valueEditor.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Werte")); JLabel propValue = new JLabel(SpringLocaleDelegate.getInstance().getMessage( "wysiwyg.chart.wizard.domain.value", "Bestimmen Sie die Spalte, die die Werte enthlt:")); valueEditor.add(propValue, new GridBagConstraints(0, 0, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0)); ChartColumn[] valueColumns = chartFunction.getValueColumnDesc(); for (int i = 0; i < valueColumns.length; i++) { ChartColumn chartColumn = valueColumns[i]; PropertyEditorString propValueEditor = new PropertyEditorString(prefix + chartColumn.property, getFittingFieldnames(wysiwygChart.getEntityName(), chartColumn.clazz), true); propValueEditor.setEditorValue(getChartProperty(prefix + chartColumn.property)); valueEditor.add(/*from w w w . ja v a 2 s .c om*/ new JLabel(SpringLocaleDelegate.getInstance() .getMessage("wysiwyg.chart.wizard.domain.column." + chartColumn.property, "")), new GridBagConstraints(0, i + 1, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 10, 0), 0, 0)); valueEditor.add(propValueEditor.getComponent(true), new GridBagConstraints(1, i + 1, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(10, -152, 10, 0), 0, 0)); propertyEditorList.add(propValueEditor); } editor.add(valueEditor, BorderLayout.NORTH); JPanel domainEditor = new JPanel(new GridBagLayout()); domainEditor.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Domain")); ChartColumn[] domainColumns = chartFunction.getDomainColumnDesc(); if (domainColumns.length > 0) { JLabel propDomain = new JLabel( SpringLocaleDelegate.getInstance().getMessage("wysiwyg.chart.wizard.domain.compare", "Geben Sie hier die Spalte(n) fr die vergleichenden Werte oder weitere Angaben an:")); domainEditor.add(propDomain, new GridBagConstraints(0, 0, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0)); int glue = 185; for (int i = 0; i < domainColumns.length; i++) { ChartColumn chartColumn = domainColumns[i]; PropertyEditorString propDomainEditor = new PropertyEditorString(prefix + chartColumn.property, getFittingFieldnames(wysiwygChart.getEntityName(), chartColumn.clazz), true); propDomainEditor.setEditorValue(getChartProperty(prefix + chartColumn.property)); domainEditor.add( new JLabel(SpringLocaleDelegate.getInstance() .getMessage("wysiwyg.chart.wizard.domain.column." + chartColumn.property, "")), new GridBagConstraints(0, i + 1, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 10, 0), 0, 0)); domainEditor.add(propDomainEditor.getComponent(true), new GridBagConstraints(1, i + 1, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(10, -240, 10, 0), 0, 0)); glue -= propDomainEditor.comboBox.getPreferredSize().height + 10; // add size. propertyEditorList.add(propDomainEditor); } domainEditor.add(new JPanel(), new GridBagConstraints(0, 3, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(glue < 0 ? 0 : glue, 0, 10, 0), 0, 0)); editor.add(domainEditor, BorderLayout.CENTER); } editor.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); PanelComponent pnlScroller = new PanelComponent(prefix, editor); pnlScroller.setPreferredSize(new Dimension(250, 80)); pnlScroller.setAlignmentX(LEFT_ALIGNMENT); pnlScroller.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); return pnlScroller; }
From source file:io.datalayer.jung.LensVertexImageShaperDemo.java
/** * create an instance of a simple graph with controls to * demo the zoom features.//from w ww. j a v a2 s . com * */ public LensVertexImageShaperDemo() { // create a simple graph for the demo graph = new DirectedSparseGraph<Number, Number>(); Number[] vertices = createVertices(11); // a Map for the labels Map<Number, String> map = new HashMap<Number, String>(); for (int i = 0; i < vertices.length; i++) { map.put(vertices[i], iconNames[i % iconNames.length]); } // a Map for the Icons Map<Number, Icon> iconMap = new HashMap<Number, Icon>(); for (int i = 0; i < vertices.length; i++) { String name = "/images/topic" + iconNames[i] + ".gif"; try { Icon icon = new LayeredIcon( new ImageIcon(LensVertexImageShaperDemo.class.getResource(name)).getImage()); iconMap.put(vertices[i], icon); } catch (Exception ex) { System.err.println("You need slashdoticons.jar in your classpath to see the image " + name); } } createEdges(vertices); FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph); layout.setMaxIterations(100); vv = new VisualizationViewer<Number, Number>(layout, new Dimension(600, 600)); Transformer<Number, Paint> vpf = new PickableVertexPaintTransformer<Number>(vv.getPickedVertexState(), Color.white, Color.yellow); vv.getRenderContext().setVertexFillPaintTransformer(vpf); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.setBackground(Color.white); final Transformer<Number, String> vertexStringerImpl = new VertexStringerImpl<Number>(map); vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan)); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan)); // features on and off. For a real application, use VertexIconAndShapeFunction instead. final VertexIconShapeTransformer<Number> vertexImageShapeFunction = new VertexIconShapeTransformer<Number>( new EllipseVertexShapeTransformer<Number>()); final DefaultVertexIconTransformer<Number> vertexIconFunction = new DefaultVertexIconTransformer<Number>(); vertexImageShapeFunction.setIconMap(iconMap); vertexIconFunction.setIconMap(iconMap); vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction); vv.getRenderContext().setVertexIconTransformer(vertexIconFunction); // Get the pickedState and add a listener that will decorate the // Vertex images with a checkmark icon when they are picked PickedState<Number> ps = vv.getPickedVertexState(); ps.addItemListener(new PickWithIconListener(vertexIconFunction)); vv.addPostRenderPaintable(new VisualizationViewer.Paintable() { int x; int y; Font font; FontMetrics metrics; int swidth; int sheight; String str = "Thank You, slashdot.org, for the images!"; public void paint(Graphics g) { Dimension d = vv.getSize(); if (font == null) { font = new Font(g.getFont().getName(), Font.BOLD, 20); metrics = g.getFontMetrics(font); swidth = metrics.stringWidth(str); sheight = metrics.getMaxAscent() + metrics.getMaxDescent(); x = (d.width - swidth) / 2; y = (int) (d.height - sheight * 1.5); } g.setFont(font); Color oldColor = g.getColor(); g.setColor(Color.lightGray); g.drawString(str, x, y); g.setColor(oldColor); } public boolean useTransform() { return false; } }); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Number>()); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); 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()); } }); JComboBox modeBox = graphMouse.getModeComboBox(); JPanel modePanel = new JPanel(); modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); 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(modePanel); content.add(controls, BorderLayout.SOUTH); this.viewSupport = new MagnifyImageLensSupport<Number, Number>(vv); // new ViewLensSupport<Number,Number>(vv, new HyperbolicShapeTransformer(vv, // vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), // new ModalLensGraphMouse()); this.modelSupport = new LayoutLensSupport<Number, Number>(vv); graphMouse.addItemListener(modelSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(viewSupport.getGraphMouse().getModeListener()); ButtonGroup radio = new ButtonGroup(); JRadioButton none = new JRadioButton("None"); none.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (viewSupport != null) { viewSupport.deactivate(); } if (modelSupport != null) { modelSupport.deactivate(); } } }); none.setSelected(true); JRadioButton hyperView = new JRadioButton("View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JRadioButton hyperModel = new JRadioButton("Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { modelSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); radio.add(none); radio.add(hyperView); radio.add(hyperModel); JMenuBar menubar = new JMenuBar(); JMenu modeMenu = graphMouse.getModeMenu(); menubar.add(modeMenu); JPanel lensPanel = new JPanel(new GridLayout(2, 0)); lensPanel.setBorder(BorderFactory.createTitledBorder("Lens")); lensPanel.add(none); lensPanel.add(hyperView); lensPanel.add(hyperModel); controls.add(lensPanel); }
From source file:com.web.vehiclerouting.optaplanner.common.swingui.SolverAndPersistenceFrame.java
private JPanel createScorePanel() { JPanel scorePanel = new JPanel(new BorderLayout()); scorePanel.setBorder(BorderFactory.createEtchedBorder()); showConstraintMatchesDialogAction = new ShowConstraintMatchesDialogAction(); showConstraintMatchesDialogAction.setEnabled(false); scorePanel.add(new JButton(showConstraintMatchesDialogAction), BorderLayout.WEST); resultLabel = new JLabel("Score:"); resultLabel.setBorder(BorderFactory.createLoweredBevelBorder()); scorePanel.add(resultLabel, BorderLayout.CENTER); refreshScreenDuringSolvingCheckBox = new JCheckBox("Refresh screen during solving", solutionPanel.isRefreshScreenDuringSolving()); scorePanel.add(refreshScreenDuringSolvingCheckBox, BorderLayout.EAST); return scorePanel; }
From source file:be.fedict.eid.tsl.tool.TslInternalFrame.java
private void initDetailsPanel(JPanel detailsPanel) { detailsPanel.setBorder(new TitledBorder("Details")); detailsPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); GridBagLayout gridBagLayout = new GridBagLayout(); JPanel dataPanel = new JPanel(gridBagLayout); detailsPanel.add(dataPanel);//from www .ja va 2 s . c o m GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.FIRST_LINE_START; constraints.gridx = 0; constraints.gridy = 0; constraints.ipadx = 10; dataPanel.add(new JLabel("Service Name"), constraints); this.serviceName = new JLabel(); constraints.gridx++; dataPanel.add(this.serviceName, constraints); constraints.gridy++; constraints.gridx = 0; dataPanel.add(new JLabel("Service Type"), constraints); constraints.gridx++; this.serviceType = new JLabel(); dataPanel.add(this.serviceType, constraints); constraints.gridy++; constraints.gridx = 0; dataPanel.add(new JLabel("Service Status"), constraints); constraints.gridx++; this.serviceStatus = new JLabel(); dataPanel.add(this.serviceStatus, constraints); constraints.gridy++; constraints.gridx = 0; dataPanel.add(new JLabel("Service SHA1 Thumbprint"), constraints); constraints.gridx++; this.serviceSha1Thumbprint = new JLabel(); dataPanel.add(this.serviceSha1Thumbprint, constraints); constraints.gridy++; constraints.gridx = 0; dataPanel.add(new JLabel("Service SHA256 Thumbprint"), constraints); constraints.gridx++; this.serviceSha256Thumbprint = new JLabel(); dataPanel.add(this.serviceSha256Thumbprint, constraints); constraints.gridy++; constraints.gridx = 0; dataPanel.add(new JLabel("Validity begin"), constraints); constraints.gridx++; this.validityBegin = new JLabel(); dataPanel.add(this.validityBegin, constraints); constraints.gridy++; constraints.gridx = 0; dataPanel.add(new JLabel("Validity end"), constraints); constraints.gridx++; this.validityEnd = new JLabel(); dataPanel.add(this.validityEnd, constraints); }
From source file:edu.uci.ics.jung.samples.LensVertexImageShaperDemo.java
/** * create an instance of a simple graph with controls to * demo the zoom features.//from ww w . ja v a2 s . c o m * */ @SuppressWarnings("rawtypes") public LensVertexImageShaperDemo() { // create a simple graph for the demo graph = new DirectedSparseGraph<Number, Number>(); Number[] vertices = createVertices(11); // a Map for the labels Map<Number, String> map = new HashMap<Number, String>(); for (int i = 0; i < vertices.length; i++) { map.put(vertices[i], iconNames[i % iconNames.length]); } // a Map for the Icons Map<Number, Icon> iconMap = new HashMap<Number, Icon>(); for (int i = 0; i < vertices.length; i++) { String name = "/images/topic" + iconNames[i] + ".gif"; try { Icon icon = new LayeredIcon( new ImageIcon(LensVertexImageShaperDemo.class.getResource(name)).getImage()); iconMap.put(vertices[i], icon); } catch (Exception ex) { System.err.println("You need slashdoticons.jar in your classpath to see the image " + name); } } createEdges(vertices); FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph); layout.setMaxIterations(100); vv = new VisualizationViewer<Number, Number>(layout, new Dimension(600, 600)); Transformer<Number, Paint> vpf = new PickableVertexPaintTransformer<Number>(vv.getPickedVertexState(), Color.white, Color.yellow); vv.getRenderContext().setVertexFillPaintTransformer(vpf); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.setBackground(Color.white); final Transformer<Number, String> vertexStringerImpl = new VertexStringerImpl<Number>(map); vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan)); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan)); // features on and off. For a real application, use VertexIconAndShapeFunction instead. final VertexIconShapeTransformer<Number> vertexImageShapeFunction = new VertexIconShapeTransformer<Number>( new EllipseVertexShapeTransformer<Number>()); final DefaultVertexIconTransformer<Number> vertexIconFunction = new DefaultVertexIconTransformer<Number>(); vertexImageShapeFunction.setIconMap(iconMap); vertexIconFunction.setIconMap(iconMap); vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction); vv.getRenderContext().setVertexIconTransformer(vertexIconFunction); // Get the pickedState and add a listener that will decorate the // Vertex images with a checkmark icon when they are picked PickedState<Number> ps = vv.getPickedVertexState(); ps.addItemListener(new PickWithIconListener(vertexIconFunction)); vv.addPostRenderPaintable(new VisualizationViewer.Paintable() { int x; int y; Font font; FontMetrics metrics; int swidth; int sheight; String str = "Thank You, slashdot.org, for the images!"; public void paint(Graphics g) { Dimension d = vv.getSize(); if (font == null) { font = new Font(g.getFont().getName(), Font.BOLD, 20); metrics = g.getFontMetrics(font); swidth = metrics.stringWidth(str); sheight = metrics.getMaxAscent() + metrics.getMaxDescent(); x = (d.width - swidth) / 2; y = (int) (d.height - sheight * 1.5); } g.setFont(font); Color oldColor = g.getColor(); g.setColor(Color.lightGray); g.drawString(str, x, y); g.setColor(oldColor); } public boolean useTransform() { return false; } }); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Number>()); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); 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()); } }); JComboBox modeBox = graphMouse.getModeComboBox(); JPanel modePanel = new JPanel(); modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); 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(modePanel); content.add(controls, BorderLayout.SOUTH); this.viewSupport = new MagnifyImageLensSupport<Number, Number>(vv); // new ViewLensSupport<Number,Number>(vv, new HyperbolicShapeTransformer(vv, // vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), // new ModalLensGraphMouse()); this.modelSupport = new LayoutLensSupport<Number, Number>(vv); graphMouse.addItemListener(modelSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(viewSupport.getGraphMouse().getModeListener()); ButtonGroup radio = new ButtonGroup(); JRadioButton none = new JRadioButton("None"); none.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (viewSupport != null) { viewSupport.deactivate(); } if (modelSupport != null) { modelSupport.deactivate(); } } }); none.setSelected(true); JRadioButton hyperView = new JRadioButton("View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JRadioButton hyperModel = new JRadioButton("Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { modelSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); radio.add(none); radio.add(hyperView); radio.add(hyperModel); JMenuBar menubar = new JMenuBar(); JMenu modeMenu = graphMouse.getModeMenu(); menubar.add(modeMenu); JPanel lensPanel = new JPanel(new GridLayout(2, 0)); lensPanel.setBorder(BorderFactory.createTitledBorder("Lens")); lensPanel.add(none); lensPanel.add(hyperView); lensPanel.add(hyperModel); controls.add(lensPanel); }
From source file:de.tbuchloh.kiskis.gui.dialogs.PropertyEditor.java
/** * Overridden!/*ww w. j a v a 2s .c o m*/ * * @see de.tbuchloh.kiskis.gui.dialogs.KisKisDialog#createMainPanel() */ @Override protected Component createMainPanel() { final JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(LnFHelper.createDefaultBorder()); panel.add(_templates); return panel; }
From source file:de.tbuchloh.kiskis.gui.dialogs.PropertyEditor.java
/** * Overridden!/* w w w .j a va2s. co m*/ * * @see de.tbuchloh.kiskis.gui.dialogs.KisKisDialog#createMainPanel() */ @Override protected Component createMainPanel() { final JPanel p = new JPanel(new SpringLayout()); p.setBorder(LnFHelper.createDefaultBorder()); p.add(new JLabel(M.getString("nameBox.label"))); p.add(_nameBox); p.add(new JLabel(M.getString("typeBox.label"))); p.add(_typeBox); SpringUtilities.makeCompactGrid(p, 2, 2, 0, 0, 5, 5); return p; }