本文整理匯總了Java中java.awt.geom.Rectangle2D.getMaxY方法的典型用法代碼示例。如果您正苦於以下問題:Java Rectangle2D.getMaxY方法的具體用法?Java Rectangle2D.getMaxY怎麽用?Java Rectangle2D.getMaxY使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.geom.Rectangle2D
的用法示例。
在下文中一共展示了Rectangle2D.getMaxY方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawHorizontalAxisTrace
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Draws a vertical line used to trace the mouse position to the horizontal axis.
*
* @param g2
* the graphics device.
* @param x
* the x-coordinate of the trace line.
*/
private void drawHorizontalAxisTrace(Graphics2D g2, int x) {
Rectangle2D dataArea = getScreenDataArea();
g2.setXORMode(Color.orange);
if ((int) dataArea.getMinX() < x && x < (int) dataArea.getMaxX()) {
if (this.verticalTraceLine != null) {
g2.draw(this.verticalTraceLine);
this.verticalTraceLine.setLine(x, (int) dataArea.getMinY(), x, (int) dataArea.getMaxY());
} else {
this.verticalTraceLine = new Line2D.Float(x, (int) dataArea.getMinY(), x, (int) dataArea.getMaxY());
}
g2.draw(this.verticalTraceLine);
}
// Reset to the default 'overwrite' mode
g2.setPaintMode();
}
示例2: drawAxisLine
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Draws an axis line at the current cursor position and edge.
*
* @param g2 the graphics device.
* @param cursor the cursor position.
* @param dataArea the data area.
* @param edge the edge.
*/
protected void drawAxisLine(Graphics2D g2, double cursor,
Rectangle2D dataArea, RectangleEdge edge) {
Line2D axisLine = null;
if (edge == RectangleEdge.TOP) {
axisLine = new Line2D.Double(dataArea.getX(), cursor, dataArea.getMaxX(), cursor);
}
else if (edge == RectangleEdge.BOTTOM) {
axisLine = new Line2D.Double(dataArea.getX(), cursor, dataArea.getMaxX(), cursor);
}
else if (edge == RectangleEdge.LEFT) {
axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, dataArea.getMaxY());
}
else if (edge == RectangleEdge.RIGHT) {
axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, dataArea.getMaxY());
}
g2.setPaint(this.axisLinePaint);
g2.setStroke(this.axisLineStroke);
g2.draw(axisLine);
}
示例3: fillDomainGridBand
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Fills a band between two values on the axis. This can be used to color bands between the
* grid lines.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param axis the domain axis.
* @param dataArea the data area.
* @param start the start value.
* @param end the end value.
*/
public void fillDomainGridBand(Graphics2D g2,
XYPlot plot,
ValueAxis axis,
Rectangle2D dataArea,
double start, double end) {
double x1 = axis.valueToJava2D(start, dataArea, plot.getDomainAxisEdge());
double x2 = axis.valueToJava2D(end, dataArea, plot.getDomainAxisEdge());
// TODO: need to change the next line to take account of plot orientation...
Rectangle2D band = new Rectangle2D.Double(
x1, dataArea.getMinY(), x2 - x1, dataArea.getMaxY() - dataArea.getMinY()
);
Paint paint = plot.getDomainTickBandPaint();
if (paint != null) {
g2.setPaint(paint);
g2.fill(band);
}
}
示例4: drawRangeGridline
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Draws a grid line against the range axis.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param axis the value axis.
* @param dataArea the area for plotting data (not yet adjusted for any 3D effect).
* @param value the value at which the grid line should be drawn.
*
*/
public void drawRangeGridline(Graphics2D g2,
CategoryPlot plot,
ValueAxis axis,
Rectangle2D dataArea,
double value) {
Range range = axis.getRange();
if (!range.contains(value)) {
return;
}
PlotOrientation orientation = plot.getOrientation();
double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());
Line2D line = null;
if (orientation == PlotOrientation.HORIZONTAL) {
line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY());
}
else if (orientation == PlotOrientation.VERTICAL) {
line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v);
}
Paint paint = plot.getRangeGridlinePaint();
if (paint == null) {
paint = CategoryPlot.DEFAULT_GRIDLINE_PAINT;
}
g2.setPaint(paint);
Stroke stroke = plot.getRangeGridlineStroke();
if (stroke == null) {
stroke = CategoryPlot.DEFAULT_GRIDLINE_STROKE;
}
g2.setStroke(stroke);
g2.draw(line);
}
示例5: drawHorizontal
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Draws a the title horizontally within the specified area. This method
* will be called from the {@link #draw(Graphics2D, Rectangle2D) draw}
* method.
*
* @param g2 the graphics device.
* @param area the area for the title.
*/
protected void drawHorizontal(Graphics2D g2, Rectangle2D area) {
Rectangle2D titleArea = (Rectangle2D) area.clone();
g2.setFont(this.font);
g2.setPaint(this.paint);
TextBlockAnchor anchor = null;
float x = 0.0f;
HorizontalAlignment horizontalAlignment = getHorizontalAlignment();
if (horizontalAlignment == HorizontalAlignment.LEFT) {
x = (float) titleArea.getX();
anchor = TextBlockAnchor.TOP_LEFT;
}
else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
x = (float) titleArea.getMaxX();
anchor = TextBlockAnchor.TOP_RIGHT;
}
else if (horizontalAlignment == HorizontalAlignment.CENTER) {
x = (float) titleArea.getCenterX();
anchor = TextBlockAnchor.TOP_CENTER;
}
float y = 0.0f;
RectangleEdge position = getPosition();
if (position == RectangleEdge.TOP) {
y = (float) titleArea.getY();
}
else if (position == RectangleEdge.BOTTOM) {
y = (float) titleArea.getMaxY();
if (horizontalAlignment == HorizontalAlignment.LEFT) {
anchor = TextBlockAnchor.BOTTOM_LEFT;
}
else if (horizontalAlignment == HorizontalAlignment.CENTER) {
anchor = TextBlockAnchor.BOTTOM_CENTER;
}
else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
anchor = TextBlockAnchor.BOTTOM_RIGHT;
}
}
this.content.draw(g2, x, y, anchor);
}
示例6: valueToJava2D
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Converts a data value to a coordinate in Java2D space, assuming that
* the axis runs along one edge of the specified plotArea.
* Note that it is possible for the coordinate to fall outside the
* plotArea.
*
* @param value the data value.
* @param plotArea the area for plotting the data.
* @param edge the axis location.
*
* @return the Java2D coordinate.
*/
public double valueToJava2D(double value, Rectangle2D plotArea, RectangleEdge edge) {
Range range = getRange();
double axisMin = switchedLog10(range.getLowerBound());
double axisMax = switchedLog10(range.getUpperBound());
double min = 0.0;
double max = 0.0;
if (RectangleEdge.isTopOrBottom(edge)) {
min = plotArea.getMinX();
max = plotArea.getMaxX();
}
else if (RectangleEdge.isLeftOrRight(edge)) {
min = plotArea.getMaxY();
max = plotArea.getMinY();
}
value = switchedLog10(value);
if (isInverted()) {
return max - (((value - axisMin) / (axisMax - axisMin)) * (max - min));
}
else {
return min + (((value - axisMin) / (axisMax - axisMin)) * (max - min));
}
}
示例7: drawDomainGridline
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Draws a grid line against the domain axis.
* <P>
* Note that this default implementation assumes that the horizontal axis
* is the domain axis. If this is not the case, you will need to override
* this method.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param dataArea the area for plotting data (not yet adjusted for any
* 3D effect).
* @param value the Java2D value at which the grid line should be drawn.
*
* @see #drawRangeGridline(Graphics2D, CategoryPlot, ValueAxis,
* Rectangle2D, double)
*/
public void drawDomainGridline(Graphics2D g2,
CategoryPlot plot,
Rectangle2D dataArea,
double value) {
Line2D line = null;
PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
line = new Line2D.Double(dataArea.getMinX(), value,
dataArea.getMaxX(), value);
}
else if (orientation == PlotOrientation.VERTICAL) {
line = new Line2D.Double(value, dataArea.getMinY(), value,
dataArea.getMaxY());
}
Paint paint = plot.getDomainGridlinePaint();
if (paint == null) {
paint = CategoryPlot.DEFAULT_GRIDLINE_PAINT;
}
g2.setPaint(paint);
Stroke stroke = plot.getDomainGridlineStroke();
if (stroke == null) {
stroke = CategoryPlot.DEFAULT_GRIDLINE_STROKE;
}
g2.setStroke(stroke);
g2.draw(line);
}
示例8: drawRangeGridLine
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Draws a grid line against the range axis.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param axis the value axis.
* @param dataArea the area for plotting data (not yet adjusted for any 3D effect).
* @param value the value at which the grid line should be drawn.
*
*/
public void drawRangeGridLine(Graphics2D g2,
XYPlot plot,
ValueAxis axis,
Rectangle2D dataArea,
double value) {
Range range = axis.getRange();
if (!range.contains(value)) {
return;
}
PlotOrientation orientation = plot.getOrientation();
Line2D line = null;
double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());
if (orientation == PlotOrientation.HORIZONTAL) {
line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY());
}
else if (orientation == PlotOrientation.VERTICAL) {
line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v);
}
Paint paint = plot.getRangeGridlinePaint();
Stroke stroke = plot.getRangeGridlineStroke();
g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT);
g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE);
g2.draw(line);
}
示例9: translateValueToJava2D
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Converts a data value to a coordinate in Java2D space, assuming that
* the axis runs along one edge of the specified plotArea.
* Note that it is possible for the coordinate to fall outside the
* plotArea.
*
* @param value the data value.
* @param plotArea the area for plotting the data.
* @param edge the axis location.
*
* @return the Java2D coordinate.
*
* @deprecated Use valueToJava2D().
*/
public double translateValueToJava2D(double value, Rectangle2D plotArea,
RectangleEdge edge) {
Range range = getRange();
double axisMin = switchedLog10(range.getLowerBound());
double axisMax = switchedLog10(range.getUpperBound());
double min = 0.0;
double max = 0.0;
if (RectangleEdge.isTopOrBottom(edge)) {
min = plotArea.getMinX();
max = plotArea.getMaxX();
}
else if (RectangleEdge.isLeftOrRight(edge)) {
min = plotArea.getMaxY();
max = plotArea.getMinY();
}
value = switchedLog10(value);
if (isInverted()) {
return max - (((value - axisMin) / (axisMax - axisMin)) * (max - min));
}
else {
return min + (((value - axisMin) / (axisMax - axisMin)) * (max - min));
}
}
示例10: drawVertical
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Draws a the title vertically within the specified area. This method
* will be called from the {@link #draw(Graphics2D, Rectangle2D) draw}
* method.
*
* @param g2 the graphics device.
* @param area the area for the title.
*/
protected void drawVertical(Graphics2D g2, Rectangle2D area) {
Rectangle2D titleArea = (Rectangle2D) area.clone();
g2.setFont(this.font);
g2.setPaint(this.paint);
TextBlockAnchor anchor = null;
float y = 0.0f;
VerticalAlignment verticalAlignment = getVerticalAlignment();
if (verticalAlignment == VerticalAlignment.TOP) {
y = (float) titleArea.getY();
anchor = TextBlockAnchor.TOP_RIGHT;
}
else if (verticalAlignment == VerticalAlignment.BOTTOM) {
y = (float) titleArea.getMaxY();
anchor = TextBlockAnchor.TOP_LEFT;
}
else if (verticalAlignment == VerticalAlignment.CENTER) {
y = (float) titleArea.getCenterY();
anchor = TextBlockAnchor.TOP_CENTER;
}
float x = 0.0f;
RectangleEdge position = getPosition();
if (position == RectangleEdge.LEFT) {
x = (float) titleArea.getX();
}
else if (position == RectangleEdge.RIGHT) {
x = (float) titleArea.getMaxX();
if (verticalAlignment == VerticalAlignment.TOP) {
anchor = TextBlockAnchor.BOTTOM_RIGHT;
}
else if (verticalAlignment == VerticalAlignment.CENTER) {
anchor = TextBlockAnchor.BOTTOM_CENTER;
}
else if (verticalAlignment == VerticalAlignment.BOTTOM) {
anchor = TextBlockAnchor.BOTTOM_LEFT;
}
}
this.content.draw(g2, x, y, anchor, x, y, -Math.PI / 2.0);
}
示例11: java2DToValue
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Converts a coordinate in Java2D space to the corresponding data
* value, assuming that the axis runs along one edge of the specified
* plotArea.
*
* @param java2DValue the coordinate in Java2D space.
* @param plotArea the area in which the data is plotted.
* @param edge the axis location.
*
* @return The data value.
*/
public double java2DToValue(double java2DValue, Rectangle2D plotArea,
RectangleEdge edge) {
Range range = getRange();
double axisMin = switchedLog10(range.getLowerBound());
double axisMax = switchedLog10(range.getUpperBound());
double plotMin = 0.0;
double plotMax = 0.0;
if (RectangleEdge.isTopOrBottom(edge)) {
plotMin = plotArea.getX();
plotMax = plotArea.getMaxX();
}
else if (RectangleEdge.isLeftOrRight(edge)) {
plotMin = plotArea.getMaxY();
plotMax = plotArea.getMinY();
}
if (isInverted()) {
return switchedPow10(axisMax - ((java2DValue - plotMin)
/ (plotMax - plotMin)) * (axisMax - axisMin));
}
else {
return switchedPow10(axisMin + ((java2DValue - plotMin)
/ (plotMax - plotMin)) * (axisMax - axisMin));
}
}
示例12: java2DToValue
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Converts a coordinate in Java2D space to the corresponding data value,
* assuming that the axis runs along one edge of the specified dataArea.
*
* @param java2DValue the coordinate in Java2D space.
* @param area the area in which the data is plotted.
* @param edge the edge along which the axis lies.
*
* @return The data value.
*/
public double java2DToValue(double java2DValue,
Rectangle2D area,
RectangleEdge edge) {
double result = Double.NaN;
double min = 0.0;
double max = 0.0;
double axisMin = this.first.getFirstMillisecond(this.calendar);
double axisMax = this.last.getLastMillisecond(this.calendar);
if (RectangleEdge.isTopOrBottom(edge)) {
min = area.getX();
max = area.getMaxX();
}
else if (RectangleEdge.isLeftOrRight(edge)) {
min = area.getMaxY();
max = area.getY();
}
if (isInverted()) {
result = axisMax - ((java2DValue - min) / (max - min)
* (axisMax - axisMin));
}
else {
result = axisMin + ((java2DValue - min) / (max - min)
* (axisMax - axisMin));
}
return result;
}
示例13: valueToJava2D
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Converts a value on the axis scale to a Java2D coordinate relative to
* the given <code>area</code>, based on the axis running along the
* specified <code>edge</code>.
*
* @param value the data value.
* @param area the area.
* @param edge the edge.
*
* @return The Java2D coordinate corresponding to <code>value</code>.
*/
public double valueToJava2D(double value, Rectangle2D area,
RectangleEdge edge) {
Range range = getRange();
double axisMin = calculateLog(range.getLowerBound());
double axisMax = calculateLog(range.getUpperBound());
value = calculateLog(value);
double min = 0.0;
double max = 0.0;
if (RectangleEdge.isTopOrBottom(edge)) {
min = area.getX();
max = area.getMaxX();
}
else if (RectangleEdge.isLeftOrRight(edge)) {
max = area.getMinY();
min = area.getMaxY();
}
if (isInverted()) {
return max
- ((value - axisMin) / (axisMax - axisMin)) * (max - min);
}
else {
return min
+ ((value - axisMin) / (axisMax - axisMin)) * (max - min);
}
}
示例14: drawVerticalLine
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Utility method for drawing a crosshair on the chart (if required).
*
* @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) {
double xx = getDomainAxis().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);
}
示例15: getSide
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Checks on which side of a rectangle a point lies. To avoid anchoring in
* points very close to an angle we take a 0.9 scale on each side.
* @param bounds the bounding box.
* @param point the point to be checked.
* @return 1 if the point lies east, 2 if it lies north, 3 if it lies west,
* 4 if it lies south, and 0 if its outside a proper position.
*/
private static int getSide(Rectangle2D bounds, Point2D point) {
double x = point.getX();
double y = point.getY();
double ulx = bounds.getX();
double uly = bounds.getY();
double brx = bounds.getMaxX();
double bry = bounds.getMaxY();
double scale = 0.1;
double dx = (bounds.getWidth() * scale) / 2;
double dy = (bounds.getHeight() * scale) / 2;
double minX = ulx + dx;
double minY = uly + dy;
double maxX = brx - dx;
double maxY = bry - dy;
int side = 0;
if (x >= brx && y >= minY && y <= maxY) {
side = 1;
} else if (y <= uly && x >= minX && x <= maxX) {
side = 2;
} else if (x <= ulx && y >= minY && y <= maxY) {
side = 3;
} else if (y >= bry && x >= minX && x <= maxX) {
side = 4;
}
return side;
}