@Override public void paintIcon(Component c, Graphics g, int x, int y) { AbstractButton abstractButton = (AbstractButton) c; ButtonModel buttonModel = abstractButton.getModel(); int w = getIconWidth(); int h = getIconHeight(); if (g instanceof Graphics2D) { Graphics2D g2 = (Graphics2D) g; RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHints(rh); float s = SizeHelper.getMinimalStrockWidth(); g2.setStroke(new BasicStroke(s)); } g.setColor(Color.WHITE); g.fillOval(x, y, w - 1, h - 1); if (buttonModel.isEnabled()) { g.setColor(Color.BLACK); } else { g.setColor(Color.GRAY); } g.drawOval(x, y, w - 1, h - 1); if (buttonModel.isSelected()) { int dx = (int) Math.round(0.25 * w); int dy = (int) Math.round(0.25 * h); g.fillOval(x + dx, y + dy, w - 2 * dx, h - 2 * dy); } }
StateTable(StateTableModel model) { super(model); getTableHeader().setReorderingAllowed(false); setDragEnabled(true); setDropMode(DropMode.INSERT_ROWS); setTransferHandler(new StateTableRowTransferHandler(this)); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); setRowHeight(SizeHelper.getComponentHeightFromFont(this.getFont())); setDefaultRenderer(SignalData.class, new SignalDataRenderer()); setDefaultRenderer(Boolean.class, new BooleanCellRenderer()); setDefaultEditor(Boolean.class, new BooleanCellEditor()); setDefaultRenderer(Color.class, new ColorCellRenderer()); setDefaultEditor(Color.class, new ColorCellEditor()); }
private Object[] getCustomButtonTable(UIDefaults table) { Object[] result = { "TabbedPane.selected", getPrimary2(), "TabbedPane.contentAreaColor", getPrimary2(), "CheckBox.icon", new CheckBoxIcon(), "CheckBoxMenuItem.checkIcon", new CheckBoxIcon(), "RadioButton.icon", new RadioButtonIcon(), "ScrollBar.width", SizeHelper.getScrollbarWidth(), }; return result; }
@Override public int getIconHeight() { // For symmetry the icon is better to have odd height return (SizeHelper.getRadioButtonIconSize() / 2) * 2 + 1; }
@Override public int getIconWidth() { // For symmetry the icon is better to have odd width return (SizeHelper.getCheckBoxIconSize() / 2) * 2 + 1; }
private Object[] getCustomIconTable(UIDefaults table) { Icon internalFrameIcon = UIManager.getIcon("InternalFrame.icon"); Icon internalFrameIconifyIcon = UIManager.getIcon("InternalFrame.iconifyIcon"); Icon internalFrameMinimizeIcon = UIManager.getIcon("InternalFrame.minimizeIcon"); Icon internalFrameMaximizeIcon = UIManager.getIcon("InternalFrame.maximizeIcon"); Icon internalFrameCloseIcon = UIManager.getIcon("InternalFrame.closeIcon"); Icon fileViewComputerIcon = UIManager.getIcon("FileView.computerIcon"); Icon fileViewDirectoryIcon = UIManager.getIcon("FileView.directoryIcon"); Icon fileViewFileIcon = UIManager.getIcon("FileView.fileIcon"); Icon fileViewFloppyDriveIcon = UIManager.getIcon("FileView.floppyDriveIcon"); Icon fileViewHardDriveIcon = UIManager.getIcon("FileView.hardDriveIcon"); Icon fileChooserDetailsViewIcon = UIManager.getIcon("FileChooser.detailsViewIcon"); Icon fileChooserHomeFolderIcon = UIManager.getIcon("FileChooser.homeFolderIcon"); Icon fileChooserListViewIcon = UIManager.getIcon("FileChooser.listViewIcon"); Icon fileChooserNewFolderIcon = UIManager.getIcon("FileChooser.newFolderIcon"); Icon fileChooserUpFolderIcon = UIManager.getIcon("FileChooser.upFolderIcon"); Object[] result = { "InternalFrame.icon", SizeHelper.scaleFrameIcon(internalFrameIcon), "InternalFrame.iconifyIcon", SizeHelper.scaleFrameIcon(internalFrameIconifyIcon), "InternalFrame.minimizeIcon", SizeHelper.scaleFrameIcon(internalFrameMinimizeIcon), "InternalFrame.maximizeIcon", SizeHelper.scaleFrameIcon(internalFrameMaximizeIcon), "InternalFrame.closeIcon", SizeHelper.scaleFrameIcon(internalFrameCloseIcon), "FileView.computerIcon", SizeHelper.scaleFileViewIcon(fileViewComputerIcon), "FileView.directoryIcon", SizeHelper.scaleFileViewIcon(fileViewDirectoryIcon), "FileView.fileIcon", SizeHelper.scaleFileViewIcon(fileViewFileIcon), "FileView.floppyDriveIcon", SizeHelper.scaleFileViewIcon(fileViewFloppyDriveIcon), "FileView.hardDriveIcon", SizeHelper.scaleFileViewIcon(fileViewHardDriveIcon), "FileChooser.detailsViewIcon", SizeHelper.scaleFileChooserIcon(fileChooserDetailsViewIcon), "FileChooser.homeFolderIcon", SizeHelper.scaleFileChooserIcon(fileChooserHomeFolderIcon), "FileChooser.listViewIcon", SizeHelper.scaleFileChooserIcon(fileChooserListViewIcon), "FileChooser.newFolderIcon", SizeHelper.scaleFileChooserIcon(fileChooserNewFolderIcon), "FileChooser.upFolderIcon", SizeHelper.scaleFileChooserIcon(fileChooserUpFolderIcon), }; return result; }
@Override public FontUIResource getControlTextFont() { return new FontUIResource(Font.SANS_SERIF, Font.PLAIN, SizeHelper.getBaseFontSize()); }
private void initialise() { // presetManager.sort(); presetCombo = new JComboBox(); for (Preset<T> p : presetManager.list()) { presetCombo.addItem(p); } presetCombo.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Preset<T> p = (Preset<T>) presetCombo.getSelectedItem(); if (p == null) { return; } if (p.isBuiltIn()) { updatePresetButton.setEnabled(false); updatePresetButton.setToolTipText("Cannot make changes to a built-in preset"); } else { updatePresetButton.setEnabled(true); updatePresetButton.setToolTipText( "Save these settings to the currently selected preset"); } T settings = p.getSettings(); guiMapper.applySettingsToControls(settings); } }); JButton manageButton = new JButton("Manage..."); manageButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean haveCustomPresets = false; for (Preset<T> p : presetManager.list()) { if (!p.isBuiltIn()) { haveCustomPresets = true; break; } } if (haveCustomPresets) { managePresets(); } else { JOptionPane.showMessageDialog( PresetManagerPanel.this, "There are no custom presets to manage."); } } }); updatePresetButton = new JButton("Update"); updatePresetButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Preset<T> selected = (Preset<T>) presetCombo.getSelectedItem(); presetManager.update(selected, guiMapper.getSettingsFromControls()); } }); JButton saveAsButton = new JButton("Save as..."); saveAsButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { createPreset(); } }); JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonsPanel.add(updatePresetButton); buttonsPanel.add(saveAsButton); buttonsPanel.add(manageButton); setBorder(BorderFactory.createTitledBorder("Presets")); setLayout( new BorderLayout(SizeHelper.getCompactLayoutHGap(), SizeHelper.getCompactLayoutVGap())); add(presetCombo, BorderLayout.CENTER); add(buttonsPanel, BorderLayout.SOUTH); }