Java 类java.awt.geom.Rectangle2D.Double 实例源码
项目:WorldGrower
文件:BuildModeOutline.java
public void repaintBuildMode(Graphics g, MouseLocationProvider mouseLocationProvider, int offsetX, int offsetY, WorldObject playerCharacter, World world) {
if (buildMode) {
Graphics2D g2 = (Graphics2D) g;
Point mouseLocation = mouseLocationProvider.getMouseLocation();
Double rectangleToDraw = getRectangleToDraw(mouseLocation);
final Color color;
WorldObject buildLocation = getBuildLocation(mouseLocation, offsetX, offsetY);
if (isbuildActionPossible(playerCharacter, world, buildLocation)) {
color = Color.GREEN;
g.drawImage(okImage, (int)rectangleToDraw.x, (int)rectangleToDraw.getY(), null);
} else {
color = Color.RED;
g.drawImage(notOkImage, (int)rectangleToDraw.x, (int)rectangleToDraw.getY(), null);
}
g2.setColor(color);
g2.draw(rectangleToDraw);
}
}
项目:SmartTokens
文件:GUIUtils.java
/**
*
*/
public static Image roundImage(Image source, int radius, float alpha) {
if (source == null)
return null;
int width = source.getWidth(null);
int height = source.getHeight(null);
BufferedImage src = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
Graphics2D g = (Graphics2D) src.getGraphics();
g.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
Rectangle2D.Double rect = new Rectangle2D.Double(0, 0, width, height);
g.fill(rect);
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
alpha));
g.clip(new RoundRectangle2D.Float(0, 0, width - 1, height - 1, radius,
radius));
g.drawImage(source, 0, 0, null);
return src;
}
项目:birt
文件:SVGTextRenderer.java
@Override
protected void renderOutline( IPrimitiveRenderer renderer,
LineAttributes lineAttribs, Double rect )
{
if ( lineAttribs != null
&& lineAttribs.isVisible( )
&& lineAttribs.getColor( ) != null )
{
SVGGraphics2D g2d = (SVGGraphics2D) ( (IDeviceRenderer) renderer ).getGraphicsContext( );
Stroke sPrevious = null;
final ColorDefinition cd = lineAttribs.getColor( );
final Stroke sCurrent = ( (SVGRendererImpl) renderer ).getCachedStroke( lineAttribs );
if ( sCurrent != null ) // SOME STROKE DEFINED?
{
sPrevious = g2d.getStroke( );
g2d.setStroke( sCurrent );
}
g2d.setColor( (Color) _sxs.getColor( cd ) );
g2d.draw( rect );
g2d.setNoFillColor( g2d.getCurrentElement( ) );
if ( sPrevious != null ) // RESTORE PREVIOUS STROKE
{
g2d.setStroke( sPrevious );
}
}
}
项目:com.opendoorlogistics
文件:QuadBlockBuilder.java
public void split(SplitRule splitRule){
children = new QuadBlock[4];
double hw = bounds.width * 0.5;
double hh = bounds.height * 0.5;
int indx=0;
for(int ix = 0 ; ix<=1 ; ix++){
for(int iy = 0 ; iy<=1 ; iy++){
children[indx++] = new QuadBlock(new Rectangle2D.Double(bounds.x + ix*hw, bounds.y + iy*hh, hw, hh));
}
}
// add to children
for(PendingWrite pw:leaves){
findChild(pw).addWrite(pw, splitRule);
}
leaves = null;
leafBytesCount=0;
}
项目:JavaTracer
文件:TreeInspectorPresenter.java
public Box clickedOnTree(Point clickPoint) {
Box textInBoxExt = null;
boolean clickedOnNode = false;
Set<Entry<Box, Double>> nodes = view.getNodeBounds().entrySet();
Iterator<Entry<Box,Double>> iterator = nodes.iterator();
while (iterator.hasNext() && !clickedOnNode){
Entry<Box,Double> entry = iterator.next();
Double rec = entry.getValue();
if (rec.contains(clickPoint)) {
textInBoxExt = (Box)entry.getKey();
clickedOnNode = true;
}
}
return textInBoxExt;
}
项目:DarwinSPL
文件:DwFeatureTreeLayouter.java
public Rectangle getBounds(DwFeatureWrapped feature) {
Rectangle2D.Double nodeBounds = getNodeBounds(feature);
try{
Rectangle result = DEGeometryUtil.rectangle2DToDraw2DRectangle(nodeBounds);
return result;
}catch(NullPointerException e){
e.printStackTrace();
}
return null;
}
项目:DarwinSPL
文件:DwVersionTreeLayouter.java
private Rectangle2D.Double getNodeBounds(HyVersion version) {
Map<HyVersion, Double> elements = treeLayout.getNodeBounds();
Rectangle2D.Double nodeBounds = elements.get(version);
if(nodeBounds == null){
return new Rectangle2D.Double(0, 0, 50, 50);
}
return adjustNodeBounds(nodeBounds, version);
}
项目:WorldGrower
文件:BuildModeOutline.java
private Rectangle2D.Double getRectangleToDraw(Point mouseLocation) {
int x = ((mouseLocation.x) / 48) * 48;
int y = ((mouseLocation.y) / 48) * 48;
int width = buildAction.getWidth() * 48;
int height = buildAction.getHeight() * 48;
return new Rectangle2D.Double(x, y, width, height);
}
项目:treelayout
文件:TreeLayoutTest.java
private static void appendDescription(StringBuilder sb,
StringTreeNode node,
Map<StringTreeNode, Rectangle2D.Double> nodeBounds) {
Rectangle2D rect = nodeBounds.get(node);
sb.append(String.format("%s @ %d,%d (%dx%d)\n", node.getText(),
(int) rect.getX(), (int) rect.getY(), (int) rect.getWidth(),
(int) rect.getHeight()));
for (StringTreeNode child : node.getChildren()) {
appendDescription(sb, child, nodeBounds);
}
}
项目:treelayout
文件:TreeLayoutTest.java
public static void dump(StringTreeNode node,
Map<StringTreeNode, Rectangle2D.Double> nodeBounds, String prefix) {
Rectangle2D rect = nodeBounds.get(node);
System.out.println(String.format("%s%s @ %d,%d (%dx%d)", prefix,
node.getText(), (int) rect.getX(), (int) rect.getY(),
(int) rect.getWidth(), (int) rect.getHeight()));
for (StringTreeNode child : node.getChildren()) {
dump(child, nodeBounds, prefix + " ");
}
}
项目:treelayout
文件:TreeLayoutTest.java
@Test
public void testGetNodeBoundsIsCached() {
StringTreeNode root = new StringTreeNode("root");
StringTreeAsTreeForTreeLayout tree = new StringTreeAsTreeForTreeLayout(
root);
FixedNodeExtentProvider<StringTreeNode> nodeExtentProvider = new FixedNodeExtentProvider<StringTreeNode>();
DefaultConfiguration<StringTreeNode> config = new DefaultConfiguration<StringTreeNode>(
10, 20);
TreeLayout<StringTreeNode> layout = new TreeLayout<StringTreeNode>(
tree, nodeExtentProvider, config);
Map<StringTreeNode, Double> nodeBounds = layout.getNodeBounds();
assertEquals(nodeBounds, layout.getNodeBounds());
}
项目:SmartTokens
文件:GUIUtils.java
/**
* Clears an image (makes it totally transparent)
*/
public static Image createTransparentImage(int width, int height) {
BufferedImage im = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
Graphics2D g2D = im.createGraphics();
g2D
.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR,
0.0f));
Rectangle2D.Double rect = new Rectangle2D.Double(0, 0, width, height);
g2D.fill(rect);
return im;
}
项目:SmartTokens
文件:GUIUtils.java
public static void drawPie (Graphics2D g, Rectangle2D.Double tmpRect, Slice[] slices, double holeRadius) {
double total = 0.0D;
for (int i = 0; i < slices.length; i++) {
total += slices[i].value;
}
double curValue = 0.0D;
double startAngle = 0;
Area hole = null;
if (holeRadius > 0) {
// compute hole
tmpellipse.setFrame(tmpRect.getCenterX() - holeRadius, tmpRect.getCenterY() - holeRadius, holeRadius*2, holeRadius*2);
hole = new Area(tmpellipse);
}
for (int i = 0; i < slices.length; i++) {
Shape pieShape;
startAngle = curValue * 360.0 / total;
double arcAngle = slices[i].value * 360.0 / total;
g.setColor(slices[i].color);
tmparc.setArc(tmpRect.x, tmpRect.y, tmpRect.width, tmpRect.height, startAngle, arcAngle, Arc2D.PIE);
if (hole != null) {
Area area = new Area(tmparc);
area.subtract(hole);
pieShape = area;
} else {
pieShape = tmparc;
}
g.fill(pieShape);
curValue += slices[i].value;
}
}
项目:KinoSim
文件:TheatreMap.java
private Map<Room, Rectangle2D.Double> getRooms(final double totalEdgeLengthInMeters) {
final Map<Room, Rectangle2D.Double> roomOutlines = new HashMap<>();
final Queue<Room> roomsBySize = new PriorityQueue<>((r1, r2) -> java.lang.Double.compare(r2.getAllocatedSpace(), r1.getAllocatedSpace()));
roomsBySize.addAll(theater.getRooms());
Point2D.Double rowBounds = new Point2D.Double(0.0, totalEdgeLengthInMeters);
int row = 0;
while (!roomsBySize.isEmpty()) {
rowBounds = createRoomsForRow(totalEdgeLengthInMeters, roomsBySize, roomOutlines, rowBounds.x, rowBounds.y, row % 2 == 0);
row++;
}
assert roomsBySize.isEmpty() : "all rooms must have their space!";
return roomOutlines;
}
项目:XPressOnTechnologies
文件:PDFNetRect.java
@Override
public void set(Rectangle2D.Double rect) throws PDFLibException {
try {
m_Rect = new Rect(rect);
set(m_Rect);
} catch (PDFNetException ex) {
throw PDFNetUtil.newPDFLibException(ex);
}
}
项目:XPressOnTechnologies
文件:PDFNetRect.java
@Override
public Double getRectangle() throws PDFLibException {
try {
return m_Rect.getRectangle();
} catch (PDFNetException ex) {
throw PDFNetUtil.newPDFLibException(ex);
}
}
项目:Calico
文件:PieMenuContainer.java
/**
* This paints the pie slices
*/
protected void paint(PPaintContext paintContext)
{
Graphics2D graphics = (Graphics2D)paintContext.getGraphics();
graphics.setStroke(new BasicStroke(1.0f));
double degIncrement = Math.min(360.0 / (PieMenu.buttonList.size()), PieMenu.DEFAULT_DEGREE_INCREMENT);
int max = (int)(360.0 / degIncrement);
Rectangle2D buttonBounds = this.getBounds();
Rectangle circleBounds = new Rectangle((int)buttonBounds.getX(), (int)buttonBounds.getY(), (int)buttonBounds.getWidth(), (int)buttonBounds.getHeight());
double innerRadius = circleBounds.getWidth()/6;
Ellipse2D.Double circle = new Ellipse2D.Double(circleBounds.getX() + circleBounds.getWidth()/2 - innerRadius, circleBounds.getY() + circleBounds.getHeight()/2 - innerRadius,
innerRadius * 2, innerRadius * 2);
RadialGradientPaint rgp = new RadialGradientPaint((float)circleBounds.getCenterX(), (float)circleBounds.getCenterY(), (float)circleBounds.width/2, new float[] { 0.0f, 0.8f, 0.95f, 1.0f }, new Color[] {Color.white, new Color(205, 201, 201), new Color(205, 201, 201), Color.gray});
for (int i = 0; i < max; i++)
{
graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.9f));
graphics.setPaint(rgp);
Arc2D.Double arc = new Arc2D.Double(circleBounds, PieMenu.START_ANGLE + degIncrement*i, degIncrement, Arc2D.PIE);
Area arcArea = new Area(arc);
arcArea.subtract(new Area(circle));
graphics.fill(arcArea);
graphics.setPaint(Color.gray);
graphics.draw(arcArea);
}
graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
}
项目:DarwinSPL
文件:DwFeatureTreeLayouter.java
/**
* @return A point representing the upper left point of the rectangle representing the bounds.
*/
public Point getCoordinates(DwFeatureWrapped feature) {
Rectangle2D.Double nodeBounds = getNodeBounds(feature);
return new Point((int) nodeBounds.getX(), (int) nodeBounds.getY());
}
项目:DarwinSPL
文件:DwFeatureTreeLayouter.java
private Rectangle2D.Double adjustNodeBounds(Rectangle2D.Double nodeBounds, DwFeatureWrapped feature) {
try{
Rectangle2D.Double adjustedNodeBounds = (Rectangle2D.Double) nodeBounds.clone();
adjustedNodeBounds.x += offsetX;
adjustedNodeBounds.y += offsetY;
return adjustedNodeBounds;
}catch(NullPointerException e){
e.printStackTrace();
}
return null;
}
项目:DarwinSPL
文件:DwFeatureTreeLayouter.java
private Rectangle2D.Double getNodeBounds(DwFeatureWrapped feature) {
Map<DwFeatureWrapped, Double> elements = treeLayout.getNodeBounds();
Rectangle2D.Double nodeBounds = elements.get(feature);
return adjustNodeBounds(nodeBounds, feature);
}
项目:DarwinSPL
文件:DwVersionTreeLayouter.java
/**
* @return A point representing the upper left point of the rectangle representing the bounds.
*/
public Point getCoordinates(HyVersion version) {
Rectangle2D.Double nodeBounds = getNodeBounds(version);
return new Point((int) nodeBounds.getX(), (int) nodeBounds.getY());
}
项目:DarwinSPL
文件:DwVersionTreeLayouter.java
public Rectangle getBounds(HyVersion version) {
Rectangle2D.Double nodeBounds = getNodeBounds(version);
return DEGeometryUtil.rectangle2DToDraw2DRectangle(nodeBounds);
}
项目:DAtools
文件:SitePosition.java
public SitePosition(Rectangle2D.Double rec, int site) {
/* 29 */ this.rec = rec;
/* 30 */ this.sitePos = site;
/* */ }
项目:DAtools
文件:SitePosition.java
public Rectangle2D.Double getRec()
/* */ {
/* 41 */ return this.rec;
/* */ }
项目:DAtools
文件:SitePosition.java
public void setRec(Rectangle2D.Double rec) {
/* 45 */ this.rec = rec;
/* */ }
项目:Gaalop
文件:DrawVisitorPrintable.java
public DrawVisitorPrintable(Drawing drawing, Double world) {
this.drawing = drawing;
this.world = world;
}
项目:SmartTokens
文件:GUIUtils.java
public static Rectangle2D growRectangle(Rectangle2D rec, double amount_x, double amount_y) {
return new Rectangle2D.Double(rec.getX() - amount_x/2, rec.getY() - amount_y/2, rec.getWidth() + amount_x, rec.getHeight() + amount_y);
}
项目:SmartTokens
文件:GUIUtils.java
public static Rectangle2D growAndTranslateRectangle(Rectangle2D rec, double dx, double dy, double amount_x, double amount_y) {
return new Rectangle2D.Double(rec.getX() - amount_x/2 + dx, rec.getY() - amount_y/2 + dy, rec.getWidth() + amount_x, rec.getHeight() + amount_y);
}
项目:TASCA
文件:ProgressBar.java
private void drawRectangle() {
rectangle = new Rectangle2D.Double(this.xCoordinate , this.yCoordinate, INITIAL_WIDTH_BAR, INITIAL_HEIGHT_BAR);
}
项目:KinoSim
文件:TheatreMap.java
/** @return remaining space between minY and maxY which was not used **/
private Point2D.Double createRoomsForRow(final double totalWidthInMeters, final Queue<Room> roomsBySize,
final Map<Room, Rectangle2D.Double> roomOutlines, final double minY, final double maxY, final boolean publicTopLeft) {
double leftXInMeters = 0;
double rightXInMeters = totalWidthInMeters;
double rowMinY = totalWidthInMeters;
double rowMaxY = 0;
while (!roomsBySize.isEmpty()) {
final Room room = roomsBySize.remove();
if (RoomType.Foyer == room.getType()) {
// foyer uses the free space between the other rooms
continue;
}
final double squareEdgeLength = Math.sqrt(room.getAllocatedSpace());
final double width = Randomness.getGaussianAround(squareEdgeLength);
final double height = room.getAllocatedSpace() / width;
final double x = (room.getType().isPublicAccessible() ^ publicTopLeft) ? rightXInMeters - width : leftXInMeters;
if (x < leftXInMeters || x + width > rightXInMeters + 0.01) { // allow some double incorrectness
roomsBySize.add(room);
break;
}
final double y;
if (publicTopLeft) {
y = minY;
} else {
y = maxY - height;
}
final Rectangle2D.Double square = new Double(x, y, width, height);
roomOutlines.put(room, square);
rowMinY = Math.min(square.y, rowMinY);
rowMaxY = Math.max(square.y + square.height, rowMaxY);
if (room.getType().isPublicAccessible() ^ publicTopLeft) {
rightXInMeters -= width;
} else {
leftXInMeters += width;
}
}
if (publicTopLeft) {
// used some space on top (decreasing upper bound)
return new Point2D.Double(rowMaxY, maxY);
} else {
// used some space on bottom (raising lower bound)
return new Point2D.Double(minY, rowMinY);
}
}
项目:com.opendoorlogistics
文件:QuadBlockBuilder.java
public QuadBlock build(Iterable<PendingWrite> writes, TileFactoryInfo info, final int zoom){
// calculate all centroids
WKBReader reader = new WKBReader();
for(PendingWrite pw:writes){
try {
Geometry g = reader.read(pw.geomBytes);
pw.centroid= g.getCentroid();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
// get bounds
Rectangle2D.Double mapBounds=null;
if(zoom<0){
// WGS84
mapBounds = new Rectangle2D.Double(-180, -90, 360, 180);
}else{
// Map tile
Dimension dim = GeoUtil.getMapSize(zoom, info);
double h = (double)dim.height * info.getTileSize(zoom);
double w = (double)dim.width * info.getTileSize(zoom);
Point2D centre = info.getMapCenterInPixelsAtZoom(zoom);
mapBounds = new Rectangle2D.Double(centre.getX() - w/2, centre.getY() - h/2, w, h);
}
QuadBlock root = new QuadBlock(mapBounds);
SplitRule splitRule = new SplitRule() {
@Override
public boolean isSplit(QuadBlock block, PendingWrite newPending) {
if(zoom>=0){
// don't split beyond the minimum on-screen size as we will typically want to load this all at once
if(block.bounds.getWidth() / 2 < MIN_SIZE_PIXELS || block.bounds.getHeight() < MIN_SIZE_PIXELS){
return false;
}
}
// never split an empty leaf
if(block.getNbLeaves()==0){
return false;
}
// don't split if block will still be under the minimum size in uncompressed bytes
long newNbBytes = block.leafBytesCount + newPending.geomBytes.length;
if(newNbBytes < MIN_SIZE_BYTES){
return false;
}
// split if new size is over max limit
if(newNbBytes > MAX_SIZE_BYTES){
return true;
}
return false;
}
};
// add all
for(PendingWrite write:writes){
root.addWrite(write, splitRule);
}
// System.out.println("Built zoom " + zoom + " quadtree: " + root.getSummary());
return root;
}
项目:com.opendoorlogistics
文件:QuadBlockBuilder.java
public QuadBlock(Double bounds) {
this.bounds = bounds;
}
项目:jclic
文件:TextGrid.java
public Rectangle2D getCellRect(int px, int py){
return new Double(getX()+px*cellWidth, getY()+py*cellHeight, cellWidth, cellHeight);
}
项目:JavaTracer
文件:TreeInspectorView.java
public Map<Box, Double> getNodeBounds() {
return getTreeLayout().getNodeBounds();
}
项目:DarwinSPL
文件:DwVersionTreeLayouter.java
private Rectangle2D.Double adjustNodeBounds(Rectangle2D.Double nodeBounds, HyVersion version) {
Rectangle2D.Double adjustedNodeBounds = (Rectangle2D.Double) nodeBounds.clone();
adjustedNodeBounds.x += calculateOffsetX();
adjustedNodeBounds.y += calculateOffsetY();
return adjustedNodeBounds;
}
项目:Calico
文件:PieMenuContainer.java
public static Rectangle2D getComputedBounds()
{
double radius = PieMenu.getMinimumRadius(PieMenu.DEFAULT_MENU_RADIUS, PieMenu.buttonList.size());
// double edge = Math.max(rect.getWidth(), rect.getHeight());
Point center = PieMenu.lastOpenedPosition;
double newX = center.x - radius;
double newY = center.y - radius;
Rectangle2D rectWithPadding = new Rectangle2D.Double(newX - circleBuffer, newY - circleBuffer, radius * 2 + circleBuffer*2, radius * 2 + circleBuffer*2);
return rectWithPadding;
}
项目:binnavi
文件:ZyGraphNode.java
/**
* Calculates the bounding box of the node.
*
* @return The bounding box of the node.
*/
@Override
public Double getBoundingBox() {
return m_realizer.getBoundingBox();
}
项目:binnavi
文件:IViewableNode.java
/**
* Returns the bounding box of the node.
*
* @return The bounding box of the node.
*/
Double getBoundingBox();
项目:binnavi
文件:IZyNodeRealizer.java
Double getBoundingBox();
项目:JavaTracer
文件:TreeInspectorViewInterface.java
Map<Box, Double> getNodeBounds();