本文整理了Java中org.jfree.data.Range.contains
方法的一些代码示例,展示了Range.contains
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Range.contains
方法的具体详情如下:
包路径:org.jfree.data.Range
类名称:Range
方法名:contains
[英]Returns true if the range contains the specified value and false otherwise.
[中]如果范围包含指定的值,则返回true,否则返回false。
代码示例来源:origin: jfree/jfreechart
/**
* Returns the value within the range that is closest to the specified
* value.
*
* @param value the value.
*
* @return The constrained value.
*/
public double constrain(double value) {
double result = value;
if (!contains(value)) {
if (value > this.upper) {
result = this.upper;
}
else if (value < this.lower) {
result = this.lower;
}
}
return result;
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-chart
/**
* Returns the value within the range that is closest to the specified
* value.
*
* @param value the value.
*
* @return The constrained value.
*/
public double constrain(double value) {
double result = value;
if (!contains(value)) {
if (value > this.upper) {
result = this.upper;
}
else if (value < this.lower) {
result = this.lower;
}
}
return result;
}
代码示例来源:origin: jfree/jfreechart
/**
* Utility method for drawing a vertical line on the data area of the plot.
*
* @param g2 the graphics device.
* @param dataArea the data area.
* @param value the coordinate, where to draw the line.
* @param stroke the stroke to use.
* @param paint the paint to use.
*/
protected void drawVerticalLine(Graphics2D g2, Rectangle2D dataArea,
double value, Stroke stroke, Paint paint) {
ValueAxis axis = getDomainAxis();
if (getOrientation() == PlotOrientation.HORIZONTAL) {
axis = getRangeAxis();
}
if (axis.getRange().contains(value)) {
double xx = axis.valueToJava2D(value, dataArea,
RectangleEdge.BOTTOM);
Line2D line = new Line2D.Double(xx, dataArea.getMinY(), xx,
dataArea.getMaxY());
g2.setStroke(stroke);
g2.setPaint(paint);
g2.draw(line);
}
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-chart
/**
* Arranges the content for this title assuming a range constraint for the
* width and no bounds on the height, and returns the required size.
*
* @param g2 the graphics target.
* @param widthRange the range for the width.
*
* @return The content size.
*/
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
Size2D s = arrangeNN(g2);
if (widthRange.contains(s.getWidth())) {
return s;
}
double ww = widthRange.constrain(s.getWidth());
return arrangeFN(g2, ww);
}
代码示例来源:origin: jfree/jfreechart
/**
* Arranges the content for this title assuming a range constraint for the
* width and no bounds on the height, and returns the required size.
*
* @param g2 the graphics target.
* @param widthRange the range for the width.
*
* @return The content size.
*/
@Override
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
Size2D s = arrangeNN(g2);
if (widthRange.contains(s.getWidth())) {
return s;
}
double ww = widthRange.constrain(s.getWidth());
return arrangeFN(g2, ww);
}
代码示例来源:origin: jfree/jfreechart
/**
* Arranges the content for this title assuming a range constraint for the
* width and no bounds on the height, and returns the required size. This
* will reflect the fact that a text title positioned on the left or right
* of a chart will be rotated by 90 degrees.
*
* @param g2 the graphics target.
* @param widthRange the range for the width.
*
* @return The content size.
*
* @since 1.0.9
*/
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
Size2D s = arrangeNN(g2);
if (widthRange.contains(s.getWidth())) {
return s;
}
double ww = widthRange.constrain(s.getWidth());
return arrangeFN(g2, ww);
}
代码示例来源:origin: jfree/jfreechart
/**
* 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);
}
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-chart
/**
* Arranges the blocks in the container with a fixed with and a range
* constraint on the height.
*
* @param container the container.
* @param g2 the graphics device.
* @param constraint the constraint.
*
* @return The size following the arrangement.
*/
protected Size2D arrangeFR(BlockContainer container, Graphics2D g2,
RectangleConstraint constraint) {
Size2D s = arrangeFN(container, g2, constraint);
if (constraint.getHeightRange().contains(s.height)) {
return s;
}
else {
RectangleConstraint c = constraint.toFixedHeight(
constraint.getHeightRange().constrain(s.getHeight()));
return arrangeFF(container, g2, c);
}
}
代码示例来源:origin: jfree/jfreechart
/**
* Arranges the blocks in the container with a range constraint on the
* width and a fixed height.
*
* @param container the container.
* @param constraint the constraint.
* @param g2 the graphics device.
*
* @return The size following the arrangement.
*/
protected Size2D arrangeRF(BlockContainer container, Graphics2D g2,
RectangleConstraint constraint) {
Size2D s = arrangeNF(container, g2, constraint);
if (constraint.getWidthRange().contains(s.width)) {
return s;
}
else {
RectangleConstraint c = constraint.toFixedWidth(
constraint.getWidthRange().constrain(s.getWidth())
);
return arrangeFF(container, g2, c);
}
}
代码示例来源:origin: jfree/jfreechart
/**
* Arranges the blocks in the container using a fixed height and a
* range for the width.
*
* @param container the container.
* @param g2 the graphics device.
* @param constraint the constraint.
*
* @return The size of the container after arrangement.
*/
protected Size2D arrangeRF(BlockContainer container, Graphics2D g2,
RectangleConstraint constraint) {
Size2D s = arrangeNF(container, g2, constraint);
if (constraint.getWidthRange().contains(s.width)) {
return s;
}
else {
RectangleConstraint c = constraint.toFixedWidth(
constraint.getWidthRange().constrain(s.getWidth())
);
return arrangeFF(container, g2, c);
}
}
代码示例来源:origin: jfree/jfreechart
/**
* Arranges the blocks in the container with a fixed width and a range
* 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 arrangeFR(BlockContainer container, Graphics2D g2,
RectangleConstraint constraint) {
Size2D s = arrangeFN(container, g2, constraint);
if (constraint.getHeightRange().contains(s.height)) {
return s;
}
else {
RectangleConstraint c = constraint.toFixedHeight(
constraint.getHeightRange().constrain(s.getHeight())
);
return arrangeFF(container, g2, c);
}
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-chart
/**
* Arranges the blocks in the container with a range constraint on the
* width and a fixed height.
*
* @param container the container.
* @param g2 the graphics device.
* @param constraint the constraint.
*
* @return The size following the arrangement.
*/
protected Size2D arrangeRF(BlockContainer container, Graphics2D g2,
RectangleConstraint constraint) {
Size2D s = arrangeNF(container, g2, constraint);
if (constraint.getWidthRange().contains(s.width)) {
return s;
}
else {
RectangleConstraint c = constraint.toFixedWidth(
constraint.getWidthRange().constrain(s.getWidth()));
return arrangeFF(container, g2, c);
}
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-chart
/**
* Arranges the blocks in the container with a fixed width and a range
* 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 arrangeFR(BlockContainer container, Graphics2D g2,
RectangleConstraint constraint) {
Size2D s = arrangeFN(container, g2, constraint);
if (constraint.getHeightRange().contains(s.height)) {
return s;
}
else {
RectangleConstraint c = constraint.toFixedHeight(
constraint.getHeightRange().constrain(s.getHeight())
);
return arrangeFF(container, g2, c);
}
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-chart
/**
* Arranges the blocks in the container with a range constraint on the
* width and a fixed height.
*
* @param container the container.
* @param constraint the constraint.
* @param g2 the graphics device.
*
* @return The size following the arrangement.
*/
protected Size2D arrangeRF(BlockContainer container, Graphics2D g2,
RectangleConstraint constraint) {
Size2D s = arrangeNF(container, g2, constraint);
if (constraint.getWidthRange().contains(s.width)) {
return s;
}
else {
RectangleConstraint c = constraint.toFixedWidth(
constraint.getWidthRange().constrain(s.getWidth())
);
return arrangeFF(container, g2, c);
}
}
代码示例来源:origin: jfree/jfreechart
/**
* Performs an arrangement with a fixed width and a range for the height.
*
* @param container the container.
* @param g2 the graphics device.
* @param constraint the constraint.
*
* @return The container size after the arrangement.
*/
protected Size2D arrangeFR(BlockContainer container, Graphics2D g2,
RectangleConstraint constraint) {
Size2D size1 = arrangeFN(container, g2, constraint.getWidth());
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);
}
}
代码示例来源:origin: jfree/jfreechart
/**
* Arrange with a fixed width and no height constraint.
*
* @param container the container.
* @param constraint the constraint.
* @param g2 the graphics device.
*
* @return The size of the arrangement.
*/
protected Size2D arrangeRN(BlockContainer container, Graphics2D g2,
RectangleConstraint constraint) {
RectangleConstraint c1 = constraint.toUnconstrainedWidth();
Size2D size1 = arrange(container, g2, c1);
if (constraint.getWidthRange().contains(size1.getWidth())) {
return size1;
}
else {
double w = constraint.getWidthRange().constrain(size1.getWidth());
RectangleConstraint c2 = constraint.toFixedWidth(w);
return arrange(container, g2, c2);
}
}
代码示例来源:origin: jfree/jfreechart
/**
* Arrange with a fixed height and a width 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 arrangeRF(BlockContainer container, Graphics2D g2,
RectangleConstraint constraint) {
RectangleConstraint c1 = constraint.toUnconstrainedWidth();
Size2D size1 = arrange(container, g2, c1);
if (constraint.getWidthRange().contains(size1.getWidth())) {
return size1;
}
else {
double w = constraint.getWidthRange().constrain(size1.getWidth());
RectangleConstraint c2 = constraint.toFixedWidth(w);
return arrange(container, g2, c2);
}
}
代码示例来源:origin: jfree/jfreechart
/**
* Arrange with a fixed height and no width constraint.
*
* @param container the container.
* @param constraint the constraint.
* @param g2 the graphics device.
*
* @return The size of the arrangement.
*/
protected Size2D arrangeNR(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);
}
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-chart
/**
* 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);
}
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-chart
/**
* Arrange with a fixed height and no width constraint.
*
* @param container the container.
* @param constraint the constraint.
* @param g2 the graphics device.
*
* @return The size of the arrangement.
*/
protected Size2D arrangeNR(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);
}
}
内容来源于网络,如有侵权,请联系作者删除!