Commit 6a716777 by Michael Koch Committed by Michael Koch

MemoryImageSource.java, [...]: New versions from classpath.

2003-07-14  Michael Koch  <konqueror@gmx.de>

	* java/awt/image/MemoryImageSource.java,
	java/beans/PropertyEditorManager.java,
	javax/naming/CompoundName.java,
	javax/naming/spi/NamingManager.java,
	javax/swing/AbstractButton.java,
	javax/swing/ButtonModel.java,
	javax/swing/SwingUtilities.java,
	javax/swing/UIManager.java,
	javax/swing/colorchooser/DefaultColorSelectionModel.java,
	javax/swing/event/AncestorEvent.java,
	javax/swing/event/InternalFrameEvent.java,
	java/util/zip/ZipFile.java:
	New versions from classpath.

From-SVN: r69321
parent 6e985040
2003-07-14 Michael Koch <konqueror@gmx.de>
* java/awt/image/MemoryImageSource.java,
java/beans/PropertyEditorManager.java,
javax/naming/CompoundName.java,
javax/naming/spi/NamingManager.java,
javax/swing/AbstractButton.java,
javax/swing/ButtonModel.java,
javax/swing/SwingUtilities.java,
javax/swing/UIManager.java,
javax/swing/colorchooser/DefaultColorSelectionModel.java,
javax/swing/event/AncestorEvent.java,
javax/swing/event/InternalFrameEvent.java,
java/util/zip/ZipFile.java:
New versions from classpath.
2003-07-13 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/FileChannelImpl.java,
......
......@@ -74,7 +74,7 @@ public class MemoryImageSource implements ImageProducer
this.props = props;
int max = (( scansize > width ) ? scansize : width );
pixelb = new byte[ max * height ];
System.arraycopy( pix, 0, pixelb, 0, max );
System.arraycopy( pix, 0, pixelb, 0, max * height );
}
/**
Constructs an ImageProducer from memory
......@@ -100,7 +100,7 @@ public class MemoryImageSource implements ImageProducer
this.props = props;
int max = (( scansize > width ) ? scansize : width );
pixeli = new int[ max * height ];
System.arraycopy( pix, 0, pixeli, 0, max );
System.arraycopy( pix, 0, pixeli, 0, max * height );
}
/**
Constructs an ImageProducer from memory using the default RGB ColorModel
......@@ -226,6 +226,7 @@ public class MemoryImageSource implements ImageProducer
if( props != null ) {
ic.setProperties( props );
}
ic.setDimensions(width, height);
if( pixeli != null ) {
ic.setPixels( 0, 0, width, height, cm, pixeli, offset, scansize );
} else {
......
......@@ -140,9 +140,13 @@ public class PropertyEditorManager
return (PropertyEditor)found.newInstance();
}
ClassLoader contextClassLoader
= Thread.currentThread().getContextClassLoader();
try
{
found = Class.forName(editedClass.getName()+"Editor");
found = Class.forName(editedClass.getName()+"Editor", true,
contextClassLoader);
registerEditor(editedClass,found);
return (PropertyEditor)found.newInstance();
}
......@@ -150,14 +154,18 @@ public class PropertyEditorManager
{
}
String appendName = "." + ClassHelper.getTruncatedClassName(editedClass) + "Editor";
String appendName
= "."
+ ClassHelper.getTruncatedClassName(editedClass)
+ "Editor";
synchronized(editorSearchPath)
{
for(int i=0;i<editorSearchPath.length;i++)
{
try
{
found = Class.forName(editorSearchPath[i] + appendName);
found = Class.forName(editorSearchPath[i] + appendName,
true, contextClassLoader);
registerEditor(editedClass,found);
return (PropertyEditor)found.newInstance();
}
......
......@@ -308,7 +308,7 @@ public class ZipFile implements ZipConstants
*/
protected void finalize() throws IOException
{
if (!closed) close();
if (!closed && raf != null) close();
}
/**
......
......@@ -142,13 +142,17 @@ public class CompoundName implements Name, Cloneable, Serializable
// Otherwise, fall through.
}
// Quotes are only special at the start of a component.
else if (new_element.length () == 0 && special == beginQuote)
else if (new_element.length () == 0
&& special == beginQuote
&& beginQuote != null)
{
quote = endQuote;
i += special.length ();
continue;
}
else if (new_element.length () == 0 && special == beginQuote2)
else if (new_element.length () == 0
&& special == beginQuote2
&& beginQuote2 != null)
{
quote = endQuote2;
i += special.length ();
......
......@@ -83,12 +83,16 @@ public class NamingManager
try
{
icf = (InitialContextFactory) Class.forName (java_naming_factory_initial).newInstance ();
icf = (InitialContextFactory)Class.forName
(java_naming_factory_initial, true,
Thread.currentThread().getContextClassLoader())
.newInstance ();
}
catch (Exception exception)
{
NoInitialContextException e
= new NoInitialContextException ("Can't load InitialContextFactory class: "
= new NoInitialContextException
("Can't load InitialContextFactory class: "
+ java_naming_factory_initial);
e.setRootCause(exception);
throw e;
......
......@@ -85,7 +85,6 @@ public abstract class AbstractButton extends JComponent
ButtonModel model;
Insets margin;
public static final String FOCUS_PAINTED_CHANGED_PROPERTY = "focusPainted";
/**
......@@ -95,10 +94,6 @@ public abstract class AbstractButton extends JComponent
extends AccessibleJComponent
implements AccessibleAction, AccessibleValue, AccessibleText {
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor AccessibleAbstractButton
* @param component TODO
......@@ -108,11 +103,6 @@ public abstract class AbstractButton extends JComponent
// TODO
} // AccessibleAbstractButton()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* getAccessibleStateSet
* @returns AccessibleStateSet
......@@ -362,15 +352,6 @@ public abstract class AbstractButton extends JComponent
}
}
/**********************************************
*
*
* Constructors
*
*
****************/
AbstractButton()
{
this("",null);
......@@ -392,81 +373,90 @@ public abstract class AbstractButton extends JComponent
updateUI(); // get a proper ui
}
/**********************************************
*
*
* Actions etc
*
*
****************/
public ButtonModel getModel()
{ return model; }
public void setModel(ButtonModel newModel)
{ model = newModel; }
public String getActionCommand()
{ return getModel().getActionCommand(); }
public void setActionCommand(String aCommand)
{ getModel().setActionCommand(aCommand); }
public void addActionListener(ActionListener l)
{ getModel().addActionListener(l); }
public void removeActionListener(ActionListener l)
{ getModel().removeActionListener(l); }
public void addChangeListener(ChangeListener l)
{ getModel().addChangeListener(l); }
public void removeChangeListener(ChangeListener l)
{ getModel().removeChangeListener(l); }
public void addItemListener(ItemListener l)
{ getModel().addItemListener(l); }
public void removeItemListener(ItemListener l)
{ getModel().removeItemListener(l); }
public int getHorizontalAlignment()
{ return hori_align; }
public int getHorizontalTextPosition()
{ return hori_text_pos; }
public int getVerticalAlignment()
{ return vert_align; }
public int getVerticalTextPosition()
{ return vert_text_pos; }
protected void fireItemStateChanged(ItemEvent event)
{ getModel().fireItemStateChanged(event); }
{
}
protected void fireStateChanged(ChangeEvent event)
{ getModel().fireStateChanged(event); }
{
}
protected void fireActionPerformed(ActionEvent event)
{ getModel().fireActionPerformed(event); }
{
}
public void setVerticalAlignment(int alignment)
{ vert_align = alignment; }
public void setHorizontalAlignment(int alignment)
{ hori_align = alignment; }
public void setVerticalTextPosition(int textPosition)
{ vert_text_pos = textPosition; }
public void setHorizontalTextPosition(int textPosition)
{ hori_text_pos = textPosition; }
public int getMnemonic()
{ return getModel().getMnemonic(); }
public void setMnemonic(char mne)
{ getModel().setMnemonic(mne); }
public void setMnemonic(int mne)
{ getModel().setMnemonic(mne); }
public void setRolloverEnabled(boolean b)
{ getModel().setRollover(b); }
public boolean isRolloverEnabled()
{ return getModel().isRollover(); }
public boolean isBorderPainted()
{ return paint_border; }
public void setBorderPainted(boolean b)
{
if (b != paint_border)
......@@ -479,6 +469,7 @@ public abstract class AbstractButton extends JComponent
public Action getAction()
{ return action_taken; }
public void setAction(Action a)
{
action_taken = a;
......@@ -488,12 +479,13 @@ public abstract class AbstractButton extends JComponent
public void setSelected(boolean b)
{ getModel().setSelected(b); }
public boolean isSelected()
{ return getModel().isSelected(); }
public Icon getIcon()
{ return default_icon; }
public void setIcon(Icon defaultIcon)
{
if (default_icon == defaultIcon)
......@@ -503,7 +495,7 @@ public abstract class AbstractButton extends JComponent
if (default_icon != null)
{
// XXX FIXME - icons do not know their parent
// default_icon.setParent(this);
// default_icon.setParent(this);
}
revalidate();
repaint();
......@@ -511,10 +503,13 @@ public abstract class AbstractButton extends JComponent
public String getText()
{ return text; }
public void setLabel(String label)
{ setText(label); }
public String getLabel()
{ return getText(); }
public void setText(String text)
{
this.text = text;
......@@ -522,9 +517,9 @@ public abstract class AbstractButton extends JComponent
repaint();
}
public Insets getMargin()
{ return margin; }
public void setMargin(Insets m)
{
margin = m;
......@@ -541,6 +536,7 @@ public abstract class AbstractButton extends JComponent
public Icon getPressedIcon()
{ return pressed_button; }
public void setPressedIcon(Icon pressedIcon)
{
pressed_button = pressedIcon;
......@@ -548,9 +544,9 @@ public abstract class AbstractButton extends JComponent
repaint();
}
public Icon getDisabledIcon()
{ return disabled_button; }
public void setDisabledIcon(Icon disabledIcon)
{
disabled_button = disabledIcon;
......@@ -560,6 +556,7 @@ public abstract class AbstractButton extends JComponent
public boolean isFocusPainted()
{ return paint_focus; }
public void setFocusPainted(boolean b)
{
boolean old = paint_focus;
......@@ -587,11 +584,13 @@ public abstract class AbstractButton extends JComponent
// Verify that key is a legal value for the horizontalAlignment properties.
return 0;
}
protected int checkVerticalKey(int key, String exception)
{
// Ensures that the key is a valid.
return 0;
}
protected void configurePropertiesFromAction(Action a)
{
//Factory method which sets the ActionEvent source's properties according to values from the Action instance.
......@@ -610,6 +609,7 @@ public abstract class AbstractButton extends JComponent
//Factory method which creates the PropertyChangeListener used to update the ActionEvent source as properties change on its Action instance.
return null;
}
protected ChangeListener createChangeListener()
{
// Subclasses that want to handle ChangeEvents differently can override this to return another ChangeListener implementation.
......@@ -627,25 +627,23 @@ public abstract class AbstractButton extends JComponent
};
}
public void doClick()
{
doClick(100);
}
public void doClick(int pressTime)
{
//Toolkit.tlkBeep ();
//Programmatically perform a "click".
}
public Icon getDisabledSelectedIcon()
{
//Returns the icon used by the button when it's disabled and selected.
return disabled_selected_button;
}
public Icon getRolloverIcon()
{
// Returns the rollover icon for the button.
......@@ -657,20 +655,19 @@ public abstract class AbstractButton extends JComponent
// Returns the rollover selection icon for the button.
return null;
}
Icon getSelectedIcon()
{
// Returns the selected icon for the button.
return selected_button;
}
public Object[] getSelectedObjects()
{
//Returns an array (length 1) containing the label or null if the button is not selected.
return null;
}
public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h)
{
//This is overridden to return false if the current Icon's Image is not equal to the passed in Image img.
......@@ -683,27 +680,24 @@ public abstract class AbstractButton extends JComponent
return false;
}
protected void paintBorder(Graphics g)
{
// Paint the button's border if BorderPainted property is true.
if (isBorderPainted())
super.paintBorder(g);
}
protected String paramString()
{
// Returns a string representation of this AbstractButton.
return "AbstractButton";
}
public void setContentAreaFilled(boolean b)
{
//Sets whether the button should paint the content area or leave it transparent.
}
public void setDisabledSelectedIcon(Icon disabledSelectedIcon)
{
// Sets the disabled selection icon for the button.
......@@ -718,13 +712,11 @@ public abstract class AbstractButton extends JComponent
// Sets the rollover selected icon for the button.
}
public void setSelectedIcon(Icon selectedIcon)
{
// Sets the selected icon for the button.
}
public void setUI(ButtonUI ui)
{ // Sets the L&F object that renders this component.
super.setUI(ui);
......@@ -752,7 +744,6 @@ public abstract class AbstractButton extends JComponent
System.out.println("PROCESS-ACTION-EVENT: " + e);
}
protected void processMouseEvent(MouseEvent e)
{
// System.out.println("PROCESS-MOUSE-EVENT: " + e + ", PRESSED-IN-MODEL="+getModel().isPressed());
......
......@@ -76,12 +76,4 @@ public interface ButtonModel extends ItemSelectable
void setSelected(boolean b);
boolean isSelected();
// there are not in the spec !!
void fireItemStateChanged(ItemEvent event);
void fireStateChanged(ChangeEvent event);
void fireActionPerformed(ActionEvent event);
}
......@@ -58,8 +58,8 @@ import javax.accessibility.AccessibleStateSet;
public class SwingUtilities implements SwingConstants
{
public static FontMetrics getFontMetrics (Font font)
{
return Toolkit.getDefaultToolkit().getFontMetrics(font);
{
return Toolkit.getDefaultToolkit ().getFontMetrics (font);
}
public static JRootPane getRootPane (Component a)
......@@ -122,6 +122,7 @@ public class SwingUtilities implements SwingConstants
return text;
}
}
......
......@@ -50,9 +50,7 @@ import javax.swing.plaf.metal.MetalLookAndFeel;
public class UIManager implements Serializable
{
static final long serialVersionUID = -5547433830339189365L;
static class LookAndFeelInfo
public static class LookAndFeelInfo
{
String name, clazz;
......@@ -62,32 +60,47 @@ public class UIManager implements Serializable
this.name = name;
this.clazz = clazz;
}
String getName() { return name; }
String getClassName() { return clazz; }
}
private static final long serialVersionUID = -5547433830339189365L;
static LookAndFeelInfo [] installed = {
new LookAndFeelInfo("Metal",
"javax.swing.plaf.metal.MetalLookAndFeel")
new LookAndFeelInfo ("Metal", "javax.swing.plaf.metal.MetalLookAndFeel")
};
static LookAndFeel[] aux_installed;
static LookAndFeel look_and_feel = new MetalLookAndFeel();
public UIManager()
{
// Do nothing here.
}
UIManager()
public static void addPropertyChangeListener (PropertyChangeListener listener)
{
// FIXME
}
public static void addPropertyChangeListener(PropertyChangeListener listener)
public static void removePropertyChangeListener (PropertyChangeListener listener)
// Remove a PropertyChangeListener from the listener list.
{
// Add a PropertyChangeListener to the listener list.
// FIXME
}
public static void addAuxiliaryLookAndFeel(LookAndFeel l)
/**
* @since 1.4
*/
public static PropertyChangeListener[] getPropertyChangeListeners ()
{
// FIXME
throw new Error ("Not implemented");
}
public static void addAuxiliaryLookAndFeel (LookAndFeel l)
{
// Add a LookAndFeel to the list of auxiliary look and feels.
if (aux_installed == null)
......@@ -98,9 +111,7 @@ public class UIManager implements Serializable
}
LookAndFeel[] T = new LookAndFeel[ aux_installed.length+1 ];
System.arraycopy(aux_installed, 0,
T, 0,
aux_installed.length);
System.arraycopy(aux_installed, 0, T, 0, aux_installed.length);
aux_installed = T;
aux_installed[aux_installed.length-1] = l;
}
......@@ -115,11 +126,8 @@ public class UIManager implements Serializable
if (aux_installed[i] == laf)
{
aux_installed[ i ] = aux_installed[aux_installed.length-1];
LookAndFeel[] T = new LookAndFeel[ aux_installed.length-1 ];
System.arraycopy(aux_installed, 0,
T, 0,
aux_installed.length-1);
System.arraycopy (aux_installed, 0, T, 0, aux_installed.length-1);
aux_installed = T;
return true;
}
......@@ -130,7 +138,6 @@ public class UIManager implements Serializable
public static LookAndFeel[] getAuxiliaryLookAndFeels()
{ return aux_installed; }
public static Object get(Object key)
{ return getLookAndFeel().getDefaults().get(key); }
......@@ -175,7 +182,6 @@ public class UIManager implements Serializable
return new Dimension(200,100);
}
/**
* Retrieves a font from the defaults table of the current
* LookAndFeel.
......@@ -194,6 +200,7 @@ public class UIManager implements Serializable
{
return (Icon) getLookAndFeel().getDefaults().get(key);
}
static Insets getInsets(Object key)
// Returns an Insets object from the defaults table.
{
......@@ -212,12 +219,12 @@ public class UIManager implements Serializable
return 0;
return x.intValue();
}
static LookAndFeel getLookAndFeel()
{
return look_and_feel;
}
/**
* Returns the <code>UIDefaults</code> table of the currently active
* look and feel.
......@@ -227,19 +234,18 @@ public class UIManager implements Serializable
return getLookAndFeel().getDefaults();
}
static String getString(Object key)
// Returns a string from the defaults table.
{
return (String) getLookAndFeel().getDefaults().get(key);
}
static String getSystemLookAndFeelClassName()
// Returns the name of the LookAndFeel class that implements the native systems look and feel if there is one, otherwise the name of the default cross platform LookAndFeel class.
{
return getCrossPlatformLookAndFeelClassName();
}
public static ComponentUI getUI(JComponent target)
// Returns the L&F object that renders the target component.
{
......@@ -248,28 +254,27 @@ public class UIManager implements Serializable
return ui;
}
public static void installLookAndFeel(String name, String className)
// Creates a new look and feel and adds it to the current array.
{
}
public static void installLookAndFeel(LookAndFeelInfo info)
// Adds the specified look and feel to the current array and then calls setInstalledLookAndFeels(javax.swing.UIManager.LookAndFeelInfo[]).
{
}
public static Object put(Object key, Object value)
// Stores an object in the defaults table.
{
return getLookAndFeel().getDefaults().put(key,value);
}
public static void removePropertyChangeListener(PropertyChangeListener listener)
// Remove a PropertyChangeListener from the listener list.
{
}
public static void setInstalledLookAndFeels(UIManager.LookAndFeelInfo[] infos)
// Replaces the current array of installed LookAndFeelInfos.
{
}
public static void setLookAndFeel(LookAndFeel newLookAndFeel)
{
if (look_and_feel != null)
......@@ -279,14 +284,12 @@ public class UIManager implements Serializable
look_and_feel = newLookAndFeel;
look_and_feel.initialize();
// revalidate();
// repaint();
//revalidate();
//repaint();
}
public static void setLookAndFeel(String className)
throws ClassNotFoundException,
InstantiationException,
IllegalAccessException,
public static void setLookAndFeel (String className)
throws ClassNotFoundException, InstantiationException, IllegalAccessException,
UnsupportedLookAndFeelException
{
// Set the current default look and feel using a class name.
......@@ -294,6 +297,4 @@ public class UIManager implements Serializable
LookAndFeel a = (LookAndFeel) c.newInstance(); // throws class-cast-exception
setLookAndFeel(a);
}
}
......@@ -52,90 +52,90 @@ import javax.swing.event.EventListenerList;
public class DefaultColorSelectionModel
implements ColorSelectionModel, Serializable
{
static final long serialVersionUID = 580150227676302096L;
private static final long serialVersionUID = -8117143602864778804L;
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
private Color selectedColor;
/**
* changeEvent
*/
protected transient ChangeEvent changeEvent;
protected transient ChangeEvent changeEvent = new ChangeEvent (this);
protected EventListenerList listenerList = new EventListenerList ();
/**
* listenerList
* Creates a new color selection model.
*/
protected EventListenerList listenerList;
public DefaultColorSelectionModel()
{
this (Color.white);
}
/**
* selectedColor
* Creates a new color selection model with a given selected color.
*
* @param color The selected color.
*/
private Color selectedColor;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
public DefaultColorSelectionModel (Color color)
{
super();
this.selectedColor = color;
}
/**
* Constructor DefaultColorSelectionModel
* Returns the selected color.
*
* @return The selected color.
*/
public DefaultColorSelectionModel() {
// TODO
} // DefaultColorSelectionModel()
public Color getSelectedColor()
{
return selectedColor;
}
/**
* Constructor DefaultColorSelectionModel
* @param color TODO
* @param color The color to set.
*/
public DefaultColorSelectionModel(Color color) {
// TODO
} // DefaultColorSelectionModel()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* getSelectedColor
* @returns Color
*/
public Color getSelectedColor() {
return null; // TODO
} // getSelectedColor()
public void setSelectedColor (Color color)
{
this.selectedColor = color;
}
/**
* setSelectedColor
* @param color TODO
* Adds a listener to this model.
*
* @param listener The listener to add.
*/
public void setSelectedColor(Color color) {
// TODO
} // setSelectedColor()
public void addChangeListener (ChangeListener listener)
{
listenerList.add (ChangeListener.class, listener);
}
/**
* addChangeListener
* @param listener TODO
* Removes a listener from this model.
*
* @param listener The listener to remove.
*/
public void addChangeListener(ChangeListener listener) {
// TODO
} // addChangeListener()
public void removeChangeListener (ChangeListener listener)
{
listenerList.remove (ChangeListener.class, listener);
}
/**
* removeChangeListener
* @param listener TODO
* Returns all currently added <code>ChangeListener</code> objects.
*
* @return Array of <code>ChangeListener</code> objects.
*/
public void removeChangeListener(ChangeListener listener) {
// TODO
} // removeChangeListener()
public ChangeListener[] getChangeListeners()
{
return (ChangeListener[]) listenerList.getListeners (ChangeListener.class);
}
/**
* fireStateChanged
* Calls all the <code>stateChanged()</code> method of all added
* <code>ChangeListener</code> objects with <code>changeEvent</code>
* as argument.
*/
protected void fireStateChanged() {
// TODO
} // fireStateChanged()
} // DefaultColorSelectionModel
protected void fireStateChanged()
{
ChangeListener[] listeners = getChangeListeners();
for (int i = 0; i < listeners.length; i++)
listeners [i].stateChanged (changeEvent);
}
}
......@@ -50,9 +50,9 @@ public class AncestorEvent extends AWTEvent
{
private static final long serialVersionUID = -8079801679695605002L;
public static final int ANCESTOR_ADDED = 0;
public static final int ANCESTOR_MOVED = 1;
public static final int ANCESTOR_ADDED = 1;
public static final int ANCESTOR_REMOVED = 2;
public static final int ANCESTOR_MOVED = 3;
private JComponent sourceComponent;
private Container ancestor;
......
......@@ -81,7 +81,7 @@ public class InternalFrameEvent extends AWTEvent
/**
* Internal frame iconified event
*/
public static final int INTERNAL_FRAME_ICONIFIED = 2552;
public static final int INTERNAL_FRAME_ICONIFIED = 25552;
/**
* Internal frame last event
......@@ -91,7 +91,7 @@ public class InternalFrameEvent extends AWTEvent
/**
* Internal frame opened event
*/
public static final int INTERNAL_FRAME_OPENED = 25550;
public static final int INTERNAL_FRAME_OPENED = 25549;
/**
* Creates a <code>JInternalFrameEvent</code> object.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment