本文整理汇总了Java中java.awt.geom.Rectangle2D.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle2D.getWidth方法的具体用法?Java Rectangle2D.getWidth怎么用?Java Rectangle2D.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.Rectangle2D
的用法示例。
在下文中一共展示了Rectangle2D.getWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resetBounds
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
@Override
public void resetBounds() {
final FRectangle old = getBounds();
final Rectangle2D r = getResetsBounds(old);
double w = r.getWidth();
double h = r.getHeight();
if (w < old.getWidth())
w = old.getWidth();
if (h < old.getHeight())
h = old.getHeight();
setBounds(old.getX()/*-((r.getWidth()-old.getWidth())/2)*/,
old.getY()/*
* -(r.getHeight()-old.getHeight())/2
*/, w, h);
// myBounds.setTransformNetBoundsMax(MovingArea.NET_LENGTH);
}
示例2: renderGraph
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
@Override
public void renderGraph(JGraph<?> graph, File file) throws PortException {
// Get graph bounds. If not available, do nothing (probably empty graph)
Rectangle2D bounds = graph.getGraphBounds();
if (bounds == null) {
return;
}
try (FileOutputStream fos = new FileOutputStream(file);) {
EpsGraphics g2d = new EpsGraphics(graph.getModel()
.getName(), fos, 0, 0, (int) bounds.getWidth(), (int) bounds.getHeight(),
ColorMode.COLOR_RGB);
// Render
toGraphics(graph, g2d);
// Cleanup
g2d.close();
} catch (IOException e) {
throw new PortException(e);
}
}
示例3: zoomTo
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
void zoomTo() {
Grid2DOverlay grid = (Grid2DOverlay)gridCB.getSelectedItem();
if( grid==null ) {
System.out.println("null");
return;
}
MultiGrid tempMGrid = ((MultiGrid)mGrids.get( grid ));
XMap m = grid.getMap();
try {
Rectangle2D.Double rect = null;
Rectangle2D shape = (Rectangle2D)tempMGrid.shape.getShapes().get( 0 );
double w = shape.getWidth();
double h = shape.getHeight();
rect = new Rectangle2D.Double( shape.getX()-.25*w, shape.getY()-.25*h, w*1.5, h*1.5 );
// Tracks zoom before, does zoom, tracks zoom after
m.setZoomHistoryPast(m);
m.zoomToRect( rect );
m.setZoomHistoryNext(m);
m.repaint();
} catch(Exception e) {}
}
示例4: applyTexturePaint
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
private void applyTexturePaint(TexturePaint texturePaint) throws IOException {
Rectangle2D anchorRect = texturePaint.getAnchorRect();
PDTilingPattern pattern = new PDTilingPattern();
pattern.setPaintType(PDTilingPattern.PAINT_COLORED);
pattern.setTilingType(PDTilingPattern.TILING_CONSTANT_SPACING_FASTER_TILING);
pattern.setBBox(new PDRectangle((float) anchorRect.getX(), (float) anchorRect.getY(),
(float) anchorRect.getWidth(), (float) anchorRect.getHeight()));
pattern.setXStep((float) anchorRect.getWidth());
pattern.setYStep((float) anchorRect.getHeight());
AffineTransform patternTransform = new AffineTransform();
patternTransform.translate(0, anchorRect.getHeight());
patternTransform.scale(1f, -1f);
pattern.setMatrix(patternTransform);
PDAppearanceStream appearance = new PDAppearanceStream(document);
appearance.setResources(pattern.getResources());
appearance.setBBox(pattern.getBBox());
PDPageContentStream imageContentStream = new PDPageContentStream(document, appearance,
((COSStream) pattern.getCOSObject()).createOutputStream());
BufferedImage texturePaintImage = texturePaint.getImage();
PDImageXObject imageXObject = imageEncoder.encodeImage(document, imageContentStream, texturePaintImage);
float ratioW = (float) ((anchorRect.getWidth()) / texturePaintImage.getWidth());
float ratioH = (float) ((anchorRect.getHeight()) / texturePaintImage.getHeight());
float paintHeight = (texturePaintImage.getHeight()) * ratioH;
imageContentStream.drawImage(imageXObject, (float) anchorRect.getX(), (float) (paintHeight + anchorRect.getY()),
texturePaintImage.getWidth() * ratioW, -paintHeight);
imageContentStream.close();
PDColorSpace patternCS1 = new PDPattern(null, imageXObject.getColorSpace());
COSName tilingPatternName = resources.add(pattern);
PDColor patternColor = new PDColor(tilingPatternName, patternCS1);
contentStream.setNonStrokingColor(patternColor);
contentStream.setStrokingColor(patternColor);
}
示例5: CochleaGenderClassifier
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public CochleaGenderClassifier (AEChip chip){
super(chip);
setNBins(weights.length);
setMaxIsiUs(9000);
setMinIsiUs(3000);
setDirection(Direction.XtimesYDirection);
titleRenderer = new TextRenderer(new Font("Helvetica",Font.PLAIN,48));
Rectangle2D bounds = titleRenderer.getBounds(Gender.Unknown.toString());
titleArea = new Rectangle((int)bounds.getWidth(),(int)bounds.getHeight());
setPropertyTooltip("Gender params","genderThreshold","threshold for abs(dot product) to classify as (female) speaker. If abs(dot)<genderThreshold then sex is Unknown.");
}
示例6: warp
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Warp the source image to create the destination image.
*
* @return the new destination image
*/
public GeoImage warp() {
Rectangle2D dstBounds = warpedBounds();
BufferedImage dstImage = createDestinationImage(dstBounds, srcGeoImage.getBufferedImage());
double cellSize = dstBounds.getWidth() / dstImage.getWidth();
double destinationWest = dstBounds.getMinX();
double destinationNorth = dstBounds.getMaxY();
GeoImage dstGeoImage = new GeoImage(dstImage, destinationWest, destinationNorth, cellSize);
double[] destXY = new double[2];
int dstImageWidth = dstImage.getWidth();
int dstImageHeight = dstImage.getHeight();
System.out.println("image size: " + dstImageHeight + " " + dstImageWidth);
for (int row = 0; row < dstImageHeight; row++) {
for (int col = 0; col < dstImageWidth; col++) {
destXY[0] = destinationWest + (col + 0.5) * cellSize;
destXY[1] = destinationNorth - (row + 0.5) * cellSize;
double[] srcXY = dstToSrcTransformation.transform(destXY);
interpolation.transform(srcXY, 1);
// // Convert srcPxX/srcPxY from meters to pixels.
// int srcPxX = (int) Math.round(srcXY[0]);
// int srcPxY = (int) Math.round(srcXY[1]);
//if (srcPxX >= 0 && srcPxX < dstImageWidth && srcPxY >= 0 && srcPxY < dstImageHeight) {
if (srcGeoImage.getBounds2D().contains(srcXY[0], srcXY[1])) {
int argb = srcGeoImage.getBilinearInterpol(srcXY[0], srcXY[1]);
dstImage.setRGB(col, row, argb);
}
// System.out.println(srcPxX + " " + srcPxY);
}
}
return dstGeoImage;
}
示例7: getWebPoint
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Returns a cartesian point from a polar angle, length and bounding box
*
* @param bounds the area inside which the point needs to be.
* @param angle the polar angle, in degrees.
* @param length the relative length. Given in percent of maximum extend.
*
* @return The cartesian point.
*/
protected Point2D getWebPoint(Rectangle2D bounds,
double angle, double length) {
double angrad = Math.toRadians(angle);
double x = Math.cos(angrad) * length * bounds.getWidth() / 2;
double y = -Math.sin(angrad) * length * bounds.getHeight() / 2;
return new Point2D.Double(bounds.getX() + x + bounds.getWidth() / 2,
bounds.getY() + y + bounds.getHeight() / 2);
}
示例8: draw
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Draws the wafermap view.
*
* @param g2 the graphics device.
* @param plotArea the plot area.
* @param state the plot state.
* @param info the plot rendering info.
*/
public void draw(Graphics2D g2, Rectangle2D plotArea, PlotState state, PlotRenderingInfo info) {
// if the plot area is too small, just return...
boolean b1 = (plotArea.getWidth() <= MINIMUM_WIDTH_TO_DRAW);
boolean b2 = (plotArea.getHeight() <= MINIMUM_HEIGHT_TO_DRAW);
if (b1 || b2) {
return;
}
// record the plot area...
if (info != null) {
info.setPlotArea(plotArea);
}
// adjust the drawing area for the plot insets (if any)...
Insets insets = getInsets();
if (insets != null) {
plotArea.setRect(plotArea.getX() + insets.left,
plotArea.getY() + insets.top,
plotArea.getWidth() - insets.left - insets.right,
plotArea.getHeight() - insets.top - insets.bottom);
}
drawChipGrid(g2, plotArea);
drawWaferEdge(g2, plotArea);
}
示例9: draw
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public void draw(SunGraphics2D sg2d, Shape s) {
if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM) {
BasicStroke bs = ((BasicStroke) sg2d.stroke);
if (s instanceof Rectangle2D) {
if (bs.getLineJoin() == BasicStroke.JOIN_MITER &&
bs.getDashArray() == null)
{
Rectangle2D r2d = (Rectangle2D) s;
double w = r2d.getWidth();
double h = r2d.getHeight();
double x = r2d.getX();
double y = r2d.getY();
if (w >= 0 && h >= 0) {
double lw = bs.getLineWidth();
drawRectangle(sg2d, x, y, w, h, lw);
}
return;
}
} else if (s instanceof Line2D) {
Line2D l2d = (Line2D) s;
if (drawGeneralLine(sg2d,
l2d.getX1(), l2d.getY1(),
l2d.getX2(), l2d.getY2()))
{
return;
}
}
}
outpipe.draw(sg2d, s);
}
示例10: calculateBarWidth
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Calculates the bar width and stores it in the renderer state.
*
* @param plot the plot.
* @param dataArea the data area.
* @param rendererIndex the renderer index.
* @param state the renderer state.
*/
protected void calculateBarWidth(CategoryPlot plot,
Rectangle2D dataArea,
int rendererIndex,
CategoryItemRendererState state) {
// calculate the bar width
CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
CategoryDataset data = plot.getDataset(rendererIndex);
if (data != null) {
PlotOrientation orientation = plot.getOrientation();
double space = 0.0;
if (orientation == PlotOrientation.HORIZONTAL) {
space = dataArea.getHeight();
}
else if (orientation == PlotOrientation.VERTICAL) {
space = dataArea.getWidth();
}
double maxWidth = space * getMaximumBarWidth();
int columns = data.getColumnCount();
double categoryMargin = 0.0;
if (columns > 1) {
categoryMargin = domainAxis.getCategoryMargin();
}
double used = space * (1 - domainAxis.getLowerMargin()
- domainAxis.getUpperMargin()
- categoryMargin);
if (columns > 0) {
state.setBarWidth(Math.min(used / columns, maxWidth));
}
else {
state.setBarWidth(Math.min(used, maxWidth));
}
}
}
示例11: paint
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public void paint(final Graphics g) {
final int width = getWidth();
final int height = getHeight();
final Font font = getFont();
final FontMetrics metrics = getFontMetrics(font);
g.setFont(font);
final String text = getText().trim();
final int ascent = metrics.getAscent();
final Rectangle2D stringBounds = metrics.getStringBounds(text, g);
final int halfway = width / 2;
final int x = (halfway - (int)stringBounds.getWidth() / 2);
final Graphics2D g2d = g instanceof Graphics2D ? (Graphics2D)g : null;
if (g2d != null) {
g.setColor(UIManager.getColor("DesktopIcon.labelBackground"));
final Object origAA = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
final int roundHeight = height - ROUND_ADDITIONAL_HEIGHT + 1;
g.fillRoundRect(0, 0, width, roundHeight, roundHeight, roundHeight);
final int[] xpts = { halfway, halfway + NUB_HEIGHT, halfway - NUB_HEIGHT };
final int[] ypts = { height, height - NUB_HEIGHT, height - NUB_HEIGHT };
g.fillPolygon(xpts, ypts, 3);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, origAA);
}
g.setColor(Color.black);
SwingUtilities2.drawString(this, g, text, x, 2 + ascent);
g.setColor(Color.white);
SwingUtilities2.drawString(this, g, text, x, 1 + ascent);
}
示例12: TexturePaint
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Constructs a {@code TexturePaint} object.
* @param txtr the {@code BufferedImage} object with the texture
* used for painting
* @param anchor the {@code Rectangle2D} in user space used to
* anchor and replicate the texture
*/
public TexturePaint(BufferedImage txtr,
Rectangle2D anchor) {
this.bufImg = txtr;
this.tx = anchor.getX();
this.ty = anchor.getY();
this.sx = anchor.getWidth() / bufImg.getWidth();
this.sy = anchor.getHeight() / bufImg.getHeight();
}
示例13: drawLabels
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Draws the labels for the pie sections.
*
* @param g2 the graphics device.
* @param keys the keys.
* @param totalValue the total value.
* @param plotArea the plot area.
* @param linkArea the link area.
* @param state the state.
*/
protected void drawLabels(Graphics2D g2, List keys, double totalValue,
Rectangle2D plotArea, Rectangle2D linkArea,
PiePlotState state) {
Composite originalComposite = g2.getComposite();
g2.setComposite(
AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
// classify the keys according to which side the label will appear...
DefaultKeyedValues leftKeys = new DefaultKeyedValues();
DefaultKeyedValues rightKeys = new DefaultKeyedValues();
double runningTotal1 = 0.0;
Iterator iterator1 = keys.iterator();
while (iterator1.hasNext()) {
Comparable key = (Comparable) iterator1.next();
boolean include = true;
double v = 0.0;
Number n = this.dataset.getValue(key);
if (n == null) {
include = !this.ignoreNullValues;
}
else {
v = n.doubleValue();
include = this.ignoreZeroValues ? v > 0.0 : v >= 0.0;
}
if (include) {
runningTotal1 = runningTotal1 + v;
// work out the mid angle (0 - 90 and 270 - 360) = right,
// otherwise left
double mid = this.startAngle + (this.direction.getFactor()
* ((runningTotal1 - v / 2.0) * 360) / totalValue);
if (Math.cos(Math.toRadians(mid)) < 0.0) {
leftKeys.addValue(key, new Double(mid));
}
else {
rightKeys.addValue(key, new Double(mid));
}
}
}
g2.setFont(getLabelFont());
float maxLabelWidth
= (float) (getMaximumLabelWidth() * plotArea.getWidth());
// draw the labels...
if (this.labelGenerator != null) {
drawLeftLabels(leftKeys, g2, plotArea, linkArea, maxLabelWidth,
state);
drawRightLabels(rightKeys, g2, plotArea, linkArea, maxLabelWidth,
state);
}
g2.setComposite(originalComposite);
}
示例14: retrieveImage
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
protected void retrieveImage(Rectangle2D rect) {
double[] wesn = geoImage.wesn;
int mapRes = geoImage.maxViewRes;
double zoom = map.getZoom();
int res = mapRes;
while (zoom * res / mapRes > 1.5 && res > 1) {
res /= 2;
}
int scale = mapRes / res;
double wrap = map.getWrap();
boolean fullWrap = false;
if (rect.getWidth() > wrap && wrap != -1) {
rect = new Rectangle2D.Double(0, rect.getY(), wrap, rect
.getHeight());
fullWrap = true;
}
int x = (int) Math.floor(scale * rect.getX());
int y = (int) Math.floor(scale * (rect.getY() - 260.));
int width = (int) Math.ceil(scale * (rect.getX() + rect.getWidth()))
- x;
int height = (int) Math.ceil(scale
* (rect.getY() - 260. + rect.getHeight()))
- y;
System.out.println(x + "\t" + y + "\t" + width + "\t" + height);
Projection proj = map.getProjection();
Point2D minLonLat = proj.getRefXY(rect.getX(), rect.getMinY());
Point2D maxLonLat = proj.getRefXY(rect.getMaxX(), rect.getMaxY());
Point2D minMapXY = proj.getMapXY(wesn[0], wesn[3]);
Point2D maxMapXY = proj.getMapXY(wesn[1], wesn[2]);
System.out.println(wesn[0] + "\t" + wesn[1]);
System.out.println(minMapXY.getX() * scale + "\t" + maxMapXY.getX() * scale);
System.out.println(x + "\t" + wrap * scale);
int sX = (int) (minMapXY.getX() * scale - x);
int sY = (int) ((minMapXY.getY() - 260) * scale - y);
int eX = (int) (maxMapXY.getX() * scale - x);
int eY = (int) ((maxMapXY.getY() - 260) * scale - y);
while (sX > eX) {
eX += wrap * scale;
}
System.out.println(sX + "\t" + sY);
System.out.println(eX + "\t" + eY);
if (width < 0 || height < 0)
return;
BufferedImage mercImage = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
Graphics2D g = mercImage.createGraphics();
BufferedImage source = geoImage.getImage();
g.drawImage(geoImage.getImage(), sX, sY, eX, eY, 0, 0, source.getWidth(), source.getHeight(), null);
if (fullWrap && eX > width)
{
sX = (int) (sX - wrap * scale);
eX = (int) (eX - wrap * scale);
g.drawImage(geoImage.getImage(), sX, sY, eX, eY, 0, 0, source.getWidth(), source.getHeight(), null);
}
while (x + width > wrap * scale)
x -= wrap * scale;
y += 260 * scale;
setImage(mercImage, x / (double) scale, y / (double) scale,
1. / scale);
setRect(x, y, width, height);
}
示例15: drawLabels
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
* Draws the labels for the pie sections.
*
* @param g2 the graphics device.
* @param keys the keys.
* @param totalValue the total value.
* @param plotArea the plot area.
* @param linkArea the link area.
* @param state the state.
*/
protected void drawLabels(Graphics2D g2, List keys, double totalValue,
Rectangle2D plotArea, Rectangle2D linkArea, PiePlotState state) {
Composite originalComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
// classify the keys according to which side the label will appear...
DefaultKeyedValues leftKeys = new DefaultKeyedValues();
DefaultKeyedValues rightKeys = new DefaultKeyedValues();
double runningTotal1 = 0.0;
Iterator iterator1 = keys.iterator();
while (iterator1.hasNext()) {
Comparable key = (Comparable) iterator1.next();
Number n = this.dataset.getValue(key);
if (n != null) {
double v = n.doubleValue();
if (v > 0.0) {
runningTotal1 = runningTotal1 + v;
// work out the mid angle (0 - 90 and 270 - 360) = right, otherwise left
double mid = this.startAngle + (this.direction.getFactor()
* ((runningTotal1 - v / 2.0) * 360) / totalValue);
if (Math.cos(Math.toRadians(mid)) < 0.0) {
leftKeys.addValue(key, new Double(mid));
}
else {
rightKeys.addValue(key, new Double(mid));
}
}
}
}
g2.setFont(getLabelFont());
float maxLabelWidth = (float) (getMaximumLabelWidth() * plotArea.getWidth());
// draw the left labels...
if (this.labelGenerator != null) {
drawLeftLabels(leftKeys, g2, plotArea, linkArea, maxLabelWidth, state);
drawRightLabels(rightKeys, g2, plotArea, linkArea, maxLabelWidth, state);
}
g2.setComposite(originalComposite);
}