List of usage examples for java.awt Font BOLD
int BOLD
To view the source code for java.awt Font BOLD.
Click Source Link
From source file:com.sec.ose.osi.ui.frm.main.manage.AddProjectTableModel.java
public void setColumnView(JTable table) { table.setShowVerticalLines(false);/*from w ww . jav a 2s . co m*/ table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setColumnSelectionAllowed(false); table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); table.setRowHeight(30); JTableHeader header = table.getTableHeader(); header.setPreferredSize(new java.awt.Dimension(table.getTableHeader().getWidth(), 30)); header.setFont(new Font("Arial", Font.BOLD, 12)); header.setReorderingAllowed(false); TableColumnModel cm = table.getColumnModel(); TableColumn col = null; searchHeader = new CheckBoxHeader(new CheckboxHeaderItemListener(table, COL_ISSELECT), ""); col = cm.getColumn(COL_ISSELECT); col.setHeaderRenderer(searchHeader); }
From source file:net.sf.dynamicreports.test.jasper.chart.LineChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/*from w ww . j a v a2 s.c o m*/ JFreeChart chart = getChart("summary.chart1", 0); CategoryItemRenderer renderer = chart.getCategoryPlot().getRenderer(); Assert.assertEquals("renderer", LineAndShapeRenderer.class, renderer.getClass()); Assert.assertFalse("show shapes", ((LineAndShapeRenderer) renderer).getBaseShapesVisible()); Assert.assertFalse("show lines", ((LineAndShapeRenderer) renderer).getBaseLinesVisible()); chart = getChart("summary.chart2", 0); Axis axis = chart.getCategoryPlot().getDomainAxis(); Assert.assertEquals("category label", "category", axis.getLabel()); Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions() .getLabelPosition(RectangleEdge.LEFT); Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); chart = getChart("summary.chart3", 0); axis = chart.getCategoryPlot().getRangeAxis(); Assert.assertEquals("value label", "value", axis.getLabel()); Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10)); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound()); Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound()); }
From source file:by.bsu.zmiecer.PieChartDemo1.java
/** * Creates a chart.//from w w w . ja v a 2 s . c om * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart(" ", // chart title dataset, // data false, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart chart.setBackgroundPaint( new GradientPaint(new Point(0, 0), new Color(0, 255, 11), new Point(400, 200), Color.BLUE)); // customise the title position and font TextTitle t = chart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 26)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInteriorGap(0.04); plot.setOutlineVisible(false); // use gradients and white borders for the section colours //plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE)); //plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED)); //plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN)); //plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW)); plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f)); // customise the section label appearance plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); plot.setLabelLinkPaint(Color.WHITE); plot.setLabelLinkStroke(new BasicStroke(2.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.WHITE); plot.setLabelBackgroundPaint(null); /* // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); */ return chart; }
From source file:Citas.FrameCita.java
public FrameCita() throws ClientProtocolException, IOException, JSONException, ParseException, java.text.ParseException { initComponents();/*from w w w.j a v a 2 s . co m*/ this.getContentPane().setLayout(new GridBagLayout()); rutasLeer = new Leer(); rutasAdd = new Add(); medico = new Medico(2, 0, 3, 30); //MEDICO EN SESIOOON citas = new Citas[medico.cantidadDeCitasxDia(10, 30)]; try { font = Font.createFont(Font.TRUETYPE_FONT, new File("Sertig.otf")); font = font.deriveFont(Font.BOLD, 11); } catch (FontFormatException ex) { Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex); } setTitle("Citas"); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.5; gbc.weighty = 0.5; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.BOTH; this.getContentPane().add(PanelCalendar, gbc); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.5; gbc.weighty = 1.0; this.getContentPane().add(PanelCita, gbc); gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 2; gbc.gridheight = 2; gbc.weightx = 1.0; gbc.weighty = 1.0; this.getContentPane().add(PanelDetalle, gbc); ////////////////// PANEL DETALLES //Colores colorBackGround = new Color(hex("8FA8F6"));//Color de los BackGround colorTextFields = new Color(hex("CDCBA6"));//Color de los JTextFields colorDelPapa = new Color(hex("2980b9"));//Color del backgorud del papa colorBotones = new Color(hex("2C3E50"));//Color d elos botonte colorActivo = new Color(hex("81CFE0"));//Color de los jTextFild cuando los activan //Colores //Inicializaciones this.setBackground(colorDelPapa);//Color del backgroud //BOTONES INICIALIZACION modificarB = new JButton("Modificar"); eliminarB = new JButton("Eliminar"); agregarB = new JButton("Agregar"); atrasB = new JButton("Atras"); buscarB = new JButton("Buscar"); Botones = new JPanel(); //PAnel donde van los botones Agregar, Modificar y Eliminar BotonAtras = new JPanel(); //PAnel donde va el boton atras BotonBuscar = new JPanel(); //PAnel donde va el boton buscar agregarB.addActionListener(this); modificarB.addActionListener(this); eliminarB.addActionListener(this); atrasB.addActionListener(this); buscarB.addActionListener(this); // FIN BOTONES INICIALIZACION PanelCita.setLayout(new GridBagLayout()); disenoBotones(modificarB); disenoBotones(eliminarB); disenoBotones(agregarB); disenoBotones(atrasB); disenoBotones(buscarB); PanelDetalle.setLayout(new GridBagLayout()); //Panel Pap (PanelDetalle) cambiarColorPanel(PanelCalendar, colorDelPapa); cambiarColorPanel(PanelCita, colorDelPapa); cambiarColorPanel(PanelDetalle, colorDelPapa); //LABELS horaCitas = new JLabel(); fechaL = new JLabel("<HTML> Fecha  </HTML>"); horaL = new JLabel("<HTML> Hora  </HTML>"); nombreL = new JLabel("<HTML> Nombre     </HTML>"); apellidoL = new JLabel("<HTML> Apellido      </HTML>"); cedulaL = new JLabel("<HTML> Cedula          </HTML>"); direccionL = new JLabel("<HTML> Direccion    </HTML>"); motivosL = new JLabel("<HTML> Motivos        </HTML>"); telefonoCasaL = new JLabel("<HTML> Tlfn Casa  </HTML>"); telefonoCelularL = new JLabel("<HTML> Tlfn Celular</HTML>"); correoL = new JLabel("<HTML> Correo      </HTML>"); font = font = font.deriveFont(Font.BOLD, 11); disenoLabel(horaCitas); disenoLabel(fechaL); disenoLabel(horaL); disenoLabel(nombreL); disenoLabel(apellidoL); disenoLabel(cedulaL); disenoLabel(direccionL); disenoLabel(motivosL); disenoLabel(telefonoCasaL); disenoLabel(telefonoCelularL); disenoLabel(correoL); //JTEXTFIELDS y TEXAREA fechaJ = new JTextField(""); horaJ = new JTextField(""); nombreJ = new JTextField(""); apellidoJ = new JTextField(""); cedulaJ = new JTextField(""); direccionJ = new JTextField(); motivosTA = new JTextArea(""); telefonoCasaJ = new JTextField(""); telefonoCelularJ = new JTextField(""); correoJ = new JTextField(""); //COLORES /*fechaJ.setBackground(colorTextFields); horaJ.setBackground(colorTextFields); nombreJ.setBackground(colorTextFields); apellidoJ.setBackground(colorTextFields); cedulaJ.setBackground(colorTextFields); direccionJ.setBackground(colorTextFields); motivosTA .setBackground(colorTextFields); telefonoCasaJ.setBackground(colorTextFields); telefonoCelularJ.setBackground(colorTextFields); correoJ.setBackground(colorTextFields); */ //Aadir componentes al PanelDetalle GridBagConstraints constraints = new GridBagConstraints(); //Caracteristicas globales del grid constraints.fill = GridBagConstraints.BOTH; constraints.weighty = 1.0; constraints.insets.set(5, 0, 5, 10); //Fin Caracteristicas Globales del grid constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; PanelDetalle.add(fechaL, constraints); constraints.gridx = 1; //Necesita estirarse constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1.0; PanelDetalle.add(fechaJ, constraints); constraints.weightx = 0.0; constraints.gridx = 0; constraints.gridy = 1; constraints.gridwidth = 1; constraints.gridheight = 1; PanelDetalle.add(horaL, constraints); constraints.gridx = 1; //Necesita estirarse constraints.gridy = 1; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1.0; PanelDetalle.add(horaJ, constraints); constraints.weightx = 0.0; constraints.gridx = 0; constraints.gridy = 2; constraints.gridwidth = 1; constraints.gridheight = 1; PanelDetalle.add(nombreL, constraints); constraints.gridx = 1;//Necesita estirarse constraints.gridy = 2; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1.0; PanelDetalle.add(nombreJ, constraints); constraints.weightx = 0.0; constraints.gridx = 0; constraints.gridy = 3; constraints.gridwidth = 1; constraints.gridheight = 1; PanelDetalle.add(apellidoL, constraints); constraints.gridx = 1;//Necesita estirarse constraints.gridy = 3; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1.0; PanelDetalle.add(apellidoJ, constraints); constraints.weightx = 0.0; constraints.gridx = 0; constraints.gridy = 4; constraints.gridwidth = 1; constraints.gridheight = 1; PanelDetalle.add(cedulaL, constraints); constraints.gridx = 1;//Necesita estirarse constraints.gridy = 4; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1.0; PanelDetalle.add(cedulaJ, constraints); constraints.weightx = 0.0; constraints.gridx = 0; constraints.gridy = 5; constraints.gridwidth = 1; constraints.gridheight = 1; PanelDetalle.add(direccionL, constraints); constraints.gridx = 1;//Necesita estirarse constraints.gridy = 5; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1.0; PanelDetalle.add(direccionJ, constraints); constraints.weightx = 0.0; constraints.gridx = 0; constraints.gridy = 6; constraints.gridwidth = 1; constraints.gridheight = 2; constraints.weighty = 1.0; PanelDetalle.add(motivosL, constraints); constraints.gridx = 1;//Necesita estirarse constraints.gridy = 6; constraints.gridwidth = 1; constraints.gridheight = 2; constraints.weightx = 1.0; constraints.weighty = 1.0; PanelDetalle.add(motivosTA, constraints); constraints.weightx = 0.0; constraints.gridx = 0; constraints.gridy = 8; constraints.gridwidth = 1; constraints.gridheight = 1; PanelDetalle.add(telefonoCasaL, constraints); constraints.gridx = 1;//Necesita estirarse constraints.gridy = 8; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1.0; PanelDetalle.add(telefonoCasaJ, constraints); constraints.weightx = 0.0; constraints.gridx = 0; constraints.gridy = 9; constraints.gridwidth = 1; constraints.gridheight = 1; PanelDetalle.add(telefonoCelularL, constraints); constraints.gridx = 1;//Necesita estirarse constraints.gridy = 9; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1.0; PanelDetalle.add(telefonoCelularJ, constraints); constraints.weightx = 0.0; constraints.gridx = 0; constraints.gridy = 10; constraints.gridwidth = 1; constraints.gridheight = 1; PanelDetalle.add(correoL, constraints); constraints.gridx = 1;//Necesita estirarse constraints.gridy = 10; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1.0; PanelDetalle.add(correoJ, constraints); constraints.weightx = 0.0; //PANEL DE LOS BOTONES constraints.insets.set(30, 0, 10, 10); constraints.gridx = 1;//Necesita estirarse constraints.gridy = 11; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0.0; FlowLayout flowLayout1 = new FlowLayout(); Botones.setLayout(flowLayout1); Botones.add(agregarB); Botones.add(modificarB); Botones.add(eliminarB); PanelDetalle.add(Botones, constraints); //Boton Buscar constraints.anchor = GridBagConstraints.NORTH; constraints.insets.set(10, 0, 0, 0); constraints.gridx = 2;//Necesita estirarse constraints.gridy = 4; constraints.gridwidth = 1; constraints.gridheight = 0; constraints.weightx = 0.0; BotonBuscar.setLayout(flowLayout1); BotonBuscar.add(buscarB); BotonBuscar.setBackground(colorBackGround); PanelDetalle.add(BotonBuscar, constraints); constraints.insets.set(30, 0, 10, 10); //BOTON ATRAS constraints.insets.set(30, 0, 10, 10); constraints.gridx = 2;//Necesita estirarse constraints.gridy = 11; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0.0; BotonAtras.setLayout(flowLayout1); BotonAtras.add(atrasB); PanelDetalle.add(BotonAtras, constraints); cambiarColorPanel(Botones, colorDelPapa); cambiarColorPanel(BotonBuscar, colorDelPapa); cambiarColorPanel(BotonAtras, colorDelPapa); PanelDetalle.setVisible(true); //////////////////////ULTIMAS MOTIFICACIONES PRIMER INCREMENTO atrasB.setEnabled(false); buscarB.setEnabled(false); modificarB.setEnabled(false); agregarB.setEnabled(false); eliminarB.setEnabled(false); fechaJ.setEditable(false); horaJ.setEditable(false); nombreJ.setEditable(false); apellidoJ.setEditable(false); cedulaJ.setEditable(false); direccionJ.setEditable(false); motivosTA.setEditable(false); telefonoCasaJ.setEditable(false); telefonoCelularJ.setEditable(false); correoJ.setEditable(false); /////////////////////FIN ULTIMAS MOTIFICACIONES PRIMER INCREMENTO /////////////////Para enero setCitas(); dibujarPanelCita(medico);//Dibuja la "libreta" de las citas /////// fin para ENERO //jCalendar1.getDayChooser().addDateEvaluator(new DJFechasEspInv());//Pinta las Fechas ocupadas en rojo jCalendar1.addPropertyChangeListener("calendar", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { try { try { setCitas(); } catch (ClientProtocolException ex) { Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex); } catch (ParseException ex) { Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex); } catch (java.text.ParseException ex) { Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex); } } catch (IOException ex) { Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex); } catch (JSONException ex) { Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex); } } }); }
From source file:org.jfree.chart.demo.SurveyResultsDemo2.java
/** * Creates a chart./*from w ww. j a v a 2 s . c om*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart(null, // chart title null, // domain axis label null, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, false); chart.setBackgroundPaint(Color.white); chart.getPlot().setOutlinePaint(null); final TextTitle title = new TextTitle("Figure 8.5 - Case studies are available"); title.setHorizontalAlignment(HorizontalAlignment.LEFT); title.setBackgroundPaint(Color.red); title.setPaint(Color.white); chart.setTitle(title); final CategoryPlot plot = chart.getCategoryPlot(); final ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setRange(0.0, 5.0); rangeAxis.setVisible(false); final ExtendedCategoryAxis domainAxis = new ExtendedCategoryAxis(null); domainAxis.setTickLabelFont(new Font("SansSerif", Font.BOLD, 12)); domainAxis.setCategoryMargin(0.30); domainAxis.addSubLabel("Sm.", "(10)"); domainAxis.addSubLabel("Med.", "(10)"); domainAxis.addSubLabel("Lg.", "(10)"); domainAxis.addSubLabel("All", "(10)"); plot.setDomainAxis(domainAxis); final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, new Color(0x9C, 0xA4, 0x4A)); renderer.setBaseOutlineStroke(null); renderer.setItemLabelsVisible(true); renderer.setItemLabelFont(new Font("SansSerif", Font.PLAIN, 18)); final ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.INSIDE12, TextAnchor.TOP_CENTER); renderer.setPositiveItemLabelPosition(position); renderer.setPositiveItemLabelPositionFallback(new ItemLabelPosition()); return chart; }
From source file:org.matsim.counts.algorithms.graphs.BoxPlotErrorGraph.java
@SuppressWarnings("unchecked") @Override/*from w ww . j av a2 s .c o m*/ public JFreeChart createChart(final int nbr) { DefaultBoxAndWhiskerCategoryDataset dataset0 = new DefaultBoxAndWhiskerCategoryDataset(); DefaultBoxAndWhiskerCategoryDataset dataset1 = new DefaultBoxAndWhiskerCategoryDataset(); final ArrayList<Double>[] listRel = new ArrayList[24]; final ArrayList<Double>[] listAbs = new ArrayList[24]; // init for (int i = 0; i < 24; i++) { listRel[i] = new ArrayList<Double>(); listAbs[i] = new ArrayList<Double>(); } // add the values of all counting stations to each hour for (CountSimComparison cc : this.ccl_) { int hour = cc.getHour() - 1; listRel[hour].add(cc.calculateRelativeError()); listAbs[hour].add(cc.getSimulationValue() - cc.getCountValue()); } // add the collected values to the graph / dataset for (int i = 0; i < 24; i++) { dataset0.add(listRel[i], "Rel Error", Integer.toString(i + 1)); dataset1.add(listAbs[i], "Abs Error", Integer.toString(i + 1)); } String title = "Iteration: " + this.iteration_; final CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(); final CategoryAxis xAxis = new CategoryAxis("Hour"); final NumberAxis yAxis0 = new NumberAxis("Signed Rel. Error [%]"); final NumberAxis yAxis1 = new NumberAxis("Signed Abs. Error [veh]"); yAxis0.setAutoRangeIncludesZero(false); yAxis1.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesToolTipGenerator(0, new BoxAndWhiskerToolTipGenerator()); CategoryPlot subplot0 = new CategoryPlot(dataset0, xAxis, yAxis0, renderer); CategoryPlot subplot1 = new CategoryPlot(dataset1, xAxis, yAxis1, renderer); plot.add(subplot0); plot.add(subplot1); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); axis1.setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.setDomainAxis(axis1); this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false); return this.chart_; }
From source file:org.jfree.chart.demo.CombinedXYPlotDemo3.java
/** * Creates a combined XYPlot chart./* www . ja va 2 s . c o m*/ * * @return the combined chart. */ private JFreeChart createCombinedChart() { // create a default chart based on some sample data... final TimeSeriesCollection dataset0 = new TimeSeriesCollection(); final TimeSeries eur = DemoDatasetFactory.createEURTimeSeries(); dataset0.addSeries(eur); final TimeSeriesCollection dataset1 = new TimeSeriesCollection(); final TimeSeries mav = MovingAverage.createMovingAverage(eur, "EUR/GBP (30 Day MA)", 30, 30); dataset1.addSeries(eur); dataset1.addSeries(mav); final TimeSeriesCollection dataset2 = new TimeSeriesCollection(); dataset2.addSeries(eur); JFreeChart chart = null; // make a common vertical axis for all the sub-plots final NumberAxis valueAxis = new NumberAxis("Value"); valueAxis.setAutoRangeIncludesZero(false); // override default // make a horizontally combined plot final CombinedRangeXYPlot parent = new CombinedRangeXYPlot(valueAxis); // add subplot 1... final XYPlot subplot1 = new XYPlot(dataset0, new DateAxis("Date 1"), null, new StandardXYItemRenderer()); parent.add(subplot1, 1); // add subplot 2... final XYPlot subplot2 = new XYPlot(dataset1, new DateAxis("Date 2"), null, new StandardXYItemRenderer()); parent.add(subplot2, 1); // add subplot 3... final XYPlot subplot3 = new XYPlot(dataset2, new DateAxis("Date 3"), null, new XYBarRenderer(0.20)); parent.add(subplot3, 1); // now make the top level JFreeChart chart = new JFreeChart("Demo Chart", JFreeChart.DEFAULT_TITLE_FONT, parent, true); // then customise it a little... final TextTitle subtitle = new TextTitle("This is a subtitle", new Font("SansSerif", Font.BOLD, 12)); chart.addSubtitle(subtitle); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue)); return chart; }
From source file:net.sf.dynamicreports.test.jasper.chart.Bar3DChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/*from w w w.j ava 2 s . co m*/ JFreeChart chart = getChart("summary.chart1", 0); CategoryPlot categoryPlot = chart.getCategoryPlot(); Assert.assertEquals("renderer", BarRenderer3D.class, categoryPlot.getRenderer().getClass()); BarRenderer3D renderer = (BarRenderer3D) categoryPlot.getRenderer(); Assert.assertTrue("show labels", renderer.getBaseItemLabelsVisible()); Assert.assertEquals("x offset", 2d, renderer.getXOffset()); Assert.assertEquals("y offset", 3d, renderer.getYOffset()); chart = getChart("summary.chart2", 0); Axis axis = chart.getCategoryPlot().getDomainAxis(); Assert.assertEquals("category label", "category", axis.getLabel()); Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions() .getLabelPosition(RectangleEdge.LEFT); Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); chart = getChart("summary.chart3", 0); axis = chart.getCategoryPlot().getRangeAxis(); Assert.assertEquals("value label", "value", axis.getLabel()); Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10)); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound()); Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound()); }
From source file:net.sf.dynamicreports.test.jasper.chart.BarChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//from ww w . j av a 2 s . c om JFreeChart chart = getChart("summary.chart1", 0); CategoryPlot categoryPlot = chart.getCategoryPlot(); Assert.assertEquals("renderer", BarRenderer.class, categoryPlot.getRenderer().getClass()); Assert.assertTrue("show labels", categoryPlot.getRenderer().getBaseItemLabelsVisible()); Assert.assertFalse("show tick labels", categoryPlot.getDomainAxis().isTickMarksVisible()); Assert.assertFalse("show tick marks", categoryPlot.getDomainAxis().isTickLabelsVisible()); chart = getChart("summary.chart2", 0); Axis axis = chart.getCategoryPlot().getDomainAxis(); Assert.assertEquals("category label", "category", axis.getLabel()); Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions() .getLabelPosition(RectangleEdge.LEFT); Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); chart = getChart("summary.chart3", 0); axis = chart.getCategoryPlot().getRangeAxis(); Assert.assertEquals("value label", "value", axis.getLabel()); Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10)); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound()); Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound()); }
From source file:org.matsim.counts.algorithms.graphs.BoxPlotNormalizedErrorGraph.java
@SuppressWarnings("unchecked") @Override/*from w w w. j a v a 2s .c o m*/ public JFreeChart createChart(final int nbr) { DefaultBoxAndWhiskerCategoryDataset dataset0 = new DefaultBoxAndWhiskerCategoryDataset(); DefaultBoxAndWhiskerCategoryDataset dataset1 = new DefaultBoxAndWhiskerCategoryDataset(); final ArrayList<Double>[] listRel = new ArrayList[24]; final ArrayList<Double>[] listAbs = new ArrayList[24]; // init for (int i = 0; i < 24; i++) { listRel[i] = new ArrayList<Double>(); listAbs[i] = new ArrayList<Double>(); } // add the values of all counting stations to each hour for (CountSimComparison cc : this.ccl_) { int hour = cc.getHour() - 1; listRel[hour].add(cc.calculateNormalizedRelativeError() * 100); listAbs[hour].add(cc.getSimulationValue() - cc.getCountValue()); } // add the collected values to the graph / dataset for (int i = 0; i < 24; i++) { dataset0.add(listRel[i], "Rel Norm Error", Integer.toString(i + 1)); dataset1.add(listAbs[i], "Abs Error", Integer.toString(i + 1)); } String title = "Iteration: " + this.iteration_; final CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(); final CategoryAxis xAxis = new CategoryAxis("Hour"); final NumberAxis yAxis0 = new NumberAxis("Norm. Rel. Error [%]"); final NumberAxis yAxis1 = new NumberAxis("Signed Abs. Error [veh]"); yAxis0.setAutoRangeIncludesZero(false); yAxis1.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesToolTipGenerator(0, new BoxAndWhiskerToolTipGenerator()); CategoryPlot subplot0 = new CategoryPlot(dataset0, xAxis, yAxis0, renderer); CategoryPlot subplot1 = new CategoryPlot(dataset1, xAxis, yAxis1, renderer); plot.add(subplot0); plot.add(subplot1); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); axis1.setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.setDomainAxis(axis1); this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false); return this.chart_; }