本文整理匯總了Java中java.awt.geom.Rectangle2D.getMinX方法的典型用法代碼示例。如果您正苦於以下問題:Java Rectangle2D.getMinX方法的具體用法?Java Rectangle2D.getMinX怎麽用?Java Rectangle2D.getMinX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.geom.Rectangle2D
的用法示例。
在下文中一共展示了Rectangle2D.getMinX方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getIntersectedNodes
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
public List<AStarNode> getIntersectedNodes(final Rectangle2D rectangle) {
final Point2D start = new Point2D.Double(rectangle.getMinX(), rectangle.getMinY());
final Point2D end = new Point2D.Double(rectangle.getMaxX(), rectangle.getMaxY());
final AStarNode startNode = this.getNodeFromMapLocation(start);
final AStarNode endNode = this.getNodeFromMapLocation(end);
final List<AStarNode> nodes = new ArrayList<>();
if (startNode == null || endNode == null) {
return nodes;
}
for (int x = startNode.getGridX(); x <= endNode.getGridX(); x++) {
for (int y = startNode.getGridY(); y <= endNode.getGridY(); y++) {
nodes.add(this.getGrid()[x][y]);
}
}
return nodes;
}
示例2: drawRangeLine
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Utility method for drawing a line perpendicular to the range axis (used
* for crosshairs).
*
* @param g2 the graphics device.
* @param dataArea the area defined by the axes.
* @param value the data value.
* @param stroke the line stroke (<code>null</code> not permitted).
* @param paint the line paint (<code>null</code> not permitted).
*/
protected void drawRangeLine(Graphics2D g2, Rectangle2D dataArea,
double value, Stroke stroke, Paint paint) {
double java2D = getRangeAxis().valueToJava2D(value, dataArea,
getRangeAxisEdge());
Line2D line = null;
if (this.orientation == PlotOrientation.HORIZONTAL) {
line = new Line2D.Double(java2D, dataArea.getMinY(), java2D,
dataArea.getMaxY());
}
else if (this.orientation == PlotOrientation.VERTICAL) {
line = new Line2D.Double(dataArea.getMinX(), java2D,
dataArea.getMaxX(), java2D);
}
g2.setStroke(stroke);
g2.setPaint(paint);
g2.draw(line);
}
示例3: shrinkSelectionXAxis
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
private void shrinkSelectionXAxis(double x, double y, Selection selectionObject, ValueAxis axis, int axisIndex,
double zoomFactor) {
Rectangle2D scaledDataArea = getScreenDataArea((int) x, (int) y);
double minX = scaledDataArea.getMinX();
double maxX = scaledDataArea.getMaxX();
double partToLeft = (x - minX) / (maxX - minX);
double lowerDomain = axis.getLowerBound();
double upperDomain = axis.getUpperBound();
double middlePointLeft = lowerDomain + (upperDomain - lowerDomain) * partToLeft;
double width = (upperDomain - lowerDomain) * zoomFactor;
Range domainRange = new Range(middlePointLeft - width / 2d, middlePointLeft + width / 2d);
for (String axisName : axisNameResolver.resolveXAxis(axisIndex)) {
selectionObject.addDelimiter(axisName, domainRange);
}
}
示例4: drawRangeCrosshair
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Draws a range crosshair.
*
* @param g2 the graphics target.
* @param dataArea the data area.
* @param orientation the plot orientation.
* @param value the crosshair value.
* @param axis the axis against which the value is measured.
* @param stroke the stroke used to draw the crosshair line.
* @param paint the paint used to draw the crosshair line.
*
* @since 1.0.5
*/
protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea,
PlotOrientation orientation, double value, ValueAxis axis,
Stroke stroke, Paint paint) {
if (!axis.getRange().contains(value)) {
return;
}
Line2D line = null;
if (orientation == PlotOrientation.HORIZONTAL) {
double xx = axis.valueToJava2D(value, dataArea,
RectangleEdge.BOTTOM);
line = new Line2D.Double(xx, dataArea.getMinY(), xx,
dataArea.getMaxY());
}
else {
double yy = axis.valueToJava2D(value, dataArea,
RectangleEdge.LEFT);
line = new Line2D.Double(dataArea.getMinX(), yy,
dataArea.getMaxX(), yy);
}
g2.setStroke(stroke);
g2.setPaint(paint);
g2.draw(line);
}
示例5: drawNeedle
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Draws the needle.
*
* @param g2 the graphics device.
* @param plotArea the plot area.
* @param rotate the rotation point.
* @param angle the angle.
*/
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea,
Point2D rotate, double angle) {
Line2D shape = new Line2D.Double();
double x = plotArea.getMinX() + (plotArea.getWidth() / 2);
shape.setLine(x, plotArea.getMinY(), x, plotArea.getMaxY());
Shape s = shape;
if ((rotate != null) && (angle != 0)) {
/// we have rotation
getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
s = getTransform().createTransformedShape(s);
}
defaultDisplay(g2, s);
}
示例6: restrictValueToDataArea
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Helper method which returns a value if it lies
* inside the visible dataArea and otherwise the corresponding
* coordinate on the border of the dataArea. The PlotOrientation
* is taken into account.
* Useful to avoid possible sun.dc.pr.PRException: endPath: bad path
* which occurs when trying to draw lines/shapes which in large part
* lie outside of the visible dataArea.
*
* @param value the value which shall be
* @param dataArea the area within which the data is being drawn.
* @param plot the plot (can be used to obtain standard color
* information etc).
* @return <code>double</code> value inside the data area.
*/
protected static double restrictValueToDataArea(double value,
XYPlot plot,
Rectangle2D dataArea) {
double min = 0;
double max = 0;
if (plot.getOrientation() == PlotOrientation.VERTICAL) {
min = dataArea.getMinY();
max = dataArea.getMaxY();
}
else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) {
min = dataArea.getMinX();
max = dataArea.getMaxX();
}
if (value < min) {
value = min;
}
else if (value > max) {
value = max;
}
return value;
}
示例7: drawHorizontalLine
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Utility method for drawing a horizontal line across 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 drawHorizontalLine(Graphics2D g2, Rectangle2D dataArea,
double value, Stroke stroke,
Paint paint) {
ValueAxis axis = getRangeAxis();
if (getOrientation() == PlotOrientation.HORIZONTAL) {
axis = getDomainAxis();
}
if (axis.getRange().contains(value)) {
double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT);
Line2D line = new Line2D.Double(dataArea.getMinX(), yy,
dataArea.getMaxX(), yy);
g2.setStroke(stroke);
g2.setPaint(paint);
g2.draw(line);
}
}
示例8: drawVerticalAxisTrace
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Draws a horizontal line used to trace the mouse position to the vertical
* axis.
*
* @param g2 the graphics device.
* @param y the y-coordinate of the trace line.
*/
private void drawVerticalAxisTrace(Graphics2D g2, int y) {
Rectangle2D dataArea = getScreenDataArea();
g2.setXORMode(Color.orange);
if (((int) dataArea.getMinY() < y) && (y < (int) dataArea.getMaxY())) {
if (this.horizontalTraceLine != null) {
g2.draw(this.horizontalTraceLine);
this.horizontalTraceLine.setLine((int) dataArea.getMinX(), y,
(int) dataArea.getMaxX(), y);
}
else {
this.horizontalTraceLine = new Line2D.Float(
(int) dataArea.getMinX(), y, (int) dataArea.getMaxX(),
y);
}
g2.draw(this.horizontalTraceLine);
}
// Reset to the default 'overwrite' mode
g2.setPaintMode();
}
示例9: 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);
}
示例10: 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.
*/
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);
}
示例11: runTest
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
public void runTest(Object ctx, int numReps) {
TLExContext tlctx = (TLExContext)ctx;
TextLayout tl = tlctx.tl;
int numhits = tlctx.hits.length;
Rectangle2D lb = tlctx.lb;
TextHitInfo hit;
for (int i = 0; i <= numhits; ++i) {
float x = (float)(lb.getMinX() + lb.getWidth() * i / numhits);
float y = (float)(lb.getMinY() + lb.getHeight() * i / numhits);
hit = tl.hitTestChar(x, y, lb);
}
}
示例12: 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));
}
}
示例13: mouseReleased
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Handles a 'mouse released' event. On Windows, we need to check if this is a popup trigger,
* but only if we haven't already been tracking a zoom rectangle.
*
* @param e
* information about the event.
*/
@Override
public void mouseReleased(MouseEvent e) {
// if we've been panning, we need to reset now that the mouse is
// released...
if (this.panLast != null) {
this.panLast = null;
setCursor(Cursor.getDefaultCursor());
} else if (this.selectionRectangle != null) {
boolean hZoom = false;
boolean vZoom = false;
if (this.orientation == PlotOrientation.HORIZONTAL) {
hZoom = this.rangeZoomable;
vZoom = this.domainZoomable;
} else {
hZoom = this.domainZoomable;
vZoom = this.rangeZoomable;
}
boolean zoomTrigger1 = hZoom && Math.abs(e.getX() - this.zoomPoint.getX()) >= this.zoomTriggerDistance;
boolean zoomTrigger2 = vZoom && Math.abs(e.getY() - this.zoomPoint.getY()) >= this.zoomTriggerDistance;
if (zoomTrigger1 || zoomTrigger2) {
if (hZoom && e.getX() < this.zoomPoint.getX() || vZoom && e.getY() < this.zoomPoint.getY()) {
restoreAutoBounds();
} else {
double x, y, w, h;
Rectangle2D screenDataArea = getScreenDataArea((int) this.zoomPoint.getX(), (int) this.zoomPoint.getY());
double maxX = screenDataArea.getMaxX();
double maxY = screenDataArea.getMaxY();
// for mouseReleased event, (horizontalZoom || verticalZoom)
// will be true, so we can just test for either being false;
// otherwise both are true
if (!vZoom) {
x = this.zoomPoint.getX();
y = screenDataArea.getMinY();
w = Math.min(this.selectionRectangle.getWidth(), maxX - this.zoomPoint.getX());
h = screenDataArea.getHeight();
} else if (!hZoom) {
x = screenDataArea.getMinX();
y = this.zoomPoint.getY();
w = screenDataArea.getWidth();
h = Math.min(this.selectionRectangle.getHeight(), maxY - this.zoomPoint.getY());
} else {
x = this.zoomPoint.getX();
y = this.zoomPoint.getY();
w = Math.min(this.selectionRectangle.getWidth(), maxX - this.zoomPoint.getX());
h = Math.min(this.selectionRectangle.getHeight(), maxY - this.zoomPoint.getY());
}
Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h);
selectRectangle(zoomArea, e);
}
this.zoomPoint = null;
this.selectionRectangle = null;
} else {
this.zoomPoint = null;
this.selectionRectangle = null;
}
}
else if (e.isPopupTrigger()) {
if (this.popup != null) {
displayPopupMenu(e.getX(), e.getY());
}
}
}
示例14: drawNeedle
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Draws the needle.
*
* @param g2 the graphics device.
* @param plotArea the plot area.
* @param rotate the rotation point.
* @param angle the angle.
*/
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea,
Point2D rotate, double angle) {
GeneralPath shape1 = new GeneralPath();
GeneralPath shape2 = new GeneralPath();
GeneralPath shape3 = new GeneralPath();
float minX = (float) plotArea.getMinX();
float minY = (float) plotArea.getMinY();
float maxX = (float) plotArea.getMaxX();
float maxY = (float) plotArea.getMaxY();
//float midX = (float) (minX + (plotArea.getWidth() * getRotateX()));
//float midY = (float) (minY + (plotArea.getHeight() * getRotateY()));
float midX = (float) (minX + (plotArea.getWidth() * 0.5));
float midY = (float) (minY + (plotArea.getHeight() * 0.8));
float y = maxY - (2 * (maxY - midY));
if (y < minY) {
y = minY;
}
shape1.moveTo(minX, midY);
shape1.lineTo(midX, minY);
shape1.lineTo(midX, y);
shape1.closePath();
shape2.moveTo(maxX, midY);
shape2.lineTo(midX, minY);
shape2.lineTo(midX, y);
shape2.closePath();
shape3.moveTo(minX, midY);
shape3.lineTo(midX, maxY);
shape3.lineTo(maxX, midY);
shape3.lineTo(midX, y);
shape3.closePath();
Shape s1 = shape1;
Shape s2 = shape2;
Shape s3 = shape3;
if ((rotate != null) && (angle != 0)) {
/// we have rotation huston, please spin me
getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
s1 = shape1.createTransformedShape(transform);
s2 = shape2.createTransformedShape(transform);
s3 = shape3.createTransformedShape(transform);
}
if (getHighlightPaint() != null) {
g2.setPaint(getHighlightPaint());
g2.fill(s3);
}
if (getFillPaint() != null) {
g2.setPaint(getFillPaint());
g2.fill(s1);
g2.fill(s2);
}
if (getOutlinePaint() != null) {
g2.setStroke(getOutlineStroke());
g2.setPaint(getOutlinePaint());
g2.draw(s1);
g2.draw(s2);
g2.draw(s3);
}
}
示例15: drawNeedle
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Draws the needle.
*
* @param g2 the graphics device.
* @param plotArea the plot area.
* @param rotate the rotation point.
* @param angle the angle.
*/
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea,
Point2D rotate, double angle) {
GeneralPath shape1 = new GeneralPath();
GeneralPath shape2 = new GeneralPath();
float minX = (float) plotArea.getMinX();
float minY = (float) plotArea.getMinY();
float maxX = (float) plotArea.getMaxX();
float maxY = (float) plotArea.getMaxY();
float midX = (float) (minX + (plotArea.getWidth() / 2));
float midY = (float) (minY + (plotArea.getHeight() / 2));
shape1.moveTo(minX, midY);
shape1.lineTo(midX, minY);
shape1.lineTo(maxX, midY);
shape1.closePath();
shape2.moveTo(minX, midY);
shape2.lineTo(midX, maxY);
shape2.lineTo(maxX, midY);
shape2.closePath();
if ((rotate != null) && (angle != 0)) {
/// we have rotation huston, please spin me
getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
shape1.transform(getTransform());
shape2.transform(getTransform());
}
if (getFillPaint() != null) {
g2.setPaint(getFillPaint());
g2.fill(shape1);
}
if (getHighlightPaint() != null) {
g2.setPaint(getHighlightPaint());
g2.fill(shape2);
}
if (getOutlinePaint() != null) {
g2.setStroke(getOutlineStroke());
g2.setPaint(getOutlinePaint());
g2.draw(shape1);
g2.draw(shape2);
}
}