List of usage examples for java.awt Font ITALIC
int ITALIC
To view the source code for java.awt Font ITALIC.
Click Source Link
From source file:net.sf.dynamicreports.test.jasper.chart.XyBarChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/*from ww w.j a v a 2s.c o m*/ JFreeChart chart = getChart("summary.chart1", 0); XYPlot plot = chart.getXYPlot(); Assert.assertEquals("renderer", XYBarRenderer.class, plot.getRenderer().getClass()); Assert.assertTrue("show labels", plot.getRenderer().getBaseItemLabelsVisible()); //Assert.assertFalse("show tick labels", plot.getDomainAxis().isTickMarksVisible()); //Assert.assertFalse("show tick marks", plot.getDomainAxis().isTickLabelsVisible()); chart = getChart("summary.chart2", 0); Axis axis = chart.getXYPlot().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()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); chart = getChart("summary.chart3", 0); axis = chart.getXYPlot().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:ToolbarDemo.java
protected JMenuBar createMenuBar() { final JMenuBar menuBar = new JMenuBar(); JMenu mFile = new JMenu("File"); mFile.setMnemonic('f'); ImageIcon iconNew = new ImageIcon("file_new.gif"); Action actionNew = new AbstractAction("New", iconNew) { public void actionPerformed(ActionEvent e) { System.out.println("new action"); }//from w ww .j a v a 2 s .c om }; JMenuItem item = mFile.add(actionNew); mFile.add(item); ImageIcon iconOpen = new ImageIcon("file_open.gif"); Action actionOpen = new AbstractAction("Open...", iconOpen) { public void actionPerformed(ActionEvent e) { System.out.println("open action"); } }; item = mFile.add(actionOpen); mFile.add(item); ImageIcon iconSave = new ImageIcon("file_save.gif"); Action actionSave = new AbstractAction("Save...", iconSave) { public void actionPerformed(ActionEvent e) { System.out.println("save action"); } }; item = mFile.add(actionSave); mFile.add(item); mFile.addSeparator(); Action actionExit = new AbstractAction("Exit") { public void actionPerformed(ActionEvent e) { System.exit(0); } }; item = mFile.add(actionExit); item.setMnemonic('x'); menuBar.add(mFile); toolBar = new JToolBar(); JButton btn1 = toolBar.add(actionNew); btn1.setToolTipText("New text"); JButton btn2 = toolBar.add(actionOpen); btn2.setToolTipText("Open text file"); JButton btn3 = toolBar.add(actionSave); btn3.setToolTipText("Save text file"); ActionListener fontListener = new ActionListener() { public void actionPerformed(ActionEvent e) { updateMonitor(); } }; JMenu mFont = new JMenu("Font"); mFont.setMnemonic('o'); ButtonGroup group = new ButtonGroup(); fontMenus = new JMenuItem[FontNames.length]; for (int k = 0; k < FontNames.length; k++) { int m = k + 1; fontMenus[k] = new JRadioButtonMenuItem(m + " " + FontNames[k]); boolean selected = (k == 0); fontMenus[k].setSelected(selected); fontMenus[k].setMnemonic('1' + k); fontMenus[k].setFont(fonts[k]); fontMenus[k].addActionListener(fontListener); group.add(fontMenus[k]); mFont.add(fontMenus[k]); } mFont.addSeparator(); boldMenu.setMnemonic('b'); Font fn = fonts[1].deriveFont(Font.BOLD); boldMenu.setFont(fn); boldMenu.setSelected(false); boldMenu.addActionListener(fontListener); mFont.add(boldMenu); italicMenu.setMnemonic('i'); fn = fonts[1].deriveFont(Font.ITALIC); italicMenu.setFont(fn); italicMenu.setSelected(false); italicMenu.addActionListener(fontListener); mFont.add(italicMenu); menuBar.add(mFont); getContentPane().add(toolBar, BorderLayout.NORTH); return menuBar; }
From source file:net.sf.dynamicreports.test.jasper.chart.XyLineChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/*w w w .j a v a 2s.c o m*/ JFreeChart chart = getChart("summary.chart1", 0); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); Assert.assertEquals("renderer", XYLineAndShapeRenderer.class, renderer.getClass()); Assert.assertFalse("show shapes", ((XYLineAndShapeRenderer) renderer).getBaseShapesVisible()); Assert.assertFalse("show lines", ((XYLineAndShapeRenderer) renderer).getBaseLinesVisible()); chart = getChart("summary.chart2", 0); Axis axis = chart.getXYPlot().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()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); chart = getChart("summary.chart3", 0); axis = chart.getXYPlot().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:com.jcraft.weirdx.DDXFont.java
public Font getFont() { if (font != null) return font; int size = 12; try {/*from w w w. j av a2s.c o m*/ int tmp = Integer.parseInt(getFontSize()); if (tmp != 0) { size = tmp; } } catch (Exception e) { LOG.error(e); } int style = Font.PLAIN; if (getWeight().equals("bold")) style |= Font.BOLD; if (getStyle().equals("i")) style |= Font.ITALIC; if (getFamily().equals("times") || getFamily().equals("times new roman") || getFamily().equals("new century schoolbook")) { font = getFont("Serif", style, size); } else if (getFamily().equals("helvetica") || getFamily().equals("helvetic") || getFamily().equals("courier")) { font = getFont("SansSerif", style, size); } else { font = getFont("Monospaced", style, size); } metric = java.awt.Toolkit.getDefaultToolkit().getFontMetrics(font); String reg = getCharsetRegistry(); String enc = getCharsetEncoding(); for (Font_CharSet foo : XFont.charSets) { if (reg.equals(foo.getCharset()) || enc.equals(foo.getCharset())) { min_byte1 = foo.getMinByte1(); max_byte1 = foo.getMaxByte1(); min_char_or_byte2 = foo.getMinCharOrByte2(); max_char_or_byte2 = foo.getMaxCharOrByte2(); default_char = foo.getDefaultChar(); encoding = foo.getEncoding(); charset = foo; break; } } min_width = getMaxAdvance(); max_width = getMaxAdvance(); if (encoding != null) { int tmp = default_char; int i = 0; while (tmp != 0) { i++; tmp >>= 8; tmp &= 0xffffff; } byte[] btmp = new byte[i]; tmp = default_char; i--; while (tmp != 0) { btmp[i] = (byte) (tmp & 0xff); tmp >>= 8; tmp &= 0xffffff; i--; } char[] ctmp = new char[1]; if (charset != null) charset.encode(btmp, 0, btmp.length, ctmp); max_width = min_width = metric.charWidth(ctmp[0]); if (getSpace().equals("p")) { min_width = 0; } } else { char[] ctmp = new char[1]; ctmp[0] = '@'; max_width = metric.charsWidth(ctmp, 0, 1); ctmp[0] = ' '; min_width = metric.charsWidth(ctmp, 0, 1); } return font; }
From source file:org.kalypso.ogc.sensor.diagview.jfreechart.ObservationChart.java
private TextTitle getTitle(final DiagView template) { final TitleFormat format = template.getTitleFormat(); final int size = format.getFontSize(); final FontWeight weight = format.getFontWeight(); Font font = null;// w w w . j a v a 2 s . c om if (FontWeight.BOLD.equals(weight)) font = new Font(format.getFontFamily(), Font.BOLD, size); else if (FontWeight.NORMAL.equals(weight)) font = new Font(format.getFontFamily(), Font.PLAIN, size); else if (FontWeight.ITALIC.equals(weight)) font = new Font(format.getFontFamily(), Font.ITALIC, size); final Alignment alignment = format.getAlignment(); if (Alignment.CENTER.equals(alignment)) return new TextTitle(template.getTitle(), font, HorizontalAlignment.CENTER); else if (Alignment.LEFT.equals(alignment)) return new TextTitle(template.getTitle(), font, HorizontalAlignment.LEFT); else if (Alignment.RIGHT.equals(alignment)) return new TextTitle(template.getTitle(), font, HorizontalAlignment.RIGHT); return new TextTitle(template.getTitle(), font, HorizontalAlignment.CENTER); }
From source file:SwingCheckBoxDemo.java
public SwingCheckBoxDemo() { super(new BorderLayout()); //Create the check boxes. chinButton = new JCheckBox("Chin"); chinButton.setMnemonic(KeyEvent.VK_C); chinButton.setSelected(true);// ww w . j a v a 2 s. c om glassesButton = new JCheckBox("Glasses"); glassesButton.setMnemonic(KeyEvent.VK_G); glassesButton.setSelected(true); hairButton = new JCheckBox("Hair"); hairButton.setMnemonic(KeyEvent.VK_H); hairButton.setSelected(true); teethButton = new JCheckBox("Teeth"); teethButton.setMnemonic(KeyEvent.VK_T); teethButton.setSelected(true); //Register a listener for the check boxes. chinButton.addItemListener(this); glassesButton.addItemListener(this); hairButton.addItemListener(this); teethButton.addItemListener(this); //Indicates what's on the geek. choices = new StringBuffer("cght"); //Set up the picture label pictureLabel = new JLabel(); pictureLabel.setFont(pictureLabel.getFont().deriveFont(Font.ITALIC)); updatePicture(); /*Put the check boxes in a column in a panel*/ JPanel checkPanel = new JPanel(new GridLayout(0, 1)); checkPanel.add(chinButton); checkPanel.add(glassesButton); checkPanel.add(hairButton); checkPanel.add(teethButton); add(checkPanel, BorderLayout.LINE_START); add(pictureLabel, BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:com.cburch.draw.shapes.SvgReader.java
private static AbstractCanvasObject createText(Element elt) { int x = Integer.parseInt(elt.getAttribute("x")); int y = Integer.parseInt(elt.getAttribute("y")); String text = elt.getTextContent(); Text ret = new Text(x, y, text); String fontFamily = elt.getAttribute("font-family"); String fontStyle = elt.getAttribute("font-style"); String fontWeight = elt.getAttribute("font-weight"); String fontSize = elt.getAttribute("font-size"); int styleFlags = 0; if (fontStyle.equals("italic")) styleFlags |= Font.ITALIC; if (fontWeight.equals("bold")) styleFlags |= Font.BOLD;/*from w ww . j a v a2s . co m*/ int size = Integer.parseInt(fontSize); ret.setValue(DrawAttr.FONT, new Font(fontFamily, styleFlags, size)); String alignStr = elt.getAttribute("text-anchor"); AttributeOption halign; if (alignStr.equals("start")) { halign = DrawAttr.ALIGN_LEFT; } else if (alignStr.equals("end")) { halign = DrawAttr.ALIGN_RIGHT; } else { halign = DrawAttr.ALIGN_CENTER; } ret.setValue(DrawAttr.ALIGNMENT, halign); // fill color is handled after we return return ret; }
From source file:MenuDemo.java
protected JMenuBar createMenuBar() { final JMenuBar menuBar = new JMenuBar(); JMenu menuFile = new JMenu("File"); menuFile.setMnemonic('f'); JMenuItem menuItem = new JMenuItem("New"); menuItem.setIcon(new ImageIcon("file_new.gif")); menuItem.setMnemonic('n'); ActionListener lst = new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("New"); }/*from w w w . j a va 2 s. c om*/ }; menuItem.addActionListener(lst); menuFile.add(menuItem); menuItem = new JMenuItem("Open..."); menuItem.setIcon(new ImageIcon("file_open.gif")); menuItem.setMnemonic('o'); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { MenuDemo.this.repaint(); if (fileChooser.showOpenDialog(MenuDemo.this) != JFileChooser.APPROVE_OPTION) return; System.out.println(fileChooser.getSelectedFile()); } }; menuItem.addActionListener(lst); menuFile.add(menuItem); menuItem = new JMenuItem("Save..."); menuItem.setIcon(new ImageIcon("file_save.gif")); menuItem.setMnemonic('s'); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Save..."); } }; menuItem.addActionListener(lst); menuFile.add(menuItem); menuFile.addSeparator(); menuItem = new JMenuItem("Exit"); menuItem.setMnemonic('x'); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }; menuItem.addActionListener(lst); menuFile.add(menuItem); menuBar.add(menuFile); ActionListener fontListener = new ActionListener() { public void actionPerformed(ActionEvent e) { updateMonitor(); } }; JMenu mFont = new JMenu("Font"); mFont.setMnemonic('o'); ButtonGroup group = new ButtonGroup(); menus = new JMenuItem[FontNames.length]; for (int i = 0; i < FontNames.length; i++) { int m = i + 1; menus[i] = new JRadioButtonMenuItem(m + " " + FontNames[i]); boolean selected = (i == 0); menus[i].setSelected(selected); menus[i].setMnemonic('1' + i); menus[i].setFont(fontArray[i]); menus[i].addActionListener(fontListener); group.add(menus[i]); mFont.add(menus[i]); } mFont.addSeparator(); boldMenuItem = new JCheckBoxMenuItem("Bold"); boldMenuItem.setMnemonic('b'); Font fn = fontArray[1].deriveFont(Font.BOLD); boldMenuItem.setFont(fn); boldMenuItem.setSelected(false); boldMenuItem.addActionListener(fontListener); mFont.add(boldMenuItem); italicMenuItem = new JCheckBoxMenuItem("Italic"); italicMenuItem.setMnemonic('i'); fn = fontArray[1].deriveFont(Font.ITALIC); italicMenuItem.setFont(fn); italicMenuItem.setSelected(false); italicMenuItem.addActionListener(fontListener); mFont.add(italicMenuItem); menuBar.add(mFont); return menuBar; }
From source file:net.sf.dynamicreports.test.jasper.chart.ScatterChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);// w w w .j a v a 2 s. c o m JFreeChart chart = getChart("summary.chart1", 0); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); Assert.assertEquals("renderer", XYLineAndShapeRenderer.class, renderer.getClass()); Assert.assertFalse("show shapes", ((XYLineAndShapeRenderer) renderer).getBaseShapesVisible()); Assert.assertFalse("show lines", ((XYLineAndShapeRenderer) renderer).getBaseLinesVisible()); xyChartDataTest(chart, 0, "Column2", new Number[][] { { 1d, 2d }, { 2d, 3d }, { 3d, 4d }, { 4d, 5d } }); xyChartDataTest(chart, 1, "Column1", new Number[][] { { 2d, 1d }, { 3d, 2d }, { 4d, 3d }, { 5d, 4d } }); chart = getChart("summary.chart2", 0); Axis axis = chart.getXYPlot().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()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); chart = getChart("summary.chart3", 0); axis = chart.getXYPlot().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()); }
From source file:net.sf.dynamicreports.test.jasper.chart.LineChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/*w w w . ja v a 2 s. c om*/ 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()); }