Java Code Examples for org.jfree.text.TextBlock#draw()

The following examples show how to use org.jfree.text.TextBlock#draw() . 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 File: Plot.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws a message to state that there is no data to plot.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 */
protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) {
    Shape savedClip = g2.getClip();
    g2.clip(area);
    String message = this.noDataMessage;
    if (message != null) {
        g2.setFont(this.noDataMessageFont);
        g2.setPaint(this.noDataMessagePaint);
        TextBlock block = TextUtilities.createTextBlock(
                this.noDataMessage, this.noDataMessageFont,
                this.noDataMessagePaint, 0.9f * (float) area.getWidth(),
                new G2TextMeasurer(g2));
        block.draw(g2, (float) area.getCenterX(),
                (float) area.getCenterY(), TextBlockAnchor.CENTER);
    }
    g2.setClip(savedClip);
}
 
Example 2
Source File: Plot.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws a message to state that there is no data to plot.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 */
protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) {
    Shape savedClip = g2.getClip();
    g2.clip(area);
    String message = this.noDataMessage;
    if (message != null) {
        g2.setFont(this.noDataMessageFont);
        g2.setPaint(this.noDataMessagePaint);
        TextBlock block = TextUtilities.createTextBlock(
                this.noDataMessage, this.noDataMessageFont,
                this.noDataMessagePaint, 0.9f * (float) area.getWidth(),
                new G2TextMeasurer(g2));
        block.draw(g2, (float) area.getCenterX(),
                (float) area.getCenterY(), TextBlockAnchor.CENTER);
    }
    g2.setClip(savedClip);
}
 
Example 3
Source File: TextBlockPanel.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Paints the panel.
 *
 * @param g  the graphics device.
 */
public void paintComponent(final Graphics g) {

    super.paintComponent(g);
    final Graphics2D g2 = (Graphics2D) g;

    final Dimension size = getSize();
    final Insets insets = getInsets();
    final Rectangle2D available = new Rectangle2D.Double(insets.left, insets.top,
                                  size.getWidth() - insets.left - insets.right,
                                  size.getHeight() - insets.top - insets.bottom);

    final double x = available.getX();
    final double y = available.getY();
    final float width = (float) available.getWidth();
    final TextBlock block = TextUtilities.createTextBlock(
        this.text, this.font, Color.black, width, new G2TextMeasurer(g2)
    );
    g2.setPaint(Color.black);
    block.draw(g2, (float) x, (float) y, TextBlockAnchor.TOP_LEFT, 0.0f, 0.0f, 0.0);

}
 
Example 4
Source File: Plot.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Draws a message to state that there is no data to plot.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 */
protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) {
    Shape savedClip = g2.getClip();
    g2.clip(area);
    String message = this.noDataMessage;
    if (message != null) {
        g2.setFont(this.noDataMessageFont);
        g2.setPaint(this.noDataMessagePaint);
        TextBlock block = TextUtilities.createTextBlock(
                this.noDataMessage, this.noDataMessageFont,
                this.noDataMessagePaint, 0.9f * (float) area.getWidth(),
                new G2TextMeasurer(g2));
        block.draw(g2, (float) area.getCenterX(),
                (float) area.getCenterY(), TextBlockAnchor.CENTER);
    }
    g2.setClip(savedClip);
}
 
Example 5
Source File: Plot.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Draws a message to state that there is no data to plot.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 */
protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) {
    Shape savedClip = g2.getClip();
    g2.clip(area);
    String message = this.noDataMessage;
    if (message != null) {
        g2.setFont(this.noDataMessageFont);
        g2.setPaint(this.noDataMessagePaint);
        TextBlock block = TextUtilities.createTextBlock(
                this.noDataMessage, this.noDataMessageFont,
                this.noDataMessagePaint, 0.9f * (float) area.getWidth(),
                new G2TextMeasurer(g2));
        block.draw(g2, (float) area.getCenterX(),
                (float) area.getCenterY(), TextBlockAnchor.CENTER);
    }
    g2.setClip(savedClip);
}
 
Example 6
Source File: Plot.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Draws a message to state that there is no data to plot.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 */
protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) {
    Shape savedClip = g2.getClip();
    g2.clip(area);
    String message = this.noDataMessage;
    if (message != null) {
        g2.setFont(this.noDataMessageFont);
        g2.setPaint(this.noDataMessagePaint);
        TextBlock block = TextUtilities.createTextBlock(
                this.noDataMessage, this.noDataMessageFont, 
                this.noDataMessagePaint, 0.9f * (float) area.getWidth(), 
                new G2TextMeasurer(g2));
        block.draw(g2, (float) area.getCenterX(), (float) area.getCenterY(), 
                TextBlockAnchor.CENTER);
    }
    g2.setClip(savedClip);
}
 
Example 7
Source File: Plot.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws a message to state that there is no data to plot.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 */
protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) {
    Shape savedClip = g2.getClip();
    g2.clip(area);
    String message = this.noDataMessage;
    if (message != null) {
        g2.setFont(this.noDataMessageFont);
        g2.setPaint(this.noDataMessagePaint);
        TextBlock block = TextUtilities.createTextBlock(
                this.noDataMessage, this.noDataMessageFont,
                this.noDataMessagePaint, 0.9f * (float) area.getWidth(),
                new G2TextMeasurer(g2));
        block.draw(g2, (float) area.getCenterX(),
                (float) area.getCenterY(), TextBlockAnchor.CENTER);
    }
    g2.setClip(savedClip);
}
 
Example 8
Source File: Plot.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws a message to state that there is no data to plot.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 */
protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) {
    Shape savedClip = g2.getClip();
    g2.clip(area);
    String message = this.noDataMessage;
    if (message != null) {
        g2.setFont(this.noDataMessageFont);
        g2.setPaint(this.noDataMessagePaint);
        TextBlock block = TextUtilities.createTextBlock(
                this.noDataMessage, this.noDataMessageFont,
                this.noDataMessagePaint, 0.9f * (float) area.getWidth(),
                new G2TextMeasurer(g2));
        block.draw(g2, (float) area.getCenterX(),
                (float) area.getCenterY(), TextBlockAnchor.CENTER);
    }
    g2.setClip(savedClip);
}