本文整理汇总了Java中java.awt.geom.Rectangle2D.getX方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle2D.getX方法的具体用法?Java Rectangle2D.getX怎么用?Java Rectangle2D.getX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.Rectangle2D
的用法示例。
在下文中一共展示了Rectangle2D.getX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTransX
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
private double getTransX(TransformType type, Rectangle2D focus) {
switch (type) {
case DOWN:
case UP:
return focus.getCenterX() - this.currentTransformRectSize / 2;
case LEFT:
case DOWNLEFT:
case UPLEFT:
return focus.getX() - this.currentTransformRectSize;
case RIGHT:
case DOWNRIGHT:
case UPRIGHT:
return focus.getMaxX();
default:
return 0;
}
}
示例2: transStart
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Translates a data value to a Java2D value for the first section of the
* axis.
*
* @param value the value.
* @param area the data area.
* @param edge the edge along which the axis lies.
* @param length1 the length of the first section.
* @param length2 the length of the second section.
*
* @return The Java2D coordinate.
*/
private double transStart(double value, Rectangle2D area, RectangleEdge edge,
double length1, double length2) {
double min = 0.0;
double max = 0.0;
if (RectangleEdge.isTopOrBottom(edge)) {
min = area.getX();
max = area.getX() + area.getWidth() * length1 / (length1 + length2);
}
else if (RectangleEdge.isLeftOrRight(edge)) {
min = area.getMaxY();
max = area.getMaxY() - area.getHeight() * length1 / (length1 + length2);
}
if (isInverted()) {
return max - ((value - this.displayStart)
/ (this.fixedRange.getUpperBound() - this.displayStart)) * (max - min);
}
else {
return min + ((value - this.displayStart)
/ (this.fixedRange.getUpperBound() - this.displayStart)) * (max - min);
}
}
示例3: getCategoryStart
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Returns the starting coordinate for the specified category.
*
* @param category the category.
* @param categoryCount the number of categories.
* @param area the data area.
* @param edge the axis location.
*
* @return The coordinate.
*
* @see #getCategoryMiddle(int, int, Rectangle2D, RectangleEdge)
* @see #getCategoryEnd(int, int, Rectangle2D, RectangleEdge)
*/
public double getCategoryStart(int category, int categoryCount,
Rectangle2D area,
RectangleEdge edge) {
double result = 0.0;
if ((edge == RectangleEdge.TOP) || (edge == RectangleEdge.BOTTOM)) {
result = area.getX() + area.getWidth() * getLowerMargin();
}
else if ((edge == RectangleEdge.LEFT)
|| (edge == RectangleEdge.RIGHT)) {
result = area.getMinY() + area.getHeight() * getLowerMargin();
}
double categorySize = calculateCategorySize(categoryCount, area, edge);
double categoryGapWidth = calculateCategoryGapSize(categoryCount, area,
edge);
result = result + category * (categorySize + categoryGapWidth);
return result;
}
示例4: draw
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Draws the border by filling in the reserved space.
*
* @param g2 the graphics device.
* @param area the area.
*/
public void draw(Graphics2D g2, Rectangle2D area) {
// this default implementation will just fill the available
// border space with a single color
double t = this.insets.calculateTopInset(area.getHeight());
double b = this.insets.calculateBottomInset(area.getHeight());
double l = this.insets.calculateLeftInset(area.getWidth());
double r = this.insets.calculateRightInset(area.getWidth());
double x = area.getX();
double y = area.getY();
double w = area.getWidth();
double h = area.getHeight();
g2.setPaint(this.paint);
Rectangle2D rect = new Rectangle2D.Double();
if (t > 0.0) {
rect.setRect(x, y, w, t);
g2.fill(rect);
}
if (b > 0.0) {
rect.setRect(x, y + h - b, w, b);
g2.fill(rect);
}
if (l > 0.0) {
rect.setRect(x, y, l, h);
g2.fill(rect);
}
if (r > 0.0) {
rect.setRect(x + w - r, y, r, h);
g2.fill(rect);
}
}
示例5: 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 dataArea.
* <p>
* Note that it is possible for the coordinate to fall outside the area.
*
* @param value the data value.
* @param area the area for plotting the data.
* @param edge the edge along which the axis lies.
*
* @return The Java2D coordinate.
*/
public double valueToJava2D(double value,
Rectangle2D area,
RectangleEdge edge) {
double result = Double.NaN;
double axisMin = this.first.getFirstMillisecond(this.calendar);
double axisMax = this.last.getLastMillisecond(this.calendar);
if (RectangleEdge.isTopOrBottom(edge)) {
double minX = area.getX();
double maxX = area.getMaxX();
if (isInverted()) {
result = maxX + ((value - axisMin) / (axisMax - axisMin))
* (minX - maxX);
}
else {
result = minX + ((value - axisMin) / (axisMax - axisMin))
* (maxX - minX);
}
}
else if (RectangleEdge.isLeftOrRight(edge)) {
double minY = area.getMinY();
double maxY = area.getMaxY();
if (isInverted()) {
result = minY + (((value - axisMin) / (axisMax - axisMin))
* (maxY - minY));
}
else {
result = maxY - (((value - axisMin) / (axisMax - axisMin))
* (maxY - minY));
}
}
return result;
}
示例6: getCaretRectangle
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
Rectangle2D getCaretRectangle(Rectangle2D r) {
int d = 3;
double cx = r.getX() - d;
double cy = r.getY();
double cw = 2 * d;
double ch = r.getHeight();
return new Rectangle2D.Double(cx, cy, cw, ch);
}
示例7: mxOrganicLayout
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Constructor for mxOrganicLayout.
*/
public mxOrganicLayout(mxGraph graph, Rectangle2D bounds)
{
super(graph);
boundsX = bounds.getX();
boundsY = bounds.getY();
boundsWidth = bounds.getWidth();
boundsHeight = bounds.getHeight();
}
示例8: createProcessAnnotation
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
@Override
public ProcessAnnotation createProcessAnnotation(ExecutionUnit process) {
Rectangle2D frame = getLocation();
AnnotationStyle style = getStyle().clone();
// process annotations are always yellow by default
if (!wasColored()) {
style.setAnnotationColor(AnnotationColor.YELLOW);
}
return new ProcessAnnotation(getComment(), style, process, false, wasColored(), new Rectangle2D.Double(frame.getX(),
frame.getY(), frame.getWidth(), Math.max(ProcessAnnotation.MIN_HEIGHT, frame.getHeight())));
}
示例9: getScreenDataArea
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Returns the data area for the chart (the area inside the axes) with the
* current scaling applied (that is, the area as it appears on screen).
*
* @return The scaled data area.
*/
public Rectangle2D getScreenDataArea() {
Rectangle2D dataArea = this.info.getPlotInfo().getDataArea();
Insets insets = getInsets();
double x = dataArea.getX() * this.scaleX + insets.left;
double y = dataArea.getY() * this.scaleY + insets.top;
double w = dataArea.getWidth() * this.scaleX;
double h = dataArea.getHeight() * this.scaleY;
return new Rectangle2D.Double(x, y, w, h);
}
示例10: java2DToValue
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Translates a Java2D coordinate into the corresponding data value. To perform this
* translation, you need to know the area used for plotting data, and which edge the
* axis is located on.
*
* @param java2DValue the coordinate in Java2D space.
* @param area the rectangle (in Java2D space) where the data is to be plotted.
* @param edge the axis location.
*
* @return A data value.
*/
public double java2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge) {
DateRange range = (DateRange) getRange();
double axisMin = this.timeline.toTimelineValue(range.getLowerDate());
double axisMax = this.timeline.toTimelineValue(range.getUpperDate());
double min = 0.0;
double max = 0.0;
if (RectangleEdge.isTopOrBottom(edge)) {
min = area.getX();
max = area.getMaxX();
}
else if (RectangleEdge.isLeftOrRight(edge)) {
min = area.getMaxY();
max = area.getY();
}
double result;
if (isInverted()) {
result = axisMax - ((java2DValue - min) / (max - min) * (axisMax - axisMin));
}
else {
result = axisMin + ((java2DValue - min) / (max - min) * (axisMax - axisMin));
}
return this.timeline.toMillisecond((long) result);
}
示例11: createAlignedRectangle2D
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Creates a rectangle that is aligned to the frame.
*
* @param dimensions
* @param frame
* @param hAlign
* @param vAlign
*
* @return A rectangle.
*/
private Rectangle2D createAlignedRectangle2D(Size2D dimensions,
Rectangle2D frame, HorizontalAlignment hAlign,
VerticalAlignment vAlign) {
double x = Double.NaN;
double y = Double.NaN;
if (hAlign == HorizontalAlignment.LEFT) {
x = frame.getX();
}
else if (hAlign == HorizontalAlignment.CENTER) {
x = frame.getCenterX() - (dimensions.width / 2.0);
}
else if (hAlign == HorizontalAlignment.RIGHT) {
x = frame.getMaxX() - dimensions.width;
}
if (vAlign == VerticalAlignment.TOP) {
y = frame.getY();
}
else if (vAlign == VerticalAlignment.CENTER) {
y = frame.getCenterY() - (dimensions.height / 2.0);
}
else if (vAlign == VerticalAlignment.BOTTOM) {
y = frame.getMaxY() - dimensions.height;
}
return new Rectangle2D.Double(x, y, dimensions.width,
dimensions.height);
}
示例12: drawOutline
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Draws the outline for the plot.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param dataArea the area inside the axes.
*/
public void drawOutline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea) {
float x0 = (float) dataArea.getX();
float x1 = x0 + (float) Math.abs(this.xOffset);
float x3 = (float) dataArea.getMaxX();
float x2 = x3 - (float) Math.abs(this.xOffset);
float y0 = (float) dataArea.getMaxY();
float y1 = y0 - (float) Math.abs(this.yOffset);
float y3 = (float) dataArea.getMinY();
float y2 = y3 + (float) Math.abs(this.yOffset);
GeneralPath clip = new GeneralPath();
clip.moveTo(x0, y0);
clip.lineTo(x0, y2);
clip.lineTo(x1, y3);
clip.lineTo(x3, y3);
clip.lineTo(x3, y1);
clip.lineTo(x2, y0);
clip.closePath();
// put an outline around the data area...
Stroke outlineStroke = plot.getOutlineStroke();
Paint outlinePaint = plot.getOutlinePaint();
if ((outlineStroke != null) && (outlinePaint != null)) {
g2.setStroke(outlineStroke);
g2.setPaint(outlinePaint);
g2.draw(clip);
}
}
示例13: 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 Math.pow(
10, axisMax - ((java2DValue - plotMin) / (plotMax - plotMin)) * (axisMax - axisMin)
);
}
else {
return Math.pow(
10, axisMin + ((java2DValue - plotMin) / (plotMax - plotMin)) * (axisMax - axisMin)
);
}
}
示例14: getSPImage
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public static boolean getSPImage(Rectangle2D rect,
MapOverlay overlay,
int mapRes,
String baseURL,
String srs,
ConnectionWrapper wrapper) {
if (!"EPSG:3031".equals(srs))
return false;
double zoom = overlay.getXMap().getZoom();
int res = mapRes;
while(zoom*res/mapRes > 1.5 && res>1) {
res /=2;
}
int scale = mapRes/res;
int x = (int)Math.floor(scale*(rect.getX()-320.));
int y = (int)Math.floor(scale*(rect.getY()-320.));
int width = (int)Math.ceil( scale*(rect.getX()-320.+rect.getWidth()) ) - x;
int height = (int)Math.ceil( scale*(rect.getY()-320.+rect.getHeight()) ) - y;
Rectangle2D.Double bounds = new Rectangle2D.Double(
rect.getX() - 320,
rect.getY() - 320,
rect.getWidth(),
rect.getHeight());
bounds.x *= 25600;
bounds.y *= 25600;
bounds.width *= 25600;
bounds.height *= 25600;
StringBuffer requestURL = new StringBuffer(baseURL);
requestURL.append("&BBOX=");
requestURL.append(bounds.getMinX());
requestURL.append(",");
requestURL.append(-bounds.getMaxY());
requestURL.append(",");
requestURL.append(bounds.getMaxX());
requestURL.append(",");
requestURL.append(-bounds.getMinY());
requestURL.append("&WIDTH=");
requestURL.append(width);
requestURL.append("&HEIGHT=");
requestURL.append(height);
// WMS url
System.out.println("wms: " + requestURL.toString());
BufferedImage image = getWMSTile(requestURL.toString(), width, height, wrapper);
x += 320*scale;
y += 320*scale;
overlay.setImage(image, x/(double)scale, y/(double)scale, 1./(double)scale);
overlay.setRect(x, y, width, height);
overlay.setResolution(res);
return true;
}
示例15: getVisibleRect
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public Rectangle getVisibleRect() {
Rectangle2D rect = getClipRect2D();
return new Rectangle((int)rect.getX(),(int)rect.getY(), (int) rect.getWidth(), (int) rect.getHeight());
}