1:
8:
9: package ;
10:
11: import ;
12:
13:
38: public final class Visual
39: {
40: public static final int VC_STATIC_GRAY = 0,
41: VC_GRAY_SCALE = 1,
42: VC_STATIC_COLOR = 2,
43: VC_PSEUDO_COLOR = 3,
44: VC_TRUE_COLOR = 4,
45: VC_DIRECT_COLOR = 5;
46:
47: protected static final int MASK_ID = 1 << 0,
48: MASK_SCREEN = 1 << 1,
49: MASK_DEPTH = 1 << 2,
50: MASK_CLASS = 1 << 3,
51: MASK_RED = 1 << 4,
52: MASK_GREEN = 1 << 5,
53: MASK_BLUE = 1 << 6,
54: MASK_COLORMAP_SIZE = 1 << 7,
55: MASK_BITS_PER_RGB = 1 << 8;
56:
57: protected static final int MASK_ALL = MASK_ID
58: | MASK_SCREEN
59: | MASK_DEPTH
60: | MASK_CLASS
61: | MASK_RED
62: | MASK_GREEN
63: | MASK_BLUE
64: | MASK_COLORMAP_SIZE
65: | MASK_BITS_PER_RGB;
66:
67: private static final int MASK_VISUAL_STRUCTURE = 1 << 31;
68:
69: Display display;
70: RawData xVisualInfo;
71: int infoMask;
72: Screen screen;
73:
74: Visual(RawData structure, Screen screen, int depth )
75: {
76: this.display = screen.getDisplay();
77: this.screen = screen;
78: init(structure, depth);
79: }
80:
81: Visual(Display display, RawData structure, int depth )
82: {
83: this.display = display;
84: init(structure, depth);
85: }
86:
87: protected native void init(RawData structure, int depth);
88:
89: protected native void finalize();
90:
91:
99: native RawData getVisualStructure();
100:
101:
102:
103:
104: public native int getRedMask();
105: public native int getGreenMask();
106: public native int getBlueMask();
107:
108: public native int getScreenNumber();
109: public native int getDepth();
110:
111: public Screen getScreen()
112: {
113: if (screen == null)
114: screen = new Screen(display, getScreenNumber());
115: return screen;
116: }
117:
118: public native int getVisualClass();
119:
120: public boolean hasRGBSubfields()
121: {
122: switch (getVisualClass())
123: {
124: case VC_TRUE_COLOR:
125: case VC_DIRECT_COLOR:
126: return true;
127: default:
128: return false;
129: }
130: }
131:
132: protected native void ensureXVisualInfo(int requiredMask);
133:
134:
135: public String toString()
136: {
137: int missingInfo = ~infoMask;
138: boolean hasSubfieldInfo =
139: (missingInfo & (MASK_CLASS|MASK_RED|MASK_GREEN|MASK_BLUE)) == 0;
140:
141: boolean hasDepth = (missingInfo & MASK_DEPTH) == 0;
142:
143: return getClass().getName() + "[" +
144: (hasDepth ? "depth=" + getDepth() : "") +
145: (hasRGBSubfields() ?
146: (", redMask=" + Integer.toHexString(getRedMask()) +
147: ", greenMask=" + Integer.toHexString(getGreenMask()) +
148: ", blueMask=" + Integer.toHexString(getBlueMask())) :
149: ", no-subfields") + ", class=" + getVisualClass() +
150: "]";
151: }
152: }