本文整理汇总了Java中org.jfree.ui.Size2D类的典型用法代码示例。如果您正苦于以下问题:Java Size2D类的具体用法?Java Size2D怎么用?Java Size2D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Size2D类属于org.jfree.ui包,在下文中一共展示了Size2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPreferredWidth
import org.jfree.ui.Size2D; //导入依赖的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;
}
示例2: getPreferredHeight
import org.jfree.ui.Size2D; //导入依赖的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;
}
示例3: arrange
import org.jfree.ui.Size2D; //导入依赖的package包/类
/**
* Arranges the contents of the block, within the given constraints, and
* returns the block size.
*
* @param g2 the graphics device.
* @param constraint the constraint (<code>null</code> not permitted).
*
* @return The block size (in Java2D units, never <code>null</code>).
*/
public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) {
Size2D result = new Size2D();
fetchLegendItems();
if (this.items.isEmpty()) {
return result;
}
BlockContainer container = this.wrapper;
if (container == null) {
container = this.items;
}
RectangleConstraint c = toContentConstraint(constraint);
Size2D size = container.arrange(g2, c);
result.height = calculateTotalHeight(size.height);
result.width = calculateTotalWidth(size.width);
return result;
}
示例4: arrangeRR
import org.jfree.ui.Size2D; //导入依赖的package包/类
protected Size2D arrangeRR(BlockContainer container, Graphics2D g2,
RectangleConstraint constraint) {
// first arrange without constraints, and see if this fits within
// the required ranges...
Size2D s1 = arrangeNN(container, g2);
if (constraint.getHeightRange().contains(s1.height)) {
return s1; // TODO: we didn't check the width yet
}
else {
RectangleConstraint c = constraint.toFixedHeight(
constraint.getHeightRange().getUpperBound()
);
return arrangeRF(container, g2, c);
}
}
示例5: arrangeRR
import org.jfree.ui.Size2D; //导入依赖的package包/类
/**
* Arranges the blocks with the overall width and height to fit within
* specified ranges.
*
* @param container the container.
* @param g2 the graphics device.
* @param constraint the constraint.
*
* @return The size after the arrangement.
*/
protected Size2D arrangeRR(BlockContainer container, Graphics2D g2,
RectangleConstraint constraint) {
// first arrange without constraints, and see if this fits within
// the required ranges...
Size2D s1 = arrangeNN(container, g2);
if (constraint.getWidthRange().contains(s1.width)) {
return s1; // TODO: we didn't check the height yet
}
else {
RectangleConstraint c = constraint.toFixedWidth(
constraint.getWidthRange().getUpperBound());
return arrangeFR(container, g2, c);
}
}
示例6: arrangeFF
import org.jfree.ui.Size2D; //导入依赖的package包/类
/**
* Arranges the container with a fixed overall width and height.
*
* @param container the container.
* @param g2 the graphics device.
* @param constraint the constraint.
*
* @return The size following the arrangement.
*/
protected Size2D arrangeFF(BlockContainer container, Graphics2D g2,
RectangleConstraint constraint) {
double width = constraint.getWidth() / this.columns;
double height = constraint.getHeight() / this.rows;
List blocks = container.getBlocks();
for (int c = 0; c < this.columns; c++) {
for (int r = 0; r < this.rows; r++) {
int index = r * this.columns + c;
if (index == blocks.size()) {
break;
}
Block b = (Block) blocks.get(index);
b.setBounds(new Rectangle2D.Double(
c * width, r * height, width, height
));
}
}
return new Size2D(this.columns * width, this.rows * height);
}
示例7: arrangeFR
import org.jfree.ui.Size2D; //导入依赖的package包/类
/**
* Arrange with a fixed width and a height within a given range.
*
* @param container the container.
* @param constraint the constraint.
* @param g2 the graphics device.
*
* @return The size of the arrangement.
*/
protected Size2D arrangeFR(BlockContainer container, Graphics2D g2,
RectangleConstraint constraint) {
RectangleConstraint c1 = constraint.toUnconstrainedHeight();
Size2D size1 = arrange(container, g2, c1);
if (constraint.getHeightRange().contains(size1.getHeight())) {
return size1;
}
else {
double h = constraint.getHeightRange().constrain(size1.getHeight());
RectangleConstraint c2 = constraint.toFixedHeight(h);
return arrange(container, g2, c2);
}
}
示例8: arrangeFN
import org.jfree.ui.Size2D; //导入依赖的package包/类
/**
* Arrange with a fixed width and a height within a given range.
*
* @param container the container.
* @param g2 the graphics device.
* @param constraint the constraint.
*
* @return The size of the arrangement.
*/
protected Size2D arrangeFN(BlockContainer container, Graphics2D g2,
RectangleConstraint constraint) {
double width = constraint.getWidth() / this.columns;
RectangleConstraint constraint2 = constraint.toFixedWidth(width);
List blocks = container.getBlocks();
double maxH = 0.0;
for (int r = 0; r < this.rows; r++) {
for (int c = 0; c < this.columns; c++) {
int index = r * this.columns + c;
if (index == blocks.size()) {
break;
}
Block b = (Block) blocks.get(index);
Size2D s = b.arrange(g2, constraint2);
maxH = Math.max(maxH, s.getHeight());
}
}
RectangleConstraint constraint3 = constraint.toFixedHeight(
maxH * this.rows
);
return arrange(container, g2, constraint3);
}
示例9: arrangeRR
import org.jfree.ui.Size2D; //导入依赖的package包/类
/**
* Arranges the blocks with the overall width and height to fit within
* specified ranges.
*
* @param container the container.
* @param constraint the constraint.
* @param g2 the graphics device.
*
* @return The size after the arrangement.
*/
protected Size2D arrangeRR(BlockContainer container, Graphics2D g2,
RectangleConstraint constraint) {
// first arrange without constraints, and see if this fits within
// the required ranges...
Size2D s1 = arrangeNN(container, g2);
if (constraint.getWidthRange().contains(s1.width)) {
return s1; // TODO: we didn't check the height yet
}
else {
RectangleConstraint c = constraint.toFixedWidth(
constraint.getWidthRange().getUpperBound()
);
return arrangeFR(container, g2, c);
}
}
示例10: arrangeRN
import org.jfree.ui.Size2D; //导入依赖的package包/类
/**
* Arranges the block with a range constraint on the width, and no
* constraint on the height.
*
* @param container the container.
* @param constraint the constraint.
* @param g2 the graphics device.
*
* @return The size following the arrangement.
*/
protected Size2D arrangeRN(BlockContainer container, Graphics2D g2,
RectangleConstraint constraint) {
// first arrange without constraints, then see if the width fits
// within the required range...if not, call arrangeFN() at max width
Size2D s1 = arrangeNN(container, g2);
if (constraint.getWidthRange().contains(s1.width)) {
return s1;
}
else {
RectangleConstraint c = constraint.toFixedWidth(
constraint.getWidthRange().getUpperBound()
);
return arrangeFN(container, g2, c);
}
}
示例11: calculateTextBlockWidth
import org.jfree.ui.Size2D; //导入依赖的package包/类
/**
* A utility method for determining the width of a text block.
*
* @param block the text block.
* @param position the position.
* @param g2 the graphics device.
*
* @return The width.
*/
protected double calculateTextBlockWidth(TextBlock block,
CategoryLabelPosition position,
Graphics2D g2) {
RectangleInsets insets = getTickLabelInsets();
Size2D size = block.calculateDimensions(g2);
Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
size.getHeight());
Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
0.0f, 0.0f);
double w = rotatedBox.getBounds2D().getWidth() + insets.getTop()
+ insets.getBottom();
return w;
}
示例12: calculateTextBlockHeight
import org.jfree.ui.Size2D; //导入依赖的package包/类
/**
* A utility method for determining the height of a text block.
*
* @param block the text block.
* @param position the label position.
* @param g2 the graphics device.
*
* @return The height.
*/
protected double calculateTextBlockHeight(TextBlock block,
CategoryLabelPosition position,
Graphics2D g2) {
RectangleInsets insets = getTickLabelInsets();
Size2D size = block.calculateDimensions(g2);
Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
size.getHeight());
Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
0.0f, 0.0f);
double h = rotatedBox.getBounds2D().getHeight()
+ insets.getTop() + insets.getBottom();
return h;
}
示例13: testArrangeNN
import org.jfree.ui.Size2D; //导入依赖的package包/类
/**
* Some checks for the arrange method.
*/
@Test
public void testArrangeNN() {
BufferedImage image = new BufferedImage(100, 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
ImageTitle t = new ImageTitle(JFreeChart.INFO.getLogo());
Size2D s = t.arrange(g2);
assertEquals(102.0, s.getWidth(), EPSILON);
assertEquals(102.0, s.getHeight(), EPSILON);
t.setPadding(1.0, 2.0, 3.0, 4.0);
s = t.arrange(g2);
assertEquals(106.0, s.getWidth(), EPSILON);
assertEquals(104.0, s.getHeight(), EPSILON);
t.setMargin(5.0, 6.0, 7.0, 8.0);
s = t.arrange(g2);
assertEquals(120.0, s.getWidth(), EPSILON);
assertEquals(116.0, s.getHeight(), EPSILON);
}
示例14: arrange
import org.jfree.ui.Size2D; //导入依赖的package包/类
/**
* Arranges the contents of the block, within the given constraints, and
* returns the block size.
*
* @param g2 the graphics device.
* @param constraint the constraint (<code>null</code> not permitted).
*
* @return The block size (in Java2D units, never <code>null</code>).
*/
@Override
public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) {
Size2D result = new Size2D();
fetchLegendItems();
if (this.items.isEmpty()) {
return result;
}
BlockContainer container = this.wrapper;
if (container == null) {
container = this.items;
}
RectangleConstraint c = toContentConstraint(constraint);
Size2D size = container.arrange(g2, c);
result.height = calculateTotalHeight(size.height);
result.width = calculateTotalWidth(size.width);
return result;
}
示例15: arrangeRR
import org.jfree.ui.Size2D; //导入依赖的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);
}
}