Using inheritance and class indicator

Hi
I need help doing the following :
I have a table with 2 types of data. I want to map it to 2 subclasses of the same superclass using the class indicator on an existing column.
The problem is that i want to map all rows with value = 1 to 1 subclass and the rest of the rows (value != 1) to the second subclass.
Can this be done ?
Thanks
Inbal

Inbal,
You will need to create a static method that takes a DatabaseRow and returns a Class, then specify this method using the api InheritancePolicy.setClassExtractionMethodName(String). In this method you will need to get the class indicator field from the databaseRow and return the Class that you want. You can also specify the class extraction method through the Mapping Workbench.
Karen

Similar Messages

  • When to use inheritance and when not to?

    I've just been trying find out when to use inheritance and when not to use inheritance? I know that inheritance gives advantages such as code reuse and maintainability. But when are their times not to use inheritance that may effect the design of a project?
    Also when should one consider aggregation over inheritance(is-a relationship)?
    thanks,
    plandis

    Hi
    Answering this question usually requires a few books, so, I'm sorry, it's not really as simple as choosing between using a screwdriver vs. a hammer.
    But, very short, inheritance should ideally only be used when there exist a strict 'is-a' relationship. However, sometimes it may be clever to inherit when you have a 'is-almost-a' relationship... And sometimes this is a stupid move. This depends on the context/circumstances.
    Aggregation is normally considered a 'has-a' relationship, thereby differing clearly from inheritance. The old 'car' model says "a car is-a vehicle and has-some (at least) wheels."
    The wheels are aggregated to the car class, that itself is inherited from vehicle.
    However, this is just a good rule-of-thumb and there may be circumstantial reasons for not following these guidelines.

  • When to use inheritance and When to use Composition

    java support both inheratiance and composition .I also know "is a" and
    "has a realitionship" but there is always a problem with me to understanding whethere i have to use extends or having a object of a class has a member of othere class.
    and also "A pure OOP must support polimorphisim,inheretiance,encapluction,Abstraction and Composition" correct me if i am wrong
    thank you and have a nice day.

    Bruce Eckel, author of Thinking In Java, has this to say about composition vs. inheritance:
    When deciding between inheritance and composition, ask if you need to upcast to the base type. If not, prefer composition (member objects) to inheritance. This can eliminate the perceived need for multiple base types. If you inherit, users will think they are supposed to upcast.
    Choose composition first when creating new classes from existing classes. You should only used inheritance if it is required by your design. If you use inheritance where composition will work, your designs will become needlessly complicated.
    Bill Venners: Composition versus Inheritance
    Use inheritance (of implementation) only when the class satisfies the following criteria:
    1) "Is a special kind of," not "is a role played by a";
    2) Never needs to transmute to be an object in some other class;
    3) Extends rather than overrides or nullifies superclass;
    4) Does not subclass what is merely a utility class (useful functionality you'd like to reuse); and
    5) Within PD: expresses special kinds of roles, transactions, or things.
    -- from Java Design: Building Better Apps and Applets (2nd Edition), by Peter Coad and Mark Mayfield

  • Difference between using FM and class in alv

    does anyone know what's the main difference between using FM to create alv  and using class to create alv?
    in what condition we usually use FM or class?

    using FM  we can create Classical and Interactive ALV Reports.
    The classes are used to create the ALV Reports with OOPS concept.
    Check this for basic concepts of OOPS
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b6cae890-0201-0010-ef8b-f970a9c41d47
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1591ec90-0201-0010-3ba8-cdcd500b17cf
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20code%20samples/alv%20grid/abap%20code%20sample%20to%20display%20data%20in%20alv%20grid%20using%20object%20oriented%20programming.doc
    Tabstrip
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/022ba607-0301-0010-e382-fdedca553f5f
    Editable ALV
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/ec31e990-0201-0010-f4b6-c02d876ce033
    Tree
    http://www.sapdevelopment.co.uk/reporting/alv/alvtree/alvtree_usrint.htm
    General Tutorial for OOPS
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
    Reward Points if useful

  • How to make a field manadatory within ALV Grid using methods and classes

    Hi,
    I am using ALV Grid using set_table_for_first_display
    inside my dialog programming. I have a field called project number inside my grid which has to be made as mandatory field.
    I have defined a method called catch_data_changed inside my class lcl_event_receiver. This method captures the changes made to one of the fields inside my ALV grid and displays all the default values of the other fields from the grid.
    Now, i have to make project number which is one of my fields inside my ALV grid as mandatory. At the field catalog level i did not find any such option for making a field as required field.
    Is there any other way, i can accomplish this within the ALV grid?

    from my understanding from ur question, i understood that u want the editable field inside alvgrid to be mandatory.
    i dont know anthing in fieldcat, but u can try the following logic.
    FORM DATA_CHANGED  USING P_ER_DATA_CHANGED TYPE REF TO
    CL_ALV_CHANGED_DATA_PROTOCOL .
      DATA: L_VALUE TYPE LVC_VALUE,
        ls_mod_cell type lvc_s_modi.
      READ TABLE P_ER_DATA_CHANGED->MT_MOD_CELLS INTO LS_MOD_CELL.
    if sy-subrc = 0.
        CALL METHOD P_ER_DATA_CHANGED->GET_CELL_VALUE
          EXPORTING
            I_ROW_ID    = LS_MOD_CELL-row_id
            I_FIELDNAME = LS_MOD_CELL-fieldname
          IMPORTING
            E_VALUE     = L_VALUE.
    IF LS_MOD_CELL-FIELDNAME <> 'fieldname what u want'
    MESSAGE 'ENTER VALUE INTO (fieldname u want) ' TYPE 'I'.
    ENDIF.
    ELSE.
    MESSAGE 'ENTER VALUE INTO (fieldname u want) ' TYPE 'I'.
    ENDIF.

  • Using mouselistener and class extending jbutton

    Hello,
    I wondered if anyone could advice, I am trying wrote a class which lowers the border of a jbutton when the button is clicked, and stays lowered until clicked again. In the sameway as bold does in ms word.
    I understand I can use setBorder(raised) or setBorder(lowered).
    But I was unsure which method here to place this code.
    Thank you
    public class AddButton extends JButton implements MouseListener{
    protected Border raised = new SoftBevelBorder(BevelBorder.RAISED);
         protected Border lowered = new SoftBevelBorder(BevelBorder.LOWERED);
    public void mouseClicked(MouseEvent e) { }
    public void mouseMoved(MouseEvent e) { }
    public void mouseExited(MouseEvent e) { }
    public void mouseReleased(MouseEvent e) { }
    public void mouseEntered(MouseEvent e) { }
    public void mousePressed(MouseEvent e) { }
    public void mouseDragged(MouseEvent e) { }
    }

    import java.awt.*;
    import javax.swing.border.Border;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test3 extends JFrame {
      Border rb = BorderFactory.createRaisedBevelBorder(),
             lb = BorderFactory.createLoweredBevelBorder();
      JButton jb1 = new JButton("I am Button"), jb2 = new JButton("Hear me roar");
      public Test3() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        content.setLayout(new FlowLayout());
        jb1.setBorder(rb);
        content.add(jb1);
        jb1.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            jb1.setBorder(jb1.getBorder()==rb?lb:rb);
        jb2.setBorder(rb);
        content.add(jb2);
        jb2.addMouseListener(new MouseAdapter() {
          public void mouseReleased(MouseEvent me) {
            jb2.setBorder(jb2.getBorder()==rb?lb:rb);
        JToggleButton jtb = new JToggleButton("Toggley Button");
        content.add(jtb);
        setSize(300,300);
        setVisible(true);
      public static void main(String[] arghs) { new Test3(); }
    }

  • Is it advisable to use inheritance when reusing dialogs/frames?

    Hi!
    While working on a project, I've noticed that there are instances when I could reuse code by creating general forms (as dialogs or windows) and subclassing them. For example, I have this set of dialogs which have a similar function: each dialog has a table (or list) of objects and functions for adding, deleting and editing objects in this table. Do you think that it's good to use inheritance in this case? That is, I create a general AddEditDeleteDialog from which to subclass particular dialogs, AddEditDeleteObject1Dialog, AddEditDeleteObject2Dialog, ...
    Thanks!

    Yes, of course. But to what extent? Should I include
    layouting code, component initialization, event
    handling, etc in the superclass (AddEditDeleteDialog),
    or should I let the subclasses (AddEditDeleteObject1Dialog)
    handle that?Basically, whatever is the same in all the subclasses can be placed in the superclass. If there are differences, then you should place it in the subclasses.
    Things like event handling can be placed in the superclass, where each method in the event listener fires an abstract method in the superclass, which each of your subclasses implement to provide custom event handling.
    Component initialization can also be used in the superclass for whatever components are used in all of the subclasses. Subclasses can then add any components which are unique to them.
    You should also be aware that the purpose of inheritance is to add to the functionality of a class. If your subclass provides no extra abstract functionality then you should just use one class, and change some settings each time you need to use it for a different purpose. E.g. If your dialogs contain the same components, same actions etc but different text, then use just one class, and for each dialog, set the text for each of the components accordingly.
    There is no hard/fast rule for using inheritance and how to design an object hierarchy, and as my first programming teacher used to say "every programming problem can usually be solved in loads of different ways."

  • Who uses inheritance?

    I had a conversation with Tom Kyte on PL/SQL and OO (see thread http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:63942113457534#642059000346437745 ).
    When I program in C#, I use a lot of inheritance and polymorphism, why not in PL/SQL?
    Do you readers have good examples that show how you can use inheritance and polymorphism?
    I hope that there will come support for encapsulation in Oracle Objects.

    I like both, I like PL/SQL and I like C# (very OO).Like you, I like PL/SQL and I like OOPL's.
    I don't know C# - I know C++, Java and Eiffel, but I'm not an expert.
    In my opinion, Eiffel is the best OOPL (Eiffel was designed in 1985, commercialy released in 1986, ISO-standardized in 2006).
    But mostly I like relational databases (relational DBMS's).
    My motto is: “Thou shall not do in the Middle Tier, what thou could have done in the Data Tier”
    (Toon Koppelaars in "A first JDeveloper project: Choices made, lessons learned", Oracle World 2002).
    I think that the current object types in Oracle aren't practical for transient objects in PL/SQL,
    first because a "true" OOPL must have references between transient objects (and then, perhaps, even a garbage collector).
    Between the way, I sent my PL/SQL "wish list" to Steven Feuerstein’s site "21st Century PL/SQL"
    (Add advanced O-O features like those found in Eiffel)
    http://www.oracleplsqlprogramming.com/IC/ideas/data_structures_and_datatypes/object_types/index.php
    Here are my attempts to use PL/SQL as OOPL ( PL/SQL++ :) :
    Dynamic Method Dispatch and Method Overloading in a Subtype (May 2003)
    http://www.quest-pipelines.com/newsletter-v4/0503_C.htm
    Calling the Parent Object's Version of an Overridden Method
    http://www.quest-pipelines.com/pipelines/plsql/tips03.htm#JUNE
    (note: Oracle 11g has Generalized Invocation)
    How to Get the Text Name of an Object's Type
    http://www.quest-pipelines.com/pipelines/plsql/tips06.htm#JULY
    The Template Design Pattern in PL/SQL
    http://www.quest-pipelines.com/pipelines/plsql/tips06.htm#OCTOBER
    Design by Contract (DBC) and PL/SQL
    http://www.quest-pipelines.com/pipelines/plsql/tips.htm#JUNE
    But, I think that Oracle object types are OK for persistent objects (for “column objects”, not for “row objects”).
    C.J.Date in An introduction to Database Systems (2004, page 885) says:
    "... object/relational systems ... are, or should be, basically just relational systems that support the relational domain concept (i.e., types) properly
    - in other words, true relational systems, meaning in particular systems that allow users to define their own types".
    Here is an attempt to use Oracle "object-relational" features "in the proper way" (in Date's sense) - to use object type as domain:
    “OR(DBMS) or R(DBMS), That is the Question”
    http://www.quest-pipelines.com/pipelines/plsql/tips.htm#OCTOBER
    Regards,
    Zlatko

  • Inheritance, class indicator field and subclasses

    Hi
    Ok, I have an inheritance model with a base class (let's call it BaseClass), which is abstract. Every subclasse of BaseClass have a different implementation, but no additional attribute. I don't want to map all subclasses in Mapping Workbench, so I mapped BaseClass and configured inheritance to use a field as a class indicator (using the java class name).
    Now, to read all subclasses in one single query, I do this:
    Collection result = session.readAllObjects(BaseClass.class);
    Now the problem is that TopLink generates the following SQL:
    SELECT JAVA_CLASS_NAME, [...] FROM BASE_CLASS_TABLE WHERE JAVA_CLASS_NAME = 'com.[...].BaseClass'
    Well, obviously this is not what I expected, since this will not return anything! I tried to use the "Read Subclasses on Query' option, to no avail. Am I missing something here? I thought this would pretty staight forward... :-(
    TIA
    Regards
    Eric Morin

    You must always map all subclasses that you wish to persist/read. If TopLink does not have a descriptor for a class it will persist/instantiate it as its superclass descriptor class.
    If you explictly configured your descriptor to read subclasses on queries in code (descriptor.getInheritancePolicy().readSubclassesOnQueries()) it would generate the correct SQL that you want, however it would return you all instances of the root class, not the subclasses. The only way to read subclasses is to map them.
    If you don't want to have to map all of the classes in the Mapping Workbench, you could just add the descriptor's for the subclasses in code.
    i.e.
    List allSublcasses = getAllMySubclasses();
    for (Iterator iterator = allSublcasses.iterator(); iterator.hasNext(); ) {
    Descriptor descriptor = new Descriptor();
    Class subclass = (Class) iterator.next();
    descriptor.setJavaClass(subclass);
    descriptor.getInheritancePolicy().setParentClass(subclass.getSuperClass());

  • XML mapping inheritance problem; missing class indicator field

    Hi!
    I am currently working on a project which involves mapping a large domain model on a XSD schema. For this we use Toplink 10.1.3.1 which is mostly great. But now I have a problem while wanting to use class inheritance.
    In my XSD I have the following defined
    <xs:complexType name="Traject">
         <xs:sequence>
              <xs:element name="SoortTraject" type="SoortTraject"/>
         </xs:sequence>
    </xs:complexType>
    <xs:complexType name="SpecialTraject">
         <xs:complexContent>
              <xs:extension base="Traject">
                   <xs:sequence>
                                 [some elements] 
                   </xs:sequence>
              </xs:extension>
         </xs:complexContent>
    </xs:complexType>My XML is an implementation of this XSD and looks like this
    <Trajecten>
            <Traject xsi:type="SpecialTraject">
                     [implementation of the elements]
             </Traject>
    </Trajecten>My domain model corresponts to the XSD, so there is a Traject object and an inherited SpecialTraject object.
    In the mapping I used the Advanced properties->inheritance on both descriptors telling the Traject descriptor that it was the 'Root Parent Descriptor' ('Use class indicator field' -> 'use XML Schema Type attribute', 'Use class indicator dictionary') and the SpecialTraject what it Child Descriptor was ('Traject').
    When I test my mapping it always results in the same error (no matter how I configure this inheritance mapping). It says :
    [TOPLINK-44] missing class indicator field
    Descriptor: XMLDescriptor(Traject --> [])What am I doing wrong? Does anybody know a sollution?
    Best regards,
    Jouke Stoel
    Developer

    This is the changed XML descriptor file. When I deploy the file it automaticly overrides the old file so it ain't possible that I was still using the wrong file
    <toplink:class-indicator-mappings>
        <toplink:class-indicator-mapping>
            <toplink:class>Traject</toplink:class>
            <toplink:class-indicator xsi:type="xsd:string">Traject</toplink:class-indicator>
        </toplink:class-indicator-mapping>
        <toplink:class-indicator-mapping>
            <toplink:class>SpecialTraject</toplink:class>
            <toplink:class-indicator xsi:type="xsd:string">SpecialTraject</toplink:class-indicator>
        </toplink:class-indicator-mapping>
    </toplink:class-indicator-mappings>I have posted the stacktrace but I had to translate a bit because my exception was in Dutch :)
    Locale is a great invention
    Exception [TOPLINK-44] (Oracle TopLink - 10g Release 3 (10.1.3.1.0) (Build 061004)): oracle.toplink.exceptions.DescriptorException
    Exception description: Missing class indicator field of database row [UnmarshalRecord()].
    Descriptor: XMLDescriptor(Traject --> [])
         at oracle.toplink.exceptions.DescriptorException.missingClassIndicatorField(DescriptorException.java:887)
         at oracle.toplink.internal.ox.QNameInheritancePolicy.classFromRow(QNameInheritancePolicy.java:84)
         at oracle.toplink.internal.ox.XMLRelationshipMappingNodeValue.processChild(XMLRelationshipMappingNodeValue.java:13)
         at oracle.toplink.internal.ox.XMLCompositeCollectionMappingNodeValue.startElement(XMLCompositeCollectionMappingNodeValue.java:62)
         at oracle.toplink.ox.record.UnmarshalRecord.startElement(UnmarshalRecord.java:352)
         at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1288)
         at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:336)
         at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:303)
         at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:205)
         at oracle.toplink.internal.ox.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:189)
         at oracle.toplink.internal.ox.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:147)
         at oracle.toplink.ox.XMLUnmarshaller.unmarshal(XMLUnmarshaller.java:228)
    .

  • Real Estate Indicator use in Asset Class

    Hi
    I would like to know what is the use of Real Estate Indicator in Asset Class.
    Thanks.

    Hi
    If u select assect indicator in asset class and after some of the settings in real estate module.  whenever  you create asset by using this asset class, system will create real estate object directly.
    Don't forge to assign points.
    Regards.

  • Using Inheritance,dose child class have father 's inner class?

    using Inheritance,dose child class have father 's inner class?

    as near as I can tell, the conversation so far has been:
    When I extend a class, does the subclass inherit the parent class's inner classes?
    followed by
    Never mind, i ran a test and found out the answer, sorry for my English.
    hope that helped.
    Lee

  • Using Timer and TimerTask classes in EJB's(J2EE)

    Does J2EE allow us to use Timer and TimerTask classes from java.util package in SessionBean EJB's ( Statless or Statefull )?.
    If J2EE does allow, I am not sure how things work in practical, Lets take simple example where a stateless SessionBean creates a Timer class
    and schedules a task to be executed after 5 hours and returns. Assuming
    GC kicks in many times in 5 hours, I wonder if the Timer object created by survives the GC run's so that it can execute the scheduled tasks.
    My gut feeling says that the Timer Object will not survive.. Just
    want to confirm that.
    I will be interested to know If there are any techiniques that can make
    the usage of Timer and TimeTask classes in EJB's possible as well as reliable with minmum impact on over all performance.

    Have a look at J2EE 1.4. I think they add a timer service for EJBs there...
    Kai

  • How to use the Rectangle class to draw an image and center it in a JPanel

    I sent an earlier post on how to center an image in a JPanel using the Rectangle class. I was asked to send an executable code which will show the malfunction. The code below is an executable code and a small part of a very big project. To simplifiy things, it is just a JFrame and a JPanel with an open dialog. Once executed the JFrame and the FileDialog will open. You can then navigate to a .gif or a .jpg picture and open it. What I want is for the picture to be centered in the middle of the JPanel and not the upper left corner. It is also important to stress that, I am usinig the Rectangle class to draw the Image. The region of interest is where the rectangle is created. In the constructor of the CenterRect class, I initialize the Rectangle class. Then I use paintComponent in the CenterRect class to draw the Image. The other classes are just support classes. The MyImage class is an extended image class which also has a draw() method. Any assistance in getting the Rectangle to show at the center of the JPanel without affecting the size and shape of the image will be greatly appreciated.
    I have divided the code into three parts. They are all supposed to be on one file in order to execute.
    import java.awt.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class CenterRect extends JPanel {
        public static Rectangle srcRect;
        Insets insets = null;
        Image image;
        MyImage imp;
        private double magnification;
        private int dstWidth, dstHeight;
        public CenterRect(MyImage imp){
            insets = getInsets();
            this.imp = imp;
            int width = imp.getWidth();
            int height = imp.getHeight();
            ImagePanel.init();
            srcRect = new Rectangle(0,0, width, height);
            srcRect.setLocation(0,0);
            setDrawingSize(width, height);
            magnification = 1.0;
        public void setDrawingSize(int width, int height) {
            dstWidth = width;
            dstHeight = height;
            setSize(dstWidth, dstHeight);
        public void paintComponent(Graphics g) {
            Image img = imp.getImage();
         try {
                if (img!=null)
                    g.drawImage(img,0,0, (int)(srcRect.width*magnification), (int)(srcRect.height*magnification),
              srcRect.x, srcRect.y, srcRect.x+srcRect.width, srcRect.y+srcRect.height, null);
            catch(OutOfMemoryError e) {e.printStackTrace();}
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new Opener().openImage();
    class Opener{
        private String dir;
        private String name;
        private static String defaultDirectory;
        JFrame parent;
        public Opener() {
            initComponents();
         public void initComponents(){
            parent = new JFrame();
            parent.setContentPane(ImagePanel.panel);
            parent.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            parent.setExtendedState(JFrame.MAXIMIZED_BOTH);
            parent.setVisible(true);
        public void openDialog(String title, String path){
            if (path==null || path.equals("")) {
                FileDialog fd = new FileDialog(parent, title);
                defaultDirectory = "dir.image";
                if (defaultDirectory!=null)
                    fd.setDirectory(defaultDirectory);
                fd.setVisible(true);
                name = fd.getFile();
                if (name!=null) {
                    dir = fd.getDirectory();
                    defaultDirectory = dir;
                fd.dispose();
                if (parent==null)
                    return;
            } else {
                int i = path.lastIndexOf('/');
                if (i==-1)
                    i = path.lastIndexOf('\\');
                if (i>0) {
                    dir = path.substring(0, i+1);
                    name = path.substring(i+1);
                } else {
                    dir = "";
                    name = path;
        public MyImage openImage(String directory, String name) {
            MyImage imp = openJpegOrGif(dir, name);
            return imp;
        public void openImage() {
            openDialog("Open...", "");
            String directory = dir;
            String name = this.name;
            if (name==null)
                return;
            MyImage imp = openImage(directory, name);
            if (imp!=null) imp.show();
        MyImage openJpegOrGif(String dir, String name) {
                MyImage imp = null;
                Image img = Toolkit.getDefaultToolkit().getImage(dir+name);
                if (img!=null) {
                    imp = new MyImage(name, img);
                    FileInfo fi = new FileInfo();
                    fi.fileFormat = fi.GIF_OR_JPG;
                    fi.fileName = name;
                    fi.directory = dir;
                    imp.setFileInfo(fi);
                return imp;
    }

    This is the second part. It is a continuation of the first part. They are all supposed to be on one file.
    class MyImage implements ImageObserver{
        private int imageUpdateY, imageUpdateW,width,height;
        private boolean imageLoaded;
        private static int currentID = -1;
        private int ID;
        private static Component comp;
        protected ImageProcessor ip;
        private String title;
        protected Image img;
        private static int xbase = -1;
        private static int ybase,xloc,yloc;
        private static int count = 0;
        private static final int XINC = 8;
        private static final int YINC = 12;
        private int originalScale = 1;
        private FileInfo fileInfo;
        ImagePanel win;
        /** Constructs an ImagePlus from an AWT Image. The first argument
         * will be used as the title of the window that displays the image. */
        public MyImage(String title, Image img) {
            this.title = title;
             ID = --currentID;
            if (img!=null)
                setImage(img);
        public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h) {
             imageUpdateY = y;
             imageUpdateW = w;
             imageLoaded = (flags & (ALLBITS|FRAMEBITS|ABORT)) != 0;
         return !imageLoaded;
        public int getWidth() {
             return width;
        public int getHeight() {
             return height;
        /** Replaces the ImageProcessor, if any, with the one specified.
         * Set 'title' to null to leave the image title unchanged. */
        public void setProcessor(String title, ImageProcessor ip) {
            if (title!=null) this.title = title;
            this.ip = ip;
            img = ip.createImage();
            boolean newSize = width!=ip.getWidth() || height!=ip.getHeight();
         width = ip.getWidth();
         height = ip.getHeight();
         if (win!=null && newSize) {
                win = new ImagePanel(this);
        public void draw(){
            CenterRect ic = null;
            win = new ImagePanel(this);
            if (win!=null){
                win.addIC(this);
                win.getCanvas().repaint();
                ic = win .getCanvas();
                win.panel.add(ic);
                int width = win.imp.getWidth();
                int height = win.imp.getHeight();
                Point ijLoc = new Point(10,32);
                if (xbase==-1) {
                    xbase = 5;
                    ybase = ijLoc.y;
                    xloc = xbase;
                    yloc = ybase;
                if ((xloc+width)>ijLoc.x && yloc<(ybase+20))
                    yloc = ybase+20;
                    int x = xloc;
                    int y = yloc;
                    xloc += XINC;
                    yloc += YINC;
                    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
                    count++;
                    if (count%6==0) {
                        xloc = xbase;
                        yloc = ybase;
                    int scale = 1;
                    while (xbase+XINC*4+width/scale>screen.width || ybase+YINC*4+height/scale>screen.height)
                        if (scale>1) {
                   originalScale = scale;
                   ic.setDrawingSize(width/scale, height/scale);
        /** Returns the current AWT image. */
        public Image getImage() {
            if (img==null && ip!=null)
                img = ip.createImage();
            return img;
        /** Replaces the AWT image, if any, with the one specified. */
        public void setImage(Image img) {
            waitForImage(img);
            this.img = img;
            JPanel panel = ImagePanel.panel;
            width = img.getWidth(panel);
            height = img.getHeight(panel);
            ip = null;
        /** Opens a window to display this image and clears the status bar. */
        public void show() {
            show("");
        /** Opens a window to display this image and displays
         * 'statusMessage' in the status bar. */
        public void show(String statusMessage) {
            if (img==null && ip!=null){
                img = ip.createImage();
            if ((img!=null) && (width>=0) && (height>=0)) {
                win = new ImagePanel(this);
                draw();
        private void waitForImage(Image img) {
        if (comp==null) {
            comp = ImagePanel.panel;
            if (comp==null)
                comp = new JPanel();
        imageLoaded = false;
        if (!comp.prepareImage(img, this)) {
            double progress;
            while (!imageLoaded) {
                if (imageUpdateW>1) {
                    progress = (double)imageUpdateY/imageUpdateW;
                    if (!(progress<1.0)) {
                        progress = 1.0 - (progress-1.0);
                        if (progress<0.0) progress = 0.9;
    public void setFileInfo(FileInfo fi) {
        fi.pixels = null;
        fileInfo = fi;
    }

  • When I use Firefox and Hotmail at startup, Firefox freezes for about 1 minute, and then I can continue. First I though it was my computer but 2 other girls in my class have the same problem with Hotmail and Firefox. What can I do to change this?

    When I start Firefox, about 15 seconds after I start it, my Firefox freezes for about 1 minute. I found out that it is my Hotmail that makes Firefox freeze.
    First I thought it was my computer, but I have 2 other girls in my class that use Hotmail and Firefox and their computer also freezes for 1 full minute.
    This is very annoying, what can I do to change this?
    xxx ellen
    p.s. I am from the Netherlands, maybe that has something to do with it?

    Try deleting cookies and cache:
    1. Tools| Clear recent history
    2. Time range to clear: Everything
    3. If it isn't already selected, select '''Cookies''' and '''Cache'''
    4. '''Clear now'''
    '''Check cookie exceptions'''
    1. Tools | Options | Privacy Panel
    2. Set '''Firefox will: Use custom settings for history.''' '''Insure Accept cookies for sites and accept third-party cookies''' is selected
    3. Click '''Exceptions'''. If the misbehaving site is in that list, select it and click '''Remove site'''
    '''Safe Mode'''
    Add-ons can cause problems with not being able to log into certain websites. To see if this is the case with your issue, run [[Safe mode]]. When you get to the safe mode window, select Continue in Safe Mode. If this resolves your problem, see [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]
    Also see [[Updating Firefox]] and [[Cannot log in to websites]]

Maybe you are looking for