001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package javax.swing.plaf.synth;
019:
020: import java.awt.Color;
021: import java.awt.Graphics;
022:
023: import org.apache.harmony.x.swing.Utilities;
024:
025: public class ColorPainter extends SynthPainter {
026:
027: /**
028: * Method that do paints
029: */
030: private void paintBackground(SynthContext context, Graphics g,
031: int x, int y, int w, int h) {
032: SynthStyle style = context.getStyle();
033: if (style.isOpaque(context)) {
034: Color oldColor = g.getColor();
035: g.setColor(style.getColor(context, ColorType.BACKGROUND));
036: g.fillRect(x, y, x + w, y + h);
037: g.setColor(oldColor);
038: }
039: }
040:
041: @Override
042: public void paintArrowButtonBackground(SynthContext context,
043: Graphics g, int x, int y, int w, int h) {
044: paintBackground(context, g, x, y, w, h);
045: }
046:
047: @Override
048: public void paintArrowButtonForeground(SynthContext context,
049: Graphics g, int x, int y, int w, int h, int direction) {
050: SynthStyle style = context.getStyle();
051: if (style.isOpaque(context)) {
052: Utilities.paintArrow(g, x, y, direction, w, true, style
053: .getColor(context, ColorType.FOREGROUND));
054: }
055: }
056:
057: @Override
058: public void paintButtonBackground(SynthContext context, Graphics g,
059: int x, int y, int w, int h) {
060: paintBackground(context, g, x, y, w, h);
061: }
062:
063: @Override
064: public void paintCheckBoxMenuItemBackground(SynthContext context,
065: Graphics g, int x, int y, int w, int h) {
066: paintBackground(context, g, x, y, w, h);
067: }
068:
069: @Override
070: public void paintColorChooserBackground(SynthContext context,
071: Graphics g, int x, int y, int w, int h) {
072: paintBackground(context, g, x, y, w, h);
073: }
074:
075: @Override
076: public void paintComboBoxBackground(SynthContext context,
077: Graphics g, int x, int y, int w, int h) {
078: paintBackground(context, g, x, y, w, h);
079: }
080:
081: @Override
082: public void paintDesktopIconBackground(SynthContext context,
083: Graphics g, int x, int y, int w, int h) {
084: paintBackground(context, g, x, y, w, h);
085: }
086:
087: @Override
088: public void paintDesktopPaneBackground(SynthContext context,
089: Graphics g, int x, int y, int w, int h) {
090: paintBackground(context, g, x, y, w, h);
091: }
092:
093: @Override
094: public void paintEditorPaneBackground(SynthContext context,
095: Graphics g, int x, int y, int w, int h) {
096: paintBackground(context, g, x, y, w, h);
097: }
098:
099: @Override
100: public void paintFileChooserBackground(SynthContext context,
101: Graphics g, int x, int y, int w, int h) {
102: paintBackground(context, g, x, y, w, h);
103: }
104:
105: @Override
106: public void paintFormattedTextFieldBackground(SynthContext context,
107: Graphics g, int x, int y, int w, int h) {
108: paintBackground(context, g, x, y, w, h);
109: }
110:
111: @Override
112: public void paintInternalFrameBackground(SynthContext context,
113: Graphics g, int x, int y, int w, int h) {
114: paintBackground(context, g, x, y, w, h);
115: }
116:
117: @Override
118: public void paintInternalFrameTitlePaneBackground(
119: SynthContext context, Graphics g, int x, int y, int w, int h) {
120: paintBackground(context, g, x, y, w, h);
121: }
122:
123: @Override
124: public void paintLabelBackground(SynthContext context, Graphics g,
125: int x, int y, int w, int h) {
126: paintBackground(context, g, x, y, w, h);
127: }
128:
129: @Override
130: public void paintListBackground(SynthContext context, Graphics g,
131: int x, int y, int w, int h) {
132: paintBackground(context, g, x, y, w, h);
133: }
134:
135: @Override
136: public void paintMenuBackground(SynthContext context, Graphics g,
137: int x, int y, int w, int h) {
138: paintBackground(context, g, x, y, w, h);
139: }
140:
141: @Override
142: public void paintMenuBarBackground(SynthContext context,
143: Graphics g, int x, int y, int w, int h) {
144: paintBackground(context, g, x, y, w, h);
145: }
146:
147: @Override
148: public void paintMenuItemBackground(SynthContext context,
149: Graphics g, int x, int y, int w, int h) {
150: paintBackground(context, g, x, y, w, h);
151: }
152:
153: @Override
154: public void paintOptionPaneBackground(SynthContext context,
155: Graphics g, int x, int y, int w, int h) {
156: paintBackground(context, g, x, y, w, h);
157: }
158:
159: @Override
160: public void paintPanelBackground(SynthContext context, Graphics g,
161: int x, int y, int w, int h) {
162: paintBackground(context, g, x, y, w, h);
163: }
164:
165: @Override
166: public void paintPasswordFieldBackground(SynthContext context,
167: Graphics g, int x, int y, int w, int h) {
168: paintBackground(context, g, x, y, w, h);
169: }
170:
171: @Override
172: public void paintPopupMenuBackground(SynthContext context,
173: Graphics g, int x, int y, int w, int h) {
174: paintBackground(context, g, x, y, w, h);
175: }
176:
177: @Override
178: public void paintProgressBarBackground(SynthContext context,
179: Graphics g, int x, int y, int w, int h) {
180: paintBackground(context, g, x, y, w, h);
181: }
182:
183: @Override
184: public void paintProgressBarForeground(SynthContext context,
185: Graphics g, int x, int y, int w, int h, int orientation) {
186:
187: SynthStyle style = context.getStyle();
188: if (style.isOpaque(context)) {
189: Color oldColor = g.getColor();
190: g.setColor(style.getColor(context, ColorType.FOREGROUND));
191: g.fillRect(x, y, x + w, y + h);
192: g.setColor(oldColor);
193: }
194: }
195:
196: @Override
197: public void paintRadioButtonBackground(SynthContext context,
198: Graphics g, int x, int y, int w, int h) {
199: paintBackground(context, g, x, y, w, h);
200: }
201:
202: @Override
203: public void paintRadioButtonMenuItemBackground(
204: SynthContext context, Graphics g, int x, int y, int w, int h) {
205: paintBackground(context, g, x, y, w, h);
206: }
207:
208: @Override
209: public void paintRootPaneBackground(SynthContext context,
210: Graphics g, int x, int y, int w, int h) {
211: paintBackground(context, g, x, y, w, h);
212: }
213:
214: @Override
215: public void paintScrollBarBackground(SynthContext context,
216: Graphics g, int x, int y, int w, int h) {
217: paintBackground(context, g, x, y, w, h);
218: }
219:
220: @Override
221: public void paintScrollBarThumbBackground(SynthContext context,
222: Graphics g, int x, int y, int w, int h, int orientation) {
223: paintBackground(context, g, x, y, w, h);
224: }
225:
226: @Override
227: public void paintScrollBarTrackBackground(SynthContext context,
228: Graphics g, int x, int y, int w, int h) {
229: paintBackground(context, g, x, y, w, h);
230: }
231:
232: @Override
233: public void paintScrollPaneBackground(SynthContext context,
234: Graphics g, int x, int y, int w, int h) {
235: paintBackground(context, g, x, y, w, h);
236: }
237:
238: @Override
239: public void paintSeparatorBackground(SynthContext context,
240: Graphics g, int x, int y, int w, int h) {
241: paintBackground(context, g, x, y, w, h);
242: }
243:
244: @Override
245: public void paintSeparatorForeground(SynthContext context,
246: Graphics g, int x, int y, int w, int h, int orientation) {
247: paintBackground(context, g, x, y, w, h);
248: }
249:
250: @Override
251: public void paintSliderBackground(SynthContext context, Graphics g,
252: int x, int y, int w, int h) {
253: paintBackground(context, g, x, y, w, h);
254: }
255:
256: @Override
257: public void paintSliderThumbBackground(SynthContext context,
258: Graphics g, int x, int y, int w, int h, int orientation) {
259: paintBackground(context, g, x, y, w, h);
260: }
261:
262: @Override
263: public void paintSliderTrackBackground(SynthContext context,
264: Graphics g, int x, int y, int w, int h) {
265: paintBackground(context, g, x, y, w, h);
266: }
267:
268: @Override
269: public void paintSpinnerBackground(SynthContext context,
270: Graphics g, int x, int y, int w, int h) {
271: paintBackground(context, g, x, y, w, h);
272: }
273:
274: @Override
275: public void paintSplitPaneBackground(SynthContext context,
276: Graphics g, int x, int y, int w, int h) {
277: paintBackground(context, g, x, y, w, h);
278: }
279:
280: @Override
281: public void paintSplitPaneDividerBackground(SynthContext context,
282: Graphics g, int x, int y, int w, int h) {
283: paintBackground(context, g, x, y, w, h);
284: }
285:
286: @Override
287: public void paintSplitPaneDragDivider(SynthContext context,
288: Graphics g, int x, int y, int w, int h, int orientation) {
289: paintBackground(context, g, x, y, w, h);
290: }
291:
292: @Override
293: public void paintTabbedPaneBackground(SynthContext context,
294: Graphics g, int x, int y, int w, int h) {
295: paintBackground(context, g, x, y, w, h);
296: }
297:
298: @Override
299: public void paintTabbedPaneContentBackground(SynthContext context,
300: Graphics g, int x, int y, int w, int h) {
301: paintBackground(context, g, x, y, w, h);
302: }
303:
304: @Override
305: public void paintTabbedPaneTabAreaBackground(SynthContext context,
306: Graphics g, int x, int y, int w, int h) {
307: paintBackground(context, g, x, y, w, h);
308: }
309:
310: @Override
311: public void paintTabbedPaneTabBackground(SynthContext context,
312: Graphics g, int x, int y, int w, int h, int tabIndex) {
313: paintBackground(context, g, x, y, w, h);
314: }
315:
316: @Override
317: public void paintTableBackground(SynthContext context, Graphics g,
318: int x, int y, int w, int h) {
319: paintBackground(context, g, x, y, w, h);
320: }
321:
322: @Override
323: public void paintTableHeaderBackground(SynthContext context,
324: Graphics g, int x, int y, int w, int h) {
325: paintBackground(context, g, x, y, w, h);
326: }
327:
328: @Override
329: public void paintTextAreaBackground(SynthContext context,
330: Graphics g, int x, int y, int w, int h) {
331: paintBackground(context, g, x, y, w, h);
332: }
333:
334: @Override
335: public void paintTextFieldBackground(SynthContext context,
336: Graphics g, int x, int y, int w, int h) {
337: paintBackground(context, g, x, y, w, h);
338: }
339:
340: @Override
341: public void paintTextPaneBackground(SynthContext context,
342: Graphics g, int x, int y, int w, int h) {
343: paintBackground(context, g, x, y, w, h);
344: }
345:
346: @Override
347: public void paintToggleButtonBackground(SynthContext context,
348: Graphics g, int x, int y, int w, int h) {
349: paintBackground(context, g, x, y, w, h);
350: }
351:
352: @Override
353: public void paintToolBarBackground(SynthContext context,
354: Graphics g, int x, int y, int w, int h) {
355: paintBackground(context, g, x, y, w, h);
356: }
357:
358: @Override
359: public void paintToolBarContentBackground(SynthContext context,
360: Graphics g, int x, int y, int w, int h) {
361: paintBackground(context, g, x, y, w, h);
362: }
363:
364: @Override
365: public void paintToolBarDragWindowBackground(SynthContext context,
366: Graphics g, int x, int y, int w, int h) {
367: paintBackground(context, g, x, y, w, h);
368: }
369:
370: @Override
371: public void paintToolTipBackground(SynthContext context,
372: Graphics g, int x, int y, int w, int h) {
373: paintBackground(context, g, x, y, w, h);
374: }
375:
376: @Override
377: public void paintTreeBackground(SynthContext context, Graphics g,
378: int x, int y, int w, int h) {
379: paintBackground(context, g, x, y, w, h);
380: }
381:
382: @Override
383: public void paintTreeCellBackground(SynthContext context,
384: Graphics g, int x, int y, int w, int h) {
385: paintBackground(context, g, x, y, w, h);
386: }
387:
388: @Override
389: public void paintViewportBackground(SynthContext context,
390: Graphics g, int x, int y, int w, int h) {
391: paintBackground(context, g, x, y, w, h);
392: }
393:
394: }
|