List of utility methods to do Graphics Settings
GraphicsConfiguration | getTransparentGraphicsConfiguration() get Transparent Graphics Configuration try { Class<?> awtUtilitiesType = Class.forName("com.sun.awt.AWTUtilities"); Method isTC = awtUtilitiesType.getMethod("isTranslucencyCapable", new Class[] { GraphicsConfiguration.class }); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = env.getScreenDevices(); GraphicsConfiguration translucencyCapableGC = null; for (int i = 0; (i < devices.length) && (translucencyCapableGC == null); ++i) { ... |
void | gradientFillShape(Graphics2D g, Color startColor, Color endColor, Shape shape) gradient Fill Shape initializeGraphics2D(g); GradientPaint gp = getGradientPaint(startColor, endColor, shape); g.setPaint(gp); g.fill(shape); |
void | gradientPaint(Graphics2D g2d, Point2D startPosition, Color startColor, Point2D endPosition, Color endColor, int sx, int sy, int ex, int ey) gradient Paint GradientPaint gradient = new GradientPaint(startPosition, startColor, endPosition, endColor, true);
g2d.setPaint(gradient);
g2d.fillRect(sx, sy, ex, ey);
|
void | setClip(Graphics g, Rectangle clipBounds) set Clip Rectangle currentClipBounds; clipBounds = new Rectangle(clipBounds); clipBounds.width += 1; clipBounds.height += 1; currentClipBounds = g.getClipBounds(); if (currentClipBounds != null) { clipBounds = clipBounds.intersection(g.getClipBounds()); clipBoundsStack.push(currentClipBounds); g.setClip(clipBounds); |
void | setRenderingHints(Graphics2D g) set optimal rendering g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); g.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE); g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); ... |
void | setRenderingHints(Graphics2D g2d) set Rendering Hints RenderingHints rh = g2d.getRenderingHints(); rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2d.setRenderingHints(rh); |
void | setTextRenderingHints(Graphics2D g2d) set Text Rendering Hints RenderingHints rh = new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); rh.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); rh.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); rh.put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF); rh.put(RenderingHints.KEY_TEXT_LCD_CONTRAST, new Integer(140)); rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_DEFAULT); ... |
void | setupGraphics(Graphics2D pG2d) setup Graphics pG2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); pG2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); pG2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED); pG2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); pG2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED); pG2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE); ... |