LWCanvasPeer.java revision 4632
1008N/A/*
1008N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
1008N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1008N/A *
1008N/A * This code is free software; you can redistribute it and/or modify it
1008N/A * under the terms of the GNU General Public License version 2 only, as
1008N/A * published by the Free Software Foundation. Oracle designates this
1008N/A * particular file as subject to the "Classpath" exception as provided
6983N/A * by Oracle in the LICENSE file that accompanied this code.
6983N/A *
1008N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1008N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1008N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1008N/A * version 2 for more details (a copy is included in the LICENSE file that
6983N/A * accompanied this code).
6983N/A *
6983N/A * You should have received a copy of the GNU General Public License version
6983N/A * 2 along with this work; if not, write to the Free Software Foundation,
1008N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1008N/A *
1008N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1008N/A * or visit www.oracle.com if you need additional information or have any
1008N/A * questions.
3215N/A */
1008N/A
1008N/Apackage sun.lwawt;
1008N/A
1008N/Aimport java.awt.BufferCapabilities;
1008N/Aimport java.awt.Canvas;
1008N/Aimport java.awt.Component;
1008N/Aimport java.awt.Dimension;
1008N/Aimport java.awt.Graphics;
1008N/Aimport java.awt.GraphicsConfiguration;
1008N/Aimport java.awt.Image;
1008N/Aimport java.awt.peer.CanvasPeer;
1008N/A
1008N/Aimport javax.swing.JComponent;
1008N/A
1008N/Afinal class LWCanvasPeer
1008N/A extends LWComponentPeer<Component, JComponent>
1008N/A implements CanvasPeer
1008N/A{
1008N/A LWCanvasPeer(final Canvas target, PlatformComponent platformComponent) {
1008N/A super(target, platformComponent);
1008N/A }
1008N/A
1008N/A @Override
1008N/A public JComponent createDelegate() {
1008N/A return new JCanvasDelegate();
1008N/A }
1008N/A
1008N/A // ---- PEER METHODS ---- //
1008N/A
1008N/A @Override
1008N/A public void createBuffers(int numBuffers, BufferCapabilities caps) {
1008N/A // TODO
1008N/A }
1008N/A
1008N/A @Override
1008N/A public Image getBackBuffer() {
1008N/A // TODO
1008N/A return null;
1008N/A }
1008N/A
1008N/A @Override
1008N/A public void flip(int x1, int y1, int x2, int y2,
1008N/A BufferCapabilities.FlipContents flipAction)
1008N/A {
1008N/A // TODO
1008N/A }
1008N/A
1008N/A @Override
1008N/A public void destroyBuffers() {
1008N/A // TODO
1008N/A }
1008N/A
1008N/A @Override
1008N/A public GraphicsConfiguration getAppropriateGraphicsConfiguration(
1008N/A GraphicsConfiguration gc)
1008N/A {
1008N/A // TODO
1008N/A return gc;
1008N/A }
1008N/A
1008N/A class JCanvasDelegate
1008N/A extends JComponent
1008N/A {
1008N/A
1008N/A @Override
1008N/A public Dimension getMinimumSize() {
1008N/A return getTarget().getSize();
1008N/A }
1008N/A
1008N/A @Override
1008N/A public Dimension getPreferredSize() {
1008N/A return getTarget().getSize();
1008N/A }
1008N/A
1008N/A @Override
1008N/A public boolean isOpaque() {
1008N/A return true;
1008N/A }
1008N/A
1008N/A @Override
1008N/A protected void paintComponent(final Graphics g) {
1008N/A if (isOpaque()) {
1008N/A g.setColor(getBackground());
1008N/A g.fillRect(0, 0, getWidth(), getHeight());
1008N/A g.setColor(getForeground());
1008N/A }
1008N/A }
1008N/A }
1008N/A}
1008N/A