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:clienteProfessor.ClickerOne_Resultados.java
public void criaGrafico() { CategoryDataset cds = createDataset(); String titulo = "Resultado da aula: " + jComboBoxAulas.getSelectedItem(); String eixoy = "Quantidade de escolhas"; String txt_legenda = "Legenda:"; boolean legenda = true; boolean tooltips = true; boolean urls = true; JFreeChart graf = ChartFactory.createBarChart3D(titulo, txt_legenda, eixoy, cds, PlotOrientation.VERTICAL, legenda, tooltips, urls);// ww w .j av a2 s .c om //JFreeChart graf = ChartFactory.createBarChart3D(titulo, txt_legenda, eixoy, cds, PlotOrientation.VERTICAL, legenda, tooltips, urls); ChartPanel myChartPanel = new ChartPanel(graf, true); myChartPanel.setSize(jPanel1.getWidth(), jPanel1.getHeight()); myChartPanel.setVisible(true); myChartPanel.setFont(new Font("Arial", Font.PLAIN, 25)); myChartPanel.setBackground(this.getBackground()); jPanel1.removeAll(); jPanel1.add(myChartPanel); jPanel1.revalidate(); jPanel1.repaint(); }
From source file:org.jfree.chart.demo.MultiplePieChartDemo4.java
/** * Creates a sample chart for the given dataset. * //from w w w . j a v a2s . co m * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createMultiplePieChart3D("Multiple Pie Chart Demo 4", dataset, TableOrder.BY_COLUMN, false, true, false); chart.setBackgroundPaint(new Color(216, 255, 216)); final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot(); final JFreeChart subchart = plot.getPieChart(); // final StandardLegend legend = new StandardLegend(); // legend.setItemFont(new Font("SansSerif", Font.PLAIN, 8)); // legend.setAnchor(Legend.SOUTH); // subchart.setLegend(legend); plot.setLimit(0.10); 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; }
From source file:com.floreantpos.ui.views.payment.PaymentView.java
private void initComponents() { setLayout(new MigLayout("fill", "[grow][grow]", "")); JPanel leftPanel = new JPanel(new BorderLayout(5, 5)); TransparentPanel transparentPanel1 = new TransparentPanel(new BorderLayout(5, 5)); 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);/*from w w w . jav a 2 s . c om*/ 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]", "[grow][][grow]")); //$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$ leftPanel.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$ btnGratuity = new PosButton(com.floreantpos.POSConstants.ADD_GRATUITY_TEXT); btnGratuity.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSetGratuity(); } }); //calcButtonPanel.add(btnGratuity, "split 3,span,growx"); //$NON-NLS-1$ btnDiscount = new PosButton(com.floreantpos.POSConstants.COUPON_DISCOUNT); btnDiscount.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { settleTicketView.doApplyCoupon(); } }); //calcButtonPanel.add(btnDiscount, "growx"); //$NON-NLS-1$ btnPrint = new com.floreantpos.swing.PosButton(POSConstants.PRINT_TICKET); btnPrint.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ReceiptPrintService.printTicket(settleTicketView.getTicket()); } }); // calcButtonPanel.add(btnPrint, "growx"); //$NON-NLS-1$ JPanel panel4 = new JPanel(new GridLayout(1, 0, 5, 5)); panel4.add(btnGratuity); panel4.add(btnDiscount); panel4.add(btnPrint); calcButtonPanel.add(panel4, "span 4,growx"); //$NON-NLS-1$ leftPanel.add(calcButtonPanel, BorderLayout.CENTER); actionButtonPanel = new com.floreantpos.swing.TransparentPanel(); actionButtonPanel.setOpaque(true); actionButtonPanel.setLayout(new MigLayout("hidemode 3,wrap 1, ins 0 20 0 0, fill", "sg, fill", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //actionButtonPanel.setPreferredSize(PosUIManager.getSize(120, 0)); 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) { doPayByCash(); } }); 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; } settleTicketView.doSettle(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) { settleTicketView.doSettle(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) { settleTicketView.doSettle(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) { settleTicketView.doSettle(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(leftPanel, "cell 0 0,grow"); add(actionButtonPanel, "cell 1 0,grow"); }
From source file:net.sf.mzmine.chartbasics.chartthemes.ChartThemeFactory.java
/** * Creates and returns a theme called "Darkness". In this theme, the charts have a black * background and white lines and labels * * @return The "Darkness" theme./*from w w w . java 2 s .c om*/ */ public static EStandardChartTheme createDarknessTheme() { EStandardChartTheme theme = new EStandardChartTheme(THEME.DARKNESS, "Darkness"); // Fonts theme.setExtraLargeFont(new Font("Arial", Font.BOLD, 20)); theme.setLargeFont(new Font("Arial", Font.BOLD, 11)); theme.setRegularFont(new Font("Arial", Font.PLAIN, 11)); theme.setSmallFont(new Font("Arial", Font.PLAIN, 11)); // theme.setTitlePaint(Color.white); theme.setSubtitlePaint(Color.white); theme.setLegendBackgroundPaint(Color.black); theme.setLegendItemPaint(Color.white); theme.setChartBackgroundPaint(Color.black); theme.setPlotBackgroundPaint(Color.black); theme.setPlotOutlinePaint(Color.yellow); theme.setBaselinePaint(Color.white); theme.setCrosshairPaint(Color.red); theme.setLabelLinkPaint(Color.lightGray); theme.setTickLabelPaint(Color.white); theme.setAxisLabelPaint(Color.white); theme.setShadowPaint(Color.darkGray); theme.setItemLabelPaint(Color.white); theme.setDrawingSupplier(new DefaultDrawingSupplier( new Paint[] { Color.WHITE, Color.decode("0xFFFF00"), Color.decode("0x0036CC"), Color.decode("0xFF0000"), Color.decode("0xFFFF7F"), Color.decode("0x6681CC"), Color.decode("0xFF7F7F"), Color.decode("0xFFFFBF"), Color.decode("0x99A6CC"), Color.decode("0xFFBFBF"), Color.decode("0xA9A938"), Color.decode("0x2D4587") }, new Paint[] { Color.decode("0xFFFF00"), Color.decode("0x0036CC") }, new Stroke[] { new BasicStroke(2.0f) }, new Stroke[] { new BasicStroke(0.5f) }, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); theme.setErrorIndicatorPaint(Color.lightGray); theme.setGridBandPaint(new Color(255, 255, 255, 20)); theme.setGridBandAlternatePaint(new Color(255, 255, 255, 40)); // axis Color transp = new Color(255, 255, 255, 200); theme.setRangeGridlinePaint(transp); theme.setDomainGridlinePaint(transp); theme.setAxisLinePaint(Color.white); theme.setMasterFontColor(Color.WHITE); // axis offset theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); return theme; }
From source file:com.mothsoft.alexis.web.ChartServlet.java
private void doLineGraph(final HttpServletRequest request, final HttpServletResponse response, final String title, final String[] dataSetIds, final Integer width, final Integer height, final Integer numberOfSamples) throws ServletException, IOException { final DataSetService dataSetService = WebApplicationContextUtils .getWebApplicationContext(this.getServletContext()).getBean(DataSetService.class); final OutputStream out = response.getOutputStream(); response.setContentType("image/png"); response.setHeader("Cache-Control", "max-age: 5; must-revalidate"); final XYSeriesCollection seriesCollection = new XYSeriesCollection(); final DateAxis dateAxis = new DateAxis(title != null ? title : "Time"); final DateTickUnit unit = new DateTickUnit(DateTickUnit.HOUR, 1); final DateFormat chartFormatter = new SimpleDateFormat("ha"); dateAxis.setDateFormatOverride(chartFormatter); dateAxis.setTickUnit(unit);//from ww w .j a v a 2 s .c o m dateAxis.setLabelFont(DEFAULT_FONT); dateAxis.setTickLabelFont(DEFAULT_FONT); if (numberOfSamples > 12) { dateAxis.setTickLabelFont( new Font(DEFAULT_FONT.getFamily(), Font.PLAIN, (int) (DEFAULT_FONT.getSize() * .8))); } final NumberAxis yAxis = new NumberAxis("Activity"); final StandardXYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES); int colorCounter = 0; if (dataSetIds != null) { for (final String dataSetIdString : dataSetIds) { final Long dataSetId = Long.valueOf(dataSetIdString); final DataSet dataSet = dataSetService.get(dataSetId); // go back for numberOfSamples, but include current hour final Calendar calendar = new GregorianCalendar(); calendar.add(Calendar.HOUR_OF_DAY, -1 * (numberOfSamples - 1)); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); final Timestamp startDate = new Timestamp(calendar.getTimeInMillis()); calendar.add(Calendar.HOUR_OF_DAY, numberOfSamples); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 59); calendar.set(Calendar.MILLISECOND, 999); final Timestamp endDate = new Timestamp(calendar.getTimeInMillis()); logger.debug(String.format("Generating chart for period: %s to %s", startDate.toString(), endDate.toString())); final List<DataSetPoint> dataSetPoints = dataSetService .findAndAggregatePointsGroupedByUnit(dataSetId, startDate, endDate, TimeUnits.HOUR); final boolean hasData = addSeries(seriesCollection, dataSet.getName(), dataSetPoints, startDate, numberOfSamples, renderer); if (dataSet.isAggregate()) { renderer.setSeriesPaint(seriesCollection.getSeriesCount() - 1, Color.BLACK); } else if (hasData) { renderer.setSeriesPaint(seriesCollection.getSeriesCount() - 1, PAINTS[colorCounter++ % PAINTS.length]); } else { renderer.setSeriesPaint(seriesCollection.getSeriesCount() - 1, Color.LIGHT_GRAY); } } } final XYPlot plot = new XYPlot(seriesCollection, dateAxis, yAxis, renderer); // create the chart... final JFreeChart chart = new JFreeChart(plot); // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... plot.setBackgroundPaint(new Color(253, 253, 253)); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabelFont(DEFAULT_FONT); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLowerBound(0.00d); ChartUtilities.writeChartAsPNG(out, chart, width, height); }
From source file:com.xmage.launcher.XMageLauncher.java
private XMageLauncher() { locale = Locale.getDefault(); //locale = new Locale("it", "IT"); messages = ResourceBundle.getBundle("MessagesBundle", locale); localize();/*from w w w .j av a 2 s . c o m*/ serverConsole = new XMageConsole("XMage Server console"); clientConsole = new XMageConsole("XMage Client console"); frame = new JFrame(messages.getString("frameTitle") + " " + Config.getVersion()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(800, 500)); frame.setResizable(false); createToolbar(); ImageIcon icon = new ImageIcon(XMageLauncher.class.getResource("/icon-mage-flashed.png")); frame.setIconImage(icon.getImage()); Random r = new Random(); int imageNum = 1 + r.nextInt(17); ImageIcon background = new ImageIcon(new ImageIcon( XMageLauncher.class.getResource("/backgrounds/" + Integer.toString(imageNum) + ".jpg")).getImage() .getScaledInstance(800, 480, Image.SCALE_SMOOTH)); mainPanel = new JLabel(background) { @Override public Dimension getPreferredSize() { Dimension size = super.getPreferredSize(); Dimension lmPrefSize = getLayout().preferredLayoutSize(this); size.width = Math.max(size.width, lmPrefSize.width); size.height = Math.max(size.height, lmPrefSize.height); return size; } }; mainPanel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { grabPoint = e.getPoint(); mainPanel.getComponentAt(grabPoint); } }); mainPanel.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent e) { // get location of Window int thisX = frame.getLocation().x; int thisY = frame.getLocation().y; // Determine how much the mouse moved since the initial click int xMoved = (thisX + e.getX()) - (thisX + grabPoint.x); int yMoved = (thisY + e.getY()) - (thisY + grabPoint.y); // Move window to this position int X = thisX + xMoved; int Y = thisY + yMoved; frame.setLocation(X, Y); } }); mainPanel.setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.insets = new Insets(10, 10, 10, 10); Font font16 = new Font("Arial", Font.BOLD, 16); Font font12 = new Font("Arial", Font.PLAIN, 12); Font font12b = new Font("Arial", Font.BOLD, 12); mainPanel.add(Box.createRigidArea(new Dimension(250, 50))); ImageIcon logo = new ImageIcon(new ImageIcon(XMageLauncher.class.getResource("/label-xmage.png")).getImage() .getScaledInstance(150, 75, Image.SCALE_SMOOTH)); xmageLogo = new JLabel(logo); constraints.gridx = 3; constraints.gridy = 0; constraints.gridheight = 1; constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.anchor = GridBagConstraints.EAST; mainPanel.add(xmageLogo, constraints); textArea = new JTextArea(5, 40); textArea.setEditable(false); textArea.setForeground(Color.WHITE); textArea.setBackground(Color.BLACK); DefaultCaret caret = (DefaultCaret) textArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); scrollPane = new JScrollPane(textArea); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); constraints.gridx = 2; constraints.gridy = 1; constraints.weightx = 1.0; constraints.weighty = 1.0; constraints.fill = GridBagConstraints.BOTH; mainPanel.add(scrollPane, constraints); labelProgress = new JLabel(messages.getString("progress")); labelProgress.setFont(font12); labelProgress.setForeground(Color.WHITE); constraints.gridy = 2; constraints.weightx = 0.0; constraints.weighty = 0.0; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.WEST; mainPanel.add(labelProgress, constraints); progressBar = new JProgressBar(0, 100); constraints.gridx = 3; constraints.weightx = 1.0; constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(progressBar, constraints); JPanel pnlButtons = new JPanel(); pnlButtons.setLayout(new GridBagLayout()); pnlButtons.setOpaque(false); constraints.gridx = 0; constraints.gridy = 3; constraints.gridheight = GridBagConstraints.REMAINDER; constraints.fill = GridBagConstraints.BOTH; mainPanel.add(pnlButtons, constraints); btnLaunchClient = new JButton(messages.getString("launchClient")); btnLaunchClient.setToolTipText(messages.getString("launchClient.tooltip")); btnLaunchClient.setFont(font16); btnLaunchClient.setForeground(Color.GRAY); btnLaunchClient.setEnabled(false); btnLaunchClient.setPreferredSize(new Dimension(180, 60)); btnLaunchClient.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleClient(); } }); constraints.gridx = GridBagConstraints.RELATIVE; constraints.gridy = 0; constraints.gridwidth = 1; constraints.fill = GridBagConstraints.BOTH; pnlButtons.add(btnLaunchClient, constraints); btnLaunchClientServer = new JButton(messages.getString("launchClientServer")); btnLaunchClientServer.setToolTipText(messages.getString("launchClientServer.tooltip")); btnLaunchClientServer.setFont(font12b); btnLaunchClientServer.setEnabled(false); btnLaunchClientServer.setForeground(Color.GRAY); btnLaunchClientServer.setPreferredSize(new Dimension(80, 40)); btnLaunchClientServer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleServer(); handleClient(); } }); constraints.fill = GridBagConstraints.HORIZONTAL; pnlButtons.add(btnLaunchClientServer, constraints); btnLaunchServer = new JButton(messages.getString("launchServer")); btnLaunchServer.setToolTipText(messages.getString("launchServer.tooltip")); btnLaunchServer.setFont(font12b); btnLaunchServer.setEnabled(false); btnLaunchServer.setForeground(Color.GRAY); btnLaunchServer.setPreferredSize(new Dimension(80, 40)); btnLaunchServer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleServer(); } }); pnlButtons.add(btnLaunchServer, constraints); btnUpdate = new JButton(messages.getString("update.xmage")); btnUpdate.setToolTipText(messages.getString("update.xmage.tooltip")); btnUpdate.setFont(font12b); btnUpdate.setForeground(Color.BLACK); btnUpdate.setPreferredSize(new Dimension(80, 40)); btnUpdate.setEnabled(true); btnUpdate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleUpdate(); } }); pnlButtons.add(btnUpdate, constraints); btnCheck = new JButton(messages.getString("check.xmage")); btnCheck.setToolTipText(messages.getString("check.xmage.tooltip")); btnCheck.setFont(font12b); btnCheck.setForeground(Color.BLACK); btnCheck.setPreferredSize(new Dimension(80, 40)); btnCheck.setEnabled(true); btnCheck.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleCheckUpdates(); } }); pnlButtons.add(btnCheck, constraints); frame.add(mainPanel); frame.pack(); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2); }
From source file:edu.scripps.fl.pubchem.xmltool.gui.GUIComponent.java
public JTextPane createJTextPane(String text) { JTextPane jtp = new JTextPane(); jtp.setText(text);/*from w ww. ja va 2 s . c om*/ SimpleAttributeSet underline = new SimpleAttributeSet(); StyleConstants.setUnderline(underline, true); jtp.getStyledDocument().setCharacterAttributes(0, text.length(), underline, true); jtp.setEditable(false); jtp.setOpaque(false); jtp.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10)); jtp.setBorder(BorderFactory.createEmptyBorder()); jtp.setForeground(Color.blue); jtp.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); return jtp; }
From source file:net.sf.xmm.moviemanager.gui.DialogIMDB.java
JPanel createMoviehitsList() { /* Movies List panel...*/ JPanel panelMoviesList = new JPanel(); panelMoviesList.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localizer.get("DialogIMDB.panel-movie-list.title")), //$NON-NLS-1$ BorderFactory.createEmptyBorder(5, 5, 5, 5))); listMovies = new JList() { public String getToolTipText(MouseEvent e) { if (getCellBounds(0, 0) == null) return null; String retVal = null; int row = (int) e.getPoint().getY() / (int) getCellBounds(0, 0).getHeight(); if (row >= 0 && row < getModel().getSize() && getMoviesList().getModel().getElementAt(row) instanceof ModelIMDbSearchHit) { retVal = ((ModelIMDbSearchHit) getMoviesList().getModel().getElementAt(row)).getAka(); if (retVal != null && retVal.trim().equals("")) //$NON-NLS-1$ retVal = null;/*from w w w. j ava 2s.c om*/ } return retVal; } public JToolTip createToolTip() { JMultiLineToolTip tooltip = new JMultiLineToolTip(); tooltip.setComponent(this); return tooltip; } }; // Unfortunately setting tooltip timeout affects ALL tooltips ToolTipManager ttm = ToolTipManager.sharedInstance(); ttm.registerComponent(listMovies); ttm.setInitialDelay(0); ttm.setReshowDelay(0); listMovies.setFixedCellHeight(18); listMovies.setFont(new Font(listMovies.getFont().getName(), Font.PLAIN, listMovies.getFont().getSize())); listMovies.setLayoutOrientation(JList.VERTICAL); listMovies.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listMovies.setCellRenderer(new MovieHitListCellRenderer()); listMovies.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent event) { // Open we page if (SwingUtilities.isRightMouseButton(event)) { int index = listMovies.locationToIndex(event.getPoint()); if (index >= 0) { ModelIMDbSearchHit hit = (ModelIMDbSearchHit) listMovies.getModel().getElementAt(index); if (hit.getUrlID() != null && !hit.getUrlID().equals("")) { BrowserOpener opener = new BrowserOpener(hit.getCompleteUrl()); opener.executeOpenBrowser(MovieManager.getConfig().getSystemWebBrowser(), MovieManager.getConfig().getBrowserPath()); } } } else if (SwingUtilities.isLeftMouseButton(event) && event.getClickCount() >= 2) { buttonSelect.doClick(); } } }); KeyStroke enterKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true); ActionListener listKeyBoardActionListener = new ActionListener() { public void actionPerformed(ActionEvent ae) { log.debug("ActionPerformed: " + "Movielist - ENTER pressed."); //$NON-NLS-1$ buttonSelect.doClick(); } }; listMovies.registerKeyboardAction(listKeyBoardActionListener, enterKeyStroke, JComponent.WHEN_FOCUSED); JScrollPane scrollPaneMovies = new JScrollPane(listMovies); scrollPaneMovies.setAutoscrolls(true); //scrollPaneMovies.registerKeyboardAction(listKeyBoardActionListener,enterKeyStroke, JComponent.WHEN_FOCUSED); panelMoviesList.setLayout(new BorderLayout()); panelMoviesList.add(scrollPaneMovies, BorderLayout.CENTER); return panelMoviesList; }
From source file:userinterface.graph.Graph.java
/** * Initialises the GraphModel's series and canvas list. Also starts off the * graph update timer (one per chart)./*from w w w. j a v a 2s . c o m*/ * * @param title * Title of the graph. */ public Graph(String title) { super(ChartFactory.createXYLineChart(title, "X", "Y", new XYSeriesCollection(), PlotOrientation.VERTICAL, true, true, false)); graphCache = new HashMap<SeriesKey, LinkedList<XYDataItem>>(); keyToSeries = new HashMap<SeriesKey, XYSeries>(); keyToGraphSeries = new HashMap<SeriesKey, SeriesSettings>(); graphTitle = new MultipleLineStringSetting("title", title, "The main title heading for the chart.", this, false); titleFont = new FontColorSetting("title font", new FontColorPair(new Font("SansSerif", Font.PLAIN, 14), Color.black), "The font for the chart's title", this, false); legendVisible = new BooleanSetting("legend visible?", new Boolean(true), "Should the legend, which displays all of the series headings, be displayed?", this, false); String[] choices = { "Left", "Right", "Bottom", "Top" }; legendPosition = new ChoiceSetting("legend position", choices, choices[RIGHT], "The position of the legend", this, false); legendFont = new FontColorSetting("legend font", new FontColorPair(new Font("SansSerif", Font.PLAIN, 11), Color.black), "The font for the legend", this, false); // Some easy references chart = super.getChart(); plot = chart.getXYPlot(); plot.setBackgroundPaint((Paint) Color.white); seriesCollection = (XYSeriesCollection) plot.getDataset(); xAxisSettings = new AxisSettings("X", true, this); yAxisSettings = new AxisSettings("Y", false, this); xAxisSettings.addObserver(this); yAxisSettings.addObserver(this); displaySettings = new DisplaySettings(this); displaySettings.addObserver(this); seriesList = new SeriesSettingsList(this); // create a regular XY line chart XYItemRenderer r = plot.getRenderer(); // if possible, try to match the old grapher if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); renderer.setAutoPopulateSeriesPaint(true); renderer.setAutoPopulateSeriesShape(true); } plot.setDrawingSupplier(new DefaultDrawingSupplier(SeriesSettings.DEFAULT_PAINTS, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, SeriesSettings.DEFAULT_SHAPES)); super.setPopupMenu(null); /* Make sure the graph resembles its default settings. */ updateGraph(); // schedule a periodic timer for graph updates new java.util.Timer().scheduleAtFixedRate(new GraphUpdateTask(), 0, // start now updateInterval); }
From source file:com.intel.stl.ui.monitor.view.PSNodesDetailsPanel.java
/** * Description:/*ww w . j a va2 s . c o m*/ * * @param name */ protected void initComponent() { setLayout(new BorderLayout(0, 0)); setOpaque(false); setBorder(BorderFactory.createTitledBorder((Border) null)); JPanel titlePanel = new JPanel(new BorderLayout(5, 1)); titlePanel.setOpaque(false); numberLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN); numberLabel.setHorizontalAlignment(JLabel.RIGHT); titlePanel.add(numberLabel, BorderLayout.CENTER); nameLabel = ComponentFactory.getH3Label("", Font.PLAIN); nameLabel.setHorizontalAlignment(JLabel.LEFT); nameLabel.setVerticalAlignment(JLabel.BOTTOM); titlePanel.add(nameLabel, BorderLayout.EAST); add(titlePanel, BorderLayout.NORTH); JPanel mainPanel = new JPanel(); mainPanel.setOpaque(false); mainPanel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); GridBagLayout gridBag = new GridBagLayout(); mainPanel.setLayout(gridBag); GridBagConstraints gc = new GridBagConstraints(); gc.weighty = 0; gc.insets = new Insets(8, 2, 2, 2); gc.weightx = 1; gc.gridwidth = 1; gc.gridheight = 2; // gc.gridheight = 3; // Should change to 3 if we add Route typeChartPanel = new ChartPanel(null); typeChartPanel.setPreferredSize(new Dimension(80, 60)); mainPanel.add(typeChartPanel, gc); gc.fill = GridBagConstraints.BOTH; gc.insets = new Insets(12, 2, 2, 2); gc.weightx = 0; gc.gridheight = 1; swNumberLabel = createNumberLabel(); mainPanel.add(swNumberLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; swNameLabel = createNameLabel(STLConstants.K0048_SWITCHES.getValue()); mainPanel.add(swNameLabel, gc); gc.insets = new Insets(2, 2, 6, 2); gc.gridwidth = 1; fiNumberLabel = createNumberLabel(); mainPanel.add(fiNumberLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; fiNameLabel = createNameLabel(STLConstants.K0052_HOSTS.getValue()); mainPanel.add(fiNameLabel, gc); // gc.gridwidth = 1; // rtNumberLabel = ComponentFactory.getH4Label( // STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN); // rtNumberLabel.setHorizontalAlignment(JLabel.CENTER); // mainPanel.add(rtNumberLabel, gc); // // gc.gridwidth = GridBagConstraints.REMAINDER; // rtNameLabel = ComponentFactory.getH5Label( // STLConstants.K0050_ROUTERS.getValue(), Font.PLAIN); // rtNameLabel.setVerticalAlignment(JLabel.BOTTOM); // mainPanel.add(rtNameLabel, gc); add(mainPanel, BorderLayout.CENTER); JPanel bottomPanel = new JPanel(new GridBagLayout()); bottomPanel.setOpaque(false); bottomPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, UIConstants.INTEL_BORDER_GRAY)); gc = new GridBagConstraints(); gc.insets = new Insets(0, 5, 1, 5); gc.fill = GridBagConstraints.BOTH; gc.weightx = 1; gc.gridheight = 2; otherPortsLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN); otherPortsLabel.setForeground(UIConstants.INTEL_GRAY); otherPortsLabel.setHorizontalAlignment(JLabel.RIGHT); bottomPanel.add(otherPortsLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; gc.gridheight = 1; gc.weightx = 0; gc.weighty = 1; JLabel label = ComponentFactory.getH4Label(STLConstants.K1026_PORT_RESOURCE.getValue(), Font.PLAIN); label.setHorizontalAlignment(JLabel.LEFT); label.setVerticalAlignment(JLabel.BOTTOM); bottomPanel.add(label, gc); gc.weighty = 0; label = ComponentFactory.getH4Label(STLConstants.K2077_NOT_IN_FABRIC.getValue(), Font.PLAIN); label.setHorizontalAlignment(JLabel.LEFT); label.setVerticalAlignment(JLabel.BOTTOM); bottomPanel.add(label, gc); add(bottomPanel, BorderLayout.SOUTH); }