001: /*
002: *
003: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
004: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License version
008: * 2 only, as published by the Free Software Foundation.
009: *
010: * This program is distributed in the hope that it will be useful, but
011: * WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * General Public License version 2 for more details (a copy is
014: * included at /legal/license.txt).
015: *
016: * You should have received a copy of the GNU General Public License
017: * version 2 along with this work; if not, write to the Free Software
018: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
019: * 02110-1301 USA
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
022: * Clara, CA 95054 or visit www.sun.com if you need additional
023: * information or have any questions.
024: */
025:
026: package com.sun.pisces;
027:
028: public final class JavaSurface extends AbstractSurface {
029: private int[] dataInt;
030: private short[] dataShort;
031: private byte[] dataByte;
032:
033: public JavaSurface(int[] data, int width, int height) {
034: this (data, TYPE_INT_ARGB, width, height);
035: }
036:
037: public JavaSurface(int[] dataInt, int dataType, int width,
038: int height) {
039: this .dataInt = dataInt;
040:
041: switch (dataType) {
042: case TYPE_INT_RGB:
043: case TYPE_INT_ARGB:
044: case TYPE_INT_ARGB_PRE:
045: break;
046: case TYPE_USHORT_565_RGB:
047: case TYPE_BYTE_GRAY:
048: throw new IllegalArgumentException(
049: "Use different constructor" + " for "
050: + JavaSurface.class.getName()
051: + " to use this" + " data type");
052: default:
053: throw new IllegalArgumentException(
054: "Data type not supported " + " for "
055: + JavaSurface.class.getName());
056: }
057:
058: initialize(dataType, width, height);
059: }
060:
061: public JavaSurface(short[] dataShort, int dataType, int width,
062: int height) {
063: this .dataShort = dataShort;
064:
065: switch (dataType) {
066: case TYPE_USHORT_565_RGB:
067: break;
068: case TYPE_INT_RGB:
069: case TYPE_INT_ARGB:
070: case TYPE_INT_ARGB_PRE:
071: case TYPE_BYTE_GRAY:
072: throw new IllegalArgumentException(
073: "Use different constructor" + " for "
074: + JavaSurface.class.getName()
075: + " to use this" + " data type");
076: default:
077: throw new IllegalArgumentException(
078: "Data type not supported " + " for "
079: + JavaSurface.class.getName());
080: }
081:
082: initialize(dataType, width, height);
083: }
084:
085: public JavaSurface(byte[] dataByte, int dataType, int width,
086: int height) {
087: this .dataByte = dataByte;
088:
089: switch (dataType) {
090: case TYPE_BYTE_GRAY:
091: break;
092: case TYPE_INT_RGB:
093: case TYPE_INT_ARGB:
094: case TYPE_INT_ARGB_PRE:
095: case TYPE_USHORT_565_RGB:
096: throw new IllegalArgumentException(
097: "Use different constructor" + " for "
098: + JavaSurface.class.getName()
099: + " to use this" + " data type");
100: default:
101: throw new IllegalArgumentException(
102: "Data type not supported " + " for "
103: + JavaSurface.class.getName());
104: }
105:
106: initialize(dataType, width, height);
107: }
108:
109: private native void initialize(int dataType, int width, int height);
110: }
|