java-2d

Java2D Unacceptable Frame Rate

前提是你 提交于 2019-12-11 09:19:59
问题 Java2D Game Running 20-30 FPS I am writing a java2D game that as of now has an almost perfect memory footprint running only at around 2% of about a 4GB usable RAM space. The problem is the game only is running at around 20-30 fps just from rendering the character and the surrounding environment. I read already something about utilizing the GraphicsConfiguration, but when I tried that my fps soared right up to 120-130 fps while my memory increased to 70-80% and the frame was frozen in one

Java Game - ClassCastException

Deadly 提交于 2019-12-11 08:22:57
问题 I am developing a simple java game and my scrollbar is raising an exception. The scrollbar is supposed to be a "gameslider". Exception in thread "Thread-3" java.lang.ClassCastException: sun.java2d.NullSurfaceData cannot be cast to sun.java2d.d3d.D3DSurfaceData at sun.java2d.d3d.D3DRenderer.copyArea(Unknown Source) at sun.java2d.d3d.D3DSurfaceData.copyArea(Unknown Source) at sun.java2d.SunGraphics2D.doCopyArea(Unknown Source) at sun.java2d.SunGraphics2D.copyArea(Unknown Source) at javax.swing

Minimal way to make a cleanable drawing area

僤鯓⒐⒋嵵緔 提交于 2019-12-11 06:43:38
问题 I got a class with a resizable background. There are paintings over that background(using a paint method and Java2D). How can i delete everything that was drawn every time that the background gets a resize? (To eventually draw again in the correct places) Is there any sort of transform i can do on the already-drawn objects(like scaling to fit the image again)? import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.geom.AffineTransform; import

Area generation not liking straight lines

Deadly 提交于 2019-12-11 04:59:35
问题 I'm using the area generation and drawing code from Smoothing a jagged path to create collision areas for tile sprites in a JRPG game I'm making in java - Its not a major full blown game, more just a proof-of-concept for me to learn from. The area generation works fine except for straight lines: http://puu.sh/7wJA2.png http://puu.sh/7wJGF.png These images are of the collision outline opened in photoshop (in the background) vs the area that the java code is generating based on the red color

JAI: How to convert 4-band 32-bits CMYK image into PNG?

拟墨画扇 提交于 2019-12-11 04:48:32
问题 I'm trying to convert a image into PNG format, the data I have is a 4-band 32-bits TIFF-like image compressed by LZW. By using Java2D and JAI now I have data uncompressed to represent colors in CMYK space and it can be exported and viewed when stored in tiff with the same settings as 4 band 32-bit format. The problem is when I try converting to other formats like PNG it produce zero-sized data, so I'd like to ask is there anyone have similar experience on converting such image? I have some of

JFreeChart StackedBarChart

∥☆過路亽.° 提交于 2019-12-11 04:47:00
问题 I am drawing a stackedbarchart. Now for the x-axis i have labels which are auto generated based on CategoryDataset. I want to show these labels with intervals because otherwise they are overlapped in case i have large number of values for the dataset. But I am not able to understand how to achieve this. For example i have this following code. CategoryDataset dataset = getDataset(); final JFreeChart chart = ChartFactory.createStackedBarChart( graphTitle, xAxisTitle, yAxisTitle, dataset,

Why is java application running smoother when moving mouse over it? Video included

家住魔仙堡 提交于 2019-12-11 03:37:27
问题 I'm working with tutorial from this site - "Fixed timestep" section. Here's the code - http://pastebin.com/QaHgcLaR import javax.swing.*; import java.awt.*; import java.awt.event.*; public class GameLoopTest extends JFrame implements ActionListener { private GamePanel gamePanel = new GamePanel(); private JButton startButton = new JButton("Start"); private JButton quitButton = new JButton("Quit"); private JButton pauseButton = new JButton("Pause"); private boolean running = false; private

Can not draw oval on a JPanel

故事扮演 提交于 2019-12-11 03:24:52
问题 I have a JFrame created with GUI builder of Netbeans, which contains a JPanel only. I have created a method getPanel for getting a reference to this JPanel: public class ShowDrawings extends JFrame { public ShowDrawings() { initComponents(); } public JPanel getPanel(){ return panel; } private JPanel panel; } In my main function I am doing: public class Main { public static void main(String[] args){ ShowDrawings sd = new ShowDrawings(); sd.setSize(800, 600); Graphics g = sd.getPanel()

Force full redraw of a Jpanel Java2D

不打扰是莪最后的温柔 提交于 2019-12-11 03:09:16
问题 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 Graphics2D that print values that are found on the database, this strings and lines move and change value, so i need to call repaint(); with a timer to make them apper in the jpanel, the problem is that repaint(); is not removing the old painting in the background before painting, but when i resize

How Ellipse to Ellipse intersection?

谁说我不能喝 提交于 2019-12-11 00:46:23
问题 I'm using JAVA. Ellipse2D s1=new Ellipse2D.Float(0,0,100,100); System.out.println(s1.intersects(99, 30, 100, 100)); Should return false but it return true. How to find intersection between 2 ellipse? Thx 回答1: CADEMIA has an useful api which can be downloaded from here. The class cib.util.geo.Geo2D has a method Geo2D#intersection which calculates the intersection points between two ellipses. Hope this will help you. Thanks. 来源: https://stackoverflow.com/questions/6544441/how-ellipse-to-ellipse