Java 2D Graphics Dimension d = getSize(); int
Java 2D Graphics Dimension d = getSize(); int cx = d.width / 2; int cy = d.height / 2; g2.translate(cx, cy); if (mShear) g2.shear(mShearX, mShearY); if (mRotate) g2.rotate(mTheta); g2.translate(-cx, -cy); } protected void setPaint(Graphics2D g2) { if (mGradient) { GradientPaint gp = new GradientPaint(0, 0, Color.blue, 50, 25, Color.green, true); g2.setPaint(gp); } else g2.setPaint(Color.orange); } protected void drawAxes(Graphics2D g2) { if (mAxes == false) return; g2.setPaint(getForeground()); g2.setStroke(new BasicStroke()); Dimension d = getSize(); int side = 20; int arrow = 4; int w = d.width / 2, h = d.height / 2; g2.drawLine(w - side, h, w + side, h); g2.drawLine(w + side - arrow, h - arrow, w + side, h); g2.drawLine(w, h - side, w, h + side); g2.drawLine(w + arrow, h + side - arrow, w, h + side); } } Table 14-2 summarizes some relevant frame rates for TextBouncer, as measured on my computer. Table 14-2, Frame Rules for TextBouncer Antialiasing Gradient Shear Rotate Axes Font Frame Rate (fps) Arial 94 x Arial 82 x x Arial 73 x x x Arial 29 x x x Arial 66 x x x x Arial 28 x x x x x Arial 32 x x x x x Times New Roman 36 x x x x x Lucida Bright Regular 32 What can you learn from this application? The results of this application are counter-intuitive: Using the gradient paint actually speeds things up when antialiasing is being used. The font used is significant, especially with complex rendering. Although you might expect serif fonts like Times New Roman to be slower than sans serif fonts, this is not the case. Although the shearing transformation costs very little, the rotation is expensive. Remember, performance is likely to vary from one system to another and from one release to another. I suggest you try these applications out for yourself. page 266
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services