Java Code Examples for java.awt.Font#PLAIN
The following examples show how to use
java.awt.Font#PLAIN .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: MeteoInfo File: ChartSet.java License: GNU Lesser General Public License v3.0 | 6 votes |
/** * Constructor */ public ChartSet() { _chartType = ChartTypes.BarChart; _drawCharts = false; _fieldNames = new ArrayList<>(); _xShift = 0; _yShift = 0; _legendScheme = new LegendScheme(ShapeTypes.Polygon); _maxSize = 50; _minSize = 0; _barWidth = 8; _avoidCollision = true; _alignType = AlignType.Center; _view3D = false; _thickness = 5; drawLabel = false; labelFont = new Font("Arial", Font.PLAIN, 12); labelColor = Color.black; this.decimalDigits = 0; }
Example 2
Source Project: MeteoInfo File: ChartLegend.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * Constructor * * @param ls LegendScheme */ public ChartLegend(LegendScheme ls) { //this.plot = plot; this.legendScheme = ls; this.colorBar = false; this.position = LegendPosition.LOWER_CENTER_OUTSIDE; this.orientation = PlotOrientation.HORIZONTAL; this.shrink = 1.0f; this.aspect = 20; this.background = Color.white; this.drawBackground = false; drawNeatLine = true; neatLineColor = Color.black; neatLineSize = 1; breakSpace = 3; topSpace = 5; leftSpace = 5; _vBarWidth = 10; _hBarHeight = 10; this.labelLocation = "out"; tickLabelFont = new Font("Arial", Font.PLAIN, 14); this.tickLabelColor = Color.black; this.tickLabelAngle = 0; this.symbolDimension = new Dimension(16, 10); this.extendRect = true; this.autoExtendFrac = false; this.xshift = 0; this.yshift = 0; }
Example 3
Source Project: openbd-core File: ImageDrawText.java License: GNU General Public License v3.0 | 5 votes |
private Font getFont(cfData s) throws cfmRunTimeException { if ( s == null ) return null; cfStructData sd = (cfStructData)s; int size = 10; int style = Font.PLAIN; String fontstr = ""; if ( sd.containsKey("size") ){ size = sd.getData("size").getInt(); } if ( sd.containsKey("font") ){ fontstr = sd.getData("font").getString(); } if ( sd.containsKey("style") ){ String st = sd.getData("style").getString().toLowerCase(); if ( st.equals("bold") ){ style = Font.BOLD; }else if ( st.equals("italic") ){ style = Font.ITALIC; }else if ( st.equals("bolditalic") ){ style = Font.BOLD | Font.ITALIC; } } return new Font( fontstr, style, size ); }
Example 4
Source Project: Course_Generator File: FontChooser.java License: GNU General Public License v3.0 | 5 votes |
private void jStyleListValueChanged(javax.swing.event.ListSelectionEvent evt) {// GEN-FIRST:event_jStyleListValueChanged String str = (String) jStyleList.getSelectedValue(); if (str != null) { if (str.equalsIgnoreCase(bundle.getString("FontChooser.Plain"))) // "Plain")) currentStyle = Font.PLAIN; else if (str.equalsIgnoreCase(bundle.getString("FontChooser.Bold"))) // "Bold")) currentStyle = Font.BOLD; else if (str.equalsIgnoreCase(bundle.getString("FontChooser.Italic")))// "Italic")) currentStyle = Font.ITALIC; else if (str.equalsIgnoreCase(bundle.getString("FontChooser.Bold_Italic"))) // "Bold Italic")) currentStyle = Font.BOLD | Font.ITALIC; ; setSampleFont(); } }
Example 5
Source Project: openjdk-8-source File: TitledBorder.java License: GNU General Public License v2.0 | 5 votes |
protected Font getFont(Component c) { Font font = getTitleFont(); if (font != null) { return font; } if (c != null) { font = c.getFont(); if (font != null) { return font; } } return new Font(Font.DIALOG, Font.PLAIN, 12); }
Example 6
Source Project: hottub File: DebugFonts.java License: GNU General Public License v2.0 | 5 votes |
public static void main(String [] args) { System.setProperty("sun.java2d.debugfonts", "true"); Font font = new Font("dialog", Font.PLAIN, 14); System.out.println(font); String s1 = font.getFamily(); String s2 = font.getFontName(); }
Example 7
Source Project: jdk8u60 File: TitledBorder.java License: GNU General Public License v2.0 | 5 votes |
protected Font getFont(Component c) { Font font = getTitleFont(); if (font != null) { return font; } if (c != null) { font = c.getFont(); if (font != null) { return font; } } return new Font(Font.DIALOG, Font.PLAIN, 12); }
Example 8
Source Project: dragonwell8_jdk File: AquaInternalFrameBorderMetrics.java License: GNU General Public License v2.0 | 5 votes |
@Override protected AquaInternalFrameBorderMetrics getInstance() { return new AquaInternalFrameBorderMetrics() { protected void initialize() { font = new Font("Lucida Grande", Font.PLAIN, 13); titleBarHeight = 22; leftSidePadding = 7; buttonHeight = 15; buttonWidth = 15; buttonPadding = 5; downShift = 0; } }; }
Example 9
Source Project: buffer_bci File: Marker.java License: GNU General Public License v3.0 | 5 votes |
/** * Constructs a new marker. * * @param paint the paint ({@code null} not permitted). * @param stroke the stroke ({@code null} not permitted). * @param outlinePaint the outline paint ({@code null} permitted). * @param outlineStroke the outline stroke ({@code null} permitted). * @param alpha the alpha transparency (must be in the range 0.0f to * 1.0f). * * @throws IllegalArgumentException if {@code paint} or * {@code stroke} is {@code null}, or {@code alpha} is * not in the specified range. */ protected Marker(Paint paint, Stroke stroke, Paint outlinePaint, Stroke outlineStroke, float alpha) { ParamChecks.nullNotPermitted(paint, "paint"); ParamChecks.nullNotPermitted(stroke, "stroke"); if (alpha < 0.0f || alpha > 1.0f) { throw new IllegalArgumentException( "The 'alpha' value must be in the range 0.0f to 1.0f"); } this.paint = paint; this.stroke = stroke; this.outlinePaint = outlinePaint; this.outlineStroke = outlineStroke; this.alpha = alpha; this.labelFont = new Font("SansSerif", Font.PLAIN, 9); this.labelPaint = Color.black; this.labelBackgroundColor = new Color(100, 100, 100, 100); this.labelAnchor = RectangleAnchor.TOP_LEFT; this.labelOffset = new RectangleInsets(3.0, 3.0, 3.0, 3.0); this.labelOffsetType = LengthAdjustmentType.CONTRACT; this.labelTextAnchor = TextAnchor.CENTER; this.listenerList = new EventListenerList(); }
Example 10
Source Project: pentaho-reporting File: RotatedTextDrawable.java License: GNU Lesser General Public License v2.1 | 5 votes |
@Override public void setStyleSheet( final StyleSheet style ) { if ( style != null ) { final String fontName = (String) style.getStyleProperty( TextStyleKeys.FONT ); final int fontSize = style.getIntStyleProperty( TextStyleKeys.FONTSIZE, 0 ); final boolean bold = style.getBooleanStyleProperty( TextStyleKeys.BOLD ); final boolean italics = style.getBooleanStyleProperty( TextStyleKeys.ITALIC ); final boolean underlined = style.getBooleanStyleProperty( TextStyleKeys.UNDERLINED ); final boolean strikeThrough = style.getBooleanStyleProperty( TextStyleKeys.STRIKETHROUGH ); final Color foregroundColor = (Color) style.getStyleProperty( ElementStyleKeys.PAINT ); final Color backgroundColor = (Color) style.getStyleProperty( ElementStyleKeys.BACKGROUND_COLOR ); if ( fontName != null && fontSize > 0 ) { int fontstyle = Font.PLAIN; if ( bold ) { fontstyle |= Font.BOLD; } if ( italics ) { fontstyle |= Font.ITALIC; } final Map<TextAttribute, Object> fontAttributes = new HashMap<>(); if ( underlined ) { fontAttributes.put( TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON ); } if ( strikeThrough ) { fontAttributes.put( TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON ); } fontAttributes.put( TextAttribute.FOREGROUND, foregroundColor ); fontAttributes.put( TextAttribute.BACKGROUND, backgroundColor ); this.font = new Font( fontName, fontstyle, fontSize ).deriveFont( fontAttributes ); this.hAlign = (ElementAlignment) style.getStyleProperty( ElementStyleKeys.ALIGNMENT ); this.vAlign = (ElementAlignment) style.getStyleProperty( ElementStyleKeys.VALIGNMENT ); } } }
Example 11
Source Project: dragonwell8_jdk File: DebugFonts.java License: GNU General Public License v2.0 | 5 votes |
public static void main(String [] args) { System.setProperty("sun.java2d.debugfonts", "true"); Font font = new Font("dialog", Font.PLAIN, 14); System.out.println(font); String s1 = font.getFamily(); String s2 = font.getFontName(); }
Example 12
Source Project: openstock File: TextTitleTest.java License: GNU General Public License v3.0 | 4 votes |
/** * Check that the equals() method distinguishes all fields. */ @Test public void testEquals() { TextTitle t1 = new TextTitle(); TextTitle t2 = new TextTitle(); assertEquals(t1, t2); t1.setText("Test 1"); assertFalse(t1.equals(t2)); t2.setText("Test 1"); assertTrue(t1.equals(t2)); Font f = new Font("SansSerif", Font.PLAIN, 15); t1.setFont(f); assertFalse(t1.equals(t2)); t2.setFont(f); assertTrue(t1.equals(t2)); t1.setTextAlignment(HorizontalAlignment.RIGHT); assertFalse(t1.equals(t2)); t2.setTextAlignment(HorizontalAlignment.RIGHT); assertTrue(t1.equals(t2)); // paint t1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(t1.equals(t2)); t2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(t1.equals(t2)); // backgroundPaint t1.setBackgroundPaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f, 1.0f, Color.blue)); assertFalse(t1.equals(t2)); t2.setBackgroundPaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f, 1.0f, Color.blue)); assertTrue(t1.equals(t2)); // maximumLinesToDisplay t1.setMaximumLinesToDisplay(3); assertFalse(t1.equals(t2)); t2.setMaximumLinesToDisplay(3); assertTrue(t1.equals(t2)); // toolTipText t1.setToolTipText("TTT"); assertFalse(t1.equals(t2)); t2.setToolTipText("TTT"); assertTrue(t1.equals(t2)); // urlText t1.setURLText(("URL")); assertFalse(t1.equals(t2)); t2.setURLText(("URL")); assertTrue(t1.equals(t2)); // expandToFitSpace t1.setExpandToFitSpace(!t1.getExpandToFitSpace()); assertFalse(t1.equals(t2)); t2.setExpandToFitSpace(!t2.getExpandToFitSpace()); assertTrue(t1.equals(t2)); }
Example 13
Source Project: jdk8u-jdk File: TestSGEuseAlternateFontforJALocales.java License: GNU General Public License v2.0 | 4 votes |
public static void main(String args[]) throws Exception { System.out.println("Default Charset = " + Charset.defaultCharset().name()); System.out.println("Locale = " + Locale.getDefault()); String os = System.getProperty("os.name"); String encoding = System.getProperty("file.encoding"); /* Want to test the JA locale uses alternate font for DialogInput. */ boolean jaTest = encoding.equalsIgnoreCase("windows-31j"); if (!os.startsWith("Win") && jaTest) { System.out.println("Skipping Windows only test"); return; } String className = "sun.java2d.SunGraphicsEnvironment"; String methodName = "useAlternateFontforJALocales"; Class sge = Class.forName(className); Method uafMethod = sge.getMethod(methodName, (Class[])null); Object ret = uafMethod.invoke(null); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); ge.preferLocaleFonts(); ge.preferProportionalFonts(); if (jaTest) { Font msMincho = new Font("MS Mincho", Font.PLAIN, 12); if (!msMincho.getFamily(Locale.ENGLISH).equals("MS Mincho")) { System.out.println("MS Mincho not installed. Skipping test"); return; } Font dialogInput = new Font("DialogInput", Font.PLAIN, 12); Font courierNew = new Font("Courier New", Font.PLAIN, 12); Font msGothic = new Font("MS Gothic", Font.PLAIN, 12); BufferedImage bi = new BufferedImage(1,1,1); Graphics2D g2d = bi.createGraphics(); FontMetrics cnMetrics = g2d.getFontMetrics(courierNew); FontMetrics diMetrics = g2d.getFontMetrics(dialogInput); FontMetrics mmMetrics = g2d.getFontMetrics(msMincho); FontMetrics mgMetrics = g2d.getFontMetrics(msGothic); // This tests to make sure we at least have applied // "preferLocaleFonts for Japanese if (cnMetrics.charWidth('A') == diMetrics.charWidth('A')) { throw new RuntimeException ("Courier New should not be used for DialogInput"); } // This is supposed to make sure we are using MS Mincho instead // of MS Gothic. However they are metrics identical so its // not definite proof. if (diMetrics.charWidth('A') != mmMetrics.charWidth('A')) { throw new RuntimeException ("MS Mincho should be used for DialogInput"); } } }
Example 14
Source Project: openjdk-8-source File: FontFamily.java License: GNU General Public License v2.0 | 4 votes |
Font2D getClosestStyle(int style) { switch (style) { /* if you ask for a plain font try to return a non-italic one, * then a italic one, finally a bold italic one */ case Font.PLAIN: if (bold != null) { return bold; } else if (italic != null) { return italic; } else { return bolditalic; } /* if you ask for a bold font try to return a non-italic one, * then a bold italic one, finally an italic one */ case Font.BOLD: if (plain != null) { return plain; } else if (bolditalic != null) { return bolditalic; } else { return italic; } /* if you ask for a italic font try to return a bold italic one, * then a plain one, finally an bold one */ case Font.ITALIC: if (bolditalic != null) { return bolditalic; } else if (plain != null) { return plain; } else { return bold; } case Font.BOLD|Font.ITALIC: if (italic != null) { return italic; } else if (bold != null) { return bold; } else { return plain; } } return null; }
Example 15
Source Project: openjdk-8-source File: AquaFonts.java License: GNU General Public License v2.0 | 4 votes |
@Override protected FontUIResource getInstance() { return new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.PLAIN, 11); }
Example 16
Source Project: ECG-Viewer File: PieChartDemo1.java License: GNU General Public License v2.0 | 4 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Smart Phones Manufactured / Q3 2011", // 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(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); // 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; }
Example 17
Source Project: Knowage-Server File: SBISpeedometer.java License: GNU Affero General Public License v3.0 | 4 votes |
/** * Creates a chart of type speedometer. * * @param chartTitle the chart title. * @param dataset the dataset. * * @return A chart speedometer. */ public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); Dataset dataset=(Dataset)datasets.getDatasets().get("1"); DialPlot plot = new DialPlot(); plot.setDataset((ValueDataset)dataset); plot.setDialFrame(new StandardDialFrame()); plot.setBackground(new DialBackground()); if(dialtextuse){ DialTextAnnotation annotation1 = new DialTextAnnotation(dialtext); annotation1.setFont(styleTitle.getFont()); annotation1.setRadius(0.7); plot.addLayer(annotation1); } DialValueIndicator dvi = new DialValueIndicator(0); dvi.setFont(new Font(labelsValueStyle.getFontName(), Font.PLAIN, labelsValueStyle.getSize())); dvi.setPaint(labelsValueStyle.getColor()); plot.addLayer(dvi); StandardDialScale scale = new StandardDialScale(lower, upper, -120, -300, 10.0, 4); if (!( increment > 0)){ logger.warn("increment cannot be less than 0, put default to 0.1"); increment = 0.01; } scale.setMajorTickIncrement(increment); // if (!( minorTickCount > 0)){ // logger.warn("minor tick count cannot be less than 0, put default to 1"); // minorTickCount = 1; // } scale.setMinorTickCount(minorTickCount); scale.setTickRadius(0.88); scale.setTickLabelOffset(0.15); //set tick label style Font tickLabelsFont = new Font(labelsTickStyle.getFontName(), Font.PLAIN, labelsTickStyle.getSize()); scale.setTickLabelFont(tickLabelsFont); scale.setTickLabelPaint(labelsTickStyle.getColor()); plot.addScale(0, scale); plot.addPointer(new DialPointer.Pin()); DialCap cap = new DialCap(); plot.setCap(cap); // sets intervals for (Iterator iterator = intervals.iterator(); iterator.hasNext();) { KpiInterval interval = (KpiInterval) iterator.next(); StandardDialRange range = new StandardDialRange(interval.getMin(), interval.getMax(), interval.getColor()); range.setInnerRadius(0.52); range.setOuterRadius(0.55); plot.addLayer(range); } GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(170, 170, 220)); DialBackground db = new DialBackground(gp); db.setGradientPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.VERTICAL)); plot.setBackground(db); plot.removePointer(0); DialPointer.Pointer p = new DialPointer.Pointer(); p.setFillPaint(Color.yellow); plot.addPointer(p); logger.debug("OUT"); JFreeChart chart=new JFreeChart(name, plot); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if(subName!= null && !subName.equals("")){ TextTitle subTitle =setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } chart.setBackgroundPaint(color); return chart; }
Example 18
Source Project: jdk8u-jdk File: MetaData.java License: GNU General Public License v2.0 | 4 votes |
protected Expression instantiate(Object oldInstance, Encoder out) { Font font = (Font) oldInstance; int count = 0; String family = null; int style = Font.PLAIN; int size = 12; Map<TextAttribute, ?> basic = font.getAttributes(); Map<TextAttribute, Object> clone = new HashMap<>(basic.size()); for (TextAttribute key : basic.keySet()) { Object value = basic.get(key); if (value != null) { clone.put(key, value); } if (key == TextAttribute.FAMILY) { if (value instanceof String) { count++; family = (String) value; } } else if (key == TextAttribute.WEIGHT) { if (TextAttribute.WEIGHT_REGULAR.equals(value)) { count++; } else if (TextAttribute.WEIGHT_BOLD.equals(value)) { count++; style |= Font.BOLD; } } else if (key == TextAttribute.POSTURE) { if (TextAttribute.POSTURE_REGULAR.equals(value)) { count++; } else if (TextAttribute.POSTURE_OBLIQUE.equals(value)) { count++; style |= Font.ITALIC; } } else if (key == TextAttribute.SIZE) { if (value instanceof Number) { Number number = (Number) value; size = number.intValue(); if (size == number.floatValue()) { count++; } } } } Class<?> type = font.getClass(); if (count == clone.size()) { return new Expression(font, type, "new", new Object[]{family, style, size}); } if (type == Font.class) { return new Expression(font, type, "getFont", new Object[]{clone}); } return new Expression(font, type, "new", new Object[]{Font.getFont(clone)}); }
Example 19
Source Project: buffer_bci File: DialTextAnnotationTest.java License: GNU General Public License v3.0 | 4 votes |
/** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { DialTextAnnotation a1 = new DialTextAnnotation("A1"); DialTextAnnotation a2 = new DialTextAnnotation("A1"); assertTrue(a1.equals(a2)); // angle a1.setAngle(1.1); assertFalse(a1.equals(a2)); a2.setAngle(1.1); assertTrue(a1.equals(a2)); // radius a1.setRadius(9.9); assertFalse(a1.equals(a2)); a2.setRadius(9.9); assertTrue(a1.equals(a2)); // font Font f = new Font("SansSerif", Font.PLAIN, 14); a1.setFont(f); assertFalse(a1.equals(a2)); a2.setFont(f); assertTrue(a1.equals(a2)); // paint a1.setPaint(Color.red); assertFalse(a1.equals(a2)); a2.setPaint(Color.red); assertTrue(a1.equals(a2)); // label a1.setLabel("ABC"); assertFalse(a1.equals(a2)); a2.setLabel("ABC"); assertTrue(a1.equals(a2)); // check an inherited attribute a1.setVisible(false); assertFalse(a1.equals(a2)); a2.setVisible(false); assertTrue(a1.equals(a2)); }
Example 20
Source Project: jdk8u_jdk File: FontFamily.java License: GNU General Public License v2.0 | 4 votes |
public Font2D getFont(int style) { switch (style) { case Font.PLAIN: return plain; case Font.BOLD: if (bold != null) { return bold; } else if (plain != null && plain.canDoStyle(style)) { return plain; } else { return null; } case Font.ITALIC: if (italic != null) { return italic; } else if (plain != null && plain.canDoStyle(style)) { return plain; } else { return null; } case Font.BOLD|Font.ITALIC: if (bolditalic != null) { return bolditalic; } else if (bold != null && bold.canDoStyle(style)) { return bold; } else if (italic != null && italic.canDoStyle(style)) { return italic; } else if (plain != null && plain.canDoStyle(style)) { return plain; } else { return null; } default: return null; } }