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:ca.sqlpower.wabit.swingui.report.selectors.FancyTextBoxSelectorField.java
public FancyTextBoxSelectorField(final TextBoxSelector selector, Runnable refreshRoutine) { this.selector = selector; this.refreshRoutine = refreshRoutine; this.addFocusListener(focusListener); this.addKeyListener(this.enterKeyListener); this.selector.addSPListener(spListener); setText(selector.getCurrentValue() == null ? null : selector.getCurrentValue().toString()); if (getText().length() == 0 || ObjectUtils.equals(getText(), selector.getDefaultValue())) { setText(selector.getDefaultValue() == null ? null : selector.getDefaultValue().toString()); setForeground(Color.GRAY); setFont(getFont().deriveFont(Font.ITALIC)); } else {//from w w w. j av a 2s. c om setForeground(Color.BLACK); setFont(getFont().deriveFont(Font.PLAIN)); } }
From source file:CheckBoxDemo.java
public CheckBoxDemo() { super(new BorderLayout()); // Create the check boxes. chinButton = new JCheckBox("Chin"); chinButton.setMnemonic(KeyEvent.VK_C); chinButton.setSelected(true);/* w ww . ja v a 2 s. co m*/ 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:net.sf.dynamicreports.test.jasper.chart.AreaChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//from w ww.j a v a2 s .co m JFreeChart chart = getChart("summary.chart1", 0); Axis axis = chart.getCategoryPlot().getDomainAxis(); CategoryPlot categoryPlot = chart.getCategoryPlot(); Assert.assertEquals("renderer", AreaRenderer.class, categoryPlot.getRenderer().getClass()); 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.chart2", 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.StackedAreaChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/*w w w . j a v a2s . c o m*/ JFreeChart chart = getChart("summary.chart1", 0); Axis axis = chart.getCategoryPlot().getDomainAxis(); CategoryPlot categoryPlot = chart.getCategoryPlot(); Assert.assertEquals("renderer", StackedAreaRenderer.class, categoryPlot.getRenderer().getClass()); 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.chart2", 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:com.mxgraph.examples.swing.chart.BarChartDemo1.java
/** * Creates a sample chart./*from w w w. j a va 2 s . c o m*/ * * @param dataset the dataset. * * @return The chart. */ public static JFreeChart createChart(final CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBarChart("", // chart title "X-value", // domain axis label "Y-value", // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation true, // include legend true, false); chart.addSubtitle(new TextTitle("http://www.bupt.edu.cn", new Font("", Font.ITALIC, 10))); // chart.setBackgroundPaint(Color.white); // chart.setBackgroundPaint(Color.getHSBColor(2, 29, 100)); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setBaseItemLabelsVisible(true); // renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setCategoryMargin(0.1);// categoryAxis.setUpperMargin(0.02); categoryAxis.setLowerMargin(0.02); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperMargin(0.10); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); chart.getTitle().setFont(new Font("", Font.PLAIN, 16));// CategoryAxis domainAxis = plot.getDomainAxis(); // domainAxis.setLabelFont(new Font("", Font.PLAIN, 14)); // domainAxis.setTickLabelFont(new Font("", Font.PLAIN, 10)); // rangeAxis.setLabelFont(new Font("", Font.PLAIN, 15)); chart.getLegend().setItemFont(new Font("", Font.PLAIN, 15)); return chart; }
From source file:net.sf.dynamicreports.test.jasper.chart.XyStepChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//from www .j a va 2 s . c om JFreeChart chart = getChart("summary.chart1", 0); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); Assert.assertEquals("renderer", XYStepRenderer.class, renderer.getClass()); Assert.assertEquals("step point", 0.5d, ((XYStepRenderer) renderer).getStepPoint()); 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:org.sbml.bargraph.MainWindow.java
/** * Creates the main application frame./* w ww.ja v a 2 s . co m*/ * * @param file A file to read and graph upon start up. If null, nothing * is graphed initially. */ public MainWindow(File file) { Log.note("Creating main application window."); setPlatformProperties(); setBackground(new Color(255, 255, 255)); setMaximumSize(new Dimension(2000, 1000)); setMinimumSize(new Dimension(600, 400)); setTitle("SBML Bar Graph"); setSize(new Dimension(600, 400)); setPreferredSize(new Dimension(600, 400)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 550, 400); contentPane = new JPanel(); contentPane.setSize(new Dimension(600, 400)); contentPane.setPreferredSize(new Dimension(600, 400)); contentPane.setMinimumSize(new Dimension(600, 400)); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); fileNamePanel = new JPanel(); fileNamePanel.setPreferredSize(new Dimension(590, 20)); fileNamePanel.setMinimumSize(new Dimension(590, 20)); fileNamePanel.setLayout(new BorderLayout(0, 0)); contentPane.add(fileNamePanel, BorderLayout.NORTH); fileNameField = new JTextField(); fileNameField.setHorizontalAlignment(SwingConstants.CENTER); fileNameField.setText("No file selected"); fileNameField.setDisabledTextColor(Color.LIGHT_GRAY); fileNameField.setFont(new Font("Lucida Grande", Font.ITALIC, 11)); fileNameField.setBorder(null); fileNameField.setOpaque(true); fileNameField.setBackground(UIManager.getColor("Separator.foreground")); fileNameField.setEnabled(false); fileNameField.setSize(new Dimension(590, 0)); fileNameField.setPreferredSize(new Dimension(590, 28)); fileNameField.setMinimumSize(new Dimension(590, 28)); fileNameField.setColumns(10); fileNamePanel.add(fileNameField, BorderLayout.CENTER); // The bar graph panel. chartPanel = new ChartPanel(createModelBarGraph(), false); contentPane.add(chartPanel, BorderLayout.CENTER); updatePanelForSBMLFile(file); // Manual additions for File menu. fileMenu = new JMenu(); fileMenu.setText("File"); openFileMenuItem = new JMenuItem(); openFileMenuItem .setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, shortcutKeyMask)); openFileMenuItem.setText("Open..."); openFileMenuItem.setToolTipText("Open file to be graphed"); openFileMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { openFileHandler(evt); } }); fileMenu.add(openFileMenuItem); menuBar = new javax.swing.JMenuBar(); menuBar.add(fileMenu); setJMenuBar(menuBar); // Replace the default Java window icon with our own. // This only has an effect on non-Mac OS systems. URL iconImageURL = getClass().getResource(Config.RES_ICON_APP); Toolkit toolkit = Toolkit.getDefaultToolkit(); Image img = toolkit.createImage(iconImageURL); setIconImage(img); Log.note("Finished constructing panel and menu bar"); }
From source file:org.wings.style.CSSStyleSheet.java
/** * Fetches the font to use for the given set of attributes. *///from w w w . j a v a2 s . co m public static SFont getFont(CSSAttributeSet a) { boolean anyFontAttribute = false; int size = getFontSize(a); anyFontAttribute |= (size > 0); /* * If the vertical alignment is set to either superscirpt or * subscript we reduce the font size by 2 points. */ String vAlign = a.get(CSSProperty.VERTICAL_ALIGN); if (vAlign != null) { if ((vAlign.indexOf("sup") >= 0) || (vAlign.indexOf("sub") >= 0)) { size -= 2; } } String family = a.get(CSSProperty.FONT_FAMILY); anyFontAttribute |= (family != null); int style = Font.PLAIN; String weight = a.get(CSSProperty.FONT_WEIGHT); if (weight == null) ; else if (weight.equals("bold")) { style |= Font.BOLD; } else if (weight.equals("normal")) ; else { try { int w = Integer.parseInt(weight); if (w > 400) style |= Font.BOLD; } catch (NumberFormatException nfe) { } } anyFontAttribute |= (weight != null); String styleValue = a.get(CSSProperty.FONT_STYLE); if ((styleValue != null) && (styleValue.toLowerCase().indexOf("italic") >= 0)) style |= Font.ITALIC; anyFontAttribute |= (styleValue != null); return anyFontAttribute ? new SFont(family, style, size) : null; }
From source file:org.eclipse.wb.tests.designer.swing.model.property.FontPropertyEditorTest.java
/** * Test for {@link ExplicitFontInfo}.// www. ja v a 2s . co m */ public void test_FontInfo_Explicit() throws Exception { // PLAIN { Font font = new Font("Arial", Font.PLAIN, 12); ExplicitFontInfo fontInfo = new ExplicitFontInfo(font); assertSame(font, fontInfo.getFont()); assertEquals("Arial 12", fontInfo.getText()); assertEquals("new java.awt.Font(\"Arial\", java.awt.Font.PLAIN, 12)", fontInfo.getSource()); assertEquals(fontInfo.getSource(), fontInfo.getClipboardSource()); } // BOLD { Font font = new Font("Arial", Font.BOLD, 12); ExplicitFontInfo fontInfo = new ExplicitFontInfo(font); assertSame(font, fontInfo.getFont()); assertEquals("Arial 12 Bold", fontInfo.getText()); assertEquals("new java.awt.Font(\"Arial\", java.awt.Font.BOLD, 12)", fontInfo.getSource()); assertEquals(fontInfo.getSource(), fontInfo.getClipboardSource()); } // ITALIC { Font font = new Font("Arial", Font.ITALIC, 12); ExplicitFontInfo fontInfo = new ExplicitFontInfo(font); assertSame(font, fontInfo.getFont()); assertEquals("Arial 12 Italic", fontInfo.getText()); assertEquals("new java.awt.Font(\"Arial\", java.awt.Font.ITALIC, 12)", fontInfo.getSource()); assertEquals(fontInfo.getSource(), fontInfo.getClipboardSource()); } // BOLD + ITALIC { Font font = new Font("Arial", Font.BOLD | Font.ITALIC, 12); ExplicitFontInfo fontInfo = new ExplicitFontInfo(font); assertSame(font, fontInfo.getFont()); assertEquals("Arial 12 Bold Italic", fontInfo.getText()); assertEquals("new java.awt.Font(\"Arial\", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12)", fontInfo.getSource()); assertEquals(fontInfo.getSource(), fontInfo.getClipboardSource()); } }
From source file:net.chaosserver.timelord.swingui.TaskDayPanel.java
/** * Builds the panel. This uses a GridBag to try and make formatting * grid-like between the unconnected rows. *///from w w w. ja v a 2 s . c o m protected void buildPanel() { GridBagLayout gridBagLayout = new GridBagLayout(); GridBagConstraints gridBagConstraints = new GridBagConstraints(); Insets defaultInsets = gridBagConstraints.insets; setLayout(gridBagLayout); taskName = new JLabel(); if (timelordTask.isHidden()) { Font taskFont = taskName.getFont(); Font italicFont = new Font(taskFont.getName(), Font.ITALIC, taskFont.getSize()); taskName.setFont(italicFont); } updateTaskNameLabel(); gridBagConstraints.anchor = GridBagConstraints.WEST; gridBagConstraints.weightx = LayoutConstants.HEAVY_WEIGHT; gridBagConstraints.insets = new Insets(0, LayoutConstants.SMALL_INSET, 0, LayoutConstants.BIG_INSET); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagLayout.addLayoutComponent(taskName, gridBagConstraints); add(taskName); minusButton = new JButton("-" + DateUtil.getSmallestTimeInMinutes() + "m"); minusButton.setToolTipText("Remove 15 minutes (0.25 hours) " + "of time from this task."); minusButton.setActionCommand(ACTION_MINUS_15); minusButton.addActionListener(this); gridBagConstraints.anchor = GridBagConstraints.CENTER; gridBagConstraints.insets = defaultInsets; gridBagConstraints.fill = GridBagConstraints.NONE; gridBagConstraints.weightx = 0; gridBagLayout.addLayoutComponent(minusButton, gridBagConstraints); add(minusButton); addButton = new JButton("+" + DateUtil.getSmallestTimeInMinutes() + "m"); addButton.setToolTipText("Add 15 minutes (0.25 hours) of " + "time from this task."); addButton.setActionCommand(ACTION_ADD_15); addButton.addActionListener(this); gridBagConstraints.anchor = GridBagConstraints.CENTER; gridBagConstraints.insets = defaultInsets; gridBagConstraints.fill = GridBagConstraints.NONE; gridBagConstraints.weightx = 0; gridBagLayout.addLayoutComponent(addButton, gridBagConstraints); add(addButton); timeLabel = new JLabel(); if (todayTaskDay != null) { timeLabel.setText(DateUtil.formatHours(null, todayTaskDay.getHours())); } else { timeLabel.setText(DateUtil.formatHours(null, 0)); } gridBagConstraints.anchor = GridBagConstraints.EAST; gridBagConstraints.fill = GridBagConstraints.NONE; gridBagConstraints.weightx = 0; gridBagConstraints.insets = new Insets(0, LayoutConstants.BIG_INSET, 0, LayoutConstants.SMALL_INSET); gridBagLayout.addLayoutComponent(timeLabel, gridBagConstraints); add(timeLabel); enabledButtons(); }