List of usage examples for java.awt Font decode
public static Font decode(String str)
From source file:Main.java
/** * Retrieve and transform the property value into a Font. * @param name The property name/* ww w . ja v a2s .c om*/ * @return A valid font (or null if invalid) * @throws IOException If an error occurred while accessing the properties file. */ public static Font asFont(String font) { if (font != null) return Font.decode(font); return null; }
From source file:Main.java
public static void setFont(Container container, String fontStr) { setFont(container, Font.decode(fontStr)); }
From source file:CubaHSQLDBServer.java
private CubaHSQLDBServer() { Font monospaced = Font.decode("monospaced"); statusArea = new JTextArea(2, 80); statusArea.setFont(monospaced);//from ww w . j a v a2 s . co m statusArea.setMargin(new Insets(5, 5, 5, 5)); exceptionArea = new JTextArea(26, 80); exceptionArea.setFont(monospaced); exceptionArea.setMargin(new Insets(5, 5, 5, 5)); JPanel exceptionWrapperContainer = new JPanel(); exceptionWrapperContainer.setLayout(new BorderLayout(0, 0)); exceptionWrapperContainer.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); exceptionWrapperContainer.add(exceptionArea); JPanel statusWrapperContainer = new JPanel(); statusWrapperContainer.setLayout(new BorderLayout(0, 0)); statusWrapperContainer.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); statusWrapperContainer.add(statusArea); addCopyPopup(statusArea); addCopyPopup(exceptionArea); exceptionBox = new JPanel(); LayoutBuilder.create(exceptionBox, BoxLayout.Y_AXIS).addSpace(5).addComponent(exceptionWrapperContainer); LayoutBuilder.create(this.getContentPane(), BoxLayout.X_AXIS).addSpace(5).addContainer(BoxLayout.Y_AXIS) .addSpace(5).addComponent(statusWrapperContainer).addComponent(exceptionBox).addSpace(5) .returnToParent().addSpace(5); statusArea.setEditable(false); exceptionArea.setEditable(false); exceptionBox.setVisible(false); exceptionArea.setBackground(new Color(255, 255, 212)); this.pack(); this.setResizable(true); this.setTitle("HSQLDB Server"); try { this.setIconImage(ImageIO.read(getClass().getResourceAsStream("/icons/database.png"))); } catch (IOException e) { throw new IllegalStateException("Unable to find icon for HSQLDB window"); } }
From source file:eu.lp0.cursus.ui.AboutDialog.java
private void initialise() { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle(Messages.getString("about.title", Constants.APP_DESC)); //$NON-NLS-1$ DefaultUnitConverter duc = DefaultUnitConverter.getInstance(); FormLayout layout = new FormLayout("2dlu, pref, fill:pref:grow, max(30dlu;pref), 2dlu", //$NON-NLS-1$ "2dlu, max(15dlu;pref), 2dlu, max(15dlu;pref), 2dlu, fill:max(100dlu;pref):grow, 2dlu, max(16dlu;pref), 2dlu"); //$NON-NLS-1$ getContentPane().setLayout(layout);//ww w.j ava2s. c o m JLabel lblName = new JLabel(Constants.APP_NAME + ": " + Messages.getString("about.description")); //$NON-NLS-1$ //$NON-NLS-2$ getContentPane().add(lblName, "2, 2, 3, 1"); //$NON-NLS-1$ getContentPane().add(new LinkJButton(Constants.APP_URL), "2, 4"); //$NON-NLS-1$ JScrollPane scrCopying = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); getContentPane().add(scrCopying, "2, 6, 3, 1"); //$NON-NLS-1$ JTextArea txtCopying = new JTextArea(loadResources("COPYRIGHT", "LICENCE")); //$NON-NLS-1$ //$NON-NLS-2$ txtCopying.setFont(Font.decode(Font.MONOSPACED)); txtCopying.setEditable(false); scrCopying.setViewportView(txtCopying); scrCopying.setPreferredSize( new Dimension(scrCopying.getPreferredSize().width, duc.dialogUnitYAsPixel(100, scrCopying))); Action actClose = new CloseDialogAction(this); JButton btnClose = new JButton(actClose); getContentPane().add(btnClose, "4, 8"); //$NON-NLS-1$ getRootPane().setDefaultButton(btnClose); getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CloseDialogAction.class.getName()); getRootPane().getActionMap().put(CloseDialogAction.class.getName(), actClose); pack(); setMinimumSize(getSize()); setSize(getSize().width, getSize().height * 3 / 2); btnClose.requestFocusInWindow(); }
From source file:es.emergya.cliente.constants.LogicConstantsUI.java
private static Font getFont(Integer type, String font) { Font f;/*from w ww . j a va2s . c om*/ try { f = Font.createFont(Font.TRUETYPE_FONT, LogicConstantsUI.class.getResourceAsStream(font)); } catch (Exception e) { LogicConstantsUI.LOG.error("No se pudo cargar el font bold", e); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] fontNames = ge.getAvailableFontFamilyNames(); if (fontNames.length > 0) { f = Font.decode(fontNames[0]); if (type != null) { f = f.deriveFont(type); } } else { throw new NullPointerException("There is no font available: " + font); } } return f; }
From source file:es.emergya.cliente.constants.LogicConstants.java
private static Font getFont(Integer type, String font) { Font f;//from w ww. j a v a2s .c o m try { f = Font.createFont(Font.TRUETYPE_FONT, LogicConstants.class.getResourceAsStream(font)); } catch (Exception e) { LogicConstants.LOG.error("No se pudo cargar el font bold", e); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] fontNames = ge.getAvailableFontFamilyNames(); if (fontNames.length > 0) { f = Font.decode(fontNames[0]); if (type != null) { f = f.deriveFont(type); } } else { throw new NullPointerException("There is no font available: " + font); } } return f; }
From source file:org.pentaho.plugin.jfreereport.reportcharts.MultiPieChartExpression.java
protected void configureSubChart(final JFreeChart chart) { final TextTitle chartTitle = chart.getTitle(); if (chartTitle != null) { if (getPieTitleFont() != null) { chartTitle.setFont(getPieTitleFont()); } else {// ww w. j av a 2 s .c o m final Font titleFont = Font.decode(getTitleFont()); chartTitle.setFont(titleFont); } } if (isAntiAlias() == false) { chart.setAntiAlias(false); } final LegendTitle chLegend = chart.getLegend(); if (chLegend != null) { final RectangleEdge loc = translateEdge(getLegendLocation().toLowerCase()); if (loc != null) { chLegend.setPosition(loc); } if (getLegendFont() != null) { chLegend.setItemFont(Font.decode(getLegendFont())); } if (!isDrawLegendBorder()) { chLegend.setBorder(BlockBorder.NONE); } if (getLegendBackgroundColor() != null) { chLegend.setBackgroundPaint(getLegendBackgroundColor()); } if (getLegendTextColor() != null) { chLegend.setItemPaint(getLegendTextColor()); } } final Plot plot = chart.getPlot(); plot.setNoDataMessageFont(Font.decode(getLabelFont())); final String pieNoData = getPieNoDataMessage(); if (pieNoData != null) { plot.setNoDataMessage(pieNoData); } else { final String message = getNoDataMessage(); if (message != null) { plot.setNoDataMessage(message); } } }
From source file:au.org.ala.delta.editor.EditorPreferences.java
public static Font getPreferredFont() { Preferences prefs = Preferences.userNodeForPackage(DeltaEditor.class); if (prefs != null) { String font = prefs.get(FONT_KEY, null); if (font != null) { return Font.decode(font); }//from w w w .j a v a2 s .com } return null; }
From source file:org.pentaho.plugin.jfreereport.reportcharts.MultiPieChartExpression.java
protected void configureChart(final JFreeChart chart) { super.configureChart(chart); final Plot plot = chart.getPlot(); final MultiplePiePlot mpp = (MultiplePiePlot) plot; final JFreeChart pc = mpp.getPieChart(); configureSubChart(pc);/* www . j a v a 2s.c o m*/ final PiePlot pp = (PiePlot) pc.getPlot(); if (StringUtils.isEmpty(getTooltipFormula()) == false) { pp.setToolTipGenerator(new FormulaPieTooltipGenerator(getRuntime(), getTooltipFormula())); } if (StringUtils.isEmpty(getUrlFormula()) == false) { pp.setURLGenerator(new FormulaPieURLGenerator(getRuntime(), getUrlFormula())); } if (shadowPaint != null) { pp.setShadowPaint(shadowPaint); } if (shadowXOffset != null) { pp.setShadowXOffset(shadowXOffset.doubleValue()); } if (shadowYOffset != null) { pp.setShadowYOffset(shadowYOffset.doubleValue()); } final CategoryDataset c = mpp.getDataset(); if (c != null) { final String[] colors = getSeriesColor(); final int keysSize = c.getColumnKeys().size(); for (int i = 0; i < colors.length; i++) { if (keysSize > i) { pp.setSectionPaint(c.getColumnKey(i), parseColorFromString(colors[i])); } } } if (StringUtils.isEmpty(getLabelFont()) == false) { pp.setLabelFont(Font.decode(getLabelFont())); } if (Boolean.FALSE.equals(getItemsLabelVisible())) { pp.setLabelGenerator(null); } else { final ExpressionRuntime runtime = getRuntime(); final Locale locale = runtime.getResourceBundleFactory().getLocale(); final FastDecimalFormat fastPercent = new FastDecimalFormat(FastDecimalFormat.TYPE_PERCENT, locale); final FastDecimalFormat fastInteger = new FastDecimalFormat(FastDecimalFormat.TYPE_INTEGER, locale); final DecimalFormat numFormat = new DecimalFormat(fastInteger.getPattern(), new DecimalFormatSymbols(locale)); numFormat.setRoundingMode(RoundingMode.HALF_UP); final DecimalFormat percentFormat = new DecimalFormat(fastPercent.getPattern(), new DecimalFormatSymbols(locale)); percentFormat.setRoundingMode(RoundingMode.HALF_UP); final StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator( multipieLabelFormat, numFormat, percentFormat); pp.setLabelGenerator(labelGen); } }
From source file:forms.frDados.java
/** * Inicializa o grfico de velocidade./*from w ww. j a v a2s .com*/ */ private void initSatVelox() { dadosGraficoVelox.clear(); veloxPlot = ChartFactory.createLineChart("Velocidade", "Hora", "Velocidade KM/h", dadosGraficoVelox, PlotOrientation.VERTICAL, false, true, false); veloxPlot.getTitle().setFont(Font.decode("arial-16")); veloxPlot.getTitle().setPadding(5, 20, 5, 20); veloxPlot.setPadding(new RectangleInsets(10, 10, 0, 10)); ChartPanel cp = new ChartPanel(veloxPlot); cp.setBorder(LineBorder.createGrayLineBorder()); LineAndShapeRenderer br = (LineAndShapeRenderer) veloxPlot.getCategoryPlot().getRenderer(); br.setBaseItemLabelsVisible(true); br.setSeriesItemLabelFont(0, Font.decode("arial-12")); br.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); br.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER)); veloxPlot.getCategoryPlot().getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); //veloxPlot.getCategoryPlot().getRangeAxis().setRange(new Range(0,100), true,true); pnlChartSpeed.setLayout(new BorderLayout()); pnlChartSpeed.add(cp, BorderLayout.CENTER); }