List of usage examples for java.awt Font getSize
public int getSize()
From source file:org.openmicroscopy.shoola.agents.metadata.editor.AnnotationDataUI.java
/** * Creates a menu item.//from w ww.j a va 2 s .co m * * @param index The index associated to the item. * @return See above. */ private JCheckBoxMenuItem createMenuItem(int index) { JCheckBoxMenuItem item = new JCheckBoxMenuItem(NAMES[index]); Font f = item.getFont(); item.setFont(f.deriveFont(f.getStyle(), f.getSize() - 2)); item.setSelected(filter == index); item.addActionListener(this); item.setActionCommand("" + index); return item; }
From source file:lcmc.common.ui.ResourceGraph.java
/** Returns layout of the text that will be drawn on the vertex. */ private TextLayout getVertexTextLayout(final Graphics2D g2d, final String text, final double fontSizeFactor) { final TextLayout ctl = textLayoutCache.get(fontSizeFactor + ":" + text); if (ctl != null) { return ctl; }//from ww w . ja v a 2 s. co m final Font font = mainData.getMainFrame().getFont(); final FontRenderContext context = g2d.getFontRenderContext(); final TextLayout tl = new TextLayout(text, new Font(font.getName(), font.getStyle(), (int) (font.getSize() * fontSizeFactor)), context); textLayoutCache.put(fontSizeFactor + ":" + text, tl); return tl; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.AnnotationDataUI.java
/** Builds and lays out the UI. */ private void buildGUI() { removeAll();/*from w ww .j ava 2s.c o m*/ JLabel l = new JLabel(); Font f = l.getFont(); int size = f.getSize() - 1; content.removeAll(); content.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 1, 2, 1); c.anchor = GridBagConstraints.WEST; c.gridx = 0; c.gridy = 0; c.weightx = 1; c.weighty = 1; c.gridwidth = 2; c.fill = GridBagConstraints.HORIZONTAL; if (!model.isAnnotationLoaded()) { l.setText("Annotation could not be loaded"); content.add(l, c); return; } if (model.isMultiSelection()) { Object refObject = model.getRefObject(); StringBuffer buffer = new StringBuffer(); buffer.append("Annotate the selected "); buffer.append(model.getObjectTypeAsString(refObject)); buffer.append("s"); l.setText(buffer.toString()); content.add(l, c); c.gridy++; } // filters content.add(createBar(filterButton, null), c); c.gridy++; // rating c.gridwidth = 1; c.gridx = 0; c.weightx = 0; c.fill = GridBagConstraints.NONE; JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(UIUtilities.setTextFont("Rating:", Font.BOLD, size)); p.add(createBar(unrateButton, null)); content.add(p, c); c.gridx = 1; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(rating); p.add(Box.createHorizontalStrut(2)); p.add(otherRating); content.add(p, c); c.gridy++; // tags c.gridx = 0; p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(UIUtilities.setTextFont("Tags:", Font.BOLD, size)); p.add(createBar(addTagsButton, removeTagsButton)); content.add(p, c); c.gridy++; content.add(tagsPane, c); c.gridy++; // attachment c.gridx = 0; c.gridwidth = 2; p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(UIUtilities.setTextFont("Attachments:", Font.BOLD, size)); p.add(createBar(addDocsButton, removeDocsButton)); content.add(p, c); c.gridy++; content.add(docRef, c); c.gridy++; if (!model.isMultiSelection()) { mapsPane.reload(filter); content.add(mapsPane, c); c.gridy++; } // other if (!CollectionUtils.isEmpty(model.getAllOtherAnnotations())) { p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(UIUtilities.setTextFont("Others:", Font.BOLD, size)); p.add(createBar(null, removeOtherAnnotationsButton)); content.add(p, c); c.gridy++; content.add(otherPane, c); } add(content, BorderLayout.CENTER); }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.AnnotationDataUI.java
/** Initializes the components composing the display. */ private void initComponents() { setLayout(new BorderLayout()); setBackground(UIUtilities.BACKGROUND); setBorder(new SeparatorOneLineBorder()); toReplace = new ArrayList<FileAnnotationData>(); IconManager icons = IconManager.getInstance(); filter = SHOW_ALL;/*from w w w . j av a 2s . c o m*/ filterButton = new JButton(NAMES[SHOW_ALL]); filterButton.setToolTipText("Filter tags and attachments."); UIUtilities.unifiedButtonLookAndFeel(filterButton); Font font = filterButton.getFont(); filterButton.setFont(font.deriveFont(font.getStyle(), font.getSize() - 2)); filterButton.setIcon(icons.getIcon(IconManager.UP_DOWN_9_12)); filterButton.setBackground(UIUtilities.BACKGROUND_COLOR); filterButton.addMouseListener(new MouseAdapter() { /** * Brings up the menu. * @see MouseListener#mouseReleased(MouseEvent) */ public void mouseReleased(MouseEvent me) { Object source = me.getSource(); if (source instanceof Component) displayMenu((Component) source, me.getPoint()); } }); otherRating = new JLabel(); otherRating.setBackground(UIUtilities.BACKGROUND_COLOR); font = otherRating.getFont(); otherRating.setFont(font.deriveFont(Font.ITALIC, font.getSize() - 2)); content = new JPanel(); content.setBackground(UIUtilities.BACKGROUND_COLOR); content.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); tagFlag = false; docFlag = false; otherFlag = false; tagNames = new ArrayList<String>(); tagsDocList = new ArrayList<DocComponent>(); filesDocList = new ArrayList<DocComponent>(); otherList = new ArrayList<DocComponent>(); existingTags = new HashMap<String, TagAnnotationData>(); addTagsButton = new JButton(icons.getIcon(IconManager.PLUS_12)); UIUtilities.unifiedButtonLookAndFeel(addTagsButton); addTagsButton.setBackground(UIUtilities.BACKGROUND_COLOR); addTagsButton.setToolTipText("Add Tags."); addTagsButton.addActionListener(controller); addTagsButton.setActionCommand("" + EditorControl.ADD_TAGS); addDocsButton = new JButton(icons.getIcon(IconManager.PLUS_12)); addDocsButton.setBackground(UIUtilities.BACKGROUND_COLOR); addDocsButton.setToolTipText("Attach a document."); addDocsButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { if (addDocsButton.isEnabled()) { Point p = e.getPoint(); createDocSelectionMenu().show(addDocsButton, p.x, p.y); } } }); UIUtilities.unifiedButtonLookAndFeel(addDocsButton); removeTagsButton = new JButton(icons.getIcon(IconManager.MINUS_12)); UIUtilities.unifiedButtonLookAndFeel(removeTagsButton); removeTagsButton.setBackground(UIUtilities.BACKGROUND_COLOR); removeTagsButton.setToolTipText("Remove Tags."); removeTagsButton.addMouseListener(controller); removeTagsButton.setActionCommand("" + EditorControl.REMOVE_TAGS); removeDocsButton = new JButton(icons.getIcon(IconManager.MINUS_12)); UIUtilities.unifiedButtonLookAndFeel(removeDocsButton); removeDocsButton.setBackground(UIUtilities.BACKGROUND_COLOR); removeDocsButton.setToolTipText("Remove Attachments."); removeDocsButton.addMouseListener(controller); removeDocsButton.setActionCommand("" + EditorControl.REMOVE_DOCS); removeOtherAnnotationsButton = new JButton(icons.getIcon(IconManager.MINUS_12)); UIUtilities.unifiedButtonLookAndFeel(removeOtherAnnotationsButton); removeOtherAnnotationsButton.setBackground(UIUtilities.BACKGROUND_COLOR); removeOtherAnnotationsButton.setToolTipText("Remove Annotations."); removeOtherAnnotationsButton.addMouseListener(controller); removeOtherAnnotationsButton.setActionCommand("" + EditorControl.REMOVE_OTHER_ANNOTATIONS); selectedValue = 0; initialValue = selectedValue; rating = new RatingComponent(selectedValue, RatingComponent.MEDIUM_SIZE); rating.setOpaque(false); rating.setBackground(UIUtilities.BACKGROUND_COLOR); rating.addPropertyChangeListener(this); unrateButton = new JButton(icons.getIcon(IconManager.MINUS_12)); UIUtilities.unifiedButtonLookAndFeel(unrateButton); unrateButton.setBackground(UIUtilities.BACKGROUND_COLOR); unrateButton.setToolTipText("Unrate."); unrateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rating.setValue(0); view.saveData(true); } }); tagsPane = new JPanel(); tagsPane.setLayout(new BoxLayout(tagsPane, BoxLayout.Y_AXIS)); tagsPane.setBackground(UIUtilities.BACKGROUND_COLOR); DocComponent doc = new DocComponent(null, model); tagsDocList.add(doc); tagsPane.add(doc); docPane = new JPanel(); docPane.setLayout(new BoxLayout(docPane, BoxLayout.Y_AXIS)); docPane.setBackground(UIUtilities.BACKGROUND_COLOR); docRef = docPane; doc = new DocComponent(null, model); filesDocList.add(doc); docPane.add(doc); publishedBox = new JCheckBox(); publishedBox.setBackground(UIUtilities.BACKGROUND_COLOR); publishedBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { firePropertyChange(EditorControl.SAVE_PROPERTY, Boolean.FALSE, Boolean.TRUE); } }); mapsPane = new MapAnnotationsComponent(model, view); otherPane = new JPanel(); otherPane.setLayout(new GridBagLayout()); otherPane.setBackground(UIUtilities.BACKGROUND_COLOR); }
From source file:lcmc.gui.ResourceGraph.java
/** Returns layout of the text that will be drawn on the vertex. */ private TextLayout getVertexTextLayout(final Graphics2D g2d, final String text, final double fontSizeFactor) { final TextLayout ctl = textLayoutCache.get(fontSizeFactor + ':' + text); if (ctl != null) { return ctl; }//from www. j a v a 2 s. com final Font font = Tools.getGUIData().getMainFrame().getFont(); final FontRenderContext context = g2d.getFontRenderContext(); TextLayout tl = new TextLayout(text, new Font(font.getName(), font.getStyle(), (int) (font.getSize() * fontSizeFactor)), context); textLayoutCache.put(fontSizeFactor + ':' + text, tl); return tl; }
From source file:org.datavyu.views.DatavyuView.java
/** * Changes the font size by adding sizeDif to the current size. Then it * creates and revalidates a new panel to show the font update. This will * not make the font smaller than smallestSize. * * @param sizeDif//from w ww .j av a 2s . c o m * The number to add to the current font size. */ public void changeFontSize(final int sizeDif) { Configuration config = Configuration.getInstance(); Font f = config.getSSDataFont(); int size = f.getSize(); size = size + sizeDif; if (size < ZOOM_MIN_SIZE) { size = ZOOM_MIN_SIZE; } else if (size > ZOOM_MAX_SIZE) { size = ZOOM_MAX_SIZE; } config.setSSDataFontSize(size); // Create and redraw fresh window pane so all of the fonts are new // again. panel.revalidate(); panel.repaint(); }
From source file:savant.view.swing.GraphPane.java
/** * Draw an informational message on top of this GraphPane. * * @param g2 the graphics to be rendered * @param message text of the message to be displayed *//*from w w w . j a va 2 s. co m*/ private void drawMessage(Graphics2D g2, String message) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font font = g2.getFont(); Font subFont = font; int h = getSize().height / 3; int w = getWidth(); if (w > 500) { font = font.deriveFont(Font.PLAIN, 36); subFont = subFont.deriveFont(Font.PLAIN, 18); } else if (w > 150) { font = font.deriveFont(Font.PLAIN, 24); subFont = subFont.deriveFont(Font.PLAIN, 12); } else { font = font.deriveFont(Font.PLAIN, 12); subFont = subFont.deriveFont(Font.PLAIN, 8); } int returnPos = message.indexOf('\n'); g2.setColor(ColourSettings.getColor(ColourKey.GRAPH_PANE_MESSAGE)); if (returnPos > 0) { drawMessageHelper(g2, message.substring(0, returnPos), font, w, h, -(subFont.getSize() / 2)); drawMessageHelper(g2, message.substring(returnPos + 1), subFont, w, h, font.getSize() - (subFont.getSize() / 2)); } else { drawMessageHelper(g2, message, font, w, h, 0); } }
From source file:org.datavyu.views.DatavyuView.java
/** * Function to reset the zoom level to the default size. * * @param evt/*w w w .ja va 2 s.com*/ * The event that triggered this action. */ private void resetZoomMenuItemActionPerformed(final java.awt.event.ActionEvent evt) { // GEN-FIRST:event_resetZoomMenuItemActionPerformed Configuration config = Configuration.getInstance(); Font f = config.getSSDataFont(); changeFontSize(ZOOM_DEFAULT_SIZE - f.getSize()); }
From source file:org.gumtree.vis.awt.JChartPanel.java
@Override public void draw(Graphics2D g2, Rectangle2D area, double shiftX, double shiftY) { // g2.setPaint(Color.white); // g2.fill(new Rectangle2D.Double(0, 0, getWidth(), getHeight())); // if (getChart() != null) { //// Image chartImage = getChart().createBufferedImage((int) area.getWidth(), //// (int) area.getHeight()); //// g2.drawImage(chartImage, (int) area.getMinX(), (int) area.getMinY(), //// this); // getChart().draw(g2, area, getAnchor(), null); // ChartMaskingUtilities.drawMasks(g2, getScreenDataArea(), maskList, // null, getChart()); // }//from www . j a v a 2 s . c o m double widthRatio = area.getWidth() / getWidth(); double heightRatio = area.getHeight() / getHeight(); double overallRatio = 1; overallRatio = widthRatio < heightRatio ? widthRatio : heightRatio; XYPlot plot = (XYPlot) getChart().getPlot(); Font domainFont = plot.getDomainAxis().getLabelFont(); int domainSize = domainFont.getSize(); Font rangeFont = plot.getRangeAxis().getLabelFont(); int rangeSize = rangeFont.getSize(); TextTitle titleBlock = getChart().getTitle(); Font titleFont = null; int titleSize = 0; if (titleBlock != null) { titleFont = titleBlock.getFont(); titleSize = titleFont.getSize(); getChart().getTitle().setFont(titleFont.deriveFont((float) (titleSize * overallRatio))); } Font domainScaleFont = plot.getDomainAxis().getTickLabelFont(); int domainScaleSize = domainScaleFont.getSize(); Font rangeScaleFont = plot.getRangeAxis().getTickLabelFont(); int rangeScaleSize = rangeScaleFont.getSize(); plot.getDomainAxis().setLabelFont(domainFont.deriveFont((float) (domainSize * overallRatio))); plot.getRangeAxis().setLabelFont(rangeFont.deriveFont((float) (rangeSize * overallRatio))); plot.getDomainAxis().setTickLabelFont(domainScaleFont.deriveFont((float) (domainScaleSize * overallRatio))); plot.getRangeAxis().setTickLabelFont(rangeScaleFont.deriveFont((float) (rangeScaleSize * overallRatio))); LegendTitle legend = getChart().getLegend(); Font legendFont = null; int legendFontSize = 0; if (legend != null) { legendFont = legend.getItemFont(); legendFontSize = legendFont.getSize(); legend.setItemFont(legendFont.deriveFont((float) (legendFontSize * overallRatio))); } Rectangle2D chartArea = (Rectangle2D) area.clone(); getChart().getPadding().trim(chartArea); if (titleBlock != null) { AxisUtilities.trimTitle(chartArea, g2, titleBlock, titleBlock.getPosition()); } Axis scaleAxis = null; Font scaleAxisFont = null; int scaleAxisFontSize = 0; for (Object object : getChart().getSubtitles()) { Title title = (Title) object; if (title instanceof PaintScaleLegend) { scaleAxis = ((PaintScaleLegend) title).getAxis(); scaleAxisFont = scaleAxis.getTickLabelFont(); scaleAxisFontSize = scaleAxisFont.getSize(); scaleAxis.setTickLabelFont(scaleAxisFont.deriveFont((float) (scaleAxisFontSize * overallRatio))); } AxisUtilities.trimTitle(chartArea, g2, title, title.getPosition()); } AxisSpace axisSpace = AxisUtilities.calculateAxisSpace(getChart().getXYPlot(), g2, chartArea); Rectangle2D dataArea = axisSpace.shrink(chartArea, null); getChart().getXYPlot().getInsets().trim(dataArea); getChart().getXYPlot().getAxisOffset().trim(dataArea); // Rectangle2D screenArea = getScreenDataArea(); // Rectangle2D visibleArea = getVisibleRect(); // Rectangle2D printScreenArea = new Rectangle2D.Double(screenArea.getMinX() * overallRatio + x, // screenArea.getMinY() * overallRatio + y, // printArea.getWidth() - visibleArea.getWidth() + screenArea.getWidth(), // printArea.getHeight() - visibleArea.getHeight() + screenArea.getHeight()); getChart().draw(g2, area, getAnchor(), null); ChartMaskingUtilities.drawMasks(g2, dataArea, maskList, null, getChart(), overallRatio); ChartMaskingUtilities.drawShapes(g2, dataArea, shapeMap, getChart()); ChartMaskingUtilities.drawText(g2, dataArea, textContentMap, getChart()); plot.getDomainAxis().setLabelFont(domainFont); plot.getRangeAxis().setLabelFont(rangeFont); if (titleBlock != null) { titleBlock.setFont(titleFont); } if (legend != null) { legend.setItemFont(legendFont); } plot.getDomainAxis().setTickLabelFont(domainScaleFont); plot.getRangeAxis().setTickLabelFont(rangeScaleFont); if (scaleAxis != null) { scaleAxis.setTickLabelFont(scaleAxisFont); } // System.out.println("print " + titleBlock.getText() + // " at [" + area.getX() + ", " + area.getY() + ", " + // area.getWidth() + ", " + area.getHeight() + "]"); }
From source file:ro.nextreports.engine.exporter.ResultExporter.java
private void buildCellFont(Map<String, Object> format, Font font) { format.put(StyleFormatConstants.FONT_FAMILY_KEY, font.getFamily()); format.put(StyleFormatConstants.FONT_NAME_KEY, font.getName()); format.put(StyleFormatConstants.FONT_SIZE, new Float(font.getSize())); if (Font.PLAIN == font.getStyle()) { format.put(StyleFormatConstants.FONT_STYLE_KEY, StyleFormatConstants.FONT_STYLE_NORMAL); }//from w w w. j a va 2 s. c o m if (Font.BOLD == font.getStyle()) { format.put(StyleFormatConstants.FONT_STYLE_KEY, StyleFormatConstants.FONT_STYLE_BOLD); } if (Font.ITALIC == font.getStyle()) { format.put(StyleFormatConstants.FONT_STYLE_KEY, StyleFormatConstants.FONT_STYLE_ITALIC); } if ((Font.BOLD | Font.ITALIC) == font.getStyle()) { format.put(StyleFormatConstants.FONT_STYLE_KEY, StyleFormatConstants.FONT_STYLE_BOLDITALIC); } }