如何在Java中更改附加文本的大小和颜色

时间:2019-02-27 04:18:37

标签: java fonts

我正在处理包含多行附加文本的代码块。有没有简单的方法可以更改字体颜色和大小?我特别想更改诸如sb.append(record.getSegText())之类的附加文本的字体大小?

下面是代码。

    @Override
public String inspect(ReferencedCoordinate coord) throws VizException {
    if (resourceData.hideSampling) {
        return "";
    }
    // check if we are in the last frame
    boolean lastFrame = false;
    FramesInfo framesInfo = this.descriptor.getFramesInfo();

    if (time != null) {
        try {
            Point point = gf.createPoint(coord.asLatLon());

            for (String key : entryMap.keySet()) {

                WarningEntry entry = entryMap.get(key);
                AbstractWarningRecord record = entry.record;
                if (matchesFrame(entry, time, framePeriod, lastFrame)
                        && record.getGeometry() != null) {

                    Geometry recordGeom = record.getGeometry();
                    for (int i = 0; i < recordGeom.getNumGeometries(); i++) {
                        PreparedGeometry prepGeom = pgf.create(recordGeom
                                .getGeometryN(i));

                        if (prepGeom.contains(point)) {
                            StringBuffer sb = new StringBuffer();
                            String[] textToPrint = getText(record, 0);
                            for (String text : textToPrint) {
                                if (sb.length() > 0) {
                                    sb.append(" ");
                                }
                                sb.append("\n\n\n\n\n\n");
                                sb.append(text);
                                sb.append(record.getSegText());
                            }
                            return sb.toString();
                        }
                    }
                }
            }
    }
    return "NO DATA";
}

0 个答案:

没有答案