libjava/classpath/ChangeLog.gcj:
2007-05-31 Matthias Klose <doko@ubuntu.com> * javax/management/NotificationBroadcasterSupport.java (getNotificationInfo): Add cast. * native/jni/qt-peer/Makefile.am (AM_CXXFLAGS): Add libstdc++ include directories. * native/jni/qt-peer/Makefile.in: Regenerate. libjava/ChangeLog: 2007-06-03 Matthias Klose <doko@ubuntu.com> * java/io/natFileWin32.cc (setFilePermissions): New (stub only). _access: Handle EXEC query, stub only. 2007-06-03 Matthias Klose <doko@ubuntu.com> Merged from classpath: * gnu/java/nio/SelectorProviderImpl.java: Whitespace merge. * java/lang/System.java(inheritedChannel): New. * java/lang/Character.java: Remove stray`;'. * java/net/MulticastSocket.java: Merged. * java/text/DateFormatSymbols.java(getInstance): New, comment updates. * java/text/Collator.java(getInstance): Merged. * java/util/Calendar.java: New attributes ALL_STYLES, SHORT, LONG. getDisplayName, getDisplayNames: New. * java/util/logging/Logger.java: Merged. * Regenerate .class and .h files. 2007-06-03 Matthias Klose <doko@ubuntu.com> * java/io/File.java: Merge with classpath-0.95, new method setFilePermissions, new attribute EXEC. * java/io/natFilePosix.cc (setFilePermissions): New. _access: Handle EXEC query. * classpath/lib/java/io/File.class, java/io/File.h: Regenerate. 2007-06-03 Matthias Klose <doko@ubuntu.com> Imported GNU Classpath 0.95. * classpath/Makefile.in, classpath/native/jni/midi-dssi/Makefile.in, classpath/native/jni/classpath/Makefile.in, classpath/native/jni/Makefile.in, classpath/native/jni/gconf-peer/Makefile.in, classpath/native/jni/java-io/Makefile.in, classpath/native/jni/native-lib/Makefile.in, classpath/native/jni/java-util/Makefile.in, classpath/native/jni/midi-alsa/Makefile.in, classpath/native/jni/java-lang/Makefile.in, classpath/native/jni/java-nio/Makefile.in, classpath/native/jni/java-net/Makefile.in, classpath/native/jni/xmlj/Makefile.in, classpath/native/jni/qt-peer/Makefile.in, classpath/native/jni/gtk-peer/Makefile.in, classpath/native/Makefile.in, classpath/native/jawt/Makefile.in, classpath/native/fdlibm/Makefile.in, classpath/native/plugin/Makefile.in, classpath/resource/Makefile.in, classpath/scripts/Makefile.in, classpath/tools/Makefile.in, classpath/doc/Makefile.in, classpath/doc/api/Makefile.in, classpath/lib/Makefile.in, classpath/external/Makefile.in, classpath/external/jsr166/Makefile.in, classpath/external/sax/Makefile.in, classpath/external/w3c_dom/Makefile.in, classpath/external/relaxngDatatype/Makefile.in, classpath/include/Makefile.in, classpath/examples/Makefile.in: Regenerate. * classpath/config.guess, classpath/config.sub, classpath/ltmain.sh : Update. * classpath/configure, classpath/depcomp, classpath/missing, classpath/aclocal.m4, classpath/install-sh: Regenerate. * gnu/classpath/Configuration.java (CLASSPATH_VERSION): Now 0.95. * sources.am: Regenerate. * Makefile.in: Regenerate. * Update the .class files and generated CNI header files, add new .class and generated CNI header files. * Remove generated files for removed java source files: classpath/gnu/java/net/BASE64.java, classpath/gnu/java/security/util/Base64.java, classpath/gnu/java/awt/peer/gtk/GThreadMutex.java, classpath/gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java, classpath/gnu/java/awt/font/autofit/Scaler.java, classpath/gnu/classpath/jdwp/util/Value.java, classpath/gnu/javax/net/ssl/Base64.java. * Remove empty directories. * Makefile.am(nat_source_files): Add natVMOperatingSystemMXBeanImpl.cc. * java/lang/Class.java(setAccessible): Merge from classpath. * java/util/Locale.java: Remove. * gnu/java/lang/management/VMOperatingSystemMXBeanImpl.java, gnu/java/lang/management/natVMOperatingSystemMXBeanImpl.cc: New. * gcj/javaprims.h: Update class declarations. * scripts/classes.pl: Update usage. * HACKING: Mention to build all peers. From-SVN: r125302
This commit is contained in:
parent
af333b9a7f
commit
e1bea0c068
2951 changed files with 80982 additions and 68583 deletions
|
@ -262,9 +262,17 @@ public abstract class AWTEvent extends EventObject
|
|||
*/
|
||||
public String toString ()
|
||||
{
|
||||
String src;
|
||||
if (source instanceof Component)
|
||||
src = ((Component) source).getName();
|
||||
else if (source instanceof MenuComponent)
|
||||
src = ((MenuComponent) source).getName();
|
||||
else if (source != null)
|
||||
src = source.toString();
|
||||
else
|
||||
src = "null";
|
||||
String string = getClass ().getName () + "[" + paramString () + "] on "
|
||||
+ source;
|
||||
|
||||
+ src;
|
||||
return string;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* AWTKeyStroke.java -- an immutable key stroke
|
||||
Copyright (C) 2002, 2004, 2005 Free Software Foundation
|
||||
Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -93,9 +93,9 @@ public class AWTKeyStroke implements Serializable
|
|||
private static final int MAX_CACHE_SIZE = 2048;
|
||||
|
||||
/** Prune stale entries. */
|
||||
protected boolean removeEldestEntry(Map.Entry<AWTKeyStroke,AWTKeyStroke>
|
||||
protected boolean removeEldestEntry(Entry<AWTKeyStroke,AWTKeyStroke>
|
||||
eldest)
|
||||
{ // XXX - FIXME Use Map.Entry, not just Entry as gcj 3.1 workaround.
|
||||
{
|
||||
return size() > MAX_CACHE_SIZE;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* AlphaComposite.java -- provides a context for performing alpha compositing
|
||||
Copyright (C) 2002, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -61,8 +61,8 @@ public final class AlphaComposite implements Composite
|
|||
private static final int MAX_CACHE_SIZE = 2048;
|
||||
|
||||
/** Prune stale entries. */
|
||||
protected boolean removeEldestEntry(Map.Entry eldest)
|
||||
{ // XXX - FIXME Use Map.Entry, not just Entry as gcj 3.1 workaround.
|
||||
protected boolean removeEldestEntry(Entry eldest)
|
||||
{
|
||||
return size() > MAX_CACHE_SIZE;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -74,11 +74,6 @@ public class Canvas
|
|||
*/
|
||||
private static transient long next_canvas_number;
|
||||
|
||||
/**
|
||||
* The graphics configuration associated with the canvas.
|
||||
*/
|
||||
transient GraphicsConfiguration graphicsConfiguration;
|
||||
|
||||
/**
|
||||
* The buffer strategy associated with this canvas.
|
||||
*/
|
||||
|
@ -100,14 +95,7 @@ public class Canvas
|
|||
*/
|
||||
public Canvas(GraphicsConfiguration graphicsConfiguration)
|
||||
{
|
||||
this.graphicsConfiguration = graphicsConfiguration;
|
||||
}
|
||||
|
||||
GraphicsConfiguration getGraphicsConfigurationImpl()
|
||||
{
|
||||
if (graphicsConfiguration != null)
|
||||
return graphicsConfiguration;
|
||||
return super.getGraphicsConfigurationImpl();
|
||||
this.graphicsConfig = graphicsConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -225,7 +225,7 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
*/
|
||||
public Dimension maximumLayoutSize (Container target)
|
||||
{
|
||||
if (target == null)
|
||||
if (target == null || target.ncomponents == 0)
|
||||
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
// The JCL says that this returns Integer.MAX_VALUE for both
|
||||
// dimensions. But that just seems wrong to me.
|
||||
|
|
|
@ -726,7 +726,23 @@ public abstract class Component
|
|||
*/
|
||||
public GraphicsConfiguration getGraphicsConfiguration()
|
||||
{
|
||||
return getGraphicsConfigurationImpl();
|
||||
GraphicsConfiguration conf = null;
|
||||
synchronized (getTreeLock())
|
||||
{
|
||||
if (graphicsConfig != null)
|
||||
{
|
||||
conf = graphicsConfig;
|
||||
}
|
||||
else
|
||||
{
|
||||
Component par = getParent();
|
||||
if (par != null)
|
||||
{
|
||||
conf = parent.getGraphicsConfiguration();
|
||||
}
|
||||
}
|
||||
}
|
||||
return conf;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -823,7 +839,8 @@ public abstract class Component
|
|||
*/
|
||||
public boolean isShowing()
|
||||
{
|
||||
return visible && peer != null && (parent == null || parent.isShowing());
|
||||
Component par = parent;
|
||||
return visible && peer != null && (par == null || par.isShowing());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1179,19 +1196,12 @@ public abstract class Component
|
|||
*/
|
||||
public Font getFont()
|
||||
{
|
||||
Font f;
|
||||
synchronized (getTreeLock())
|
||||
{
|
||||
f = getFontImpl();
|
||||
}
|
||||
return f;
|
||||
return getFontImpl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of getFont(). This is pulled out of getFont() to prevent
|
||||
* client programs from overriding this. This method is executed within
|
||||
* a tree lock, so we can assume that the hierarchy doesn't change in
|
||||
* between.
|
||||
* client programs from overriding this.
|
||||
*
|
||||
* @return the font of this component
|
||||
*/
|
||||
|
@ -1204,7 +1214,12 @@ public abstract class Component
|
|||
if (p != null)
|
||||
f = p.getFontImpl();
|
||||
else
|
||||
f = new Font("Dialog", Font.PLAIN, 12);
|
||||
{
|
||||
// It is important to return null here and not some kind of default
|
||||
// font, otherwise the Swing UI would not install its fonts because
|
||||
// it keeps non-UIResource fonts.
|
||||
f = null;
|
||||
}
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
@ -5434,27 +5449,6 @@ p * <li>the set of backward traversal keys
|
|||
this.peer = peer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation method that allows classes such as Canvas and Window to
|
||||
* override the graphics configuration without violating the published API.
|
||||
*
|
||||
* @return the graphics configuration
|
||||
*/
|
||||
GraphicsConfiguration getGraphicsConfigurationImpl()
|
||||
{
|
||||
if (peer != null)
|
||||
{
|
||||
GraphicsConfiguration config = peer.getGraphicsConfiguration();
|
||||
if (config != null)
|
||||
return config;
|
||||
}
|
||||
|
||||
if (parent != null)
|
||||
return parent.getGraphicsConfiguration();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate an AWT 1.1 event ({@link AWTEvent}) into an AWT 1.0
|
||||
* event ({@link Event}).
|
||||
|
|
268
libjava/classpath/java/awt/Desktop.java
Normal file
268
libjava/classpath/java/awt/Desktop.java
Normal file
|
@ -0,0 +1,268 @@
|
|||
/* Desktop.java -- enable desktop integration between java programs and system
|
||||
programs.
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package java.awt;
|
||||
|
||||
import java.awt.peer.DesktopPeer;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* This class enables Java application to access system commands to perform
|
||||
* desktop oriented operations, like writing and sending emails, or surfing
|
||||
* webpages with the system browser or editing/printing files with a default
|
||||
* editor. Methods are provided to handle these common operations, plus an
|
||||
* <code>open</code> command selects a default registered application for the
|
||||
* specified file type. For example, opening an odf file results in launching
|
||||
* OpenOffice. If an operation is not supported, or the application fails to
|
||||
* launch, an exception is generated.
|
||||
*
|
||||
* <strong>Implementation note: </strong>As this class is used to manage Desktop
|
||||
* integration, we provide some extension to configure the behaviour of this
|
||||
* class depending on the type of dektop that is detected.<br />
|
||||
*
|
||||
* First of all, we support 5 system properties that can be used to define
|
||||
* the application to launch in any given case. These properties are:<br />
|
||||
* <br />
|
||||
* <code>gnu.java.awt.peer.Desktop.html.command</code><br />
|
||||
* <code>gnu.java.awt.peer.Desktop.mail.command</code><br />
|
||||
* <code>gnu.java.awt.peer.Desktop.edit.command</code><br />
|
||||
* <code>gnu.java.awt.peer.Desktop.print.command</code><br />
|
||||
* <code>gnu.java.awt.peer.Desktop.open.command</code><br />
|
||||
* <br />
|
||||
* <br />
|
||||
* These can be specified from the command line and have priority on every
|
||||
* other setting.<br />
|
||||
* <br />
|
||||
* The second method supported is defining a Java preference.<br />
|
||||
* The main preference node is a <strong>user node</strong> relative to the
|
||||
* class <code>gnu.java.awt.peer.ClasspathDesktopPeer</code>. This node
|
||||
* contains a child for each supported operation. The key for each type is
|
||||
* always <code>command</code>:
|
||||
* <br /><br />
|
||||
* <code>gnu.java.awt.peer.Desktop.html.command</code><br />
|
||||
* <code>gnu.java.awt.peer.Desktop.mail.command</code><br />
|
||||
* <code>gnu.java.awt.peer.Desktop.edit.command</code><br />
|
||||
* <code>gnu.java.awt.peer.Desktop.print.command</code><br />
|
||||
* <code>gnu.java.awt.peer.Desktop.open.command</code><br />
|
||||
* <br />
|
||||
* <br />
|
||||
* The access to these keys is done with the Preference API or, if outside
|
||||
* of the java scope, is done in a backend dependent way. For example,
|
||||
* with the GConf backend, you can access these properties
|
||||
* with (may not be accurate on your system):
|
||||
* <br /><br />
|
||||
* <code>
|
||||
* gconftool-2 -g /apps/classpath/gnu/java/awt/peer/Desktop/html/command
|
||||
* </code>
|
||||
*
|
||||
* @author Mario Torre <neugens@limasoftware.net>
|
||||
* @since 1.6
|
||||
*/
|
||||
public class Desktop
|
||||
{
|
||||
/**
|
||||
* Represents an action type supported by a platform.
|
||||
*
|
||||
* To determine if a given action is supported by the platform,
|
||||
* use the <code>Desktop.isSupported(java.awt.Desktop.Action)</code>
|
||||
* method.
|
||||
*
|
||||
* @author Mario Torre <neugens@limasoftware.net>
|
||||
*/
|
||||
public enum Action
|
||||
{
|
||||
BROWSE, EDIT, MAIL, OPEN, PRINT
|
||||
}
|
||||
|
||||
private DesktopPeer peer;
|
||||
|
||||
private Desktop()
|
||||
{
|
||||
/* nothing to be done */
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an istance of the Desktop Class.
|
||||
*
|
||||
* If this implementation does not support Desktop, an
|
||||
* UnsupportedOperationException will be thrown.
|
||||
* Also, an HeadlessException will be generated if
|
||||
* GraphicsEnvironment.isHeadless() returns true.
|
||||
*
|
||||
* @throws UnsupportedOperationException
|
||||
* @throws HeadlessException
|
||||
*/
|
||||
public static Desktop getDesktop() throws UnsupportedOperationException,
|
||||
HeadlessException
|
||||
{
|
||||
if (GraphicsEnvironment.isHeadless())
|
||||
throw new HeadlessException();
|
||||
|
||||
if (!Desktop.isDesktopSupported())
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
Desktop desktop = new Desktop();
|
||||
desktop.peer = Toolkit.getDefaultToolkit().createDesktopPeer(desktop);
|
||||
|
||||
return desktop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this implementation supports Desktop.
|
||||
* If true, use getDesktop to get an instance of this class.
|
||||
*
|
||||
* This implementation will return false when GraphicsEnvironment.isHeadless
|
||||
* returns true.
|
||||
*
|
||||
* @return true if this class is supported on the current platform;
|
||||
* false otherwise
|
||||
*/
|
||||
private static boolean isDesktopSupported()
|
||||
{
|
||||
if (GraphicsEnvironment.isHeadless())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given Action is supported by this implementation.
|
||||
*
|
||||
* @param action
|
||||
* @return
|
||||
*/
|
||||
public boolean isSupported(Desktop.Action action)
|
||||
{
|
||||
return peer.isSupported(action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Launches the Desktop default browser to open the given <code>uri</code>.
|
||||
*
|
||||
* If a security manager exists and denies
|
||||
* AWTPermission("showWindowWithoutWarningBanner"),a SecurityException will
|
||||
* be generated.
|
||||
*
|
||||
* @param uri
|
||||
* @throws IOException
|
||||
*/
|
||||
public void browse(URI uri)
|
||||
throws IOException
|
||||
{
|
||||
peer.browse(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch the edit command to edit this file.
|
||||
* File should already exist before the editing starts.
|
||||
*
|
||||
* If a security manager exists and
|
||||
* SecurityManager.checkRead(java.lang.String) method denies read access to
|
||||
* the file, or SecurityManager.checkPrintJobAccess() method denies the
|
||||
* permission to print the file, a SecurityException will be generated.
|
||||
*
|
||||
* @param file
|
||||
* @throws IOException
|
||||
*/
|
||||
public void edit(File file)
|
||||
throws IOException
|
||||
{
|
||||
peer.edit(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Launches the Desktop default mailer.
|
||||
*
|
||||
* If a security manager exists and denies
|
||||
* AWTPermission("showWindowWithoutWarningBanner"), a SecurityException will
|
||||
* be generated.
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void mail()
|
||||
throws IOException
|
||||
{
|
||||
peer.mail();
|
||||
}
|
||||
|
||||
/**
|
||||
* Launches the Desktop default mailer, with the given mailtoURI
|
||||
* as agrument. The <code>mailtoURI</code> must conform to the
|
||||
* {@link http://www.ietf.org/rfc/rfc2368.txt The mailto URL scheme (RFC 2368)}
|
||||
*
|
||||
* If a security manager exists and denies
|
||||
* AWTPermission("showWindowWithoutWarningBanner"), a SecurityException will
|
||||
* be generated.
|
||||
*
|
||||
* @param mailtoURI
|
||||
* @throws IOException
|
||||
*/
|
||||
public void mail(URI mailtoURI)
|
||||
throws IOException
|
||||
{
|
||||
peer.mail(mailtoURI);
|
||||
}
|
||||
|
||||
/**
|
||||
* Launches the Desktop default application to open the given File.
|
||||
* If <code>file</code> is a directory, a file manager is launched.
|
||||
*
|
||||
* @param file
|
||||
* @throws IOException
|
||||
*/
|
||||
public void open(File file)
|
||||
throws IOException
|
||||
{
|
||||
peer.open(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch the print program to print this file.
|
||||
*
|
||||
* @param file
|
||||
* @throws IOException
|
||||
*/
|
||||
public void print(File file)
|
||||
throws IOException
|
||||
{
|
||||
peer.print(file);
|
||||
}
|
||||
}
|
|
@ -73,6 +73,9 @@ class EventDispatchThread extends Thread
|
|||
// Ignore and use default.
|
||||
}
|
||||
setPriority(priority);
|
||||
|
||||
// Make sure that an event dispatch thread is never a daemon thread.
|
||||
setDaemon(false);
|
||||
}
|
||||
|
||||
public void run()
|
||||
|
|
|
@ -128,10 +128,8 @@ public class EventQueue
|
|||
if (peekEvent() != null)
|
||||
return false;
|
||||
|
||||
Frame[] frames = Frame.getFrames();
|
||||
for (int i = 0; i < frames.length; ++i)
|
||||
if (frames[i].isDisplayable())
|
||||
return false;
|
||||
if (Frame.hasDisplayableFrames())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -40,9 +40,10 @@ exception statement from your version. */
|
|||
package java.awt;
|
||||
|
||||
import java.awt.peer.FramePeer;
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.accessibility.AccessibleContext;
|
||||
|
@ -484,44 +485,72 @@ public class Frame extends Window implements MenuContainer
|
|||
return super.paramString () + ",title=" + title + resizable + state;
|
||||
}
|
||||
|
||||
private static ArrayList weakFrames = new ArrayList();
|
||||
/**
|
||||
* The list of active frames. GC'ed frames get removed in noteFrame().
|
||||
*/
|
||||
private static ArrayList<WeakReference<Frame>> weakFrames =
|
||||
new ArrayList<WeakReference<Frame>>();
|
||||
|
||||
/**
|
||||
* The death queue for all frames.
|
||||
*/
|
||||
private static ReferenceQueue weakFramesQueue =
|
||||
new ReferenceQueue<Frame>();
|
||||
|
||||
private static void noteFrame(Frame f)
|
||||
{
|
||||
synchronized (weakFrames)
|
||||
{
|
||||
weakFrames.add(new WeakReference(f));
|
||||
// Remove GCed frames from the list.
|
||||
Reference ref = weakFramesQueue.poll();
|
||||
while (ref != null)
|
||||
{
|
||||
weakFrames.remove(ref);
|
||||
ref = weakFramesQueue.poll();
|
||||
}
|
||||
// Add new frame.
|
||||
weakFrames.add(new WeakReference<Frame>(f));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> when there are any displayable frames,
|
||||
* <code>false</code> otherwise.
|
||||
*
|
||||
* @return <code>true</code> when there are any displayable frames,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
static boolean hasDisplayableFrames()
|
||||
{
|
||||
synchronized (weakFrames)
|
||||
{
|
||||
for (WeakReference<Frame> r : Frame.weakFrames)
|
||||
{
|
||||
Frame f = (Frame) r.get();
|
||||
if (f != null && f.isDisplayable())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Frame[] getFrames()
|
||||
{
|
||||
int n = 0;
|
||||
synchronized (weakFrames)
|
||||
{
|
||||
Iterator i = weakFrames.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
WeakReference wr = (WeakReference) i.next();
|
||||
if (wr.get() != null)
|
||||
++n;
|
||||
}
|
||||
if (n == 0)
|
||||
return new Frame[0];
|
||||
else
|
||||
{
|
||||
Frame[] frames = new Frame[n];
|
||||
n = 0;
|
||||
i = weakFrames.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
WeakReference wr = (WeakReference) i.next();
|
||||
if (wr.get() != null)
|
||||
frames[n++] = (Frame) wr.get();
|
||||
}
|
||||
return frames;
|
||||
}
|
||||
}
|
||||
{
|
||||
ArrayList<Frame> existingFrames = new ArrayList<Frame>();
|
||||
for (WeakReference<Frame> ref : weakFrames)
|
||||
{
|
||||
Frame f = ref.get();
|
||||
if (f != null)
|
||||
{
|
||||
existingFrames.add(f);
|
||||
}
|
||||
}
|
||||
Frame[] frames = new Frame[existingFrames.size()];
|
||||
frames = existingFrames.toArray(frames);
|
||||
return frames;
|
||||
}
|
||||
}
|
||||
|
||||
public void setState(int state)
|
||||
|
|
|
@ -38,8 +38,6 @@ exception statement from your version. */
|
|||
|
||||
package java.awt;
|
||||
|
||||
import gnu.classpath.NotImplementedException;
|
||||
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
|
@ -131,7 +129,8 @@ public abstract class GraphicsConfiguration
|
|||
ImageCapabilities caps)
|
||||
throws AWTException
|
||||
{
|
||||
throw new AWTException("not implemented");
|
||||
// Must be overridden by implementations to check caps.
|
||||
return createCompatibleVolatileImage(w, h);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,6 +148,32 @@ public abstract class GraphicsConfiguration
|
|||
int height,
|
||||
int transparency);
|
||||
|
||||
/**
|
||||
* Creates a volatile image with the specified capabilities and transparency.
|
||||
* If the backend cannot meet the requested capabilities and transparency,
|
||||
* an AWTException is thrown.
|
||||
*
|
||||
* @param width the width of the image
|
||||
* @param height the height of the image
|
||||
* @param caps the requested capabilities
|
||||
* @param transparency the required transparency
|
||||
*
|
||||
* @return a volatile image with the specified capabilites and transparency
|
||||
*
|
||||
* @throws AWTException if the required capabilities and transparency cannot
|
||||
* be met
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public VolatileImage createCompatibleVolatileImage(int width, int height,
|
||||
ImageCapabilities caps,
|
||||
int transparency)
|
||||
throws AWTException
|
||||
{
|
||||
// Must be overridden by implementations to check caps.
|
||||
return createCompatibleVolatileImage(width, height, transparency);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a buffered image optimized to this device, and with the specified
|
||||
* transparency, so that blitting can be supported in the buffered image.
|
||||
|
|
|
@ -158,7 +158,7 @@ public class RenderingHints
|
|||
}
|
||||
} // class KeyImpl
|
||||
|
||||
private HashMap hintMap = new HashMap();
|
||||
private HashMap<Object,Object> hintMap = new HashMap<Object,Object>();
|
||||
|
||||
/**
|
||||
* A key for the 'antialiasing' hint. Permitted values are:
|
||||
|
@ -711,9 +711,9 @@ public class RenderingHints
|
|||
Iterator iterator = m.keySet().iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Key key = (Key) iterator.next();
|
||||
if (!key.isCompatibleValue(m.get(key)))
|
||||
throw new IllegalArgumentException();
|
||||
Key key = (Key) iterator.next();
|
||||
if (!key.isCompatibleValue(m.get(key)))
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
// map is OK, update
|
||||
hintMap.putAll(m);
|
||||
|
@ -783,7 +783,7 @@ public class RenderingHints
|
|||
try
|
||||
{
|
||||
RenderingHints copy = (RenderingHints) super.clone();
|
||||
copy.hintMap = (HashMap) hintMap.clone();
|
||||
copy.hintMap = new HashMap<Object,Object>(hintMap);
|
||||
return copy;
|
||||
}
|
||||
catch (CloneNotSupportedException e)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Toolkit.java -- AWT Toolkit superclass
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
@ -40,6 +40,7 @@ exception statement from your version. */
|
|||
package java.awt;
|
||||
|
||||
import gnu.classpath.SystemProperties;
|
||||
import gnu.java.awt.AWTUtilities;
|
||||
import gnu.java.awt.peer.GLightweightPeer;
|
||||
import gnu.java.awt.peer.headless.HeadlessToolkit;
|
||||
|
||||
|
@ -62,6 +63,7 @@ import java.awt.peer.CanvasPeer;
|
|||
import java.awt.peer.CheckboxMenuItemPeer;
|
||||
import java.awt.peer.CheckboxPeer;
|
||||
import java.awt.peer.ChoicePeer;
|
||||
import java.awt.peer.DesktopPeer;
|
||||
import java.awt.peer.DialogPeer;
|
||||
import java.awt.peer.FileDialogPeer;
|
||||
import java.awt.peer.FontPeer;
|
||||
|
@ -147,6 +149,15 @@ public abstract class Toolkit
|
|||
awtEventListeners = new AWTEventListenerProxy[0];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param target
|
||||
* @return
|
||||
* @throws HeadlessException
|
||||
*/
|
||||
protected abstract DesktopPeer createDesktopPeer(Desktop target)
|
||||
throws HeadlessException;
|
||||
|
||||
/**
|
||||
* Creates a peer object for the specified <code>Button</code>.
|
||||
*
|
||||
|
@ -802,12 +813,11 @@ public abstract class Toolkit
|
|||
*/
|
||||
public boolean getLockingKeyState(int keyCode)
|
||||
{
|
||||
if (keyCode != KeyEvent.VK_CAPS_LOCK
|
||||
&& keyCode != KeyEvent.VK_NUM_LOCK
|
||||
&& keyCode != KeyEvent.VK_SCROLL_LOCK)
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
throw new UnsupportedOperationException();
|
||||
if (AWTUtilities.isValidKey(keyCode))
|
||||
throw new UnsupportedOperationException
|
||||
("cannot get locking state of key code " + keyCode);
|
||||
|
||||
throw new IllegalArgumentException("invalid key code " + keyCode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -87,7 +87,6 @@ public class Window extends Container implements Accessible
|
|||
private transient WindowListener windowListener;
|
||||
private transient WindowFocusListener windowFocusListener;
|
||||
private transient WindowStateListener windowStateListener;
|
||||
private transient GraphicsConfiguration graphicsConfiguration;
|
||||
|
||||
private transient boolean shown;
|
||||
|
||||
|
@ -132,13 +131,13 @@ public class Window extends Container implements Accessible
|
|||
setLayout(new BorderLayout());
|
||||
|
||||
GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
graphicsConfiguration = g.getDefaultScreenDevice().getDefaultConfiguration();
|
||||
graphicsConfig = g.getDefaultScreenDevice().getDefaultConfiguration();
|
||||
}
|
||||
|
||||
Window(GraphicsConfiguration gc)
|
||||
{
|
||||
this();
|
||||
graphicsConfiguration = gc;
|
||||
graphicsConfig = gc;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -204,19 +203,11 @@ public class Window extends Container implements Accessible
|
|||
throw new IllegalArgumentException ("gc must be from a screen device");
|
||||
|
||||
if (gc == null)
|
||||
graphicsConfiguration = GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||
.getDefaultScreenDevice()
|
||||
.getDefaultConfiguration();
|
||||
graphicsConfig = GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||
.getDefaultScreenDevice()
|
||||
.getDefaultConfiguration();
|
||||
else
|
||||
graphicsConfiguration = gc;
|
||||
}
|
||||
|
||||
GraphicsConfiguration getGraphicsConfigurationImpl()
|
||||
{
|
||||
if (graphicsConfiguration != null)
|
||||
return graphicsConfiguration;
|
||||
|
||||
return super.getGraphicsConfigurationImpl();
|
||||
graphicsConfig = gc;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1073,9 +1064,14 @@ public class Window extends Container implements Accessible
|
|||
*/
|
||||
public GraphicsConfiguration getGraphicsConfiguration()
|
||||
{
|
||||
if (graphicsConfiguration != null) return graphicsConfiguration;
|
||||
if (peer != null) return peer.getGraphicsConfiguration();
|
||||
return null;
|
||||
GraphicsConfiguration conf = graphicsConfig;
|
||||
if (conf == null)
|
||||
{
|
||||
conf = GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||
.getDefaultScreenDevice().getDefaultConfiguration();
|
||||
graphicsConfig = conf;
|
||||
}
|
||||
return conf;
|
||||
}
|
||||
|
||||
protected void processWindowFocusEvent(WindowEvent event)
|
||||
|
|
|
@ -38,12 +38,21 @@ exception statement from your version. */
|
|||
|
||||
package java.awt.datatransfer;
|
||||
|
||||
import gnu.classpath.NotImplementedException;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
/**
|
||||
|
@ -72,19 +81,102 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable
|
|||
* This map maps native <code>String</code>s to lists of
|
||||
* <code>DataFlavor</code>s
|
||||
*/
|
||||
private HashMap nativeToFlavorMap = new HashMap();
|
||||
private HashMap<String,List<DataFlavor>> nativeToFlavorMap =
|
||||
new HashMap<String,List<DataFlavor>>();
|
||||
|
||||
/**
|
||||
* This map maps <code>DataFlavor</code>s to lists of native
|
||||
* <code>String</code>s
|
||||
*/
|
||||
private HashMap flavorToNativeMap = new HashMap();
|
||||
private HashMap<DataFlavor, List<String>> flavorToNativeMap =
|
||||
new HashMap<DataFlavor, List<String>>();
|
||||
|
||||
/**
|
||||
* Private constructor.
|
||||
*/
|
||||
private SystemFlavorMap ()
|
||||
{
|
||||
AccessController.doPrivileged
|
||||
(new PrivilegedAction<Object>()
|
||||
{
|
||||
public Object run()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Load installed flavormap.properties first.
|
||||
String sep = File.separator;
|
||||
File propsFile =
|
||||
new File(System.getProperty("gnu.classpath.home.url")
|
||||
+ sep + "accessibility.properties");
|
||||
InputStream in = new FileInputStream(propsFile);
|
||||
Properties props = new Properties();
|
||||
props.load(in);
|
||||
in.close();
|
||||
|
||||
String augmented = Toolkit.getProperty("AWT.DnD.flavorMapFileURL",
|
||||
null);
|
||||
if (augmented != null)
|
||||
{
|
||||
URL url = new URL(augmented);
|
||||
in = url.openStream();
|
||||
props.load(in);
|
||||
}
|
||||
setupMapping(props);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
// Can't do anything about it.
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the mapping from native to mime types and vice versa as specified
|
||||
* in the flavormap.properties file.
|
||||
*
|
||||
* This is package private to avoid an accessor method.
|
||||
*
|
||||
* @param props the properties file
|
||||
*/
|
||||
void setupMapping(Properties props)
|
||||
{
|
||||
Enumeration propNames = props.propertyNames();
|
||||
while (propNames.hasMoreElements())
|
||||
{
|
||||
try
|
||||
{
|
||||
String nat = (String) propNames.nextElement();
|
||||
String mime = (String) props.getProperty(nat);
|
||||
// Check valid mime type.
|
||||
MimeType type = new MimeType(mime);
|
||||
DataFlavor flav = new DataFlavor(mime);
|
||||
|
||||
List<DataFlavor> flavs = nativeToFlavorMap.get(nat);
|
||||
if (flavs == null)
|
||||
{
|
||||
flavs = new ArrayList<DataFlavor>();
|
||||
nativeToFlavorMap.put(nat, flavs);
|
||||
}
|
||||
List<String> nats = flavorToNativeMap.get(flav);
|
||||
if (nats == null)
|
||||
{
|
||||
nats = new ArrayList<String>();
|
||||
flavorToNativeMap.put(flav, nats);
|
||||
}
|
||||
flavs.add(flav);
|
||||
nats.add(nat);
|
||||
}
|
||||
catch (ClassNotFoundException ex)
|
||||
{
|
||||
// Skip.
|
||||
}
|
||||
catch (MimeTypeParseException ex)
|
||||
{
|
||||
// Skip.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -263,16 +355,52 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable
|
|||
* specified native and a DataFlavor whose MIME type is a decoded
|
||||
* version of the native.
|
||||
*/
|
||||
public List<DataFlavor> getFlavorsForNative (String nat)
|
||||
throws NotImplementedException
|
||||
public List<DataFlavor> getFlavorsForNative(String nat)
|
||||
{
|
||||
throw new Error ("Not implemented");
|
||||
List<DataFlavor> ret = new ArrayList<DataFlavor>();
|
||||
if (nat == null)
|
||||
{
|
||||
Collection<List<DataFlavor>> all = nativeToFlavorMap.values();
|
||||
for (List<DataFlavor> list : all)
|
||||
{
|
||||
for (DataFlavor flav : list)
|
||||
{
|
||||
if (! ret.contains(flav))
|
||||
ret.add(flav);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
List<DataFlavor> list = nativeToFlavorMap.get(nat);
|
||||
if (list != null)
|
||||
ret.addAll(list);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<String> getNativesForFlavor (DataFlavor flav)
|
||||
throws NotImplementedException
|
||||
{
|
||||
throw new Error ("Not implemented");
|
||||
List<String> ret = new ArrayList<String>();
|
||||
if (flav == null)
|
||||
{
|
||||
Collection<List<String>> all = flavorToNativeMap.values();
|
||||
for (List<String> list : all)
|
||||
{
|
||||
for (String nat : list)
|
||||
{
|
||||
if (! ret.contains(nat))
|
||||
ret.add(nat);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
List<String> list = flavorToNativeMap.get(flav);
|
||||
if (list != null)
|
||||
ret.addAll(list);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -298,10 +426,10 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable
|
|||
{
|
||||
if ((nativeStr == null) || (flavor == null))
|
||||
throw new NullPointerException();
|
||||
List flavors = (List) nativeToFlavorMap.get(nativeStr);
|
||||
List<DataFlavor> flavors = nativeToFlavorMap.get(nativeStr);
|
||||
if (flavors == null)
|
||||
{
|
||||
flavors = new ArrayList();
|
||||
flavors = new ArrayList<DataFlavor>();
|
||||
nativeToFlavorMap.put(nativeStr, flavors);
|
||||
}
|
||||
else
|
||||
|
@ -336,10 +464,10 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable
|
|||
{
|
||||
if ((nativeStr == null) || (flavor == null))
|
||||
throw new NullPointerException();
|
||||
List natives = (List) flavorToNativeMap.get(flavor);
|
||||
List<String> natives = flavorToNativeMap.get(flavor);
|
||||
if (natives == null)
|
||||
{
|
||||
natives = new ArrayList();
|
||||
natives = new ArrayList<String>();
|
||||
flavorToNativeMap.put(flavor, natives);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -79,22 +79,17 @@ import java.awt.Shape;
|
|||
*/
|
||||
public final class GeneralPath implements Shape, Cloneable
|
||||
{
|
||||
// WORKAROUND for gcj 4.0.x (x < 3)
|
||||
// fully qualify PathIterator constants.
|
||||
|
||||
/** Same constant as {@link PathIterator#WIND_EVEN_ODD}. */
|
||||
public static final int WIND_EVEN_ODD
|
||||
= java.awt.geom.PathIterator.WIND_EVEN_ODD;
|
||||
public static final int WIND_EVEN_ODD = PathIterator.WIND_EVEN_ODD;
|
||||
|
||||
/** Same constant as {@link PathIterator#WIND_NON_ZERO}. */
|
||||
public static final int WIND_NON_ZERO
|
||||
= java.awt.geom.PathIterator.WIND_NON_ZERO;
|
||||
public static final int WIND_NON_ZERO = PathIterator.WIND_NON_ZERO;
|
||||
|
||||
/** Initial size if not specified. */
|
||||
private static final int INIT_SIZE = 10;
|
||||
|
||||
/** A big number, but not so big it can't survive a few float operations */
|
||||
private static final double BIG_VALUE = java.lang.Double.MAX_VALUE / 10.0;
|
||||
private static final double BIG_VALUE = Double.MAX_VALUE / 10.0;
|
||||
|
||||
/** The winding rule.
|
||||
* This is package-private to avoid an accessor method.
|
||||
|
|
|
@ -39,7 +39,9 @@ exception statement from your version. */
|
|||
package java.awt.image;
|
||||
|
||||
import gnu.java.awt.Buffers;
|
||||
import gnu.java.awt.ClasspathGraphicsEnvironment;
|
||||
import gnu.java.awt.ComponentDataBlitOp;
|
||||
import gnu.java.awt.peer.gtk.CairoSurface;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
|
@ -83,7 +85,7 @@ public class BufferedImage extends Image
|
|||
/**
|
||||
* Vector of TileObservers (or null)
|
||||
*/
|
||||
Vector tileObservers;
|
||||
Vector<TileObserver> tileObservers;
|
||||
|
||||
/**
|
||||
* The image's WritableRaster
|
||||
|
@ -143,39 +145,39 @@ public class BufferedImage extends Image
|
|||
{
|
||||
SampleModel sm = null;
|
||||
ColorModel cm = null;
|
||||
boolean premultiplied = (type == BufferedImage.TYPE_INT_ARGB_PRE ||
|
||||
type == BufferedImage.TYPE_4BYTE_ABGR_PRE);
|
||||
boolean premultiplied = (type == BufferedImage.TYPE_INT_ARGB_PRE
|
||||
|| type == BufferedImage.TYPE_4BYTE_ABGR_PRE);
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case BufferedImage.TYPE_INT_RGB:
|
||||
sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_INT,
|
||||
width, height,
|
||||
new int[]{ 0x00FF0000,
|
||||
0x0000FF00,
|
||||
0x000000FF } ) ;
|
||||
cm = new DirectColorModel( 24, 0xff0000, 0xff00, 0xff );
|
||||
break;
|
||||
sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_INT,
|
||||
width, height,
|
||||
new int[]{ 0x00FF0000,
|
||||
0x0000FF00,
|
||||
0x000000FF } ) ;
|
||||
cm = new DirectColorModel( 24, 0xff0000, 0xff00, 0xff );
|
||||
break;
|
||||
|
||||
case BufferedImage.TYPE_3BYTE_BGR:
|
||||
sm = new PixelInterleavedSampleModel( DataBuffer.TYPE_BYTE,
|
||||
width, height,
|
||||
3, width * 3,
|
||||
new int[]{ 2, 1, 0 } );
|
||||
cm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
|
||||
false, false,
|
||||
BufferedImage.OPAQUE,
|
||||
DataBuffer.TYPE_BYTE);
|
||||
sm = new PixelInterleavedSampleModel( DataBuffer.TYPE_BYTE,
|
||||
width, height,
|
||||
3, width * 3,
|
||||
new int[]{ 2, 1, 0 } );
|
||||
cm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
|
||||
false, false,
|
||||
BufferedImage.OPAQUE,
|
||||
DataBuffer.TYPE_BYTE);
|
||||
break;
|
||||
|
||||
case BufferedImage.TYPE_INT_ARGB:
|
||||
case BufferedImage.TYPE_INT_ARGB_PRE:
|
||||
sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_INT,
|
||||
width, height,
|
||||
new int[]{ 0x00FF0000,
|
||||
0x0000FF00,
|
||||
0x000000FF,
|
||||
0xFF000000 } );
|
||||
sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_INT,
|
||||
width, height,
|
||||
new int[]{ 0x00FF0000,
|
||||
0x0000FF00,
|
||||
0x000000FF,
|
||||
0xFF000000 } );
|
||||
if (premultiplied)
|
||||
cm = new DirectColorModel( ColorSpace.getInstance(ColorSpace.CS_sRGB),
|
||||
32, 0xff0000, 0xff00, 0xff, 0xff000000,
|
||||
|
@ -183,7 +185,8 @@ public class BufferedImage extends Image
|
|||
Buffers.smallestAppropriateTransferType(32));
|
||||
else
|
||||
cm = new DirectColorModel( 32, 0xff0000, 0xff00, 0xff, 0xff000000 );
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
case BufferedImage.TYPE_4BYTE_ABGR:
|
||||
case BufferedImage.TYPE_4BYTE_ABGR_PRE:
|
||||
|
@ -195,57 +198,58 @@ public class BufferedImage extends Image
|
|||
true, premultiplied,
|
||||
BufferedImage.TRANSLUCENT,
|
||||
DataBuffer.TYPE_BYTE);
|
||||
break;
|
||||
break;
|
||||
|
||||
case BufferedImage.TYPE_INT_BGR:
|
||||
sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_INT,
|
||||
width, height,
|
||||
new int[]{ 0x000000FF,
|
||||
0x0000FF00,
|
||||
0x00FF0000 } ) ;
|
||||
cm = new DirectColorModel( 24, 0xff, 0xff00, 0xff0000 );
|
||||
sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_INT,
|
||||
width, height,
|
||||
new int[]{ 0x000000FF,
|
||||
0x0000FF00,
|
||||
0x00FF0000 } ) ;
|
||||
cm = new DirectColorModel( 24, 0xff, 0xff00, 0xff0000 );
|
||||
break;
|
||||
|
||||
case BufferedImage.TYPE_USHORT_565_RGB:
|
||||
sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_USHORT,
|
||||
width, height,
|
||||
new int[]{ 0xF800,
|
||||
0x7E0,
|
||||
0x1F } ) ;
|
||||
cm = new DirectColorModel( 16, 0xF800, 0x7E0, 0x1F );
|
||||
break;
|
||||
sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_USHORT,
|
||||
width, height,
|
||||
new int[]{ 0xF800,
|
||||
0x7E0,
|
||||
0x1F } ) ;
|
||||
cm = new DirectColorModel( 16, 0xF800, 0x7E0, 0x1F );
|
||||
break;
|
||||
|
||||
case BufferedImage.TYPE_USHORT_555_RGB:
|
||||
sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_USHORT,
|
||||
width, height,
|
||||
new int[]{ 0x7C00,
|
||||
0x3E0,
|
||||
0x1F } ) ;
|
||||
cm = new DirectColorModel( 15, 0x7C00, 0x3E0, 0x1F );
|
||||
break;
|
||||
sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_USHORT,
|
||||
width, height,
|
||||
new int[]{ 0x7C00,
|
||||
0x3E0,
|
||||
0x1F } ) ;
|
||||
cm = new DirectColorModel( 15, 0x7C00, 0x3E0, 0x1F );
|
||||
break;
|
||||
|
||||
case BufferedImage.TYPE_BYTE_INDEXED:
|
||||
cm = createDefaultIndexedColorModel( false );
|
||||
cm = createDefaultIndexedColorModel( false );
|
||||
|
||||
case BufferedImage.TYPE_BYTE_GRAY:
|
||||
sm = new PixelInterleavedSampleModel( DataBuffer.TYPE_BYTE,
|
||||
width, height,
|
||||
1, width, new int[]{ 0 } );
|
||||
break;
|
||||
sm = new PixelInterleavedSampleModel( DataBuffer.TYPE_BYTE,
|
||||
width, height,
|
||||
1, width, new int[]{ 0 } );
|
||||
break;
|
||||
|
||||
case BufferedImage.TYPE_USHORT_GRAY:
|
||||
sm = new PixelInterleavedSampleModel( DataBuffer.TYPE_USHORT,
|
||||
width, height,
|
||||
1, width, new int[]{ 0 } );
|
||||
break;
|
||||
sm = new PixelInterleavedSampleModel( DataBuffer.TYPE_USHORT,
|
||||
width, height,
|
||||
1, width, new int[]{ 0 } );
|
||||
break;
|
||||
|
||||
case BufferedImage.TYPE_BYTE_BINARY:
|
||||
cm = createDefaultIndexedColorModel( true );
|
||||
sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
|
||||
width, height, 1);
|
||||
break;
|
||||
cm = createDefaultIndexedColorModel( true );
|
||||
sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
|
||||
width, height, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
sm = null;
|
||||
sm = null;
|
||||
}
|
||||
|
||||
if( sm == null )
|
||||
|
@ -253,33 +257,41 @@ public class BufferedImage extends Image
|
|||
|
||||
if( cm == null ) // only for the grayscale types
|
||||
{
|
||||
int buftype;
|
||||
int[] bits = new int[1];
|
||||
if( type == BufferedImage.TYPE_BYTE_GRAY )
|
||||
{
|
||||
buftype = DataBuffer.TYPE_BYTE;
|
||||
bits[0] = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
buftype = DataBuffer.TYPE_USHORT;
|
||||
bits[0] = 16;
|
||||
}
|
||||
ColorSpace graySpace = ColorSpace.getInstance( ColorSpace.CS_GRAY );
|
||||
|
||||
cm = new ComponentColorModel( graySpace, bits, false, false,
|
||||
Transparency.OPAQUE, buftype );
|
||||
int buftype;
|
||||
int[] bits = new int[1];
|
||||
if( type == BufferedImage.TYPE_BYTE_GRAY )
|
||||
{
|
||||
buftype = DataBuffer.TYPE_BYTE;
|
||||
bits[0] = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
buftype = DataBuffer.TYPE_USHORT;
|
||||
bits[0] = 16;
|
||||
}
|
||||
ColorSpace graySpace = ColorSpace.getInstance( ColorSpace.CS_GRAY );
|
||||
|
||||
cm = new ComponentColorModel( graySpace, bits, false, false,
|
||||
Transparency.OPAQUE, buftype );
|
||||
}
|
||||
|
||||
init( cm,
|
||||
Raster.createWritableRaster(sm, new Point( 0, 0 ) ),
|
||||
premultiplied,
|
||||
null, // no properties
|
||||
type );
|
||||
WritableRaster rst = null;
|
||||
|
||||
// Attempt to create an accelerated backend for this image
|
||||
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
if (env instanceof ClasspathGraphicsEnvironment)
|
||||
rst = ((ClasspathGraphicsEnvironment)env).createRaster(cm, sm);
|
||||
|
||||
// Default to a standard Java raster & databuffer if needed
|
||||
if (rst == null)
|
||||
rst = Raster.createWritableRaster(sm, new Point( 0, 0 ) );
|
||||
|
||||
init(cm, rst, premultiplied,
|
||||
null, // no properties
|
||||
type );
|
||||
}
|
||||
|
||||
public BufferedImage(int w, int h, int type,
|
||||
IndexColorModel indexcolormodel)
|
||||
public BufferedImage(int w, int h, int type, IndexColorModel indexcolormodel)
|
||||
{
|
||||
if ((type != TYPE_BYTE_BINARY) && (type != TYPE_BYTE_INDEXED))
|
||||
throw new IllegalArgumentException("Type must be TYPE_BYTE_BINARY or TYPE_BYTE_INDEXED");
|
||||
|
@ -289,27 +301,21 @@ public class BufferedImage extends Image
|
|||
throw new IllegalArgumentException("Byte type cannot have a larger than 256-color palette.");
|
||||
|
||||
init( indexcolormodel,
|
||||
indexcolormodel.createCompatibleWritableRaster(w, h),
|
||||
indexcolormodel.isAlphaPremultiplied(),
|
||||
null, // no properties
|
||||
type );
|
||||
indexcolormodel.createCompatibleWritableRaster(w, h),
|
||||
indexcolormodel.isAlphaPremultiplied(),
|
||||
null, // no properties
|
||||
type );
|
||||
}
|
||||
|
||||
public BufferedImage(ColorModel colormodel,
|
||||
WritableRaster writableraster,
|
||||
boolean premultiplied,
|
||||
Hashtable<?,?> properties)
|
||||
public BufferedImage(ColorModel colormodel, WritableRaster writableraster,
|
||||
boolean premultiplied, Hashtable<?,?> properties)
|
||||
{
|
||||
init(colormodel, writableraster, premultiplied, properties,
|
||||
TYPE_CUSTOM);
|
||||
init(colormodel, writableraster, premultiplied, properties, TYPE_CUSTOM);
|
||||
}
|
||||
|
||||
|
||||
private void init(ColorModel cm,
|
||||
WritableRaster writableraster,
|
||||
boolean premultiplied,
|
||||
Hashtable properties,
|
||||
int type)
|
||||
private void init(ColorModel cm, WritableRaster writableraster,
|
||||
boolean premultiplied, Hashtable properties, int type)
|
||||
{
|
||||
raster = writableraster;
|
||||
colorModel = cm;
|
||||
|
@ -329,29 +335,32 @@ public class BufferedImage extends Image
|
|||
{
|
||||
if( binary )
|
||||
{
|
||||
byte[] t = new byte[]{ 0, (byte)255 };
|
||||
return new IndexColorModel( 1, 2, t, t, t );
|
||||
byte[] t = new byte[]{ 0, (byte)255 };
|
||||
return new IndexColorModel( 1, 2, t, t, t );
|
||||
}
|
||||
|
||||
byte[] r = new byte[256];
|
||||
byte[] g = new byte[256];
|
||||
byte[] b = new byte[256];
|
||||
|
||||
int index = 0;
|
||||
for( int i = 0; i < 6; i++ )
|
||||
for( int j = 0; j < 6; j++ )
|
||||
for( int k = 0; k < 6; k++ )
|
||||
{
|
||||
r[ index ] = (byte)(i * 51);
|
||||
g[ index ] = (byte)(j * 51);
|
||||
b[ index ] = (byte)(k * 51);
|
||||
index++;
|
||||
}
|
||||
for( int k = 0; k < 6; k++ )
|
||||
{
|
||||
r[ index ] = (byte)(i * 51);
|
||||
g[ index ] = (byte)(j * 51);
|
||||
b[ index ] = (byte)(k * 51);
|
||||
index++;
|
||||
}
|
||||
|
||||
while( index < 256 )
|
||||
{
|
||||
r[ index ] = g[ index ] = b[ index ] =
|
||||
(byte)(18 + (index - 216) * 6);
|
||||
index++;
|
||||
r[ index ] = g[ index ] = b[ index ] =
|
||||
(byte)(18 + (index - 216) * 6);
|
||||
index++;
|
||||
}
|
||||
|
||||
return new IndexColorModel( 8, 256, r, g, b );
|
||||
}
|
||||
|
||||
|
@ -375,12 +384,13 @@ public class BufferedImage extends Image
|
|||
// create a src child that has the right bounds...
|
||||
WritableRaster src =
|
||||
raster.createWritableChild(x, y, w, h, x, y,
|
||||
null // same bands
|
||||
);
|
||||
null); // same bands
|
||||
|
||||
if (src.getSampleModel () instanceof ComponentSampleModel
|
||||
&& dest.getSampleModel () instanceof ComponentSampleModel)
|
||||
// Refer to ComponentDataBlitOp for optimized data blitting:
|
||||
ComponentDataBlitOp.INSTANCE.filter(src, dest);
|
||||
|
||||
else
|
||||
{
|
||||
// slower path
|
||||
|
@ -397,7 +407,8 @@ public class BufferedImage extends Image
|
|||
return env.createGraphics (this);
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
public void flush()
|
||||
{
|
||||
}
|
||||
|
||||
public WritableRaster getAlphaRaster()
|
||||
|
@ -512,26 +523,24 @@ public class BufferedImage extends Image
|
|||
|
||||
public int getRGB(int x, int y)
|
||||
{
|
||||
Object rgbElem = raster.getDataElements(x, y,
|
||||
null // create as needed
|
||||
);
|
||||
Object rgbElem = raster.getDataElements(x, y, null);
|
||||
return colorModel.getRGB(rgbElem);
|
||||
}
|
||||
|
||||
public int[] getRGB(int startX, int startY, int w, int h,
|
||||
int[] rgbArray,
|
||||
int offset, int scanlineStride)
|
||||
public int[] getRGB(int startX, int startY, int w, int h, int[] rgbArray,
|
||||
int offset, int scanlineStride)
|
||||
{
|
||||
if (rgbArray == null)
|
||||
{
|
||||
/*
|
||||
000000000000000000
|
||||
00000[#######----- [ = start
|
||||
-----########----- ] = end
|
||||
-----#######]00000
|
||||
000000000000000000 */
|
||||
int size = (h-1)*scanlineStride + w;
|
||||
rgbArray = new int[size];
|
||||
{
|
||||
/*
|
||||
000000000000000000
|
||||
00000[#######----- [ = start
|
||||
-----########----- ] = end
|
||||
-----#######]00000
|
||||
000000000000000000
|
||||
*/
|
||||
int size = (h-1)*scanlineStride + w;
|
||||
rgbArray = new int[size];
|
||||
}
|
||||
|
||||
int endX = startX + w;
|
||||
|
@ -547,15 +556,15 @@ public class BufferedImage extends Image
|
|||
Object rgbElem = null;
|
||||
for (int y=startY; y<endY; y++)
|
||||
{
|
||||
int xoffset = offset;
|
||||
for (int x=startX; x<endX; x++)
|
||||
{
|
||||
int rgb;
|
||||
rgbElem = raster.getDataElements(x, y, rgbElem);
|
||||
rgb = colorModel.getRGB(rgbElem);
|
||||
rgbArray[xoffset++] = rgb;
|
||||
}
|
||||
offset += scanlineStride;
|
||||
int xoffset = offset;
|
||||
for (int x=startX; x<endX; x++)
|
||||
{
|
||||
int rgb;
|
||||
rgbElem = raster.getDataElements(x, y, rgbElem);
|
||||
rgb = colorModel.getRGB(rgbElem);
|
||||
rgbArray[xoffset++] = rgb;
|
||||
}
|
||||
offset += scanlineStride;
|
||||
}
|
||||
return rgbArray;
|
||||
}
|
||||
|
@ -572,14 +581,14 @@ public class BufferedImage extends Image
|
|||
|
||||
public ImageProducer getSource()
|
||||
{
|
||||
return new ImageProducer() {
|
||||
|
||||
Vector consumers = new Vector();
|
||||
return new ImageProducer()
|
||||
{
|
||||
Vector<ImageConsumer> consumers = new Vector<ImageConsumer>();
|
||||
|
||||
public void addConsumer(ImageConsumer ic)
|
||||
{
|
||||
if(!consumers.contains(ic))
|
||||
consumers.add(ic);
|
||||
if(!consumers.contains(ic))
|
||||
consumers.add(ic);
|
||||
}
|
||||
|
||||
public boolean isConsumer(ImageConsumer ic)
|
||||
|
@ -589,7 +598,7 @@ public class BufferedImage extends Image
|
|||
|
||||
public void removeConsumer(ImageConsumer ic)
|
||||
{
|
||||
consumers.remove(ic);
|
||||
consumers.remove(ic);
|
||||
}
|
||||
|
||||
public void startProduction(ImageConsumer ic)
|
||||
|
@ -610,9 +619,9 @@ public class BufferedImage extends Image
|
|||
|
||||
consumers.add(ic);
|
||||
|
||||
for(int i=0;i<consumers.size();i++)
|
||||
for(int i = 0; i < consumers.size(); i++)
|
||||
{
|
||||
ImageConsumer c = (ImageConsumer) consumers.elementAt(i);
|
||||
ImageConsumer c = consumers.elementAt(i);
|
||||
c.setHints(ImageConsumer.SINGLEPASS);
|
||||
c.setDimensions(getWidth(), getHeight());
|
||||
c.setPixels(x, y, width, height, model, pixels, offset, stride);
|
||||
|
@ -638,10 +647,8 @@ public class BufferedImage extends Image
|
|||
WritableRaster subRaster =
|
||||
getRaster().createWritableChild(x, y, w, h, 0, 0, null);
|
||||
|
||||
return new BufferedImage(getColorModel(),
|
||||
subRaster,
|
||||
isPremultiplied,
|
||||
properties);
|
||||
return new BufferedImage(getColorModel(), subRaster, isPremultiplied,
|
||||
properties);
|
||||
}
|
||||
|
||||
public Raster getTile(int tileX, int tileY)
|
||||
|
@ -730,9 +737,7 @@ public class BufferedImage extends Image
|
|||
|
||||
// create a dest child that has the right bounds...
|
||||
WritableRaster dest =
|
||||
raster.createWritableChild(x, y, w, h, x, y,
|
||||
null // same bands
|
||||
);
|
||||
raster.createWritableChild(x, y, w, h, x, y, null);
|
||||
|
||||
if (src.getSampleModel () instanceof ComponentSampleModel
|
||||
&& dest.getSampleModel () instanceof ComponentSampleModel)
|
||||
|
@ -762,14 +767,14 @@ public class BufferedImage extends Image
|
|||
Object rgbElem = null;
|
||||
for (int y=startY; y<endY; y++)
|
||||
{
|
||||
int xoffset = offset;
|
||||
for (int x=startX; x<endX; x++)
|
||||
{
|
||||
int argb = argbArray[xoffset++];
|
||||
rgbElem = colorModel.getDataElements(argb, rgbElem);
|
||||
raster.setDataElements(x, y, rgbElem);
|
||||
}
|
||||
offset += scanlineStride;
|
||||
int xoffset = offset;
|
||||
for (int x=startX; x<endX; x++)
|
||||
{
|
||||
int argb = argbArray[xoffset++];
|
||||
rgbElem = colorModel.getDataElements(argb, rgbElem);
|
||||
raster.setDataElements(x, y, rgbElem);
|
||||
}
|
||||
offset += scanlineStride;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -800,7 +805,7 @@ public class BufferedImage extends Image
|
|||
public void addTileObserver (TileObserver to)
|
||||
{
|
||||
if (tileObservers == null)
|
||||
tileObservers = new Vector ();
|
||||
tileObservers = new Vector<TileObserver>();
|
||||
|
||||
tileObservers.add (to);
|
||||
}
|
||||
|
|
|
@ -36,12 +36,8 @@ exception statement from your version. */
|
|||
|
||||
package java.awt.image;
|
||||
|
||||
import gnu.java.awt.Buffers;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/* FIXME: This class does not yet support data type TYPE_SHORT */
|
||||
|
||||
/**
|
||||
* ComponentSampleModel supports a flexible organization of pixel samples in
|
||||
* memory, permitting pixel samples to be interleaved by band, by scanline,
|
||||
|
@ -88,9 +84,7 @@ public class ComponentSampleModel extends SampleModel
|
|||
* corresponding sample for the next pixel in the same row.
|
||||
*/
|
||||
protected int pixelStride;
|
||||
|
||||
private boolean tightPixelPacking = false;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new sample model that assumes that all bands are stored in a
|
||||
* single bank of the {@link DataBuffer}.
|
||||
|
@ -203,22 +197,6 @@ public class ComponentSampleModel extends SampleModel
|
|||
this.scanlineStride = scanlineStride;
|
||||
this.pixelStride = pixelStride;
|
||||
|
||||
// See if we can use some speedups
|
||||
|
||||
/* FIXME: May these checks should be reserved for the
|
||||
PixelInterleavedSampleModel? */
|
||||
|
||||
if (pixelStride == numBands)
|
||||
{
|
||||
tightPixelPacking = true;
|
||||
for (int b = 0; b < numBands; b++) {
|
||||
if ((bandOffsets[b] != b) || (bankIndices[b] != 0))
|
||||
{
|
||||
tightPixelPacking = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -275,8 +253,30 @@ public class ComponentSampleModel extends SampleModel
|
|||
highestOffset = Math.max(highestOffset, bandOffsets[b]);
|
||||
int size = pixelStride * (width - 1) + scanlineStride * (height - 1)
|
||||
+ highestOffset + 1;
|
||||
|
||||
return Buffers.createBuffer(getDataType(), size, numBanks);
|
||||
|
||||
DataBuffer buffer = null;
|
||||
switch (getTransferType())
|
||||
{
|
||||
case DataBuffer.TYPE_BYTE:
|
||||
buffer = new DataBufferByte(size, numBanks);
|
||||
break;
|
||||
case DataBuffer.TYPE_SHORT:
|
||||
buffer = new DataBufferShort(size, numBanks);
|
||||
break;
|
||||
case DataBuffer.TYPE_USHORT:
|
||||
buffer = new DataBufferUShort(size, numBanks);
|
||||
break;
|
||||
case DataBuffer.TYPE_INT:
|
||||
buffer = new DataBufferInt(size, numBanks);
|
||||
break;
|
||||
case DataBuffer.TYPE_FLOAT:
|
||||
buffer = new DataBufferFloat(size, numBanks);
|
||||
break;
|
||||
case DataBuffer.TYPE_DOUBLE:
|
||||
buffer = new DataBufferDouble(size, numBanks);
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -424,239 +424,80 @@ public class ComponentSampleModel extends SampleModel
|
|||
*/
|
||||
public Object getDataElements(int x, int y, Object obj, DataBuffer data)
|
||||
{
|
||||
int xyOffset = pixelStride * x + scanlineStride * y;
|
||||
|
||||
int[] totalBandDataOffsets = new int[numBands];
|
||||
|
||||
/* Notice that band and bank offsets are different. Band offsets
|
||||
are managed by the sample model, and bank offsets are managed
|
||||
by the data buffer. Both must be accounted for. */
|
||||
|
||||
/* FIXME: For single pixels, it is probably easier to simple
|
||||
call getElem instead of calculating the bank offset ourself.
|
||||
|
||||
On the other hand, then we need to push the value through
|
||||
the int type returned by the getElem method. */
|
||||
|
||||
int[] bankOffsets = data.getOffsets();
|
||||
|
||||
for (int b = 0; b < numBands; b++)
|
||||
int type = getTransferType();
|
||||
int numDataEls = getNumDataElements();
|
||||
int offset = y * scanlineStride + x * pixelStride;
|
||||
switch (type)
|
||||
{
|
||||
totalBandDataOffsets[b] = bandOffsets[b] + bankOffsets[bankIndices[b]]
|
||||
+ xyOffset;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
switch (getTransferType())
|
||||
case DataBuffer.TYPE_BYTE:
|
||||
byte[] bData;
|
||||
if (obj == null)
|
||||
bData = new byte[numDataEls];
|
||||
else
|
||||
bData = (byte[]) obj;
|
||||
for (int i = 0; i < numDataEls; i++)
|
||||
{
|
||||
case DataBuffer.TYPE_BYTE:
|
||||
DataBufferByte inByte = (DataBufferByte) data;
|
||||
byte[] outByte = (byte[]) obj;
|
||||
if (outByte == null)
|
||||
outByte = new byte[numBands];
|
||||
|
||||
for (int b = 0; b < numBands; b++)
|
||||
{
|
||||
int dOffset = totalBandDataOffsets[b];
|
||||
outByte[b] = inByte.getData(bankIndices[b])[dOffset];
|
||||
}
|
||||
return outByte;
|
||||
|
||||
case DataBuffer.TYPE_USHORT:
|
||||
DataBufferUShort inUShort = (DataBufferUShort) data;
|
||||
short[] outUShort = (short[]) obj;
|
||||
if (outUShort == null)
|
||||
outUShort = new short[numBands];
|
||||
|
||||
for (int b = 0; b < numBands; b++)
|
||||
{
|
||||
int dOffset = totalBandDataOffsets[b];
|
||||
outUShort[b] = inUShort.getData(bankIndices[b])[dOffset];
|
||||
}
|
||||
return outUShort;
|
||||
|
||||
case DataBuffer.TYPE_SHORT:
|
||||
DataBufferShort inShort = (DataBufferShort) data;
|
||||
short[] outShort = (short[]) obj;
|
||||
if (outShort == null)
|
||||
outShort = new short[numBands];
|
||||
|
||||
for (int b = 0; b < numBands; b++)
|
||||
{
|
||||
int dOffset = totalBandDataOffsets[b];
|
||||
outShort[b] = inShort.getData(bankIndices[b])[dOffset];
|
||||
}
|
||||
return outShort;
|
||||
|
||||
case DataBuffer.TYPE_INT:
|
||||
DataBufferInt inInt = (DataBufferInt) data;
|
||||
int[] outInt = (int[]) obj;
|
||||
if (outInt == null)
|
||||
outInt = new int[numBands];
|
||||
|
||||
for (int b = 0; b < numBands; b++)
|
||||
{
|
||||
int dOffset = totalBandDataOffsets[b];
|
||||
outInt[b] = inInt.getData(bankIndices[b])[dOffset];
|
||||
}
|
||||
return outInt;
|
||||
|
||||
case DataBuffer.TYPE_FLOAT:
|
||||
DataBufferFloat inFloat = (DataBufferFloat) data;
|
||||
float[] outFloat = (float[]) obj;
|
||||
if (outFloat == null)
|
||||
outFloat = new float[numBands];
|
||||
|
||||
for (int b = 0; b < numBands; b++)
|
||||
{
|
||||
int dOffset = totalBandDataOffsets[b];
|
||||
outFloat[b] = inFloat.getData(bankIndices[b])[dOffset];
|
||||
}
|
||||
return outFloat;
|
||||
|
||||
case DataBuffer.TYPE_DOUBLE:
|
||||
DataBufferDouble inDouble = (DataBufferDouble) data;
|
||||
double[] outDouble = (double[]) obj;
|
||||
if (outDouble == null)
|
||||
outDouble = new double[numBands];
|
||||
|
||||
for (int b = 0; b < numBands; b++)
|
||||
{
|
||||
int dOffset = totalBandDataOffsets[b];
|
||||
outDouble[b] = inDouble.getData(bankIndices[b])[dOffset];
|
||||
}
|
||||
return outDouble;
|
||||
|
||||
default:
|
||||
throw new IllegalStateException("unknown transfer type "
|
||||
+ getTransferType());
|
||||
bData[i] = (byte) data.getElem(bankIndices[i],
|
||||
offset + bandOffsets[i]);
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException aioobe)
|
||||
{
|
||||
String msg = "While reading data elements, " +
|
||||
"x=" + x + ", y=" + y +", " + ", xyOffset=" + xyOffset +
|
||||
", data.getSize()=" + data.getSize() + ": " + aioobe;
|
||||
throw new ArrayIndexOutOfBoundsException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the samples for the pixels in the region defined by
|
||||
* <code>(x, y, w, h)</code> in a primitive array (the array type is
|
||||
* determined by the data type for this model). The <code>obj</code>
|
||||
* argument provides an option to supply an existing array to hold the
|
||||
* result, if this is <code>null</code> a new array will be allocated.
|
||||
*
|
||||
* @param x the x-coordinate.
|
||||
* @param y the y-coordinate.
|
||||
* @param w the width.
|
||||
* @param h the height.
|
||||
* @param obj a primitive array that, if not <code>null</code>, will be
|
||||
* used to store and return the sample values.
|
||||
* @param data the data buffer (<code>null</code> not permitted).
|
||||
*
|
||||
* @return An array of sample values for the specified pixels.
|
||||
*
|
||||
* @see #setDataElements(int, int, int, int, Object, DataBuffer)
|
||||
*/
|
||||
public Object getDataElements(int x, int y, int w, int h, Object obj,
|
||||
DataBuffer data)
|
||||
{
|
||||
if (!tightPixelPacking)
|
||||
{
|
||||
return super.getDataElements(x, y, w, h, obj, data);
|
||||
}
|
||||
|
||||
// using get speedup
|
||||
|
||||
// We can copy whole rows
|
||||
int rowSize = w * numBands;
|
||||
int dataSize = rowSize * h;
|
||||
|
||||
DataBuffer transferBuffer = Buffers.createBuffer(getTransferType(), obj,
|
||||
dataSize);
|
||||
obj = Buffers.getData(transferBuffer);
|
||||
|
||||
int inOffset = pixelStride * x + scanlineStride * y + data.getOffset();
|
||||
// Assumes only one band is used
|
||||
|
||||
/* We don't add band offsets since we assume that bands have
|
||||
offsets 0, 1, 2, ... */
|
||||
|
||||
// See if we can copy everything in one go
|
||||
if (scanlineStride == rowSize)
|
||||
{
|
||||
// Collapse scan lines:
|
||||
rowSize *= h;
|
||||
// We ignore scanlineStride since it won't be of any use
|
||||
h = 1;
|
||||
}
|
||||
|
||||
int outOffset = 0;
|
||||
Object inArray = Buffers.getData(data);
|
||||
for (int yd = 0; yd < h; yd++)
|
||||
{
|
||||
System.arraycopy(inArray, inOffset, obj, outOffset, rowSize);
|
||||
inOffset += scanlineStride;
|
||||
outOffset += rowSize;
|
||||
obj = bData;
|
||||
break;
|
||||
case DataBuffer.TYPE_SHORT:
|
||||
case DataBuffer.TYPE_USHORT:
|
||||
short[] sData;
|
||||
if (obj == null)
|
||||
sData = new short[numDataEls];
|
||||
else
|
||||
sData = (short[]) obj;
|
||||
for (int i = 0; i < numDataEls; i++)
|
||||
{
|
||||
sData[i] = (short) data.getElem(bankIndices[i],
|
||||
offset + bandOffsets[i]);
|
||||
}
|
||||
obj = sData;
|
||||
break;
|
||||
case DataBuffer.TYPE_INT:
|
||||
int[] iData;
|
||||
if (obj == null)
|
||||
iData = new int[numDataEls];
|
||||
else
|
||||
iData = (int[]) obj;
|
||||
for (int i = 0; i < numDataEls; i++)
|
||||
{
|
||||
iData[i] = data.getElem(bankIndices[i], offset + bandOffsets[i]);
|
||||
}
|
||||
obj = iData;
|
||||
break;
|
||||
case DataBuffer.TYPE_FLOAT:
|
||||
float[] fData;
|
||||
if (obj == null)
|
||||
fData = new float[numDataEls];
|
||||
else
|
||||
fData = (float[]) obj;
|
||||
for (int i = 0; i < numDataEls; i++)
|
||||
{
|
||||
fData[i] = data.getElemFloat(bankIndices[i],
|
||||
offset + bandOffsets[i]);
|
||||
}
|
||||
obj = fData;
|
||||
break;
|
||||
case DataBuffer.TYPE_DOUBLE:
|
||||
double[] dData;
|
||||
if (obj == null)
|
||||
dData = new double[numDataEls];
|
||||
else
|
||||
dData = (double[]) obj;
|
||||
for (int i = 0; i < numDataEls; i++)
|
||||
{
|
||||
dData[i] = data.getElemDouble(bankIndices[i],
|
||||
offset + bandOffsets[i]);
|
||||
}
|
||||
obj = dData;
|
||||
break;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the samples for the pixels in the region defined by
|
||||
* <code>(x, y, w, h)</code> from a supplied primitive array (the array type
|
||||
* must be consistent with the data type for this model).
|
||||
*
|
||||
* @param x the x-coordinate.
|
||||
* @param y the y-coordinate.
|
||||
* @param w the width.
|
||||
* @param h the height.
|
||||
* @param obj a primitive array containing the sample values.
|
||||
* @param data the data buffer (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getDataElements(int, int, int, int, Object, DataBuffer)
|
||||
*/
|
||||
public void setDataElements(int x, int y, int w, int h,
|
||||
Object obj, DataBuffer data)
|
||||
{
|
||||
if (!tightPixelPacking)
|
||||
{
|
||||
super.setDataElements(x, y, w, h, obj, data);
|
||||
return;
|
||||
}
|
||||
|
||||
// using set speedup, we can copy whole rows
|
||||
int rowSize = w * numBands;
|
||||
int dataSize = rowSize * h;
|
||||
|
||||
DataBuffer transferBuffer
|
||||
= Buffers.createBufferFromData(getTransferType(), obj, dataSize);
|
||||
|
||||
int[] bankOffsets = data.getOffsets();
|
||||
|
||||
int outOffset = pixelStride * x + scanlineStride * y + bankOffsets[0];
|
||||
// same assumptions as in get...
|
||||
|
||||
// See if we can copy everything in one go
|
||||
if (scanlineStride == rowSize)
|
||||
{
|
||||
// Collapse scan lines:
|
||||
rowSize *= h;
|
||||
h = 1;
|
||||
}
|
||||
|
||||
int inOffset = 0;
|
||||
Object outArray = Buffers.getData(data);
|
||||
for (int yd = 0; yd < h; yd++)
|
||||
{
|
||||
System.arraycopy(obj, inOffset, outArray, outOffset, rowSize);
|
||||
outOffset += scanlineStride;
|
||||
inOffset += rowSize;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the samples for the pixel at location <code>(x, y)</code>
|
||||
|
@ -764,78 +605,51 @@ public class ComponentSampleModel extends SampleModel
|
|||
*/
|
||||
public void setDataElements(int x, int y, Object obj, DataBuffer data)
|
||||
{
|
||||
int offset = pixelStride * x + scanlineStride * y;
|
||||
int[] totalBandDataOffsets = new int[numBands];
|
||||
int[] bankOffsets = data.getOffsets();
|
||||
for (int b = 0; b < numBands; b++)
|
||||
totalBandDataOffsets[b] = bandOffsets[b] + bankOffsets[bankIndices[b]]
|
||||
+ offset;
|
||||
|
||||
switch (getTransferType())
|
||||
int type = getTransferType();
|
||||
int numDataEls = getNumDataElements();
|
||||
int offset = y * scanlineStride + x * pixelStride;
|
||||
switch (type)
|
||||
{
|
||||
case DataBuffer.TYPE_BYTE:
|
||||
{
|
||||
DataBufferByte out = (DataBufferByte) data;
|
||||
byte[] in = (byte[]) obj;
|
||||
|
||||
for (int b = 0; b < numBands; b++)
|
||||
out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b];
|
||||
|
||||
return;
|
||||
}
|
||||
case DataBuffer.TYPE_USHORT:
|
||||
{
|
||||
DataBufferUShort out = (DataBufferUShort) data;
|
||||
short[] in = (short[]) obj;
|
||||
|
||||
for (int b = 0; b < numBands; b++)
|
||||
out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b];
|
||||
|
||||
return;
|
||||
}
|
||||
byte[] bData = (byte[]) obj;
|
||||
for (int i = 0; i < numDataEls; i++)
|
||||
{
|
||||
data.setElem(bankIndices[i], offset + bandOffsets[i],
|
||||
((int) bData[i]) & 0xFF);
|
||||
}
|
||||
break;
|
||||
case DataBuffer.TYPE_SHORT:
|
||||
{
|
||||
DataBufferShort out = (DataBufferShort) data;
|
||||
short[] in = (short[]) obj;
|
||||
|
||||
for (int b = 0; b < numBands; b++)
|
||||
out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b];
|
||||
|
||||
return;
|
||||
}
|
||||
case DataBuffer.TYPE_USHORT:
|
||||
short[] sData = (short[]) obj;
|
||||
for (int i = 0; i < numDataEls; i++)
|
||||
{
|
||||
data.setElem(bankIndices[i], offset + bandOffsets[i],
|
||||
((int) sData[i]) & 0xFFFF);
|
||||
}
|
||||
break;
|
||||
case DataBuffer.TYPE_INT:
|
||||
{
|
||||
DataBufferInt out = (DataBufferInt) data;
|
||||
int[] in = (int[]) obj;
|
||||
|
||||
for (int b = 0; b < numBands; b++)
|
||||
out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b];
|
||||
|
||||
return;
|
||||
}
|
||||
int[] iData = (int[]) obj;
|
||||
for (int i = 0; i < numDataEls; i++)
|
||||
{
|
||||
data.setElem(bankIndices[i], offset + bandOffsets[i], iData[i]);
|
||||
}
|
||||
break;
|
||||
case DataBuffer.TYPE_FLOAT:
|
||||
{
|
||||
DataBufferFloat out = (DataBufferFloat) data;
|
||||
float[] in = (float[]) obj;
|
||||
|
||||
for (int b = 0; b < numBands; b++)
|
||||
out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b];
|
||||
|
||||
return;
|
||||
}
|
||||
float[] fData = (float[]) obj;
|
||||
for (int i = 0; i < numDataEls; i++)
|
||||
{
|
||||
data.setElemFloat(bankIndices[i], offset + bandOffsets[i],
|
||||
fData[i]);
|
||||
}
|
||||
break;
|
||||
case DataBuffer.TYPE_DOUBLE:
|
||||
{
|
||||
DataBufferDouble out = (DataBufferDouble) data;
|
||||
double[] in = (double[]) obj;
|
||||
|
||||
for (int b = 0; b < numBands; b++)
|
||||
out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b];
|
||||
|
||||
return;
|
||||
}
|
||||
default:
|
||||
throw new UnsupportedOperationException("transfer type not " +
|
||||
"implemented");
|
||||
double[] dData = (double[]) obj;
|
||||
for (int i = 0; i < numDataEls; i++)
|
||||
{
|
||||
data.setElemDouble(bankIndices[i], offset + bandOffsets[i],
|
||||
dData[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ public class IndexColorModel extends ColorModel
|
|||
if (size < 1)
|
||||
throw new IllegalArgumentException("size < 1");
|
||||
map_size = size;
|
||||
rgb = new int[size];
|
||||
rgb = createColorMap(bits, size);
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
rgb[i] = (0xff000000
|
||||
|
@ -187,7 +187,7 @@ public class IndexColorModel extends ColorModel
|
|||
map_size = size;
|
||||
opaque = (alphas == null);
|
||||
|
||||
rgb = new int[size];
|
||||
rgb = createColorMap(bits, size);
|
||||
if (alphas == null)
|
||||
{
|
||||
for (int i = 0; i < size; i++)
|
||||
|
@ -275,7 +275,7 @@ public class IndexColorModel extends ColorModel
|
|||
map_size = size;
|
||||
opaque = !hasAlpha;
|
||||
|
||||
rgb = new int[size];
|
||||
rgb = createColorMap(bits, size);
|
||||
if (hasAlpha)
|
||||
{
|
||||
int alpha;
|
||||
|
@ -360,7 +360,7 @@ public class IndexColorModel extends ColorModel
|
|||
throw new IllegalArgumentException("size < 1");
|
||||
map_size = size;
|
||||
opaque = !hasAlpha;
|
||||
rgb = new int[size];
|
||||
rgb = createColorMap(bits, size);
|
||||
if (!hasAlpha)
|
||||
for (int i = 0; i < size; i++)
|
||||
rgb[i] = cmap[i + start] | 0xff000000;
|
||||
|
@ -419,7 +419,7 @@ public class IndexColorModel extends ColorModel
|
|||
this.trans = -1;
|
||||
this.validBits = validBits;
|
||||
|
||||
rgb = new int[size];
|
||||
rgb = createColorMap(bits, size);
|
||||
if (!hasAlpha)
|
||||
for (int i = 0; i < size; i++)
|
||||
rgb[i] = cmap[i + start] | 0xff000000;
|
||||
|
@ -726,4 +726,11 @@ public class IndexColorModel extends ColorModel
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int[] createColorMap(int bits, int size)
|
||||
{
|
||||
// According to a Mauve test, the RI allocates at least 256 entries here.
|
||||
int realSize = Math.max(256, Math.max(1 << bits, size));
|
||||
return new int[realSize];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ package java.awt.image;
|
|||
import java.util.Arrays;
|
||||
|
||||
import gnu.java.awt.BitMaskExtent;
|
||||
import gnu.java.awt.Buffers;
|
||||
|
||||
/**
|
||||
* A <code>SampleModel</code> used when all samples are stored in a single
|
||||
|
@ -151,14 +150,25 @@ public class SinglePixelPackedSampleModel extends SampleModel
|
|||
*/
|
||||
public DataBuffer createDataBuffer()
|
||||
{
|
||||
int size;
|
||||
|
||||
// We can save (scanlineStride - width) pixels at the very end of
|
||||
// the buffer. The Sun reference implementation (J2SE 1.3.1 and
|
||||
// 1.4.1_01) seems to do this; tested with Mauve test code.
|
||||
size = scanlineStride * (height - 1) + width;
|
||||
int size = scanlineStride * (height - 1) + width;
|
||||
|
||||
return Buffers.createBuffer(getDataType(), size);
|
||||
DataBuffer buffer = null;
|
||||
switch (getTransferType())
|
||||
{
|
||||
case DataBuffer.TYPE_BYTE:
|
||||
buffer = new DataBufferByte(size);
|
||||
break;
|
||||
case DataBuffer.TYPE_USHORT:
|
||||
buffer = new DataBufferUShort(size);
|
||||
break;
|
||||
case DataBuffer.TYPE_INT:
|
||||
buffer = new DataBufferInt(size);
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -253,73 +263,39 @@ public class SinglePixelPackedSampleModel extends SampleModel
|
|||
public Object getDataElements(int x, int y, Object obj,
|
||||
DataBuffer data)
|
||||
{
|
||||
int offset = scanlineStride*y + x + data.getOffset();
|
||||
|
||||
return Buffers.getData(data, offset, obj,
|
||||
0, // destination offset,
|
||||
1 // length
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a more efficient implementation of the default implementation in
|
||||
* the super class.
|
||||
* @param x The x-coordinate of the pixel rectangle to store in
|
||||
* <code>obj</code>.
|
||||
* @param y The y-coordinate of the pixel rectangle to store in
|
||||
* <code>obj</code>.
|
||||
* @param w The width of the pixel rectangle to store in <code>obj</code>.
|
||||
* @param h The height of the pixel rectangle to store in <code>obj</code>.
|
||||
* @param obj The primitive array to store the pixels into or null to force
|
||||
* creation.
|
||||
* @param data The DataBuffer that is the source of the pixel data.
|
||||
* @return The primitive array containing the pixel data.
|
||||
* @see java.awt.image.SampleModel#getDataElements(int, int, int, int,
|
||||
* java.lang.Object, java.awt.image.DataBuffer)
|
||||
*/
|
||||
public Object getDataElements(int x, int y, int w, int h, Object obj,
|
||||
DataBuffer data)
|
||||
{
|
||||
int size = w*h;
|
||||
int dataSize = size;
|
||||
Object pixelData = null;
|
||||
switch (getTransferType())
|
||||
{
|
||||
int type = getTransferType();
|
||||
Object ret = null;
|
||||
switch (type)
|
||||
{
|
||||
case DataBuffer.TYPE_BYTE:
|
||||
pixelData = ((DataBufferByte) data).getData();
|
||||
if (obj == null) obj = new byte[dataSize];
|
||||
break;
|
||||
case DataBuffer.TYPE_USHORT:
|
||||
pixelData = ((DataBufferUShort) data).getData();
|
||||
if (obj == null) obj = new short[dataSize];
|
||||
break;
|
||||
case DataBuffer.TYPE_INT:
|
||||
pixelData = ((DataBufferInt) data).getData();
|
||||
if (obj == null) obj = new int[dataSize];
|
||||
break;
|
||||
default:
|
||||
// Seems like the only sensible thing to do.
|
||||
throw new ClassCastException();
|
||||
}
|
||||
if(x == 0 && scanlineStride == w)
|
||||
{
|
||||
// The full width need to be copied therefore we can copy in one shot.
|
||||
System.arraycopy(pixelData, scanlineStride*y + data.getOffset(), obj,
|
||||
0, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Since we do not need the full width we need to copy line by line.
|
||||
int outOffset = 0;
|
||||
int dataOffset = scanlineStride*y + x + data.getOffset();
|
||||
for (int yy = y; yy<(y+h); yy++)
|
||||
{
|
||||
System.arraycopy(pixelData, dataOffset, obj, outOffset, w);
|
||||
dataOffset += scanlineStride;
|
||||
outOffset += w;
|
||||
byte[] in = (byte[]) obj;
|
||||
if (in == null)
|
||||
in = new byte[1];
|
||||
in[0] = (byte) data.getElem(x + y * scanlineStride);
|
||||
ret = in;
|
||||
}
|
||||
break;
|
||||
case DataBuffer.TYPE_USHORT:
|
||||
{
|
||||
short[] in = (short[]) obj;
|
||||
if (in == null)
|
||||
in = new short[1];
|
||||
in[0] = (short) data.getElem(x + y * scanlineStride);
|
||||
ret = in;
|
||||
}
|
||||
break;
|
||||
case DataBuffer.TYPE_INT:
|
||||
{
|
||||
int[] in = (int[]) obj;
|
||||
if (in == null)
|
||||
in = new int[1];
|
||||
in[0] = data.getElem(x + y * scanlineStride);
|
||||
ret = in;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return obj;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -414,30 +390,29 @@ public class SinglePixelPackedSampleModel extends SampleModel
|
|||
|
||||
public void setDataElements(int x, int y, Object obj, DataBuffer data)
|
||||
{
|
||||
|
||||
int transferType = getTransferType();
|
||||
switch (transferType)
|
||||
{
|
||||
case DataBuffer.TYPE_BYTE:
|
||||
{
|
||||
byte[] in = (byte[]) obj;
|
||||
data.setElem(y * scanlineStride + x, ((int) in[0]) & 0xff);
|
||||
break;
|
||||
}
|
||||
case DataBuffer.TYPE_USHORT:
|
||||
{
|
||||
short[] in = (short[]) obj;
|
||||
switch (transferType)
|
||||
{
|
||||
case DataBuffer.TYPE_BYTE:
|
||||
{
|
||||
byte[] in = (byte[]) obj;
|
||||
data.setElem(y * scanlineStride + x, ((int) in[0]) & 0xff);
|
||||
}
|
||||
break;
|
||||
case DataBuffer.TYPE_USHORT:
|
||||
{
|
||||
short[] in = (short[]) obj;
|
||||
data.setElem(y * scanlineStride + x, ((int) in[0]) & 0xffff);
|
||||
break;
|
||||
}
|
||||
case DataBuffer.TYPE_INT:
|
||||
{
|
||||
int[] in = (int[]) obj;
|
||||
}
|
||||
break;
|
||||
case DataBuffer.TYPE_INT:
|
||||
{
|
||||
int[] in = (int[]) obj;
|
||||
data.setElem(y * scanlineStride + x, in[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the samples for the pixel at (x, y) in the specified data buffer to
|
||||
|
@ -479,7 +454,6 @@ public class SinglePixelPackedSampleModel extends SampleModel
|
|||
DataBuffer data)
|
||||
{
|
||||
int inOffset = 0;
|
||||
int[] pixel = new int[numBands];
|
||||
for (int yy=y; yy<(y+h); yy++)
|
||||
{
|
||||
int offset = scanlineStride*yy + x;
|
||||
|
|
64
libjava/classpath/java/awt/peer/DesktopPeer.java
Normal file
64
libjava/classpath/java/awt/peer/DesktopPeer.java
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* DesktopPeer.java -- Interface to enable access to common applications
|
||||
Copyright (C) 2006, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.Desktop.Action;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* @author Mario Torre <neugens@limasoftware.net>
|
||||
*
|
||||
*/
|
||||
public interface DesktopPeer
|
||||
{
|
||||
public void browse(URI url) throws IOException;
|
||||
|
||||
public void edit(File file) throws IOException;
|
||||
|
||||
public boolean isSupported(Action action);
|
||||
|
||||
public void mail(URI mailtoURL) throws IOException;
|
||||
|
||||
public void mail() throws IOException;
|
||||
|
||||
public void open(File file) throws IOException;
|
||||
|
||||
public void print(File file) throws IOException;
|
||||
}
|
|
@ -264,15 +264,12 @@ public abstract class PrinterJob
|
|||
* @return Array of stream print services, could be empty.
|
||||
* @since 1.4
|
||||
*/
|
||||
// FIXME:
|
||||
// Enable when StreamPrintServiceFactory has lookupStreamServiceFactories
|
||||
// public static StreamPrintServiceFactory[] lookupStreamPrintServices(String mimeType)
|
||||
// {
|
||||
// return StreamPrintServiceFactory.lookupStreamServiceFactories(
|
||||
// new DocFlavor("application/x-java-jvm-local-objectref",
|
||||
// "java.awt.print.Pageable"),
|
||||
// mimeType);
|
||||
// }
|
||||
public static StreamPrintServiceFactory[]
|
||||
lookupStreamPrintServices(String mimeType)
|
||||
{
|
||||
return StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
|
||||
DocFlavor.SERVICE_FORMATTED.PAGEABLE, mimeType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the printer for this job. If print services aren't supported by
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue