pixmapengine.java
来自「JAVA的一些源码 JAVA2 STANDARD EDITION DEVELO」· Java 代码 · 共 548 行 · 第 1/2 页
JAVA
548 行
/* * @(#)PixmapEngine.java 1.14 03/12/19 * * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package com.sun.java.swing.plaf.gtk;import javax.swing.plaf.synth.*;import java.awt.*;import java.security.AccessController;import java.util.*;import javax.swing.*;import sun.security.action.GetPropertyAction;/** * GTKEngine implementation that renders using images. The images to render * are dictated by the <code>PixmapStyle.Info</code>. * * @version 1.14, 12/19/03 * @author Scott Violet */class PixmapEngine extends GTKEngine implements GTKConstants { /** * By default we don't use smooth scaling as it is currently not optimized. */ private static final Object RENDERING_HINT; private int _clipX1; private int _clipX2; private int _clipY1; private int _clipY2; static { if ("true".equals((String)AccessController.doPrivileged( new GetPropertyAction("swing.pixmap.smoothScaling")))) { RENDERING_HINT = RenderingHints.VALUE_INTERPOLATION_BILINEAR; } else { RENDERING_HINT = null; } } public void paintSlider(SynthContext context, Graphics g, int state, int shadowType, String info, int x, int y, int w, int h, int orientation) { if (!paintPixmap(g, x, y, w, h, ((PixmapStyle)context.getStyle()). getInfo("SLIDER", info,state, shadowType, orientation, UNDEFINED, UNDEFINED), true)) { super.paintSlider(context, g, state, shadowType, info, x, y, w, h, orientation); } } public void paintHline(SynthContext context, Graphics g, int state, String info, int x, int y, int w, int h) { if (!paintPixmap(g, x, y, w, h, ((PixmapStyle)context.getStyle()). getInfo("HLINE", info, state, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED), true)) { super.paintHline(context, g, state, info, x, y, w, h); } } public void paintVline(SynthContext context, Graphics g, int state, String info, int x, int y, int w, int h) { if (!paintPixmap(g, x, y, w, h, ((PixmapStyle)context.getStyle()). getInfo("VLINE", info, state, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED), true)) { super.paintVline(context, g, state, info, x, y, w, h); } } public void paintArrow(SynthContext context, Graphics g, int state, int shadowType, int direction, String info, int x, int y, int w, int h) { if (!paintPixmap(g, x, y, w, h, ((PixmapStyle)context.getStyle()). getInfo("ARROW", info, state, shadowType, UNDEFINED, UNDEFINED, direction), true)) { super.paintArrow(context, g, state, shadowType, direction, info, x, y, w, h); } } public void paintBox(SynthContext context, Graphics g, int state, int shadowType, String info, int x, int y, int w, int h) { int orientation; Region id = context.getRegion(); if (id == Region.SCROLL_BAR) { if (((JScrollBar)context.getComponent()).getOrientation() == SwingConstants.HORIZONTAL) { orientation = GTKConstants.HORIZONTAL; } else { orientation = GTKConstants.VERTICAL; } } else if (id == Region.SLIDER_TRACK) { if (((JSlider)context.getComponent()).getOrientation() == SwingConstants.HORIZONTAL) { orientation = GTKConstants.HORIZONTAL; } else { orientation = GTKConstants.VERTICAL; } } else { orientation = UNDEFINED; } if (!paintPixmap(g, x, y, w, h, ((PixmapStyle)context.getStyle()). getInfo("BOX", info, state, shadowType, orientation, UNDEFINED, UNDEFINED), true)) { super.paintBox(context, g, state, shadowType, info, x, y, w, h); } } public void paintBoxGap(SynthContext context, Graphics g, int state, int shadow, String key, int x, int y, int w, int h, int gapSide, int gapStart, int gapSize) { PixmapStyle.Info info = ((PixmapStyle)context.getStyle()).getInfo( "BOX_GAP", key, state, shadow, UNDEFINED, gapSide, UNDEFINED); if (info != null) { // Yes, this appears to paint before the gap does. paintPixmap(g, x, y, w, h, info, true); // Determine the size of the opposite axis of the gap. int size = 0; Image startImage = info.getGapStartImage(); Image image = info.getGapImage(); Image endImage = info.getGapEndImage(); if (gapSide == LEFT || gapSide == RIGHT) { if (startImage != null) { size = startImage.getWidth(null); } else if (image != null) { size = image.getWidth(null); } else if (endImage != null) { size = endImage.getWidth(null); } } else { if (startImage != null) { size = startImage.getHeight(null); } else if (image != null) { size = image.getHeight(null); } else if (endImage != null) { size = endImage.getHeight(null); } } if (size <= 0) { // No matching images. return; } paintGapImage(g, x, y, w, h, startImage, info.getGapStartInsets(), gapSide, size, 0, gapStart); paintGapImage(g, x, y, w, h, image, info.getGapInsets(), gapSide, size, gapStart, gapSize); paintGapImage(g, x, y, w, h, endImage, info.getGapEndInsets(), gapSide, size, gapStart + gapSize, Integer.MAX_VALUE); } else { super.paintBoxGap(context, g, state, shadow, key, x, y, w, h, gapSide, gapStart,gapSize); } } public void paintHandle(SynthContext context, Graphics g, int paintState, int shadowType, String info, int x, int y, int w, int h, int orientation) { if (!paintPixmap(g, x, y, w, h, ((PixmapStyle)context.getStyle()). getInfo("HANDLE", info, paintState, shadowType, orientation, UNDEFINED, UNDEFINED), true)) { super.paintHandle(context, g, paintState, shadowType, info, x, y, w, h, orientation); } } public void paintOption(SynthContext context, Graphics g, int paintState, int shadowType, String info, int x, int y, int w, int h) { if (!paintPixmap(g, x, y, w, h, ((PixmapStyle)context.getStyle()). getInfo("OPTION", info, paintState, shadowType, UNDEFINED, UNDEFINED, UNDEFINED), true)) { super.paintOption(context, g, paintState, shadowType, info, x, y, w, h); } } public void paintFocus(SynthContext context, Graphics g, int state, String key, int x, int y, int w, int h) { if (!paintPixmap(g, x, y, w, h, ((PixmapStyle)context.getStyle()). getInfo( "FOCUS", key, state, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED), true)) { super.paintFocus(context, g, state, key, x, y, w, h); } } public void paintShadow(SynthContext context, Graphics g, int state, int shadowType, String info, int x, int y, int w, int h) { if (!paintPixmap(g, x, y, w, h, ((PixmapStyle)context.getStyle()). getInfo("SHADOW", info, state, shadowType, UNDEFINED, UNDEFINED, UNDEFINED), false)) { super.paintShadow(context, g, state, shadowType, info, x, y, w, h); } } public void paintExpander(SynthContext context, Graphics g, int state, int expanderStyle, String info, int x, int y, int w, int h) { // It does not appear that there is a way to override this. super.paintExpander(context, g, state, expanderStyle, info, x, y, w,h); } public void paintCheck(SynthContext context, Graphics g, int state, int shadowType, String info, int x, int y, int w, int h) { if (!paintPixmap(g, x, y, w, h, ((PixmapStyle)context.getStyle()). getInfo("CHECK", info, state, shadowType, UNDEFINED, UNDEFINED, UNDEFINED), true)) { super.paintCheck(context, g, state, shadowType, info, x, y, w, h); } } public void paintExtension(SynthContext context, Graphics g, int state, int shadowType, String info, int x, int y, int w, int h, int placement, int tabIndex) { if (!paintPixmap(g, x, y, w, h, ((PixmapStyle)context.getStyle()). getInfo("EXTENSION", info, state, shadowType, UNDEFINED, placement, UNDEFINED), true)) { super.paintExtension(context, g, state, shadowType, info, x, y, w, h, placement, tabIndex); } } public void paintFlatBox(SynthContext context, Graphics g, int state, String key, int x, int y, int w, int h) { if (!paintPixmap(g, x, y, w, h, ((PixmapStyle)context.getStyle()). getInfo("FLAT_BOX", key, state, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED), true)) { super.paintFlatBox(context, g, state, key, x, y, w, h); } } /** * Paints a gap image. This renders the image into a portion of * the passed in region that is dictated * by the <code>gapSide</code> and <code>size</code> arguments. For * example, if <code>gapSide</code> is <code>GTKConstants.TOP</code>, * this will render the image into the space: * <table> * <tr><td>x origin<td> <code>x</code> + <code>gapStart</code> * <tr><td>y origin<td> <code>y</code> * <tr><td>width<td> <code>gapSize</code> * <tr><td>height<td> <code>size</code> * </table> * * @param g Graphics object to paint to * @param x X origin * @param y Y origin * @param w Width to draw to * @param h Height to draw to * @param image Image to paint * @param insets Insets dicatating fixed portion and scaled portion of * the image. * @param gapSide Side the gap is on, one of GTKConstants.LEFT,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?