java.awt.Font Java Examples

The following examples show how to use java.awt.Font. 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: jdk8u60   Author: chenghanpeng   File: Font2D.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected void setStyle() {

        String fName = fullName.toLowerCase();

        for (int i=0; i < boldItalicNames.length; i++) {
            if (fName.indexOf(boldItalicNames[i]) != -1) {
                style = Font.BOLD|Font.ITALIC;
                return;
            }
        }

        for (int i=0; i < italicNames.length; i++) {
            if (fName.indexOf(italicNames[i]) != -1) {
                style = Font.ITALIC;
                return;
            }
        }

        for (int i=0; i < boldNames.length; i++) {
            if (fName.indexOf(boldNames[i]) != -1 ) {
                style = Font.BOLD;
                return;
            }
        }
    }
 
Example #2
Source Project: TencentKona-8   Author: Tencent   File: XOpenTypeViewer.java    License: GNU General Public License v2.0 6 votes vote down vote up
public Component prepareRenderer(TableCellRenderer renderer,
        int row, int column) {
    Component comp = super.prepareRenderer(renderer, row, column);

    if (normalFont == null) {
        normalFont = comp.getFont();
        boldFont = normalFont.deriveFont(Font.BOLD);
    }

    Object o = ((DefaultTableModel) getModel()).getValueAt(row, column);
    if (column == 0) {
        String key = o.toString();
        renderKey(key, comp);
    } else {
        if (isClickableElement(o)) {
            comp.setFont(boldFont);
        } else {
            comp.setFont(normalFont);
        }
    }

    return comp;
}
 
Example #3
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: TextLayout.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs a <code>TextLayout</code> from a <code>String</code>
 * and an attribute set.
 * <p>
 * All the text is styled using the provided attributes.
 * <p>
 * <code>string</code> must specify a single paragraph of text because an
 * entire paragraph is required for the bidirectional algorithm.
 * @param string the text to display
 * @param attributes the attributes used to style the text
 * @param frc contains information about a graphics device which is needed
 *       to measure the text correctly.
 *       Text measurements can vary slightly depending on the
 *       device resolution, and attributes such as antialiasing.  This
 *       parameter does not specify a translation between the
 *       <code>TextLayout</code> and user space.
 */
public TextLayout(String string, Map<? extends Attribute,?> attributes,
                  FontRenderContext frc)
{
    if (string == null) {
        throw new IllegalArgumentException("Null string passed to TextLayout constructor.");
    }

    if (attributes == null) {
        throw new IllegalArgumentException("Null map passed to TextLayout constructor.");
    }

    if (string.length() == 0) {
        throw new IllegalArgumentException("Zero length string passed to TextLayout constructor.");
    }

    char[] text = string.toCharArray();
    Font font = singleFont(text, 0, text.length, attributes);
    if (font != null) {
        fastInit(text, font, attributes, frc);
    } else {
        AttributedString as = new AttributedString(string, attributes);
        standardInit(as.getIterator(), text, frc);
    }
}
 
Example #4
Source Project: seaglass   Author: khuxtable   File: SeaGlassBrowser.java    License: Apache License 2.0 6 votes vote down vote up
static void printFont(PrintWriter html, Font font) {
    String style = "";
    if (font.isBold() && font.isItalic()) {
        style = "Bold & Italic";
    } else if (font.isBold()) {
        style = "Bold";
    } else if (font.isItalic()) {
        style = "Italic";
    }
    html.println("<td>Font: " + font.getFamily() + " " + font.getSize() + " " + style + "</td>");
    int w = 300, h = 30;
    BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = img.createGraphics();
    Composite old = g2.getComposite();
    g2.setComposite(AlphaComposite.Clear);
    g2.fillRect(0, 0, w, h);
    g2.setComposite(old);
    g2.setColor(Color.BLACK);
    g2.setFont(font);
    g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    g2.drawString("The quick brown fox jumps over the lazy dog.", 5, 20);
    g2.dispose();
    html.println("<td>" + saveImage(img) + "</td>");
}
 
Example #5
Source Project: Spark   Author: igniterealtime   File: SparkToaster.java    License: Apache License 2.0 6 votes vote down vote up
public TitleLabel(String text, final boolean showCloseIcon) {
    setLayout(new GridBagLayout());
    label = new JLabel(text);
    label.setFont(new Font("Dialog", Font.BOLD, 11));
    label.setHorizontalTextPosition(JLabel.RIGHT);
    label.setHorizontalAlignment(JLabel.LEFT);

    add(label, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));

closeButton = new RolloverButton(SparkRes.getImageIcon(SparkRes.CLOSE_IMAGE));

if (showCloseIcon) {
	add(closeButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
}

    setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.lightGray));
}
 
Example #6
Source Project: Spark   Author: igniterealtime   File: DialButton.java    License: Apache License 2.0 6 votes vote down vote up
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    int width = getWidth();
    int height = getHeight();

    g.setColor(Color.gray);
    g.setFont(new Font("Tahoma", Font.PLAIN, 10));

    int topTextWidth = g.getFontMetrics().stringWidth(textOnTop);
    int x = (width - topTextWidth) / 2;
    int y = height - 26;
    g.drawString(textOnTop, x, y);

    g.setColor(Color.black);
    g.setFont(new Font("Tahoma", Font.BOLD, 11));
    int numberWidth = g.getFontMetrics().stringWidth(number);
    x = (width - numberWidth) / 2;
    y = height - 13;
    g.drawString(number, x, y);
}
 
Example #7
Source Project: openstock   Author: lcmeyer37   File: MultiplePiePlot.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new plot.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 */
public MultiplePiePlot(CategoryDataset dataset) {
    super();
    setDataset(dataset);
    PiePlot piePlot = new PiePlot(null);
    piePlot.setIgnoreNullValues(true);
    this.pieChart = new JFreeChart(piePlot);
    this.pieChart.removeLegend();
    this.dataExtractOrder = TableOrder.BY_COLUMN;
    this.pieChart.setBackgroundPaint(null);
    TextTitle seriesTitle = new TextTitle("Series Title",
            new Font("SansSerif", Font.BOLD, 12));
    seriesTitle.setPosition(RectangleEdge.BOTTOM);
    this.pieChart.setTitle(seriesTitle);
    this.aggregatedItemsKey = "Other";
    this.aggregatedItemsPaint = Color.lightGray;
    this.sectionPaints = new HashMap();
    this.legendItemShape = new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0);
}
 
Example #8
Source Project: netbeans   Author: apache   File: TimelineHeaderRenderer.java    License: Apache License 2.0 6 votes vote down vote up
private static void initStaticUI(Component c, JTableHeader header) {
    painter = new LabelRenderer(true);
    
    Color color = c.getForeground();
    if (color == null) color = header.getForeground();
    if (color == null) color = UIManager.getColor("TableHeader.foreground"); // NOI18N
    if (color != null) painter.setForeground(color);
    Font font = c.getFont();
    if (font == null) font = header.getFont();
    if (font == null) font = UIManager.getFont("TableHeader.font"); // NOI18N
    if (font != null) painter.setFont(font);
    
    if (UIUtils.isWindowsXPLookAndFeel()) Y_LAF_OFFSET = 1;
    else if (UIUtils.isNimbusLookAndFeel()) Y_LAF_OFFSET = -1;
    else Y_LAF_OFFSET = 0;
}
 
Example #9
Source Project: Spark   Author: igniterealtime   File: NonRosterPanel.java    License: Apache License 2.0 5 votes vote down vote up
public JPanel buildTopPanel() {
    final JLabel avatarLabel = new JLabel(PhoneRes.getImageIcon("LARGE_PHONE_ICON"));

    final JLabel nameLabel = new JLabel();
    nameLabel.setFont(new Font("Arial", Font.BOLD, 19));
    nameLabel.setForeground(new Color(64, 103, 162));
    String remoteName = getActiveCall().getCall().getRemoteName();
    nameLabel.setText(remoteName);

    final JPanel topPanel = new JPanel();
    topPanel.setOpaque(false);
    topPanel.setLayout(new GridBagLayout());

    // Add Connected Label
    connectedLabel = new JLabel(CONNECTED);
    connectedLabel.setFont(new Font("Arial", Font.BOLD, 16));
    connectedLabel.setForeground(greenColor);

    // Add All Items to Top Panel
    topPanel.add(avatarLabel, new GridBagConstraints(0, 0, 1, 2, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    topPanel.add(nameLabel, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    topPanel.add(connectedLabel, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));

    topPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.lightGray));

    return topPanel;
}
 
Example #10
Source Project: hottub   Author: dsrg-uoft   File: PrintLatinCJKTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public int print(Graphics g, PageFormat pf, int pageIndex)
                     throws PrinterException {

    if (pageIndex > 0) {
        return Printable.NO_SUCH_PAGE;
    }
    g.translate((int) pf.getImageableX(), (int) pf.getImageableY());
    g.setFont(new Font("Dialog", Font.PLAIN, 36));
    g.drawString("\u4e00\u4e01\u4e02\u4e03\u4e04English", 20, 100);
    return Printable.PAGE_EXISTS;
}
 
Example #11
Source Project: jdk8u_jdk   Author: JetBrains   File: TextConstructionTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    TCContext tcctx = (TCContext)ctx;
    final Font font = tcctx.font;
    final char[] chars = tcctx.chars1;
    final int start = 1;
    final int limit = chars.length - 1;
    final FontRenderContext frc = tcctx.frc;
    final int flags = tcctx.flags;
    GlyphVector gv;
    do {
        gv = font.layoutGlyphVector(frc, chars, start, limit, flags);
    } while (--numReps >= 0);
}
 
Example #12
Source Project: coming   Author: SpoonLabs   File: Arja_000_t.java    License: MIT License 5 votes vote down vote up
/**
 * Draws an item label.
 *
 * @param g2  the graphics device.
 * @param orientation  the orientation.
 * @param dataset  the dataset.
 * @param row  the row.
 * @param column  the column.
 * @param selected  is the item selected?
 * @param x  the x coordinate (in Java2D space).
 * @param y  the y coordinate (in Java2D space).
 * @param negative  indicates a negative value (which affects the item
 *                  label position).
 *
 * @since 1.2.0
 */
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
        CategoryDataset dataset, int row, int column, boolean selected,
        double x, double y, boolean negative) {

    CategoryItemLabelGenerator generator = getItemLabelGenerator(row,
            column, selected);
    if (generator != null) {
        Font labelFont = getItemLabelFont(row, column, selected);
        Paint paint = getItemLabelPaint(row, column, selected);
        g2.setFont(labelFont);
        g2.setPaint(paint);
        String label = generator.generateLabel(dataset, row, column);
        ItemLabelPosition position = null;
        if (!negative) {
            position = getPositiveItemLabelPosition(row, column, selected);
        }
        else {
            position = getNegativeItemLabelPosition(row, column, selected);
        }
        Point2D anchorPoint = calculateLabelAnchorPoint(
                position.getItemLabelAnchor(), x, y, orientation);
        TextUtilities.drawRotatedString(label, g2,
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(),
                position.getAngle(), position.getRotationAnchor());
    }

}
 
Example #13
Source Project: filthy-rich-clients   Author: romainguy   File: DoneStepPanel.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public DoneStepPanel() {
    setLayout(new GridBagLayout());
    setBackground(Color.BLACK);
    setOpaque(false);
    JLabel label = new JLabel(
            Application.getResourceBundle().getString("step.3.doneTitle"));
    label.setFont(new Font("Helvetica", Font.BOLD, 64)); // NON-NLS
    label.setForeground(Color.WHITE);
    add(label, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
                                      GridBagConstraints.CENTER,
                                      GridBagConstraints.NONE,
                                      new Insets(0, 0, 0, 0), 0, 0));
}
 
Example #14
Source Project: MeteoInfo   Author: meteoinfo   File: JDayChooser.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Sets the font property.
 * 
 * @param font
 *            the new font
 */
public void setFont(Font font) {
	if (days != null) {
		for (int i = 0; i < 49; i++) {
			days[i].setFont(font);
		}
	}
	if (weeks != null) {
		for (int i = 0; i < 7; i++) {
			weeks[i].setFont(font);
		}
	}
}
 
Example #15
Source Project: netbeans   Author: apache   File: IconPanel.java    License: Apache License 2.0 5 votes vote down vote up
public void setFont(Font f) {
    if (comp != null) {
        comp.setFont(f);
    }

    super.setFont(f);
}
 
Example #16
Source Project: netbeans   Author: apache   File: PrependedTextView.java    License: Apache License 2.0 5 votes vote down vote up
public PrependedTextView(DocumentViewOp op, AttributeSet attributes, EditorView delegate) {
    super(null);
    this.attributes = attributes;
    this.delegate = delegate;
    Font font = ViewUtils.getFont(attributes, op.getDefaultHintFont());
    prependedTextLayout = op.createTextLayout((String) attributes.getAttribute(ViewUtils.KEY_VIRTUAL_TEXT_PREPEND), font);
    Rectangle2D textBounds = prependedTextLayout.getBounds(); //TODO: allocation!
    double em = op.getDefaultCharWidth();
    leftShift = em / 2;
    prependedTextWidth = Math.ceil(textBounds.getWidth() + em);
}
 
Example #17
Source Project: amodeus   Author: amodeus-science   File: LinkLayer.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** Draw labels onto graphics object
 *
 * @param map to find closest streets
 * @param graphics Graphics2D object on which the labels are to be drawn */
private void drawLabel(NdMap<Street> map, Graphics2D graphics) {
    final Point point = amodeusComponent.getMapPosition(lastCoord.getLat(), lastCoord.getLon());
    if (Objects.nonNull(point)) {
        Tensor center = Tensors.vector(point.x, point.y);
        NdCluster<Street> cluster = map.buildCluster(NdCenterInterface.euclidean(center), 2);
        graphics.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
        GraphicsUtil.setQualityHigh(graphics);
        for (NdEntry<Street> entry : cluster.collection()) {
            Street street = entry.value();
            double theta = street.angle();
            Point p1 = street.p1;
            Point p2 = street.p2;
            graphics.setColor(Color.RED);
            graphics.drawLine(p1.x, p1.y, p2.x, p2.y);
            graphics.setColor(Color.WHITE);
            graphics.fillRect(p1.x - 1, p1.y - 1, 3, 3);
            graphics.fillRect(p2.x - 1, p2.y - 1, 3, 3);
            AffineTransform saveAT = graphics.getTransform();
            graphics.rotate(theta, p1.x, p1.y);
            graphics.drawString( //
                    "\u2192 " + street.osmLink.link.getId().toString() + " \u2192", //
                    p1.x + 10, p1.y + 10);
            graphics.setTransform(saveAT);
            jTextArea.setText(street.osmLink.link.getId().toString());
        }
        GraphicsUtil.setQualityDefault(graphics);
    }

}
 
Example #18
Source Project: ET_Redux   Author: CIRDLES   File: GeoAgeLabel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param g2d
 */
public void paint(Graphics2D g2d) {
    
    g2d.setFont(new Font(
            "SansSerif",
            Font.PLAIN,
            10));
    
    Rectangle2D level1GeoAge = new Rectangle2D.Double(0, 0, width - 0.1, height - 0.1);
    g2d.draw(level1GeoAge);
    g2d.drawString(label, (float)1, (float)(height - 2));

}
 
Example #19
Source Project: coming   Author: SpoonLabs   File: Arja_0089_t.java    License: MIT License 5 votes vote down vote up
/**
 * Draws an item label.
 *
 * @param g2  the graphics device.
 * @param orientation  the orientation.
 * @param dataset  the dataset.
 * @param row  the row.
 * @param column  the column.
 * @param selected  is the item selected?
 * @param x  the x coordinate (in Java2D space).
 * @param y  the y coordinate (in Java2D space).
 * @param negative  indicates a negative value (which affects the item
 *                  label position).
 *
 * @since 1.2.0
 */
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
        CategoryDataset dataset, int row, int column, boolean selected,
        double x, double y, boolean negative) {

    CategoryItemLabelGenerator generator = getItemLabelGenerator(row,
            column, selected);
    if (generator != null) {
        Font labelFont = getItemLabelFont(row, column, selected);
        Paint paint = getItemLabelPaint(row, column, selected);
        g2.setFont(labelFont);
        g2.setPaint(paint);
        String label = generator.generateLabel(dataset, row, column);
        ItemLabelPosition position = null;
        if (!negative) {
            position = getPositiveItemLabelPosition(row, column, selected);
        }
        else {
            position = getNegativeItemLabelPosition(row, column, selected);
        }
        Point2D anchorPoint = calculateLabelAnchorPoint(
                position.getItemLabelAnchor(), x, y, orientation);
        TextUtilities.drawRotatedString(label, g2,
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(),
                position.getAngle(), position.getRotationAnchor());
    }

}
 
Example #20
Source Project: ghidra   Author: NationalSecurityAgency   File: DiffScreenShots.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testDiffApplySettingsPopup() throws Exception {
	JMenu jMenu = new JMenu();
	Font font = jMenu.getFont().deriveFont(11f);
	TextFormatter tf = new TextFormatter(font, 3, 220, 0, 20, 3);
	TextFormatterContext white = new TextFormatterContext(Color.WHITE);
	tf.colorLines(new Color(60, 115, 200), 2, 1);

	tf.writeln("Set Ignore for All Apply Settings");
	tf.writeln("Set Replace for All Apply Settings");
	tf.writeln("|Set Merge for All Apply Settings|", white);
	image = tf.getImage();
}
 
Example #21
Source Project: Java-MP3-player   Author: mis94   File: PlayerTest.java    License: MIT License 5 votes vote down vote up
void playButton() {
	btnPlay = new OvalButton("►");
	btnPlay.setFont(new Font("Dialog", Font.BOLD, 26));

	btnPlay.setBounds(240, 30, 54, 54);
	btnPlay.setPreferredSize(new Dimension(130, 28));

	btnPlay.addMouseListener(new MouseAdapter() {
		public void mouseClicked(MouseEvent e) {
			Play();
		}
	});
	panel.add(btnPlay);
}
 
Example #22
Source Project: buffer_bci   Author: jadref   File: StandardChartTheme.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new default instance.
 *
 * @param name  the name of the theme (<code>null</code> not permitted).
 * @param shadow  a flag that controls whether a shadow generator is 
 *                included.
 *
 * @since 1.0.14
 */
public StandardChartTheme(String name, boolean shadow) {
    ParamChecks.nullNotPermitted(name, "name");
    this.name = name;
    this.extraLargeFont = new Font("Tahoma", Font.BOLD, 20);
    this.largeFont = new Font("Tahoma", Font.BOLD, 14);
    this.regularFont = new Font("Tahoma", Font.PLAIN, 12);
    this.smallFont = new Font("Tahoma", Font.PLAIN, 10);
    this.titlePaint = Color.black;
    this.subtitlePaint = Color.black;
    this.legendBackgroundPaint = Color.white;
    this.legendItemPaint = Color.darkGray;
    this.chartBackgroundPaint = Color.white;
    this.drawingSupplier = new DefaultDrawingSupplier();
    this.plotBackgroundPaint = Color.lightGray;
    this.plotOutlinePaint = Color.black;
    this.labelLinkPaint = Color.black;
    this.labelLinkStyle = PieLabelLinkStyle.CUBIC_CURVE;
    this.axisOffset = new RectangleInsets(4, 4, 4, 4);
    this.domainGridlinePaint = Color.white;
    this.rangeGridlinePaint = Color.white;
    this.baselinePaint = Color.black;
    this.crosshairPaint = Color.blue;
    this.axisLabelPaint = Color.darkGray;
    this.tickLabelPaint = Color.darkGray;
    this.barPainter = new GradientBarPainter();
    this.xyBarPainter = new GradientXYBarPainter();
    this.shadowVisible = false;
    this.shadowPaint = Color.gray;
    this.itemLabelPaint = Color.black;
    this.thermometerPaint = Color.white;
    this.wallPaint = BarRenderer3D.DEFAULT_WALL_PAINT;
    this.errorIndicatorPaint = Color.black;
    this.shadowGenerator = shadow ? new DefaultShadowGenerator() : null;
}
 
Example #23
Source Project: netbeans   Author: apache   File: JPQLEditorTopComponent.java    License: Apache License 2.0 5 votes vote down vote up
public JPQLEditorTopComponent(JPQLEditorController controller) {
    this.controller = controller;
    initComponents();
    
    // configure row height
    // FIXME there should be a common place to do that
    int height = resultsTable.getRowHeight();
    Font cellFont = UIManager.getFont("TextField.font");
    if (cellFont != null) {
        FontMetrics metrics = resultsTable.getFontMetrics(cellFont);
        if (metrics != null) {
            height = metrics.getHeight() + 2;
        }
    }
    resultsTable.setRowHeight(Math.max(resultsTable.getRowHeight(), height));
    
    puComboBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            puComboboxActionPerformed();
        }
    });

    this.thisWindowCount = getNextWindowCount();
    setName(NbBundle.getMessage(JPQLEditorTopComponent.class, "CTL_JPQLEditorTopComponent") + thisWindowCount);
    setToolTipText(NbBundle.getMessage(JPQLEditorTopComponent.class, "HINT_JPQLEditorTopComponent"));
    setIcon(ImageUtilities.loadImage(ICON_PATH, true));

    sqlToggleButton.setSelected(true);
    jpqlEditor.getDocument().addDocumentListener(new JPQLDocumentListener());
    ((NbEditorDocument) jpqlEditor.getDocument()).runAtomic(new Runnable() {//hack to unlock editor (make modifieble)
        @Override
        public void run() {
        }
    });
    jpqlEditor.addMouseListener(new JPQLEditorPopupMouseAdapter());
    showSQL(NbBundle.getMessage(JPQLEditorTopComponent.class, "BuildHint"));
    resultsTable.setDefaultRenderer(Object.class, new ResultTableCellRenderer());
}
 
Example #24
Source Project: SikuliX1   Author: RaiMan   File: EditorRegionLabel.java    License: MIT License 5 votes vote down vote up
private void init(EditorPane pane, String lblText) {
  editor = pane;
  pyText = lblText;
  setFont(new Font(editor.getFont().getFontName(), Font.PLAIN, editor.getFont().getSize()));
  setBorder(bfinal);
  setCursor(new Cursor(Cursor.HAND_CURSOR));
  addMouseListener(this);
  setText(pyText.replaceAll("Region", "").replaceAll("\\(", "").replaceAll("\\)", ""));
}
 
Example #25
Source Project: wandora   Author: wandora-team   File: TMQLPanel.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates new form TMQLPanel
 */
public TMQLPanel() {
    wandora = Wandora.getWandora();
    initComponents();
    runtimeComboBox.setEditable(false);
    message = new SimpleLabel();
    message.setHorizontalAlignment(SimpleLabel.CENTER);
    message.setIcon(UIBox.getIcon("gui/icons/warn.png"));
    tmqlTextPane.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
    clearResultsButton.setEnabled(false);
    ((TMQLTextPane) tmqlTextPane).setHorizontallyResizeable(false);
    readStoredTmqlQueries();
}
 
Example #26
Source Project: openprodoc   Author: JHierrot   File: MainWin.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 
 * @return
 */
static public Font getFontDialog()
{
if (DialogFont==null)
    EvaluateDef();
return (DialogFont);
}
 
Example #27
Source Project: ccu-historian   Author: mdzio   File: LogAxis.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Estimates the maximum tick label height.
 *
 * @param g2  the graphics device.
 *
 * @return The maximum height.
 *
 * @since 1.0.7
 */
protected double estimateMaximumTickLabelHeight(Graphics2D g2) {
    RectangleInsets tickLabelInsets = getTickLabelInsets();
    double result = tickLabelInsets.getTop() + tickLabelInsets.getBottom();

    Font tickLabelFont = getTickLabelFont();
    FontRenderContext frc = g2.getFontRenderContext();
    result += tickLabelFont.getLineMetrics("123", frc).getHeight();
    return result;
}
 
Example #28
Source Project: jdk8u_jdk   Author: JetBrains   File: Font2D.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * The length of the metrics array must be >= 4.  This method will
 * store the following elements in that array before returning:
 *    metrics[0]: ascent
 *    metrics[1]: descent
 *    metrics[2]: leading
 *    metrics[3]: max advance
 */
public void getFontMetrics(Font font, FontRenderContext frc,
                           float metrics[]) {
    StrikeMetrics strikeMetrics = getStrike(font, frc).getFontMetrics();
    metrics[0] = strikeMetrics.getAscent();
    metrics[1] = strikeMetrics.getDescent();
    metrics[2] = strikeMetrics.getLeading();
    metrics[3] = strikeMetrics.getMaxAdvance();
}
 
Example #29
Source Project: scrimage   Author: sksamuel   File: CaptionFilter.java    License: Apache License 2.0 5 votes vote down vote up
public CaptionFilter(String text, Position position, Font font, Color textColor, double textAlpha, boolean antiAlias, boolean fullWidth, Color captionBackground, double captionAlpha, Padding padding) {
    this.text = text;
    this.position = position;
    this.x = -1;
    this.y = -1;
    this.font = font;
    this.textColor = textColor;
    this.textAlpha = textAlpha;
    this.antiAlias = antiAlias;
    this.fullWidth = fullWidth;
    this.captionBackground = captionBackground;
    this.captionAlpha = captionAlpha;
    this.padding = padding;
}
 
Example #30
Source Project: ramus   Author: Vitaliy-Yakovchuk   File: SelectFontDialog.java    License: GNU General Public License v3.0 5 votes vote down vote up
public Font showModal(final Font font) {
    Options.loadOptions("select_font_dialog", this);
    res = font;
    jFontChooser.setSelFont(font);
    setVisible(true);
    Options.saveOptions("select_font_dialog", this);
    return res;
}