本文整理汇总了Java中org.jfree.text.TextUtilities类的典型用法代码示例。如果您正苦于以下问题:Java TextUtilities类的具体用法?Java TextUtilities怎么用?Java TextUtilities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextUtilities类属于org.jfree.text包,在下文中一共展示了TextUtilities类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getPreferredWidth
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* Returns the preferred width of the title. This will only be called when the title
* is being drawn at the left or right of a chart.
*
* @param g2 the graphics device.
* @param height the height.
*
* @return The preferred width of the title.
*/
public float getPreferredWidth(Graphics2D g2, float height) {
float result = 0.0f;
if (this.text != null && !this.text.equals("")) {
g2.setFont(this.font);
TextBlock title = TextUtilities.createTextBlock(
this.text, this.font, this.paint, height, new G2TextMeasurer(g2)
);
Size2D d = title.calculateDimensions(g2);
result = (float) getSpacer().getAdjustedWidth(d.getHeight());
// use height here because the title
// is displayed rotated
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Title preferred width = " + result);
}
return result;
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:TextTitle.java
示例2: getPreferredHeight
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* Returns the preferred height of the title.
*
* @param g2 the graphics device.
* @param width the width.
*
* @return The preferred height of the title.
*/
public float getPreferredHeight(Graphics2D g2, float width) {
float result = 0.0f;
if (this.text != null && !this.text.equals("")) {
g2.setFont(this.font);
float textWidth = (float) getSpacer().trimWidth(width);
TextBlock title = TextUtilities.createTextBlock(
this.text, this.font, this.paint, textWidth, new G2TextMeasurer(g2)
);
Size2D d = title.calculateDimensions(g2);
result = (float) getSpacer().getAdjustedHeight(d.getHeight());
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Title preferred height = " + result);
}
return result;
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:TextTitle.java
示例3: drawNoDataMessage
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* 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);
// FontMetrics fm = g2.getFontMetrics(this.noDataMessageFont);
// Rectangle2D bounds = TextUtilities.getTextBounds(message, g2, fm);
// float x = (float) (area.getX() + area.getWidth() / 2 - bounds.getWidth() / 2);
// float y = (float) (area.getMinY() + (area.getHeight() / 2) - (bounds.getHeight() / 2));
// g2.drawString(message, x, y);
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);
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:31,代码来源:Plot.java
示例4: drawStringInRect
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* A utility method that draws a string inside a rectangle.
*
* @param g2 the graphics device.
* @param bounds the rectangle.
* @param font the font.
* @param text the text.
*/
private void drawStringInRect(Graphics2D g2, Rectangle2D bounds, Font font,
String text) {
g2.setFont(font);
FontMetrics fm = g2.getFontMetrics(font);
Rectangle2D r = TextUtilities.getTextBounds(text, g2, fm);
double x = bounds.getX();
if (r.getWidth() < bounds.getWidth()) {
x = x + (bounds.getWidth() - r.getWidth()) / 2;
}
LineMetrics metrics = font.getLineMetrics(text, g2.getFontRenderContext());
g2.drawString(
text,
(float) x, (float) (bounds.getMaxY() - this.bottomInnerGap - metrics.getDescent())
);
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:MarkerAxisBand.java
示例5: getMaxDim
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* Returns the maximum of the relevant dimension (height or width) of the subcategory labels.
*
* @param g2 the graphics device.
* @param edge the edge.
*
* @return The maximum dimension.
*/
private double getMaxDim(Graphics2D g2, RectangleEdge edge) {
double result = 0.0;
g2.setFont(this.subLabelFont);
FontMetrics fm = g2.getFontMetrics();
Iterator iterator = this.subCategories.iterator();
while (iterator.hasNext()) {
Comparable subcategory = (Comparable) iterator.next();
String label = subcategory.toString();
Rectangle2D bounds = TextUtilities.getTextBounds(label, g2, fm);
double dim = 0.0;
if (RectangleEdge.isLeftOrRight(edge)) {
dim = bounds.getWidth();
}
else { // must be top or bottom
dim = bounds.getHeight();
}
result = Math.max(result, dim);
}
return result;
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:29,代码来源:SubCategoryAxis.java
示例6: drawLegendTitle
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* Draws the legend title.
*
* @param g2 the graphics device (<code>null</code> not permitted).
* @param legendTitle the title (<code>null</code> permitted, in which case the method
* does nothing).
*/
private void drawLegendTitle(Graphics2D g2, DrawableLegendItem legendTitle) {
if (legendTitle != null) {
// XXX dsm - make title bold?
g2.setPaint(legendTitle.getItem().getPaint());
g2.setPaint(this.itemPaint);
g2.setFont(getTitleFont());
TextUtilities.drawAlignedString(
legendTitle.getItem().getLabel(), g2,
(float) legendTitle.getLabelPosition().getX(),
(float) legendTitle.getLabelPosition().getY(), TextAnchor.CENTER_LEFT
);
LOGGER.debug("Title x = " + legendTitle.getLabelPosition().getX());
LOGGER.debug("Title y = " + legendTitle.getLabelPosition().getY());
}
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:23,代码来源:StandardLegend.java
示例7: drawValueLabel
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* Draws the value label just below the center of the dial.
*
* @param g2 the graphics device.
* @param area the plot area.
*/
protected void drawValueLabel(Graphics2D g2, Rectangle2D area) {
g2.setFont(this.valueFont);
g2.setPaint(this.valuePaint);
String valueStr = "No value";
if (this.dataset != null) {
Number n = this.dataset.getValue();
if (n != null) {
valueStr = this.tickLabelFormat.format(n.doubleValue()) + " "
+ this.units;
}
}
float x = (float) area.getCenterX();
float y = (float) area.getCenterY() + DEFAULT_CIRCLE_SIZE;
TextUtilities.drawAlignedString(valueStr, g2, x, y,
TextAnchor.TOP_CENTER);
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:23,代码来源:MeterPlot.java
示例8: drawNoDataMessage
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* 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);
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:23,代码来源:Plot.java
示例9: getLabelEnclosure
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* Returns a rectangle that encloses the axis label. This is typically
* used for layout purposes (it gives the maximum dimensions of the label).
*
* @param g2 the graphics device.
* @param edge the edge of the plot area along which the axis is measuring.
*
* @return The enclosing rectangle.
*/
protected Rectangle2D getLabelEnclosure(Graphics2D g2, RectangleEdge edge) {
Rectangle2D result = new Rectangle2D.Double();
String axisLabel = getLabel();
if (axisLabel != null && !axisLabel.equals("")) {
FontMetrics fm = g2.getFontMetrics(getLabelFont());
Rectangle2D bounds = TextUtilities.getTextBounds(axisLabel, g2, fm);
RectangleInsets insets = getLabelInsets();
bounds = insets.createOutsetRectangle(bounds);
double angle = getLabelAngle();
if (edge == RectangleEdge.LEFT || edge == RectangleEdge.RIGHT) {
angle = angle - Math.PI / 2.0;
}
double x = bounds.getCenterX();
double y = bounds.getCenterY();
AffineTransform transformer
= AffineTransform.getRotateInstance(angle, x, y);
Shape labelBounds = transformer.createTransformedShape(bounds);
result = labelBounds.getBounds2D();
}
return result;
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:34,代码来源:Axis.java
示例10: drawStringInRect
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* A utility method that draws a string inside a rectangle.
*
* @param g2 the graphics device.
* @param bounds the rectangle.
* @param font the font.
* @param text the text.
*/
private void drawStringInRect(Graphics2D g2, Rectangle2D bounds, Font font,
String text) {
g2.setFont(font);
FontMetrics fm = g2.getFontMetrics(font);
Rectangle2D r = TextUtilities.getTextBounds(text, g2, fm);
double x = bounds.getX();
if (r.getWidth() < bounds.getWidth()) {
x = x + (bounds.getWidth() - r.getWidth()) / 2;
}
LineMetrics metrics = font.getLineMetrics(
text, g2.getFontRenderContext()
);
g2.drawString(
text, (float) x, (float) (bounds.getMaxY()
- this.bottomInnerGap - metrics.getDescent())
);
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:MarkerAxisBand.java
示例11: getMaxDim
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* Returns the maximum of the relevant dimension (height or width) of the
* subcategory labels.
*
* @param g2 the graphics device.
* @param edge the edge.
*
* @return The maximum dimension.
*/
private double getMaxDim(Graphics2D g2, RectangleEdge edge) {
double result = 0.0;
g2.setFont(this.subLabelFont);
FontMetrics fm = g2.getFontMetrics();
Iterator iterator = this.subCategories.iterator();
while (iterator.hasNext()) {
Comparable subcategory = (Comparable) iterator.next();
String label = subcategory.toString();
Rectangle2D bounds = TextUtilities.getTextBounds(label, g2, fm);
double dim = 0.0;
if (RectangleEdge.isLeftOrRight(edge)) {
dim = bounds.getWidth();
}
else { // must be top or bottom
dim = bounds.getHeight();
}
result = Math.max(result, dim);
}
return result;
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:SubCategoryAxis.java
示例12: arrangeRR
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* Returns the content size for the title.
*
* @param g2 the graphics device.
* @param widthRange the width range.
* @param heightRange the height range.
*
* @return The content size.
*/
@Override
protected Size2D arrangeRR(Graphics2D g2, Range widthRange,
Range heightRange) {
g2.setFont(getFont());
FontMetrics fm = g2.getFontMetrics(getFont());
Rectangle2D bounds = TextUtilities.getTextBounds(getText(), g2, fm);
if (bounds.getWidth() <= widthRange.getUpperBound()
&& bounds.getHeight() <= heightRange.getUpperBound()) {
return new Size2D(bounds.getWidth(), bounds.getHeight());
}
else {
return new Size2D(0.0, 0.0);
}
}
开发者ID:mdzio,项目名称:ccu-historian,代码行数:25,代码来源:ShortTextTitle.java
示例13: draw
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* Draws the title using the current font and paint.
*
* @param g2 the graphics target.
* @param area the title area.
* @param params optional parameters (ignored here).
*
* @return <code>null</code>.
*/
@Override
public Object draw(Graphics2D g2, Rectangle2D area, Object params) {
if (area.isEmpty()) {
return null;
}
area = trimMargin(area);
drawBorder(g2, area);
area = trimBorder(area);
area = trimPadding(area);
g2.setFont(getFont());
g2.setPaint(getPaint());
TextUtilities.drawAlignedString(getText(), g2, (float) area.getMinX(),
(float) area.getMinY(), TextAnchor.TOP_LEFT);
return null;
}
开发者ID:mdzio,项目名称:ccu-historian,代码行数:25,代码来源:ShortTextTitle.java
示例14: drawAdditionalItemLabel
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* Draws an item label.
*
* @param g2 the graphics device.
* @param orientation the orientation.
* @param dataset the dataset.
* @param series the series index (zero-based).
* @param item the item index (zero-based).
* @param x the x coordinate (in Java2D space).
* @param y the y coordinate (in Java2D space).
*/
private void drawAdditionalItemLabel(Graphics2D g2,
PlotOrientation orientation, XYDataset dataset, int series,
int item, double x, double y) {
if (this.additionalItemLabelGenerator == null) {
return;
}
Font labelFont = getItemLabelFont(series, item);
Paint paint = getItemLabelPaint(series, item);
g2.setFont(labelFont);
g2.setPaint(paint);
String label = this.additionalItemLabelGenerator.generateLabel(dataset,
series, item);
ItemLabelPosition position = getNegativeItemLabelPosition(series, item);
Point2D anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), x, y, orientation);
TextUtilities.drawRotatedString(label, g2,
(float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
}
开发者ID:mdzio,项目名称:ccu-historian,代码行数:35,代码来源:YIntervalRenderer.java
示例15: drawValueLabel
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* Draws the value label just below the center of the dial.
*
* @param g2 the graphics device.
* @param area the plot area.
*/
protected void drawValueLabel(Graphics2D g2, Rectangle2D area) {
g2.setFont(this.valueFont);
g2.setPaint(this.valuePaint);
String valueStr = "No value";
if (this.dataset != null) {
Number n = this.dataset.getValue();
if (n != null) {
valueStr = this.tickLabelFormat.format(n.doubleValue()) + " "
+ this.units;
}
}
float x = (float) area.getCenterX();
float y = (float) area.getCenterY() + DEFAULT_CIRCLE_SIZE;
TextUtilities.drawAlignedString(valueStr, g2, x, y,
TextAnchor.TOP_CENTER);
}
开发者ID:mdzio,项目名称:ccu-historian,代码行数:23,代码来源:MeterPlot.java
示例16: draw
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* Draws the background to the specified graphics device. If the dial
* frame specifies a window, the clipping region will already have been
* set to this window before this method is called.
*
* @param g2 the graphics device (<code>null</code> not permitted).
* @param plot the plot (ignored here).
* @param frame the dial frame (ignored here).
* @param view the view rectangle (<code>null</code> not permitted).
*/
@Override
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
Rectangle2D view) {
// work out the anchor point
Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius,
this.radius);
Arc2D arc = new Arc2D.Double(f, this.angle, 0.0, Arc2D.OPEN);
Point2D pt = arc.getStartPoint();
g2.setPaint(this.paint);
g2.setFont(this.font);
TextUtilities.drawAlignedString(this.label, g2, (float) pt.getX(),
(float) pt.getY(), this.anchor);
}
开发者ID:mdzio,项目名称:ccu-historian,代码行数:26,代码来源:DialTextAnnotation.java
示例17: drawNoDataMessage
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* 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);
}
开发者ID:mdzio,项目名称:ccu-historian,代码行数:23,代码来源:Plot.java
示例18: drawStringInRect
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* A utility method that draws a string inside a rectangle.
*
* @param g2 the graphics device.
* @param bounds the rectangle.
* @param font the font.
* @param text the text.
*/
private void drawStringInRect(Graphics2D g2, Rectangle2D bounds, Font font,
String text) {
g2.setFont(font);
FontMetrics fm = g2.getFontMetrics(font);
Rectangle2D r = TextUtilities.getTextBounds(text, g2, fm);
double x = bounds.getX();
if (r.getWidth() < bounds.getWidth()) {
x = x + (bounds.getWidth() - r.getWidth()) / 2;
}
LineMetrics metrics = font.getLineMetrics(
text, g2.getFontRenderContext()
);
g2.drawString(
text, (float) x, (float) (bounds.getMaxY()
- this.bottomInnerGap - metrics.getDescent())
);
}
开发者ID:mdzio,项目名称:ccu-historian,代码行数:27,代码来源:MarkerAxisBand.java
示例19: getMaxDim
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* Returns the maximum of the relevant dimension (height or width) of the
* subcategory labels.
*
* @param g2 the graphics device.
* @param edge the edge.
*
* @return The maximum dimension.
*/
private double getMaxDim(Graphics2D g2, RectangleEdge edge) {
double result = 0.0;
g2.setFont(this.subLabelFont);
FontMetrics fm = g2.getFontMetrics();
Iterator iterator = this.subCategories.iterator();
while (iterator.hasNext()) {
Comparable subcategory = (Comparable) iterator.next();
String label = subcategory.toString();
Rectangle2D bounds = TextUtilities.getTextBounds(label, g2, fm);
double dim;
if (RectangleEdge.isLeftOrRight(edge)) {
dim = bounds.getWidth();
}
else { // must be top or bottom
dim = bounds.getHeight();
}
result = Math.max(result, dim);
}
return result;
}
开发者ID:mdzio,项目名称:ccu-historian,代码行数:30,代码来源:SubCategoryAxis.java
示例20: paintComponent
import org.jfree.text.TextUtilities; //导入依赖的package包/类
/**
* 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);
}
开发者ID:mdzio,项目名称:ccu-historian,代码行数:27,代码来源:TextBlockPanel.java
注:本文中的org.jfree.text.TextUtilities类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论