List of usage examples for java.awt Font getName
public String getName()
From source file:NwFontChooserS.java
private NwFontChooserS(Frame parent, boolean modal, Font font) { super(parent, modal); initAll();// w w w . j ava2 s.co m setTitle("Font Choosr"); if (font == null) font = Sample.getFont(); FontList.setSelectedItem(font.getName()); SizeList.setSelectedItem(font.getSize() + ""); StyleList.setSelectedItem(styleList[font.getStyle()]); }
From source file:piramide.interaction.reasoner.FuzzyReasonerWizardFacade.java
@Override public void generateMembershipFunctionGraph(boolean isInput, boolean isDevices, String variableName, RegionDistributionInfo[] linguisticTerms, OutputStream destination, int width, int height, Geolocation geo, DecayFunctions decayFunction, Calendar when) { BufferedImage img;/*from w w w.j a v a 2s. c om*/ if (variableName == null) { img = createErrorMessagesImage("Error generating graph: variableName not provided"); } else if (linguisticTerms == null) { img = createErrorMessagesImage("Error generating graph: linguisticTerms not provided"); } else if (isInput && isDevices && !isValidDeviceVariableName(variableName)) { img = createErrorMessagesImage("Error generating graph: invalid device variable name: " + variableName); } else if (isInput && !isDevices && !isValidUserVariableName(variableName)) { img = createErrorMessagesImage("Error generating graph: invalid user variable name: " + variableName); } else { try { final WarningStore warningStore = new WarningStore(); final net.sourceforge.jFuzzyLogic.rule.Variable variable = processVariable(isInput, isDevices, variableName, linguisticTerms, geo, decayFunction, when, warningStore); final JFreeChart theChart = variable.chart(false); final String[] messages = warningStore.getMessages(); if (messages.length > 0) { final Font font = TextTitle.DEFAULT_FONT; final Font bigBold = new Font(font.getName(), Font.BOLD, font.getSize() + 2); final Font bold = new Font(font.getName(), Font.BOLD, font.getSize()); theChart.addSubtitle(new TextTitle("WARNINGS:", bigBold, Color.RED, Title.DEFAULT_POSITION, Title.DEFAULT_HORIZONTAL_ALIGNMENT, Title.DEFAULT_VERTICAL_ALIGNMENT, Title.DEFAULT_PADDING)); for (String message : messages) theChart.addSubtitle(new TextTitle(message, bold, Color.RED, Title.DEFAULT_POSITION, Title.DEFAULT_HORIZONTAL_ALIGNMENT, Title.DEFAULT_VERTICAL_ALIGNMENT, Title.DEFAULT_PADDING)); } img = theChart.createBufferedImage(width, height); } catch (FuzzyReasonerException e) { e.printStackTrace(); img = createErrorMessagesImage("Error generating graph: " + e.getMessage()); } } try { final ImageEncoder myEncoder = ImageEncoderFactory.newInstance("png"); myEncoder.encode(img, destination); destination.flush(); destination.close(); } catch (IOException e) { // Cry e.printStackTrace(); return; } }
From source file:edu.harvard.i2b2.analysis.ui.WaitPanel.java
public void init(int width, int height) { if (width <= 0 || height <= 0) { width = 273;//from w w w .j ava 2 s . com height = 144; } setBackground(java.awt.Color.WHITE); java.awt.Image img = this.getToolkit().getImage(WaitPanel.class.getResource("waiting.gif")); comp = new GIFComponent(img); add(comp); comp.setBounds(width, height, 110, 110); comp.go(); Font currentFont = comp.getFont(); Font thisFont = new Font(currentFont.getName(), Font.BOLD, 16); topLabel = new javax.swing.JLabel(); add(topLabel); topLabel.setBounds(width - 100, height - 70, 250, 40); topLabel.setText("Working on visualization ......."); topLabel.setFont(thisFont); topLabel1 = new javax.swing.JLabel(); add(topLabel1); topLabel1.setBounds(width - 100, height - 50, 400, 40); topLabel1.setText("Click on \"create model for Timeline\" tab to abort"); topLabel1.setFont(thisFont); elapsedTimeLabel = new javax.swing.JLabel(); add(elapsedTimeLabel); elapsedTimeLabel.setBounds(width - 50, height + 120, 260, 40); elapsedTimeLabel.setText("Elapsed Time = 00 : 00"); elapsedTimeLabel.setFont(thisFont); /* * minuteLabel = new javax.swing.JLabel(); add(minuteLabel); * minuteLabel.setBounds(width+75, height+120, 25, 40); * minuteLabel.setText("00"); minuteLabel.setFont(thisFont); * * seperateLabel = new javax.swing.JLabel(); add(seperateLabel); * seperateLabel.setText(":"); seperateLabel.setBounds(width+100, * height+120, 10, 40); seperateLabel.setFont(thisFont); * * secondLabel = new javax.swing.JLabel(); add(secondLabel); * secondLabel.setBounds(width+112, height+120, 25, 40); * secondLabel.setText("00"); secondLabel.setFont(thisFont); */ estimateTimeLabel = new javax.swing.JLabel(); add(estimateTimeLabel); estimateTimeLabel.setBounds(width - 50, height + 140, 250, 40); estimateTimeLabel.setText("Estimated Time = " + this.estimatedTimeStr); estimateTimeLabel.setFont(thisFont); new Thread(this).start(); }
From source file:edu.harvard.i2b2.patientMapping.ui.WaitPanel.java
public void init(int width, int height) { if (width <= 0 || height <= 0) { width = 273;// w w w .j a v a2s .c om height = 144; } setBackground(java.awt.Color.WHITE); java.awt.Image img = this.getToolkit().getImage(WaitPanel.class.getResource("waiting.gif")); comp = new GIFComponent(img); add(comp); comp.setBounds(width, height, 110, 110); comp.go(); Font currentFont = comp.getFont(); Font thisFont = new Font(currentFont.getName(), Font.BOLD, 16); topLabel = new javax.swing.JLabel(); add(topLabel); topLabel.setBounds(width - 100, height - 70, 250, 40); topLabel.setText("Loading patient set ......."); topLabel.setFont(thisFont); topLabel1 = new javax.swing.JLabel(); add(topLabel1); topLabel1.setBounds(width - 100, height - 50, 400, 40); topLabel1.setText("Click on the \"Cancel\" button below to abort"); topLabel1.setFont(thisFont); elapsedTimeLabel = new javax.swing.JLabel(); add(elapsedTimeLabel); elapsedTimeLabel.setBounds(width - 50, height + 120, 260, 40); elapsedTimeLabel.setText("Elapsed Time = 00 : 00"); elapsedTimeLabel.setFont(thisFont); /* * minuteLabel = new javax.swing.JLabel(); add(minuteLabel); * minuteLabel.setBounds(width+75, height+120, 25, 40); * minuteLabel.setText("00"); minuteLabel.setFont(thisFont); * * seperateLabel = new javax.swing.JLabel(); add(seperateLabel); * seperateLabel.setText(":"); seperateLabel.setBounds(width+100, * height+120, 10, 40); seperateLabel.setFont(thisFont); * * secondLabel = new javax.swing.JLabel(); add(secondLabel); * secondLabel.setBounds(width+112, height+120, 25, 40); * secondLabel.setText("00"); secondLabel.setFont(thisFont); */ estimateTimeLabel = new javax.swing.JLabel(); //add(estimateTimeLabel); estimateTimeLabel.setBounds(width - 50, height + 140, 250, 40); estimateTimeLabel.setText("Estimated Time = " + this.estimatedTimeStr); estimateTimeLabel.setFont(thisFont); new Thread(this).start(); }
From source file:com.limegroup.gnutella.gui.themes.setters.SubstanceThemeSetter.java
public void apply() { SubstanceLookAndFeel.setSkin(_skinClassName); ThemeMediator.applyCommonSkinUI();//from w w w . ja v a2 s.com float scaledFontPolicyFactor = WINDOWS_SCALED_FONT_POLICY_FACTOR; if (OSUtils.isMacOSX()) { scaledFontPolicyFactor = MAC_SCALED_FONT_POLICY_FACTOR; } else if (OSUtils.isLinux()) { scaledFontPolicyFactor = LINUX_SCALED_FONT_POLICY_FACTOR; } if (LookUtils.IS_OS_WINDOWS) { fixWindowsOSFont(); } else if (LookUtils.IS_OS_LINUX) { fixLinuxOSFont(); } SubstanceLookAndFeel.setFontPolicy(SubstanceFontUtilities.getScaledFontPolicy(scaledFontPolicyFactor)); //reduceFont("Label.font"); //reduceFont("Table.font"); //ResourceManager.setFontSizes(-1); //ResourceManager.setFontSizes(0); UIManager.put("Tree.leafIcon", UIManager.getIcon("Tree.closedIcon")); // remove split pane borders UIManager.put("SplitPane.border", BorderFactory.createEmptyBorder()); if (!OSUtils.isMacOSX()) { UIManager.put("Table.focusRowHighlightBorder", UIManager.get("Table.focusCellHighlightBorder")); } UIManager.put("Table.focusCellHighlightBorder", BorderFactory.createEmptyBorder(1, 1, 1, 1)); // Add a bold text version of simple text. Font normal = UIManager.getFont("Table.font"); FontUIResource bold = new FontUIResource(normal.getName(), Font.BOLD, normal.getSize()); UIManager.put("Table.font.bold", bold); UIManager.put("Tree.rowHeight", 0); }
From source file:org.yardstickframework.report.jfreechart.JFreeChartGraphPlotter.java
/** * @param folderToWrite Folder to write the resulted charts. * @param plots Collections of plots./*from w w w . ja v a2s .c o m*/ * @param infoMap Map with additional plot info. * @param mode Generation mode. * @throws Exception If failed. */ private static void processPlots(File folderToWrite, Collection<List<PlotData>> plots, Map<String, List<JFreeChartPlotInfo>> infoMap, JFreeChartGenerationMode mode) throws Exception { ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); int idx = -1; while (true) { idx++; DefaultXYDataset dataSet = new DefaultXYDataset(); List<JFreeChartPlotInfo> infoList = new ArrayList<>(); String xAxisLabel = ""; String yAxisLabel = ""; String plotName = ""; int cnt = 0; for (List<PlotData> plotData0 : plots) { if (plotData0.size() <= idx) continue; PlotData plotData = plotData0.get(idx); dataSet.addSeries(plotData.plotName() + "_" + cnt++, plotData.series().data); xAxisLabel = plotData.xAxisLabel; yAxisLabel = plotData.yAxisLabel; plotName = plotData.plotName(); infoList.add(info(plotData.series(), mode)); } if (infoList.isEmpty()) break; JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, dataSet, PlotOrientation.VERTICAL, false, false, false); AxisSpace as = new AxisSpace(); as.add(150, RectangleEdge.LEFT); XYPlot plot = (XYPlot) chart.getPlot(); BasicStroke stroke = new BasicStroke(1); plot.setRenderer(renderer); plot.setBackgroundPaint(WHITE); plot.setRangeGridlinePaint(GRAY); plot.setDomainGridlinePaint(GRAY); plot.setFixedRangeAxisSpace(as); plot.setOutlineStroke(stroke); for (int i = 0; i < infoList.size(); i++) { Color color = PLOT_COLORS[i % PLOT_COLORS.length]; renderer.setSeriesPaint(i, color); renderer.setSeriesStroke(i, new BasicStroke(3)); // Line thickness. infoList.get(i).color(Integer.toHexString(color.getRGB()).substring(2)); } ValueAxis axis = plot.getRangeAxis(); Font font = new Font("Helvetica,Arial,sans-serif", Font.BOLD, axis.getTickLabelFont().getSize() + 5); axis.setTickLabelFont(font); axis.setLabelFont(font); plot.getDomainAxis().setTickLabelFont(font); plot.getDomainAxis().setLabelFont(font); chart.setTitle(new TextTitle(yAxisLabel, new Font(font.getName(), font.getStyle(), 30))); File res = new File(folderToWrite, plotName + ".png"); ChartUtilities.saveChartAsPNG(res, chart, 1000, 500, info); infoMap.put(res.getAbsolutePath(), infoList); println("Chart is saved to file: ", res); } }
From source file:net.chaosserver.timelord.swingui.TaskDayPanel.java
/** * Builds the panel. This uses a GridBag to try and make formatting * grid-like between the unconnected rows. *///from ww w.j a v a 2s . com protected void buildPanel() { GridBagLayout gridBagLayout = new GridBagLayout(); GridBagConstraints gridBagConstraints = new GridBagConstraints(); Insets defaultInsets = gridBagConstraints.insets; setLayout(gridBagLayout); taskName = new JLabel(); if (timelordTask.isHidden()) { Font taskFont = taskName.getFont(); Font italicFont = new Font(taskFont.getName(), Font.ITALIC, taskFont.getSize()); taskName.setFont(italicFont); } updateTaskNameLabel(); gridBagConstraints.anchor = GridBagConstraints.WEST; gridBagConstraints.weightx = LayoutConstants.HEAVY_WEIGHT; gridBagConstraints.insets = new Insets(0, LayoutConstants.SMALL_INSET, 0, LayoutConstants.BIG_INSET); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagLayout.addLayoutComponent(taskName, gridBagConstraints); add(taskName); minusButton = new JButton("-" + DateUtil.getSmallestTimeInMinutes() + "m"); minusButton.setToolTipText("Remove 15 minutes (0.25 hours) " + "of time from this task."); minusButton.setActionCommand(ACTION_MINUS_15); minusButton.addActionListener(this); gridBagConstraints.anchor = GridBagConstraints.CENTER; gridBagConstraints.insets = defaultInsets; gridBagConstraints.fill = GridBagConstraints.NONE; gridBagConstraints.weightx = 0; gridBagLayout.addLayoutComponent(minusButton, gridBagConstraints); add(minusButton); addButton = new JButton("+" + DateUtil.getSmallestTimeInMinutes() + "m"); addButton.setToolTipText("Add 15 minutes (0.25 hours) of " + "time from this task."); addButton.setActionCommand(ACTION_ADD_15); addButton.addActionListener(this); gridBagConstraints.anchor = GridBagConstraints.CENTER; gridBagConstraints.insets = defaultInsets; gridBagConstraints.fill = GridBagConstraints.NONE; gridBagConstraints.weightx = 0; gridBagLayout.addLayoutComponent(addButton, gridBagConstraints); add(addButton); timeLabel = new JLabel(); if (todayTaskDay != null) { timeLabel.setText(DateUtil.formatHours(null, todayTaskDay.getHours())); } else { timeLabel.setText(DateUtil.formatHours(null, 0)); } gridBagConstraints.anchor = GridBagConstraints.EAST; gridBagConstraints.fill = GridBagConstraints.NONE; gridBagConstraints.weightx = 0; gridBagConstraints.insets = new Insets(0, LayoutConstants.BIG_INSET, 0, LayoutConstants.SMALL_INSET); gridBagLayout.addLayoutComponent(timeLabel, gridBagConstraints); add(timeLabel); enabledButtons(); }
From source file:com.tulskiy.musique.system.configuration.Configuration.java
public void setFont(String key, Font value) { if (value == null) remove(key);/*from w w w.ja v a 2 s .c o m*/ else { String s = new Formatter().format("%s, %d, %d", value.getName(), value.getStyle(), value.getSize()) .toString(); put(key, s); } }
From source file:org.apache.jetspeed.security.mfa.impl.CaptchaImageResource.java
/** * Renders this image/*from ww w .ja v a 2 s. c o m*/ * * @return The image data */ private final byte[] render() throws IOException { Graphics2D gfx = (Graphics2D) this.image.getGraphics(); if (config.isFontAntialiasing()) gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int curWidth = config.getTextMarginLeft(); FontRenderContext ctx = new FontRenderContext(null, config.isFontAntialiasing(), false); for (int i = 0; i < charAttsList.size(); i++) { CharAttributes cf = (CharAttributes) charAttsList.get(i); TextLayout text = new TextLayout(cf.getChar() + "", getFont(cf.getName()), ctx); //gfx.getFontRenderContext()); AffineTransform textAt = new AffineTransform(); textAt.translate(curWidth, this.height - cf.getRise()); if (cf.getRotation() != 0) { textAt.rotate(cf.getRotation()); } if (cf.getShearX() > 0.0) textAt.shear(cf.getShearX(), cf.getShearY()); Shape shape = text.getOutline(textAt); curWidth += shape.getBounds().getWidth() + config.getTextSpacing(); if (config.isUseImageBackground()) gfx.setColor(Color.BLACK); else gfx.setXORMode(Color.BLACK); gfx.fill(shape); } if (config.isEffectsNoise()) { noiseEffects(gfx, image); } if (config.isUseTimestamp()) { if (config.isEffectsNoise()) gfx.setColor(Color.WHITE); else gfx.setColor(Color.BLACK); TimeZone tz = TimeZone.getTimeZone(config.getTimestampTZ()); Calendar cal = new GregorianCalendar(tz); SimpleDateFormat formatter; if (config.isUseTimestamp24hr()) formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss z"); else formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a, z"); formatter.setTimeZone(tz); Font font = gfx.getFont(); Font newFont = new Font(font.getName(), font.getStyle(), config.getTimestampFontSize()); gfx.setFont(newFont); gfx.drawString(formatter.format(cal.getTime()), config.getTextMarginLeft() * 4, this.height - 1); } return toImageData(image); }
From source file:FontChooser.java
/** * Show dialog defaulting to the passed font. * * @param font The font to default to.// www. j a va2 s. co 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; }