graphics2d Questions

3

Solved

I'm trying to write a 2d game engine and I'm trying to implement a viewport system so that when I'm drawing in a certain viewport, the game coordinates will be transformed to the screen coordinates...
Clari asked 17/8, 2016 at 20:3

6

Solved

In my program I want to draw a simple score line graph. I have a text file and on each line is an integer score, which I read in and want to pass as argument to my graph class. I'm having some trou...
Lumbricalis asked 1/1, 2012 at 13:37

3

Solved

I need to draw a ring, with given thickness, that looks something like this: The center must be transparent, so that it doesn't cover previously drawn shapes. (or other rings) I've tried somethi...
Saporous asked 20/2, 2016 at 14:9

2

Solved

Using Graphics2d, I am trying to draw a BufferedImage on top of a background image. At an arbitrary point in this image, I would like to "cut a circular hole" in the drawn image to let the backgrou...
Sectarianize asked 9/1, 2016 at 0:11

2

Solved

I've always created rectangles with outlines like this (using Graphics(2D)): g.setColor(aColor); g.fillRect(x, y, width, height); g.setColor(anotherColor); g.drawRect(x, y, width, height); This ...
Prolate asked 15/9, 2015 at 21:5

2

Solved

I am trying to achieve the following 'grid' layout. The class is extending java.awt.Canvas, and drawing these shapes (or lines) in the paint function. Why Canvas? Check here, trying to do someth...
Woolfolk asked 16/6, 2015 at 7:21

3

Solved

How can I draw an object without a class (which extends JFrame)? I found getGraphics method but it doesnt draw the object. import javax.swing.*; import java.awt.*; public class Main { public stat...
Dame asked 13/4, 2013 at 10:11

1

I have a custom Icon which uses a TexturePaint as paint and calls fillPolygon on a Graphics2D object. This code works fine on JDK6 and JDK7, but fails under JDK8 with 64bit Linux (tried most recen...
Gingivitis asked 29/10, 2014 at 13:44

4

Solved

I am currently attempting to draw images on the screen at a regular rate like in a video game. Unfortunately, because of the rate at which the image is moving, some frames are identical because th...
Woodenhead asked 30/12, 2011 at 6:42

5

In a subclass of a JPanel I am doing this: public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D)g; g2d.rotate(Math.toRadians(90.)); g2d.drawString(aS...
Unreasoning asked 28/1, 2013 at 19:18

4

Solved

I want to rotate text on a JPanel using Graphics2D.. My code is this: double paso=d.width/numeroBarras; double alto=datos[i].valor; Font fBarras=new Font("Serif", Font.PLAIN, 15); g2.setFont(f...
Marston asked 10/4, 2012 at 6:9

4

Solved

It’s easy to determine the rendered height of a font using FontMetrics, but what about the other way around? How can I obtain a font that will fit into a specific height in pixels? "Give me Verd...
Oversew asked 29/4, 2011 at 8:19

1

Solved

My question is that i need to make a GUI that keeps updating becuse i get values that can change from a DB and i got some problems in the graphical area. well im using Drawline and Drawstring from...
Mineralogist asked 21/10, 2014 at 1:23

2

I'm currently trying to implement a 2D shadow casting method in Java by following this tutorial: http://ncase.me/sight-and-light/ I want to stick to Line2D and Polygon objects. Here is the main pa...
Papen asked 31/5, 2014 at 5:56

6

I'm trying to write application which need to draw many strings using Graphics2D class in Java. I need to get sizes of each String object (to calculate exact position of each string). There are so ...
Hedden asked 6/2, 2011 at 15:20

2

Solved

I got the following code: import java.awt.*; import javax.swing.*; public class GraphicPanel extends JPanel { public void paintComponent(Graphics g){ super.paintComponent(g); Graphics2D g2d ...
Bushmaster asked 31/12, 2013 at 20:55

1

Solved

I want to rotate a bitmap about its center point, and then draw it into a larger graphics context. The bitmap is 40x40 pixels. The graphics context is 500x500 pixels. This is what I'm doing: Buff...
Alexandrite asked 4/12, 2013 at 4:55

1

Solved

I've been attempting to make a 2D space-like game using Java just for the fun of it. I've decided just to use Java's Graphics2D to render my game because I wasn't in the mood to learn LWJGL. Howeve...
Dinky asked 25/11, 2013 at 1:45

4

Solved

I want to copy part of one image into another smaller one: in other words, copy a subrectangle. I have a Graphics2D object for the source, I can make one for the target, and I know about targetGr...
Operational asked 6/12, 2010 at 13:59

1

Solved

What is difference between Graphics and Graphics2D? Whether Graphics2D is extend of Graphics? public void paintComponent(Graphics g) { super.paintComponent(g); g.drawRect(25, 25, 20, 20); //use...
Conscious asked 13/10, 2013 at 11:52

3

Solved

I got an extended JLabel class where I draw my Map using the code below : the new AffineTransform() is the identity to left my image as it is (0,0,w,h) mygraphics2D = (Graphics2D) getGraphics(); ...
Natascha asked 6/8, 2012 at 0:42

1

Solved

I'm making a 'game' of sorts where the player has to click on an image bouncing around the screen. The catch is that the screen is in darkness and the mouse cursor is a 'flashlight' which 'light up...
Trihedron asked 22/8, 2013 at 19:9

3

I recently found out that a badge printing program I wrote that has been working fine for years on windows doesn't print correctly on MAC OS X. I am using Arial truetype font. The program seems to ...
Rhodium asked 17/3, 2013 at 20:49

1

Solved

I am working with a group that is looking to target a graphics renderer in Java. I am trying to figure out whether targeting java.awt.Graphics2D will be forward compatible. Namely, can other librar...
Icily asked 12/6, 2013 at 17:43

1

Solved

I am having trouble adjusting line thickness. Can I do that in Graphics or do i have to do it in Graphics2D? If so, how do I alter the program to make it run? Thanks! import java.applet.Ap...
Etheleneethelin asked 8/6, 2013 at 2:6

© 2022 - 2024 — McMap. All rights reserved.