Message1071
OK, its a little tricky to do Graphics 2D. But here is an example pretty similar to yours in Jython and awt Graphics and Jython with awt Graphics2D. You have to actually do a translation from Graphics to Graphics 2D.
### AWT Graphics ####
import java.awt as awt
import javax.swing as swing
#import java.awt.Graphics2D as G2D
class Drawing(swing.JFrame):
def __init__(self):
swing.JFrame.__init__(self, size=(400, 400), title="Test Frame")
self.setDefaultCloseOperation(swing.JFrame.EXIT_ON_CLOSE)
self.setResizable(False)
self.setLayout(None)
self.validate()
self.setVisible(True)
def paint(self, g):
swing.JFrame.paint(self, g)
g.setColor(awt.Color.orange)
shape = awt.Rectangle(40, 40, 200, 100)
g.fill(shape)
g.stroke = awt.BasicStroke(10)
g.setColor(awt.Color(128, 0, 0))
g.draw(shape)
if __name__ == "__main__":
Drawing()
### AWTGraphics2D #######
import java.awt as awt
import javax.swing as swing
import java.awt.Graphics2D as G2D
class Drawing(swing.JFrame):
def __init__(self):
swing.JFrame.__init__(self, size=(400, 400), title="Test Frame")
self.setDefaultCloseOperation(swing.JFrame.EXIT_ON_CLOSE)
self.setResizable(False)
self.setLayout(None)
self.validate()
self.setVisible(True)
def paint(self, g):
G2D.setPaint( g, swing.JFrame.paint(self, g))
G2D.setColor(g, awt.Color.orange)
G2D.fillRect(g, 40, 40, 200, 100)
G2D.setStroke(g, awt.BasicStroke(1))
G2D.setColor(g, awt.Color(128, 0, 0))
G2D.draw(g, awt.Rectangle(40, 40, 200, 100))
if __name__ == "__main__":
Drawing()
|
|
Date |
User |
Action |
Args |
2008-02-20 17:17:26 | admin | link | issue1337592 messages |
2008-02-20 17:17:26 | admin | create | |
|