List of usage examples for java.awt Font PLAIN
int PLAIN
To view the source code for java.awt Font PLAIN.
Click Source Link
From source file:com.brainflow.application.toplevel.Brainflow.java
private void splashMessage(String message) { Graphics2D g = SplashScreen.getSplashScreen().createGraphics(); //g.setComposite(AlphaComposite.Clear); //g.fillRect(20,430,100,460); //g.setPaintMode(); g.setColor(Color.WHITE);/*from w w w .ja v a 2 s . c o m*/ g.setFont(new Font("helvetica", Font.PLAIN, 16)); g.drawString(message, 20, 430); SplashScreen.getSplashScreen().update(); }
From source file:BookTest.java
/** * Gets the page count of this section./*from w ww. j av a 2 s .c o m*/ * @param g2 the graphics context * @param pf the page format * @return the number of pages needed */ public int getPageCount(Graphics2D g2, PageFormat pf) { if (message.equals("")) return 0; FontRenderContext context = g2.getFontRenderContext(); Font f = new Font("Serif", Font.PLAIN, 72); Rectangle2D bounds = f.getStringBounds(message, context); scale = pf.getImageableHeight() / bounds.getHeight(); double width = scale * bounds.getWidth(); int pages = (int) Math.ceil(width / pf.getImageableWidth()); return pages; }
From source file:edu.ku.brc.ui.skin.SkinItem.java
/** * Constructs the font or return null.// w ww. j av a2 s . c o m * @return return the font or null */ public Font getFont() { if (font == null && StringUtils.isNotEmpty(fontName) && fontSize > 0) { int style = Font.PLAIN; if (StringUtils.isNotEmpty(fontStyle)) { if (fontStyle.equalsIgnoreCase("plain")) { style = Font.PLAIN; } else if (fontStyle.equalsIgnoreCase("bold")) { style = Font.BOLD; } else if (fontStyle.equalsIgnoreCase("italic")) { style = Font.ITALIC; } else if (fontStyle.equalsIgnoreCase("bolditalic")) { style = Font.BOLD | Font.ITALIC; } } font = new Font(fontName, style, fontSize); } return font; }
From source file:net.sf.jasperreports.engine.util.JRFontUtil.java
/** * Returns font information containing the font family, font face and font style. * // w w w . j a v a 2 s . co m * @param name the font family or font face name * @param locale the locale * @return a font info object */ public static FontInfo getFontInfo(String name, Locale locale) { //FIXMEFONT do some cache List<FontFamily> families = ExtensionsEnvironment.getExtensionsRegistry().getExtensions(FontFamily.class); for (Iterator<FontFamily> itf = families.iterator(); itf.hasNext();) { FontFamily family = itf.next(); if (locale == null || family.supportsLocale(locale)) { if (name.equals(family.getName())) { return new FontInfo(family, null, Font.PLAIN); } FontFace face = family.getNormalFace(); if (face != null && name.equals(face.getName())) { return new FontInfo(family, face, Font.PLAIN); } face = family.getBoldFace(); if (face != null && name.equals(face.getName())) { return new FontInfo(family, face, Font.BOLD); } face = family.getItalicFace(); if (face != null && name.equals(face.getName())) { return new FontInfo(family, face, Font.ITALIC); } face = family.getBoldItalicFace(); if (face != null && name.equals(face.getName())) { return new FontInfo(family, face, Font.BOLD | Font.ITALIC); } } } //throw new JRRuntimeException("Font family/face named '" + name + "' not found."); return null; }
From source file:net.sf.jasperreports.engine.fonts.SimpleFontFace.java
public void loadFont() throws InvalidFontException { if (ttf != null && font == null) { if (log.isDebugEnabled()) { log.debug("Loading font " + ttf); }// w ww . j a v a 2s .co m String upperCaseTtf = ttf.trim().toUpperCase(); if (upperCaseTtf.endsWith(".TTF") || upperCaseTtf.endsWith(".OTF")) { InputStream is = null; try { is = RepositoryUtil.getInstance(jasperReportsContext).getInputStreamFromLocation(ttf); } catch (JRException e) { throw new InvalidFontException(ttf, e); } try { font = Font.createFont(Font.TRUETYPE_FONT, is); } catch (FontFormatException e) { throw new InvalidFontException(ttf, e); } catch (IOException e) { throw new InvalidFontException(ttf, e); } finally { try { is.close(); } catch (IOException e) { } } } else { FontUtil.getInstance(jasperReportsContext).checkAwtFont(ttf, JRPropertiesUtil.getInstance(jasperReportsContext) .getBooleanProperty(JRStyledText.PROPERTY_AWT_IGNORE_MISSING_FONT)); font = new Font(ttf, Font.PLAIN, JRPropertiesUtil.getInstance(jasperReportsContext) .getIntegerProperty(JRFont.DEFAULT_FONT_SIZE)); } } }
From source file:com.floreantpos.ui.views.payment.GroupPaymentView.java
private void initComponents() { setLayout(new MigLayout("fill", "[grow][grow]", "")); JPanel centerPanel = new JPanel(new BorderLayout(5, 5)); TransparentPanel transparentPanel1 = new TransparentPanel(new BorderLayout()); labelDueAmount = new javax.swing.JLabel(); labelTenderedAmount = new javax.swing.JLabel(); txtDueAmount = new JTextField(); txtTenderedAmount = new JTextField(); Font font1 = new java.awt.Font("Tahoma", 1, PosUIManager.getFontSize(20)); // NOI18N //$NON-NLS-1$ Font font2 = new java.awt.Font("Arial", Font.PLAIN, PosUIManager.getFontSize(34)); // NOI18N //$NON-NLS-1$ labelTenderedAmount.setFont(font1);/* www . j a v a2 s .co m*/ labelTenderedAmount.setText(Messages.getString("PaymentView.54") + " " + CurrencyUtil.getCurrencySymbol()); //$NON-NLS-1$ //$NON-NLS-2$ labelTenderedAmount.setForeground(Color.gray); txtTenderedAmount.setHorizontalAlignment(javax.swing.JTextField.RIGHT); txtTenderedAmount.setFont(font1); labelDueAmount.setFont(font1); labelDueAmount.setText(Messages.getString("PaymentView.52") + " " + CurrencyUtil.getCurrencySymbol()); //$NON-NLS-1$ //$NON-NLS-2$ labelDueAmount.setForeground(Color.gray); txtDueAmount.setFont(font1); txtDueAmount.setEditable(false); txtDueAmount.setHorizontalAlignment(javax.swing.JTextField.RIGHT); transparentPanel1.setLayout(new MigLayout("", "[][grow,fill]", "[19px][][19px]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ transparentPanel1.add(labelDueAmount, "cell 0 0,alignx right,aligny center"); //$NON-NLS-1$ transparentPanel1.add(labelTenderedAmount, "cell 0 2,alignx left,aligny center"); //$NON-NLS-1$ transparentPanel1.add(txtDueAmount, "cell 1 0,growx,aligny top"); //$NON-NLS-1$ transparentPanel1.add(txtTenderedAmount, "cell 1 2,growx,aligny top"); //$NON-NLS-1$ centerPanel.add(transparentPanel1, BorderLayout.NORTH); calcButtonPanel = new com.floreantpos.swing.TransparentPanel(); calcButtonPanel.setLayout(new MigLayout("wrap 4,fill, ins 0", "sg, fill", "sg, fill")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ btnNextAmount = new com.floreantpos.swing.PosButton(); btnAmount1 = new com.floreantpos.swing.PosButton(); btnAmount1.setFont(font2); btnAmount2 = new com.floreantpos.swing.PosButton(); btnAmount2.setFont(font2); btnAmount5 = new com.floreantpos.swing.PosButton(); btnAmount5.setFont(font2); btnAmount10 = new com.floreantpos.swing.PosButton(); btnAmount10.setFont(font2); btnAmount20 = new com.floreantpos.swing.PosButton(); btnAmount20.setFont(font2); btnAmount50 = new com.floreantpos.swing.PosButton(); btnAmount50.setFont(font2); btnAmount100 = new com.floreantpos.swing.PosButton(); btnAmount100.setFont(font2); btnExactAmount = new com.floreantpos.swing.PosButton(); btn7 = new com.floreantpos.swing.PosButton(); btn8 = new com.floreantpos.swing.PosButton(); btn9 = new com.floreantpos.swing.PosButton(); btn4 = new com.floreantpos.swing.PosButton(); btn5 = new com.floreantpos.swing.PosButton(); btn6 = new com.floreantpos.swing.PosButton(); btn1 = new com.floreantpos.swing.PosButton(); btn2 = new com.floreantpos.swing.PosButton(); btn3 = new com.floreantpos.swing.PosButton(); btn0 = new com.floreantpos.swing.PosButton(); btnDot = new com.floreantpos.swing.PosButton(); btnClear = new com.floreantpos.swing.PosButton(); btn00 = new com.floreantpos.swing.PosButton(); btnAmount1.setForeground(Color.blue); btnAmount1.setAction(nextButtonAction); btnAmount1.setText(Messages.getString("PaymentView.1")); //$NON-NLS-1$ btnAmount1.setActionCommand("1"); //$NON-NLS-1$ btnAmount1.setFocusable(false); calcButtonPanel.add(btnAmount1); btn7.setAction(calAction); btn7.setText("7"); btn7.setFont(font2); //btn7.setIcon(IconFactory.getIcon("/ui_icons/", "7.png")); // NOI18N //$NON-NLS-1$ //$NON-NLS-2$ btn7.setActionCommand("7"); //$NON-NLS-1$ btn7.setFocusable(false); calcButtonPanel.add(btn7); btn8.setAction(calAction); btn8.setText("8"); btn8.setFont(font2); //btn8.setIcon(IconFactory.getIcon("/ui_icons/", "8.png")); // NOI18N //$NON-NLS-1$ //$NON-NLS-2$ btn8.setActionCommand("8"); //$NON-NLS-1$ btn8.setFocusable(false); calcButtonPanel.add(btn8); btn9.setAction(calAction); btn9.setText("9"); btn9.setFont(font2); //btn9.setIcon(IconFactory.getIcon("/ui_icons/", "9.png")); // NOI18N //$NON-NLS-1$ //$NON-NLS-2$ btn9.setActionCommand("9"); //$NON-NLS-1$ btn9.setFocusable(false); calcButtonPanel.add(btn9); btnAmount2.setForeground(Color.blue); btnAmount2.setAction(nextButtonAction); btnAmount2.setText(Messages.getString("PaymentView.10")); //$NON-NLS-1$ btnAmount2.setActionCommand("2"); //$NON-NLS-1$ btnAmount2.setFocusable(false); calcButtonPanel.add(btnAmount2); btn4.setAction(calAction); btn4.setText("4"); btn4.setFont(font2); //btn4.setIcon(IconFactory.getIcon("/ui_icons/", "4.png")); // NOI18N //$NON-NLS-1$ //$NON-NLS-2$ btn4.setActionCommand("4"); //$NON-NLS-1$ btn4.setFocusable(false); calcButtonPanel.add(btn4); btn5.setAction(calAction); btn5.setText("5"); btn5.setFont(font2); //btn5.setIcon(IconFactory.getIcon("/ui_icons/", "5.png")); // NOI18N //$NON-NLS-1$ //$NON-NLS-2$ btn5.setActionCommand("5"); //$NON-NLS-1$ btn5.setFocusable(false); calcButtonPanel.add(btn5); btn6.setAction(calAction); btn6.setText("6"); btn6.setFont(font2); //btn6.setIcon(IconFactory.getIcon("/ui_icons/", "6.png")); // NOI18N //$NON-NLS-1$ //$NON-NLS-2$ btn6.setActionCommand("6"); //$NON-NLS-1$ btn6.setFocusable(false); calcButtonPanel.add(btn6); btnAmount5.setForeground(Color.blue); btnAmount5.setAction(nextButtonAction); btnAmount5.setText(Messages.getString("PaymentView.12")); //$NON-NLS-1$ btnAmount5.setActionCommand("5"); //$NON-NLS-1$ btnAmount5.setFocusable(false); calcButtonPanel.add(btnAmount5); btn1.setAction(calAction); btn1.setText("1"); btn1.setFont(font2); //btn1.setIcon(IconFactory.getIcon("/ui_icons/", "1.png")); // NOI18N //$NON-NLS-1$ //$NON-NLS-2$ btn1.setActionCommand(REMOVE); btn1.setFocusable(false); calcButtonPanel.add(btn1); btn2.setAction(calAction); btn2.setText("2"); btn2.setFont(font2); //btn2.setIcon(IconFactory.getIcon("/ui_icons/", "2.png")); // NOI18N //$NON-NLS-1$ //$NON-NLS-2$ btn2.setActionCommand("2"); //$NON-NLS-1$ btn2.setFocusable(false); calcButtonPanel.add(btn2); btn3.setAction(calAction); btn3.setText("3"); btn3.setFont(font2); //btn3.setIcon(IconFactory.getIcon("/ui_icons/", "3.png")); // NOI18N //$NON-NLS-1$ //$NON-NLS-2$ btn3.setActionCommand("3"); //$NON-NLS-1$ btn3.setFocusable(false); calcButtonPanel.add(btn3); btnAmount10.setForeground(Color.blue); btnAmount10.setAction(nextButtonAction); btnAmount10.setText(Messages.getString("PaymentView.14")); //$NON-NLS-1$ btnAmount10.setActionCommand("10"); //$NON-NLS-1$ btnAmount10.setFocusable(false); calcButtonPanel.add(btnAmount10, "grow"); //$NON-NLS-1$ btn0.setAction(calAction); btn0.setText("0"); btn0.setFont(font2); //btn0.setIcon(IconFactory.getIcon("/ui_icons/", "0.png")); // NOI18N //$NON-NLS-1$ //$NON-NLS-2$ btn0.setActionCommand(ZERO); btn0.setFocusable(false); calcButtonPanel.add(btn0); btn00.setFont(new Font("Arial", Font.PLAIN, 30)); //$NON-NLS-1$ btn00.setAction(calAction); btn00.setText(Messages.getString("PaymentView.18")); //$NON-NLS-1$ btn00.setActionCommand("00"); //$NON-NLS-1$ btn00.setFocusable(false); calcButtonPanel.add(btn00); btnDot.setAction(calAction); btnDot.setIcon(IconFactory.getIcon("/ui_icons/", "dot.png")); // NOI18N //$NON-NLS-1$ //$NON-NLS-2$ btnDot.setActionCommand("."); //$NON-NLS-1$ btnDot.setFocusable(false); calcButtonPanel.add(btnDot); btnAmount20.setForeground(Color.BLUE); btnAmount20.setAction(nextButtonAction); btnAmount20.setText("20"); //$NON-NLS-1$ btnAmount20.setActionCommand("20"); //$NON-NLS-1$ btnAmount20.setFocusable(false); calcButtonPanel.add(btnAmount20, "grow"); //$NON-NLS-1$ btnAmount50.setForeground(Color.blue); btnAmount50.setAction(nextButtonAction); btnAmount50.setText("50"); //$NON-NLS-1$ btnAmount50.setActionCommand("50"); //$NON-NLS-1$ btnAmount50.setFocusable(false); calcButtonPanel.add(btnAmount50, "grow"); //$NON-NLS-1$ btnAmount100.setForeground(Color.blue); btnAmount100.setAction(nextButtonAction); btnAmount100.setText("100"); //$NON-NLS-1$ btnAmount100.setActionCommand("100"); //$NON-NLS-1$ btnAmount100.setFocusable(false); calcButtonPanel.add(btnAmount100, "grow"); //$NON-NLS-1$ btnClear.setAction(calAction); btnClear.setIcon(IconFactory.getIcon("/ui_icons/", "clear.png")); // NOI18N //$NON-NLS-1$ //$NON-NLS-2$ btnClear.setText(Messages.getString("PaymentView.38")); //$NON-NLS-1$ btnClear.setFocusable(false); calcButtonPanel.add(btnClear); btnExactAmount.setAction(nextButtonAction); btnExactAmount.setText(Messages.getString("PaymentView.20")); //$NON-NLS-1$ btnExactAmount.setActionCommand("exactAmount"); //$NON-NLS-1$ btnExactAmount.setFocusable(false); calcButtonPanel.add(btnExactAmount, "span 2,grow"); //$NON-NLS-1$ btnNextAmount.setAction(nextButtonAction); btnNextAmount.setText(Messages.getString("PaymentView.23")); //$NON-NLS-1$ btnNextAmount.setActionCommand("nextAmount"); //$NON-NLS-1$ btnNextAmount.setFocusable(false); calcButtonPanel.add(btnNextAmount, "span 2,grow"); //$NON-NLS-1$ PosButton btnPrint = new com.floreantpos.swing.PosButton(POSConstants.PRINT_TICKET); btnPrint.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { for (Ticket ticket : groupSettleTicketView.getTickets()) { ReceiptPrintService.printTicket(ticket); } } }); calcButtonPanel.add(btnPrint, "span 4,grow"); //$NON-NLS-1$ centerPanel.add(calcButtonPanel, BorderLayout.CENTER); actionButtonPanel = new com.floreantpos.swing.TransparentPanel(); actionButtonPanel.setLayout(new MigLayout("wrap 1, ins 0 20 0 0,hidemode 3, fill", "sg, fill", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //actionButtonPanel.setPreferredSize(PosUIManager.getSize(180, 380)); int width = PosUIManager.getSize(160); btnCash = new com.floreantpos.swing.PosButton(Messages.getString("PaymentView.31")); //$NON-NLS-1$ actionButtonPanel.add(btnCash, "grow,w " + width + "!"); //$NON-NLS-1$ //$NON-NLS-2$ btnCash.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { try { double x = NumberUtil.parse(txtTenderedAmount.getText()).doubleValue(); if (x <= 0) { POSMessageDialog.showError(Messages.getString("PaymentView.32")); //$NON-NLS-1$ return; } groupSettleTicketView.doGroupSettle(PaymentType.CASH); } catch (Exception e) { org.apache.commons.logging.LogFactory.getLog(getClass()).error(e); } } }); PosButton btnMultiCurrencyCash = new com.floreantpos.swing.PosButton("MULTI CURRENCY CASH"); //$NON-NLS-1$ actionButtonPanel.add(btnMultiCurrencyCash, "grow,w " + width + "!"); //$NON-NLS-1$ //$NON-NLS-2$ btnMultiCurrencyCash.setVisible(TerminalConfig.isEnabledMultiCurrency()); btnMultiCurrencyCash.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { try { List<Currency> currencyList = CurrencyUtil.getAllCurrency(); if (currencyList.size() > 1) { if (!adjustCashDrawerBalance(currencyList)) { return; } } double x = NumberUtil.parse(txtTenderedAmount.getText()).doubleValue(); if (x <= 0) { POSMessageDialog.showError(Messages.getString("PaymentView.32")); //$NON-NLS-1$ return; } groupSettleTicketView.doGroupSettle(PaymentType.CASH); } catch (Exception e) { org.apache.commons.logging.LogFactory.getLog(getClass()).error(e); } } }); btnCreditCard = new PosButton(Messages.getString("PaymentView.33")); //$NON-NLS-1$ actionButtonPanel.add(btnCreditCard, "grow,w " + width + "!"); //$NON-NLS-1$ //$NON-NLS-2$ btnCreditCard.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupSettleTicketView.doGroupSettle(PaymentType.CREDIT_CARD); } }); btnGift = new PosButton(Messages.getString("PaymentView.35")); //$NON-NLS-1$ actionButtonPanel.add(btnGift, "grow,w " + width + "!"); //$NON-NLS-1$ //$NON-NLS-2$ btnGift.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupSettleTicketView.doGroupSettle(PaymentType.GIFT_CERTIFICATE); } }); btnOther = new PosButton("OTHER"); //$NON-NLS-1$ actionButtonPanel.add(btnOther, "grow,w " + width + "!"); //$NON-NLS-1$ //$NON-NLS-2$ btnOther.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupSettleTicketView.doGroupSettle(PaymentType.CUSTOM_PAYMENT); } }); btnCancel = new com.floreantpos.swing.PosButton(POSConstants.CANCEL.toUpperCase()); actionButtonPanel.add(btnCancel, "grow,w " + width + "!"); //$NON-NLS-1$ //$NON-NLS-2$ btnCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCancelActionPerformed(evt); } }); //rightPanel.add(actionButtonPanel, BorderLayout.EAST); add(centerPanel, "cell 0 0,grow"); add(actionButtonPanel, "cell 1 0,grow"); }
From source file:com.seniorproject.augmentedreality.test.AreaChartDemo.java
/** * Creates a chart.//from ww w .j a v a 2 s. c o m * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createAreaChart("Area Chart", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setAnchor(StandardLegend.SOUTH); chart.setBackgroundPaint(Color.white); final TextTitle subtitle = new TextTitle("An area chart demonstration. We use this " + "subtitle as an example of what happens when you get a really long title or " + "subtitle."); subtitle.setFont(new Font("SansSerif", Font.PLAIN, 12)); subtitle.setPosition(RectangleEdge.TOP); // subtitle.setSpacer(new Spacer(Spacer.RELATIVE, 0.05, 0.05, 0.05, 0.05)); subtitle.setVerticalAlignment(VerticalAlignment.BOTTOM); chart.addSubtitle(subtitle); final CategoryPlot plot = chart.getCategoryPlot(); plot.setForegroundAlpha(0.5f); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.addCategoryLabelToolTip("Type 1", "The first type."); domainAxis.addCategoryLabelToolTip("Type 2", "The second type."); domainAxis.addCategoryLabelToolTip("Type 3", "The third type."); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLabelAngle(0 * Math.PI / 2.0); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:com.mxgraph.examples.swing.chart.BarChartDemo1.java
/** * Creates a sample chart./*from w ww . ja v a 2s . c om*/ * * @param dataset the dataset. * * @return The chart. */ public static JFreeChart createChart(final CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBarChart("", // chart title "X-value", // domain axis label "Y-value", // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation true, // include legend true, false); chart.addSubtitle(new TextTitle("http://www.bupt.edu.cn", new Font("", Font.ITALIC, 10))); // chart.setBackgroundPaint(Color.white); // chart.setBackgroundPaint(Color.getHSBColor(2, 29, 100)); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setBaseItemLabelsVisible(true); // renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setCategoryMargin(0.1);// categoryAxis.setUpperMargin(0.02); categoryAxis.setLowerMargin(0.02); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperMargin(0.10); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); chart.getTitle().setFont(new Font("", Font.PLAIN, 16));// CategoryAxis domainAxis = plot.getDomainAxis(); // domainAxis.setLabelFont(new Font("", Font.PLAIN, 14)); // domainAxis.setTickLabelFont(new Font("", Font.PLAIN, 10)); // rangeAxis.setLabelFont(new Font("", Font.PLAIN, 15)); chart.getLegend().setItemFont(new Font("", Font.PLAIN, 15)); return chart; }
From source file:com.awesomecoding.minetestlauncher.Main.java
private void initialize() { fileGetter = new FileGetter(userhome + "\\minetest\\temp\\"); latest = fileGetter.getContents("http://socialmelder.com/minetest/latest.txt", true); currentVersion = latest.split("\n")[0]; changelog = fileGetter.getContents("http://socialmelder.com/minetest/changelog.html", false); try {//from w ww . ja v a 2s. com UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } frmMinetestLauncherV = new JFrame(); frmMinetestLauncherV.setResizable(false); frmMinetestLauncherV.setIconImage(Toolkit.getDefaultToolkit() .getImage(Main.class.getResource("/com/awesomecoding/minetestlauncher/icon.png"))); frmMinetestLauncherV.setTitle("Minetest Launcher (Version 0.1)"); frmMinetestLauncherV.setBounds(100, 100, 720, 480); frmMinetestLauncherV.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpringLayout springLayout = new SpringLayout(); frmMinetestLauncherV.getContentPane().setLayout(springLayout); final JProgressBar progressBar = new JProgressBar(); springLayout.putConstraint(SpringLayout.WEST, progressBar, 10, SpringLayout.WEST, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.SOUTH, progressBar, -10, SpringLayout.SOUTH, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.EAST, progressBar, -130, SpringLayout.EAST, frmMinetestLauncherV.getContentPane()); frmMinetestLauncherV.getContentPane().add(progressBar); final JButton btnDownloadPlay = new JButton("Play!"); springLayout.putConstraint(SpringLayout.WEST, btnDownloadPlay, 6, SpringLayout.EAST, progressBar); springLayout.putConstraint(SpringLayout.SOUTH, btnDownloadPlay, 0, SpringLayout.SOUTH, progressBar); springLayout.putConstraint(SpringLayout.EAST, btnDownloadPlay, -10, SpringLayout.EAST, frmMinetestLauncherV.getContentPane()); frmMinetestLauncherV.getContentPane().add(btnDownloadPlay); final JLabel label = new JLabel("Ready to play!"); springLayout.putConstraint(SpringLayout.WEST, label, 10, SpringLayout.WEST, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.NORTH, btnDownloadPlay, 0, SpringLayout.NORTH, label); springLayout.putConstraint(SpringLayout.SOUTH, label, -37, SpringLayout.SOUTH, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.NORTH, progressBar, 6, SpringLayout.SOUTH, label); frmMinetestLauncherV.getContentPane().add(label); JTextPane txtpnNewFeatures = new JTextPane(); txtpnNewFeatures.setBackground(SystemColor.window); springLayout.putConstraint(SpringLayout.NORTH, txtpnNewFeatures, 10, SpringLayout.NORTH, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.WEST, txtpnNewFeatures, 10, SpringLayout.WEST, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.SOUTH, txtpnNewFeatures, -10, SpringLayout.NORTH, btnDownloadPlay); springLayout.putConstraint(SpringLayout.EAST, txtpnNewFeatures, 0, SpringLayout.EAST, btnDownloadPlay); txtpnNewFeatures.setEditable(false); txtpnNewFeatures.setContentType("text/html"); txtpnNewFeatures.setText(changelog); txtpnNewFeatures.setFont(new Font("Tahoma", Font.PLAIN, 12)); frmMinetestLauncherV.getContentPane().add(txtpnNewFeatures); File file = new File(userhome + "\\minetest\\version.txt"); if (!file.exists()) newVersion = true; else { String version = fileGetter.getLocalContents(file, false); if (!version.equals(currentVersion)) newVersion = true; } if (newVersion) { label.setText("New Version Available! (" + currentVersion + ")"); btnDownloadPlay.setText("Download & Play"); btnDownloadPlay.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { Thread t = new Thread() { public void run() { File file = new File(userhome + "\\minetest\\version.txt"); String version = fileGetter.getLocalContents(file, false); try { FileUtils.deleteDirectory(new File(userhome + "\\minetest\\minetest-" + version)); } catch (Exception e) { e.printStackTrace(); } fileGetter.download(latest.split("\n")[1], userhome + "\\minetest\\temp\\", "minetest.zip", label, progressBar, btnDownloadPlay, currentVersion); try { label.setText("Cleaning up..."); btnDownloadPlay.setText("Cleaning up..."); FileUtils.deleteDirectory(new File(userhome + "\\minetest\\temp")); } catch (IOException e) { e.printStackTrace(); } System.exit(0); } }; t.start(); } }); } else { btnDownloadPlay.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { try { label.setText("Launching..."); btnDownloadPlay.setEnabled(false); btnDownloadPlay.setText("Launching..."); File file = new File(userhome + "\\minetest\\version.txt"); String version = fileGetter.getLocalContents(file, false); Runtime.getRuntime() .exec(userhome + "\\minetest\\minetest-" + version + "\\bin\\minetest.exe"); System.exit(0); } catch (IOException e) { e.printStackTrace(); } } }); progressBar.setValue(100); } }
From source file:org.jfree.chart.demo.ImageMapDemo6.java
/** * Creates a sample chart with the given dataset. * /*from w w w.ja va 2s .c o m*/ * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createMultiplePieChart("Multiple Pie Chart", // chart title dataset, // dataset TableOrder.BY_ROW, true, // include legend true, true); final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot(); final JFreeChart subchart = plot.getPieChart(); final PiePlot p = (PiePlot) subchart.getPlot(); p.setLabelGenerator(new StandardPieItemLabelGenerator("{0}")); p.setLabelFont(new Font("SansSerif", Font.PLAIN, 8)); p.setInteriorGap(0.30); return chart; }