java.awt.geom.Rectangle2D.Double Java Examples

The following examples show how to use java.awt.geom.Rectangle2D.Double. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BuildModeOutline.java    From WorldGrower with GNU General Public License v3.0 6 votes vote down vote up
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);
	}
}
 
Example #2
Source File: SVGTextRenderer.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
@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 );
		}
	}
}
 
Example #3
Source File: BuildModeOutline.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #4
Source File: TreeLayoutTest.java    From treelayout with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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);
	}
}
 
Example #5
Source File: TreeLayoutTest.java    From treelayout with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 + "    ");
	}
}
 
Example #6
Source File: TreeLayoutTest.java    From treelayout with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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());
}
 
Example #7
Source File: DrawVisitorPrintable.java    From Gaalop with GNU Lesser General Public License v3.0 4 votes vote down vote up
public DrawVisitorPrintable(Drawing drawing, Double world) {
    this.drawing = drawing;
    this.world = world;
}
 
Example #8
Source File: TextGrid.java    From jclic with GNU General Public License v2.0 4 votes vote down vote up
public Rectangle2D getCellRect(int px, int py) {
  return new Double(getX() + px * cellWidth, getY() + py * cellHeight, cellWidth, cellHeight);
}
 
Example #9
Source File: ZyGraphNode.java    From binnavi with Apache License 2.0 2 votes vote down vote up
/**
 * Calculates the bounding box of the node.
 *
 * @return The bounding box of the node.
 */
@Override
public Double getBoundingBox() {
  return m_realizer.getBoundingBox();
}
 
Example #10
Source File: IViewableNode.java    From binnavi with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the bounding box of the node.
 * 
 * @return The bounding box of the node.
 */
Double getBoundingBox();
 
Example #11
Source File: IZyNodeRealizer.java    From binnavi with Apache License 2.0 votes vote down vote up
Double getBoundingBox();