java.awt.Font#PLAIN源码实例Demo

下面列出了java.awt.Font#PLAIN 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: MeteoInfo   文件: ChartSet.java
/**
 * 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;
}
 
源代码2 项目: MeteoInfo   文件: ChartLegend.java
/**
 * 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;
}
 
源代码3 项目: openbd-core   文件: ImageDrawText.java
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 );
}
 
源代码4 项目: Course_Generator   文件: FontChooser.java
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();
	}
}
 
源代码5 项目: openjdk-8-source   文件: TitledBorder.java
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);
}
 
源代码6 项目: hottub   文件: DebugFonts.java
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();
}
 
源代码7 项目: jdk8u60   文件: TitledBorder.java
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);
}
 
@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;
        }
    };
}
 
源代码9 项目: buffer_bci   文件: Marker.java
/**
 * 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();
}
 
源代码10 项目: pentaho-reporting   文件: RotatedTextDrawable.java
@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 );
    }
  }
}
 
源代码11 项目: dragonwell8_jdk   文件: DebugFonts.java
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();
}
 
源代码12 项目: openstock   文件: TextTitleTest.java
/**
 * 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));

}
 
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");
         }
    }
}
 
源代码14 项目: openjdk-8-source   文件: FontFamily.java
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;
    }
 
源代码15 项目: openjdk-8-source   文件: AquaFonts.java
@Override
protected FontUIResource getInstance() {
    return new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.PLAIN, 11);
}
 
源代码16 项目: ECG-Viewer   文件: PieChartDemo1.java
/**
 * 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;

}
 
源代码17 项目: Knowage-Server   文件: SBISpeedometer.java
/**
	 * 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;
	}
 
源代码18 项目: jdk8u-jdk   文件: MetaData.java
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)});
}
 
源代码19 项目: buffer_bci   文件: DialTextAnnotationTest.java
/**
 * 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));
}
 
源代码20 项目: jdk8u_jdk   文件: FontFamily.java
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;
        }
    }