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.TimeSeriesChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//ww w . j a v a2 s . c om 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", "time", 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()); Assert.assertTrue("vertical tick labels", ((ValueAxis) axis).isVerticalTickLabels()); 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()); Assert.assertTrue("vertical tick labels", ((ValueAxis) axis).isVerticalTickLabels()); }
From source file:NwFontChooserS.java
private void showSample() { int g = 0;/*www . j a v a 2 s. c om*/ try { g = Integer.parseInt(SizeList.getSelectedValue()); } catch (NumberFormatException nfe) { } String st = StyleList.getSelectedValue(); int s = Font.PLAIN; if (st.equalsIgnoreCase("Bold")) s = Font.BOLD; if (st.equalsIgnoreCase("Italic")) s = Font.ITALIC; Sample.setFont(new Font(FontList.getSelectedValue(), s, g)); Sample.setText("The quick brown fox jumped over the lazy dog."); }
From source file:components.TextSamplerDemo.java
public TextSamplerDemo() { setLayout(new BorderLayout()); //Create a regular text field. JTextField textField = new JTextField(10); textField.setActionCommand(textFieldString); textField.addActionListener(this); //Create a password field. JPasswordField passwordField = new JPasswordField(10); passwordField.setActionCommand(passwordFieldString); passwordField.addActionListener(this); //Create a formatted text field. JFormattedTextField ftf = new JFormattedTextField(java.util.Calendar.getInstance().getTime()); ftf.setActionCommand(textFieldString); ftf.addActionListener(this); //Create some labels for the fields. JLabel textFieldLabel = new JLabel(textFieldString + ": "); textFieldLabel.setLabelFor(textField); JLabel passwordFieldLabel = new JLabel(passwordFieldString + ": "); passwordFieldLabel.setLabelFor(passwordField); JLabel ftfLabel = new JLabel(ftfString + ": "); ftfLabel.setLabelFor(ftf);// w w w. j a v a2 s.com //Create a label to put messages during an action event. actionLabel = new JLabel("Type text in a field and press Enter."); actionLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); //Lay out the text controls and the labels. JPanel textControlsPane = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); textControlsPane.setLayout(gridbag); JLabel[] labels = { textFieldLabel, passwordFieldLabel, ftfLabel }; JTextField[] textFields = { textField, passwordField, ftf }; addLabelTextRows(labels, textFields, gridbag, textControlsPane); c.gridwidth = GridBagConstraints.REMAINDER; //last c.anchor = GridBagConstraints.WEST; c.weightx = 1.0; textControlsPane.add(actionLabel, c); textControlsPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Text Fields"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Create a text area. JTextArea textArea = new JTextArea("This is an editable JTextArea. " + "A text area is a \"plain\" text component, " + "which means that although it can display text " + "in any font, all of the text is in the same font."); textArea.setFont(new Font("Serif", Font.ITALIC, 16)); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); JScrollPane areaScrollPane = new JScrollPane(textArea); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setPreferredSize(new Dimension(250, 250)); areaScrollPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Plain Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5)), areaScrollPane.getBorder())); //Create an editor pane. JEditorPane editorPane = createEditorPane(); JScrollPane editorScrollPane = new JScrollPane(editorPane); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(250, 145)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); //Create a text pane. JTextPane textPane = createTextPane(); JScrollPane paneScrollPane = new JScrollPane(textPane); paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); paneScrollPane.setPreferredSize(new Dimension(250, 155)); paneScrollPane.setMinimumSize(new Dimension(10, 10)); //Put the editor pane and the text pane in a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editorScrollPane, paneScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.5); JPanel rightPane = new JPanel(new GridLayout(1, 0)); rightPane.add(splitPane); rightPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Styled Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Put everything together. JPanel leftPane = new JPanel(new BorderLayout()); leftPane.add(textControlsPane, BorderLayout.PAGE_START); leftPane.add(areaScrollPane, BorderLayout.CENTER); add(leftPane, BorderLayout.LINE_START); add(rightPane, BorderLayout.LINE_END); }
From source file:CalIcon.java
/** Construct the object with a Calendar object */ public CalIcon(Calendar c, boolean showT) { super();//from www. j a v a 2 s .c o m showTime = showT; myCal = c; setLayout(null); // we don't need another layout, ... if (showTime) { // System.err.println("Constructing and adding Clock"); clock = new Clock(); add(clock); clock.setBounds(0, 2, SIZE, 10); // clock.setBackground(Color.black); // clock.setForeground(Color.green); RBY = d.height - (RBH + (showTime ? 12 : 0) / 2); } else { RBY = 6; } RBX = 12; // raised box x offset // System.err.println("RBX, RBY = " + RBX + "," + RBY); dayNumbFont = new Font("Serif", Font.BOLD, 20); dayNumbFM = getFontMetrics(dayNumbFont); dayNameFont = new Font("SansSerif", Font.PLAIN, 10); dayNameFM = getFontMetrics(dayNameFont); monNameFont = new Font("SansSerif", Font.ITALIC, 10); monNameFM = getFontMetrics(monNameFont); }
From source file:net.sf.dynamicreports.test.jasper.chart.BubbleChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/*from w w w . j a va 2 s. c om*/ JFreeChart chart = getChart("summary.chart1", 0); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); Assert.assertEquals("renderer", XYBubbleRenderer.class, renderer.getClass()); Assert.assertEquals("scale type", XYBubbleRenderer.SCALE_ON_BOTH_AXES, ((XYBubbleRenderer) renderer).getScaleType()); xyzChartDataTest(chart, 0, "a", new Number[][] { { 1d, 2d, 0.25 }, { 2d, 3d, 0.5 }, { 3d, 4d, 0.75 }, { 4d, 5d, 1d } }); xyzChartDataTest(chart, 1, "serie1", new Number[][] { { 2d, 1d, 0.25 }, { 3d, 2d, 0.5 }, { 4d, 3d, 0.75 }, { 5d, 4d, 1d } }); 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:com.sec.ose.osi.ui.frm.main.identification.stringmatch.table.JTableInfoForSMFile.java
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);/*from w ww . j a v a2s .c om*/ if (value != null) { if (table.getColumnName(column).equals("Version") || table.getColumnName(column).equals("Pending Hits") || table.getColumnName(column).equals("Status") || table.getColumnName(column).equals("Identified Hits") || table.getColumnName(column).equals("Files")) { setHorizontalAlignment(SwingConstants.CENTER); } else { setHorizontalAlignment(SwingConstants.LEFT); } comp.setToolTipText(String.valueOf(value)); if (table.getValueAt(row, TableModelForSMFile.COL_STATUS) != null && table.getValueAt(row, TableModelForSMFile.COL_STATUS).toString().equals("Identified")) { comp.setFont(new Font("Arial", Font.BOLD | Font.ITALIC, 12)); comp.setForeground(new Color(20, 20, 20)); } else if (table.getValueAt(row, TableModelForSMFile.COL_STATUS).toString().equals("Declared")) { comp.setForeground(new Color(150, 150, 150)); } else { comp.setForeground(new Color(20, 20, 20)); } } else { comp.setToolTipText(null); } return comp; }
From source file:components.ListDialogRunner.java
/** * Finds a cursive font to use, or falls back to using * an italic serif font./*from w ww . j a v a 2 s . co m*/ */ protected static Font getAFont() { //initial strings of desired fonts String[] desiredFonts = { "French Script", "FrenchScript", "Script" }; String[] existingFamilyNames = null; //installed fonts String fontName = null; //font we'll use //Search for all installed font families. The first //call may take a while on some systems with hundreds of //installed fonts, so if possible execute it in idle time, //and certainly not in a place that delays painting of //the UI (for example, when bringing up a menu). // //In systems with malformed fonts, this code might cause //serious problems; use the latest JRE in this case. (You'll //see the same problems if you use Swing's HTML support or //anything else that searches for all fonts.) If this call //causes problems for you under the latest JRE, please let //us know. GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); if (ge != null) { existingFamilyNames = ge.getAvailableFontFamilyNames(); } //See if there's one we like. if ((existingFamilyNames != null) && (desiredFonts != null)) { int i = 0; while ((fontName == null) && (i < desiredFonts.length)) { //Look for a font whose name starts with desiredFonts[i]. int j = 0; while ((fontName == null) && (j < existingFamilyNames.length)) { if (existingFamilyNames[j].startsWith(desiredFonts[i])) { //We've found a match. Test whether it can display //the Latin character 'A'. (You might test for //a different character if you're using a different //language.) Font f = new Font(existingFamilyNames[j], Font.PLAIN, 1); if (f.canDisplay('A')) { fontName = existingFamilyNames[j]; System.out.println("Using font: " + fontName); } } j++; //Look at next existing font name. } i++; //Look for next desired font. } } //Return a valid Font. if (fontName != null) { return new Font(fontName, Font.PLAIN, 36); } else { return new Font("Serif", Font.ITALIC, 36); } }
From source file:net.sf.dynamicreports.test.jasper.chart.GroupedStackedBarChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/*from ww w .j a v a 2s . co m*/ JFreeChart chart = getChart("summary.chart1", 0); CategoryPlot categoryPlot = chart.getCategoryPlot(); Assert.assertEquals("renderer", GroupedStackedBarRenderer.class, categoryPlot.getRenderer().getClass()); Assert.assertTrue("show labels", categoryPlot.getRenderer().getBaseItemLabelsVisible()); Assert.assertFalse("show tick labels", categoryPlot.getDomainAxis().isTickLabelsVisible()); Assert.assertFalse("show tick marks", categoryPlot.getDomainAxis().isTickMarksVisible()); 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.LayeredBarChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/*www . j a v a 2s .c o m*/ JFreeChart chart = getChart("summary.chart1", 0); CategoryPlot categoryPlot = chart.getCategoryPlot(); Assert.assertEquals("renderer", LayeredBarRenderer.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.rapidcontext.app.ui.ControlPanel.java
/** * Initializes the panel UI.//from ww w . j a v a 2s .com */ private void initialize() { Rectangle bounds = new Rectangle(); GridBagConstraints c; JLabel label; Font font; Properties info; String str; // Set system UI looks if (SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_WINDOWS) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ignore) { // Ah well... at least we tried. } } // Set title, menu & layout setDefaultCloseOperation(EXIT_ON_CLOSE); setTitle("RapidContext Server"); setMenuBar(menuBar); initializeMenu(); getContentPane().setLayout(new GridBagLayout()); try { logotype = ImageIO.read(getClass().getResource("logotype.png")); Image img = ImageIO.read(getClass().getResource("logotype-icon-256x256.png")); setIconImage(img); if (SystemUtils.IS_OS_MAC_OSX) { MacApplication.get().setDockIconImage(img); } } catch (Exception ignore) { // Again, we only do our best effort here } // Add logotype c = new GridBagConstraints(); c.gridheight = 5; c.insets = new Insets(6, 15, 10, 10); c.anchor = GridBagConstraints.NORTHWEST; Image small = logotype.getScaledInstance(128, 128, Image.SCALE_SMOOTH); getContentPane().add(new JLabel(new ImageIcon(small)), c); // Add link label c = new GridBagConstraints(); c.gridx = 1; c.insets = new Insets(10, 10, 2, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(new JLabel("Server URL:"), c); serverLink.setText("http://localhost:" + server.port + "/"); serverLink.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { AppUtils.openURL(serverLink.getText()); } catch (Exception e) { error(e.getMessage()); } } }); c = new GridBagConstraints(); c.gridx = 2; c.weightx = 1.0; c.insets = new Insets(10, 0, 2, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(serverLink, c); // Add login info label label = new JLabel("Login as 'admin' on a new server."); font = label.getFont(); font = font.deriveFont(Font.ITALIC, font.getSize() - 2); label.setFont(font); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 1; c.gridwidth = 2; c.insets = new Insets(0, 0, 6, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(label, c); // Add status label c = new GridBagConstraints(); c.gridx = 1; c.gridy = 2; c.insets = new Insets(0, 10, 6, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(new JLabel("Status:"), c); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 2; c.insets = new Insets(0, 0, 6, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(statusLabel, c); // Add version label c = new GridBagConstraints(); c.gridx = 1; c.gridy = 3; c.insets = new Insets(0, 10, 6, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(new JLabel("Version:"), c); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 3; c.insets = new Insets(0, 0, 6, 10); c.anchor = GridBagConstraints.WEST; info = Main.buildInfo(); str = info.getProperty("build.version") + " (built " + info.getProperty("build.date") + ")"; getContentPane().add(new JLabel(str), c); // Add buttons startButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { start(); } }); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 4; c.weighty = 1.0; c.insets = new Insets(0, 10, 10, 10); c.anchor = GridBagConstraints.SOUTH; getContentPane().add(startButton, c); stopButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { stop(); } }); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 4; c.weighty = 1.0; c.insets = new Insets(0, 0, 10, 0); c.anchor = GridBagConstraints.SOUTHWEST; getContentPane().add(stopButton, c); // Set size & position pack(); bounds = this.getBounds(); bounds.width = 470; bounds.x = 100; bounds.y = 100; setBounds(bounds); }