private void _update(Graphics2D graphics2D, JComponent jComponent) { GFX ctx = new Java2DGFX(graphics2D); graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); graphics2D.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); graphics2D.setRenderingHint( RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); // graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, // RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); ctx.setPaint(backgroundFill); ctx.fillRect(0, 0, jComponent.getWidth(), jComponent.getHeight()); // draw the scene root.draw(ctx); }
public Java2DWindow(Core core, int width, int height) { this.core = core; this._frame = new JFrame(); this._frame.setSize(width, height); this._frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this._rootcomp = new JComponent() { @Override protected void paintComponent(Graphics graphics) { Graphics2D gfx = (Graphics2D) graphics; _update(gfx, this); } }; this._frame.add(_rootcomp); MasterListener ml = new MasterListener(_rootcomp, this); _rootcomp.addMouseListener(ml); _rootcomp.addMouseMotionListener(ml); _rootcomp.addKeyListener(ml); }
private void fireEvent(String type, Object key, Object e) { window.core.fireEvent(type, key, e); canvas.repaint(); }