List of usage examples for java.awt Font getSize
public int getSize()
From source file:gate.gui.ControllerMetadataViewer.java
@Override public void setTarget(Object target) { if (target == null) throw new NullPointerException("received a null target"); if (!(target instanceof Controller)) throw new IllegalArgumentException("not a controller"); Controller controller = (Controller) target; if (!controller.getFeatures().containsKey("gate.app.MetadataURL")) throw new IllegalArgumentException("no gate.app.MetadataURL feature"); try {// www . j ava 2s . co m URL metadata = (URL) controller.getFeatures().get("gate.app.MetadataURL"); URL longDesc = new URL(metadata, "long-desc.html"); URL iconDesc = new URL(metadata, "icon.png"); Document document = builder.parse(metadata.openStream()); Node text = document.getDocumentElement().getElementsByTagName("pipeline-name").item(0).getFirstChild(); Font font = Gate.getUserConfig().getFont(GateConstants.TEXT_COMPONENTS_FONT); StringBuilder page = new StringBuilder(); page.append("<!DOCTYPE html>"); page.append("<html>"); page.append("<head>"); page.append("<style type='text/css'>body { font-family: ").append(font.getFamily()) .append("; font-size: ").append(font.getSize()).append("pt }</style>"); page.append("</head>"); page.append("<body>"); page.append("<h1><img style='vertical-align: middle;' src='") .append(StringEscapeUtils.escapeHtml(iconDesc.toString())).append("'/> ") .append(StringEscapeUtils.escapeHtml(text.getTextContent())).append("</h1>"); page.append(IOUtils.toString(longDesc, "UTF-8")); page.append("</body></html>"); // parse using NekoHTML HTMLConfiguration config = new HTMLConfiguration(); // Force element names to lower case to match XHTML requirements // as that is what Flying Saucer expects config.setProperty("http://cyberneko.org/html/properties/names/elems", "lower"); DOMParser htmlParser = new DOMParser(config); htmlParser.parse(new InputSource(new StringReader(page.toString()))); display.setDocument(htmlParser.getDocument(), longDesc.toString()); } catch (Exception e) { throw new IllegalArgumentException(e); } }
From source file:ca.sqlpower.architect.swingui.ProfileGraphPanel.java
public ProfileGraphPanel(ProfilePanel panel, int rowCount) { this.profilePanel = panel; this.rowCount = rowCount; FormLayout displayLayout = new FormLayout("4dlu, default, 4dlu, 100dlu, 4dlu, fill:default:grow, 4dlu", // columns "4dlu, default, 6dlu"); // rows CellConstraints cc = new CellConstraints(); validResultsPanel = ProfileGraphPanel.logger.isDebugEnabled() ? new FormDebugPanel(displayLayout) : new JPanel(displayLayout); validResultsPanel.setBorder(BorderFactory.createEtchedBorder()); Font bodyFont = validResultsPanel.getFont(); Font titleFont = bodyFont.deriveFont(Font.BOLD, bodyFont.getSize() * 1.25F); title = new JLabel("Column Name"); title.setFont(titleFont);/*from www .j a v a2 s. co m*/ PanelBuilder pb = new PanelBuilder(displayLayout, validResultsPanel); pb.add(title, cc.xyw(2, 2, 5)); int row = 4; rowCountDisplay = makeInfoRow(pb, "RowCount", row); row += 2; nullableLabel = makeInfoRow(pb, "Nullable", row); row += 2; nullCountLabel = makeInfoRow(pb, "Null Count", row); row += 2; nullPercentLabel = makeInfoRow(pb, "% Null Records", row); row += 2; minLengthLabel = makeInfoRow(pb, "Minimum Length", row); row += 2; maxLengthLabel = makeInfoRow(pb, "Maximum Length", row); row += 2; uniqueCountLabel = makeInfoRow(pb, "Unique Values", row); row += 2; uniquePercentLabel = makeInfoRow(pb, "% Unique", row); row += 2; minValue = makeInfoRow(pb, "Minimum Value", row); row += 2; maxValue = makeInfoRow(pb, "Maximum Value", row); row += 2; avgValue = makeInfoRow(pb, "Average Value", row); row += 2; freqValueTable = new FreqValueTable(null); freqValueSp = new JScrollPane(freqValueTable); pb.appendRow("fill:10dlu:grow"); pb.appendRow("fill:default:grow"); pb.add(freqValueSp, cc.xyw(2, row + 1, 3)); // Now add something to represent the chart JFreeChart createPieChart = ChartFactory.createPieChart("", new DefaultPieDataset(new DefaultKeyedValues()), false, false, false); chartPanel = new ChartPanel(createPieChart); chartPanel.setPreferredSize(new Dimension(300, 300)); if (panel.getProfileManager().getWorkspaceContainer() instanceof ArchitectSession && ((ArchitectSession) panel.getProfileManager().getWorkspaceContainer()).isEnterpriseSession()) { pb.add(new JLabel("Column Profile Notes"), cc.xy(6, 2)); notesField = new JTextArea(); notesField.setLineWrap(true); notesField.setWrapStyleWord(true); JScrollPane notesScroll = new JScrollPane(notesField); notesScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); notesScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); pb.add(notesScroll, cc.xywh(6, 4, 1, row - 4)); pb.appendRow("fill:4dlu:grow"); pb.appendRow("4dlu"); pb.add(chartPanel, cc.xy(6, row + 1)); } else { pb.appendRow("fill:4dlu:grow"); pb.appendRow("4dlu"); pb.add(chartPanel, cc.xywh(6, 4, 1, row - 2)); } invalidResultsPanel = new JPanel(new BorderLayout()); invalidResultsLabel = new JLabel("No error message yet"); invalidResultsPanel.add(invalidResultsLabel); displayArea = new JPanel(new GridLayout(1, 1)); displayArea.setPreferredSize(validResultsPanel.getPreferredSize()); }
From source file:savant.ucscexplorer.UCSCExplorerPlugin.java
private void buildUI() { topLevelPanel.removeAll();/*from w ww .j a v a 2 s . co m*/ topLevelPanel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(5, 5, 5, 5); try { UCSCDataSourcePlugin ucsc = getUCSCPlugin(); ucsc.getConnection(); JLabel cladeLabel = new JLabel("Clade:"); gbc.anchor = GridBagConstraints.EAST; topLevelPanel.add(cladeLabel, gbc); cladeCombo = new JComboBox(); cladeCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { UCSCDataSourcePlugin ucsc = getUCSCPlugin(); String clade = (String) cladeCombo.getSelectedItem(); genomeCombo.setModel(new DefaultComboBoxModel(ucsc.getCladeGenomes(clade))); genomeCombo.setSelectedItem(ucsc.getCurrentGenome(clade)); } }); gbc.anchor = GridBagConstraints.WEST; topLevelPanel.add(cladeCombo, gbc); JLabel genomeLabel = new JLabel("Genome:"); gbc.anchor = GridBagConstraints.EAST; topLevelPanel.add(genomeLabel, gbc); genomeCombo = new JComboBox(); genomeCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { buildProgressUI(); new GroupsFetcher(getUCSCPlugin(), (GenomeDef) genomeCombo.getSelectedItem()) { @Override public void done(List<GroupDef> groups) { if (groups != null) { GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1.0; for (GroupDef g : groups) { groupsPanel.add(new GroupPanel(g), gbc); } // Add a filler panel to force everything to the top. gbc.weighty = 1.0; groupsPanel.add(new JPanel(), gbc); loadButton.setEnabled(true); topLevelPanel.validate(); } } @Override public void showProgress(double value) { updateProgress(progressMessage, value); } }.execute(); } }); gbc.anchor = GridBagConstraints.WEST; topLevelPanel.add(genomeCombo, gbc); loadButton = new JButton("Load Selected Tracks"); loadButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { try { loadSelectedTracks(); } catch (Throwable x) { DialogUtils.displayException(getTitle(), "Unable to load selected tracks.", x); } } }); gbc.anchor = GridBagConstraints.EAST; gbc.gridwidth = GridBagConstraints.REMAINDER; topLevelPanel.add(loadButton, gbc); groupsPanel = new GroupsPanel(); groupsPanel.setLayout(new GridBagLayout()); JScrollPane groupsScroller = new JScrollPane(groupsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; topLevelPanel.add(groupsScroller, gbc); buildProgressUI(); GenomeUtils.addGenomeChangedListener(new Listener<GenomeChangedEvent>() { @Override public void handleEvent(GenomeChangedEvent event) { UCSCDataSourcePlugin ucsc = getUCSCPlugin(); ucsc.selectGenomeDB(null); GenomeAdapter newGenome = event.getNewGenome(); GenomeDef g = new GenomeDef(newGenome.getName(), null); String newClade = ucsc.findCladeForGenome(g); // newClade could be null if the user has opened a genome which has no UCSC equivalent. if (newClade != null) { cladeCombo.setSelectedItem(newClade); } } }); ucsc.selectGenomeDB(null); new CladesFetcher(getUCSCPlugin()) { @Override public void done(String selectedClade) { cladeCombo.setModel(new DefaultComboBoxModel(UCSCDataSourcePlugin.STANDARD_CLADES)); if (selectedClade != null) { cladeCombo.setSelectedItem(selectedClade); } else { cladeCombo.setSelectedIndex(0); } } @Override public void showProgress(double value) { updateProgress(progressMessage, value); } }.execute(); } catch (Exception x) { LOG.error("Unable to connect to UCSC database.", x); topLevelPanel.removeAll(); gbc.anchor = GridBagConstraints.CENTER; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0.0; gbc.weighty = 0.0; topLevelPanel.add(new JLabel("Unable to connect to UCSC database."), gbc); JLabel error = new JLabel(MiscUtils.getMessage(x)); Font f = topLevelPanel.getFont(); f = f.deriveFont(Font.ITALIC, f.getSize() - 2.0f); error.setFont(f); topLevelPanel.add(error, gbc); } }
From source file:FontChooser.java
public boolean doesFontMatch(Font font) { if (font == null) { return false; }/* w w w. j a v a 2 s . c om*/ return font.getFamily().equals(_familyName) && font.getSize() == getSize() && font.getStyle() == generateStyle(); }
From source file:captureplugin.drivers.DeviceCreatorDialog.java
/** * Create the GUI//from ww w . jav a2s . c om */ private void createGUI() { UiUtilities.registerForClosing(this); DriverIf[] drivers = DriverFactory.getInstance().getDrivers(); mDriverCombo = new JComboBox(drivers); mDriverCombo.setRenderer(new DefaultListCellRenderer() { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value instanceof DriverIf) { value = ((DriverIf) value).getDriverName(); } return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } }); JPanel panel = (JPanel) getContentPane(); panel.setLayout(new GridBagLayout()); GridBagConstraints label = new GridBagConstraints(); label.insets = new Insets(5, 5, 5, 5); label.anchor = GridBagConstraints.NORTHWEST; GridBagConstraints input = new GridBagConstraints(); input.fill = GridBagConstraints.HORIZONTAL; input.weightx = 1.0; input.gridwidth = GridBagConstraints.REMAINDER; input.insets = new Insets(5, 5, 5, 5); panel.add(new JLabel(mLocalizer.msg("Name", "Name")), label); mName = new JTextField(); panel.add(mName, input); panel.add(new JLabel(mLocalizer.msg("Driver", "Driver")), label); panel.add(mDriverCombo, input); mDesc = UiUtilities.createHtmlHelpTextArea(""); mDesc.setEditable(false); panel.add(new JLabel(mLocalizer.msg("Description", "Description")), input); GridBagConstraints descC = new GridBagConstraints(); descC.weightx = 1.0; descC.weighty = 1.0; descC.fill = GridBagConstraints.BOTH; descC.gridwidth = GridBagConstraints.REMAINDER; descC.insets = new Insets(5, 5, 5, 5); panel.add(new JScrollPane(mDesc, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER), descC); final Font font = new JLabel().getFont(); String desc = ((DriverIf) mDriverCombo.getSelectedItem()).getDriverDesc(); desc = "<html><div style=\"color:#000000;font-family:" + font.getName() + "; font-size:" + font.getSize() + ";\">" + desc + "</div></html>"; mDesc.setText(desc); mDesc.setFont(font); mDriverCombo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { String description = ((DriverIf) mDriverCombo.getSelectedItem()).getDriverDesc(); description = "<html><div style=\"color:#000000;font-family:" + font.getName() + "; font-size:" + font.getSize() + ";\">" + description + "</div></html>"; mDesc.setText(description); mDesc.setFont(font); } }); final JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK)); ok.setEnabled(false); final JButton cancel = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL)); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okPressed(); } }); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); } }); mName.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { updateButtons(); } @Override public void insertUpdate(DocumentEvent e) { updateButtons(); } @Override public void changedUpdate(DocumentEvent e) { updateButtons(); } private void updateButtons() { ok.setEnabled(!mName.getText().trim().isEmpty()); } }); ButtonBarBuilder2 builder = new ButtonBarBuilder2(); builder.addGlue(); builder.addButton(new JButton[] { ok, cancel }); getRootPane().setDefaultButton(ok); input.insets = new Insets(5, 5, 5, 5); panel.add(builder.getPanel(), input); setSize(400, 300); }
From source file:org.zephyrsoft.sdb2.presenter.SongView.java
private Style addStyleFromFont(String styleName, Font font) { return addStyle(styleName, font.isItalic(), font.isBold(), font.getFamily(), font.getSize()); }
From source file:nz.govt.natlib.ndha.manualdeposit.metadata.PersonalSettings.java
public void setStandardFont(final Font value) { fontName = value.getFontName();/*from w w w . jav a 2 s.co m*/ fontSize = value.getSize(); fontBold = value.isBold(); fontItalic = value.isItalic(); fontPlain = value.isPlain(); saveData(); }
From source file:FontChooser.java
/** * Show dialog defaulting to the passed font. * * @param font The font to default to./*from ww w.j a v a 2 s. c o m*/ */ public Font showDialog(Font font) { if (font != null) { _fontNamesCmb.setSelectedItem(font.getName()); _fontSizesCmb.setSelectedItem("" + font.getSize()); _boldChk.setSelected(_selectStyles && font.isBold()); _italicChk.setSelected(_selectStyles && font.isItalic()); } else { _fontNamesCmb.setSelectedIndex(0); _fontSizesCmb.setSelectedIndex(0); _boldChk.setSelected(false); _italicChk.setSelected(false); } setupPreviewLabel(); setVisible(true); return _font; }
From source file:com.limegroup.gnutella.gui.LicenseWindow.java
protected void createValid() { GridBagConstraints c = new GridBagConstraints(); JComponent label = new JLabel(getDetailsString()); Font f = label.getFont(); label.setFont(new Font(f.getName(), Font.BOLD, f.getSize())); c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHWEST; DETAILS.add(label, c);//from ww w .j a v a2 s . c o m JTextArea text = newTextArea(LICENSE.getLicenseDescription(URN)); c.gridwidth = GridBagConstraints.RELATIVE; c.gridheight = 2; c.weighty = 1; c.weightx = .7; c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.BOTH; DETAILS.add(text, c); if (LICENSE.getLicenseDeed(URN) != null) { label = new URLLabel(LICENSE.getLicenseDeed(URN), getDeedString()); } else { label = new JLabel(); label.setVisible(false); } c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 1; c.weighty = 0; c.weightx = .3; c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.BOTH; c.insets = new Insets(0, 0, 3, 0); DETAILS.add(label, c); label = new URLLabel(LICENSE.getLicenseURI(), getVerificationString()); DETAILS.add(label, c); }
From source file:ome.formats.importer.gui.OptionsDialog.java
/** * Initialize and show the options dialog * //from w w w .j av a 2s. c o m * @param config - ImportConfig to store/save settings too * @param owner - parent * @param title - dialog title * @param modal - modal yes/no */ OptionsDialog(ImportConfig config, JFrame owner, String title, boolean modal) { super(owner); this.owner = owner; setLocation(200, 200); setTitle(title); setModal(modal); setResizable(false); setSize(new Dimension(dialogWidth, dialogHeight)); setLocationRelativeTo(owner); tabbedPane = new JTabbedPane(); tabbedPane.setOpaque(false); // content panes must be opaque this.config = config; oldQuaquaLevel = config.getUseQuaqua(); oldUserDisableHistory = config.getUserDisableHistory(); /////////////////////// START MAIN PANEL //////////////////////// // Set up the main pane double mainPanelTable[][] = { { TableLayout.FILL, 120, 5, 120, TableLayout.FILL }, // columns { TableLayout.FILL, 5, 30 } }; // rows mainPanel = GuiCommonElements.addMainPanel(this, mainPanelTable, 10, 10, 10, 10, debug); // Buttons at the bottom of the form cancelBtn = GuiCommonElements.addButton(mainPanel, "Cancel", 'L', "Cancel", "1, 2, f, c", debug); cancelBtn.addActionListener(this); okBtn = GuiCommonElements.addButton(mainPanel, "OK", 'Q', "Import", "3, 2, f, c", debug); okBtn.addActionListener(this); this.getRootPane().setDefaultButton(okBtn); GuiCommonElements.enterPressesWhenFocused(okBtn); mainPanel.add(tabbedPane, "0,0,4,0"); /////////////////////// START DEBUG OPTIONS PANEL //////////////////////// double debugOptionTable[][] = { { TableLayout.FILL }, // columns { 10, TableLayout.PREFERRED, 20, 30, 15, TableLayout.FILL } }; // rows debugOptionsPanel = GuiCommonElements.addMainPanel(tabbedPane, debugOptionTable, 0, 10, 10, 10, debug); String message = "Choose the level of detail for your log file's data."; GuiCommonElements.addTextPane(debugOptionsPanel, message, "0, 1, 0, 0", debug); dBox = GuiCommonElements.addComboBox(debugOptionsPanel, "Debug Level: ", debugItems, 'D', "Choose the level of detail for your log file's data.", 95, "0,3,F,C", debug); int debugLevel = config.getDebugLevel(); for (int i = 0; i < dBox.getItemCount(); i++) { if (((DebugItem) dBox.getItemAt(i)).getLevel() == debugLevel) dBox.setSelectedIndex(i); } dBox.addActionListener(this); String description = ((DebugItem) dBox.getSelectedItem()).getDescription(); descriptionText = GuiCommonElements.addTextPane(debugOptionsPanel, description, "0, 5", debug); final Font textFieldFont = (Font) UIManager.get("TextField.font"); final Font font = new Font(textFieldFont.getFamily(), Font.ITALIC, textFieldFont.getSize()); descriptionText.setFont(font); /////////////////////// START OTHER OPTIONS PANEL //////////////////////// double otherOptionTable[][] = { { TableLayout.FILL }, // columns { 10, TableLayout.PREFERRED, 20, 30, 15, TableLayout.FILL } }; // rows otherOptionsPanel = GuiCommonElements.addMainPanel(tabbedPane, otherOptionTable, 0, 10, 10, 10, debug); companionFileCheckbox = GuiCommonElements.addCheckBox(otherOptionsPanel, "<html>Attached a text file to each imported" + " file containing all collected metadata.</html>", "0,1", debug); companionFileCheckbox.setSelected(config.companionFile.get()); disableHistoryCheckbox = GuiCommonElements.addCheckBox(otherOptionsPanel, "<html>Disable Import History. (Improves " + " import speed. Restart required if changed).</html>", "0,3", debug); disableHistoryCheckbox.setSelected(config.getUserDisableHistory()); // If disabled by admin in import.config, disable this option if (config.getStaticDisableHistory()) { disableHistoryCheckbox.setEnabled(false); } /////////////////////// START FILECHOOSER PANEL //////////////////////// // Set up the import panel for tPane, quit, and send buttons double fileChooserTable[][] = { { TableLayout.FILL, 120, 5, 120, TableLayout.FILL }, // columns { TableLayout.PREFERRED, 15, TableLayout.FILL, 10 } }; // rows fileChooserPanel = GuiCommonElements.addMainPanel(tabbedPane, fileChooserTable, 0, 10, 0, 10, debug); message = "Switch between single pane view and triple pane view. " + "You will need to reboot the importer before your changes will take effect."; GuiCommonElements.addTextPane(fileChooserPanel, message, "0, 0, 4, 0", debug); // Set up single pane table double singlePaneTable[][] = { { 24, 5, TableLayout.FILL }, // columns { TableLayout.FILL } }; // rows // Panel containing the single pane layout singlePanePanel = GuiCommonElements.addMainPanel(fileChooserPanel, singlePaneTable, 0, 0, 0, 0, debug); singlePaneBtn = GuiCommonElements.addRadioButton(singlePanePanel, null, 'u', null, "0,0", debug); GuiCommonElements.addImagePanel(singlePanePanel, SINGLE_PANE_IMAGE, "2,0", debug); fileChooserPanel.add(singlePanePanel, "0, 2, 1, 2"); // Set up triple pane table double triplePaneTable[][] = { { 24, 5, TableLayout.FILL }, // columns { TableLayout.FILL } }; // rows // Panel containing the triple pane layout triplePanePanel = GuiCommonElements.addMainPanel(fileChooserPanel, triplePaneTable, 0, 0, 0, 0, debug); triplePaneBtn = GuiCommonElements.addRadioButton(triplePanePanel, null, 'u', null, "0,0", debug); GuiCommonElements.addImagePanel(triplePanePanel, TRIPLE_PANE_IMAGE, "2,0", debug); fileChooserPanel.add(triplePanePanel, "3, 2, 4, 2"); ButtonGroup group = new ButtonGroup(); group.add(singlePaneBtn); group.add(triplePaneBtn); if (config.getUseQuaqua() == true) { triplePaneBtn.setSelected(true); singlePaneBtn.setSelected(false); } else { triplePaneBtn.setSelected(false); singlePaneBtn.setSelected(true); } /////////////////////// START TABBED PANE //////////////////////// //if (GuiCommonElements.getIsMac()) tabbedPane.addTab("FileChooser", null, fileChooserPanel, "FileChooser Settings"); tabbedPane.addTab("Debug", null, debugOptionsPanel, "Debug Settings"); tabbedPane.addTab("Other", null, otherOptionsPanel, "Other Settings"); this.add(mainPanel); setVisible(true); }